mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-16 06:18:43 +00:00
Changed: #1275 Create an OpenGL ES driver
This commit is contained in:
parent
37adf50601
commit
7368462f20
4 changed files with 116 additions and 17 deletions
|
@ -2508,8 +2508,13 @@ void CDriverGL::checkTextureOn() const
|
|||
GLboolean flagCM;
|
||||
GLboolean flagTR;
|
||||
glGetBooleanv(GL_TEXTURE_2D, &flag2D);
|
||||
#ifdef USE_OPENGLES
|
||||
glGetBooleanv(GL_TEXTURE_CUBE_MAP_OES, &flagCM);
|
||||
flagTR = true; // always true in OpenGL ES
|
||||
#else
|
||||
glGetBooleanv(GL_TEXTURE_CUBE_MAP_ARB, &flagCM);
|
||||
glGetBooleanv(GL_TEXTURE_RECTANGLE_NV, &flagTR);
|
||||
#endif
|
||||
switch(dgs.getTextureMode())
|
||||
{
|
||||
case CDriverGLStates::TextureDisabled:
|
||||
|
@ -2545,7 +2550,8 @@ bool CDriverGL::supportOcclusionQuery() const
|
|||
// ***************************************************************************
|
||||
bool CDriverGL::supportTextureRectangle() const
|
||||
{
|
||||
H_AUTO_OGL(CDriverGL_supportTextureRectangle)
|
||||
H_AUTO_OGL(CDriverGL_supportTextureRectangle);
|
||||
|
||||
return (_Extensions.NVTextureRectangle || _Extensions.EXTTextureRectangle || _Extensions.ARBTextureRectangle);
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,9 @@ void CDriverGL::setTextureEnvFunction(uint stage, CMaterial& mat)
|
|||
_DriverGLStates.setTexGenMode (stage, GL_OBJECT_LINEAR);
|
||||
}
|
||||
else if(mode==CMaterial::TexCoordGenEyeSpace)
|
||||
{
|
||||
_DriverGLStates.setTexGenMode (stage, GL_EYE_LINEAR);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -918,7 +920,11 @@ void CDriverGL::setupLightMapPass(uint pass)
|
|||
if (mat._LightMapsMulx2)
|
||||
{
|
||||
// Multiply x 2
|
||||
#ifdef USE_OPENGLES
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE, 2);
|
||||
#else
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1027,7 +1033,11 @@ void CDriverGL::endLightMapMultiPass()
|
|||
for (uint32 i = 0; i < (_NLightMapPerPass+1); ++i)
|
||||
{
|
||||
_DriverGLStates.activeTextureARB(i);
|
||||
#ifdef USE_OPENGLES
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE, 1);
|
||||
#else
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1102,13 +1112,16 @@ void CDriverGL::setupSpecularBegin()
|
|||
// todo hulud remove
|
||||
// _DriverGLStates.setTextureMode(CDriverGLStates::TextureCubeMap);
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
_DriverGLStates.setTexGenMode (1, GL_REFLECTION_MAP_OES);
|
||||
#else
|
||||
_DriverGLStates.setTexGenMode (1, GL_REFLECTION_MAP_ARB);
|
||||
#endif
|
||||
|
||||
// setup the good matrix for stage 1.
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadMatrixf( _SpecularTexMtx.get() );
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
@ -1292,7 +1305,8 @@ void CDriverGL::setupSpecularPass(uint pass)
|
|||
_DriverGLStates.setTextureMode(CDriverGLStates::TextureDisabled);
|
||||
}
|
||||
else
|
||||
{ // Multiply texture1 by alpha_texture0 and display with add
|
||||
{
|
||||
// Multiply texture1 by alpha_texture0 and display with add
|
||||
_DriverGLStates.enableBlend(true);
|
||||
_DriverGLStates.blendFunc(GL_ONE, GL_ONE);
|
||||
|
||||
|
|
|
@ -77,7 +77,8 @@ void CDriverGLStates::init(bool supportTextureCubeMap, bool supportTextureRect
|
|||
// ***************************************************************************
|
||||
void CDriverGLStates::forceDefaults(uint nbStages)
|
||||
{
|
||||
H_AUTO_OGL(CDriverGLStates_forceDefaults)
|
||||
H_AUTO_OGL(CDriverGLStates_forceDefaults);
|
||||
|
||||
// Enable / disable.
|
||||
_CurFog= false;
|
||||
_CurBlend= false;
|
||||
|
@ -86,6 +87,7 @@ void CDriverGLStates::forceDefaults(uint nbStages)
|
|||
_CurLighting= false;
|
||||
_CurZWrite= true;
|
||||
_CurStencilTest=false;
|
||||
|
||||
// setup GLStates.
|
||||
glDisable(GL_FOG);
|
||||
glDisable(GL_BLEND);
|
||||
|
@ -642,10 +644,14 @@ void CDriverGLStates::setTexGenMode (uint stage, GLint mode)
|
|||
|
||||
if(mode==0)
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
glDisable(GL_TEXTURE_GEN_STR_OES);
|
||||
#else
|
||||
glDisable( GL_TEXTURE_GEN_S );
|
||||
glDisable( GL_TEXTURE_GEN_T );
|
||||
glDisable( GL_TEXTURE_GEN_R );
|
||||
glDisable( GL_TEXTURE_GEN_Q );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -667,6 +673,7 @@ void CDriverGLStates::setTexGenMode (uint stage, GLint mode)
|
|||
{
|
||||
glDisable( GL_TEXTURE_GEN_Q );
|
||||
}
|
||||
|
||||
// Enable All.
|
||||
#ifdef USE_OPENGLES
|
||||
glEnable(GL_TEXTURE_GEN_STR_OES);
|
||||
|
@ -853,22 +860,25 @@ void CDriverGLStates::enableNormalArray(bool enable)
|
|||
// ***************************************************************************
|
||||
void CDriverGLStates::enableWeightArray(bool enable)
|
||||
{
|
||||
H_AUTO_OGL(CDriverGLStates_enableWeightArray)
|
||||
H_AUTO_OGL(CDriverGLStates_enableWeightArray);
|
||||
|
||||
if(_WeightArrayEnabled != enable)
|
||||
{
|
||||
#ifndef USE_OPENGLES
|
||||
if(enable)
|
||||
glEnableClientState(GL_VERTEX_WEIGHTING_EXT);
|
||||
else
|
||||
glDisableClientState(GL_VERTEX_WEIGHTING_EXT);
|
||||
#endif
|
||||
|
||||
_WeightArrayEnabled= enable;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
// ***************************************************************************
|
||||
void CDriverGLStates::enableColorArray(bool enable)
|
||||
{
|
||||
H_AUTO_OGL(CDriverGLStates_enableColorArray)
|
||||
H_AUTO_OGL(CDriverGLStates_enableColorArray);
|
||||
|
||||
if(_ColorArrayEnabled != enable)
|
||||
{
|
||||
if(enable)
|
||||
|
@ -885,14 +895,16 @@ void CDriverGLStates::enableColorArray(bool enable)
|
|||
// ***************************************************************************
|
||||
void CDriverGLStates::enableSecondaryColorArray(bool enable)
|
||||
{
|
||||
H_AUTO_OGL(CDriverGLStates_enableSecondaryColorArray)
|
||||
H_AUTO_OGL(CDriverGLStates_enableSecondaryColorArray);
|
||||
|
||||
if(_SecondaryColorArrayEnabled != enable)
|
||||
{
|
||||
#ifndef USE_OPENGLES
|
||||
if(enable)
|
||||
glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
|
||||
else
|
||||
glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
|
||||
|
||||
#endif
|
||||
|
||||
_SecondaryColorArrayEnabled= enable;
|
||||
|
||||
|
@ -910,10 +922,15 @@ void CDriverGLStates::enableSecondaryColorArray(bool enable)
|
|||
// ***************************************************************************
|
||||
void CDriverGLStates::clientActiveTextureARB(uint stage)
|
||||
{
|
||||
H_AUTO_OGL(CDriverGLStates_clientActiveTextureARB)
|
||||
H_AUTO_OGL(CDriverGLStates_clientActiveTextureARB);
|
||||
|
||||
if( _CurrentClientActiveTextureARB != stage )
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
glClientActiveTexture(GL_TEXTURE0+stage);
|
||||
#else
|
||||
nglClientActiveTextureARB(GL_TEXTURE0_ARB+stage);
|
||||
#endif
|
||||
_CurrentClientActiveTextureARB= stage;
|
||||
}
|
||||
}
|
||||
|
@ -921,7 +938,8 @@ void CDriverGLStates::clientActiveTextureARB(uint stage)
|
|||
// ***************************************************************************
|
||||
void CDriverGLStates::enableTexCoordArray(bool enable)
|
||||
{
|
||||
H_AUTO_OGL(CDriverGLStates_enableTexCoordArray)
|
||||
H_AUTO_OGL(CDriverGLStates_enableTexCoordArray);
|
||||
|
||||
if(_TexCoordArrayEnabled[_CurrentClientActiveTextureARB] != enable)
|
||||
{
|
||||
if(enable)
|
||||
|
@ -937,14 +955,16 @@ void CDriverGLStates::enableTexCoordArray(bool enable)
|
|||
// ***************************************************************************
|
||||
void CDriverGLStates::enableVertexAttribArray(uint glIndex, bool enable)
|
||||
{
|
||||
H_AUTO_OGL(CDriverGLStates_enableVertexAttribArray)
|
||||
H_AUTO_OGL(CDriverGLStates_enableVertexAttribArray);
|
||||
|
||||
if(_VertexAttribArrayEnabled[glIndex] != enable)
|
||||
{
|
||||
#ifndef USE_OPENGLES
|
||||
if(enable)
|
||||
glEnableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV);
|
||||
else
|
||||
glDisableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV);
|
||||
|
||||
#endif
|
||||
|
||||
_VertexAttribArrayEnabled[glIndex]= enable;
|
||||
}
|
||||
|
@ -953,15 +973,18 @@ void CDriverGLStates::enableVertexAttribArray(uint glIndex, bool enable)
|
|||
// ***************************************************************************
|
||||
void CDriverGLStates::enableVertexAttribArrayARB(uint glIndex,bool enable)
|
||||
{
|
||||
H_AUTO_OGL(CDriverGLStates_enableVertexAttribArrayARB)
|
||||
H_AUTO_OGL(CDriverGLStates_enableVertexAttribArrayARB);
|
||||
|
||||
#ifndef NL3D_GLSTATE_DISABLE_CACHE
|
||||
if(_VertexAttribArrayEnabled[glIndex] != enable)
|
||||
#endif
|
||||
{
|
||||
#ifndef USE_OPENGLES
|
||||
if(enable)
|
||||
nglEnableVertexAttribArrayARB(glIndex);
|
||||
else
|
||||
nglDisableVertexAttribArrayARB(glIndex);
|
||||
#endif
|
||||
|
||||
_VertexAttribArrayEnabled[glIndex]= enable;
|
||||
}
|
||||
|
|
|
@ -1210,19 +1210,37 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
|
|||
// create a ARB VBHard
|
||||
GLuint vertexBufferID;
|
||||
glGetError();
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
glGenBuffers(1, &vertexBufferID);
|
||||
#else
|
||||
nglGenBuffersARB(1, &vertexBufferID);
|
||||
#endif
|
||||
|
||||
if (glGetError() != GL_NO_ERROR) return false;
|
||||
_Driver->_DriverGLStates.forceBindARBVertexBuffer(vertexBufferID);
|
||||
switch(_VBType)
|
||||
{
|
||||
case CVertexBuffer::AGPPreferred:
|
||||
#ifdef USE_OPENGLES
|
||||
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
|
||||
#else
|
||||
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
|
||||
#endif
|
||||
break;
|
||||
case CVertexBuffer::StaticPreferred:
|
||||
if (_Driver->getStaticMemoryToVRAM())
|
||||
#ifdef USE_OPENGLES
|
||||
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STATIC_DRAW);
|
||||
#else
|
||||
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB);
|
||||
#endif
|
||||
else
|
||||
#ifdef USE_OPENGLES
|
||||
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
|
||||
#else
|
||||
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
nlassert(0);
|
||||
|
@ -1230,7 +1248,12 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
|
|||
}
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
glDeleteBuffers(1, &vertexBufferID);
|
||||
#else
|
||||
nglDeleteBuffersARB(1, &vertexBufferID);
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
CVertexBufferHardARB *newVbHard= new CVertexBufferHardARB(_Driver, vb);
|
||||
|
@ -1272,8 +1295,13 @@ void CVertexArrayRangeARB::updateLostBuffers()
|
|||
{
|
||||
nlassert((*it)->_VertexObjectId);
|
||||
GLuint id = (GLuint) (*it)->_VertexObjectId;
|
||||
#ifdef USE_OPENGLES
|
||||
nlassert(glIsBuffer(id));
|
||||
glDeleteBuffers(1, &id);
|
||||
#else
|
||||
nlassert(nglIsBufferARB(id));
|
||||
nglDeleteBuffersARB(1, &id);
|
||||
#endif
|
||||
(*it)->_VertexObjectId = 0;
|
||||
(*it)->VB->setLocation(CVertexBuffer::NotResident);
|
||||
}
|
||||
|
@ -1316,8 +1344,13 @@ CVertexBufferHardARB::~CVertexBufferHardARB()
|
|||
if (_VertexObjectId)
|
||||
{
|
||||
GLuint id = (GLuint) _VertexObjectId;
|
||||
#ifdef USE_OPENGLES
|
||||
nlassert(glIsBuffer(id));
|
||||
glDeleteBuffers(1, &id);
|
||||
#else
|
||||
nlassert(nglIsBufferARB(id));
|
||||
nglDeleteBuffersARB(1, &id);
|
||||
#endif
|
||||
}
|
||||
if (_VertexArrayRange)
|
||||
{
|
||||
|
@ -1341,7 +1374,8 @@ CVertexBufferHardARB::~CVertexBufferHardARB()
|
|||
// ***************************************************************************
|
||||
void *CVertexBufferHardARB::lock()
|
||||
{
|
||||
H_AUTO_OGL(CVertexBufferHardARB_lock)
|
||||
H_AUTO_OGL(CVertexBufferHardARB_lock);
|
||||
|
||||
if (_VertexPtr) return _VertexPtr; // already locked
|
||||
if (_Invalid)
|
||||
{
|
||||
|
@ -1352,7 +1386,13 @@ void *CVertexBufferHardARB::lock()
|
|||
}
|
||||
// recreate a vb
|
||||
GLuint vertexBufferID;
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
glGenBuffers(1, &vertexBufferID);
|
||||
#else
|
||||
nglGenBuffersARB(1, &vertexBufferID);
|
||||
#endif
|
||||
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
_Driver->incrementResetCounter();
|
||||
|
@ -1363,13 +1403,25 @@ void *CVertexBufferHardARB::lock()
|
|||
switch(_MemType)
|
||||
{
|
||||
case CVertexBuffer::AGPPreferred:
|
||||
#ifdef USE_OPENGLES
|
||||
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
|
||||
#else
|
||||
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
|
||||
#endif
|
||||
break;
|
||||
case CVertexBuffer::StaticPreferred:
|
||||
if (_Driver->getStaticMemoryToVRAM())
|
||||
#ifdef USE_OPENGLES
|
||||
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STATIC_DRAW);
|
||||
#else
|
||||
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB);
|
||||
#endif
|
||||
else
|
||||
#ifdef USE_OPENGLES
|
||||
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
|
||||
#else
|
||||
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
nlassert(0);
|
||||
|
@ -1378,7 +1430,11 @@ void *CVertexBufferHardARB::lock()
|
|||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
_Driver->incrementResetCounter();
|
||||
#ifdef USE_OPENGLES
|
||||
glDeleteBuffers(1, &vertexBufferID);
|
||||
#else
|
||||
nglDeleteBuffersARB(1, &vertexBufferID);
|
||||
#endif
|
||||
return &_DummyVB[0];;
|
||||
}
|
||||
_VertexObjectId = vertexBufferID;
|
||||
|
|
Loading…
Reference in a new issue