- // get tightest scissor rectangle that encloses all viewports in the clear mask
- int x1 = clear & 0x15 ? 0 : size;
- int x2 = clear & 0x2A ? 2 * size : size;
- int y1 = clear & 0x03 ? 0 : (clear & 0xC ? size : 2 * size);
- int y2 = clear & 0x30 ? 3 * size : (clear & 0xC ? 2 * size : size);
- GL_Scissor(x1, y1, x2 - x1, y2 - y1);
- GL_Clear(GL_DEPTH_BUFFER_BIT);
+ case RENDERPATH_GL11:
+ case RENDERPATH_GL13:
+ case RENDERPATH_GL20:
+ case RENDERPATH_CGGL:
+ GL_CullFace(r_refdef.view.cullface_back);
+ // OpenGL lets us scissor larger than the viewport, so go ahead and clear all views at once
+ if ((clear & ((2 << side) - 1)) == (1 << side)) // only clear if the side is the first in the mask
+ {
+ // get tightest scissor rectangle that encloses all viewports in the clear mask
+ int x1 = clear & 0x15 ? 0 : size;
+ int x2 = clear & 0x2A ? 2 * size : size;
+ int y1 = clear & 0x03 ? 0 : (clear & 0xC ? size : 2 * size);
+ int y2 = clear & 0x30 ? 3 * size : (clear & 0xC ? 2 * size : size);
+ GL_Scissor(x1, y1, x2 - x1, y2 - y1);
+ GL_Clear(GL_DEPTH_BUFFER_BIT, NULL, 1.0f, 0);
+ }
+ GL_Scissor(viewport.x, viewport.y, viewport.width, viewport.height);
+ break;
+ case RENDERPATH_D3D9:
+ // completely different meaning than in OpenGL path
+ r_shadow_shadowmap_parameters[1] = 0;
+ r_shadow_shadowmap_parameters[3] = -bias;
+ // we invert the cull mode because we flip the projection matrix
+ // NOTE: this actually does nothing because the DrawShadowMap code sets it to doublesided...
+ GL_CullFace(r_refdef.view.cullface_front);
+ // D3D considers it an error to use a scissor larger than the viewport... clear just this view
+ GL_Scissor(viewport.x, viewport.y, viewport.width, viewport.height);
+ if (r_shadow_shadowmapsampler)
+ {
+ GL_ColorMask(0,0,0,0);
+ if (clear)
+ GL_Clear(GL_DEPTH_BUFFER_BIT, testcolor, 1.0f, 0);
+ }
+ else
+ {
+ GL_ColorMask(1,1,1,1);
+ if (clear)
+ GL_Clear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT, testcolor, 1.0f, 0);
+ }
+ break;
+ case RENDERPATH_D3D10:
+ case RENDERPATH_D3D11:
+ // D3D considers it an error to use a scissor larger than the viewport... clear just this view
+ GL_Scissor(viewport.x, viewport.y, viewport.width, viewport.height);
+ GL_ColorMask(0,0,0,0);
+ if (clear)
+ GL_Clear(GL_DEPTH_BUFFER_BIT, NULL, 1.0f, 0);
+ break;