Finally finished cleaning the OpenGL ES stuff.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 12 years ago
parent e44b663bdb
commit 7f0ae42a40

@ -1474,9 +1474,7 @@ void CDriverGL3::setMatrix2DForTextureOffsetAddrMode(const uint stage, const flo
nlassert(stage < inlGetNumTextStages() );
_DriverGLStates.activeTextureARB(stage);
#ifndef USE_OPENGLES
glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, mat);
#endif
}
@ -1487,7 +1485,6 @@ void CDriverGL3::enableNVTextureShader(bool enabled)
if (enabled != _NVTextureShaderEnabled)
{
#ifndef USE_OPENGLES
if (enabled)
{
glEnable(GL_TEXTURE_SHADER_NV);
@ -1496,7 +1493,6 @@ void CDriverGL3::enableNVTextureShader(bool enabled)
{
glDisable(GL_TEXTURE_SHADER_NV);
}
#endif
_NVTextureShaderEnabled = enabled;
}
}
@ -1558,10 +1554,8 @@ void CDriverGL3::setBlendConstantColor(NLMISC::CRGBA col)
if(!_Extensions.EXTBlendColor)
return;
#ifndef USE_OPENGLES
static const float OO255= 1.0f/255;
nglBlendColorEXT(col.R*OO255, col.G*OO255, col.B*OO255, col.A*OO255);
#endif
}
// ***************************************************************************

@ -759,11 +759,7 @@ private:
TCursorMap _Cursors;
#ifdef USE_OPENGLES
EGLDisplay _EglDisplay;
EGLContext _EglContext;
EGLSurface _EglSurface;
#elif defined(NL_OS_WINDOWS)
#if defined(NL_OS_WINDOWS)
HGLRC _hRC;
HDC _hDC;
PIXELFORMATDESCRIPTOR _pfd;

@ -1655,7 +1655,7 @@ bool registerGlXExtensions(CGlExtensions &ext, Display *dpy, sint screen)
return true;
}
#endif // USE_OPENGLES
#endif
#ifdef NL_STATIC
} // NLDRIVERGL/ES

@ -26,12 +26,8 @@
namespace NL3D {
#ifdef NL_STATIC
#ifdef USE_OPENGLES
namespace NLDRIVERGLES {
#else
namespace NLDRIVERGL3 {
#endif
#endif
// ***************************************************************************
/// The extensions used by NL3D.
@ -254,10 +250,7 @@ public:
// ***************************************************************************
#ifdef USE_OPENGLES
/// This function will test and register EGL functions before than the gl context is created
bool registerEGlExtensions(CGlExtensions &ext, EGLDisplay dpy);
#elif defined(NL_OS_WINDOWS)
#if defined(NL_OS_WINDOWS)
/// This function will test and register WGL functions before than the gl context is created
bool registerWGlExtensions(CGlExtensions &ext, HDC hDC);
#elif defined(NL_OS_MAC)
@ -284,48 +277,6 @@ void registerGlExtensions(CGlExtensions &ext);
NB: we do it for all (EXT, NV, ARB extension) even it should be useful only for ARB ones.
*/
#ifdef USE_OPENGLES
// OES_mapbuffer.
//===============
extern NEL_PFNGLMAPBUFFEROESPROC nglMapBufferOES;
extern NEL_PFNGLUNMAPBUFFEROESPROC nglUnmapBufferOES;
extern NEL_PFNGLGETBUFFERPOINTERVOESPROC nglGetBufferPointervOES;
extern NEL_PFNGLBUFFERSUBDATAPROC nglBufferSubData;
extern PFNGLDRAWTEXFOESPROC nglDrawTexfOES;
// GL_OES_framebuffer_object
extern NEL_PFNGLISRENDERBUFFEROESPROC nglIsRenderbufferOES;
extern NEL_PFNGLBINDRENDERBUFFEROESPROC nglBindRenderbufferOES;
extern NEL_PFNGLDELETERENDERBUFFERSOESPROC nglDeleteRenderbuffersOES;
extern NEL_PFNGLGENRENDERBUFFERSOESPROC nglGenRenderbuffersOES;
extern NEL_PFNGLRENDERBUFFERSTORAGEOESPROC nglRenderbufferStorageOES;
extern NEL_PFNGLGETRENDERBUFFERPARAMETERIVOESPROC nglGetRenderbufferParameterivOES;
extern NEL_PFNGLISFRAMEBUFFEROESPROC nglIsFramebufferOES;
extern NEL_PFNGLBINDFRAMEBUFFEROESPROC nglBindFramebufferOES;
extern NEL_PFNGLDELETEFRAMEBUFFERSOESPROC nglDeleteFramebuffersOES;
extern NEL_PFNGLGENFRAMEBUFFERSOESPROC nglGenFramebuffersOES;
extern NEL_PFNGLCHECKFRAMEBUFFERSTATUSOESPROC nglCheckFramebufferStatusOES;
extern NEL_PFNGLFRAMEBUFFERRENDERBUFFEROESPROC nglFramebufferRenderbufferOES;
extern NEL_PFNGLFRAMEBUFFERTEXTURE2DOESPROC nglFramebufferTexture2DOES;
extern NEL_PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOESPROC nglGetFramebufferAttachmentParameterivOES;
extern NEL_PFNGLGENERATEMIPMAPOESPROC nglGenerateMipmapOES;
// GL_OES_texture_cube_map
extern NEL_PFNGLTEXGENFOESPROC nglTexGenfOES;
extern NEL_PFNGLTEXGENFVOESPROC nglTexGenfvOES;
extern NEL_PFNGLTEXGENIOESPROC nglTexGeniOES;
extern NEL_PFNGLTEXGENIVOESPROC nglTexGenivOES;
extern NEL_PFNGLTEXGENXOESPROC nglTexGenxOES;
extern NEL_PFNGLTEXGENXVOESPROC nglTexGenxvOES;
extern NEL_PFNGLGETTEXGENFVOESPROC nglGetTexGenfvOES;
extern NEL_PFNGLGETTEXGENIVOESPROC nglGetTexGenivOES;
extern NEL_PFNGLGETTEXGENXVOESPROC nglGetTexGenxvOES;
#else
// ARB_multitexture
//=================
extern NEL_PFNGLACTIVETEXTUREARBPROC nglActiveTextureARB;
@ -778,7 +729,5 @@ extern NEL_PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC nglRenderbufferStorageMul
// GL_ARB_multisample
extern NEL_PFNGLSAMPLECOVERAGEARBPROC nglSampleCoverageARB;
#endif // USE_OPENGLES
#endif // NL_OPENGL_EXTENSION_H

@ -24,68 +24,6 @@
extern "C" {
#endif
#ifdef USE_OPENGLES
// OES_mapbuffer
//==============
typedef void* (APIENTRY * NEL_PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
typedef GLboolean (APIENTRY * NEL_PFNGLUNMAPBUFFEROESPROC) (GLenum target);
typedef void (APIENTRY * NEL_PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, void** params);
typedef void (APIENTRY * NEL_PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
// GL_OES_framebuffer_object
//==================================
typedef GLboolean (APIENTRY * NEL_PFNGLISRENDERBUFFEROESPROC) (GLuint renderbuffer);
typedef void (APIENTRY * NEL_PFNGLBINDRENDERBUFFEROESPROC) (GLenum target, GLuint renderbuffer);
typedef void (APIENTRY * NEL_PFNGLDELETERENDERBUFFERSOESPROC) (GLsizei n, const GLuint* renderbuffers);
typedef void (APIENTRY * NEL_PFNGLGENRENDERBUFFERSOESPROC) (GLsizei n, GLuint* renderbuffers);
typedef void (APIENTRY * NEL_PFNGLRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (APIENTRY * NEL_PFNGLGETRENDERBUFFERPARAMETERIVOESPROC) (GLenum target, GLenum pname, GLint* params);
typedef GLboolean (APIENTRY * NEL_PFNGLISFRAMEBUFFEROESPROC) (GLuint framebuffer);
typedef void (APIENTRY * NEL_PFNGLBINDFRAMEBUFFEROESPROC) (GLenum target, GLuint framebuffer);
typedef void (APIENTRY * NEL_PFNGLDELETEFRAMEBUFFERSOESPROC) (GLsizei n, const GLuint* framebuffers);
typedef void (APIENTRY * NEL_PFNGLGENFRAMEBUFFERSOESPROC) (GLsizei n, GLuint* framebuffers);
typedef GLenum (APIENTRY * NEL_PFNGLCHECKFRAMEBUFFERSTATUSOESPROC) (GLenum target);
typedef void (APIENTRY * NEL_PFNGLFRAMEBUFFERRENDERBUFFEROESPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
typedef void (APIENTRY * NEL_PFNGLFRAMEBUFFERTEXTURE2DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
typedef void (APIENTRY * NEL_PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOESPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
typedef void (APIENTRY * NEL_PFNGLGENERATEMIPMAPOESPROC) (GLenum target);
// GL_OES_texture_cube_map
//==================================
typedef void (APIENTRY * NEL_PFNGLTEXGENFOESPROC) (GLenum coord, GLenum pname, GLfloat param);
typedef void (APIENTRY * NEL_PFNGLTEXGENFVOESPROC) (GLenum coord, GLenum pname, const GLfloat *params);
typedef void (APIENTRY * NEL_PFNGLTEXGENIOESPROC) (GLenum coord, GLenum pname, GLint param);
typedef void (APIENTRY * NEL_PFNGLTEXGENIVOESPROC) (GLenum coord, GLenum pname, const GLint *params);
typedef void (APIENTRY * NEL_PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param);
typedef void (APIENTRY * NEL_PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params);
typedef void (APIENTRY * NEL_PFNGLGETTEXGENFVOESPROC) (GLenum coord, GLenum pname, GLfloat *params);
typedef void (APIENTRY * NEL_PFNGLGETTEXGENIVOESPROC) (GLenum coord, GLenum pname, GLint *params);
typedef void (APIENTRY * NEL_PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params);
#define GL_MULTISAMPLE_ARB GL_MULTISAMPLE
#define GL_TEXTURE_CUBE_MAP_ARB GL_TEXTURE_CUBE_MAP_OES
#define GL_NONE 0
#define GL_MAX_TEXTURE_UNITS_ARB GL_MAX_TEXTURE_UNITS
#define GL_REFLECTION_MAP_ARB GL_REFLECTION_MAP_OES
#define GL_RGB_SCALE_EXT GL_RGB_SCALE
#define GL_REFLECTION_MAP_ARB GL_REFLECTION_MAP_OES
#define GL_PREVIOUS_EXT GL_PREVIOUS
#define GL_PRIMARY_COLOR_EXT GL_PRIMARY_COLOR
#define GL_CONSTANT_EXT GL_CONSTANT
#define GL_ADD_SIGNED_EXT GL_ADD_SIGNED
#define GL_INTERPOLATE_EXT GL_INTERPOLATE
#define GL_BUMP_ENVMAP_ATI GL_INTERPOLATE
#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
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES
#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
#else
// ***************************************************************************
// ***************************************************************************
// The NEL Functions Typedefs.
@ -461,8 +399,6 @@ typedef void (APIENTRY * NEL_PFNGLXFREEMEMORYNVPROC) (void *pointer);
#endif // NL_OS_MAC
#endif // USE_OPENGLES
#ifdef __cplusplus
}
#endif

@ -38,13 +38,12 @@ static void convBlend(CMaterial::TBlend blend, GLenum& glenum)
case CMaterial::invsrcalpha:glenum=GL_ONE_MINUS_SRC_ALPHA; break;
case CMaterial::srccolor: glenum=GL_SRC_COLOR; break;
case CMaterial::invsrccolor:glenum=GL_ONE_MINUS_SRC_COLOR; break;
// Extended Blend modes.
#ifndef USE_OPENGLES
case CMaterial::blendConstantColor: glenum=GL_CONSTANT_COLOR_EXT; break;
case CMaterial::blendConstantInvColor: glenum=GL_ONE_MINUS_CONSTANT_COLOR_EXT; break;
case CMaterial::blendConstantAlpha: glenum=GL_CONSTANT_ALPHA_EXT; break;
case CMaterial::blendConstantInvAlpha: glenum=GL_ONE_MINUS_CONSTANT_ALPHA_EXT; break;
#endif
default: nlstop;
}

@ -643,14 +643,10 @@ void CDriverGLStates3::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
{

@ -23,12 +23,8 @@
namespace NL3D {
#ifdef NL_STATIC
#ifdef USE_OPENGLES
namespace NLDRIVERGLES {
#else
namespace NLDRIVERGL3 {
#endif
#endif
// ***************************************************************************
/**

@ -49,12 +49,8 @@ using namespace NLMISC;
namespace NL3D {
#ifdef NL_STATIC
#ifdef USE_OPENGLES
namespace NLDRIVERGLES {
#else
namespace NLDRIVERGL3 {
#endif
#endif
// ***************************************************************************
@ -282,12 +278,8 @@ bool CDriverGL3::renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines)
}
else
{
#ifdef USE_OPENGLES
nlerror("not available in OpenGL ES 1.0, only use 16 bits indices");
#else
nlassert(_LastIB._Format == CIndexBuffer::Indices32);
glDrawElements(GL_LINES,2*nlines,GL_UNSIGNED_INT,((uint32 *) _LastIB._Values)+firstIndex);
#endif
}
}
}
@ -342,12 +334,8 @@ bool CDriverGL3::renderTriangles(CMaterial& mat, uint32 firstIndex, uint32 ntris
}
else
{
#ifdef USE_OPENGLES
nlerror("not available in OpenGL ES 1.0, only use 16 bits indices");
#else
nlassert(_LastIB._Format == CIndexBuffer::Indices32);
glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstIndex);
#endif
}
}
}
@ -390,12 +378,8 @@ bool CDriverGL3::renderSimpleTriangles(uint32 firstTri, uint32 ntris)
}
else
{
#ifdef USE_OPENGLES
nlerror("not available in OpenGL ES 1.0, only use 16 bits indices");
#else
nlassert(_LastIB._Format == CIndexBuffer::Indices32);
glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstTri);
#endif
}
// Profiling.
@ -622,9 +606,6 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua
}
else
{
#ifdef USE_OPENGLES
nlerror("not available in OpenGL ES 1.0, only use 16 bits indices");
#else
// indices fits on 32 bits
GLint indices[QUAD_BATCH_SIZE];
GLint *curr = indices;
@ -642,7 +623,6 @@ bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQua
}
while(curr != end);
glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_INT, indices);
#endif
}
numLeftQuads -= numQuadsToDraw;
currIndex += 4 * numQuadsToDraw;
@ -683,12 +663,11 @@ void CDriverGL3::setupUVPtr(uint stage, CVertexBufferInfo &VB, uint uvId)
// Setup ATI VBHard or std ptr.
switch(VB.VBMode)
{
#ifndef USE_OPENGLES
case CVertexBufferInfo::HwATI:
nglArrayObjectATI(GL_TEXTURE_COORD_ARRAY, numTexCoord, GL_FLOAT, VB.VertexSize, VB.VertexObjectId,
(ptrdiff_t) VB.ValuePtr[CVertexBuffer::TexCoord0+uvId]);
break;
#endif
case CVertexBufferInfo::HwARB:
_DriverGLStates.bindARBVertexBuffer(VB.VertexObjectId);
// with arb buffers, position is relative to the start of the stream
@ -831,21 +810,6 @@ const uint CDriverGL3::NumCoordinatesType[CVertexBuffer::NumType]=
// ***************************************************************************
const uint CDriverGL3::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_FLOAT, // Float1
GL_SHORT, // Short1
@ -859,7 +823,6 @@ const uint CDriverGL3::GLType[CVertexBuffer::NumType]=
GL_FLOAT, // Float4
GL_SHORT, // Short4
GL_UNSIGNED_BYTE // UChar4
#endif
};
// ***************************************************************************
@ -962,7 +925,7 @@ void CDriverGL3::setupGlArraysStd(CVertexBufferInfo &vb)
}
}
break;
#ifndef USE_OPENGLES
case CVertexBufferInfo::HwATI:
{
// setup vertex ptr.
@ -1005,7 +968,7 @@ void CDriverGL3::setupGlArraysStd(CVertexBufferInfo &vb)
}
}
break;
#endif
default:
nlassert(0);
break;
@ -1075,9 +1038,8 @@ void CDriverGL3::toggleGlArraysForARBVertexProgram()
// If last was a VertexProgram setup, and now it is a standard GL array setup.
if( _LastSetupGLArrayVertexProgram && !isVertexProgramEnabled () )
{
#ifndef USE_OPENGLES
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
// (seems to be a driver bug)
@ -1089,14 +1051,13 @@ void CDriverGL3::toggleGlArraysForARBVertexProgram()
activateTexture(stage, NULL);
}
#ifndef USE_OPENGLES
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);
glEnd();
#endif
for(uint stage=0 ; stage<inlGetNumTextStages() ; stage++)
{
@ -1231,9 +1192,7 @@ void CDriverGL3::setupGlArraysForNVVertexProgram(CVertexBufferInfo &vb)
{
// Secondary color
_DriverGLStates.enableSecondaryColorArray(true);
#ifndef USE_OPENGLES
nglSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[value]);
#endif
}
}
else
@ -1247,9 +1206,7 @@ void CDriverGL3::setupGlArraysForNVVertexProgram(CVertexBufferInfo &vb)
// Active this value
_DriverGLStates.enableVertexAttribArray(glIndex, true);
#ifndef USE_OPENGLES
nglVertexAttribPointerNV (glIndex, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
#endif
}
}
// Else normal case, can't do anything for other values with UChar4....
@ -1257,9 +1214,7 @@ void CDriverGL3::setupGlArraysForNVVertexProgram(CVertexBufferInfo &vb)
{
// Active this value
_DriverGLStates.enableVertexAttribArray(glIndex, true);
#ifndef USE_OPENGLES
nglVertexAttribPointerNV (glIndex, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
#endif
}
}
else
@ -1315,7 +1270,6 @@ void CDriverGL3::setupGlArraysForARBVertexProgram(CVertexBufferInfo &vb)
_DriverGLStates.bindARBVertexBuffer(vb.VertexObjectId);
}
#ifndef USE_OPENGLES
// special case if the buffer is an ATI_vertex_array_object
if (vb.VBMode == CVertexBufferInfo::HwATI)
{
@ -1349,7 +1303,6 @@ void CDriverGL3::setupGlArraysForARBVertexProgram(CVertexBufferInfo &vb)
}
}
else
#endif
{
// For each value
for (uint value=0; value<CVertexBuffer::NumValue; value++)
@ -1371,11 +1324,7 @@ void CDriverGL3::setupGlArraysForARBVertexProgram(CVertexBufferInfo &vb)
{
mustNormalize = ARBVertexProgramMustNormalizeAttrib[value];
}
#ifdef USE_OPENGLES
glVertexPointer(NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
#else
nglVertexAttribPointerARB(glIndex, NumCoordinatesType[type], GLType[type], mustNormalize, vb.VertexSize, vb.ValuePtr[value]);
#endif
}
else
{
@ -1423,7 +1372,7 @@ void CDriverGL3::setupGlArraysForEXTVertexShader(CVertexBufferInfo &vb)
if (flags & flag & drvInfo->UsedVertexComponents)
{
_DriverGLStates.enableVertexAttribArrayForEXTVertexShader(glIndex, true, drvInfo->Variants);
#ifndef USE_OPENGLES
// use variant or open gl standard array
if (vb.VBMode == CVertexBufferInfo::HwATI)
{
@ -1496,7 +1445,6 @@ void CDriverGL3::setupGlArraysForEXTVertexShader(CVertexBufferInfo &vb)
}
}
else
#endif
{
switch(value)
{
@ -1509,9 +1457,7 @@ void CDriverGL3::setupGlArraysForEXTVertexShader(CVertexBufferInfo &vb)
case CVertexBuffer::Weight: // skin weight
{
nlassert(NumCoordinatesType[type] == 4); // variant, only 4 component supported
#ifndef USE_OPENGLES
nglVariantPointerEXT(drvInfo->Variants[CDriverGL3::EVSSkinWeightVariant], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
#endif
}
break;
case CVertexBuffer::Normal: // normal
@ -1530,27 +1476,21 @@ void CDriverGL3::setupGlArraysForEXTVertexShader(CVertexBufferInfo &vb)
{
// implemented using a variant, as not available with EXTVertexShader
nlassert(NumCoordinatesType[type] == 4); // variant, only 4 component supported
#ifndef USE_OPENGLES
nglVariantPointerEXT(drvInfo->Variants[CDriverGL3::EVSSecondaryColorVariant], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
#endif
}
break;
case CVertexBuffer::Fog: // fog coordinate
{
// implemented using a variant
nlassert(NumCoordinatesType[type] == 4); // variant, only 4 component supported
#ifndef USE_OPENGLES
nglVariantPointerEXT(drvInfo->Variants[CDriverGL3::EVSFogCoordsVariant], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
#endif
}
break;
case CVertexBuffer::PaletteSkin: // palette skin
{
// implemented using a variant
nlassert(NumCoordinatesType[type] == 4); // variant, only 4 component supported
#ifndef USE_OPENGLES
nglVariantPointerEXT(drvInfo->Variants[CDriverGL3::EVSPaletteSkinVariant], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
#endif
}
break;
case CVertexBuffer::Empty: // empty
@ -1807,7 +1747,6 @@ void CDriverGL3::fenceOnCurVBHardIfNeeded(IVertexBufferHardGL *newVBHard)
{
H_AUTO_OGL(CDriverGL3_fenceOnCurVBHardIfNeeded);
#ifndef USE_OPENGLES
// If old is not a VBHard, or if not a NVidia VBHard, no-op.
if( _CurrentVertexBufferHard==NULL || !_CurrentVertexBufferHard->VBType == IVertexBufferHardGL::NVidiaVB)
return;
@ -1836,7 +1775,6 @@ void CDriverGL3::fenceOnCurVBHardIfNeeded(IVertexBufferHardGL *newVBHard)
vbHardNV->GPURenderingAfterFence= false;
}
}
#endif
}
// ***************************************************************************

@ -27,12 +27,8 @@ using namespace NLMISC;
namespace NL3D {
#ifdef NL_STATIC
#ifdef USE_OPENGLES
namespace NLDRIVERGLES {
#else
namespace NLDRIVERGL3 {
#endif
#endif
// ***************************************************************************
// ***************************************************************************
@ -73,8 +69,6 @@ IVertexBufferHardGL::~IVertexBufferHardGL()
H_AUTO_OGL(IVertexBufferHardGL_IVertexBufferHardGLDtor)
}
#ifndef USE_OPENGLES
// ***************************************************************************
// ***************************************************************************
// ***************************************************************************
@ -1135,9 +1129,6 @@ void CVertexArrayRangeMapObjectATI::updateLostBuffers()
}
#endif
#endif // USE_OPENGLES
// ***************************************************************************
// ***************************************************************************
// ***************************************************************************
@ -1213,36 +1204,20 @@ 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);
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);
@ -1250,12 +1225,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;
}
CVertexBufferHardARB *newVbHard= new CVertexBufferHardARB(_Driver, vb);
@ -1297,13 +1267,8 @@ 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);
}
@ -1331,11 +1296,6 @@ CVertexBufferHardARB::CVertexBufferHardARB(CDriverGL3 *drv, CVertexBuffer *vb) :
_Unmapping = false;
#endif
#ifdef USE_OPENGLES
_Buffer = NULL;
_BufferSize = 0;
_LastBufferSize = 0;
#endif
}
// ***************************************************************************
@ -1352,13 +1312,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)
{
@ -1378,13 +1333,6 @@ CVertexBufferHardARB::~CVertexBufferHardARB()
}
#endif
#ifdef USE_OPENGLES
if (_Buffer)
{
delete [] _Buffer;
_Buffer = NULL;
}
#endif
}
// ***************************************************************************
@ -1403,11 +1351,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)
{
@ -1419,25 +1363,13 @@ 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);
@ -1446,11 +1378,7 @@ 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;
@ -1467,38 +1395,7 @@ void *CVertexBufferHardARB::lock()
}
_Driver->_DriverGLStates.bindARBVertexBuffer(_VertexObjectId);
#ifdef USE_OPENGLES
if (_Driver->_Extensions.OESMapBuffer)
{
_VertexPtr = nglMapBufferOES(GL_ARRAY_BUFFER, GL_WRITE_ONLY_OES);
if (!_VertexPtr)
{
nglUnmapBufferOES(GL_ARRAY_BUFFER);
nlassert(glIsBuffer(_VertexObjectId));
invalidate();
return &_DummyVB[0];
}
}
else
{
const uint size = VB->getNumVertices() * VB->getVertexSize();
if (size > _BufferSize)
{
if (_Buffer) delete [] _Buffer;
_Buffer = new uint8[size+3];
_BufferSize = size;
}
uint8 offset = (size_t)_Buffer % 4;
if (offset > 0) offset = 4 - offset;
_VertexPtr = _Buffer + offset;
_LastBufferSize = size;
}
#else
_VertexPtr = nglMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
if (!_VertexPtr)
{
@ -1507,7 +1404,6 @@ void *CVertexBufferHardARB::lock()
invalidate();
return &_DummyVB[0];
}
#endif
#ifdef NL_DEBUG
_VertexArrayRange->_MappedVBList.push_front(this);
@ -1544,14 +1440,7 @@ void CVertexBufferHardARB::unlock()
#endif
GLboolean unmapOk = GL_FALSE;
#ifdef USE_OPENGLES
if (_Driver->_Extensions.OESMapBuffer)
{
unmapOk = nglUnmapBufferOES(GL_ARRAY_BUFFER);
}
#else
unmapOk = nglUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
#endif
#ifdef NL_DEBUG
_Unmapping = false;

@ -23,12 +23,8 @@
namespace NL3D {
#ifdef NL_STATIC
#ifdef USE_OPENGLES
namespace NLDRIVERGLES {
#else
namespace NLDRIVERGL3 {
#endif
#endif
class CDriverGL;
class IVertexBufferHardGL;
@ -117,8 +113,6 @@ protected:
bool _Invalid;
};
#ifndef USE_OPENGLES
// ***************************************************************************
// ***************************************************************************
// NVidia implementation
@ -460,8 +454,6 @@ public:
#endif
};
#endif
// ***************************************************************************
// ***************************************************************************
// ARB_vertex_buffer_object implementation
@ -559,11 +551,7 @@ private:
CVertexArrayRangeARB *_VertexArrayRange;
CVertexBuffer::TPreferredMemory _MemType;
void *_VertexPtr; // pointer on current datas. Null if not locked
#ifdef USE_OPENGLES
uint8 *_Buffer;
uint32 _BufferSize;
uint32 _LastBufferSize;
#endif
// if buffer has been invalidated, returns a dummy memory block and silently fails rendering
std::vector<uint8> _DummyVB;
// for use by CVertexArrayRangeARB

@ -33,12 +33,8 @@ using namespace NLMISC;
namespace NL3D {
#ifdef NL_STATIC
#ifdef USE_OPENGLES
namespace NLDRIVERGLES {
#else
namespace NLDRIVERGL3 {
#endif
#endif
// ***************************************************************************
CVertexProgamDrvInfosGL3::CVertexProgamDrvInfosGL3 (CDriverGL3 *drv, ItVtxPrgDrvInfoPtrList it) : IVertexProgramDrvInfos (drv, it)
@ -51,7 +47,6 @@ CVertexProgamDrvInfosGL3::CVertexProgamDrvInfosGL3 (CDriverGL3 *drv, ItVtxPrgDrv
|| drv->_Extensions.ARBVertexProgram
);
#ifndef USE_OPENGLES
if (drv->_Extensions.NVVertexProgram) // NVIDIA implemntation
{
// Generate a program
@ -65,7 +60,6 @@ CVertexProgamDrvInfosGL3::CVertexProgamDrvInfosGL3 (CDriverGL3 *drv, ItVtxPrgDrv
{
ID = nglGenVertexShadersEXT(1); // ATI implementation
}
#endif
}
@ -90,7 +84,6 @@ bool CDriverGL3::activeNVVertexProgram (CVertexProgram *program)
{
H_AUTO_OGL(CVertexProgamDrvInfosGL_activeNVVertexProgram);
#ifndef USE_OPENGLES
// Setup or unsetup ?
if (program)
{
@ -200,13 +193,10 @@ bool CDriverGL3::activeNVVertexProgram (CVertexProgram *program)
// Ok
return true;
}
#endif
return false;
}
// ***************************************************************************
#ifndef USE_OPENGLES
static
inline GLenum convSwizzleToGLFormat(CVPSwizzle::EComp comp, bool negate)
{
@ -243,7 +233,6 @@ inline GLenum convSwizzleToGLFormat(CVPSwizzle::EComp comp, bool negate)
}
}
}
#endif
// ***************************************************************************
/** Convert an output register to a EXTVertexShader register
@ -252,7 +241,6 @@ static GLuint convOutputRegisterToEXTVertexShader(CVPOperand::EOutputRegister r)
{
H_AUTO_OGL(convOutputRegisterToEXTVertexShader);
#ifndef USE_OPENGLES
switch (r)
{
case CVPOperand::OHPosition: return GL_OUTPUT_VERTEX_EXT;
@ -280,7 +268,6 @@ static GLuint convOutputRegisterToEXTVertexShader(CVPOperand::EOutputRegister r)
nlstop;
break;
}
#endif
return 0;
}
@ -334,7 +321,6 @@ static void doSwizzle(GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum ou
{
H_AUTO_OGL(doSwizzle);
#ifndef USE_OPENGLES
nglSwizzleEXT(res, in, outX, outY, outZ, outW);
#ifdef DEBUG_SETUP_EXT_VERTEX_SHADER
std::string swzStr = "Swizzle : ";
@ -378,7 +364,6 @@ static void doSwizzle(GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum ou
}
EVS_INFO(swzStr.c_str());
#endif
#endif
}
// Perform write mask and output de bug information
@ -386,7 +371,6 @@ static void doWriteMask(GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum
{
H_AUTO_OGL(doWriteMask);
#ifndef USE_OPENGLES
nglWriteMaskEXT(res, in, outX, outY, outZ, outW);
#ifdef DEBUG_SETUP_EXT_VERTEX_SHADER
nlinfo("3D: Write Mask : %c%c%c%c",
@ -396,7 +380,6 @@ static void doWriteMask(GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum
outW ? 'w' : '-'
);
#endif
#endif
}
// ***************************************************************************
@ -406,7 +389,6 @@ bool CDriverGL3::setupEXTVertexShader(const CVPParser::TProgram &program, GLuint
{
H_AUTO_OGL(CDriverGL3_setupEXTVertexShader);
#ifndef USE_OPENGLES
// counter to see what is generated
uint numOp = 0;
uint numOpIndex = 0;
@ -1187,9 +1169,6 @@ bool CDriverGL3::setupEXTVertexShader(const CVPParser::TProgram &program, GLuint
#endif
return true;
#else
return false;
#endif
}
//=================================================================================================
@ -1346,7 +1325,6 @@ bool CDriverGL3::setupARBVertexProgram (const CVPParser::TProgram &inParsedProgr
{
H_AUTO_OGL(CDriverGL3_setupARBVertexProgram);
#ifndef USE_OPENGLES
// tmp
CVPParser::TProgram parsedProgram = inParsedProgram;
//
@ -1481,9 +1459,6 @@ bool CDriverGL3::setupARBVertexProgram (const CVPParser::TProgram &inParsedProgr
#endif
return true;
#else
return false;
#endif
}
@ -1493,7 +1468,6 @@ bool CDriverGL3::activeARBVertexProgram (CVertexProgram *program)
{
H_AUTO_OGL(CDriverGL3_activeARBVertexProgram);
#ifndef USE_OPENGLES
// Setup or unsetup ?
if (program)
{
@ -1557,9 +1531,6 @@ bool CDriverGL3::activeARBVertexProgram (CVertexProgram *program)
_VertexProgramEnabled = false;
}
return true;
#else
return false;
#endif
}
// ***************************************************************************
@ -1567,7 +1538,6 @@ bool CDriverGL3::activeEXTVertexShader (CVertexProgram *program)
{
H_AUTO_OGL(CDriverGL3_activeEXTVertexShader);
#ifndef USE_OPENGLES
// Setup or unsetup ?
if (program)
{
@ -1635,9 +1605,6 @@ bool CDriverGL3::activeEXTVertexShader (CVertexProgram *program)
_VertexProgramEnabled = false;
}
return true;
#else
return false;
#endif
}
// ***************************************************************************
@ -1669,7 +1636,6 @@ void CDriverGL3::setConstant (uint index, float f0, float f1, float f2, float f3
{
H_AUTO_OGL(CDriverGL3_setConstant);
#ifndef USE_OPENGLES
// Vertex program exist ?
if (_Extensions.NVVertexProgram)
{
@ -1685,7 +1651,6 @@ void CDriverGL3::setConstant (uint index, float f0, float f1, float f2, float f3
float datas[] = { f0, f1, f2, f3 };
nglSetInvariantEXT(_EVSConstantHandle + index, GL_FLOAT, datas);
}
#endif
}
@ -1695,7 +1660,6 @@ void CDriverGL3::setConstant (uint index, double d0, double d1, double d2, doubl
{
H_AUTO_OGL(CDriverGL3_setConstant);
#ifndef USE_OPENGLES
// Vertex program exist ?
if (_Extensions.NVVertexProgram)
{
@ -1711,7 +1675,6 @@ void CDriverGL3::setConstant (uint index, double d0, double d1, double d2, doubl
double datas[] = { d0, d1, d2, d3 };
nglSetInvariantEXT(_EVSConstantHandle + index, GL_DOUBLE, datas);
}
#endif
}
@ -1721,7 +1684,6 @@ void CDriverGL3::setConstant (uint index, const NLMISC::CVector& value)
{
H_AUTO_OGL(CDriverGL3_setConstant);
#ifndef USE_OPENGLES
// Vertex program exist ?
if (_Extensions.NVVertexProgram)
{
@ -1737,7 +1699,6 @@ void CDriverGL3::setConstant (uint index, const NLMISC::CVector& value)
float datas[] = { value.x, value.y, value.z, 0 };
nglSetInvariantEXT(_EVSConstantHandle + index, GL_FLOAT, datas);
}
#endif
}
@ -1747,7 +1708,6 @@ void CDriverGL3::setConstant (uint index, const NLMISC::CVectorD& value)
{
H_AUTO_OGL(CDriverGL3_setConstant);
#ifndef USE_OPENGLES
// Vertex program exist ?
if (_Extensions.NVVertexProgram)
{
@ -1763,7 +1723,6 @@ void CDriverGL3::setConstant (uint index, const NLMISC::CVectorD& value)
double datas[] = { value.x, value.y, value.z, 0 };
nglSetInvariantEXT(_EVSConstantHandle + index, GL_DOUBLE, datas);
}
#endif
}
@ -1772,7 +1731,6 @@ void CDriverGL3::setConstant (uint index, uint num, const float *src)
{
H_AUTO_OGL(CDriverGL3_setConstant);
#ifndef USE_OPENGLES
// Vertex program exist ?
if (_Extensions.NVVertexProgram)
{
@ -1792,7 +1750,6 @@ void CDriverGL3::setConstant (uint index, uint num, const float *src)
nglSetInvariantEXT(_EVSConstantHandle + index + k, GL_FLOAT, (void *) (src + 4 * k));
}
}
#endif
}
// ***************************************************************************
@ -1800,7 +1757,6 @@ void CDriverGL3::setConstant (uint index, uint num, const double *src)
{
H_AUTO_OGL(CDriverGL3_setConstant);
#ifndef USE_OPENGLES
// Vertex program exist ?
if (_Extensions.NVVertexProgram)
{
@ -1820,7 +1776,6 @@ void CDriverGL3::setConstant (uint index, uint num, const double *src)
nglSetInvariantEXT(_EVSConstantHandle + index + k, GL_DOUBLE, (void *) (src + 4 * k));
}
}
#endif
}
// ***************************************************************************
@ -1829,11 +1784,7 @@ const uint CDriverGL3::GLMatrix[IDriver::NumMatrix]=
{
GL_MODELVIEW,
GL_PROJECTION,
#ifdef USE_OPENGLES
GL_MODELVIEW
#else
GL_MODELVIEW_PROJECTION_NV
#endif
};
@ -1841,17 +1792,10 @@ const uint CDriverGL3::GLMatrix[IDriver::NumMatrix]=
const uint CDriverGL3::GLTransform[IDriver::NumTransform]=
{
#ifdef USE_OPENGLES
0,
0,
0,
0
#else
GL_IDENTITY_NV,
GL_INVERSE_NV,
GL_TRANSPOSE_NV,
GL_INVERSE_TRANSPOSE_NV
#endif
};
@ -1861,7 +1805,6 @@ void CDriverGL3::setConstantMatrix (uint index, IDriver::TMatrix matrix, IDriver
{
H_AUTO_OGL(CDriverGL3_setConstantMatrix);
#ifndef USE_OPENGLES
// Vertex program exist ?
if (_Extensions.NVVertexProgram)
{
@ -1931,7 +1874,6 @@ void CDriverGL3::setConstantMatrix (uint index, IDriver::TMatrix matrix, IDriver
nglSetInvariantEXT(_EVSConstantHandle + index + 3, GL_FLOAT, matDatas + 12);
}
}
#endif
}
// ***************************************************************************
@ -1949,7 +1891,6 @@ void CDriverGL3::enableVertexProgramDoubleSidedColor(bool doubleSided)
{
H_AUTO_OGL(CDriverGL3_enableVertexProgramDoubleSidedColor);
#ifndef USE_OPENGLES
// Vertex program exist ?
if (_Extensions.NVVertexProgram)
{
@ -1967,7 +1908,6 @@ void CDriverGL3::enableVertexProgramDoubleSidedColor(bool doubleSided)
else
glDisable (GL_VERTEX_PROGRAM_TWO_SIDE_ARB);
}
#endif
}

@ -49,12 +49,8 @@ using namespace NLMISC;
namespace NL3D {
#ifdef NL_STATIC
#ifdef USE_OPENGLES
namespace NLDRIVERGLES {
#else
namespace NLDRIVERGL3 {
#endif
#endif
#ifdef NL_OS_WINDOWS
@ -451,7 +447,6 @@ bool CDriverGL3::unInit()
#ifdef NL_OS_WINDOWS
#ifndef USE_OPENGLES
// Off-screen rendering ?
if (_PBuffer)
{
@ -459,7 +454,6 @@ bool CDriverGL3::unInit()
nwglDestroyPbufferARB(_PBuffer);
_PBuffer = NULL;
}
#endif
if (_Registered && !UnregisterClassW(L"NLClass", GetModuleHandle(NULL)))
{
@ -615,11 +609,9 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
#ifdef NL_OS_WINDOWS
// Init pointers
#ifndef USE_OPENGLES
_PBuffer = NULL;
_hRC = NULL;
_hDC = NULL;
#endif
// Driver caps.
//=============
@ -705,11 +697,7 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
}
// Register WGL functions
#ifdef USE_OPENGLES
registerEGlExtensions (_Extensions, tempHDC);
#else
registerWGlExtensions (_Extensions, tempHDC);
#endif
HDC hdc = wglGetCurrentDC ();
@ -868,19 +856,11 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
_CurrentMode.Depth = uint8(GetDeviceCaps (_hDC, BITSPIXEL));
// Destroy the temp gl context
#ifdef USE_OPENGLES
if (!eglDestroyContext(_EglDisplay, _EglContext);)
{
DWORD error = GetLastError ();
nlwarning ("CDriverGL3::setDisplay: wglDeleteContext failed: 0x%x", error);
}
#else
if (!wglDeleteContext (tempGLRC))
{
DWORD error = GetLastError ();
nlwarning ("CDriverGL3::setDisplay: wglDeleteContext failed: 0x%x", error);
}
#endif
// Destroy the temp windows
if (!DestroyWindow (tmpHWND))
@ -894,13 +874,9 @@ bool CDriverGL3::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool r
DWORD error = GetLastError ();
nlwarning ("CDriverGL3::setDisplay: wglMakeCurrent failed: 0x%x", error);
#ifdef USE_OPENGLES
eglDestroyContext(_EglDisplay, _EglContext);
#else
wglDeleteContext (_hRC);
nwglReleasePbufferDCARB( _PBuffer, _hDC );
nwglDestroyPbufferARB( _PBuffer );
#endif
DestroyWindow (tmpHWND);
_PBuffer = NULL;
@ -1607,19 +1583,7 @@ bool CDriverGL3::destroyWindow()
std::vector<NLMISC::CBitmap> bitmaps;
setWindowIcon(bitmaps);
#ifdef USE_OPENGLES
if (_EglDisplay && _EglContext)
{
eglMakeCurrent(_EglDisplay, _EglSurface, _EglSurface, _EglContext);
if (_DestroyWindow)
{
eglDestroyContext(_EglDisplay, _EglContext);
}
}
#elif defined(NL_OS_WINDOWS)
#if defined(NL_OS_WINDOWS)
// Then delete.
// wglMakeCurrent(NULL,NULL);
@ -2377,106 +2341,7 @@ emptyProc CDriverGL3::getWindowProc()
// --------------------------------------------------
bool CDriverGL3::createContext()
{
#ifdef USE_OPENGLES
uint samples = 0;
if (_CurrentMode.AntiAlias > -1)
{
if (_CurrentMode.AntiAlias == 0)
{
samples = 4;
}
else
{
samples = _CurrentMode.AntiAlias;
}
}
EGLint attribList[] =
{
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_DEPTH_SIZE, 16,
EGL_STENCIL_SIZE, 8,
// EGL_SAMPLE_BUFFERS, _CurrentMode.AntiAlias > -1 ? 1:0,
// EGL_SAMPLES, samples,
EGL_RENDERABLE_TYPE,
EGL_OPENGL_ES_BIT,
EGL_NONE
};
// Get Display
_EglDisplay = EGL_NO_DISPLAY; // eglGetDisplay(_hDC);
if (_EglDisplay == EGL_NO_DISPLAY)
{
_EglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (_EglDisplay == EGL_NO_DISPLAY)
{
nlwarning("3D: failed to get display 0x%x", eglGetError());
return false;
}
}
// Initialize EGL
EGLint majorVersion;
EGLint minorVersion;
if (!eglInitialize(_EglDisplay, &majorVersion, &minorVersion))
{
return EGL_FALSE;
}
const char *extensions = eglQueryString(_EglDisplay, EGL_EXTENSIONS);
// Get configs
EGLint numConfigs;
if (!eglGetConfigs(_EglDisplay, NULL, 0, &numConfigs))
{
return false;
}
// Choose config
EGLConfig config = NULL;
if (!eglChooseConfig(_EglDisplay, attribList, &config, 1, &numConfigs))
{
return false;
}
// Create a surface
_EglSurface = eglCreateWindowSurface(_EglDisplay, config, (EGLNativeWindowType)_win, NULL);
if (_EglSurface == EGL_NO_SURFACE)
{
return false;
}
// Create a GL context
EGLint contextAttribs[] =
{
EGL_CONTEXT_CLIENT_VERSION, 1,
EGL_NONE
};
_EglContext = eglCreateContext(_EglDisplay, config, EGL_NO_CONTEXT, contextAttribs);
if (_EglContext == EGL_NO_CONTEXT)
{
return false;
}
// Make the context current
if (!eglMakeCurrent(_EglDisplay, _EglSurface, _EglSurface, _EglContext))
{
return false;
}
#elif defined(NL_OS_WINDOWS)
#if defined(NL_OS_WINDOWS)
_hDC = GetDC(_win);
_CurrentMode.Depth = uint8(GetDeviceCaps(_hDC,BITSPIXEL));
@ -2526,20 +2391,7 @@ bool CDriverGL3::activate()
if (_win == EmptyWindow)
return false;
#ifdef USE_OPENGLES
EGLContext ctx = eglGetCurrentContext();
if (ctx != _EglContext)
{
// Make the context current
if (!eglMakeCurrent(_EglDisplay, _EglSurface, _EglSurface, _EglContext))
{
return false;
}
}
#elif defined(NL_OS_WINDOWS)
#if defined(NL_OS_WINDOWS)
HGLRC hglrc = wglGetCurrentContext();
@ -2558,7 +2410,7 @@ bool CDriverGL3::activate()
if (nctx != NULL && nctx != _ctx)
glXMakeCurrent(_dpy, _win, _ctx);
#endif // USE_OPENGLES
#endif
return true;
}
@ -2614,14 +2466,11 @@ void CDriverGL3::getWindowSize(uint32 &width, uint32 &height)
{
#ifdef NL_OS_WINDOWS
#ifndef USE_OPENGLES
if (_PBuffer)
{
nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width );
nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height );
}
#endif
#endif
}
else

@ -39,12 +39,6 @@
# include <windowsx.h>
#endif
#ifdef USE_OPENGLES
# include "GLES/gl.h"
# include "GLES/glext.h"
# include "EGL/egl.h"
# include "EGL/eglext.h"
#else
#ifdef NL_OS_WINDOWS
#include <GL/gl.h>
#include "GL/wglext.h"
@ -58,7 +52,6 @@
#include "GL/glxext.h"
#endif
#include "GL/glext.h"
#endif
#include "nel/misc/common.h"
#include "nel/misc/debug.h"

Loading…
Cancel
Save