* the fog frag coord is thrown away. If the fog frag coord is used, but not written by
* the shader, it is set to 0.0(fully fogged, since start = 1.0, end = 0.0)
*/
- if(args->super.fog_src == VS_FOG_Z) {
+ if (args->super.fog_src == VS_FOG_Z)
shader_addline(buffer, "MOV result.fogcoord, TMP_OUT.z;\n");
- } else if (!reg_maps->fog) {
- /* posFixup.x is always 1.0, so we can savely use it */
+ else if (!reg_maps->fog)
+ /* posFixup.x is always 1.0, so we can safely use it */
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");
- if(use_nv_clip(gl_info) && priv_ctx->target_version >= NV2)
+ /* Clipplanes are always stored without y inversion */
+ if (use_nv_clip(gl_info) && priv_ctx->target_version >= NV2)
{
- if(args->super.clip_enabled)
+ if (args->super.clip_enabled)
{
- for(i = 0; i < priv_ctx->vs_clipplanes; i++)
+ for (i = 0; i < priv_ctx->vs_clipplanes; i++)
{
shader_addline(buffer, "DP4 result.clip[%u].x, TMP_OUT, state.clip[%u].plane;\n", i, i);
}
}
}
- else if(args->clip.boolclip.clip_texcoord)
+ else if (args->clip.boolclip.clip_texcoord)
{
unsigned int cur_clip = 0;
char component[4] = {'x', 'y', 'z', 'w'};
for (i = 0; i < gl_info->limits.clipplanes; ++i)
{
- if(args->clip.boolclip.clipplane_mask & (1 << i))
+ if (args->clip.boolclip.clipplane_mask & (1 << i))
{
shader_addline(buffer, "DP4 TA.%c, TMP_OUT, state.clip[%u].plane;\n",
component[cur_clip++], i);
}
}
- switch(cur_clip)
+ switch (cur_clip)
{
case 0:
shader_addline(buffer, "MOV TA, %s;\n", zero);
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
*/
{
const char *two = arb_get_helper_value(WINED3D_SHADER_TYPE_VERTEX, ARB_TWO);
shader_addline(buffer, "MAD TMP_OUT.z, TMP_OUT.z, %s, -TMP_OUT.w;\n", two);
- } else {
+ }
+ else
+ {
shader_addline(buffer, "ADD TMP_OUT.z, TMP_OUT.z, TMP_OUT.z;\n");
shader_addline(buffer, "ADD TMP_OUT.z, TMP_OUT.z, -TMP_OUT.w;\n");
}
shader_addline(buffer, "#version 120\n");
if (gl_info->supported[EXT_GPU_SHADER4])
- {
shader_addline(buffer, "#extension GL_EXT_gpu_shader4 : enable\n");
- }
memset(&priv_ctx, 0, sizeof(priv_ctx));
priv_ctx.cur_vs_args = args;
* the fog frag coord is thrown away. If the fog frag coord is used, but not written by
* the shader, it is set to 0.0(fully fogged, since start = 1.0, end = 0.0)
*/
- if(args->fog_src == VS_FOG_Z) {
+ if (args->fog_src == VS_FOG_Z)
shader_addline(buffer, "gl_FogFragCoord = gl_Position.z;\n");
- } else if (!reg_maps->fog) {
+ else if (!reg_maps->fog)
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.
*
*/
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
*
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],