Even more OpenGL ES cleanup.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 11 years ago
parent 2b5eddbe95
commit e44b663bdb

@ -20,12 +20,8 @@
namespace NL3D { namespace NL3D {
#ifdef NL_STATIC #ifdef NL_STATIC
#ifdef USE_OPENGLES
namespace NLDRIVERGLES {
#else
namespace NLDRIVERGL3 { namespace NLDRIVERGL3 {
#endif #endif
#endif
// *************************************************************************** // ***************************************************************************
void CDriverGL3::setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective) void CDriverGL3::setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective)
@ -36,21 +32,9 @@ void CDriverGL3::setFrustum(float left, float right, float bottom, float top, fl
glLoadIdentity(); glLoadIdentity();
if (perspective) if (perspective)
{
#ifdef USE_OPENGLES
glFrustumf(left,right,bottom,top,znear,zfar);
#else
glFrustum(left,right,bottom,top,znear,zfar); glFrustum(left,right,bottom,top,znear,zfar);
#endif
}
else else
{
#ifdef USE_OPENGLES
glOrthof(left,right,bottom,top,znear,zfar);
#else
glOrtho(left,right,bottom,top,znear,zfar); glOrtho(left,right,bottom,top,znear,zfar);
#endif
}
_ProjMatDirty = true; _ProjMatDirty = true;

@ -25,12 +25,8 @@
namespace NL3D { namespace NL3D {
#ifdef NL_STATIC #ifdef NL_STATIC
#ifdef USE_OPENGLES
namespace NLDRIVERGLES {
#else
namespace NLDRIVERGL3 { namespace NLDRIVERGL3 {
#endif #endif
#endif
// *************************************************************************** // ***************************************************************************
CDriverGLStates3::CDriverGLStates3() CDriverGLStates3::CDriverGLStates3()
@ -155,28 +151,17 @@ void CDriverGLStates3::forceDefaults(uint nbStages)
for(stage=0;stage<nbStages; stage++) for(stage=0;stage<nbStages; stage++)
{ {
// disable texturing. // disable texturing.
#ifdef USE_OPENGLES
glActiveTexture(GL_TEXTURE0+stage);
#else
nglActiveTextureARB(GL_TEXTURE0_ARB+stage); nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
#endif
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
if(_TextureCubeMapSupported) if(_TextureCubeMapSupported)
{
glDisable(GL_TEXTURE_CUBE_MAP_ARB); glDisable(GL_TEXTURE_CUBE_MAP_ARB);
#ifdef USE_OPENGLES
glDisable(GL_TEXTURE_GEN_STR_OES);
#endif
}
_TextureMode[stage]= TextureDisabled; _TextureMode[stage]= TextureDisabled;
// Tex gen init // Tex gen init
_TexGenMode[stage] = 0; _TexGenMode[stage] = 0;
#ifndef USE_OPENGLES
if(_TextureRectangleSupported) if(_TextureRectangleSupported)
glDisable(GL_TEXTURE_RECTANGLE_NV); glDisable(GL_TEXTURE_RECTANGLE_NV);
@ -184,17 +169,11 @@ void CDriverGLStates3::forceDefaults(uint nbStages)
glDisable(GL_TEXTURE_GEN_T); glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_R); glDisable(GL_TEXTURE_GEN_R);
glDisable(GL_TEXTURE_GEN_Q); glDisable(GL_TEXTURE_GEN_Q);
#endif
} }
// ActiveTexture current texture to 0. // ActiveTexture current texture to 0.
#ifdef USE_OPENGLES
glActiveTexture(GL_TEXTURE0);
glClientActiveTexture(GL_TEXTURE0);
#else
nglActiveTextureARB(GL_TEXTURE0_ARB); nglActiveTextureARB(GL_TEXTURE0_ARB);
nglClientActiveTextureARB(GL_TEXTURE0_ARB); nglClientActiveTextureARB(GL_TEXTURE0_ARB);
#endif
_CurrentActiveTextureARB= 0; _CurrentActiveTextureARB= 0;
_CurrentClientActiveTextureARB= 0; _CurrentClientActiveTextureARB= 0;
@ -204,11 +183,7 @@ void CDriverGLStates3::forceDefaults(uint nbStages)
_DepthRangeFar = 1.f; _DepthRangeFar = 1.f;
_ZBias = 0.f; _ZBias = 0.f;
#ifdef USE_OPENGLES
glDepthRangef (0.f, 1.f);
#else
glDepthRange (0, 1); glDepthRange (0, 1);
#endif
// Cull order // Cull order
_CullMode = CCW; _CullMode = CCW;
@ -594,9 +569,7 @@ void CDriverGLStates3::setVertexColorLighted(bool enable)
if (_VertexColorLighted) if (_VertexColorLighted)
{ {
glEnable (GL_COLOR_MATERIAL); glEnable (GL_COLOR_MATERIAL);
#ifndef USE_OPENGLES
glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE); glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE);
#endif
} }
else else
{ {
@ -622,11 +595,8 @@ void CDriverGLStates3::updateDepthRange()
float delta = _ZBias * (_DepthRangeFar - _DepthRangeNear); float delta = _ZBias * (_DepthRangeFar - _DepthRangeNear);
#ifdef USE_OPENGLES
glDepthRangef(delta + _DepthRangeNear, delta + _DepthRangeFar);
#else
glDepthRange(delta + _DepthRangeNear, delta + _DepthRangeFar); glDepthRange(delta + _DepthRangeNear, delta + _DepthRangeFar);
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -684,13 +654,9 @@ void CDriverGLStates3::setTexGenMode (uint stage, GLint mode)
} }
else else
{ {
#ifdef USE_OPENGLES
nglTexGeniOES(GL_TEXTURE_GEN_STR_OES, GL_TEXTURE_GEN_MODE_OES, mode);
#else
glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, mode); glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, mode);
glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, mode); glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, mode);
glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, mode); glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, mode);
#endif
/* Object or Eye Space ? => enable W generation. VERY IMPORTANT because /* Object or Eye Space ? => enable W generation. VERY IMPORTANT because
was a bug with VegetableRender and ShadowRender: was a bug with VegetableRender and ShadowRender:
@ -698,17 +664,7 @@ void CDriverGLStates3::setTexGenMode (uint stage, GLint mode)
- Shadow Render don't use any TexCoord in VB (since projected) - Shadow Render don't use any TexCoord in VB (since projected)
=> TexCoord1.w dirty!! => TexCoord1.w dirty!!
*/ */
#ifdef USE_OPENGLES
// if(mode==GL_OBJECT_LINEAR || mode==GL_EYE_LINEAR)
// {
// nglTexGeniOES(GL_TEXTURE_GEN_STR_OES, GL_TEXTURE_GEN_MODE_OES, mode);
// glEnable(GL_TEXTURE_GEN_STR_OES);
// }
// else
// {
// glDisable(GL_TEXTURE_GEN_STR_OES);
// }
#else
if(mode==GL_OBJECT_LINEAR || mode==GL_EYE_LINEAR) if(mode==GL_OBJECT_LINEAR || mode==GL_EYE_LINEAR)
{ {
glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, mode); glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, mode);
@ -718,16 +674,11 @@ void CDriverGLStates3::setTexGenMode (uint stage, GLint mode)
{ {
glDisable( GL_TEXTURE_GEN_Q ); glDisable( GL_TEXTURE_GEN_Q );
} }
#endif
// Enable All. // Enable All.
#ifdef USE_OPENGLES
glEnable(GL_TEXTURE_GEN_STR_OES);
#else
glEnable( GL_TEXTURE_GEN_S ); glEnable( GL_TEXTURE_GEN_S );
glEnable( GL_TEXTURE_GEN_T ); glEnable( GL_TEXTURE_GEN_T );
glEnable( GL_TEXTURE_GEN_R ); glEnable( GL_TEXTURE_GEN_R );
#endif
} }
} }
} }
@ -744,12 +695,10 @@ void CDriverGLStates3::resetTextureMode()
glDisable(GL_TEXTURE_CUBE_MAP_ARB); glDisable(GL_TEXTURE_CUBE_MAP_ARB);
} }
#ifndef USE_OPENGLES
if (_TextureRectangleSupported) if (_TextureRectangleSupported)
{ {
glDisable(GL_TEXTURE_RECTANGLE_NV); glDisable(GL_TEXTURE_RECTANGLE_NV);
} }
#endif
_TextureMode[_CurrentActiveTextureARB]= TextureDisabled; _TextureMode[_CurrentActiveTextureARB]= TextureDisabled;
} }
@ -769,13 +718,11 @@ void CDriverGLStates3::setTextureMode(TTextureMode texMode)
} }
else if(oldTexMode == TextureRect) else if(oldTexMode == TextureRect)
{ {
#ifndef USE_OPENGLES
if(_TextureRectangleSupported) if(_TextureRectangleSupported)
{ {
glDisable(GL_TEXTURE_RECTANGLE_NV); glDisable(GL_TEXTURE_RECTANGLE_NV);
} }
else else
#endif
{ {
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
} }
@ -799,13 +746,11 @@ void CDriverGLStates3::setTextureMode(TTextureMode texMode)
} }
else if(texMode == TextureRect) else if(texMode == TextureRect)
{ {
#ifndef USE_OPENGLES
if(_TextureRectangleSupported) if(_TextureRectangleSupported)
{ {
glEnable(GL_TEXTURE_RECTANGLE_NV); glEnable(GL_TEXTURE_RECTANGLE_NV);
} }
else else
#endif
{ {
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
} }
@ -835,11 +780,7 @@ void CDriverGLStates3::activeTextureARB(uint stage)
if( _CurrentActiveTextureARB != stage ) if( _CurrentActiveTextureARB != stage )
{ {
#ifdef USE_OPENGLES
glActiveTexture(GL_TEXTURE0+stage);
#else
nglActiveTextureARB(GL_TEXTURE0_ARB+stage); nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
#endif
_CurrentActiveTextureARB= stage; _CurrentActiveTextureARB= stage;
} }
@ -850,11 +791,7 @@ void CDriverGLStates3::forceActiveTextureARB(uint stage)
{ {
H_AUTO_OGL(CDriverGLStates3_forceActiveTextureARB); H_AUTO_OGL(CDriverGLStates3_forceActiveTextureARB);
#ifdef USE_OPENGLES
glActiveTexture(GL_TEXTURE0+stage);
#else
nglActiveTextureARB(GL_TEXTURE0_ARB+stage); nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
#endif
_CurrentActiveTextureARB= stage; _CurrentActiveTextureARB= stage;
} }
@ -896,12 +833,10 @@ void CDriverGLStates3::enableWeightArray(bool enable)
if(_WeightArrayEnabled != enable) if(_WeightArrayEnabled != enable)
{ {
#ifndef USE_OPENGLES
if(enable) if(enable)
glEnableClientState(GL_VERTEX_WEIGHTING_EXT); glEnableClientState(GL_VERTEX_WEIGHTING_EXT);
else else
glDisableClientState(GL_VERTEX_WEIGHTING_EXT); glDisableClientState(GL_VERTEX_WEIGHTING_EXT);
#endif
_WeightArrayEnabled= enable; _WeightArrayEnabled= enable;
} }
@ -931,23 +866,19 @@ void CDriverGLStates3::enableSecondaryColorArray(bool enable)
if(_SecondaryColorArrayEnabled != enable) if(_SecondaryColorArrayEnabled != enable)
{ {
#ifndef USE_OPENGLES
if(enable) if(enable)
glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT); glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
else else
glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT); glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
#endif
_SecondaryColorArrayEnabled= enable; _SecondaryColorArrayEnabled= enable;
#ifndef USE_OPENGLES
// If disable // If disable
if(!enable) if(!enable)
{ {
// GeForceFx Bug: Must reset Secondary color to 0 (if comes from a VP), else bugs // GeForceFx Bug: Must reset Secondary color to 0 (if comes from a VP), else bugs
nglSecondaryColor3ubEXT(0,0,0); nglSecondaryColor3ubEXT(0,0,0);
} }
#endif
} }
} }
@ -958,11 +889,7 @@ void CDriverGLStates3::clientActiveTextureARB(uint stage)
if( _CurrentClientActiveTextureARB != stage ) if( _CurrentClientActiveTextureARB != stage )
{ {
#ifdef USE_OPENGLES
glClientActiveTexture(GL_TEXTURE0+stage);
#else
nglClientActiveTextureARB(GL_TEXTURE0_ARB+stage); nglClientActiveTextureARB(GL_TEXTURE0_ARB+stage);
#endif
_CurrentClientActiveTextureARB= stage; _CurrentClientActiveTextureARB= stage;
} }
} }
@ -991,13 +918,10 @@ void CDriverGLStates3::enableVertexAttribArray(uint glIndex, bool enable)
if(_VertexAttribArrayEnabled[glIndex] != enable) if(_VertexAttribArrayEnabled[glIndex] != enable)
{ {
#ifndef USE_OPENGLES
if(enable) if(enable)
glEnableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV); glEnableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV);
else else
glDisableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV); glDisableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV);
#endif
_VertexAttribArrayEnabled[glIndex]= enable; _VertexAttribArrayEnabled[glIndex]= enable;
} }
} }
@ -1011,12 +935,10 @@ void CDriverGLStates3::enableVertexAttribArrayARB(uint glIndex,bool enable)
if(_VertexAttribArrayEnabled[glIndex] != enable) if(_VertexAttribArrayEnabled[glIndex] != enable)
#endif #endif
{ {
#ifndef USE_OPENGLES
if(enable) if(enable)
nglEnableVertexAttribArrayARB(glIndex); nglEnableVertexAttribArrayARB(glIndex);
else else
nglDisableVertexAttribArrayARB(glIndex); nglDisableVertexAttribArrayARB(glIndex);
#endif
_VertexAttribArrayEnabled[glIndex]= enable; _VertexAttribArrayEnabled[glIndex]= enable;
} }
@ -1035,12 +957,10 @@ void CDriverGLStates3::enableVertexAttribArrayForEXTVertexShader(uint glIndex, b
enableVertexArray(enable); enableVertexArray(enable);
break; break;
case 1: // skin weight case 1: // skin weight
#ifndef USE_OPENGLES
if(enable) if(enable)
nglEnableVariantClientStateEXT(variants[CDriverGL3::EVSSkinWeightVariant]); nglEnableVariantClientStateEXT(variants[CDriverGL3::EVSSkinWeightVariant]);
else else
nglDisableVariantClientStateEXT(variants[CDriverGL3::EVSSkinWeightVariant]); nglDisableVariantClientStateEXT(variants[CDriverGL3::EVSSkinWeightVariant]);
#endif
break; break;
case 2: // normal case 2: // normal
enableNormalArray(enable); enableNormalArray(enable);
@ -1049,28 +969,22 @@ void CDriverGLStates3::enableVertexAttribArrayForEXTVertexShader(uint glIndex, b
enableColorArray(enable); enableColorArray(enable);
break; break;
case 4: // secondary color case 4: // secondary color
#ifndef USE_OPENGLES
if(enable) if(enable)
nglEnableVariantClientStateEXT(variants[CDriverGL3::EVSSecondaryColorVariant]); nglEnableVariantClientStateEXT(variants[CDriverGL3::EVSSecondaryColorVariant]);
else else
nglDisableVariantClientStateEXT(variants[CDriverGL3::EVSSecondaryColorVariant]); nglDisableVariantClientStateEXT(variants[CDriverGL3::EVSSecondaryColorVariant]);
#endif
break; break;
case 5: // fog coordinate case 5: // fog coordinate
#ifndef USE_OPENGLES
if(enable) if(enable)
nglEnableVariantClientStateEXT(variants[CDriverGL3::EVSFogCoordsVariant]); nglEnableVariantClientStateEXT(variants[CDriverGL3::EVSFogCoordsVariant]);
else else
nglDisableVariantClientStateEXT(variants[CDriverGL3::EVSFogCoordsVariant]); nglDisableVariantClientStateEXT(variants[CDriverGL3::EVSFogCoordsVariant]);
#endif
break; break;
case 6: // palette skin case 6: // palette skin
#ifndef USE_OPENGLES
if(enable) if(enable)
nglEnableVariantClientStateEXT(variants[CDriverGL3::EVSPaletteSkinVariant]); nglEnableVariantClientStateEXT(variants[CDriverGL3::EVSPaletteSkinVariant]);
else else
nglDisableVariantClientStateEXT(variants[CDriverGL3::EVSPaletteSkinVariant]); nglDisableVariantClientStateEXT(variants[CDriverGL3::EVSPaletteSkinVariant]);
#endif
break; break;
case 7: // empty case 7: // empty
nlstop; nlstop;
@ -1121,11 +1035,7 @@ void CDriverGLStates3::forceBindARBVertexBuffer(uint objectID)
{ {
H_AUTO_OGL(CDriverGLStates3_forceBindARBVertexBuffer) H_AUTO_OGL(CDriverGLStates3_forceBindARBVertexBuffer)
#ifdef USE_OPENGLES
glBindBuffer(GL_ARRAY_BUFFER, objectID);
#else
nglBindBufferARB(GL_ARRAY_BUFFER_ARB, objectID); nglBindBufferARB(GL_ARRAY_BUFFER_ARB, objectID);
#endif
_CurrARBVertexBuffer = objectID; _CurrARBVertexBuffer = objectID;
} }

@ -44,12 +44,8 @@ using namespace std;
namespace NL3D { namespace NL3D {
#ifdef NL_STATIC #ifdef NL_STATIC
#ifdef USE_OPENGLES
namespace NLDRIVERGLES {
#else
namespace NLDRIVERGL3 { namespace NLDRIVERGL3 {
#endif #endif
#endif
// *************************************************************************** // ***************************************************************************
CTextureDrvInfosGL3::CTextureDrvInfosGL3(IDriver *drv, ItTexDrvInfoPtrMap it, CDriverGL3 *drvGl, bool isRectangleTexture) : ITextureDrvInfos(drv, it) CTextureDrvInfosGL3::CTextureDrvInfosGL3(IDriver *drv, ItTexDrvInfoPtrMap it, CDriverGL3 *drvGl, bool isRectangleTexture) : ITextureDrvInfos(drv, it)
@ -66,11 +62,7 @@ CTextureDrvInfosGL3::CTextureDrvInfosGL3(IDriver *drv, ItTexDrvInfoPtrMap it, CD
// Nb: at Driver dtor, all tex infos are deleted, so _Driver is always valid. // Nb: at Driver dtor, all tex infos are deleted, so _Driver is always valid.
_Driver= drvGl; _Driver= drvGl;
#ifdef USE_OPENGLES
TextureMode = GL_TEXTURE_2D;
#else
TextureMode = isRectangleTexture?GL_TEXTURE_RECTANGLE_NV:GL_TEXTURE_2D; TextureMode = isRectangleTexture?GL_TEXTURE_RECTANGLE_NV:GL_TEXTURE_2D;
#endif
FBOId = 0; FBOId = 0;
DepthFBOId = 0; DepthFBOId = 0;
@ -95,15 +87,6 @@ CTextureDrvInfosGL3::~CTextureDrvInfosGL3()
if(InitFBO) if(InitFBO)
{ {
#ifdef USE_OPENGLES
nglDeleteFramebuffersOES(1, &FBOId);
if(AttachDepthStencil)
{
nglDeleteRenderbuffersOES(1, &DepthFBOId);
if(!UsePackedDepthStencil)
nglDeleteRenderbuffersOES(1, &StencilFBOId);
}
#else
nglDeleteFramebuffersEXT(1, &FBOId); nglDeleteFramebuffersEXT(1, &FBOId);
if(AttachDepthStencil) if(AttachDepthStencil)
{ {
@ -111,7 +94,6 @@ CTextureDrvInfosGL3::~CTextureDrvInfosGL3()
if(!UsePackedDepthStencil) if(!UsePackedDepthStencil)
nglDeleteRenderbuffersEXT(1, &StencilFBOId); nglDeleteRenderbuffersEXT(1, &StencilFBOId);
} }
#endif
} }
} }
@ -125,53 +107,6 @@ bool CTextureDrvInfosGL3::initFrameBufferObject(ITexture * tex)
AttachDepthStencil = !((CTextureBloom*)tex)->isMode2D(); AttachDepthStencil = !((CTextureBloom*)tex)->isMode2D();
} }
#ifdef USE_OPENGLES
// generate IDs
nglGenFramebuffersOES(1, &FBOId);
if(AttachDepthStencil)
{
nglGenRenderbuffersOES(1, &DepthFBOId);
if(UsePackedDepthStencil)
StencilFBOId = DepthFBOId;
else
nglGenRenderbuffersOES(1, &StencilFBOId);
}
//nldebug("3D: using depth %d and stencil %d", DepthFBOId, StencilFBOId);
// initialize FBO
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, FBOId);
nglFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, TextureMode, ID, 0);
// attach depth/stencil render to FBO
// note: for some still unkown reason it's impossible to add
// a stencil buffer as shown in the respective docs (see
// opengl.org extension registry). Until a safe approach to add
// them is found, there will be no attached stencil for the time
// being, aside of using packed depth+stencil buffers.
if(AttachDepthStencil)
{
if(UsePackedDepthStencil)
{
//nldebug("3D: using packed depth stencil");
nglBindRenderbufferOES(GL_RENDERBUFFER_OES, StencilFBOId);
nglRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH24_STENCIL8_OES, tex->getWidth(), tex->getHeight());
}
else
{
nglBindRenderbufferOES(GL_RENDERBUFFER_OES, DepthFBOId);
nglRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT24_OES, tex->getWidth(), tex->getHeight());
/*
nglBindRenderbufferEXT(GL_RENDERBUFFER_OES, StencilFBOId);
nglRenderbufferStorageEXT(GL_RENDERBUFFER_OES, GL_STENCIL_INDEX8_EXT, tex->getWidth(), tex->getHeight());
*/
}
nglFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, DepthFBOId);
nldebug("3D: glFramebufferRenderbufferExt(depth:24) = %X", nglCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
nglFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, StencilFBOId);
nldebug("3D: glFramebufferRenderbufferExt(stencil:8) = %X", nglCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
}
#else
// generate IDs // generate IDs
nglGenFramebuffersEXT(1, &FBOId); nglGenFramebuffersEXT(1, &FBOId);
if(AttachDepthStencil) if(AttachDepthStencil)
@ -219,15 +154,11 @@ bool CTextureDrvInfosGL3::initFrameBufferObject(ITexture * tex)
GL_RENDERBUFFER_EXT, StencilFBOId); GL_RENDERBUFFER_EXT, StencilFBOId);
nldebug("3D: glFramebufferRenderbufferExt(stencil:8) = %X", nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)); nldebug("3D: glFramebufferRenderbufferExt(stencil:8) = %X", nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT));
} }
#endif
// check status // check status
GLenum status; GLenum status;
#ifdef USE_OPENGLES
status = (GLenum) nglCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
#else
status = (GLenum) nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); status = (GLenum) nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
#endif
switch(status) { switch(status) {
#ifdef GL_FRAMEBUFFER_COMPLETE_EXT #ifdef GL_FRAMEBUFFER_COMPLETE_EXT
case GL_FRAMEBUFFER_COMPLETE_EXT: case GL_FRAMEBUFFER_COMPLETE_EXT:
@ -327,24 +258,14 @@ bool CTextureDrvInfosGL3::initFrameBufferObject(ITexture * tex)
// clean up resources if allocation failed // clean up resources if allocation failed
if (!InitFBO) if (!InitFBO)
{ {
#ifdef USE_OPENGLES
nglDeleteFramebuffersOES(1, &FBOId);
#else
nglDeleteFramebuffersEXT(1, &FBOId); nglDeleteFramebuffersEXT(1, &FBOId);
#endif
if (AttachDepthStencil) if (AttachDepthStencil)
{ {
#ifdef USE_OPENGLES
nglDeleteRenderbuffersOES(1, &DepthFBOId);
#else
nglDeleteRenderbuffersEXT(1, &DepthFBOId); nglDeleteRenderbuffersEXT(1, &DepthFBOId);
#endif
if(!UsePackedDepthStencil) if(!UsePackedDepthStencil)
#ifdef USE_OPENGLES
nglDeleteRenderbuffersOES(1, &StencilFBOId);
#else
nglDeleteRenderbuffersEXT(1, &StencilFBOId); nglDeleteRenderbuffersEXT(1, &StencilFBOId);
#endif
} }
} }
@ -361,22 +282,14 @@ bool CTextureDrvInfosGL3::activeFrameBufferObject(ITexture * tex)
if(initFrameBufferObject(tex)) if(initFrameBufferObject(tex))
{ {
glBindTexture(TextureMode, 0); glBindTexture(TextureMode, 0);
#ifdef USE_OPENGLES
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, FBOId);
#else
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBOId); nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBOId);
#endif
} }
else else
return false; return false;
} }
else else
{ {
#ifdef USE_OPENGLES
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
#else
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
#endif
} }
return true; return true;
@ -449,16 +362,6 @@ GLint CDriverGL3::getGlTextureFormat(ITexture& tex, bool &compressed)
compressed= false; compressed= false;
switch(texfmt) switch(texfmt)
{ {
#ifdef USE_OPENGLES
case ITexture::RGBA8888: return GL_RGBA;
// case ITexture::RGBA4444: return GL_RGBA4_OES;
// case ITexture::RGBA5551: return GL_RGB5_A1_OES;
case ITexture::RGB888: return GL_RGB;
// case ITexture::RGB565: return GL_RGB5_OES;
case ITexture::Luminance: return GL_LUMINANCE;
case ITexture::Alpha: return GL_ALPHA;
case ITexture::AlphaLuminance: return GL_LUMINANCE_ALPHA;
#else
case ITexture::RGBA8888: return GL_RGBA8; case ITexture::RGBA8888: return GL_RGBA8;
case ITexture::RGBA4444: return GL_RGBA4; case ITexture::RGBA4444: return GL_RGBA4;
case ITexture::RGBA5551: return GL_RGB5_A1; case ITexture::RGBA5551: return GL_RGB5_A1;
@ -479,16 +382,11 @@ GLint CDriverGL3::getGlTextureFormat(ITexture& tex, bool &compressed)
return 0; return 0;
} }
break; break;
#endif
default: default:
break; break;
} }
#ifdef USE_OPENGLES
return GL_RGBA;
#else
return GL_RGBA8; return GL_RGBA8;
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -497,11 +395,7 @@ static GLint getGlSrcTextureFormat(ITexture &tex, GLint glfmt)
H_AUTO_OGL(getGlSrcTextureFormat) H_AUTO_OGL(getGlSrcTextureFormat)
// Is destination format is alpha or lumiance ? // Is destination format is alpha or lumiance ?
#ifdef USE_OPENGLES
if ((glfmt==GL_ALPHA)||(glfmt==GL_LUMINANCE_ALPHA)||(glfmt==GL_LUMINANCE))
#else
if ((glfmt==GL_ALPHA8)||(glfmt==GL_LUMINANCE8_ALPHA8)||(glfmt==GL_LUMINANCE8)) if ((glfmt==GL_ALPHA8)||(glfmt==GL_LUMINANCE8_ALPHA8)||(glfmt==GL_LUMINANCE8))
#endif
{ {
switch(tex.getPixelFormat()) switch(tex.getPixelFormat())
{ {
@ -512,7 +406,6 @@ static GLint getGlSrcTextureFormat(ITexture &tex, GLint glfmt)
} }
} }
#ifndef USE_OPENGLES
if (glfmt == GL_DSDT_NV) if (glfmt == GL_DSDT_NV)
{ {
return GL_DSDT_NV; return GL_DSDT_NV;
@ -522,7 +415,6 @@ static GLint getGlSrcTextureFormat(ITexture &tex, GLint glfmt)
{ {
return GL_DUDV_ATI; return GL_DUDV_ATI;
} }
#endif
// Else, not a Src format for upload, or RGBA. // Else, not a Src format for upload, or RGBA.
return GL_RGBA; return GL_RGBA;
@ -533,7 +425,6 @@ static GLenum getGlSrcTextureComponentType(GLint texSrcFormat)
{ {
H_AUTO_OGL(getGlSrcTextureComponentType); H_AUTO_OGL(getGlSrcTextureComponentType);
#ifndef USE_OPENGLES
switch (texSrcFormat) switch (texSrcFormat)
{ {
case GL_DSDT_NV: case GL_DSDT_NV:
@ -543,7 +434,6 @@ static GLenum getGlSrcTextureComponentType(GLint texSrcFormat)
default: default:
break; break;
} }
#endif
return GL_UNSIGNED_BYTE; return GL_UNSIGNED_BYTE;
} }
@ -629,14 +519,10 @@ static inline GLenum translateWrapToGl(ITexture::TWrapMode mode, const CGlExtens
if(mode== ITexture::Repeat) if(mode== ITexture::Repeat)
return GL_REPEAT; return GL_REPEAT;
#ifdef USE_OPENGLES
return GL_CLAMP_TO_EDGE;
#else
if(extensions.Version1_2) if(extensions.Version1_2)
return GL_CLAMP_TO_EDGE; return GL_CLAMP_TO_EDGE;
return GL_CLAMP; return GL_CLAMP;
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -787,10 +673,9 @@ void CDriverGL3::bindTextureWithMode(ITexture &tex)
else else
{ {
CDriverGLStates3::TTextureMode textureMode= CDriverGLStates3::Texture2D; CDriverGLStates3::TTextureMode textureMode= CDriverGLStates3::Texture2D;
#ifndef USE_OPENGLES
if(gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV) if(gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV)
textureMode = CDriverGLStates3::TextureRect; textureMode = CDriverGLStates3::TextureRect;
#endif
_DriverGLStates.setTextureMode(textureMode); _DriverGLStates.setTextureMode(textureMode);
// Bind this texture // Bind this texture
@ -818,9 +703,7 @@ void CDriverGL3::setupTextureBasicParameters(ITexture &tex)
{ {
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_S, translateWrapToGl(ITexture::Clamp, _Extensions)); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_S, translateWrapToGl(ITexture::Clamp, _Extensions));
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_T, translateWrapToGl(ITexture::Clamp, _Extensions)); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_T, translateWrapToGl(ITexture::Clamp, _Extensions));
#ifndef USE_OPENGLES
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_R, translateWrapToGl(ITexture::Clamp, _Extensions)); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_R, translateWrapToGl(ITexture::Clamp, _Extensions));
#endif
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext)); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext));
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext)); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext));
@ -1097,13 +980,8 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
sint size= tex.getPixels(i).size(); sint size= tex.getPixels(i).size();
if (bUpload) if (bUpload)
{ {
#ifdef USE_OPENGLES
glCompressedTexImage2D (GL_TEXTURE_2D, i-decalMipMapResize, glfmt,
tex.getWidth(i),tex.getHeight(i), 0, size, ptr);
#else
nglCompressedTexImage2DARB (GL_TEXTURE_2D, i-decalMipMapResize, glfmt, nglCompressedTexImage2DARB (GL_TEXTURE_2D, i-decalMipMapResize, glfmt,
tex.getWidth(i),tex.getHeight(i), 0, size, ptr); tex.getWidth(i),tex.getHeight(i), 0, size, ptr);
#endif
bAllUploaded = true; bAllUploaded = true;
} }
else else
@ -1237,24 +1115,6 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
clamp(y0, 0, h); clamp(y0, 0, h);
clamp(x1, x0, w); clamp(x1, x0, w);
clamp(y1, y0, h); clamp(y1, y0, h);
#ifdef USE_OPENGLES
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if (!bUpload)
ptr = NULL;
sint pixelSize = 4;
if (glSrcFmt == GL_ALPHA)
pixelSize = 1;
for(sint yy = 0; yy < (y1-y0); yy++)
{
char *row = (char*)ptr + ((yy + y0)*w + x0) * pixelSize;
glTexSubImage2D (GL_TEXTURE_2D, i, x0, y0+yy, x1-x0, 1, glSrcFmt, glSrcType, row );
}
#else
glPixelStorei(GL_UNPACK_ROW_LENGTH, w); glPixelStorei(GL_UNPACK_ROW_LENGTH, w);
glPixelStorei(GL_UNPACK_SKIP_ROWS, y0); glPixelStorei(GL_UNPACK_SKIP_ROWS, y0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, x0); glPixelStorei(GL_UNPACK_SKIP_PIXELS, x0);
@ -1262,7 +1122,7 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
glTexSubImage2D (GL_TEXTURE_2D, i, x0, y0, x1-x0, y1-y0, glSrcFmt,glSrcType, ptr); glTexSubImage2D (GL_TEXTURE_2D, i, x0, y0, x1-x0, y1-y0, glSrcFmt,glSrcType, ptr);
else else
glTexSubImage2D (GL_TEXTURE_2D, i, x0, y0, x1-x0, y1-y0, glSrcFmt,glSrcType, NULL); glTexSubImage2D (GL_TEXTURE_2D, i, x0, y0, x1-x0, y1-y0, glSrcFmt,glSrcType, NULL);
#endif
// Next mipmap!! // Next mipmap!!
// floor . // floor .
@ -1275,13 +1135,9 @@ bool CDriverGL3::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
} }
// Reset the transfer mode... // Reset the transfer mode...
#ifdef USE_OPENGLES
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
#else
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
#endif
} }
} }
@ -1337,10 +1193,8 @@ bool CDriverGL3::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap)
_DriverGLStates.activeTextureARB (0); _DriverGLStates.activeTextureARB (0);
CDriverGLStates3::TTextureMode textureMode= CDriverGLStates3::Texture2D; CDriverGLStates3::TTextureMode textureMode= CDriverGLStates3::Texture2D;
#ifndef USE_OPENGLES
if(gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV) if(gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV)
textureMode = CDriverGLStates3::TextureRect; textureMode = CDriverGLStates3::TextureRect;
#endif
_DriverGLStates.setTextureMode (textureMode); _DriverGLStates.setTextureMode (textureMode);
// Bind this texture, for reload... // Bind this texture, for reload...
@ -1397,11 +1251,7 @@ bool CDriverGL3::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap)
nlassert (((x0&3) == 0) && ((y0&3) == 0)); nlassert (((x0&3) == 0) && ((y0&3) == 0));
if ((w>=4) && (h>=4)) if ((w>=4) && (h>=4))
{ {
#ifdef USE_OPENGLES
glCompressedTexSubImage2D (
#else
nglCompressedTexSubImage2DARB ( nglCompressedTexSubImage2DARB (
#endif
GL_TEXTURE_2D, nNumMipMap-decalMipMapResize, GL_TEXTURE_2D, nNumMipMap-decalMipMapResize,
x0, y0, (x1-x0), (y1-y0), glfmt, imageSize, ptr ); x0, y0, (x1-x0), (y1-y0), glfmt, imageSize, ptr );
} }
@ -1411,11 +1261,7 @@ bool CDriverGL3::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap)
// of the mipmap is less than 4 pixel so we use the other form. (its not really time critical // of the mipmap is less than 4 pixel so we use the other form. (its not really time critical
// to upload 16 bytes so we can do it twice if texture is cut) // to upload 16 bytes so we can do it twice if texture is cut)
imageSize = tex.getPixels(nNumMipMap).size(); imageSize = tex.getPixels(nNumMipMap).size();
#ifdef USE_OPENGLES
glCompressedTexImage2D (
#else
nglCompressedTexImage2DARB ( nglCompressedTexImage2DARB (
#endif
GL_TEXTURE_2D, nNumMipMap-decalMipMapResize, GL_TEXTURE_2D, nNumMipMap-decalMipMapResize,
glfmt, w, h, 0, imageSize, ptr); glfmt, w, h, 0, imageSize, ptr);
} }
@ -1427,21 +1273,6 @@ bool CDriverGL3::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap)
void *ptr= tex.getPixels(nNumMipMap).getPtr(); void *ptr= tex.getPixels(nNumMipMap).getPtr();
#ifdef USE_OPENGLES
sint pixelSize = 4;
if (glSrcFmt == GL_ALPHA)
pixelSize = 1;
for(sint yy = 0; yy < (y1-y0); yy++)
{
char *row = (char*)ptr + ((yy + y0)*w + x0) * pixelSize;
glTexSubImage2D (GL_TEXTURE_2D, nNumMipMap, x0, y0+yy, x1-x0, 1, glSrcFmt, glSrcType, row );
}
// Reset the transfer mode...
// glPixelStorei (GL_UNPACK_ALIGNMENT, 0);
#else
glPixelStorei (GL_UNPACK_ROW_LENGTH, w); glPixelStorei (GL_UNPACK_ROW_LENGTH, w);
glPixelStorei (GL_UNPACK_SKIP_ROWS, y0); glPixelStorei (GL_UNPACK_SKIP_ROWS, y0);
glPixelStorei (GL_UNPACK_SKIP_PIXELS, x0); glPixelStorei (GL_UNPACK_SKIP_PIXELS, x0);
@ -1451,7 +1282,6 @@ bool CDriverGL3::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap)
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei (GL_UNPACK_SKIP_ROWS, 0); glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0); glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
#endif
} }
// Disable texture 0 // Disable texture 0
@ -1533,10 +1363,8 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex)
{ {
// setup texture mode, after activeTextureARB() // setup texture mode, after activeTextureARB()
CDriverGLStates3::TTextureMode textureMode= CDriverGLStates3::Texture2D; CDriverGLStates3::TTextureMode textureMode= CDriverGLStates3::Texture2D;
#ifndef USE_OPENGLES
if(gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV) if(gltext->TextureMode == GL_TEXTURE_RECTANGLE_NV)
textureMode = CDriverGLStates3::TextureRect; textureMode = CDriverGLStates3::TextureRect;
#endif
_DriverGLStates.setTextureMode(/*CDriverGLStates3::Texture2D*/textureMode); _DriverGLStates.setTextureMode(/*CDriverGLStates3::Texture2D*/textureMode);
// Activate texture... // Activate texture...
@ -1584,13 +1412,11 @@ bool CDriverGL3::activateTexture(uint stage, ITexture *tex)
// setup texture mode, after activeTextureARB() // setup texture mode, after activeTextureARB()
_DriverGLStates.setTextureMode(CDriverGLStates3::TextureDisabled); _DriverGLStates.setTextureMode(CDriverGLStates3::TextureDisabled);
#ifndef USE_OPENGLES
if (_Extensions.ATITextureEnvCombine3) if (_Extensions.ATITextureEnvCombine3)
{ {
// very strange bug with ATI cards : when a texture is set to NULL at a stage, the stage is still active sometimes... // very strange bug with ATI cards : when a texture is set to NULL at a stage, the stage is still active sometimes...
activateTexEnvMode(stage, _TexEnvReplace); // set the whole stage to replace fix the problem activateTexEnvMode(stage, _TexEnvReplace); // set the whole stage to replace fix the problem
} }
#endif
} }
this->_CurrentTexture[stage]= tex; this->_CurrentTexture[stage]= tex;
@ -1612,8 +1438,6 @@ static const GLenum OperandLUT[4]= { GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_SR
// This maps the CMaterial::TTexOperator, used for openGL Arg2 setup. // This maps the CMaterial::TTexOperator, used for openGL Arg2 setup.
static const GLenum InterpolateSrcLUT[8]= { GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, GL_PREVIOUS_EXT, GL_PRIMARY_COLOR_EXT, GL_CONSTANT_EXT }; static const GLenum InterpolateSrcLUT[8]= { GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, GL_PREVIOUS_EXT, GL_PRIMARY_COLOR_EXT, GL_CONSTANT_EXT };
#ifndef USE_OPENGLES
// *************************************************************************** // ***************************************************************************
// Set general tex env using ENV_COMBINE4 for the current setupped stage (used by forceActivateTexEnvMode) // Set general tex env using ENV_COMBINE4 for the current setupped stage (used by forceActivateTexEnvMode)
static void forceActivateTexEnvModeEnvCombine4(const CMaterial::CTexEnv &env) static void forceActivateTexEnvModeEnvCombine4(const CMaterial::CTexEnv &env)
@ -1904,8 +1728,6 @@ static void forceActivateTexEnvModeEnvCombine4(const CMaterial::CTexEnv &env)
} }
} }
#endif
// *************************************************************************** // ***************************************************************************
void CDriverGL3::forceActivateTexEnvMode(uint stage, const CMaterial::CTexEnv &env) void CDriverGL3::forceActivateTexEnvMode(uint stage, const CMaterial::CTexEnv &env)
{ {
@ -1919,113 +1741,6 @@ void CDriverGL3::forceActivateTexEnvMode(uint stage, const CMaterial::CTexEnv
// Setup the gl env mode. // Setup the gl env mode.
_DriverGLStates.activeTextureARB(stage); _DriverGLStates.activeTextureARB(stage);
#ifdef USE_OPENGLES
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
// RGB.
//=====
if (env.Env.OpRGB == CMaterial::Mad)
{
//
if (false)
{
// GL_MODULATE_ADD_ATI
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_DOT3_RGB);
// Arg0.
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, SourceLUT[env.Env.SrcArg0RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, OperandLUT[env.Env.OpArg0RGB]);
// Arg1.
glTexEnvi(GL_TEXTURE_ENV, GL_SRC2_RGB, SourceLUT[env.Env.SrcArg1RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, OperandLUT[env.Env.OpArg1RGB]);
// Arg2.
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, SourceLUT[env.Env.SrcArg2RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, OperandLUT[env.Env.OpArg2RGB]);
}
else
{
// fallback to modulate ..
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
//
// Arg0.
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, SourceLUT[env.Env.SrcArg0RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, OperandLUT[env.Env.OpArg0RGB]);
// Arg1.
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, SourceLUT[env.Env.SrcArg1RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, OperandLUT[env.Env.OpArg1RGB]);
}
}
else
{
// Operator.
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, OperatorLUT[env.Env.OpRGB] );
// Arg0.
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, SourceLUT[env.Env.SrcArg0RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, OperandLUT[env.Env.OpArg0RGB]);
// Arg1.
if(env.Env.OpRGB > CMaterial::Replace)
{
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, SourceLUT[env.Env.SrcArg1RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, OperandLUT[env.Env.OpArg1RGB]);
// Arg2.
if(env.Env.OpRGB >= CMaterial::InterpolateTexture )
{
glTexEnvi(GL_TEXTURE_ENV, GL_SRC2_RGB, InterpolateSrcLUT[env.Env.OpRGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
}
}
}
// Alpha.
//=====
if (env.Env.OpAlpha == CMaterial::Mad)
{
if (true)
{
// GL_MODULATE_ADD_ATI
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_DOT3_RGB);
// Arg0.
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, SourceLUT[env.Env.SrcArg0Alpha] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, OperandLUT[env.Env.OpArg0Alpha]);
// Arg1.
glTexEnvi(GL_TEXTURE_ENV, GL_SRC2_ALPHA, SourceLUT[env.Env.SrcArg1Alpha] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, OperandLUT[env.Env.OpArg1Alpha]);
// Arg2.
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_ALPHA, SourceLUT[env.Env.SrcArg2Alpha] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, OperandLUT[env.Env.OpArg2Alpha]);
}
else
{
// fallback to modulate ..
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
//
// Arg0.
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, SourceLUT[env.Env.SrcArg0RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, OperandLUT[env.Env.OpArg0RGB]);
// Arg1.
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_ALPHA, SourceLUT[env.Env.SrcArg1RGB] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, OperandLUT[env.Env.OpArg1RGB]);
}
}
else
{
// Operator.
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, OperatorLUT[env.Env.OpAlpha] );
// Arg0.
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, SourceLUT[env.Env.SrcArg0Alpha] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, OperandLUT[env.Env.OpArg0Alpha]);
// Arg1.
if(env.Env.OpAlpha > CMaterial::Replace)
{
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_ALPHA, SourceLUT[env.Env.SrcArg1Alpha] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, OperandLUT[env.Env.OpArg1Alpha]);
// Arg2.
if(env.Env.OpAlpha >= CMaterial::InterpolateTexture )
{
glTexEnvi(GL_TEXTURE_ENV, GL_SRC2_ALPHA, InterpolateSrcLUT[env.Env.OpAlpha] );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, GL_SRC_ALPHA);
}
}
}
#else
// if the Mad operator is used, then // if the Mad operator is used, then
// "Normal drivers", setup EnvCombine. // "Normal drivers", setup EnvCombine.
if(_Extensions.EXTTextureEnvCombine) if(_Extensions.EXTTextureEnvCombine)
@ -2146,7 +1861,7 @@ void CDriverGL3::forceActivateTexEnvMode(uint stage, const CMaterial::CTexEnv
{ {
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
} }
#endif
} }
// *************************************************************************** // ***************************************************************************

Loading…
Cancel
Save