Go to the source code of this file.
Functions | |
static void | update_viewport (struct st_context *st) |
Update the viewport transformation matrix. | |
Variables | |
struct st_tracked_state | st_update_viewport |
static void update_viewport | ( | struct st_context * | st | ) | [static] |
Update the viewport transformation matrix.
Depends on:
Definition at line 43 of file st_atom_viewport.c.
References st_context::cso_context, cso_set_viewport(), st_context::ctx, pipe_viewport_state::scale, st_fb_orientation(), st_context::state, pipe_viewport_state::translate, st_context::viewport, and Y_0_TOP.
00044 { 00045 GLcontext *ctx = st->ctx; 00046 GLfloat yScale, yBias; 00047 00048 /* _NEW_BUFFERS 00049 */ 00050 if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) { 00051 yScale = -1; 00052 yBias = (GLfloat)ctx->DrawBuffer->Height; 00053 } 00054 else { 00055 yScale = 1.0; 00056 yBias = 0.0; 00057 } 00058 00059 /* _NEW_VIEWPORT 00060 */ 00061 { 00062 GLfloat x = (GLfloat)ctx->Viewport.X; 00063 GLfloat y = (GLfloat)ctx->Viewport.Y; 00064 GLfloat z = ctx->Viewport.Near; 00065 GLfloat half_width = (GLfloat)ctx->Viewport.Width / 2.0f; 00066 GLfloat half_height = (GLfloat)ctx->Viewport.Height / 2.0f; 00067 GLfloat half_depth = (GLfloat)(ctx->Viewport.Far - ctx->Viewport.Near) / 2.0f; 00068 00069 st->state.viewport.scale[0] = half_width; 00070 st->state.viewport.scale[1] = half_height * yScale; 00071 st->state.viewport.scale[2] = half_depth; 00072 st->state.viewport.scale[3] = 1.0; 00073 00074 st->state.viewport.translate[0] = half_width + x; 00075 st->state.viewport.translate[1] = (half_height + y) * yScale + yBias; 00076 st->state.viewport.translate[2] = half_depth + z; 00077 st->state.viewport.translate[3] = 0.0; 00078 00079 cso_set_viewport(st->cso_context, &st->state.viewport); 00080 } 00081 }
Initial value:
{ "st_update_viewport", { _NEW_BUFFERS | _NEW_VIEWPORT, 0, }, update_viewport }
Definition at line 84 of file st_atom_viewport.c.