Conflicts:
	src/graphics/stkmesh.hpp
This commit is contained in:
Marianne Gagnon 2014-09-27 18:51:49 -04:00
commit f5de76a988
22 changed files with 227 additions and 454 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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);
}

View File

@ -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)

View File

@ -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);
}
}
};

View File

@ -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);
}

View File

@ -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() &&

View File

@ -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<const scene::IMeshBuffer *> 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:

View File

@ -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;

View File

@ -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);
}
//-----------------------------------------------------------------------------

View File

@ -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,

View File

@ -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();

View File

@ -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<GlowData>& 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);

View File

@ -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();

View File

@ -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,

View File

@ -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<TransparentShader, core::matrix4, core::matrix4>, public TextureRead<Trilinear_Anisotropic_Filtered>
{
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) \

View File

@ -33,8 +33,6 @@ TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE typ
{
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 +239,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 +257,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))

View File

@ -29,7 +29,6 @@ enum TransparentMaterial
{
TM_DEFAULT,
TM_ADDITIVE,
TM_BUBBLE,
TM_DISPLACEMENT,
TM_COUNT
};
@ -187,9 +186,6 @@ class ListDisplacement : public MiscList<ListDisplacement, GLMesh *, core::matri
class ListInstancedGlow : public Singleton<ListInstancedGlow>, public std::vector<GLMesh *>
{};
// Forward pass (for transparents meshes)
void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
MeshMaterial MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE, video::E_VERTEX_TYPE, Material* material);
TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE, f32 MaterialTypeParam, Material* material);

View File

@ -432,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;
}
}

View File

@ -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;

View File

@ -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,

View File

@ -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
}