Merge remote-tracking branch 'origin/glplaincore'
This commit is contained in:
commit
f7bc014b16
@ -296,6 +296,30 @@ static GLboolean _glewStrSame3 (GLubyte** a, GLuint* na, const GLubyte* b, GLuin
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* A simple open addressing hashset for extensions on OpenGL 3+. */
|
||||
static const char ** ext_hashset = NULL;
|
||||
size_t ext_hashset_size = 0;
|
||||
|
||||
static unsigned hash_string(const char * key)
|
||||
{
|
||||
unsigned hash = 0;
|
||||
unsigned i = 0;
|
||||
for (; i < strlen(key); ++i)
|
||||
{
|
||||
hash += key[i];
|
||||
hash += (hash << 10);
|
||||
hash ^= (hash >> 6);
|
||||
}
|
||||
hash += (hash << 3);
|
||||
hash ^= (hash >> 11);
|
||||
hash += (hash << 15);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
/*
|
||||
* Search for name in the extensions string. Use of strstr()
|
||||
* is not sufficient because extension names can be prefixes of
|
||||
@ -304,14 +328,37 @@ static GLboolean _glewStrSame3 (GLubyte** a, GLuint* na, const GLubyte* b, GLuin
|
||||
*/
|
||||
static GLboolean _glewSearchExtension (const char* name, const GLubyte *start, const GLubyte *end)
|
||||
{
|
||||
const GLubyte* p;
|
||||
GLuint len = _glewStrLen((const GLubyte*)name);
|
||||
p = start;
|
||||
while (p < end)
|
||||
if (ext_hashset != NULL)
|
||||
{
|
||||
GLuint n = _glewStrCLen(p, ' ');
|
||||
if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE;
|
||||
p += n+1;
|
||||
unsigned hash = hash_string(name);
|
||||
|
||||
/*
|
||||
* As the hashset is bigger than the number of extensions
|
||||
* this will eventually break.
|
||||
*/
|
||||
while(1)
|
||||
{
|
||||
unsigned index = hash % ext_hashset_size;
|
||||
if (ext_hashset[index] == NULL)
|
||||
break;
|
||||
|
||||
if (!strcmp(ext_hashset[index], name))
|
||||
return GL_TRUE;
|
||||
|
||||
hash++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const GLubyte* p;
|
||||
GLuint len = _glewStrLen((const GLubyte*)name);
|
||||
p = start;
|
||||
while (p < end)
|
||||
{
|
||||
GLuint n = _glewStrCLen(p, ' ');
|
||||
if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE;
|
||||
p += n+1;
|
||||
}
|
||||
}
|
||||
return GL_FALSE;
|
||||
}
|
||||
@ -10052,7 +10099,10 @@ static GLboolean _glewInit_GL_WIN_swap_hint (GLEW_CONTEXT_ARG_DEF_INIT)
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
GLboolean GLEWAPIENTRY glewGetExtension (const char* name)
|
||||
{
|
||||
{
|
||||
if (ext_hashset != NULL)
|
||||
return _glewSearchExtension(name, NULL, NULL);
|
||||
|
||||
const GLubyte* start;
|
||||
const GLubyte* end;
|
||||
start = (const GLubyte*)glGetString(GL_EXTENSIONS);
|
||||
@ -10114,9 +10164,39 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
|
||||
GLEW_VERSION_1_2 = GLEW_VERSION_1_2_1 == GL_TRUE || ( major == 1 && minor >= 2 ) ? GL_TRUE : GL_FALSE;
|
||||
GLEW_VERSION_1_1 = GLEW_VERSION_1_2 == GL_TRUE || ( major == 1 && minor >= 1 ) ? GL_TRUE : GL_FALSE;
|
||||
}
|
||||
|
||||
if (major >= 3) /* glGetString method is deprecated */
|
||||
{
|
||||
GLint n, i;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
||||
glGetStringi = (PFNGLGETSTRINGIPROC)glewGetProcAddress((const GLubyte*)"glGetStringi");
|
||||
|
||||
free(ext_hashset); /* In case we get called a second time. */
|
||||
|
||||
ext_hashset_size = (n * 3) / 2;
|
||||
ext_hashset = calloc(ext_hashset_size, sizeof(const char *));
|
||||
for (i = 0; i < n; ++i)
|
||||
{
|
||||
const char * extension;
|
||||
unsigned hash;
|
||||
|
||||
extension = (const char *)glGetStringi(GL_EXTENSIONS, i);
|
||||
hash = hash_string(extension);
|
||||
|
||||
while(ext_hashset[hash % ext_hashset_size] != NULL)
|
||||
hash++;
|
||||
|
||||
ext_hashset[hash % ext_hashset_size] = extension;
|
||||
}
|
||||
|
||||
extStart = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* query opengl extensions string */
|
||||
extStart = glGetString(GL_EXTENSIONS);
|
||||
}
|
||||
|
||||
/* query opengl extensions string */
|
||||
extStart = glGetString(GL_EXTENSIONS);
|
||||
if (extStart == 0)
|
||||
extStart = (const GLubyte*)"";
|
||||
extEnd = extStart + _glewStrLen(extStart);
|
||||
|
@ -58,6 +58,7 @@ namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
extern bool useCoreContext;
|
||||
IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
|
||||
io::IFileSystem* io, CIrrDeviceLinux* device);
|
||||
}
|
||||
@ -499,21 +500,7 @@ void IrrPrintXGrabError(int grabResult, const c8 * grabCommand )
|
||||
static GLXContext getMeAGLContext(Display *display, GLXFBConfig glxFBConfig)
|
||||
{
|
||||
GLXContext Context;
|
||||
int compat43ctxdebug[] =
|
||||
{
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, 4,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
||||
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,
|
||||
None
|
||||
};
|
||||
int compat43ctx[] =
|
||||
{
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, 4,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
||||
None
|
||||
};
|
||||
irr::video::useCoreContext = true;
|
||||
int core43ctxdebug[] =
|
||||
{
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, 4,
|
||||
@ -528,21 +515,6 @@ static GLXContext getMeAGLContext(Display *display, GLXFBConfig glxFBConfig)
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
None
|
||||
};
|
||||
int compat33ctxdebug[] =
|
||||
{
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
||||
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,
|
||||
None
|
||||
};
|
||||
int compat33ctx[] =
|
||||
{
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
||||
None
|
||||
};
|
||||
int core33ctxdebug[] =
|
||||
{
|
||||
@ -584,25 +556,13 @@ static GLXContext getMeAGLContext(Display *display, GLXFBConfig glxFBConfig)
|
||||
glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
|
||||
glXGetProcAddressARB( (const GLubyte *) "glXCreateContextAttribsARB" );
|
||||
|
||||
// create compat 4.3 context (for proprietary drivers)
|
||||
Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, GLContextDebugBit ? compat43ctxdebug : compat43ctx);
|
||||
if (!XErrorSignaled)
|
||||
return Context;
|
||||
|
||||
XErrorSignaled = false;
|
||||
// create core 4.3 context (for mesa)
|
||||
// create core 4.3 context
|
||||
Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, GLContextDebugBit ? core43ctxdebug : core43ctx);
|
||||
if (!XErrorSignaled)
|
||||
return Context;
|
||||
|
||||
XErrorSignaled = false;
|
||||
// create compat 3.3 context (for proprietary drivers)
|
||||
Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, GLContextDebugBit ? compat33ctxdebug : compat33ctx);
|
||||
if (!XErrorSignaled)
|
||||
return Context;
|
||||
|
||||
XErrorSignaled = false;
|
||||
// create core 3.3 context (for mesa)
|
||||
// create core 3.3 context
|
||||
Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, GLContextDebugBit ? core33ctxdebug : core33ctx);
|
||||
if (!XErrorSignaled)
|
||||
return Context;
|
||||
@ -614,6 +574,7 @@ static GLXContext getMeAGLContext(Display *display, GLXFBConfig glxFBConfig)
|
||||
return Context;
|
||||
|
||||
XErrorSignaled = false;
|
||||
irr::video::useCoreContext = false;
|
||||
// fall back to legacy context
|
||||
Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, legacyctx);
|
||||
return Context;
|
||||
|
@ -31,7 +31,7 @@ namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
bool useCoreContext;
|
||||
// -----------------------------------------------------------------------
|
||||
// WINDOWS CONSTRUCTOR
|
||||
// -----------------------------------------------------------------------
|
||||
@ -91,13 +91,14 @@ static PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs_ARB;
|
||||
|
||||
static HGLRC getMeAGLContext(HDC HDc)
|
||||
{
|
||||
useCoreContext = true;
|
||||
HGLRC hrc = 0;
|
||||
int ctx44debug[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
|
||||
@ -105,7 +106,7 @@ static HGLRC getMeAGLContext(HDC HDc)
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
|
||||
@ -118,7 +119,7 @@ static HGLRC getMeAGLContext(HDC HDc)
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 0,
|
||||
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
|
||||
@ -126,7 +127,7 @@ static HGLRC getMeAGLContext(HDC HDc)
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 0,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
|
||||
@ -139,7 +140,7 @@ static HGLRC getMeAGLContext(HDC HDc)
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
|
||||
@ -147,7 +148,7 @@ static HGLRC getMeAGLContext(HDC HDc)
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
|
||||
@ -155,6 +156,7 @@ static HGLRC getMeAGLContext(HDC HDc)
|
||||
if (hrc)
|
||||
return hrc;
|
||||
|
||||
useCoreContext = false;
|
||||
int legacyctx[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 2,
|
||||
@ -794,10 +796,11 @@ bool COpenGLDriver::genericDriverInit()
|
||||
|
||||
setAmbientLight(SColorf(0.0f,0.0f,0.0f,0.0f));
|
||||
#ifdef GL_EXT_separate_specular_color
|
||||
if (FeatureAvailable[IRR_EXT_separate_specular_color])
|
||||
if (FeatureAvailable[IRR_EXT_separate_specular_color] && !useCoreContext)
|
||||
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
|
||||
#endif
|
||||
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
|
||||
if (!useCoreContext)
|
||||
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
|
||||
|
||||
Params.HandleSRGB &= ((FeatureAvailable[IRR_ARB_framebuffer_sRGB] || FeatureAvailable[IRR_EXT_framebuffer_sRGB]) &&
|
||||
FeatureAvailable[IRR_EXT_texture_sRGB]);
|
||||
@ -814,7 +817,8 @@ bool COpenGLDriver::genericDriverInit()
|
||||
// glEnable(GL_RESCALE_NORMAL_EXT);
|
||||
|
||||
glClearDepth(1.0);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
if (!useCoreContext)
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||
glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
@ -830,7 +834,8 @@ bool COpenGLDriver::genericDriverInit()
|
||||
// set the renderstates
|
||||
setRenderStates3DMode();
|
||||
|
||||
glAlphaFunc(GL_GREATER, 0.f);
|
||||
if (!useCoreContext)
|
||||
glAlphaFunc(GL_GREATER, 0.f);
|
||||
|
||||
// set fog mode
|
||||
setFog(FogColor, FogType, FogStart, FogEnd, FogDensity, PixelFog, RangeFog);
|
||||
@ -1027,9 +1032,11 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri
|
||||
case ETS_WORLD:
|
||||
{
|
||||
// OpenGL only has a model matrix, view and world is not existent. so lets fake these two.
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
if (!useCoreContext)
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
// first load the viewing transformation for user clip planes
|
||||
if (!useCoreContext)
|
||||
glLoadMatrixf((Matrices[ETS_VIEW]).pointer());
|
||||
|
||||
// we have to update the clip planes to the latest view matrix
|
||||
@ -1038,13 +1045,16 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri
|
||||
uploadClipPlane(i);
|
||||
|
||||
// now the real model-view matrix
|
||||
glMultMatrixf(Matrices[ETS_WORLD].pointer());
|
||||
if (!useCoreContext)
|
||||
glMultMatrixf(Matrices[ETS_WORLD].pointer());
|
||||
}
|
||||
break;
|
||||
case ETS_PROJECTION:
|
||||
{
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadMatrixf(mat.pointer());
|
||||
if (!useCoreContext)
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
if (!useCoreContext)
|
||||
glLoadMatrixf(mat.pointer());
|
||||
}
|
||||
break;
|
||||
case ETS_COUNT:
|
||||
@ -1060,8 +1070,9 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri
|
||||
if (MultiTextureExtension)
|
||||
extGlActiveTexture(GL_TEXTURE0_ARB + i);
|
||||
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
if (!isRTT && mat.isIdentity() )
|
||||
if (!useCoreContext)
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
if (!isRTT && mat.isIdentity() && !useCoreContext)
|
||||
glLoadIdentity();
|
||||
else
|
||||
{
|
||||
@ -1070,7 +1081,8 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri
|
||||
getGLTextureMatrix(glmat, mat * TextureFlipMatrix);
|
||||
else
|
||||
getGLTextureMatrix(glmat, mat);
|
||||
glLoadMatrixf(glmat);
|
||||
if (!useCoreContext)
|
||||
glLoadMatrixf(glmat);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1841,6 +1853,9 @@ void COpenGLDriver::draw2DVertexPrimitiveList(const void* vertices, u32 vertexCo
|
||||
if (!primitiveCount || !vertexCount)
|
||||
return;
|
||||
|
||||
if (useCoreContext)
|
||||
return;
|
||||
|
||||
if (!checkPrimitiveCount(primitiveCount))
|
||||
return;
|
||||
|
||||
@ -2518,20 +2533,23 @@ bool COpenGLDriver::setActiveTexture(u32 stage, const video::ITexture* texture)
|
||||
|
||||
if (!texture)
|
||||
{
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
if (!useCoreContext)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (texture->getDriverType() != EDT_OPENGL)
|
||||
{
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
if (!useCoreContext)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
CurrentTexture.set(stage, 0);
|
||||
os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
if (!useCoreContext)
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D,
|
||||
static_cast<const COpenGLTexture*>(texture)->getOpenGLTextureName());
|
||||
}
|
||||
@ -2647,15 +2665,20 @@ void COpenGLDriver::setRenderStates3DMode()
|
||||
{
|
||||
// Reset Texture Stages
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
if (!useCoreContext)
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// switch back the matrices
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadMatrixf((Matrices[ETS_VIEW] * Matrices[ETS_WORLD]).pointer());
|
||||
if (!useCoreContext)
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
if (!useCoreContext)
|
||||
glLoadMatrixf((Matrices[ETS_VIEW] * Matrices[ETS_WORLD]).pointer());
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadMatrixf(Matrices[ETS_PROJECTION].pointer());
|
||||
if (!useCoreContext)
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
if (!useCoreContext)
|
||||
glLoadMatrixf(Matrices[ETS_PROJECTION].pointer());
|
||||
|
||||
ResetRenderStates = true;
|
||||
#ifdef GL_EXT_clip_volume_hint
|
||||
@ -2822,22 +2845,27 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
break;
|
||||
case ECM_DIFFUSE:
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
||||
if (!useCoreContext)
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
||||
break;
|
||||
case ECM_AMBIENT:
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT);
|
||||
if (!useCoreContext)
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT);
|
||||
break;
|
||||
case ECM_EMISSIVE:
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION);
|
||||
if (!useCoreContext)
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION);
|
||||
break;
|
||||
case ECM_SPECULAR:
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
|
||||
if (!useCoreContext)
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
|
||||
break;
|
||||
case ECM_DIFFUSE_AND_AMBIENT:
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
||||
if (!useCoreContext)
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
||||
break;
|
||||
}
|
||||
if (material.ColorMaterial != ECM_NONE)
|
||||
if (material.ColorMaterial != ECM_NONE && !useCoreContext)
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
}
|
||||
|
||||
@ -2858,7 +2886,8 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
|
||||
color[1] = material.AmbientColor.getGreen() * inv;
|
||||
color[2] = material.AmbientColor.getBlue() * inv;
|
||||
color[3] = material.AmbientColor.getAlpha() * inv;
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color);
|
||||
if (!useCoreContext)
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color);
|
||||
}
|
||||
|
||||
if ((material.ColorMaterial != video::ECM_DIFFUSE) &&
|
||||
@ -2868,7 +2897,8 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
|
||||
color[1] = material.DiffuseColor.getGreen() * inv;
|
||||
color[2] = material.DiffuseColor.getBlue() * inv;
|
||||
color[3] = material.DiffuseColor.getAlpha() * inv;
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color);
|
||||
if (!useCoreContext)
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color);
|
||||
}
|
||||
|
||||
if (material.ColorMaterial != video::ECM_EMISSIVE)
|
||||
@ -2877,7 +2907,8 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
|
||||
color[1] = material.EmissiveColor.getGreen() * inv;
|
||||
color[2] = material.EmissiveColor.getBlue() * inv;
|
||||
color[3] = material.EmissiveColor.getAlpha() * inv;
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color);
|
||||
if (!useCoreContext)
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2889,13 +2920,14 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
|
||||
GLfloat color[4]={0.f,0.f,0.f,1.f};
|
||||
const f32 inv = 1.0f / 255.0f;
|
||||
|
||||
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.Shininess);
|
||||
if (!useCoreContext)
|
||||
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.Shininess);
|
||||
// disable Specular colors if no shininess is set
|
||||
if ((material.Shininess != 0.0f) &&
|
||||
(material.ColorMaterial != video::ECM_SPECULAR))
|
||||
{
|
||||
#ifdef GL_EXT_separate_specular_color
|
||||
if (FeatureAvailable[IRR_EXT_separate_specular_color])
|
||||
if (FeatureAvailable[IRR_EXT_separate_specular_color] && !useCoreContext)
|
||||
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
|
||||
#endif
|
||||
color[0] = material.SpecularColor.getRed() * inv;
|
||||
@ -2904,10 +2936,11 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
|
||||
color[3] = material.SpecularColor.getAlpha() * inv;
|
||||
}
|
||||
#ifdef GL_EXT_separate_specular_color
|
||||
else if (FeatureAvailable[IRR_EXT_separate_specular_color])
|
||||
else if (FeatureAvailable[IRR_EXT_separate_specular_color] && !useCoreContext)
|
||||
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
|
||||
#endif
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color);
|
||||
if (!useCoreContext)
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color);
|
||||
}
|
||||
|
||||
// Texture filter
|
||||
@ -2961,18 +2994,18 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
|
||||
// shademode
|
||||
if (resetAllRenderStates || (lastmaterial.GouraudShading != material.GouraudShading))
|
||||
{
|
||||
if (material.GouraudShading)
|
||||
if (material.GouraudShading && !useCoreContext)
|
||||
glShadeModel(GL_SMOOTH);
|
||||
else
|
||||
else if (!useCoreContext)
|
||||
glShadeModel(GL_FLAT);
|
||||
}
|
||||
|
||||
// lighting
|
||||
if (resetAllRenderStates || (lastmaterial.Lighting != material.Lighting))
|
||||
{
|
||||
if (material.Lighting)
|
||||
if (material.Lighting && !useCoreContext)
|
||||
glEnable(GL_LIGHTING);
|
||||
else
|
||||
else if (!useCoreContext)
|
||||
glDisable(GL_LIGHTING);
|
||||
}
|
||||
|
||||
@ -3053,18 +3086,18 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
|
||||
// fog
|
||||
if (resetAllRenderStates || lastmaterial.FogEnable != material.FogEnable)
|
||||
{
|
||||
if (material.FogEnable)
|
||||
if (material.FogEnable && !useCoreContext)
|
||||
glEnable(GL_FOG);
|
||||
else
|
||||
else if (!useCoreContext)
|
||||
glDisable(GL_FOG);
|
||||
}
|
||||
|
||||
// normalization
|
||||
if (resetAllRenderStates || lastmaterial.NormalizeNormals != material.NormalizeNormals)
|
||||
{
|
||||
if (material.NormalizeNormals)
|
||||
if (material.NormalizeNormals && !useCoreContext)
|
||||
glEnable(GL_NORMALIZE);
|
||||
else
|
||||
else if (!useCoreContext)
|
||||
glDisable(GL_NORMALIZE);
|
||||
}
|
||||
|
||||
@ -3618,7 +3651,8 @@ u32 COpenGLDriver::getMaximalDynamicLightAmount() const
|
||||
void COpenGLDriver::setAmbientLight(const SColorf& color)
|
||||
{
|
||||
GLfloat data[4] = {color.r, color.g, color.b, color.a};
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, data);
|
||||
if (!useCoreContext)
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, data);
|
||||
}
|
||||
|
||||
|
||||
@ -3849,38 +3883,42 @@ void COpenGLDriver::setFog(SColor c, E_FOG_TYPE fogType, f32 start,
|
||||
{
|
||||
CNullDriver::setFog(c, fogType, start, end, density, pixelFog, rangeFog);
|
||||
|
||||
glFogf(GL_FOG_MODE, GLfloat((fogType==EFT_FOG_LINEAR)? GL_LINEAR : (fogType==EFT_FOG_EXP)?GL_EXP:GL_EXP2));
|
||||
if (!useCoreContext)
|
||||
glFogf(GL_FOG_MODE, GLfloat((fogType==EFT_FOG_LINEAR)? GL_LINEAR : (fogType==EFT_FOG_EXP)?GL_EXP:GL_EXP2));
|
||||
|
||||
#ifdef GL_EXT_fog_coord
|
||||
if (FeatureAvailable[IRR_EXT_fog_coord])
|
||||
if (FeatureAvailable[IRR_EXT_fog_coord] && !useCoreContext)
|
||||
glFogi(GL_FOG_COORDINATE_SOURCE, GL_FRAGMENT_DEPTH);
|
||||
#endif
|
||||
#ifdef GL_NV_fog_distance
|
||||
if (FeatureAvailable[IRR_NV_fog_distance])
|
||||
{
|
||||
if (rangeFog)
|
||||
if (rangeFog && !useCoreContext)
|
||||
glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV);
|
||||
else
|
||||
else if (!useCoreContext)
|
||||
glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fogType==EFT_FOG_LINEAR)
|
||||
{
|
||||
glFogf(GL_FOG_START, start);
|
||||
glFogf(GL_FOG_END, end);
|
||||
if (!useCoreContext)
|
||||
glFogf(GL_FOG_START, start);
|
||||
if (!useCoreContext)
|
||||
glFogf(GL_FOG_END, end);
|
||||
}
|
||||
else
|
||||
else if (!useCoreContext)
|
||||
glFogf(GL_FOG_DENSITY, density);
|
||||
|
||||
if (pixelFog)
|
||||
if (pixelFog && !useCoreContext)
|
||||
glHint(GL_FOG_HINT, GL_NICEST);
|
||||
else
|
||||
else if (!useCoreContext)
|
||||
glHint(GL_FOG_HINT, GL_FASTEST);
|
||||
|
||||
SColorf color(c);
|
||||
GLfloat data[4] = {color.r, color.g, color.b, color.a};
|
||||
glFogfv(GL_FOG_COLOR, data);
|
||||
if (!useCoreContext)
|
||||
glFogfv(GL_FOG_COLOR, data);
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
extern bool useCoreContext;
|
||||
COpenGLExtensionHandler::COpenGLExtensionHandler() :
|
||||
StencilBuffer(false), MultiTextureExtension(false),
|
||||
TextureCompressionExtension(false),
|
||||
@ -568,7 +568,8 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
|
||||
if (Version>102 || FeatureAvailable[IRR_ARB_multitexture])
|
||||
{
|
||||
#if defined(GL_MAX_TEXTURE_UNITS)
|
||||
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &num);
|
||||
if (!useCoreContext)
|
||||
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &num);
|
||||
#elif defined(GL_MAX_TEXTURE_UNITS_ARB)
|
||||
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &num);
|
||||
#endif
|
||||
@ -587,7 +588,8 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
|
||||
MaxSupportedTextures=core::max_(MaxSupportedTextures,static_cast<u8>(num));
|
||||
}
|
||||
#endif
|
||||
glGetIntegerv(GL_MAX_LIGHTS, &num);
|
||||
if (!useCoreContext)
|
||||
glGetIntegerv(GL_MAX_LIGHTS, &num);
|
||||
MaxLights=static_cast<u8>(num);
|
||||
#ifdef GL_EXT_texture_filter_anisotropic
|
||||
if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic])
|
||||
@ -621,7 +623,8 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
|
||||
#endif
|
||||
glGetIntegerv(GL_MAX_CLIP_PLANES, &num);
|
||||
MaxUserClipPlanes=static_cast<u8>(num);
|
||||
glGetIntegerv(GL_AUX_BUFFERS, &num);
|
||||
if (!useCoreContext)
|
||||
glGetIntegerv(GL_AUX_BUFFERS, &num);
|
||||
MaxAuxBuffers=static_cast<u8>(num);
|
||||
#ifdef GL_ARB_draw_buffers
|
||||
if (FeatureAvailable[IRR_ARB_draw_buffers])
|
||||
@ -641,7 +644,8 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
|
||||
}
|
||||
#endif
|
||||
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine);
|
||||
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint);
|
||||
if (!useCoreContext)
|
||||
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint);
|
||||
glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, DimSmoothedLine);
|
||||
glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, DimSmoothedPoint);
|
||||
#if defined(GL_ARB_shading_language_100) || defined (GL_VERSION_2_0)
|
||||
|
@ -15,7 +15,7 @@ namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
extern bool useCoreContext;
|
||||
//! Base class for all internal OpenGL material renderers
|
||||
class COpenGLMaterialRenderer : public IMaterialRenderer
|
||||
{
|
||||
@ -50,7 +50,8 @@ public:
|
||||
{
|
||||
// thanks to Murphy, the following line removed some
|
||||
// bugs with several OpenGL implementations.
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
if (!useCoreContext)
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
extern bool useCoreContext;
|
||||
//! constructor for usual textures
|
||||
COpenGLTexture::COpenGLTexture(IImage* origImage, const io::path& name, void* mipmapData, COpenGLDriver* driver)
|
||||
: ITexture(name), ColorFormat(ECF_A8R8G8B8), Driver(driver), Image(0), MipImage(0),
|
||||
@ -350,12 +350,12 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
|
||||
// auto generate if possible and no mipmap data is given
|
||||
if (HasMipMaps && !mipmapData && Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE))
|
||||
{
|
||||
if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED))
|
||||
if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED) && !useCoreContext)
|
||||
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST);
|
||||
else if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY))
|
||||
else if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY) && !useCoreContext)
|
||||
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
|
||||
else
|
||||
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_DONT_CARE);
|
||||
else if (!useCoreContext)
|
||||
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_DONT_CARE);
|
||||
|
||||
AutomaticMipmapUpdate=true;
|
||||
|
||||
@ -405,7 +405,8 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
|
||||
|
||||
if (!MipmapLegacyMode && AutomaticMipmapUpdate)
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
if (!useCoreContext)
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
Driver->extGlGenerateMipmap(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,6 @@ void PostProcessing::renderSSAO()
|
||||
{
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
|
||||
// Generate linear depth buffer
|
||||
irr_driver->getFBO(FBO_LINEAR_DEPTH).Bind();
|
||||
|
@ -342,7 +342,6 @@ void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, unsigned po
|
||||
glDepthMask(GL_TRUE);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_CULL_FACE);
|
||||
if (UserConfigParams::m_dynamic_lights || forceRTT)
|
||||
@ -836,7 +835,6 @@ void IrrDriver::renderGlow(std::vector<GlowData>& glows)
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
|
@ -639,7 +639,6 @@ static video::ITexture *displaceTex = 0;
|
||||
void IrrDriver::renderTransparent()
|
||||
{
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
@ -688,7 +687,6 @@ void IrrDriver::renderTransparent()
|
||||
cb->update();
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
@ -868,7 +866,6 @@ void IrrDriver::renderShadows()
|
||||
glDepthMask(GL_TRUE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(1.5, 0.);
|
||||
m_rtts->getShadowFBO().Bind();
|
||||
|
@ -46,6 +46,14 @@
|
||||
|
||||
#include <ICameraSceneNode.h>
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
extern bool useCoreContext;
|
||||
}
|
||||
}
|
||||
|
||||
RaceGUIBase::RaceGUIBase()
|
||||
{
|
||||
m_ignore_unimportant_messages = false;
|
||||
@ -418,7 +426,8 @@ void RaceGUIBase::renderPlayerView(const Camera *camera, float dt)
|
||||
glviewport[3] = viewport.LowerRightCorner.Y;
|
||||
//glGetIntegerv(GL_VIEWPORT, glviewport);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
if (!irr::video::useCoreContext)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_BLEND);
|
||||
@ -433,7 +442,8 @@ void RaceGUIBase::renderPlayerView(const Camera *camera, float dt)
|
||||
glVertex3d(glviewport[2],glviewport[3],0);
|
||||
glVertex3d(glviewport[2],glviewport[1],0);
|
||||
glEnd();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
if (!irr::video::useCoreContext)
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user