diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 101de6d..d2734d0 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -3118,17 +3118,7 @@ static void vshader_add_footer(struct shader_arb_ctx_priv *priv_ctx, shader_addline(buffer, "ADD result.fogcoord, posFixup.x, -posFixup.x;\n"); } - /* Write the final position. - * - * OpenGL coordinates specify the center of the pixel while d3d coords specify - * the corner. The offsets are stored in z and w in posFixup. posFixup.y contains - * 1.0 or -1.0 to turn the rendering upside down for offscreen rendering. PosFixup.x - * contains 1.0 to allow a mad, but arb vs swizzles are too restricted for that. - */ - shader_addline(buffer, "MUL TA, posFixup, TMP_OUT.w;\n"); - shader_addline(buffer, "ADD TMP_OUT.x, TMP_OUT.x, TA.z;\n"); - shader_addline(buffer, "MAD TMP_OUT.y, TMP_OUT.y, posFixup.y, TA.w;\n"); - + /* Clipplanes are always stored without y inversion */ if(use_nv_clip(gl_info) && priv_ctx->target_version >= NV2) { if(args->super.clip_enabled) @@ -3172,6 +3162,17 @@ static void vshader_add_footer(struct shader_arb_ctx_priv *priv_ctx, args->clip.boolclip.clip_texcoord - 1); } + /* Write the final position. + * + * OpenGL coordinates specify the center of the pixel while d3d coords specify + * the corner. The offsets are stored in z and w in posFixup. posFixup.y contains + * 1.0 or -1.0 to turn the rendering upside down for offscreen rendering. PosFixup.x + * contains 1.0 to allow a mad, but arb vs swizzles are too restricted for that. + */ + shader_addline(buffer, "MUL TA, posFixup, TMP_OUT.w;\n"); + shader_addline(buffer, "ADD TMP_OUT.x, TMP_OUT.x, TA.z;\n"); + shader_addline(buffer, "MAD TMP_OUT.y, TMP_OUT.y, posFixup.y, TA.w;\n"); + /* Z coord [0;1]->[-1;1] mapping, see comment in transform_projection in state.c * and the glsl equivalent */ diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index efd6d55..f984c96 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -4106,6 +4106,11 @@ static GLuint shader_glsl_generate_vshader(const struct wined3d_context *context shader_addline(buffer, "gl_FogFragCoord = 0.0;\n"); } + /* We always store the clipplanes without y inversion */ + if(args->clip_enabled) { + shader_addline(buffer, "gl_ClipVertex = gl_Position;\n"); + } + /* Write the final position. * * OpenGL coordinates specify the center of the pixel while d3d coords specify @@ -4115,9 +4120,6 @@ static GLuint shader_glsl_generate_vshader(const struct wined3d_context *context */ shader_addline(buffer, "gl_Position.y = gl_Position.y * posFixup.y;\n"); shader_addline(buffer, "gl_Position.xy += posFixup.zw * gl_Position.ww;\n"); - if(args->clip_enabled) { - shader_addline(buffer, "gl_ClipVertex = gl_Position;\n"); - } /* Z coord [0;1]->[-1;1] mapping, see comment in transform_projection in state.c * diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index a34ac4f..34ceff2 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -3798,24 +3798,18 @@ static void clipplane(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct return; } + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + /* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */ if (!use_vs(state)) - { - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); glLoadMatrixf(&state->transforms[WINED3DTS_VIEW].u.m[0][0]); - } else - { /* with vertex shaders, clip planes are not transformed in direct3d, * in OpenGL they are still transformed by the model view. * Use this to swap the y coordinate if necessary */ - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); glLoadIdentity(); - if (context->render_offscreen) glScalef(1.0f, -1.0f, 1.0f); - } TRACE("Clipplane [%.8e, %.8e, %.8e, %.8e]\n", state->clip_planes[index][0],