GL3: Replace glActiveTexture

--HG--
branch : opengl3
hg/feature/opengl3
kaetemi 11 years ago
parent 7ae15eb2b8
commit 641125963e

@ -460,7 +460,7 @@ bool CDriverGL3::setupDisplay()
_CurrentTexEnvSpecial[stage] = TexEnvSpecialDisabled;
// set All TexGen by default to identity matrix (prefer use the textureMatrix scheme)
_DriverGLStates.activeTextureARB(stage);
_DriverGLStates.activeTexture(stage);
}
if (!initProgramPipeline())
@ -974,8 +974,8 @@ void CDriverGL3::copyFrameBufferToTexture(ITexture *tex,
CTextureDrvInfosGL3* gltext = (CTextureDrvInfosGL3*)(ITextureDrvInfos*)(tex->TextureDrvShare->DrvTexture);
//if (_RenderTargetFBO)
// gltext->activeFrameBufferObject(NULL);
_DriverGLStates.activeTextureARB(0);
// setup texture mode, after activeTextureARB()
_DriverGLStates.activeTexture(0);
// setup texture mode, after activeTexture()
CDriverGLStates3::TTextureMode textureMode= CDriverGLStates3::Texture2D;
if (gltext->TextureMode == GL_TEXTURE_RECTANGLE)
@ -1158,7 +1158,7 @@ void CDriverGL3::setMatrix2DForTextureOffsetAddrMode(const uint stage, const flo
if (!supportTextureShaders()) return;
//nlassert(supportTextureShaders());
nlassert(stage < inlGetNumTextStages());
_DriverGLStates.activeTextureARB(stage);
_DriverGLStates.activeTexture(stage);
//glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, mat);
}
@ -1586,10 +1586,10 @@ void CDriverGL3::checkTextureOn() const
H_AUTO_OGL(CDriverGL3_checkTextureOn)
// tmp for debug
CDriverGLStates3 &dgs = const_cast<CDriverGLStates3 &>(_DriverGLStates);
uint currTexStage = dgs.getActiveTextureARB();
uint currTexStage = dgs.getActiveTexture();
for (uint k = 0; k < this->getNbTextureStages(); ++k)
{
dgs.activeTextureARB(k);
dgs.activeTexture(k);
GLboolean flag2D;
GLboolean flagCM;
GLboolean flagTR;
@ -1620,7 +1620,7 @@ void CDriverGL3::checkTextureOn() const
break;
}
}
dgs.activeTextureARB(currTexStage);
dgs.activeTexture(currTexStage);
}
// ***************************************************************************

@ -156,6 +156,8 @@ PFNGLBLITFRAMEBUFFERPROC nglBlitFramebuffer;
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC nglRenderbufferStorageMultisample;
PFNGLFRAMEBUFFERTEXTURELAYERPROC nglFramebufferTextureLayer;
PFNGLACTIVETEXTUREPROC nglActiveTexture;
PFNGLCOMPRESSEDTEXIMAGE3DPROC nglCompressedTexImage3D;
PFNGLCOMPRESSEDTEXIMAGE2DPROC nglCompressedTexImage2D;
PFNGLCOMPRESSEDTEXIMAGE1DPROC nglCompressedTexImage1D;
@ -436,6 +438,8 @@ static bool setupGLCore(const char *glext)
CHECK_ADDRESS(PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC, glRenderbufferStorageMultisample);
CHECK_ADDRESS(PFNGLFRAMEBUFFERTEXTURELAYERPROC, glFramebufferTextureLayer);
CHECK_ADDRESS(PFNGLACTIVETEXTUREPROC, glActiveTexture);
CHECK_ADDRESS(PFNGLCOMPRESSEDTEXIMAGE3DPROC, glCompressedTexImage3D);
CHECK_ADDRESS(PFNGLCOMPRESSEDTEXIMAGE2DPROC, glCompressedTexImage2D);
CHECK_ADDRESS(PFNGLCOMPRESSEDTEXIMAGE1DPROC, glCompressedTexImage1D);

@ -140,9 +140,9 @@ void registerGlExtensions(CGlExtensions &ext);
// ***************************************************************************
// The exported function names
/* NB: We named all like nglActiveTextureARB (n for NEL :)
/* NB: We named all like nglActiveTexture (n for NEL :)
to avoid compilation conflict with future version of gl.h
eg: gl.h Version 1.2 define glActiveTextureARB so we can't use it.
eg: gl.h Version 1.2 define glActiveTexture so we can't use it.
NB: we do it for all (EXT, NV, ARB extension) even it should be useful only for ARB ones.
*/
@ -240,6 +240,8 @@ extern PFNGLBLITFRAMEBUFFERPROC nglBlitFramebuffer;
extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC nglRenderbufferStorageMultisample;
extern PFNGLFRAMEBUFFERTEXTURELAYERPROC nglFramebufferTextureLayer;
extern PFNGLACTIVETEXTUREPROC nglActiveTexture;
extern PFNGLCOMPRESSEDTEXIMAGE3DPROC nglCompressedTexImage3D;
extern PFNGLCOMPRESSEDTEXIMAGE2DPROC nglCompressedTexImage2D;
extern PFNGLCOMPRESSEDTEXIMAGE1DPROC nglCompressedTexImage1D;

@ -128,7 +128,7 @@ void CDriverGL3::setTextureEnvFunction(uint stage, CMaterial& mat)
activateTexEnvColor(stage, env);
// Activate texture generation mapping
_DriverGLStates.activeTextureARB(stage);
_DriverGLStates.activeTexture(stage);
if (mat.getTexCoordGen (stage))
{
// set mode and enable.
@ -820,7 +820,7 @@ void CDriverGL3::setupLightMapPass(uint pass)
_DriverGLStates.setEmissive(packedColorBlack, glcolBlack);
// Setup gen tex off
_DriverGLStates.activeTextureARB(0);
_DriverGLStates.activeTexture(0);
_DriverGLStates.setTexGenMode(0, 0);
// And disable other stages.
@ -922,7 +922,7 @@ void CDriverGL3::setupLightMapPass(uint pass)
activateTexEnvColor(stage, stdEnv);
// Setup env for texture stage.
_DriverGLStates.activeTextureARB(stage);
_DriverGLStates.activeTexture(stage);
_DriverGLStates.setTexGenMode(stage, 0);
// setup TexEnvCombine4 (ignore alpha part).
@ -951,7 +951,7 @@ void CDriverGL3::setupLightMapPass(uint pass)
activateTexEnvMode(stage, _LightMapLastStageEnv);
// Setup gen tex off
_DriverGLStates.activeTextureARB(stage);
_DriverGLStates.activeTexture(stage);
_DriverGLStates.setTexGenMode(stage, 0);
int tl = currentProgram.pp->getUniformIndex(CProgramIndex::TName(CProgramIndex::Sampler0 + stage));
@ -1080,13 +1080,13 @@ void CDriverGL3::setupSpecularBegin()
activateTexEnvMode(0, env);
// Disable texGen for stage 0
_DriverGLStates.activeTextureARB(0);
_DriverGLStates.activeTexture(0);
_DriverGLStates.setTexGenMode(0, 0);
// ---- Stage 1 Common Setup.
// NB don't setup the TexEnv here (stage1 setuped in setupSpecularPass() according to extensions)
// For all cases, setup the TexCoord gen for stage1
_DriverGLStates.activeTextureARB(1);
_DriverGLStates.activeTexture(1);
// setup the good matrix for stage 1.
_UserTexMat[ 1 ] = _SpecularTexMtx;
@ -1098,7 +1098,7 @@ void CDriverGL3::setupSpecularEnd()
{
H_AUTO_OGL(CDriverGL3_setupSpecularEnd)
// Disable Texture coord generation.
_DriverGLStates.activeTextureARB(1);
_DriverGLStates.activeTexture(1);
_DriverGLStates.setTexGenMode(1, 0);
// Happiness !!! we have already enabled the stage 1
@ -1181,7 +1181,7 @@ void CDriverGL3::setupSpecularPass(uint pass)
// TexEnv is special.
_CurrentTexEnvSpecial[1] = newEnvStage1;
_DriverGLStates.activeTextureARB(1);
_DriverGLStates.activeTexture(1);
}
}

@ -84,7 +84,6 @@ void CDriverGLStates3::forceDefaults(uint nbStages)
_CurLighting= false;
_CurZWrite= true;
_CurStencilTest=false;
_CurMultisample= false;
// setup GLStates.
glDisable(GL_FOG);
@ -93,7 +92,6 @@ void CDriverGLStates3::forceDefaults(uint nbStages)
glDisable(GL_ALPHA_TEST);
glDisable(GL_LIGHTING);
glDepthMask(GL_TRUE);
glDisable(GL_MULTISAMPLE_ARB);
// Func.
_CurBlendSrc= GL_SRC_ALPHA;
@ -137,7 +135,7 @@ void CDriverGLStates3::forceDefaults(uint nbStages)
for (stage=0;stage<nbStages; stage++)
{
// disable texturing.
// nglActiveTextureARB(GL_TEXTURE0_ARB+stage); // FIXME GL3 TEXTURE
nglActiveTexture(GL_TEXTURE0 + stage);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_CUBE_MAP);
@ -156,11 +154,10 @@ void CDriverGLStates3::forceDefaults(uint nbStages)
}
// ActiveTexture current texture to 0.
// nglActiveTextureARB(GL_TEXTURE0_ARB); // FIXME GL3 TEXTURE
// nglClientActiveTextureARB(GL_TEXTURE0_ARB); // FIXME GL3 TEXTURE
nglActiveTexture(GL_TEXTURE0);
_CurrentActiveTextureARB= 0;
_CurrentClientActiveTextureARB= 0;
_CurrentActiveTexture= 0;
_CurrentClientActiveTexture= 0;
// Depth range
_DepthRangeNear = 0.f;
@ -326,27 +323,6 @@ void CDriverGLStates3::enableStencilTest(bool enable)
}
}
// ***************************************************************************
void CDriverGLStates3::enableMultisample(bool enable)
{
H_AUTO_OGL(CDriverGLStates3_enableMultisample);
// If different from current setup, update.
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if (enable != _CurMultisample)
#endif
{
// new state.
_CurMultisample= enable;
// Setup GLState.
if (_CurMultisample)
glEnable(GL_MULTISAMPLE_ARB);
else
glDisable(GL_MULTISAMPLE_ARB);
}
}
// ***************************************************************************
void CDriverGLStates3::blendFunc(GLenum src, GLenum dst)
{
@ -592,7 +568,7 @@ void CDriverGLStates3::resetTextureMode()
{
H_AUTO_OGL(CDriverGLStates3_resetTextureMode);
_TextureMode[_CurrentActiveTextureARB]= TextureDisabled;
_TextureMode[_CurrentActiveTexture]= TextureDisabled;
}
@ -600,37 +576,37 @@ void CDriverGLStates3::resetTextureMode()
void CDriverGLStates3::setTextureMode(TTextureMode texMode)
{
H_AUTO_OGL(CDriverGLStates3_setTextureMode)
TTextureMode oldTexMode = _TextureMode[_CurrentActiveTextureARB];
TTextureMode oldTexMode = _TextureMode[_CurrentActiveTexture];
if (oldTexMode != texMode)
{
// new mode.
_TextureMode[_CurrentActiveTextureARB]= texMode;
_TextureMode[_CurrentActiveTexture]= texMode;
}
}
// ***************************************************************************
void CDriverGLStates3::activeTextureARB(uint stage)
void CDriverGLStates3::activeTexture(uint stage)
{
H_AUTO_OGL(CDriverGLStates3_activeTextureARB);
H_AUTO_OGL(CDriverGLStates3_activeTexture);
if (_CurrentActiveTextureARB != stage)
if (_CurrentActiveTexture != stage)
{
// nglActiveTextureARB(GL_TEXTURE0_ARB+stage); // FIXME GL3 TEXTURE
nglActiveTexture(GL_TEXTURE0 + stage);
_CurrentActiveTextureARB= stage;
_CurrentActiveTexture = stage;
}
}
// ***************************************************************************
void CDriverGLStates3::forceActiveTextureARB(uint stage)
void CDriverGLStates3::forceActiveTexture(uint stage)
{
H_AUTO_OGL(CDriverGLStates3_forceActiveTextureARB);
H_AUTO_OGL(CDriverGLStates3_forceActiveTexture);
// nglActiveTextureARB(GL_TEXTURE0_ARB+stage); // FIXME GL3 TEXTURE
nglActiveTexture(GL_TEXTURE0 + stage);
_CurrentActiveTextureARB= stage;
_CurrentActiveTexture= stage;
}
// ***************************************************************************

@ -43,8 +43,8 @@ namespace NLDRIVERGL3 {
- GL_COLOR_MATERIAL
- GL_FOG
- GL_MULTISAMPLE_ARB
- glActiveTextureARB()
- glClientActiveTextureARB()
- glActiveTexture()
- glClientActiveTexture()
- glEnableClientState() glDisableClientState() with:
- GL_VERTEX_ARRAY
- GL_NORMAL_ARRAY
@ -98,9 +98,6 @@ public:
/// enable/disable stencil test
void enableStencilTest(bool enable);
bool isStencilTestEnabled() const { return _CurStencilTest; }
/// enable/disable multisample
void enableMultisample(bool enable);
bool isMultisampleEnabled() const { return _CurMultisample; }
// @}
/// glBlendFunc.
@ -140,17 +137,17 @@ public:
/// \name Texture Mode setting.
// @{
enum TTextureMode {TextureDisabled, Texture2D, TextureRect, TextureCubeMap, TextureModeCount};
/// same as glActiveTextureARB(). useful for setTextureMode.
void activeTextureARB(uint stage);
/// same as glActiveTexture(). useful for setTextureMode.
void activeTexture(uint stage);
/// same as active texture arb, but with no cache check
void forceActiveTextureARB(uint stage);
void forceActiveTexture(uint stage);
/// get active texture
uint getActiveTextureARB() const { return _CurrentActiveTextureARB; }
uint getActiveTexture() const { return _CurrentActiveTexture; }
/** change if needed the texture mode of the current active Texture ARB.
* NB: if CubeMap extension not supported, TextureCubeMap <=> TextureDisabled.
*/
void setTextureMode(TTextureMode texMode);
TTextureMode getTextureMode() const { return _TextureMode[_CurrentActiveTextureARB]; }
TTextureMode getTextureMode() const { return _TextureMode[_CurrentActiveTexture]; }
// reset texture mode to the default (disabled) for the current stage. It forces the state (useful after texture shaders)
void resetTextureMode();
// @}
@ -176,7 +173,6 @@ private:
bool _CurLighting;
bool _CurZWrite;
bool _CurStencilTest;
bool _CurMultisample;
GLenum _CurBlendSrc;
GLenum _CurBlendDst;
@ -197,7 +193,7 @@ private:
float _CurShininess;
bool _VertexColorLighted;
uint _CurrentActiveTextureARB;
uint _CurrentActiveTexture;
TTextureMode _TextureMode[8];
bool _VertexArrayEnabled;
@ -205,7 +201,7 @@ private:
bool _WeightArrayEnabled;
bool _ColorArrayEnabled;
bool _SecondaryColorArrayEnabled;
uint _CurrentClientActiveTextureARB;
uint _CurrentClientActiveTexture;
bool _TexCoordArrayEnabled[8];
bool _VertexAttribArrayEnabled[CVertexBuffer::NumValue];

@ -597,7 +597,7 @@ void CDriverGL3::bindTextureWithMode(ITexture &tex)
CTextureDrvInfosGL3* gltext;
gltext= getTextureGl(tex);
// system of "backup the previous binded texture" seems to not work with some drivers....
_DriverGLStates.activeTextureARB(0);
_DriverGLStates.activeTexture(0);
if (tex.isTextureCube())
{
_DriverGLStates.setTextureMode(CDriverGLStates3::TextureCubeMap);
@ -1118,7 +1118,7 @@ bool CDriverGL3::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap)
gltext = getTextureGl (tex);
// system of "backup the previous binded texture" seems to not work with some drivers....
_DriverGLStates.activeTextureARB (0);
_DriverGLStates.activeTexture (0);
CDriverGLStates3::TTextureMode textureMode= CDriverGLStates3::Texture2D;
if (gltext->TextureMode == GL_TEXTURE_RECTANGLE)
@ -1238,7 +1238,7 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex)
H_AUTO_OGL(activateTexture)
if (this->_CurrentTexture[stage]!=tex)
{
_DriverGLStates.activeTextureARB(stage);
_DriverGLStates.activeTexture(stage);
if (tex && tex->TextureDrvShare)
{
// get the drv info. should be not NULL.
@ -1255,7 +1255,7 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex)
if (tex->isTextureCube())
{
// setup texture mode, after activeTextureARB()
// setup texture mode, after activeTexture()
_DriverGLStates.setTextureMode(CDriverGLStates3::TextureCubeMap);
// Activate texturing...
@ -1286,7 +1286,7 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex)
}
else
{
// setup texture mode, after activeTextureARB()
// setup texture mode, after activeTexture()
CDriverGLStates3::TTextureMode textureMode= CDriverGLStates3::Texture2D;
if (gltext->TextureMode == GL_TEXTURE_RECTANGLE)
textureMode = CDriverGLStates3::TextureRect;
@ -1334,7 +1334,7 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex)
{
// Force no texturing for this stage.
_CurrentTextureInfoGL[stage]= NULL;
// setup texture mode, after activeTextureARB()
// setup texture mode, after activeTexture()
_DriverGLStates.setTextureMode(CDriverGLStates3::TextureDisabled);
/*if (_Extensions.ATITextureEnvCombine3)

Loading…
Cancel
Save