mirror of
https://github.com/libretro/libretro-tyrquake.git
synced 2024-11-27 10:10:58 +00:00
[PATCH] Use glGenTextures for texture handles
Rather than just assuming that the texture handles that we generate are okay to use, use the proper glGenTextures function. Note that we're still leaking textures all over the place (every map load, etc.) - proper texture management is still needed. Signed-off-by: Tyrann <tyrann@disenchant.net>
This commit is contained in:
parent
3f74b76822
commit
e30996ce3a
@ -45,8 +45,8 @@ static int c_alias_polys;
|
||||
|
||||
qboolean envmap; // true during envmap command capture
|
||||
|
||||
int currenttexture = -1; // to avoid unnecessary texture sets
|
||||
int playertextures; // up to 16 color translated skins
|
||||
GLuint currenttexture = -1; // to avoid unnecessary texture sets
|
||||
GLuint playertextures[MAX_CLIENTS];// up to 16 color translated skins
|
||||
|
||||
int mirrortexturenum; // quake texturenum, not gltexturenum
|
||||
qboolean mirror;
|
||||
@ -552,7 +552,7 @@ R_DrawAliasModel(entity_t *e)
|
||||
if (i >= 1 && i <= cl.maxclients
|
||||
/* && !strcmp (currententity->model->name, "progs/player.mdl") */
|
||||
)
|
||||
GL_Bind(playertextures - 1 + i);
|
||||
GL_Bind(playertextures[i - 1]);
|
||||
}
|
||||
|
||||
if (gl_smoothmodels.value)
|
||||
|
@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#include "sys.h"
|
||||
|
||||
// FIXME - should only be needed in r_part.c or here, not both.
|
||||
int particletexture;
|
||||
GLuint particletexture;
|
||||
|
||||
/*
|
||||
==================
|
||||
@ -84,7 +84,7 @@ R_InitParticleTexture(void)
|
||||
//
|
||||
// particle texture
|
||||
//
|
||||
particletexture = texture_extension_number++;
|
||||
glGenTextures(1, &particletexture);
|
||||
GL_Bind(particletexture);
|
||||
|
||||
for (x = 0; x < 8; x++) {
|
||||
@ -233,8 +233,7 @@ R_Init(void)
|
||||
R_InitParticles();
|
||||
R_InitParticleTexture();
|
||||
|
||||
playertextures = texture_extension_number;
|
||||
texture_extension_number += MAX_CLIENTS;
|
||||
glGenTextures(MAX_CLIENTS, playertextures);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -308,7 +307,7 @@ R_TranslatePlayerSkin(int playernum)
|
||||
|
||||
// because this happens during gameplay, do it fast
|
||||
// instead of sending it through gl_upload 8
|
||||
GL_Bind(playertextures + playernum);
|
||||
GL_Bind(playertextures[playernum]);
|
||||
|
||||
#if 0
|
||||
byte translated[320 * 200];
|
||||
|
@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
// FIXME - header hacks
|
||||
extern byte *draw_chars;
|
||||
|
||||
int netgraphtexture; // netgraph texture
|
||||
GLuint netgraphtexture; // netgraph texture
|
||||
|
||||
#define NET_GRAPHHEIGHT 32
|
||||
|
||||
|
@ -46,8 +46,8 @@ static int c_alias_polys;
|
||||
|
||||
qboolean envmap; // true during envmap command capture
|
||||
|
||||
int currenttexture = -1; // to avoid unnecessary texture sets
|
||||
int playertextures; // up to 16 color translated skins
|
||||
GLuint currenttexture = -1; // to avoid unnecessary texture sets
|
||||
GLuint playertextures[MAX_CLIENTS];// up to 16 color translated skins
|
||||
|
||||
int mirrortexturenum; // quake texturenum, not gltexturenum
|
||||
qboolean mirror;
|
||||
@ -556,7 +556,7 @@ R_DrawAliasModel(entity_t *e)
|
||||
R_TranslatePlayerSkin(i);
|
||||
}
|
||||
if (i >= 0 && i < MAX_CLIENTS)
|
||||
GL_Bind(playertextures + i);
|
||||
GL_Bind(playertextures[i]);
|
||||
}
|
||||
|
||||
if (gl_smoothmodels.value)
|
||||
|
@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#include "sys.h"
|
||||
|
||||
// FIXME - should only be needed in r_part.c or here, not both.
|
||||
int particletexture;
|
||||
GLuint particletexture;
|
||||
|
||||
/*
|
||||
==================
|
||||
@ -84,7 +84,7 @@ R_InitParticleTexture(void)
|
||||
//
|
||||
// particle texture
|
||||
//
|
||||
particletexture = texture_extension_number++;
|
||||
glGenTextures(1, &particletexture);
|
||||
GL_Bind(particletexture);
|
||||
|
||||
for (x = 0; x < 8; x++) {
|
||||
@ -233,11 +233,8 @@ R_Init(void)
|
||||
R_InitParticles();
|
||||
R_InitParticleTexture();
|
||||
|
||||
netgraphtexture = texture_extension_number;
|
||||
texture_extension_number++;
|
||||
|
||||
playertextures = texture_extension_number;
|
||||
texture_extension_number += MAX_CLIENTS;
|
||||
glGenTextures(1, &netgraphtexture);
|
||||
glGenTextures(MAX_CLIENTS, playertextures);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -323,7 +320,7 @@ R_TranslatePlayerSkin(int playernum)
|
||||
|
||||
// because this happens during gameplay, do it fast
|
||||
// instead of sending it through gl_upload 8
|
||||
GL_Bind(playertextures + playernum);
|
||||
GL_Bind(playertextures[playernum]);
|
||||
|
||||
#if 0
|
||||
s = 320 * 200;
|
||||
|
@ -54,9 +54,9 @@ byte *draw_chars; /* 8*8 graphic characters */
|
||||
qpic_t *draw_disc;
|
||||
static qpic_t *draw_backtile;
|
||||
|
||||
static int translate_texture;
|
||||
static int char_texture;
|
||||
static int cs_texture; // crosshair texture
|
||||
static GLuint translate_texture;
|
||||
static GLuint char_texture;
|
||||
static GLuint cs_texture; // crosshair texture
|
||||
|
||||
static byte cs_data[64] = {
|
||||
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
|
||||
@ -87,7 +87,7 @@ static int gl_filter_max = GL_LINEAR;
|
||||
static int texels;
|
||||
|
||||
typedef struct {
|
||||
int texnum;
|
||||
GLuint texnum;
|
||||
char identifier[64];
|
||||
int width, height;
|
||||
qboolean mipmap;
|
||||
@ -135,7 +135,7 @@ GL_Bind(int texnum)
|
||||
static int scrap_allocated[MAX_SCRAPS][BLOCK_WIDTH];
|
||||
static byte scrap_texels[MAX_SCRAPS][BLOCK_WIDTH * BLOCK_HEIGHT * 4];
|
||||
static qboolean scrap_dirty;
|
||||
static int scrap_texnum;
|
||||
static GLuint scrap_textures[MAX_SCRAPS];
|
||||
|
||||
// returns a texture number and the position inside it
|
||||
static int
|
||||
@ -185,7 +185,7 @@ Scrap_Upload(void)
|
||||
|
||||
scrap_uploads++;
|
||||
for (texnum = 0; texnum < MAX_SCRAPS; ++texnum) {
|
||||
GL_Bind(scrap_texnum + texnum);
|
||||
GL_Bind(scrap_textures[texnum]);
|
||||
GL_Upload8(scrap_texels[texnum], BLOCK_WIDTH, BLOCK_HEIGHT, false,
|
||||
true);
|
||||
}
|
||||
@ -232,8 +232,7 @@ Draw_PicFromWad(const char *name)
|
||||
for (j = 0; j < p->width; j++, k++)
|
||||
scrap_texels[texnum][(y + i) * BLOCK_WIDTH + x + j] =
|
||||
p->data[k];
|
||||
texnum += scrap_texnum;
|
||||
gl->texnum = texnum;
|
||||
gl->texnum = scrap_textures[texnum];
|
||||
gl->sl = (x + 0.01) / (float)BLOCK_WIDTH;
|
||||
gl->sh = (x + p->width - 0.01) / (float)BLOCK_WIDTH;
|
||||
gl->tl = (y + 0.01) / (float)BLOCK_WIDTH;
|
||||
@ -512,11 +511,10 @@ Draw_Init(void)
|
||||
Hunk_FreeToLowMark(start);
|
||||
|
||||
// save a texture slot for translated picture
|
||||
translate_texture = texture_extension_number++;
|
||||
glGenTextures(1, &translate_texture);
|
||||
|
||||
// save slots for scraps
|
||||
scrap_texnum = texture_extension_number;
|
||||
texture_extension_number += MAX_SCRAPS;
|
||||
glGenTextures(MAX_SCRAPS, scrap_textures);
|
||||
|
||||
//
|
||||
// get the other pics we need
|
||||
@ -1364,8 +1362,7 @@ GL_LoadTexture(const char *identifier, int width, int height,
|
||||
strncpy(glt->identifier, identifier, sizeof(glt->identifier) - 1);
|
||||
glt->identifier[sizeof(glt->identifier) - 1] = '\0';
|
||||
|
||||
glt->texnum = texture_extension_number;
|
||||
texture_extension_number++;
|
||||
glGenTextures(1, &glt->texnum);
|
||||
|
||||
GL_LoadTexture_setup:
|
||||
glt->crc = crc;
|
||||
|
@ -52,15 +52,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
int skytexturenum;
|
||||
|
||||
#define MAX_LIGHTMAPS 80
|
||||
|
||||
static int lightmap_bytes; // 1, 2, or 4
|
||||
static int lightmap_textures;
|
||||
static int lightmap_textures_initialised = 0;
|
||||
static GLuint lightmap_textures[MAX_LIGHTMAPS];
|
||||
|
||||
static unsigned blocklights[18 * 18];
|
||||
|
||||
#define BLOCK_WIDTH 128
|
||||
#define BLOCK_HEIGHT 128
|
||||
|
||||
#define MAX_LIGHTMAPS 80
|
||||
|
||||
typedef struct glRect_s {
|
||||
unsigned char l, t, w, h;
|
||||
@ -541,7 +543,7 @@ R_BlendLightmaps(void)
|
||||
p = lightmap_polys[i];
|
||||
if (!p)
|
||||
continue;
|
||||
GL_Bind(lightmap_textures + i);
|
||||
GL_Bind(lightmap_textures[i]);
|
||||
if (lightmap_modified[i]) {
|
||||
R_UploadLightmapUpdate(i);
|
||||
lightmap_modified[i] = false;
|
||||
@ -657,7 +659,7 @@ R_RenderBrushPoly(msurface_t *fa)
|
||||
/* All lightmaps are up to date... */
|
||||
i = fa->lightmaptexturenum;
|
||||
GL_EnableMultitexture();
|
||||
GL_Bind(lightmap_textures + i);
|
||||
GL_Bind(lightmap_textures[i]);
|
||||
if (lightmap_modified[i]) {
|
||||
R_UploadLightmapUpdate(i);
|
||||
lightmap_modified[i] = false;
|
||||
@ -1308,9 +1310,10 @@ GL_BuildLightmaps(void)
|
||||
|
||||
r_framecount = 1; // no dlightcache
|
||||
|
||||
if (!lightmap_textures) {
|
||||
lightmap_textures = texture_extension_number;
|
||||
texture_extension_number += MAX_LIGHTMAPS;
|
||||
// FIXME - move this to one of the init functions...
|
||||
if (!lightmap_textures_initialised) {
|
||||
glGenTextures(MAX_LIGHTMAPS, lightmap_textures);
|
||||
lightmap_textures_initialised = 1;
|
||||
}
|
||||
|
||||
gl_lightmap_format = GL_LUMINANCE;
|
||||
@ -1431,7 +1434,7 @@ GL_BuildLightmaps(void)
|
||||
lightmap_rectchange[i].t = BLOCK_HEIGHT;
|
||||
lightmap_rectchange[i].w = 0;
|
||||
lightmap_rectchange[i].h = 0;
|
||||
GL_Bind(lightmap_textures + i);
|
||||
GL_Bind(lightmap_textures[i]);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, lightmap_bytes, BLOCK_WIDTH,
|
||||
|
@ -93,8 +93,6 @@ int texture_mode = GL_LINEAR;
|
||||
//int texture_mode = GL_LINEAR_MIPMAP_NEAREST;
|
||||
//int texture_mode = GL_LINEAR_MIPMAP_LINEAR;
|
||||
|
||||
int texture_extension_number = 1;
|
||||
|
||||
float gldepthmin, gldepthmax;
|
||||
|
||||
cvar_t gl_ztrick = { "gl_ztrick", "1" };
|
||||
|
@ -571,8 +571,6 @@ int texture_mode = GL_LINEAR;
|
||||
//int texture_mode = GL_LINEAR_MIPMAP_NEAREST;
|
||||
//int texture_mode = GL_LINEAR_MIPMAP_LINEAR;
|
||||
|
||||
int texture_extension_number = 1;
|
||||
|
||||
static void
|
||||
CheckMultiTextureExtensions(void)
|
||||
{
|
||||
|
@ -31,10 +31,13 @@ extern cvar_t gl_subdivide_size;
|
||||
|
||||
int skytexturenum;
|
||||
|
||||
int solidskytexture;
|
||||
int alphaskytexture;
|
||||
float speedscale; // for top sky and bottom sky
|
||||
float speedscale2; // for sky alpha layer using multitexture
|
||||
static GLuint solidskytexture;
|
||||
static GLuint alphaskytexture;
|
||||
static int solidskytexture_initialised = 0;
|
||||
static int alphaskytexture_initialised = 0;
|
||||
|
||||
static float speedscale; // for top sky and bottom sky
|
||||
static float speedscale2; // for sky alpha layer using multitexture
|
||||
|
||||
msurface_t *warpface;
|
||||
|
||||
@ -425,8 +428,11 @@ R_InitSky(texture_t *mt)
|
||||
((byte *)&transpix)[2] = b / (128 * 128);
|
||||
((byte *)&transpix)[3] = 0;
|
||||
|
||||
if (!solidskytexture)
|
||||
solidskytexture = texture_extension_number++;
|
||||
// FIXME - move this to some init function
|
||||
if (!solidskytexture_initialised) {
|
||||
glGenTextures(1, &solidskytexture);
|
||||
solidskytexture_initialised = 1;
|
||||
}
|
||||
GL_Bind(solidskytexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, gl_solid_format, 128, 128, 0, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, trans);
|
||||
@ -442,8 +448,12 @@ R_InitSky(texture_t *mt)
|
||||
trans[(i * 128) + j] = d_8to24table[p];
|
||||
}
|
||||
|
||||
if (!alphaskytexture)
|
||||
alphaskytexture = texture_extension_number++;
|
||||
// FIXME - move this to an init function...
|
||||
if (!alphaskytexture_initialised) {
|
||||
glGenTextures(1, &alphaskytexture);
|
||||
alphaskytexture_initialised = 1;
|
||||
}
|
||||
|
||||
GL_Bind(alphaskytexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, gl_alpha_format, 128, 128, 0, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, trans);
|
||||
|
@ -31,8 +31,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#include <GL/glext.h>
|
||||
#endif
|
||||
|
||||
#include "gl_model.h"
|
||||
#include "client.h"
|
||||
#include "gl_model.h"
|
||||
#include "protocol.h"
|
||||
|
||||
#ifndef APIENTRY
|
||||
#define APIENTRY
|
||||
@ -72,7 +73,6 @@ extern TEXSUBIMAGEPTR TexSubImage2DFunc;
|
||||
#define GL_MAX_TEXTURE_UNITS GL_MAX_TEXTURE_UNITS_ARB
|
||||
#endif
|
||||
|
||||
extern int texture_extension_number;
|
||||
extern int texture_mode;
|
||||
|
||||
extern float gldepthmin, gldepthmax;
|
||||
@ -182,9 +182,9 @@ extern texture_t *r_notexture_mip;
|
||||
extern int d_lightstylevalue[256]; // 8.8 fraction of base light value
|
||||
|
||||
extern qboolean envmap;
|
||||
extern int currenttexture;
|
||||
extern int particletexture;
|
||||
extern int playertextures;
|
||||
extern GLuint currenttexture;
|
||||
extern GLuint particletexture;
|
||||
extern GLuint playertextures[MAX_CLIENTS];
|
||||
|
||||
extern int skytexturenum; // index in cl.loadmodel, not gl texture object
|
||||
|
||||
@ -225,7 +225,7 @@ extern cvar_t gl_doubleeyes;
|
||||
#endif
|
||||
|
||||
#ifdef QW_HACK
|
||||
extern int netgraphtexture; // netgraph texture
|
||||
extern GLuint netgraphtexture; // netgraph texture
|
||||
extern cvar_t r_netgraph;
|
||||
void R_NetGraph(void);
|
||||
#endif
|
||||
@ -270,10 +270,6 @@ void EmitWaterPolys(msurface_t *fa);
|
||||
void EmitSkyPolys(msurface_t *fa);
|
||||
void R_DrawSkyChain(msurface_t *s);
|
||||
|
||||
extern int solidskytexture;
|
||||
extern int alphaskytexture;
|
||||
extern float speedscale; // for top sky and bottom sky
|
||||
|
||||
//
|
||||
// gl_draw.c
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user