mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-27 09:36:15 +00:00
Changed: #1275 Create an OpenGL ES driver
This commit is contained in:
parent
ea39e6ac7a
commit
ae9de611f6
5 changed files with 169 additions and 16 deletions
|
@ -139,8 +139,13 @@ void CDriverGL::setLightInternal(uint8 num, const CLight& light)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Deactivate spot properties
|
// Deactivate spot properties
|
||||||
|
#ifdef USE_OPENGLES
|
||||||
|
glLightf (lightNum, GL_SPOT_CUTOFF, 180.f);
|
||||||
|
glLightf (lightNum, GL_SPOT_EXPONENT, 0.f);
|
||||||
|
#else
|
||||||
glLighti (lightNum, GL_SPOT_CUTOFF, 180);
|
glLighti (lightNum, GL_SPOT_CUTOFF, 180);
|
||||||
glLighti (lightNum, GL_SPOT_EXPONENT, 0);
|
glLighti (lightNum, GL_SPOT_EXPONENT, 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flag this light as dirt.
|
// Flag this light as dirt.
|
||||||
|
|
|
@ -15,24 +15,35 @@
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "stdopengl.h"
|
#include "stdopengl.h"
|
||||||
|
|
||||||
#include "driver_opengl.h"
|
#include "driver_opengl.h"
|
||||||
|
|
||||||
namespace NL3D {
|
namespace NL3D {
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CDriverGL::setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective)
|
void CDriverGL::setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective)
|
||||||
{
|
{
|
||||||
H_AUTO_OGL(CDriverGL_setFrustum)
|
H_AUTO_OGL(CDriverGL_setFrustum);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
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;
|
||||||
|
|
||||||
// Backup znear and zfar for zbias setup
|
// Backup znear and zfar for zbias setup
|
||||||
|
|
|
@ -144,33 +144,62 @@ void CDriverGLStates::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)
|
||||||
|
{
|
||||||
|
#ifdef USE_OPENGLES
|
||||||
|
glDisable(GL_TEXTURE_CUBE_MAP_OES);
|
||||||
|
glDisable(GL_TEXTURE_GEN_STR_OES);
|
||||||
|
#else
|
||||||
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
|
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
|
||||||
if(_TextureRectangleSupported)
|
#endif
|
||||||
glDisable(GL_TEXTURE_RECTANGLE_NV);
|
}
|
||||||
|
|
||||||
_TextureMode[stage]= TextureDisabled;
|
_TextureMode[stage]= TextureDisabled;
|
||||||
|
|
||||||
// Tex gen init
|
// Tex gen init
|
||||||
_TexGenMode[stage] = 0;
|
_TexGenMode[stage] = 0;
|
||||||
glDisable( GL_TEXTURE_GEN_S );
|
|
||||||
glDisable( GL_TEXTURE_GEN_T );
|
#ifndef USE_OPENGLES
|
||||||
glDisable( GL_TEXTURE_GEN_R );
|
if(_TextureRectangleSupported)
|
||||||
glDisable( GL_TEXTURE_GEN_Q );
|
glDisable(GL_TEXTURE_RECTANGLE_NV);
|
||||||
|
|
||||||
|
glDisable(GL_TEXTURE_GEN_S);
|
||||||
|
glDisable(GL_TEXTURE_GEN_T);
|
||||||
|
glDisable(GL_TEXTURE_GEN_R);
|
||||||
|
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);
|
||||||
_CurrentActiveTextureARB= 0;
|
|
||||||
nglClientActiveTextureARB(GL_TEXTURE0_ARB);
|
nglClientActiveTextureARB(GL_TEXTURE0_ARB);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_CurrentActiveTextureARB= 0;
|
||||||
_CurrentClientActiveTextureARB= 0;
|
_CurrentClientActiveTextureARB= 0;
|
||||||
|
|
||||||
// Depth range
|
// Depth range
|
||||||
_DepthRangeNear = 0.f;
|
_DepthRangeNear = 0.f;
|
||||||
_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;
|
||||||
|
@ -536,7 +565,9 @@ void CDriverGLStates::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
|
||||||
{
|
{
|
||||||
|
@ -558,9 +589,15 @@ void CDriverGLStates::setVertexColorLighted(bool enable)
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CDriverGLStates::updateDepthRange()
|
void CDriverGLStates::updateDepthRange()
|
||||||
{
|
{
|
||||||
H_AUTO_OGL(CDriverGLStates_updateDepthRange)
|
H_AUTO_OGL(CDriverGLStates_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
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
@ -631,9 +668,13 @@ void CDriverGLStates::setTexGenMode (uint stage, GLint mode)
|
||||||
glDisable( GL_TEXTURE_GEN_Q );
|
glDisable( GL_TEXTURE_GEN_Q );
|
||||||
}
|
}
|
||||||
// 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -649,12 +690,19 @@ void CDriverGLStates::resetTextureMode()
|
||||||
|
|
||||||
if (_TextureCubeMapSupported)
|
if (_TextureCubeMapSupported)
|
||||||
{
|
{
|
||||||
|
#ifdef USE_OPENGLES
|
||||||
|
glDisable(GL_TEXTURE_CUBE_MAP_OES);
|
||||||
|
#else
|
||||||
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
|
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef USE_OPENGLES
|
||||||
if (_TextureRectangleSupported)
|
if (_TextureRectangleSupported)
|
||||||
{
|
{
|
||||||
glDisable(GL_TEXTURE_RECTANGLE_NV);
|
glDisable(GL_TEXTURE_RECTANGLE_NV);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
_TextureMode[_CurrentActiveTextureARB]= TextureDisabled;
|
_TextureMode[_CurrentActiveTextureARB]= TextureDisabled;
|
||||||
}
|
}
|
||||||
|
@ -674,11 +722,13 @@ void CDriverGLStates::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);
|
||||||
}
|
}
|
||||||
|
@ -687,7 +737,11 @@ void CDriverGLStates::setTextureMode(TTextureMode texMode)
|
||||||
{
|
{
|
||||||
if(_TextureCubeMapSupported)
|
if(_TextureCubeMapSupported)
|
||||||
{
|
{
|
||||||
|
#ifdef USE_OPENGLES
|
||||||
|
glDisable(GL_TEXTURE_CUBE_MAP_OES);
|
||||||
|
#else
|
||||||
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
|
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -702,24 +756,30 @@ void CDriverGLStates::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
|
||||||
{
|
{
|
||||||
glDisable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(texMode == TextureCubeMap)
|
else if(texMode == TextureCubeMap)
|
||||||
{
|
{
|
||||||
if(_TextureCubeMapSupported)
|
if(_TextureCubeMapSupported)
|
||||||
{
|
{
|
||||||
|
#ifdef USE_OPENGLES
|
||||||
|
glEnable(GL_TEXTURE_CUBE_MAP_OES);
|
||||||
|
#else
|
||||||
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
|
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glDisable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -736,8 +796,11 @@ void CDriverGLStates::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;
|
||||||
}
|
}
|
||||||
|
@ -748,7 +811,11 @@ void CDriverGLStates::forceActiveTextureARB(uint stage)
|
||||||
{
|
{
|
||||||
H_AUTO_OGL(CDriverGLStates_forceActiveTextureARB);
|
H_AUTO_OGL(CDriverGLStates_forceActiveTextureARB);
|
||||||
|
|
||||||
|
#ifdef USE_OPENGLES
|
||||||
|
glActiveTexture(GL_TEXTURE0+stage);
|
||||||
|
#else
|
||||||
nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
|
nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
|
||||||
|
#endif
|
||||||
|
|
||||||
_CurrentActiveTextureARB= stage;
|
_CurrentActiveTextureARB= stage;
|
||||||
}
|
}
|
||||||
|
@ -828,12 +895,15 @@ void CDriverGLStates::enableSecondaryColorArray(bool enable)
|
||||||
|
|
||||||
|
|
||||||
_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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -988,7 +1058,13 @@ void CDriverGLStates::enableFog(uint enable)
|
||||||
void CDriverGLStates::forceBindARBVertexBuffer(uint objectID)
|
void CDriverGLStates::forceBindARBVertexBuffer(uint objectID)
|
||||||
{
|
{
|
||||||
H_AUTO_OGL(CDriverGLStates_forceBindARBVertexBuffer)
|
H_AUTO_OGL(CDriverGLStates_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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,8 +280,12 @@ bool CDriverGL::renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef USE_OPENGLES
|
||||||
|
nlerror("not available in OpenGL ES 1.0, only use 16 bits indices");
|
||||||
|
#else
|
||||||
nlassert(_LastIB._Format == CIndexBuffer::Indices32);
|
nlassert(_LastIB._Format == CIndexBuffer::Indices32);
|
||||||
glDrawElements(GL_LINES,2*nlines,GL_UNSIGNED_INT,((uint32 *) _LastIB._Values)+firstIndex);
|
glDrawElements(GL_LINES,2*nlines,GL_UNSIGNED_INT,((uint32 *) _LastIB._Values)+firstIndex);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,8 +340,12 @@ bool CDriverGL::renderTriangles(CMaterial& mat, uint32 firstIndex, uint32 ntris)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef USE_OPENGLES
|
||||||
|
nlerror("not available in OpenGL ES 1.0, only use 16 bits indices");
|
||||||
|
#else
|
||||||
nlassert(_LastIB._Format == CIndexBuffer::Indices32);
|
nlassert(_LastIB._Format == CIndexBuffer::Indices32);
|
||||||
glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstIndex);
|
glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstIndex);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -380,8 +388,12 @@ bool CDriverGL::renderSimpleTriangles(uint32 firstTri, uint32 ntris)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef USE_OPENGLES
|
||||||
|
nlerror("not available in OpenGL ES 1.0, only use 16 bits indices");
|
||||||
|
#else
|
||||||
nlassert(_LastIB._Format == CIndexBuffer::Indices32);
|
nlassert(_LastIB._Format == CIndexBuffer::Indices32);
|
||||||
glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstTri);
|
glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstTri);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Profiling.
|
// Profiling.
|
||||||
|
@ -608,6 +620,9 @@ bool CDriverGL::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQuad
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef USE_OPENGLES
|
||||||
|
nlerror("not available in OpenGL ES 1.0, only use 16 bits indices");
|
||||||
|
#else
|
||||||
// indices fits on 32 bits
|
// indices fits on 32 bits
|
||||||
GLint indices[QUAD_BATCH_SIZE];
|
GLint indices[QUAD_BATCH_SIZE];
|
||||||
GLint *curr = indices;
|
GLint *curr = indices;
|
||||||
|
@ -625,6 +640,7 @@ bool CDriverGL::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQuad
|
||||||
}
|
}
|
||||||
while(curr != end);
|
while(curr != end);
|
||||||
glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_INT, indices);
|
glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_INT, indices);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
numLeftQuads -= numQuadsToDraw;
|
numLeftQuads -= numQuadsToDraw;
|
||||||
currIndex += 4 * numQuadsToDraw;
|
currIndex += 4 * numQuadsToDraw;
|
||||||
|
@ -665,10 +681,12 @@ void CDriverGL::setupUVPtr(uint stage, CVertexBufferInfo &VB, uint uvId)
|
||||||
// Setup ATI VBHard or std ptr.
|
// Setup ATI VBHard or std ptr.
|
||||||
switch(VB.VBMode)
|
switch(VB.VBMode)
|
||||||
{
|
{
|
||||||
|
#ifndef USE_OPENGLES
|
||||||
case CVertexBufferInfo::HwATI:
|
case CVertexBufferInfo::HwATI:
|
||||||
nglArrayObjectATI(GL_TEXTURE_COORD_ARRAY, numTexCoord, GL_FLOAT, VB.VertexSize, VB.VertexObjectId,
|
nglArrayObjectATI(GL_TEXTURE_COORD_ARRAY, numTexCoord, GL_FLOAT, VB.VertexSize, VB.VertexObjectId,
|
||||||
(ptrdiff_t) VB.ValuePtr[CVertexBuffer::TexCoord0+uvId]);
|
(ptrdiff_t) VB.ValuePtr[CVertexBuffer::TexCoord0+uvId]);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case CVertexBufferInfo::HwARB:
|
case CVertexBufferInfo::HwARB:
|
||||||
_DriverGLStates.bindARBVertexBuffer(VB.VertexObjectId);
|
_DriverGLStates.bindARBVertexBuffer(VB.VertexObjectId);
|
||||||
// with arb buffers, position is relative to the start of the stream
|
// with arb buffers, position is relative to the start of the stream
|
||||||
|
@ -811,6 +829,21 @@ const uint CDriverGL::NumCoordinatesType[CVertexBuffer::NumType]=
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
const uint CDriverGL::GLType[CVertexBuffer::NumType]=
|
const uint CDriverGL::GLType[CVertexBuffer::NumType]=
|
||||||
{
|
{
|
||||||
|
#ifdef USE_OPENGLES
|
||||||
|
GL_FLOAT, // Double1
|
||||||
|
GL_FLOAT, // Float1
|
||||||
|
GL_SHORT, // Short1
|
||||||
|
GL_FLOAT, // Double2
|
||||||
|
GL_FLOAT, // Float2
|
||||||
|
GL_SHORT, // Short2
|
||||||
|
GL_FLOAT, // Double3
|
||||||
|
GL_FLOAT, // Float3
|
||||||
|
GL_SHORT, // Short3
|
||||||
|
GL_FLOAT, // Double4
|
||||||
|
GL_FLOAT, // Float4
|
||||||
|
GL_SHORT, // Short4
|
||||||
|
GL_UNSIGNED_BYTE // UChar4
|
||||||
|
#else
|
||||||
GL_DOUBLE, // Double1
|
GL_DOUBLE, // Double1
|
||||||
GL_FLOAT, // Float1
|
GL_FLOAT, // Float1
|
||||||
GL_SHORT, // Short1
|
GL_SHORT, // Short1
|
||||||
|
@ -824,6 +857,7 @@ const uint CDriverGL::GLType[CVertexBuffer::NumType]=
|
||||||
GL_FLOAT, // Float4
|
GL_FLOAT, // Float4
|
||||||
GL_SHORT, // Short4
|
GL_SHORT, // Short4
|
||||||
GL_UNSIGNED_BYTE // UChar4
|
GL_UNSIGNED_BYTE // UChar4
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
@ -926,6 +960,7 @@ void CDriverGL::setupGlArraysStd(CVertexBufferInfo &vb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#ifndef USE_OPENGLES
|
||||||
case CVertexBufferInfo::HwATI:
|
case CVertexBufferInfo::HwATI:
|
||||||
{
|
{
|
||||||
// setup vertex ptr.
|
// setup vertex ptr.
|
||||||
|
@ -963,9 +998,12 @@ void CDriverGL::setupGlArraysStd(CVertexBufferInfo &vb)
|
||||||
nglArrayObjectATI(GL_COLOR_ARRAY, 4, GL_UNSIGNED_BYTE, vb.VertexSize, vb.VertexObjectId, (ptrdiff_t) vb.ValuePtr[CVertexBuffer::PrimaryColor]);
|
nglArrayObjectATI(GL_COLOR_ARRAY, 4, GL_UNSIGNED_BYTE, vb.VertexSize, vb.VertexObjectId, (ptrdiff_t) vb.ValuePtr[CVertexBuffer::PrimaryColor]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
_DriverGLStates.enableColorArray(false);
|
_DriverGLStates.enableColorArray(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
nlassert(0);
|
nlassert(0);
|
||||||
break;
|
break;
|
||||||
|
@ -1035,7 +1073,9 @@ void CDriverGL::toggleGlArraysForARBVertexProgram()
|
||||||
// If last was a VertexProgram setup, and now it is a standard GL array setup.
|
// If last was a VertexProgram setup, and now it is a standard GL array setup.
|
||||||
if( _LastSetupGLArrayVertexProgram && !isVertexProgramEnabled () )
|
if( _LastSetupGLArrayVertexProgram && !isVertexProgramEnabled () )
|
||||||
{
|
{
|
||||||
|
#ifndef USE_OPENGLES
|
||||||
if (_Extensions.ATITextureEnvCombine3)
|
if (_Extensions.ATITextureEnvCombine3)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
// fix for ATI : when switching from Vertex Program to fixed Pipe, must clean texture, otherwise texture may be disabled in next render
|
// fix for ATI : when switching from Vertex Program to fixed Pipe, must clean texture, otherwise texture may be disabled in next render
|
||||||
// (seems to be a driver bug)
|
// (seems to be a driver bug)
|
||||||
|
@ -1046,12 +1086,16 @@ void CDriverGL::toggleGlArraysForARBVertexProgram()
|
||||||
// activate the texture, or disable texturing if NULL.
|
// activate the texture, or disable texturing if NULL.
|
||||||
activateTexture(stage, NULL);
|
activateTexture(stage, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef USE_OPENGLES
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glVertex4f(0.f, 0.f, 0.f, 1.f);
|
glVertex4f(0.f, 0.f, 0.f, 1.f);
|
||||||
glVertex4f(0.f, 0.f, 0.f, 1.f);
|
glVertex4f(0.f, 0.f, 0.f, 1.f);
|
||||||
glVertex4f(0.f, 0.f, 0.f, 1.f);
|
glVertex4f(0.f, 0.f, 0.f, 1.f);
|
||||||
glVertex4f(0.f, 0.f, 0.f, 1.f);
|
glVertex4f(0.f, 0.f, 0.f, 1.f);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
#endif
|
||||||
|
|
||||||
for(uint stage=0 ; stage<inlGetNumTextStages() ; stage++)
|
for(uint stage=0 ; stage<inlGetNumTextStages() ; stage++)
|
||||||
{
|
{
|
||||||
// activate the texture, or disable texturing if NULL.
|
// activate the texture, or disable texturing if NULL.
|
||||||
|
@ -1185,7 +1229,9 @@ void CDriverGL::setupGlArraysForNVVertexProgram(CVertexBufferInfo &vb)
|
||||||
{
|
{
|
||||||
// Secondary color
|
// Secondary color
|
||||||
_DriverGLStates.enableSecondaryColorArray(true);
|
_DriverGLStates.enableSecondaryColorArray(true);
|
||||||
nglSecondaryColorPointerEXT(4,GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[value]);
|
#ifndef USE_OPENGLES
|
||||||
|
nglSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[value]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1199,7 +1245,9 @@ void CDriverGL::setupGlArraysForNVVertexProgram(CVertexBufferInfo &vb)
|
||||||
|
|
||||||
// Active this value
|
// Active this value
|
||||||
_DriverGLStates.enableVertexAttribArray(glIndex, true);
|
_DriverGLStates.enableVertexAttribArray(glIndex, true);
|
||||||
|
#ifndef USE_OPENGLES
|
||||||
nglVertexAttribPointerNV (glIndex, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
|
nglVertexAttribPointerNV (glIndex, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Else normal case, can't do anything for other values with UChar4....
|
// Else normal case, can't do anything for other values with UChar4....
|
||||||
|
@ -1207,7 +1255,9 @@ void CDriverGL::setupGlArraysForNVVertexProgram(CVertexBufferInfo &vb)
|
||||||
{
|
{
|
||||||
// Active this value
|
// Active this value
|
||||||
_DriverGLStates.enableVertexAttribArray(glIndex, true);
|
_DriverGLStates.enableVertexAttribArray(glIndex, true);
|
||||||
|
#ifndef USE_OPENGLES
|
||||||
nglVertexAttribPointerNV (glIndex, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
|
nglVertexAttribPointerNV (glIndex, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1420,7 +1420,8 @@ void *CVertexBufferHardARB::lock()
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CVertexBufferHardARB::unlock()
|
void CVertexBufferHardARB::unlock()
|
||||||
{
|
{
|
||||||
H_AUTO_OGL(CVertexBufferHardARB_unlock)
|
H_AUTO_OGL(CVertexBufferHardARB_unlock);
|
||||||
|
|
||||||
_VertexPtr = NULL;
|
_VertexPtr = NULL;
|
||||||
if (_Invalid) return;
|
if (_Invalid) return;
|
||||||
if (!_VertexObjectId) return;
|
if (!_VertexObjectId) return;
|
||||||
|
@ -1434,7 +1435,17 @@ void CVertexBufferHardARB::unlock()
|
||||||
#ifdef NL_DEBUG
|
#ifdef NL_DEBUG
|
||||||
_Unmapping = true;
|
_Unmapping = true;
|
||||||
#endif
|
#endif
|
||||||
GLboolean unmapOk = nglUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
|
GLboolean unmapOk = false;
|
||||||
|
|
||||||
|
#ifdef USE_OPENGLES
|
||||||
|
if (_Driver->_Extensions.OESMapBuffer)
|
||||||
|
{
|
||||||
|
unmapOk = nglUnmapBufferOES(GL_ARRAY_BUFFER);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
unmapOk = nglUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef NL_DEBUG
|
#ifdef NL_DEBUG
|
||||||
_Unmapping = false;
|
_Unmapping = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue