mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Make sure both software and OpenGL ignore patches that are completely out of a multi-patch texture's bounds.
This fixes OpenGL in particular crashing because of such a weird situation.
This commit is contained in:
parent
b1695de124
commit
bf88407d00
2 changed files with 25 additions and 2 deletions
|
@ -62,19 +62,31 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
|
|||
UINT8 texel;
|
||||
UINT16 texelu16;
|
||||
|
||||
if (!ptexturewidth)
|
||||
return;
|
||||
|
||||
x1 = originx;
|
||||
x2 = x1 + SHORT(realpatch->width);
|
||||
|
||||
if (x1 > ptexturewidth || x2 < 0)
|
||||
return; // patch not located within texture's x bounds, ignore
|
||||
|
||||
if (originy > ptextureheight || (originy + SHORT(realpatch->height)) < 0)
|
||||
return; // patch not located within texture's y bounds, ignore
|
||||
|
||||
// patch is actually inside the texture!
|
||||
// now check if texture is partly off-screen and adjust accordingly
|
||||
|
||||
// left edge
|
||||
if (x1 < 0)
|
||||
x = 0;
|
||||
else
|
||||
x = x1;
|
||||
|
||||
// right edge
|
||||
if (x2 > ptexturewidth)
|
||||
x2 = ptexturewidth;
|
||||
|
||||
if (!ptexturewidth)
|
||||
return;
|
||||
|
||||
col = x * pblockwidth / ptexturewidth;
|
||||
ncols = ((x2 - x) * pblockwidth) / ptexturewidth;
|
||||
|
|
11
src/r_data.c
11
src/r_data.c
|
@ -439,11 +439,22 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
|||
height = SHORT(realpatch->height);
|
||||
x2 = x1 + width;
|
||||
|
||||
if (x1 > texture->width || x2 < 0)
|
||||
continue; // patch not located within texture's x bounds, ignore
|
||||
|
||||
if (patch->originy > texture->height || (patch->originy + height) < 0)
|
||||
continue; // patch not located within texture's y bounds, ignore
|
||||
|
||||
// patch is actually inside the texture!
|
||||
// now check if texture is partly off-screen and adjust accordingly
|
||||
|
||||
// left edge
|
||||
if (x1 < 0)
|
||||
x = 0;
|
||||
else
|
||||
x = x1;
|
||||
|
||||
// right edge
|
||||
if (x2 > texture->width)
|
||||
x2 = texture->width;
|
||||
|
||||
|
|
Loading…
Reference in a new issue