mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
r_shadows: Better stencil shadow rendering from MarkV.
Now an 8-bit stencil buffer is requested when using a 24-bit depth buffer (the default). git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1209 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
93a442003a
commit
2e2b110ecb
2 changed files with 32 additions and 2 deletions
|
@ -852,6 +852,15 @@ void R_DrawShadows (void)
|
||||||
if (!r_shadows.value || !r_drawentities.value || r_drawflat_cheatsafe || r_lightmap_cheatsafe)
|
if (!r_shadows.value || !r_drawentities.value || r_drawflat_cheatsafe || r_lightmap_cheatsafe)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Use stencil buffer to prevent self-intersecting shadows, from Baker (MarkV)
|
||||||
|
if (gl_stencilbits)
|
||||||
|
{
|
||||||
|
glClear(GL_STENCIL_BUFFER_BIT);
|
||||||
|
glStencilFunc(GL_EQUAL, 0, ~0);
|
||||||
|
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
|
||||||
|
glEnable(GL_STENCIL_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0 ; i<cl_numvisedicts ; i++)
|
for (i=0 ; i<cl_numvisedicts ; i++)
|
||||||
{
|
{
|
||||||
currententity = cl_visedicts[i];
|
currententity = cl_visedicts[i];
|
||||||
|
@ -864,6 +873,11 @@ void R_DrawShadows (void)
|
||||||
|
|
||||||
GL_DrawAliasShadow (currententity);
|
GL_DrawAliasShadow (currententity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gl_stencilbits)
|
||||||
|
{
|
||||||
|
glDisable(GL_STENCIL_TEST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -536,7 +536,7 @@ static qboolean VID_SetMode (int width, int height, int bpp, qboolean fullscreen
|
||||||
int temp;
|
int temp;
|
||||||
Uint32 flags;
|
Uint32 flags;
|
||||||
char caption[50];
|
char caption[50];
|
||||||
int depthbits;
|
int depthbits, stencilbits;
|
||||||
int fsaa_obtained;
|
int fsaa_obtained;
|
||||||
|
|
||||||
// so Con_Printfs don't mess us up by forcing vid and snd updates
|
// so Con_Printfs don't mess us up by forcing vid and snd updates
|
||||||
|
@ -548,9 +548,17 @@ static qboolean VID_SetMode (int width, int height, int bpp, qboolean fullscreen
|
||||||
|
|
||||||
/* z-buffer depth */
|
/* z-buffer depth */
|
||||||
if (bpp == 16)
|
if (bpp == 16)
|
||||||
|
{
|
||||||
depthbits = 16;
|
depthbits = 16;
|
||||||
else depthbits = 24;
|
stencilbits = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
depthbits = 24;
|
||||||
|
stencilbits = 8;
|
||||||
|
}
|
||||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, depthbits);
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, depthbits);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, stencilbits);
|
||||||
|
|
||||||
/* fsaa */
|
/* fsaa */
|
||||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, fsaa > 0 ? 1 : 0);
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, fsaa > 0 ? 1 : 0);
|
||||||
|
@ -574,6 +582,10 @@ static qboolean VID_SetMode (int width, int height, int bpp, qboolean fullscreen
|
||||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
|
||||||
draw_context = SDL_CreateWindow (caption, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags);
|
draw_context = SDL_CreateWindow (caption, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags);
|
||||||
}
|
}
|
||||||
|
if (!draw_context) { // scale back SDL_GL_STENCIL_SIZE
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
|
||||||
|
draw_context = SDL_CreateWindow (caption, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags);
|
||||||
|
}
|
||||||
if (!draw_context)
|
if (!draw_context)
|
||||||
Sys_Error ("Couldn't create window");
|
Sys_Error ("Couldn't create window");
|
||||||
|
|
||||||
|
@ -631,6 +643,10 @@ static qboolean VID_SetMode (int width, int height, int bpp, qboolean fullscreen
|
||||||
if (!draw_context) { // scale back SDL_GL_DEPTH_SIZE
|
if (!draw_context) { // scale back SDL_GL_DEPTH_SIZE
|
||||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
|
||||||
draw_context = SDL_SetVideoMode(width, height, bpp, flags);
|
draw_context = SDL_SetVideoMode(width, height, bpp, flags);
|
||||||
|
}
|
||||||
|
if (!draw_context) { // scale back SDL_GL_STENCIL_SIZE
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
|
||||||
|
draw_context = SDL_SetVideoMode(width, height, bpp, flags);
|
||||||
if (!draw_context)
|
if (!draw_context)
|
||||||
Sys_Error ("Couldn't set video mode");
|
Sys_Error ("Couldn't set video mode");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue