mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 15:31:39 +00:00
gl_draw.c: fixed several strict aliasing violations about glpic_t.
git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@56 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
80346daacf
commit
3766cbbb92
1 changed files with 36 additions and 33 deletions
|
@ -215,12 +215,11 @@ Draw_PicFromWad
|
|||
qpic_t *Draw_PicFromWad (char *name)
|
||||
{
|
||||
qpic_t *p;
|
||||
glpic_t *gl;
|
||||
glpic_t gl;
|
||||
src_offset_t offset; //johnfitz
|
||||
|
||||
p = W_GetLumpName (name);
|
||||
if (!p) return pic_nul; //johnfitz
|
||||
gl = (glpic_t *)p->data;
|
||||
|
||||
// load little ones into the scrap
|
||||
if (p->width < 64 && p->height < 64)
|
||||
|
@ -233,14 +232,16 @@ qpic_t *Draw_PicFromWad (char *name)
|
|||
scrap_dirty = true;
|
||||
k = 0;
|
||||
for (i=0 ; i<p->height ; i++)
|
||||
{
|
||||
for (j=0 ; j<p->width ; j++, k++)
|
||||
scrap_texels[texnum][(y+i)*BLOCK_WIDTH + x + j] = p->data[k];
|
||||
gl->gltexture = scrap_textures[texnum]; //johnfitz -- changed to an array
|
||||
}
|
||||
gl.gltexture = scrap_textures[texnum]; //johnfitz -- changed to an array
|
||||
//johnfitz -- no longer go from 0.01 to 0.99
|
||||
gl->sl = x/(float)BLOCK_WIDTH;
|
||||
gl->sh = (x+p->width)/(float)BLOCK_WIDTH;
|
||||
gl->tl = y/(float)BLOCK_WIDTH;
|
||||
gl->th = (y+p->height)/(float)BLOCK_WIDTH;
|
||||
gl.sl = x/(float)BLOCK_WIDTH;
|
||||
gl.sh = (x+p->width)/(float)BLOCK_WIDTH;
|
||||
gl.tl = y/(float)BLOCK_WIDTH;
|
||||
gl.th = (y+p->height)/(float)BLOCK_WIDTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -249,14 +250,16 @@ qpic_t *Draw_PicFromWad (char *name)
|
|||
|
||||
offset = (src_offset_t)p - (src_offset_t)wad_base + sizeof(int)*2; //johnfitz
|
||||
|
||||
gl->gltexture = TexMgr_LoadImage (NULL, texturename, p->width, p->height, SRC_INDEXED, p->data, WADFILENAME,
|
||||
gl.gltexture = TexMgr_LoadImage (NULL, texturename, p->width, p->height, SRC_INDEXED, p->data, WADFILENAME,
|
||||
offset, TEXPREF_ALPHA | TEXPREF_PAD | TEXPREF_NOPICMIP); //johnfitz -- TexMgr
|
||||
gl->sl = 0;
|
||||
gl->sh = (float)p->width/(float)TexMgr_PadConditional(p->width); //johnfitz
|
||||
gl->tl = 0;
|
||||
gl->th = (float)p->height/(float)TexMgr_PadConditional(p->height); //johnfitz
|
||||
gl.sl = 0;
|
||||
gl.sh = (float)p->width/(float)TexMgr_PadConditional(p->width); //johnfitz
|
||||
gl.tl = 0;
|
||||
gl.th = (float)p->height/(float)TexMgr_PadConditional(p->height); //johnfitz
|
||||
}
|
||||
|
||||
memcpy (p->data, &gl, sizeof(glpic_t));
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -270,7 +273,7 @@ qpic_t *Draw_CachePic (char *path)
|
|||
cachepic_t *pic;
|
||||
int i;
|
||||
qpic_t *dat;
|
||||
glpic_t *gl;
|
||||
glpic_t gl;
|
||||
|
||||
for (pic=menu_cachepics, i=0 ; i<menu_numcachepics ; pic++, i++)
|
||||
{
|
||||
|
@ -299,13 +302,13 @@ qpic_t *Draw_CachePic (char *path)
|
|||
pic->pic.width = dat->width;
|
||||
pic->pic.height = dat->height;
|
||||
|
||||
gl = (glpic_t *)pic->pic.data;
|
||||
gl->gltexture = TexMgr_LoadImage (NULL, path, dat->width, dat->height, SRC_INDEXED, dat->data, path,
|
||||
gl.gltexture = TexMgr_LoadImage (NULL, path, dat->width, dat->height, SRC_INDEXED, dat->data, path,
|
||||
sizeof(int)*2, TEXPREF_ALPHA | TEXPREF_PAD | TEXPREF_NOPICMIP); //johnfitz -- TexMgr
|
||||
gl->sl = 0;
|
||||
gl->sh = (float)dat->width/(float)TexMgr_PadConditional(dat->width); //johnfitz
|
||||
gl->tl = 0;
|
||||
gl->th = (float)dat->height/(float)TexMgr_PadConditional(dat->height); //johnfitz
|
||||
gl.sl = 0;
|
||||
gl.sh = (float)dat->width/(float)TexMgr_PadConditional(dat->width); //johnfitz
|
||||
gl.tl = 0;
|
||||
gl.th = (float)dat->height/(float)TexMgr_PadConditional(dat->height); //johnfitz
|
||||
memcpy (pic->pic.data, &gl, sizeof(glpic_t));
|
||||
|
||||
return &pic->pic;
|
||||
}
|
||||
|
@ -325,7 +328,7 @@ qpic_t *Draw_ConbackPic (void)
|
|||
cachepic_t *pic;
|
||||
int i;
|
||||
qpic_t *dat;
|
||||
glpic_t *gl;
|
||||
glpic_t gl;
|
||||
|
||||
for (pic=menu_cachepics, i=0 ; i<menu_numcachepics ; pic++, i++)
|
||||
{
|
||||
|
@ -341,14 +344,14 @@ qpic_t *Draw_ConbackPic (void)
|
|||
SwapPic (dat);
|
||||
pic->pic.width = dat->width;
|
||||
pic->pic.height = dat->height;
|
||||
gl = (glpic_t *)pic->pic.data;
|
||||
gl->gltexture = TexMgr_LoadImage (NULL, "gfx/conback.lmp", dat->width, dat->height, SRC_INDEXED, dat->data,
|
||||
gl.gltexture = TexMgr_LoadImage (NULL, "gfx/conback.lmp", dat->width, dat->height, SRC_INDEXED, dat->data,
|
||||
"", (src_offset_t)dat->data,
|
||||
TEXPREF_ALPHA | TEXPREF_PAD | TEXPREF_NOPICMIP); //johnfitz -- TexMgr
|
||||
gl->sl = 0;
|
||||
gl->sh = (float)dat->width/(float)TexMgr_PadConditional(dat->width); //johnfitz
|
||||
gl->tl = 0;
|
||||
gl->th = (float)dat->height/(float)TexMgr_PadConditional(dat->height); //johnfitz
|
||||
gl.sl = 0;
|
||||
gl.sh = (float)dat->width/(float)TexMgr_PadConditional(dat->width); //johnfitz
|
||||
gl.tl = 0;
|
||||
gl.th = (float)dat->height/(float)TexMgr_PadConditional(dat->height); //johnfitz
|
||||
memcpy (pic->pic.data, &gl, sizeof(glpic_t));
|
||||
|
||||
return &pic->pic;
|
||||
} /* -- QuakeSpasm */
|
||||
|
@ -363,18 +366,18 @@ qpic_t *Draw_MakePic (char *name, int width, int height, byte *data)
|
|||
{
|
||||
int flags = TEXPREF_NEAREST | TEXPREF_ALPHA | TEXPREF_PERSIST | TEXPREF_NOPICMIP | TEXPREF_PAD;
|
||||
qpic_t *pic;
|
||||
glpic_t *gl;
|
||||
glpic_t gl;
|
||||
|
||||
pic = Hunk_Alloc (sizeof(qpic_t) - 4 + sizeof (glpic_t));
|
||||
pic->width = width;
|
||||
pic->height = height;
|
||||
|
||||
gl = (glpic_t *)pic->data;
|
||||
gl->gltexture = TexMgr_LoadImage (NULL, name, width, height, SRC_INDEXED, data, "", (src_offset_t)data, flags);
|
||||
gl->sl = 0;
|
||||
gl->sh = (float)width/(float)TexMgr_PadConditional(width);
|
||||
gl->tl = 0;
|
||||
gl->th = (float)height/(float)TexMgr_PadConditional(height);
|
||||
gl.gltexture = TexMgr_LoadImage (NULL, name, width, height, SRC_INDEXED, data, "", (src_offset_t)data, flags);
|
||||
gl.sl = 0;
|
||||
gl.sh = (float)width/(float)TexMgr_PadConditional(width);
|
||||
gl.tl = 0;
|
||||
gl.th = (float)height/(float)TexMgr_PadConditional(height);
|
||||
memcpy (pic->data, &gl, sizeof(glpic_t));
|
||||
|
||||
return pic;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue