diff options
author | Mathias Fröhlich <[email protected]> | 2014-09-21 18:09:21 +0200 |
---|---|---|
committer | Mathias Fröhlich <[email protected]> | 2014-10-24 19:21:20 +0200 |
commit | 6340e609a354770e04192b9b44e91fb06aab0159 (patch) | |
tree | a23faaf3f456f4775efd556e2701ad07021ff1b4 /src/mesa/state_tracker | |
parent | 8c7ac377b7a859705479a0b421d1dacc53ca240a (diff) |
mesa: Refactor viewport transform computation.
This is for preparation of ARB_clip_control.
v3:
Add comments.
Reviewed-by: Brian Paul <[email protected]>
Signed-off-by: Mathias Froehlich <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_atom_viewport.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/mesa/state_tracker/st_atom_viewport.c b/src/mesa/state_tracker/st_atom_viewport.c index 7584f9b3d55..5b992084bd5 100644 --- a/src/mesa/state_tracker/st_atom_viewport.c +++ b/src/mesa/state_tracker/st_atom_viewport.c @@ -27,6 +27,7 @@ #include "main/context.h" +#include "main/viewport.h" #include "st_context.h" #include "st_atom.h" #include "pipe/p_context.h" @@ -63,21 +64,17 @@ update_viewport( struct st_context *st ) */ for (i = 0; i < ctx->Const.MaxViewports; i++) { - GLfloat x = ctx->ViewportArray[i].X; - GLfloat y = ctx->ViewportArray[i].Y; - GLfloat z = ctx->ViewportArray[i].Near; - GLfloat half_width = ctx->ViewportArray[i].Width * 0.5f; - GLfloat half_height = ctx->ViewportArray[i].Height * 0.5f; - GLfloat half_depth = (GLfloat)(ctx->ViewportArray[i].Far - ctx->ViewportArray[i].Near) * 0.5f; - - st->state.viewport[i].scale[0] = half_width; - st->state.viewport[i].scale[1] = half_height * yScale; - st->state.viewport[i].scale[2] = half_depth; + double scale[3], translate[3]; + _mesa_get_viewport_xform(ctx, i, scale, translate); + + st->state.viewport[i].scale[0] = scale[0]; + st->state.viewport[i].scale[1] = scale[1] * yScale; + st->state.viewport[i].scale[2] = scale[2]; st->state.viewport[i].scale[3] = 1.0; - st->state.viewport[i].translate[0] = half_width + x; - st->state.viewport[i].translate[1] = (half_height + y) * yScale + yBias; - st->state.viewport[i].translate[2] = half_depth + z; + st->state.viewport[i].translate[0] = translate[0]; + st->state.viewport[i].translate[1] = translate[1] * yScale + yBias; + st->state.viewport[i].translate[2] = translate[2]; st->state.viewport[i].translate[3] = 0.0; } |