Commit ae52bec9 authored by Richard Gobeille's avatar Richard Gobeille
Browse files

engine: remove wrappers around glBindTexture() and glActiveTexture() in favor...

engine: remove wrappers around glBindTexture() and glActiveTexture() in favor of explicitly calling polymost_activeTexture() and polymost_bindTexture()

This is better for clarity, I think.
parent 1d10d93d
......@@ -73,12 +73,6 @@ void polymost_useShaderProgram(uint32_t shaderID);
float* multiplyMatrix4f(float m0[4*4], const float m1[4*4]);
//POGOTODO: these wrappers won't be needed down the line -- remove them once proper draw call organization is finished
#undef glActiveTexture
#undef glBindTexture
#define glActiveTexture polymost_activeTexture
#define glBindTexture polymost_bindTexture
void polymost_glinit(void);
void polymost_glreset(void);
......
......@@ -907,7 +907,7 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
if ((doalloc&3)==1)
glGenTextures(1, texidx);
glBindTexture(GL_TEXTURE_2D, *texidx);
polymost_bindTexture(GL_TEXTURE_2D, *texidx);
//gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA,xsiz,ysiz,GL_BGRA_EXT,GL_UNSIGNED_BYTE,(char *)fptr);
......@@ -2401,7 +2401,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
if (!i)
continue;
//i = mdloadskin((md2model *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,surfi); //hack for testing multiple surfaces per MD3
glBindTexture(GL_TEXTURE_2D, i);
polymost_bindTexture(GL_TEXTURE_2D, i);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
......@@ -2567,7 +2567,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTexture(texunits - 1);
glActiveTexture(--texunits);
polymost_activeTexture(--texunits);
}
#else
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
......@@ -2588,7 +2588,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
glMatrixMode(GL_MODELVIEW);
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 1.0f);
glDisable(GL_TEXTURE_2D);
glActiveTexture(--texunits);
polymost_activeTexture(--texunits);
}
} // r_vertexarrays
......
......@@ -820,7 +820,7 @@ int32_t polymer_init(void)
if (prhighpalookups[i][j].data)
{
glGenTextures(1, &prhighpalookups[i][j].map);
glBindTexture(GL_TEXTURE_3D, prhighpalookups[i][j].map);
polymost_bindTexture(GL_TEXTURE_3D, prhighpalookups[i][j].map);
glTexImage3D(GL_TEXTURE_3D, // target
0, // mip level
GL_RGBA, // internalFormat
......@@ -836,7 +836,7 @@ int32_t polymer_init(void)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
glBindTexture(GL_TEXTURE_3D, 0);
polymost_bindTexture(GL_TEXTURE_3D, 0);
}
j++;
}
......@@ -4263,7 +4263,7 @@ static void polymer_drawartsky(int16_t tilenum, char palnum, int8_t shad
const int8_t tileofs = j&numskytilesm1;
glColor4f(glcolors[tileofs][0], glcolors[tileofs][1], glcolors[tileofs][2], 1.0f);
glBindTexture(GL_TEXTURE_2D, glpics[tileofs]);
polymost_bindTexture(GL_TEXTURE_2D, glpics[tileofs]);
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &oldswrap);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
......@@ -4349,7 +4349,7 @@ static void polymer_drawskybox(int16_t tilenum, char palnum, int8_t shad
glColor4f(color[0], color[1], color[2], 1.0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0);
polymost_bindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0);
if (pr_vbos > 0)
{
glVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), (GLfloat*)(4 * 5 * i * sizeof(GLfloat)));
......@@ -4904,7 +4904,7 @@ static void polymer_setupartmap(int16_t tilenum, char pal)
}
glGenTextures(1, &prartmaps[tilenum]);
glBindTexture(GL_TEXTURE_2D, prartmaps[tilenum]);
polymost_bindTexture(GL_TEXTURE_2D, prartmaps[tilenum]);
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RED,
......@@ -4918,13 +4918,13 @@ static void polymer_setupartmap(int16_t tilenum, char pal)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glBindTexture(GL_TEXTURE_2D, 0);
polymost_bindTexture(GL_TEXTURE_2D, 0);
Xfree(tempbuffer);
}
if (!prbasepalmaps[curbasepal]) {
glGenTextures(1, &prbasepalmaps[curbasepal]);
glBindTexture(GL_TEXTURE_2D, prbasepalmaps[curbasepal]);
polymost_bindTexture(GL_TEXTURE_2D, prbasepalmaps[curbasepal]);
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGB,
......@@ -4938,12 +4938,12 @@ static void polymer_setupartmap(int16_t tilenum, char pal)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glinfo.clamptoedge ? GL_CLAMP_TO_EDGE : GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glinfo.clamptoedge ? GL_CLAMP_TO_EDGE : GL_CLAMP);
glBindTexture(GL_TEXTURE_2D, 0);
polymost_bindTexture(GL_TEXTURE_2D, 0);
}
if (!prlookups[pal]) {
glGenTextures(1, &prlookups[pal]);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, prlookups[pal]);
polymost_bindTexture(GL_TEXTURE_RECTANGLE_ARB, prlookups[pal]);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB,
0,
GL_RED,
......@@ -4957,7 +4957,7 @@ static void polymer_setupartmap(int16_t tilenum, char pal)
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, glinfo.clamptoedge ? GL_CLAMP_TO_EDGE : GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, glinfo.clamptoedge ? GL_CLAMP_TO_EDGE : GL_CLAMP);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
polymost_bindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
}
}
......@@ -5244,8 +5244,8 @@ static int32_t polymer_bindmaterial(const _prmaterial *material, const int1
pos[1] = fglobalposz * (-1.f/16.f);
pos[2] = -fglobalposx;
glActiveTexture(texunit + GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, material->normalmap);
polymost_activeTexture(texunit + GL_TEXTURE0);
polymost_bindTexture(GL_TEXTURE_2D, material->normalmap);
if (material->mdspritespace == GL_TRUE) {
float mdspritespacepos[3];
......@@ -5286,22 +5286,22 @@ static int32_t polymer_bindmaterial(const _prmaterial *material, const int1
// PR_BIT_ART_MAP
if (programbits & prprogrambits[PR_BIT_ART_MAP].bit)
{
glActiveTexture(texunit + GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, material->artmap);
polymost_activeTexture(texunit + GL_TEXTURE0);
polymost_bindTexture(GL_TEXTURE_2D, material->artmap);
glUniform1i(prprograms[programbits].uniform_artMap, texunit);
texunit++;
glActiveTexture(texunit + GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, material->basepalmap);
polymost_activeTexture(texunit + GL_TEXTURE0);
polymost_bindTexture(GL_TEXTURE_2D, material->basepalmap);
glUniform1i(prprograms[programbits].uniform_basePalMap, texunit);
texunit++;
glActiveTexture(texunit + GL_TEXTURE0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, material->lookupmap);
polymost_activeTexture(texunit + GL_TEXTURE0);
polymost_bindTexture(GL_TEXTURE_RECTANGLE_ARB, material->lookupmap);
glUniform1i(prprograms[programbits].uniform_lookupMap, texunit);
......@@ -5332,8 +5332,8 @@ static int32_t polymer_bindmaterial(const _prmaterial *material, const int1
// PR_BIT_DIFFUSE_MAP
if (programbits & prprogrambits[PR_BIT_DIFFUSE_MAP].bit)
{
glActiveTexture(texunit + GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, material->diffusemap);
polymost_activeTexture(texunit + GL_TEXTURE0);
polymost_bindTexture(GL_TEXTURE_2D, material->diffusemap);
glUniform1i(prprograms[programbits].uniform_diffuseMap, texunit);
glUniform2fv(prprograms[programbits].uniform_diffuseScale, 1, material->diffusescale);
......@@ -5344,8 +5344,8 @@ static int32_t polymer_bindmaterial(const _prmaterial *material, const int1
// PR_BIT_HIGHPALOOKUP_MAP
if (programbits & prprogrambits[PR_BIT_HIGHPALOOKUP_MAP].bit)
{
glActiveTexture(texunit + GL_TEXTURE0);
glBindTexture(GL_TEXTURE_3D, material->highpalookupmap);
polymost_activeTexture(texunit + GL_TEXTURE0);
polymost_bindTexture(GL_TEXTURE_3D, material->highpalookupmap);
glUniform1i(prprograms[programbits].uniform_highPalookupMap, texunit);
......@@ -5367,8 +5367,8 @@ static int32_t polymer_bindmaterial(const _prmaterial *material, const int1
scale[1] = material->detailscale[1];
}
glActiveTexture(texunit + GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, material->detailmap);
polymost_activeTexture(texunit + GL_TEXTURE0);
polymost_bindTexture(GL_TEXTURE_2D, material->detailmap);
glUniform1i(prprograms[programbits].uniform_detailMap, texunit);
glUniform2fv(prprograms[programbits].uniform_detailScale, 1, scale);
......@@ -5388,8 +5388,8 @@ static int32_t polymer_bindmaterial(const _prmaterial *material, const int1
// PR_BIT_SPECULAR_MAP
if (programbits & prprogrambits[PR_BIT_SPECULAR_MAP].bit)
{
glActiveTexture(texunit + GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, material->specmap);
polymost_activeTexture(texunit + GL_TEXTURE0);
polymost_bindTexture(GL_TEXTURE_2D, material->specmap);
glUniform1i(prprograms[programbits].uniform_specMap, texunit);
......@@ -5412,8 +5412,8 @@ static int32_t polymer_bindmaterial(const _prmaterial *material, const int1
// PR_BIT_MIRROR_MAP
if (programbits & prprogrambits[PR_BIT_MIRROR_MAP].bit)
{
glActiveTexture(texunit + GL_TEXTURE0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, material->mirrormap);
polymost_activeTexture(texunit + GL_TEXTURE0);
polymost_bindTexture(GL_TEXTURE_RECTANGLE_ARB, material->mirrormap);
glUniform1i(prprograms[programbits].uniform_mirrorMap, texunit);
......@@ -5428,8 +5428,8 @@ static int32_t polymer_bindmaterial(const _prmaterial *material, const int1
// PR_BIT_GLOW_MAP
if (programbits & prprogrambits[PR_BIT_GLOW_MAP].bit)
{
glActiveTexture(texunit + GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, material->glowmap);
polymost_activeTexture(texunit + GL_TEXTURE0);
polymost_bindTexture(GL_TEXTURE_2D, material->glowmap);
glUniform1i(prprograms[programbits].uniform_glowMap, texunit);
......@@ -5497,8 +5497,8 @@ static int32_t polymer_bindmaterial(const _prmaterial *material, const int1
// PR_BIT_SHADOW_MAP
if (programbits & prprogrambits[PR_BIT_SHADOW_MAP].bit)
{
glActiveTexture(texunit + GL_TEXTURE0);
glBindTexture(prrts[prlights[lights[curlight]].rtindex].target, prrts[prlights[lights[curlight]].rtindex].z);
polymost_activeTexture(texunit + GL_TEXTURE0);
polymost_bindTexture(prrts[prlights[lights[curlight]].rtindex].target, prrts[prlights[lights[curlight]].rtindex].z);
glUniform1i(prprograms[programbits].uniform_shadowMap, texunit);
......@@ -5508,8 +5508,8 @@ static int32_t polymer_bindmaterial(const _prmaterial *material, const int1
// PR_BIT_LIGHT_MAP
if (programbits & prprogrambits[PR_BIT_LIGHT_MAP].bit)
{
glActiveTexture(texunit + GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, prlights[lights[curlight]].lightmap);
polymost_activeTexture(texunit + GL_TEXTURE0);
polymost_bindTexture(GL_TEXTURE_2D, prlights[lights[curlight]].lightmap);
glUniform1i(prprograms[programbits].uniform_lightMap, texunit);
......@@ -5544,7 +5544,7 @@ static int32_t polymer_bindmaterial(const _prmaterial *material, const int1
glLightfv(GL_LIGHT0, GL_LINEAR_ATTENUATION, &range[1]);
}
glActiveTexture(GL_TEXTURE0);
polymost_activeTexture(GL_TEXTURE0);
return programbits;
}
......@@ -6296,7 +6296,7 @@ static void polymer_initrendertargets(int32_t count)
prrts[i].ydim = ydim;
glGenTextures(1, &prrts[i].color);
glBindTexture(prrts[i].target, prrts[i].color);
polymost_bindTexture(prrts[i].target, prrts[i].color);
glTexImage2D(prrts[i].target, 0, GL_RGB, prrts[i].xdim, prrts[i].ydim, 0, GL_RGB, GL_SHORT, NULL);
glTexParameteri(prrts[i].target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
......@@ -6311,7 +6311,7 @@ static void polymer_initrendertargets(int32_t count)
if (pr_ati_fboworkaround) {
glGenTextures(1, &prrts[i].color);
glBindTexture(prrts[i].target, prrts[i].color);
polymost_bindTexture(prrts[i].target, prrts[i].color);
glTexImage2D(prrts[i].target, 0, GL_RGB, prrts[i].xdim, prrts[i].ydim, 0, GL_RGB, GL_SHORT, NULL);
glTexParameteri(prrts[i].target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
......@@ -6322,7 +6322,7 @@ static void polymer_initrendertargets(int32_t count)
}
glGenTextures(1, &prrts[i].z);
glBindTexture(prrts[i].target, prrts[i].z);
polymost_bindTexture(prrts[i].target, prrts[i].z);
glTexImage2D(prrts[i].target, 0, GL_DEPTH_COMPONENT, prrts[i].xdim, prrts[i].ydim, 0, GL_DEPTH_COMPONENT, GL_SHORT, NULL);
glTexParameteri(prrts[i].target, GL_TEXTURE_MIN_FILTER, pr_shadowfiltering ? GL_LINEAR : GL_NEAREST);
......@@ -6350,7 +6350,7 @@ static void polymer_initrendertargets(int32_t count)
OSD_Printf("PR : FBO #%d initialization failed.\n", i);
}
glBindTexture(prrts[i].target, 0);
polymost_bindTexture(prrts[i].target, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
i++;
......
......@@ -349,7 +349,7 @@ static void bind_2d_texture(GLuint texture, int filter)
if (filter == -1)
filter = gltexfiltermode;
glBindTexture(GL_TEXTURE_2D, texture);
polymost_bindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glfiltermodes[filter].mag);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, glfiltermodes[filter].min);
#ifdef USE_GLEXT
......@@ -636,11 +636,11 @@ void polymost_resetProgram()
polymost_useShaderProgram(polymost1CurrentShaderProgramID);
// ensure that palswapTexture and paletteTexture[curbasepal] is bound
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, palswapTextureID);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, paletteTextureIDs[curbasepal]);
glActiveTexture(GL_TEXTURE0);
polymost_activeTexture(GL_TEXTURE1);
polymost_bindTexture(GL_TEXTURE_2D, palswapTextureID);
polymost_activeTexture(GL_TEXTURE2);
polymost_bindTexture(GL_TEXTURE_2D, paletteTextureIDs[curbasepal]);
polymost_activeTexture(GL_TEXTURE0);
}
static void polymost_setCurrentShaderProgram(uint32_t programID)
......@@ -876,10 +876,11 @@ void polymost_shadeInterpolate(int32_t shadeInterpolate)
}
}
//POGOTODO: these wrappers won't be needed down the line -- remove them once proper draw call organization is finished
void polymost_activeTexture(GLenum texture)
{
currentActiveTexture = texture;
glad_glActiveTexture(texture);
glActiveTexture(texture);
}
//POGOTODO: replace this and polymost_activeTexture with proper draw call organization
......@@ -890,7 +891,7 @@ void polymost_bindTexture(GLenum target, uint32_t textureID)
currentActiveTexture != GL_TEXTURE0 ||
videoGetRenderMode() != REND_POLYMOST)
{
glad_glBindTexture(target, textureID);
glBindTexture(target, textureID);
if (currentActiveTexture == GL_TEXTURE0)
{
currentTextureID = textureID;
......@@ -924,7 +925,7 @@ static void polymost_bindPth(pthtyp const * const pPth)
}
polymost_setTexturePosSize(texturePosSize);
polymost_setHalfTexelSize(halfTexelSize);
glBindTexture(GL_TEXTURE_2D, pPth->glpic);
polymost_bindTexture(GL_TEXTURE_2D, pPth->glpic);
}
void polymost_useShaderProgram(uint32_t shaderID)
......@@ -1018,7 +1019,7 @@ void polymost_glinit()
for (int i = 0; i < numTilesheets; ++i)
{
glGenTextures(1, tilesheetTexIDs+i);
glBindTexture(GL_TEXTURE_2D, tilesheetTexIDs[i]);
polymost_bindTexture(GL_TEXTURE_2D, tilesheetTexIDs[i]);
uploadtextureindexed(true, {0, 0}, maxTexDimensions, (intptr_t) NULL);
}
......@@ -1026,7 +1027,7 @@ void polymost_glinit()
255, 255};
Tile blankTile;
tilepacker_getTile(0, &blankTile);
glBindTexture(GL_TEXTURE_2D, tilesheetTexIDs[blankTile.tilesheetID]);
polymost_bindTexture(GL_TEXTURE_2D, tilesheetTexIDs[blankTile.tilesheetID]);
uploadtextureindexed(false, {(int32_t) blankTile.rect.u, (int32_t) blankTile.rect.v}, {2, 2}, (intptr_t) blankTex);
quadVertsID = ids[1];
......@@ -1634,7 +1635,7 @@ static void Polymost_DetermineTextureFormatSupport(void)
GLuint tex = 0;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
polymost_bindTexture(GL_TEXTURE_2D, tex);
BuildGLErrorCheck(); // XXX: Clear errors.
......@@ -1902,7 +1903,7 @@ void uploadbasepalette(int32_t basepalnum)
{
glGenTextures(1, &paletteTextureIDs[basepalnum]);
}
glBindTexture(GL_TEXTURE_2D, paletteTextureIDs[basepalnum]);
polymost_bindTexture(GL_TEXTURE_2D, paletteTextureIDs[basepalnum]);
if (allocateTexture)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
......@@ -1937,7 +1938,7 @@ void uploadpalswap(int32_t palookupnum)
{
glGenTextures(1, &palswapTextureID);
}
glBindTexture(GL_TEXTURE_2D, palswapTextureID);
polymost_bindTexture(GL_TEXTURE_2D, palswapTextureID);
if (allocateTexture)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
......@@ -2061,7 +2062,7 @@ static void gloadtile_art_indexed(int32_t dapic, int32_t dameth, pthtyp *pth, in
{
glGenTextures(1, (GLuint *)&pth->glpic);
}
glBindTexture(GL_TEXTURE_2D, pth->glpic);
polymost_bindTexture(GL_TEXTURE_2D, pth->glpic);
if (doalloc)
{
......@@ -2269,7 +2270,7 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t das
}
if (doalloc) glGenTextures(1,(GLuint *)&pth->glpic); //# of textures (make OpenGL allocate structure)
glBindTexture(GL_TEXTURE_2D, pth->glpic);
polymost_bindTexture(GL_TEXTURE_2D, pth->glpic);
fixtransparency(pic,tsiz,siz,dameth);
......@@ -2609,7 +2610,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
if ((doalloc&3)==1)
glGenTextures(1, &pth->glpic); //# of textures (make OpenGL allocate structure)
glBindTexture(GL_TEXTURE_2D, pth->glpic);
polymost_bindTexture(GL_TEXTURE_2D, pth->glpic);
fixtransparency(pic,tsiz,siz,dameth);
......@@ -2710,9 +2711,9 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
#ifdef USE_GLEXT
void polymost_setupdetailtexture(const int32_t texunits, const int32_t tex)
{
glActiveTexture(texunits);
polymost_activeTexture(texunits);
glBindTexture(GL_TEXTURE_2D, tex);
polymost_bindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
......@@ -2723,9 +2724,9 @@ void polymost_setupdetailtexture(const int32_t texunits, const int32_t tex)
void polymost_setupglowtexture(const int32_t texunits, const int32_t tex)
{
glActiveTexture(texunits);
polymost_activeTexture(texunits);
glBindTexture(GL_TEXTURE_2D, tex);
polymost_bindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
......@@ -2873,13 +2874,13 @@ static void polymost2_drawVBO(GLenum mode,
return;
}
glActiveTexture(GL_TEXTURE1);
polymost_activeTexture(GL_TEXTURE1);
//POGO: temporarily swapped out blankTextureID for 0 (as the blank texture has been moved into the dynamic tilesheets)
glBindTexture(GL_TEXTURE_2D, (pth && pth->flags & PTH_HASFULLBRIGHT && r_fullbrights) ? pth->ofb->glpic : 0);
polymost_bindTexture(GL_TEXTURE_2D, (pth && pth->flags & PTH_HASFULLBRIGHT && r_fullbrights) ? pth->ofb->glpic : 0);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
glActiveTexture(GL_TEXTURE0);
polymost_activeTexture(GL_TEXTURE0);
polymost_bindPth(pth);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
......@@ -2983,10 +2984,10 @@ void polymost_updatePalette()
//POGO: only bind the base pal once when it's swapped
if (curbasepal != lastbasepal)
{
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, paletteTextureIDs[curbasepal]);
polymost_activeTexture(GL_TEXTURE2);
polymost_bindTexture(GL_TEXTURE_2D, paletteTextureIDs[curbasepal]);
lastbasepal = curbasepal;
glActiveTexture(GL_TEXTURE0);
polymost_activeTexture(GL_TEXTURE0);
}
}
......@@ -3313,7 +3314,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
glScalef(detailpth->hicr->scale.x, detailpth->hicr->scale.y, 1.0f);
glMatrixMode(GL_MODELVIEW);
glActiveTexture(GL_TEXTURE0);
polymost_activeTexture(GL_TEXTURE0);
}
}
......@@ -3328,7 +3329,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
{
polymost_useGlowMapping(true);
polymost_setupglowtexture(videoGetRenderMode() == REND_POLYMOST ? GL_TEXTURE4 : ++texunits, glowpth->glpic);
glActiveTexture(GL_TEXTURE0);
polymost_activeTexture(GL_TEXTURE0);
}
}
......@@ -3619,7 +3620,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
{
while (texunits > GL_TEXTURE0)
{
glActiveTexture(texunits);
polymost_activeTexture(texunits);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
......@@ -9698,7 +9699,7 @@ static int32_t gen_font_glyph_tex(void)
}
}
glBindTexture(GL_TEXTURE_2D, polymosttext);
polymost_bindTexture(GL_TEXTURE_2D, polymosttext);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,256,128,0,GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid *)tbuf);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
......@@ -9726,7 +9727,7 @@ int32_t polymost_printtext256(int32_t xpos, int32_t ypos, int16_t col, int16_t b
if (videoGetRenderMode() < REND_POLYMOST || !in3dmode() || (!polymosttext && gen_font_glyph_tex() < 0))
return -1;
glBindTexture(GL_TEXTURE_2D, polymosttext);
polymost_bindTexture(GL_TEXTURE_2D, polymosttext);
polymost_setTexturePosSize({0, 0, 1, 1});
polymost_usePaletteIndexing(false);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment