It is now possible to use 32bpp textures. It's not currently possible to

load them.  That comes later.
This commit is contained in:
Joseph Carter 2000-06-23 08:43:32 +00:00
parent 8a40786b66
commit 957068392d
3 changed files with 27 additions and 12 deletions

View file

@ -86,7 +86,7 @@ extern float gldepthmin, gldepthmax;
void GL_Upload32 (unsigned *data, int width, int height, qboolean mipmap, qboolean alpha);
void GL_Upload8 (byte *data, int width, int height, qboolean mipmap, qboolean alpha);
void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboolean alpha);
int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha);
int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha, int bytesperpixel);
int GL_FindTexture (char *identifier);
typedef struct

View file

@ -114,6 +114,7 @@ typedef struct
int texnum;
char identifier[64];
int width, height;
int bytesperpixel;
qboolean mipmap;
int crc; // not really a standard CRC, but it works
} gltexture_t;
@ -413,9 +414,9 @@ void Draw_Init (void)
draw_chars[i] = 255; // proper transparent color
// now turn them into textures
char_texture = GL_LoadTexture ("charset", 128, 128, draw_chars, false, true);
char_texture = GL_LoadTexture ("charset", 128, 128, draw_chars, false, true, 1);
// Draw_CrosshairAdjust();
cs_texture = GL_LoadTexture ("crosshair", 8, 8, cs_data, false, true);
cs_texture = GL_LoadTexture ("crosshair", 8, 8, cs_data, false, true, 1);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@ -1321,7 +1322,7 @@ static unsigned trans[640*480]; // FIXME, temporary
GL_LoadTexture
================
*/
int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha)
int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha, int bytesperpixel)
{
int i;
int s;
@ -1330,7 +1331,7 @@ int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolea
// LordHavoc's cache check, not a standard crc but it works --KB
lcrc = 0;
s = width*height; // size
s = width*height*bytesperpixel; // size
for (i = 0; i < 256; i++)
ltexcrctable[i] = i + 1;
for (i = 0; i < s; i++)
@ -1345,7 +1346,8 @@ int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolea
{
if (lcrc != glt->crc
|| width != glt->width
|| height != glt->height)
|| height != glt->height
|| bytesperpixel != glt->bytesperpixel)
goto SetupTexture;
else
return gltextures[i].texnum;
@ -1364,15 +1366,28 @@ SetupTexture:
glt->crc = lcrc;
glt->width = width;
glt->height = height;
glt->bytesperpixel = bytesperpixel;
glt->mipmap = mipmap;
glBindTexture (GL_TEXTURE_2D, glt->texnum);
GL_Upload8 (data, width, height, mipmap, alpha);
switch (glt->bytesperpixel)
{
case 1:
GL_Upload8 (data, width, height, mipmap, alpha);
break;
case 4:
GL_Upload32 ((unsigned *)data, width, height, mipmap, alpha);
break;
default:
Sys_Error ("SetupTexture: unknown bytesperpixel %i",
glt->bytesperpixel);
}
return glt->texnum;
}
/*
================
GL_LoadPicTexture
@ -1380,7 +1395,7 @@ GL_LoadPicTexture
*/
int GL_LoadPicTexture (qpic_t *pic)
{
return GL_LoadTexture ("", pic->width, pic->height, pic->data, false, true);
return GL_LoadTexture ("", pic->width, pic->height, pic->data, false, true, 1);
}
/****************************************/

View file

@ -1313,7 +1313,7 @@ void
Mod_LoadMMNearest(miptex_t *mt, texture_t *tx)
{
texture_mode = GL_LINEAR_MIPMAP_NEAREST; //_LINEAR;
tx->gl_texturenum = GL_LoadTexture (mt->name, tx->width, tx->height, (byte *)(tx+1), true, false);
tx->gl_texturenum = GL_LoadTexture (mt->name, tx->width, tx->height, (byte *)(tx+1), true, false, 1);
texture_mode = GL_LINEAR;
}
@ -1537,7 +1537,7 @@ void *Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype)
pheader->gl_texturenum[i][2] =
pheader->gl_texturenum[i][3] =
GL_LoadTexture (name, pheader->skinwidth,
pheader->skinheight, (byte *)(pskintype + 1), true, false);
pheader->skinheight, (byte *)(pskintype + 1), true, false, 1);
pskintype = (daliasskintype_t *)((byte *)(pskintype+1) + s);
} else {
// animating skin group. yuck.
@ -1554,7 +1554,7 @@ void *Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype)
snprintf (name, sizeof(name), "%s_%i_%i", loadmodel->name, i,j);
pheader->gl_texturenum[i][j&3] =
GL_LoadTexture (name, pheader->skinwidth,
pheader->skinheight, (byte *)(pskintype), true, false);
pheader->skinheight, (byte *)(pskintype), true, false, 1);
pskintype = (daliasskintype_t *)((byte *)(pskintype) + s);
}
k = j;
@ -1796,7 +1796,7 @@ void * Mod_LoadSpriteFrame (void * pin, mspriteframe_t **ppframe, int framenum)
pspriteframe->right = width + origin[0];
snprintf (name, sizeof(name), "%s_%i", loadmodel->name, framenum);
pspriteframe->gl_texturenum = GL_LoadTexture (name, width, height, (byte *)(pinframe + 1), true, true);
pspriteframe->gl_texturenum = GL_LoadTexture (name, width, height, (byte *)(pinframe + 1), true, true, 1);
return (void *)((byte *)pinframe + sizeof (dspriteframe_t) + size);
}