From: Brian Paul Date: Mon, 22 Feb 2010 15:04:53 +0000 (-0700) Subject: st/mesa: change viewport Z scale/bias for glBitmap/glDrawPixels X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cfdd1ca69521446b5d937d95e7d8bfb27f6d68eb;p=mesa.git st/mesa: change viewport Z scale/bias for glBitmap/glDrawPixels This fixes incorrect Z position of glBitmap, glDraw/CopyPixels for the svga driver. Now we use 0.5, 0.5 as is typical for ordinary 3D rendering. (cherry picked from commit bcd561c66777e58dbb29a573c4d2279772bac6c5) --- diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 5968426a1d7..0332d4dbdfe 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -481,15 +481,18 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, struct pipe_viewport_state vp; vp.scale[0] = 0.5f * width; vp.scale[1] = height * (invert ? -0.5f : 0.5f); - vp.scale[2] = 1.0f; + vp.scale[2] = 0.5f; vp.scale[3] = 1.0f; vp.translate[0] = 0.5f * width; vp.translate[1] = 0.5f * height; - vp.translate[2] = 0.0f; + vp.translate[2] = 0.5f; vp.translate[3] = 0.0f; cso_set_viewport(cso, &vp); } + /* convert Z from [0,1] to [-1,-1] to match viewport Z scale/bias */ + z = z * 2.0 - 1.0; + /* draw textured quad */ offset = setup_bitmap_vertex_data(st, x, y, width, height, z, color); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 4e86450edf4..e9aee6b2058 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -572,11 +572,11 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, struct pipe_viewport_state vp; vp.scale[0] = 0.5f * w; vp.scale[1] = -0.5f * h; - vp.scale[2] = 1.0f; + vp.scale[2] = 0.5f; vp.scale[3] = 1.0f; vp.translate[0] = 0.5f * w; vp.translate[1] = 0.5f * h; - vp.translate[2] = 0.0f; + vp.translate[2] = 0.5f; vp.translate[3] = 0.0f; cso_set_viewport(cso, &vp); } @@ -601,6 +601,9 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, y0 = (GLfloat) y; y1 = y + height * ctx->Pixel.ZoomY; + /* convert Z from [0,1] to [-1,-1] to match viewport Z scale/bias */ + z = z * 2.0 - 1.0; + draw_quad(ctx, x0, y0, z, x1, y1, color, invertTex, (GLfloat) width / pt->width0, (GLfloat) height / pt->height0);