mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-17 04:51:48 +00:00
Changed: More aliases for OpenGL ES functions and defines to simplify code
This commit is contained in:
parent
751d6de2eb
commit
2a6478b505
6 changed files with 54 additions and 139 deletions
|
@ -435,11 +435,7 @@ bool CDriverGL::setupDisplay()
|
|||
glViewport(0,0,_CurrentMode.Width,_CurrentMode.Height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
#ifdef USE_OPENGLES
|
||||
glOrthof(0.f,_CurrentMode.Width,_CurrentMode.Height,0.f,-1.0f,1.0f);
|
||||
#else
|
||||
glOrtho(0,_CurrentMode.Width,_CurrentMode.Height,0,-1.0f,1.0f);
|
||||
#endif
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
#ifndef USE_OPENGLES
|
||||
|
@ -725,11 +721,7 @@ bool CDriverGL::activeFrameBufferObject(ITexture * tex)
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
|
||||
#else
|
||||
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,24 @@ extern "C" {
|
|||
#define GL_ADD_SIGNED_EXT GL_ADD_SIGNED
|
||||
#define GL_INTERPOLATE_EXT GL_INTERPOLATE
|
||||
#define GL_BUMP_ENVMAP_ATI GL_INTERPOLATE
|
||||
#define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER_OES
|
||||
#define GL_RENDERBUFFER_EXT GL_RENDERBUFFER_OES
|
||||
#define GL_DEPTH24_STENCIL8_EXT GL_DEPTH24_STENCIL8_OES
|
||||
#define GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT24_OES
|
||||
#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0_OES
|
||||
#define GL_DEPTH_ATTACHMENT_EXT GL_DEPTH_ATTACHMENT_OES
|
||||
#define GL_STENCIL_ATTACHMENT_EXT GL_STENCIL_ATTACHMENT_OES
|
||||
#define GL_ARRAY_BUFFER_ARB GL_ARRAY_BUFFER
|
||||
#define GL_TEXTURE0_ARB GL_TEXTURE0
|
||||
|
||||
#define GL_ALPHA8 GL_ALPHA
|
||||
#define GL_LUMINANCE8_ALPHA8 GL_LUMINANCE_ALPHA
|
||||
#define GL_LUMINANCE8 GL_LUMINANCE
|
||||
#define GL_RGBA8 GL_RGBA
|
||||
#define GL_RGB8 GL_RGB
|
||||
|
||||
#define GL_STATIC_DRAW_ARB GL_STATIC_DRAW
|
||||
#define GL_DYNAMIC_DRAW_ARB GL_DYNAMIC_DRAW
|
||||
|
||||
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES
|
||||
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES
|
||||
|
@ -48,6 +66,31 @@ extern "C" {
|
|||
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES
|
||||
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES
|
||||
|
||||
#define nglGenRenderbuffersEXT nglGenRenderbuffersOES
|
||||
#define nglBindRenderbufferEXT nglBindRenderbufferOES
|
||||
#define nglDeleteRenderbuffersEXT nglDeleteRenderbuffersOES
|
||||
#define nglRenderbufferStorageEXT nglRenderbufferStorageOES
|
||||
#define nglGenFramebuffersEXT nglGenFramebuffersOES
|
||||
#define nglBindFramebufferEXT nglBindFramebufferOES
|
||||
#define nglFramebufferTexture2DEXT nglFramebufferTexture2DOES
|
||||
#define nglFramebufferRenderbufferEXT nglFramebufferRenderbufferOES
|
||||
#define nglCheckFramebufferStatusEXT nglCheckFramebufferStatusOES
|
||||
#define nglDeleteBuffersARB glDeleteBuffers
|
||||
#define nglIsBufferARB glIsBuffer
|
||||
#define nglDeleteRenderbuffersEXT nglDeleteRenderbuffersOES
|
||||
#define nglBindFramebufferEXT nglBindFramebufferOES
|
||||
#define nglDeleteFramebuffersEXT nglDeleteFramebuffersOES
|
||||
#define nglUnmapBufferARB nglUnmapBufferOES
|
||||
#define nglActiveTextureARB glActiveTexture
|
||||
#define nglClientActiveTextureARB glClientActiveTexture
|
||||
#define nglBindBufferARB glBindBuffer
|
||||
#define nglGenBuffersARB glGenBuffers
|
||||
#define nglBufferDataARB glBufferData
|
||||
|
||||
#define glFrustum glFrustumf
|
||||
#define glOrtho glOrthof
|
||||
#define glDepthRange glDepthRangef
|
||||
|
||||
#else
|
||||
|
||||
#if defined(NL_OS_MAC)
|
||||
|
|
|
@ -37,19 +37,11 @@ void CDriverGL::setFrustum(float left, float right, float bottom, float top, flo
|
|||
|
||||
if (perspective)
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
glFrustumf(left,right,bottom,top,znear,zfar);
|
||||
#else
|
||||
glFrustum(left,right,bottom,top,znear,zfar);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
glOrthof(left,right,bottom,top,znear,zfar);
|
||||
#else
|
||||
glOrtho(left,right,bottom,top,znear,zfar);
|
||||
#endif
|
||||
}
|
||||
|
||||
_ProjMatDirty = true;
|
||||
|
|
|
@ -155,11 +155,7 @@ void CDriverGLStates::forceDefaults(uint nbStages)
|
|||
for(stage=0;stage<nbStages; stage++)
|
||||
{
|
||||
// disable texturing.
|
||||
#ifdef USE_OPENGLES
|
||||
glActiveTexture(GL_TEXTURE0+stage);
|
||||
#else
|
||||
nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
|
||||
#endif
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
|
@ -188,13 +184,8 @@ void CDriverGLStates::forceDefaults(uint nbStages)
|
|||
}
|
||||
|
||||
// ActiveTexture current texture to 0.
|
||||
#ifdef USE_OPENGLES
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
#else
|
||||
nglActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
nglClientActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
#endif
|
||||
|
||||
_CurrentActiveTextureARB= 0;
|
||||
_CurrentClientActiveTextureARB= 0;
|
||||
|
@ -622,11 +613,7 @@ void CDriverGLStates::updateDepthRange()
|
|||
|
||||
float delta = _ZBias * (_DepthRangeFar - _DepthRangeNear);
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
glDepthRangef(delta + _DepthRangeNear, delta + _DepthRangeFar);
|
||||
#else
|
||||
glDepthRange(delta + _DepthRangeNear, delta + _DepthRangeFar);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
@ -835,11 +822,7 @@ void CDriverGLStates::activeTextureARB(uint stage)
|
|||
|
||||
if( _CurrentActiveTextureARB != stage )
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
glActiveTexture(GL_TEXTURE0+stage);
|
||||
#else
|
||||
nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
|
||||
#endif
|
||||
|
||||
_CurrentActiveTextureARB= stage;
|
||||
}
|
||||
|
@ -850,11 +833,7 @@ void CDriverGLStates::forceActiveTextureARB(uint stage)
|
|||
{
|
||||
H_AUTO_OGL(CDriverGLStates_forceActiveTextureARB);
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
glActiveTexture(GL_TEXTURE0+stage);
|
||||
#else
|
||||
nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
|
||||
#endif
|
||||
|
||||
_CurrentActiveTextureARB= stage;
|
||||
}
|
||||
|
@ -958,11 +937,7 @@ void CDriverGLStates::clientActiveTextureARB(uint stage)
|
|||
|
||||
if( _CurrentClientActiveTextureARB != stage )
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
glClientActiveTexture(GL_TEXTURE0+stage);
|
||||
#else
|
||||
nglClientActiveTextureARB(GL_TEXTURE0_ARB+stage);
|
||||
#endif
|
||||
_CurrentClientActiveTextureARB= stage;
|
||||
}
|
||||
}
|
||||
|
@ -1121,11 +1096,7 @@ void CDriverGLStates::forceBindARBVertexBuffer(uint objectID)
|
|||
{
|
||||
H_AUTO_OGL(CDriverGLStates_forceBindARBVertexBuffer)
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
glBindBuffer(GL_ARRAY_BUFFER, objectID);
|
||||
#else
|
||||
nglBindBufferARB(GL_ARRAY_BUFFER_ARB, objectID);
|
||||
#endif
|
||||
|
||||
_CurrARBVertexBuffer = objectID;
|
||||
}
|
||||
|
|
|
@ -256,12 +256,8 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex)
|
|||
#endif
|
||||
|
||||
// check status
|
||||
GLenum status;
|
||||
#ifdef USE_OPENGLES
|
||||
status = (GLenum) nglCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
|
||||
#else
|
||||
status = (GLenum) nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
#endif
|
||||
GLenum status = (GLenum) nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
|
||||
switch(status) {
|
||||
#ifdef GL_FRAMEBUFFER_COMPLETE_EXT
|
||||
case GL_FRAMEBUFFER_COMPLETE_EXT:
|
||||
|
@ -361,11 +357,8 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex)
|
|||
// clean up resources if allocation failed
|
||||
if (!InitFBO)
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
nglDeleteFramebuffersOES(1, &FBOId);
|
||||
#else
|
||||
nglDeleteFramebuffersEXT(1, &FBOId);
|
||||
#endif
|
||||
|
||||
if (AttachDepthStencil)
|
||||
{
|
||||
DepthStencilFBO = NULL;
|
||||
|
@ -385,22 +378,14 @@ bool CTextureDrvInfosGL::activeFrameBufferObject(ITexture * tex)
|
|||
if(initFrameBufferObject(tex))
|
||||
{
|
||||
glBindTexture(TextureMode, 0);
|
||||
#ifdef USE_OPENGLES
|
||||
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, FBOId);
|
||||
#else
|
||||
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBOId);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
|
||||
#else
|
||||
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -508,11 +493,7 @@ GLint CDriverGL::getGlTextureFormat(ITexture& tex, bool &compressed)
|
|||
break;
|
||||
}
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
return GL_RGBA;
|
||||
#else
|
||||
return GL_RGBA8;
|
||||
#endif
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
@ -521,11 +502,7 @@ static GLint getGlSrcTextureFormat(ITexture &tex, GLint glfmt)
|
|||
H_AUTO_OGL(getGlSrcTextureFormat)
|
||||
|
||||
// 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))
|
||||
#endif
|
||||
{
|
||||
switch(tex.getPixelFormat())
|
||||
{
|
||||
|
@ -578,19 +555,9 @@ uint CDriverGL::computeMipMapMemoryUsage(uint w, uint h, GLint glfmt) const
|
|||
H_AUTO_OGL(CDriverGL_computeMipMapMemoryUsage)
|
||||
switch(glfmt)
|
||||
{
|
||||
#ifdef GL_RGBA8
|
||||
case GL_RGBA8: return w*h* 4;
|
||||
#endif
|
||||
#ifdef GL_RGBA
|
||||
case GL_RGBA: return w*h* 4;
|
||||
#endif
|
||||
// Well this is ugly, but simple :). GeForce 888 is stored as 32 bits.
|
||||
#ifdef GL_RGB8
|
||||
case GL_RGB8: return w*h* 4;
|
||||
#endif
|
||||
#ifdef GL_RGB
|
||||
case GL_RGB: return w*h* 4;
|
||||
#endif
|
||||
#ifdef GL_RGBA4
|
||||
case GL_RGBA4: return w*h* 2;
|
||||
#endif
|
||||
|
@ -600,24 +567,9 @@ uint CDriverGL::computeMipMapMemoryUsage(uint w, uint h, GLint glfmt) const
|
|||
#ifdef GL_RGB5
|
||||
case GL_RGB5: return w*h* 2;
|
||||
#endif
|
||||
#ifdef GL_LUMINANCE8
|
||||
case GL_LUMINANCE8: return w*h* 1;
|
||||
#endif
|
||||
#ifdef GL_LUMINANCE
|
||||
case GL_LUMINANCE: return w*h* 1;
|
||||
#endif
|
||||
#ifdef GL_ALPHA8
|
||||
case GL_ALPHA8: return w*h* 1;
|
||||
#endif
|
||||
#ifdef GL_ALPHA
|
||||
case GL_ALPHA: return w*h* 1;
|
||||
#endif
|
||||
#ifdef GL_LUMINANCE8_ALPHA8
|
||||
case GL_LUMINANCE8_ALPHA8: return w*h* 2;
|
||||
#endif
|
||||
#ifdef GL_LUMINANCE_ALPHA
|
||||
case GL_LUMINANCE_ALPHA: return w*h* 2;
|
||||
#endif
|
||||
#ifdef GL_COMPRESSED_RGB_S3TC_DXT1_EXT
|
||||
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: return w*h /2;
|
||||
#endif
|
||||
|
|
|
@ -1216,11 +1216,7 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
|
|||
GLuint vertexBufferID;
|
||||
glGetError();
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
glGenBuffers(1, &vertexBufferID);
|
||||
#else
|
||||
nglGenBuffersARB(1, &vertexBufferID);
|
||||
#endif
|
||||
|
||||
if (glGetError() != GL_NO_ERROR) return NULL;
|
||||
_Driver->_DriverGLStates.forceBindARBVertexBuffer(vertexBufferID);
|
||||
|
@ -1259,11 +1255,7 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
|
|||
}
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
glDeleteBuffers(1, &vertexBufferID);
|
||||
#else
|
||||
nglDeleteBuffersARB(1, &vertexBufferID);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1306,13 +1298,10 @@ 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);
|
||||
}
|
||||
|
@ -1361,13 +1350,8 @@ 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)
|
||||
{
|
||||
|
@ -1412,12 +1396,7 @@ void *CVertexBufferHardARB::lock()
|
|||
}
|
||||
// recreate a vb
|
||||
GLuint vertexBufferID;
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
glGenBuffers(1, &vertexBufferID);
|
||||
#else
|
||||
nglGenBuffersARB(1, &vertexBufferID);
|
||||
#endif
|
||||
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
|
@ -1436,35 +1415,23 @@ void *CVertexBufferHardARB::lock()
|
|||
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;
|
||||
// case CVertexBuffer::AGPPreferred:
|
||||
default:
|
||||
#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;
|
||||
}
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
_Driver->incrementResetCounter();
|
||||
#ifdef USE_OPENGLES
|
||||
glDeleteBuffers(1, &vertexBufferID);
|
||||
#else
|
||||
|
||||
nglDeleteBuffersARB(1, &vertexBufferID);
|
||||
#endif
|
||||
|
||||
return &_DummyVB[0];;
|
||||
}
|
||||
_VertexObjectId = vertexBufferID;
|
||||
|
@ -1567,12 +1534,10 @@ void CVertexBufferHardARB::unlock()
|
|||
|
||||
#ifdef USE_OPENGLES
|
||||
if (_Driver->_Extensions.OESMapBuffer)
|
||||
{
|
||||
unmapOk = nglUnmapBufferOES(GL_ARRAY_BUFFER);
|
||||
}
|
||||
#else
|
||||
unmapOk = nglUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
|
||||
#endif
|
||||
{
|
||||
unmapOk = nglUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
|
||||
}
|
||||
|
||||
#ifdef NL_DEBUG
|
||||
_Unmapping = false;
|
||||
|
|
Loading…
Reference in a new issue