+
+ square_items="true" child_width="175" child_height="120" />
+#include
+
+/* 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,9 +10099,13 @@ static GLboolean _glewInit_GL_WIN_swap_hint (GLEW_CONTEXT_ARG_DEF_INIT)
/* ------------------------------------------------------------------------- */
GLboolean GLEWAPIENTRY glewGetExtension (const char* name)
-{
+{
const GLubyte* start;
const GLubyte* end;
+
+ if (ext_hashset != NULL)
+ return _glewSearchExtension(name, NULL, NULL);
+
start = (const GLubyte*)glGetString(GL_EXTENSIONS);
if (start == 0)
return GL_FALSE;
@@ -10114,9 +10165,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);
diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp
index 189f78aa3..09a15b162 100644
--- a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp
+++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp
@@ -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;
diff --git a/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp b/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp
index fb25f475d..d2bcea8a4 100644
--- a/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp
+++ b/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp
@@ -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(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);
}
@@ -3444,8 +3477,9 @@ const wchar_t* COpenGLDriver::getName() const
//! deletes all dynamic lights there are
void COpenGLDriver::deleteAllDynamicLights()
{
- for (s32 i=0; i102 || 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(num));
}
#endif
- glGetIntegerv(GL_MAX_LIGHTS, &num);
+ if (!useCoreContext)
+ glGetIntegerv(GL_MAX_LIGHTS, &num);
MaxLights=static_cast(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(num);
- glGetIntegerv(GL_AUX_BUFFERS, &num);
+ if (!useCoreContext)
+ glGetIntegerv(GL_AUX_BUFFERS, &num);
MaxAuxBuffers=static_cast(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)
diff --git a/lib/irrlicht/source/Irrlicht/COpenGLMaterialRenderer.h b/lib/irrlicht/source/Irrlicht/COpenGLMaterialRenderer.h
index ea84a54d5..991e2a6fe 100644
--- a/lib/irrlicht/source/Irrlicht/COpenGLMaterialRenderer.h
+++ b/lib/irrlicht/source/Irrlicht/COpenGLMaterialRenderer.h
@@ -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);
}
}
};
diff --git a/lib/irrlicht/source/Irrlicht/COpenGLTexture.cpp b/lib/irrlicht/source/Irrlicht/COpenGLTexture.cpp
index 20b5d834a..72a750a50 100644
--- a/lib/irrlicht/source/Irrlicht/COpenGLTexture.cpp
+++ b/lib/irrlicht/source/Irrlicht/COpenGLTexture.cpp
@@ -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);
}
diff --git a/src/graphics/callbacks.cpp b/src/graphics/callbacks.cpp
index bfbb6180b..99122a7ab 100644
--- a/src/graphics/callbacks.cpp
+++ b/src/graphics/callbacks.cpp
@@ -93,36 +93,6 @@ void GrassShaderProvider::OnSetConstants(IMaterialRendererServices *srv, int use
{
}
-//-------------------------------------
-void SkyboxProvider::OnSetConstants(IMaterialRendererServices *srv, int)
-{
- const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
- srv->setVertexShaderConstant("time", &time, 1);
-
- vector3df sun_pos = m_sunpos;
- srv->setVertexShaderConstant("sun_pos", &sun_pos.X, 3);
-
- core::matrix4 ModelViewProjectionMatrix = srv->getVideoDriver()->getTransform(ETS_PROJECTION);
- ModelViewProjectionMatrix *= srv->getVideoDriver()->getTransform(ETS_VIEW);
- ModelViewProjectionMatrix *= srv->getVideoDriver()->getTransform(ETS_WORLD);
- srv->setVertexShaderConstant("ModelViewProjectionMatrix", ModelViewProjectionMatrix.pointer(), 16);
-
- if (!firstdone)
- {
- s32 tex = 0;
- srv->setPixelShaderConstant("tex", &tex, 1);
- s32 glow_tex = 1;
- srv->setPixelShaderConstant("glow_tex", &glow_tex, 1);
- firstdone = true;
- }
-}
-
-//-------------------------------------
-
-void BubbleEffectProvider::OnSetConstants(IMaterialRendererServices *srv, int)
-{
-}
-
//-------------------------------------
void MotionBlurProvider::OnSetConstants(IMaterialRendererServices *srv, int)
@@ -160,13 +130,6 @@ void MotionBlurProvider::OnSetConstants(IMaterialRendererServices *srv, int)
//-------------------------------------
-void GaussianBlurProvider::OnSetConstants(IMaterialRendererServices *srv, int)
-{
- srv->setVertexShaderConstant("pixel", m_pixel, 2);
-}
-
-//-------------------------------------
-
void MipVizProvider::OnSetConstants(IMaterialRendererServices *srv, int)
{
const ITexture * const tex = mat.TextureLayer[0].Texture;
@@ -187,18 +150,6 @@ void MipVizProvider::OnSetConstants(IMaterialRendererServices *srv, int)
//-------------------------------------
-void ColorizeProvider::OnSetConstants(IMaterialRendererServices *srv, int)
-{
-}
-
-//-------------------------------------
-
-void ObjectPassProvider::OnSetConstants(IMaterialRendererServices *srv, int)
-{
-}
-
-//-------------------------------------
-
void SunLightProvider::OnSetConstants(IMaterialRendererServices *srv, int)
{
const int hasclouds = World::getWorld()->getTrack()->hasClouds() &&
diff --git a/src/graphics/callbacks.hpp b/src/graphics/callbacks.hpp
index 72976161b..b3c4ab350 100644
--- a/src/graphics/callbacks.hpp
+++ b/src/graphics/callbacks.hpp
@@ -137,87 +137,6 @@ private:
//
-class SkyboxProvider: public CallBase
-{
-public:
- virtual void OnSetConstants(video::IMaterialRendererServices *srv, int);
-
- void setSunPosition(const core::vector3df &in)
- {
- m_sunpos = in;
- //m_sunpos.normalize();
- }
-
-private:
- core::vector3df m_sunpos;
-};
-
-//
-
-class BubbleEffectProvider: public CallBase
-{
-public:
- virtual void OnSetConstants(video::IMaterialRendererServices *srv, int);
-
- BubbleEffectProvider()
- {
- }
-
- // We hijack the material type param 2 of bubbles.
- // It's time to start the fade, negative if fade out, positive if in.
- // It'd be unused otherwise.
-
- void onMadeVisible(scene::IMeshBuffer * const mb)
- {
- if (!contains(mb))
- return;
-
- video::SMaterial &mat = mb->getMaterial();
- mat.MaterialTypeParam2 = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
- }
-
- void onHidden(scene::IMeshBuffer * const mb)
- {
- if (!contains(mb))
- return;
-
- video::SMaterial &mat = mb->getMaterial();
- mat.MaterialTypeParam2 = irr_driver->getDevice()->getTimer()->getTime() / -1000.0f;
- }
-
- void isInitiallyHidden(scene::IMeshBuffer * const mb)
- {
- if (!contains(mb))
- return;
-
- video::SMaterial &mat = mb->getMaterial();
- mat.MaterialTypeParam2 = irr_driver->getDevice()->getTimer()->getTime() / -1000.0f;
- }
-
- void removeBubble(const scene::IMeshBuffer * const mb)
- {
- m_bubbles.erase(mb);
- }
-
- void addBubble(scene::IMeshBuffer * const mb)
- {
- m_bubbles.insert(mb);
-
- video::SMaterial &mat = mb->getMaterial();
- mat.MaterialTypeParam2 = 1;
- }
-
- bool contains(const scene::IMeshBuffer * const mb) const
- {
- return m_bubbles.count(mb)!=0;
- }
-
-private:
- std::set m_bubbles;
-};
-
-//
-
class MotionBlurProvider: public CallBase
{
public:
@@ -284,29 +203,6 @@ private:
//
-class GaussianBlurProvider: public CallBase
-{
-public:
- GaussianBlurProvider()
- {
- m_pixel[0] = 1.0f / UserConfigParams::m_width;
- m_pixel[1] = 1.0f / UserConfigParams::m_height;
- }
-
- void setResolution(int x, int y)
- {
- m_pixel[0] = 1.0f / x;
- m_pixel[1] = 1.0f / y;
- }
-
- virtual void OnSetConstants(video::IMaterialRendererServices *srv, int);
-
-private:
- float m_pixel[2];
-};
-
-//
-
class MipVizProvider: public CallBase
{
public:
@@ -315,47 +211,6 @@ public:
//
-class ColorizeProvider: public CallBase
-{
-public:
- virtual void OnSetConstants(video::IMaterialRendererServices *srv, int);
-
- void setColor(float r, float g, float b)
- {
- m_color[0] = r;
- m_color[1] = g;
- m_color[2] = b;
- }
-
- float getRed() const
- {
- return m_color[0];
- }
-
- float getGreen() const
- {
- return m_color[1];
- }
-
- float getBlue() const
- {
- return m_color[2];
- }
-
-private:
- float m_color[3];
-};
-
-//
-
-class ObjectPassProvider: public CallBase
-{
-public:
- virtual void OnSetConstants(video::IMaterialRendererServices *srv, int);
-};
-
-//
-
class SunLightProvider: public CallBase
{
public:
diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp
index 537b89a26..c858e0645 100644
--- a/src/graphics/irr_driver.cpp
+++ b/src/graphics/irr_driver.cpp
@@ -2490,7 +2490,6 @@ scene::ISceneNode *IrrDriver::addLight(const core::vector3df &pos, float energy,
m_suncam->updateAbsolutePosition();
((WaterShaderProvider *) m_shaders->m_callbacks[ES_WATER])->setSunPosition(pos);
- ((SkyboxProvider *) m_shaders->m_callbacks[ES_SKYBOX])->setSunPosition(pos);
}
return light;
diff --git a/src/graphics/material.cpp b/src/graphics/material.cpp
index a9771816f..d633a8a3c 100644
--- a/src/graphics/material.cpp
+++ b/src/graphics/material.cpp
@@ -203,10 +203,6 @@ Material::Material(const XMLNode *node, bool deprecated)
node->get("splatting-texture-3", &m_splatting_texture_3);
node->get("splatting-texture-4", &m_splatting_texture_4);
}
- else if (s == "bubble")
- {
- m_shader_type = SHADERTYPE_BUBBLE;
- }
else
{
Log::warn("Material", "Unknown shader type <%s> for <%s>", s.c_str(), m_texname.c_str());
@@ -261,10 +257,6 @@ Material::Material(const XMLNode *node, bool deprecated)
{
m_water_splash = true;
}
- else if (s == "bubble")
- {
- m_shader_type = SHADERTYPE_BUBBLE;
- }
else if (s == "grass")
{
m_shader_type = SHADERTYPE_VEGETATION;
@@ -779,17 +771,6 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
m->MaterialType = irr_driver->getShader(ES_GRASS_REF);
m->setTexture(1, glossytex);
return;
- case SHADERTYPE_BUBBLE:
- if (mb)
- {
- BubbleEffectProvider * bubble = (BubbleEffectProvider *)
- irr_driver->getCallback(ES_BUBBLES);
- bubble->addBubble(mb);
-
- m->MaterialType = irr_driver->getShader(ES_BUBBLES);
- m->BlendOperation = video::EBO_ADD;
- }
- return;
}
if (!m->getTexture(0))
@@ -996,12 +977,6 @@ void Material::adjustForFog(scene::ISceneNode* parent, video::SMaterial *m,
void Material::onMadeVisible(scene::IMeshBuffer* who)
{
if (!irr_driver->isGLSL()) return;
-
- BubbleEffectProvider * bubble = (BubbleEffectProvider *)
- irr_driver->getCallback(ES_BUBBLES);
-
- if (bubble != NULL)
- bubble->onMadeVisible(who);
}
//-----------------------------------------------------------------------------
@@ -1010,11 +985,6 @@ void Material::onMadeVisible(scene::IMeshBuffer* who)
void Material::onHidden(scene::IMeshBuffer* who)
{
if (!irr_driver->isGLSL()) return;
-
- BubbleEffectProvider * bubble = (BubbleEffectProvider *)
- irr_driver->getCallback(ES_BUBBLES);
- if (bubble != NULL)
- bubble->onHidden(who);
}
//-----------------------------------------------------------------------------
@@ -1022,11 +992,6 @@ void Material::onHidden(scene::IMeshBuffer* who)
void Material::isInitiallyHidden(scene::IMeshBuffer* who)
{
if (!irr_driver->isGLSL()) return;
-
- BubbleEffectProvider * bubble = (BubbleEffectProvider *)
- irr_driver->getCallback(ES_BUBBLES);
- if (bubble != NULL)
- bubble->isInitiallyHidden(who);
}
//-----------------------------------------------------------------------------
diff --git a/src/graphics/material.hpp b/src/graphics/material.hpp
index c2ff73159..99f0951e2 100644
--- a/src/graphics/material.hpp
+++ b/src/graphics/material.hpp
@@ -53,8 +53,6 @@ public:
SHADERTYPE_ALPHA_BLEND,
SHADERTYPE_ADDITIVE,
SHADERTYPE_SOLID_UNLIT,
- /** Effect where the UV texture is moved in a wave pattern */
- SHADERTYPE_BUBBLE,
/** Effect that makes grass wave as in the wind */
SHADERTYPE_VEGETATION,
SHADERTYPE_WATER,
diff --git a/src/graphics/material_manager.cpp b/src/graphics/material_manager.cpp
index f960709d6..eae49fb90 100644
--- a/src/graphics/material_manager.cpp
+++ b/src/graphics/material_manager.cpp
@@ -66,7 +66,9 @@ MaterialManager::~MaterialManager()
Material* MaterialManager::getMaterialFor(video::ITexture* t,
scene::IMeshBuffer *mb)
{
- assert(t != NULL);
+ if (t == NULL)
+ return m_default_material;
+
const std::string image = StringUtils::getBasename(core::stringc(t->getName()).c_str());
// Search backward so that temporary (track) textures are found first
for(int i = (int)m_materials.size()-1; i>=0; i-- )
@@ -77,7 +79,7 @@ Material* MaterialManager::getMaterialFor(video::ITexture* t,
}
} // for i
- return NULL;
+ return m_default_material;
}
//-----------------------------------------------------------------------------
diff --git a/src/graphics/post_processing.cpp b/src/graphics/post_processing.cpp
index aac0e3d0e..dee6b68a4 100644
--- a/src/graphics/post_processing.cpp
+++ b/src/graphics/post_processing.cpp
@@ -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();
@@ -622,8 +621,6 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode, boo
// Set the sun's color
const SColor col = track->getGodRaysColor();
- ColorizeProvider * const colcb = (ColorizeProvider *)irr_driver->getCallback(ES_COLORIZE);
- colcb->setColor(col.getRed() / 255.0f, col.getGreen() / 255.0f, col.getBlue() / 255.0f);
// The sun interposer
STKMeshSceneNode *sun = irr_driver->getSunInterposer();
diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp
index 545695739..1e468a526 100644
--- a/src/graphics/render.cpp
+++ b/src/graphics/render.cpp
@@ -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)
@@ -829,14 +828,12 @@ void IrrDriver::renderGlow(std::vector& glows)
glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
const u32 glowcount = (int)glows.size();
- ColorizeProvider * const cb = (ColorizeProvider *) m_shaders->m_callbacks[ES_COLORIZE];
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glStencilFunc(GL_ALWAYS, 1, ~0);
glEnable(GL_STENCIL_TEST);
glEnable(GL_DEPTH_TEST);
- glDisable(GL_ALPHA_TEST);
glDepthMask(GL_FALSE);
glDisable(GL_BLEND);
diff --git a/src/graphics/render_geometry.cpp b/src/graphics/render_geometry.cpp
index 34a0a3eb3..f42f04b0b 100644
--- a/src/graphics/render_geometry.cpp
+++ b/src/graphics/render_geometry.cpp
@@ -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();
diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp
index 44b5bc5f4..66cb91bdd 100644
--- a/src/graphics/shaders.cpp
+++ b/src/graphics/shaders.cpp
@@ -110,14 +110,10 @@ Shaders::Shaders()
// Callbacks
memset(m_callbacks, 0, sizeof(m_callbacks));
- m_callbacks[ES_SKYBOX] = new SkyboxProvider();
m_callbacks[ES_WATER] = new WaterShaderProvider();
m_callbacks[ES_GRASS] = new GrassShaderProvider();
- m_callbacks[ES_BUBBLES] = new BubbleEffectProvider();
m_callbacks[ES_MOTIONBLUR] = new MotionBlurProvider();
- m_callbacks[ES_GAUSSIAN3V] = m_callbacks[ES_GAUSSIAN3H] = new GaussianBlurProvider();
m_callbacks[ES_MIPVIZ] = new MipVizProvider();
- m_callbacks[ES_COLORIZE] = new ColorizeProvider();
m_callbacks[ES_SUNLIGHT] = new SunLightProvider();
m_callbacks[ES_DISPLACE] = new DisplaceProvider();
@@ -346,9 +342,6 @@ void Shaders::loadShaders()
m_shaders[ES_GRASS_REF] = glslmat(dir + "pass.vert", dir + "pass.frag",
m_callbacks[ES_GRASS], EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
- m_shaders[ES_BUBBLES] = glslmat(dir + "pass.vert", dir + "pass.frag",
- m_callbacks[ES_BUBBLES], EMT_TRANSPARENT_ALPHA_CHANNEL);
-
m_shaders[ES_MOTIONBLUR] = glsl(dir + "pass.vert", dir + "pass.frag",
m_callbacks[ES_MOTIONBLUR]);
@@ -407,7 +400,6 @@ void Shaders::loadShaders()
initFrustrumVBO();
initShadowVPMUBO();
initParticleQuadVBO();
- MeshShader::BubbleShader::init();
MeshShader::ViewFrustrumShader::init();
UtilShader::ColoredLine::init();
}
@@ -1000,30 +992,6 @@ namespace MeshShader
7, "tex_detail3");
}
- GLuint BubbleShader::Program;
- GLuint BubbleShader::uniform_MVP;
- GLuint BubbleShader::uniform_tex;
- GLuint BubbleShader::uniform_time;
- GLuint BubbleShader::uniform_transparency;
-
- void BubbleShader::init()
- {
- Program = LoadProgram(OBJECT,
- GL_VERTEX_SHADER, file_manager->getAsset("shaders/bubble.vert").c_str(),
- GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/bubble.frag").c_str());
- uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
- uniform_tex = glGetUniformLocation(Program, "tex");
- uniform_time = glGetUniformLocation(Program, "time");
- uniform_transparency = glGetUniformLocation(Program, "transparency");
- }
- void BubbleShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex, float time, float transparency)
- {
- glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
- glUniform1i(uniform_tex, TU_tex);
- glUniform1f(uniform_time, time);
- glUniform1f(uniform_transparency, transparency);
- }
-
TransparentShader::TransparentShader()
{
Program = LoadProgram(OBJECT,
diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp
index 96fa24d2b..9a0214731 100644
--- a/src/graphics/shaders.hpp
+++ b/src/graphics/shaders.hpp
@@ -179,16 +179,6 @@ public:
SplattingShader();
};
-class BubbleShader
-{
-public:
- static GLuint Program;
- static GLuint uniform_MVP, uniform_tex, uniform_time, uniform_transparency;
-
- static void init();
- static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex, float time, float transparency);
-};
-
class TransparentShader : public ShaderHelperSingleton, public TextureRead
{
public:
@@ -628,7 +618,6 @@ public:
ACT(ES_SPHERE_MAP) \
ACT(ES_GRASS) \
ACT(ES_GRASS_REF) \
- ACT(ES_BUBBLES) \
ACT(ES_MOTIONBLUR) \
ACT(ES_GAUSSIAN3H) \
ACT(ES_GAUSSIAN3V) \
diff --git a/src/graphics/stkanimatedmesh.cpp b/src/graphics/stkanimatedmesh.cpp
index 40b29437a..da07759f6 100644
--- a/src/graphics/stkanimatedmesh.cpp
+++ b/src/graphics/stkanimatedmesh.cpp
@@ -4,6 +4,7 @@
#include
#include
#include "graphics/irr_driver.hpp"
+#include "graphics/material_manager.hpp"
#include "config/user_config.hpp"
#include "modes/world.hpp"
#include "tracks/track.hpp"
@@ -95,14 +96,16 @@ void STKAnimatedMesh::updateNoGL()
continue;
}
GLMesh &mesh = GLmeshes[i];
+ Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb);
+
if (rnd->isTransparent())
{
- TransparentMaterial TranspMat = MaterialTypeToTransparentMaterial(type, MaterialTypeParam);
+ TransparentMaterial TranspMat = MaterialTypeToTransparentMaterial(type, MaterialTypeParam, material);
TransparentMesh[TranspMat].push_back(&mesh);
}
else
{
- MeshMaterial MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType());
+ MeshMaterial MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material);
MeshSolidMaterial[MatType].push_back(&mesh);
}
}
@@ -138,7 +141,8 @@ void STKAnimatedMesh::updateGL()
if (!rnd->isTransparent())
{
- MeshMaterial MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType());
+ Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb);
+ MeshMaterial MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material);
InitTextures(mesh, MatType);
}
diff --git a/src/graphics/stkmesh.cpp b/src/graphics/stkmesh.cpp
index 565382b64..b073e1212 100644
--- a/src/graphics/stkmesh.cpp
+++ b/src/graphics/stkmesh.cpp
@@ -10,31 +10,34 @@
#include "graphics/camera.hpp"
#include "modes/world.hpp"
-MeshMaterial MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE MaterialType, video::E_VERTEX_TYPE tp)
+MeshMaterial MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE MaterialType, video::E_VERTEX_TYPE tp, Material* material)
{
- if (MaterialType == irr_driver->getShader(ES_SPHERE_MAP))
+ switch (material->getShaderType())
+ {
+ case Material::SHADERTYPE_SPHERE_MAP:
return MAT_SPHEREMAP;
- if (MaterialType == irr_driver->getShader(ES_NORMAL_MAP))
- return MAT_NORMAL_MAP;
- else if (MaterialType == irr_driver->getShader(ES_OBJECTPASS_REF) || MaterialType == video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
+ case Material::SHADERTYPE_ALPHA_TEST:
return MAT_ALPHA_REF;
- else if (MaterialType == irr_driver->getShader(ES_GRASS) || MaterialType == irr_driver->getShader(ES_GRASS_REF))
+ case Material::SHADERTYPE_VEGETATION:
return MAT_GRASS;
- else if (MaterialType == irr_driver->getShader(ES_SPLATTING))
+ case Material::SHADERTYPE_SPLATTING:
return MAT_SPLATTING;
- else if (MaterialType == irr_driver->getShader(ES_OBJECT_UNLIT))
+ case Material::SHADERTYPE_SOLID_UNLIT:
return MAT_UNLIT;
- else if (tp == video::EVT_2TCOORDS)
- return MAT_DETAIL;
- return MAT_DEFAULT;
+ default:
+ if (MaterialType == irr_driver->getShader(ES_NORMAL_MAP))
+ return MAT_NORMAL_MAP;
+ else if (tp == video::EVT_2TCOORDS)
+ return MAT_DETAIL;
+ return MAT_DEFAULT;
+ }
+
}
-TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE type, f32 MaterialTypeParam)
+TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE type, f32 MaterialTypeParam, Material* material)
{
if (type == irr_driver->getShader(ES_DISPLACE))
return TM_DISPLACEMENT;
- if (type == irr_driver->getShader(ES_BUBBLES))
- return TM_BUBBLE;
video::E_BLEND_FACTOR srcFact, DstFact;
video::E_MODULATE_FUNC mod;
u32 alpha;
@@ -241,23 +244,6 @@ core::vector3df getWindDir()
return m_speed * vector3df(1., 0., 0.) * cos(time);
}
-void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
-{
- irr_driver->IncreaseObjectCount();
- const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
- float transparency = 1.;
-
- GLenum ptype = mesh.PrimitiveType;
- GLenum itype = mesh.IndexType;
- size_t count = mesh.IndexCount;
-
- compressTexture(mesh.textures[0], true);
- setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
-
- MeshShader::BubbleShader::setUniforms(ModelViewProjectionMatrix, 0, time, transparency);
- glDrawElementsBaseVertex(ptype, count, itype, (GLvoid *)mesh.vaoOffset, mesh.vaoBaseVertex);
-}
-
bool isObject(video::E_MATERIAL_TYPE type)
{
if (type == irr_driver->getShader(ES_OBJECTPASS))
@@ -276,8 +262,6 @@ bool isObject(video::E_MATERIAL_TYPE type)
return true;
if (type == irr_driver->getShader(ES_GRASS_REF))
return true;
- if (type == irr_driver->getShader(ES_BUBBLES))
- return true;
if (type == irr_driver->getShader(ES_DISPLACE))
return true;
if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
diff --git a/src/graphics/stkmesh.hpp b/src/graphics/stkmesh.hpp
index 1a89044b6..e9e111033 100644
--- a/src/graphics/stkmesh.hpp
+++ b/src/graphics/stkmesh.hpp
@@ -10,6 +10,8 @@
#include
+class Material;
+
enum MeshMaterial
{
MAT_DEFAULT,
@@ -27,7 +29,6 @@ enum TransparentMaterial
{
TM_DEFAULT,
TM_ADDITIVE,
- TM_BUBBLE,
TM_DISPLACEMENT,
TM_COUNT
};
@@ -185,11 +186,8 @@ class ListDisplacement : public MiscList, public std::vector
{};
-// Forward pass (for transparents meshes)
-void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
-
-MeshMaterial MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE, video::E_VERTEX_TYPE);
-TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE, f32 MaterialTypeParam);
+MeshMaterial MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE, video::E_VERTEX_TYPE, Material* material);
+TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE, f32 MaterialTypeParam, Material* material);
void InitTextures(GLMesh &mesh, MeshMaterial);
diff --git a/src/graphics/stkmeshscenenode.cpp b/src/graphics/stkmeshscenenode.cpp
index 6ad361375..d63420aef 100644
--- a/src/graphics/stkmeshscenenode.cpp
+++ b/src/graphics/stkmeshscenenode.cpp
@@ -8,6 +8,7 @@
#include "config/user_config.hpp"
#include "graphics/callbacks.hpp"
#include "graphics/camera.hpp"
+#include "graphics/material_manager.hpp"
#include "modes/world.hpp"
#include "utils/helpers.hpp"
#include "utils/tuple.hpp"
@@ -132,16 +133,17 @@ void STKMeshSceneNode::updateNoGL()
}
GLMesh &mesh = GLmeshes[i];
+ Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb);
if (rnd->isTransparent())
{
- TransparentMaterial TranspMat = MaterialTypeToTransparentMaterial(type, MaterialTypeParam);
+ TransparentMaterial TranspMat = MaterialTypeToTransparentMaterial(type, MaterialTypeParam, material);
if (!immediate_draw)
TransparentMesh[TranspMat].push_back(&mesh);
}
else
{
assert(!isDisplacement);
- MeshMaterial MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType());
+ MeshMaterial MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material);
if (!immediate_draw)
MeshSolidMaterial[MatType].push_back(&mesh);
}
@@ -176,7 +178,8 @@ void STKMeshSceneNode::updateGL()
if (!rnd->isTransparent())
{
- MeshMaterial MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType());
+ Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb);
+ MeshMaterial MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material);
if (!immediate_draw)
InitTextures(mesh, MatType);
}
@@ -429,18 +432,5 @@ void STKMeshSceneNode::render()
}
return;
}
-
- GLMesh* mesh;
- if (!TransparentMesh[TM_BUBBLE].empty())
- glUseProgram(MeshShader::BubbleShader::Program);
- if (irr_driver->hasARB_base_instance())
- glBindVertexArray(VAOManager::getInstance()->getVAO(video::EVT_STANDARD));
- for_in(mesh, TransparentMesh[TM_BUBBLE])
- {
- if (irr_driver->hasARB_base_instance())
- glBindVertexArray(mesh->vao);
- drawBubble(*mesh, ModelViewProjectionMatrix);
- }
- return;
}
}
diff --git a/src/io/file_manager.cpp b/src/io/file_manager.cpp
index 3b784c35a..fecf0f3b2 100644
--- a/src/io/file_manager.cpp
+++ b/src/io/file_manager.cpp
@@ -422,8 +422,8 @@ XMLNode *FileManager::createXMLTreeFromString(const std::string & content)
{
char *b = new char[content.size()];
memcpy(b, content.c_str(), content.size());
- io::IReadFile * ireadfile =
- m_file_system->createMemoryReadFile(b, (int)content.size(),
+ io::IReadFile * ireadfile =
+ m_file_system->createMemoryReadFile(b, (int)content.size(),
"tempfile", true);
io::IXMLReader * reader = m_file_system->createXMLReader(ireadfile);
XMLNode* node = new XMLNode(reader);
@@ -1290,7 +1290,7 @@ bool FileManager::copyFile(const std::string &source, const std::string &dest)
{
Log::error("FileManager", "Write error copying '%s' to '%s",
source.c_str(), dest.c_str());
- delete buffer;
+ delete[] buffer;
fclose(f_source);
fclose(f_dest);
return false;
@@ -1298,7 +1298,7 @@ bool FileManager::copyFile(const std::string &source, const std::string &dest)
} // if fwrite()!=n
} // while
- delete buffer;
+ delete[] buffer;
fclose(f_source);
fclose(f_dest);
return true;
diff --git a/src/karts/controller/player_controller.cpp b/src/karts/controller/player_controller.cpp
index a88a4e691..61298f308 100644
--- a/src/karts/controller/player_controller.cpp
+++ b/src/karts/controller/player_controller.cpp
@@ -92,6 +92,7 @@ void PlayerController::reset()
m_prev_brake = 0;
m_prev_accel = 0;
m_prev_nitro = false;
+ m_sound_schedule = false;
m_penalty_time = 0;
} // reset
@@ -108,6 +109,7 @@ void PlayerController::resetInputState()
m_prev_brake = 0;
m_prev_accel = 0;
m_prev_nitro = false;
+ m_sound_schedule = false;
m_controls->reset();
} // resetInputState
@@ -378,14 +380,20 @@ void PlayerController::update(float dt)
// Only accept rescue if there is no kart animation is already playing
// (e.g. if an explosion happens, wait till the explosion is over before
// starting any other animation).
- if ( m_controls->m_rescue && !m_kart->getKartAnimation() )
+ if (m_controls->m_rescue && !m_kart->getKartAnimation())
{
new RescueAnimation(m_kart);
m_controls->m_rescue=false;
}
- if (m_kart->getKartAnimation() &&
+
+ if (m_kart->getKartAnimation() && m_sound_schedule == false &&
m_kart->getAttachment()->getType() != Attachment::ATTACH_TINYTUX)
{
+ m_sound_schedule = true;
+ }
+ else if (!m_kart->getKartAnimation() && m_sound_schedule == true)
+ {
+ m_sound_schedule = false;
m_bzzt_sound->play();
}
} // update
diff --git a/src/karts/controller/player_controller.hpp b/src/karts/controller/player_controller.hpp
index 1e75ac8e5..9f90da39b 100644
--- a/src/karts/controller/player_controller.hpp
+++ b/src/karts/controller/player_controller.hpp
@@ -40,6 +40,7 @@ private:
int m_prev_accel;
bool m_prev_brake;
bool m_prev_nitro;
+ bool m_sound_schedule;
float m_penalty_time;
diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp
index 67b4e2159..46879f99c 100644
--- a/src/karts/kart.cpp
+++ b/src/karts/kart.cpp
@@ -1761,7 +1761,6 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
// a fence.
btVector3 gravity = m_body->getGravity();
gravity.normalize();
- // Cast necessary since otherwise to operator- (vec3/btvector) exists
Vec3 impulse = normal - gravity* btDot(normal, gravity);
if(impulse.getX() || impulse.getZ())
impulse.normalize();
diff --git a/src/main.cpp b/src/main.cpp
index 1be3db9de..50e80db02 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -429,7 +429,7 @@ void setupRaceStart()
*/
void cmdLineHelp()
{
- Log::info("main",
+ fprintf(stdout,
"Usage: %s [OPTIONS]\n\n"
"Run SuperTuxKart, a racing game with go-kart that features"
" the Tux and friends.\n\n"
diff --git a/src/race/race_manager.cpp b/src/race/race_manager.cpp
index 1a3535548..e49592125 100644
--- a/src/race/race_manager.cpp
+++ b/src/race/race_manager.cpp
@@ -324,7 +324,7 @@ void RaceManager::startNew(bool from_overworld)
// Then the players, which start behind the AI karts
// -------------------------------------------------
- for(unsigned int i=0; i<(int)m_player_karts.size(); i++)
+ for(unsigned int i=0; i<(unsigned int)m_player_karts.size(); i++)
{
KartType kt= m_player_karts[i].isNetworkPlayer() ? KT_NETWORK_PLAYER : KT_PLAYER;
m_kart_status.push_back(KartStatus(m_player_karts[i].getKartName(), i,
diff --git a/src/states_screens/race_gui_base.cpp b/src/states_screens/race_gui_base.cpp
index 22fab2709..185c6ed5e 100644
--- a/src/states_screens/race_gui_base.cpp
+++ b/src/states_screens/race_gui_base.cpp
@@ -46,6 +46,14 @@
#include
+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
}
diff --git a/src/states_screens/register_screen.cpp b/src/states_screens/register_screen.cpp
index 98aa42311..ab94ce007 100644
--- a/src/states_screens/register_screen.cpp
+++ b/src/states_screens/register_screen.cpp
@@ -79,7 +79,6 @@ void RegisterScreen::init()
m_info_widget = getWidget("info");
assert(m_info_widget);
m_info_widget->setDefaultColor();
- m_info_widget->setText("", false);
m_options_widget = getWidget("options");
assert(m_options_widget);
diff --git a/src/tracks/model_definition_loader.cpp b/src/tracks/model_definition_loader.cpp
index 98159e961..e8444e98a 100644
--- a/src/tracks/model_definition_loader.cpp
+++ b/src/tracks/model_definition_loader.cpp
@@ -88,6 +88,7 @@ LODNode* ModelDefinitionLoader::instanciateAsLOD(const XMLNode* node, scene::ISc
a_mesh->grab();
//cache.push_back(a_mesh);
irr_driver->grabAllTextures(a_mesh);
+ m_track->addCachedMesh(a_mesh);
scene::IMeshSceneNode* scene_node = irr_driver->addMesh(a_mesh);
m_track->handleAnimatedTextures( scene_node, *group[m].m_xml );
diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp
index bf734a488..ff9888cc1 100644
--- a/src/tracks/track.cpp
+++ b/src/tracks/track.cpp
@@ -2062,6 +2062,10 @@ void Track::loadObjects(const XMLNode* root, const std::string& path, ModelDefin
{
// handled above
}
+ else if (name == "lightshaft")
+ {
+ // handled above
+ }
else if (name == "instancing")
{
// TODO: eventually remove, this is now automatic
diff --git a/src/tracks/track.hpp b/src/tracks/track.hpp
index 0e6381fe1..d5eadd80b 100644
--- a/src/tracks/track.hpp
+++ b/src/tracks/track.hpp
@@ -654,7 +654,11 @@ public:
// ------------------------------------------------------------------------
void setActualNumberOfLaps(unsigned int laps)
{ m_actual_number_of_laps = laps; }
+ // ------------------------------------------------------------------------
bool operator<(const Track &other) const;
+ // ------------------------------------------------------------------------
+ /** Adds mesh to cleanup list */
+ void addCachedMesh(scene::IMesh* mesh) { m_all_cached_meshes.push_back(mesh); }
}; // class Track
#endif