diff --git a/include/QF/GL/qf_lightmap.h b/include/QF/GL/qf_lightmap.h index 102f26313..37485888f 100644 --- a/include/QF/GL/qf_lightmap.h +++ b/include/QF/GL/qf_lightmap.h @@ -28,6 +28,8 @@ #ifndef __QF_GL_lightmap_h #define __QF_GL_lightmap_h +#include "QF/GL/types.h" + // LordHavoc: since lightmaps are now allocated only as needed, allow a ridiculous number :) #define MAX_LIGHTMAPS 1024 #define BLOCK_WIDTH 64 @@ -40,7 +42,7 @@ typedef struct glRect_s { extern int lm_src_blend, lm_dest_blend; extern model_t *gl_currentmodel; -extern int gl_lightmap_textures; +extern GLuint gl_lightmap_textures[MAX_LIGHTMAPS]; extern qboolean gl_lightmap_modified[MAX_LIGHTMAPS]; extern instsurf_t *gl_lightmap_polys[MAX_LIGHTMAPS]; extern glRect_t gl_lightmap_rectchange[MAX_LIGHTMAPS]; diff --git a/include/QF/GL/qf_rmain.h b/include/QF/GL/qf_rmain.h index 651a9fff2..d6b8fe94b 100644 --- a/include/QF/GL/qf_rmain.h +++ b/include/QF/GL/qf_rmain.h @@ -51,6 +51,6 @@ void gl_R_RenderView (void); void gl_R_ClearState (void); void gl_R_ViewChanged (void); void gl_R_LineGraph (int x, int y, int *h_vals, int count, int height); -int gl_R_InitGraphTextures (int base); +void gl_R_InitGraphTextures (void); #endif // __QF_GL_rmain_h diff --git a/include/QF/GL/qf_sky.h b/include/QF/GL/qf_sky.h index f2f030bb4..b7a0fc35a 100644 --- a/include/QF/GL/qf_sky.h +++ b/include/QF/GL/qf_sky.h @@ -30,11 +30,14 @@ #include "QF/qtypes.h" #include "QF/model.h" +#include "QF/GL/types.h" #define SKY_TEX 2000 // Quake 2 environment sky extern qboolean gl_skyloaded; extern vec5_t gl_skyvec[6][4]; +extern GLuint gl_solidskytexture; +extern GLuint gl_alphaskytexture; struct texture_s; diff --git a/include/QF/GL/qf_textures.h b/include/QF/GL/qf_textures.h index aae32fb50..9a905b649 100644 --- a/include/QF/GL/qf_textures.h +++ b/include/QF/GL/qf_textures.h @@ -29,6 +29,7 @@ #define __gl_textures_h #include "QF/qtypes.h" +#include "QF/GL/types.h" #define MAX_GLTEXTURES 2048 @@ -39,7 +40,7 @@ extern int gl_filter_min; extern int gl_filter_max; extern qboolean gl_Anisotropy; extern float gl_aniso; -extern int gl_part_tex; +extern GLuint gl_part_tex; void GL_Upload8 (const byte *data, int width, int height, qboolean mipmap, qboolean alpha); void GL_Upload8_EXT (const byte *data, int width, int height, qboolean mipmap, qboolean alpha); diff --git a/include/QF/GL/qf_vid.h b/include/QF/GL/qf_vid.h index bb6291aa1..6702c2a6e 100644 --- a/include/QF/GL/qf_vid.h +++ b/include/QF/GL/qf_vid.h @@ -44,7 +44,6 @@ extern qboolean gl_mtex_fullbright; extern GLenum gl_mtex_enum; extern qboolean gl_combine_capable; extern float gl_rgb_scale; -extern int gl_texture_number; extern qboolean gl_feature_mach64; extern float gldepthmin, gldepthmax; diff --git a/include/mod_internal.h b/include/mod_internal.h index 9126a3280..b54496dc4 100644 --- a/include/mod_internal.h +++ b/include/mod_internal.h @@ -120,6 +120,6 @@ void glsl_Skin_InitTranslations (void); void gl_Skin_SetupSkin (skin_t *skin, int cmap); void gl_Skin_ProcessTranslation (int cmap, const byte *translation); void gl_Skin_InitTranslations (void); -int gl_Skin_Init_Textures (int base); +void gl_Skin_Init_Textures (void); void gl_Skin_SetPlayerSkin (int width, int height, const byte *data); #endif// __mod_internal_h diff --git a/include/r_shared.h b/include/r_shared.h index d24632139..843978033 100644 --- a/include/r_shared.h +++ b/include/r_shared.h @@ -137,9 +137,6 @@ extern void SetUpForLineScan(fixed8_t startvertu, fixed8_t startvertv, extern int r_skymade; extern void R_MakeSky (void); -extern int gl_solidskytexture; -extern int gl_alphaskytexture; - // flags in finalvert_t.flags #define ALIAS_LEFT_CLIP 0x0001 #define ALIAS_TOP_CLIP 0x0002 diff --git a/libs/models/gl_skin.c b/libs/models/gl_skin.c index e55a88791..5ecef36ba 100644 --- a/libs/models/gl_skin.c +++ b/libs/models/gl_skin.c @@ -60,8 +60,8 @@ typedef struct { qboolean fb; } glskin_t; -static int skin_textures; -static int skin_fb_textures; +static GLuint skin_textures[MAX_TRANSLATIONS]; +static GLuint skin_fb_textures[MAX_TRANSLATIONS]; static byte skin_cmap[MAX_TRANSLATIONS][256]; static glskin_t skins[MAX_TRANSLATIONS]; @@ -189,10 +189,10 @@ build_skin (skin_t *skin, int cmap) if (!s->tex) // we haven't loaded the player model yet return; - texnum = skin_textures + cmap; + texnum = skin_textures[cmap]; fb_texnum = 0; if (s->fb) - fb_texnum = skin_fb_textures + cmap; + fb_texnum = skin_fb_textures[cmap]; if (skin) { skin->texnum = texnum; skin->auxtex = fb_texnum; @@ -245,9 +245,9 @@ gl_Skin_SetupSkin (skin_t *skin, int cmap) changed = (s->tex != skin->texels); s->tex = skin->texels; if (!changed) { - skin->texnum = skin_textures + cmap; + skin->texnum = skin_textures[cmap]; if (s->fb) - skin->auxtex = skin_fb_textures + cmap; + skin->auxtex = skin_fb_textures[cmap]; return; } if (s->tex) @@ -260,12 +260,9 @@ gl_Skin_InitTranslations (void) { } -int -gl_Skin_Init_Textures (int base) +void +gl_Skin_Init_Textures (void) { - skin_textures = base; - base += MAX_TRANSLATIONS; - skin_fb_textures = base; - base += MAX_TRANSLATIONS; - return base; + qfglGenTextures (MAX_TRANSLATIONS, skin_textures); + qfglGenTextures (MAX_TRANSLATIONS, skin_fb_textures); } diff --git a/libs/video/renderer/gl/gl_draw.c b/libs/video/renderer/gl/gl_draw.c index 6d64779d8..c2009f609 100644 --- a/libs/video/renderer/gl/gl_draw.c +++ b/libs/video/renderer/gl/gl_draw.c @@ -82,7 +82,7 @@ static float *textCoords, *tC; static qpic_t *draw_backtile; static cc_cell_t char_cells[256]; -static int translate_texture; +static GLuint translate_texture; static int char_texture; static int cs_texture; // crosshair texturea @@ -403,7 +403,7 @@ gl_Draw_Init (void) qfglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // save a texture slot for translated picture - translate_texture = gl_texture_number++; + qfglGenTextures (1, &translate_texture); // get the other pics we need draw_backtile = gl_Draw_PicFromWad ("backtile"); diff --git a/libs/video/renderer/gl/gl_dyn_textures.c b/libs/video/renderer/gl/gl_dyn_textures.c index 28e7d8ef4..d9004a69a 100644 --- a/libs/video/renderer/gl/gl_dyn_textures.c +++ b/libs/video/renderer/gl/gl_dyn_textures.c @@ -46,7 +46,7 @@ #include "r_internal.h" -int gl_part_tex; +GLuint gl_part_tex; static GLint part_tex_internal_format = 2; @@ -57,7 +57,7 @@ GDT_InitParticleTexture (void) memset (data, 0, sizeof (data)); - gl_part_tex = gl_texture_number++; + qfglGenTextures (1, &gl_part_tex); qfglBindTexture (GL_TEXTURE_2D, gl_part_tex); qfglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); qfglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); diff --git a/libs/video/renderer/gl/gl_graph.c b/libs/video/renderer/gl/gl_graph.c index 12c5e3774..8e816eb11 100644 --- a/libs/video/renderer/gl/gl_graph.c +++ b/libs/video/renderer/gl/gl_graph.c @@ -52,20 +52,16 @@ #define NUM_GRAPH_TEXTURES 8 static byte *graph_texels[NUM_GRAPH_TEXTURES]; -static int graph_texture[NUM_GRAPH_TEXTURES]; +static GLuint graph_texture[NUM_GRAPH_TEXTURES]; static int graph_index; static int graph_size[NUM_GRAPH_TEXTURES]; static int graph_width[NUM_GRAPH_TEXTURES]; -int -gl_R_InitGraphTextures (int base) +void +gl_R_InitGraphTextures (void) { - int i; - - for (i = 0; i < NUM_GRAPH_TEXTURES; i++) - graph_texture[i] = base++; - return base; + qfglGenTextures (NUM_GRAPH_TEXTURES, graph_texture); } void diff --git a/libs/video/renderer/gl/gl_lightmap.c b/libs/video/renderer/gl/gl_lightmap.c index 964b5aa36..ca54c7061 100644 --- a/libs/video/renderer/gl/gl_lightmap.c +++ b/libs/video/renderer/gl/gl_lightmap.c @@ -59,7 +59,7 @@ static int dlightdivtable[8192]; static int gl_internalformat; // 1 or 3 static int lightmap_bytes; // 1, 3, or 4 -int gl_lightmap_textures; +GLuint gl_lightmap_textures[MAX_LIGHTMAPS]; // keep lightmap texture data in main memory so texsubimage can update properly // LordHavoc: changed to be allocated at runtime (typically lower memory usage) @@ -480,7 +480,7 @@ gl_R_CalcLightmaps (void) if (!gl_lightmap_polys[i]) continue; if (gl_lightmap_modified[i]) { - qfglBindTexture (GL_TEXTURE_2D, gl_lightmap_textures + i); + qfglBindTexture (GL_TEXTURE_2D, gl_lightmap_textures[i]); GL_UploadLightmap (i); gl_lightmap_modified[i] = false; } @@ -500,7 +500,7 @@ gl_R_BlendLightmaps (void) for (i = 0; i < MAX_LIGHTMAPS; i++) { for (sc = gl_lightmap_polys[i]; sc; sc = sc->lm_chain) { - qfglBindTexture (GL_TEXTURE_2D, gl_lightmap_textures + i); + qfglBindTexture (GL_TEXTURE_2D, gl_lightmap_textures[i]); if (sc->transform) { qfglPushMatrix (); qfglLoadMatrixf (sc->transform); @@ -691,9 +691,8 @@ GL_BuildLightmaps (model_t **models, int num_models) r_framecount = 1; // no dlightcache - if (!gl_lightmap_textures) { - gl_lightmap_textures = gl_texture_number; - gl_texture_number += MAX_LIGHTMAPS; + if (!gl_lightmap_textures[0]) { + qfglGenTextures (MAX_LIGHTMAPS, gl_lightmap_textures); } switch (r_lightmap_components->int_val) { @@ -756,7 +755,7 @@ GL_BuildLightmaps (model_t **models, int num_models) gl_lightmap_rectchange[i].t = BLOCK_HEIGHT; gl_lightmap_rectchange[i].w = 0; gl_lightmap_rectchange[i].h = 0; - qfglBindTexture (GL_TEXTURE_2D, gl_lightmap_textures + i); + qfglBindTexture (GL_TEXTURE_2D, gl_lightmap_textures[i]); qfglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); qfglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); if (gl_Anisotropy) diff --git a/libs/video/renderer/gl/gl_rmisc.c b/libs/video/renderer/gl/gl_rmisc.c index 2cbfcdfee..93375ece1 100644 --- a/libs/video/renderer/gl/gl_rmisc.c +++ b/libs/video/renderer/gl/gl_rmisc.c @@ -187,9 +187,8 @@ gl_R_Init (void) GDT_Init (); - gl_texture_number = gl_R_InitGraphTextures (gl_texture_number); - - gl_texture_number = gl_Skin_Init_Textures (gl_texture_number); + gl_R_InitGraphTextures (); + gl_Skin_Init_Textures (); r_init = 1; gl_R_InitParticles (); diff --git a/libs/video/renderer/gl/gl_rsurf.c b/libs/video/renderer/gl/gl_rsurf.c index 9b6bd214c..0de24b23f 100644 --- a/libs/video/renderer/gl/gl_rsurf.c +++ b/libs/video/renderer/gl/gl_rsurf.c @@ -397,8 +397,8 @@ DrawTextureChains (int disable_blend, int do_bind) } if (s->color && do_bind) qfglColor4fv (s->color); - qfglBindTexture (GL_TEXTURE_2D, gl_lightmap_textures + - surf->lightmaptexturenum); + qfglBindTexture (GL_TEXTURE_2D, + gl_lightmap_textures[surf->lightmaptexturenum]); R_RenderBrushPoly_3 (surf); @@ -416,8 +416,8 @@ DrawTextureChains (int disable_blend, int do_bind) qglActiveTexture (gl_mtex_enum + 1); for (s = tex->tex_chain; s; s = s->tex_chain) { surf = s->surface; - qfglBindTexture (GL_TEXTURE_2D, gl_lightmap_textures + - surf->lightmaptexturenum); + qfglBindTexture (GL_TEXTURE_2D, + gl_lightmap_textures[surf->lightmaptexturenum]); if (s->transform) { qfglPushMatrix (); diff --git a/libs/video/renderer/gl/gl_sky.c b/libs/video/renderer/gl/gl_sky.c index b0f00cfbe..47c6bc072 100644 --- a/libs/video/renderer/gl/gl_sky.c +++ b/libs/video/renderer/gl/gl_sky.c @@ -56,8 +56,8 @@ // cube from the outside on the -ve y axis with +x to the right, +y going in, // +z up, and front is the nearest face. static const char *suf[6] = { "rt", "bk", "lf", "ft", "up", "dn" }; -int gl_solidskytexture; -int gl_alphaskytexture; +GLuint gl_solidskytexture; +GLuint gl_alphaskytexture; // Set to true if a valid skybox is loaded --KB qboolean gl_skyloaded = false; @@ -428,8 +428,9 @@ gl_R_InitSky (texture_t *mt) ((byte *) & transpix)[2] = b / (128 * 128); ((byte *) & transpix)[3] = 0; - if (!gl_solidskytexture) - gl_solidskytexture = gl_texture_number++; + if (!gl_solidskytexture) { + qfglGenTextures (1, &gl_solidskytexture); + } qfglBindTexture (GL_TEXTURE_2D, gl_solidskytexture); qfglTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, trans); @@ -448,8 +449,9 @@ gl_R_InitSky (texture_t *mt) trans[(i * 128) + j] = d_8to24table[p]; } - if (!gl_alphaskytexture) - gl_alphaskytexture = gl_texture_number++; + if (!gl_alphaskytexture) { + qfglGenTextures (1, &gl_alphaskytexture); + } qfglBindTexture (GL_TEXTURE_2D, gl_alphaskytexture); qfglTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, trans); diff --git a/libs/video/renderer/gl/gl_textures.c b/libs/video/renderer/gl/gl_textures.c index 85a43eec9..9beb146dc 100644 --- a/libs/video/renderer/gl/gl_textures.c +++ b/libs/video/renderer/gl/gl_textures.c @@ -55,7 +55,7 @@ #include "vid_internal.h" typedef struct { - int texnum; + GLuint texnum; char identifier[64]; int width, height; int bytesperpixel; @@ -584,8 +584,7 @@ GL_LoadTexture (const char *identifier, int width, int height, const byte *data, strncpy (glt->identifier, identifier, sizeof (glt->identifier) - 1); glt->identifier[sizeof (glt->identifier) - 1] = '\0'; - glt->texnum = gl_texture_number; - gl_texture_number++; + qfglGenTextures (1, &glt->texnum); SetupTexture: glt->crc = crc; diff --git a/libs/video/renderer/gl/vid_common_gl.c b/libs/video/renderer/gl/vid_common_gl.c index ce8a5e3d6..d1547d2d9 100644 --- a/libs/video/renderer/gl/vid_common_gl.c +++ b/libs/video/renderer/gl/vid_common_gl.c @@ -79,7 +79,6 @@ int gl_use_bgra; int gl_va_capable; static int driver_vaelements; int vaelements; -int gl_texture_number = 1; int gl_filter_min = GL_LINEAR_MIPMAP_LINEAR; int gl_filter_max = GL_LINEAR; float gldepthmin, gldepthmax;