Skip to content

Commit

Permalink
Calculate viewport and screen texture coordinates correctly for sun s…
Browse files Browse the repository at this point in the history
…hadows. This fixes part of #5889.
  • Loading branch information
SmileTheory committed Mar 5, 2013
1 parent e7753f9 commit 2153fc4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions code/renderergl2/tr_backend.c
Expand Up @@ -1186,17 +1186,17 @@ const void *RB_DrawSurfs( const void *data ) {
FBO_Bind(tr.screenShadowFbo);

box[0] = (backEnd.refdef.x ) * tr.screenShadowFbo->width / (float)glConfig.vidWidth;
box[1] = (backEnd.refdef.y ) * tr.screenShadowFbo->height / (float)glConfig.vidHeight;
box[1] = (glConfig.vidHeight - ( backEnd.refdef.y + backEnd.refdef.height )) * tr.screenShadowFbo->height / (float)glConfig.vidHeight;
box[2] = (backEnd.refdef.width ) * tr.screenShadowFbo->width / (float)glConfig.vidWidth;
box[3] = (backEnd.refdef.height) * tr.screenShadowFbo->height / (float)glConfig.vidHeight;

qglViewport(box[0], box[1], box[2], box[3]);
qglScissor(box[0], box[1], box[2], box[3]);

box[0] = (backEnd.refdef.x ) / (float)glConfig.vidWidth;
box[1] = (backEnd.refdef.y ) / (float)glConfig.vidHeight;
box[1] = 1.0 - (backEnd.refdef.y + backEnd.refdef.height) / (float)glConfig.vidHeight;
box[2] = (backEnd.refdef.x + backEnd.refdef.width ) / (float)glConfig.vidWidth;
box[3] = (backEnd.refdef.y + backEnd.refdef.height) / (float)glConfig.vidHeight;
box[3] = 1.0 - (backEnd.refdef.y ) / (float)glConfig.vidHeight;

texCoords[0][0] = box[0]; texCoords[0][1] = box[3];
texCoords[1][0] = box[2]; texCoords[1][1] = box[3];
Expand Down

1 comment on commit 2153fc4

@timangus
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.0 should be 1.0f. Otherwise you induce a lot of needless implicit double/float casting.

Please sign in to comment.