Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Marc Coll Carrillo 2014-09-28 09:27:09 +02:00
commit eaf6ee9556
34 changed files with 302 additions and 494 deletions

View File

@ -6,8 +6,8 @@
I18N="In the registration dialog" />
<spacer height="15" width="10"/>
<box proportion="1" width="100%" layout="vertical-row">
<div width="80%" align="center" layout="vertical-row" height="fit">
<box proportion="1" width="100%" height="100%" layout="vertical-row">
<div width="90%" align="center" layout="vertical-row" height="80%">
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" height="100%" text_align="left"
I18N="In the registration dialog" text="Local Username"/>
@ -15,7 +15,7 @@
</div>
<div width="100%" height="fit" layout="horizontal-row" >
<label id="label_online" proportion="1" height="100%" text_align="left"
I18N="In the login screen" text="Online"/>
I18N="In the login screen" text="Create online account"/>
<checkbox id="online" I18N="In the login screen" text_align="left"/>
</div>
@ -56,10 +56,11 @@
I18N="In the registration dialog" text="Confirm"/>
<textbox id="email_confirm" proportion="2" height="fit" I18N="In the registration dialog"/>
</div>
<spacer height="20" width="50"/>
<spacer height="30" width="50"/>
<label id="info" proportion="1" width="90%" align="center" text_align="center" word_wrap="true"
I18N="In the registration dialog" text="You don't need to register if you have a STK Addons account!"/>
<label id="info" height="20%" width="100%" align="center" text_align="center" word_wrap="true"
I18N="In the registration dialog"
text="You can play without creating an online account by unchecking the online checkbox, though then you can not connect to friends, vote for addons etc. You can also use an existing SuperTuxKart Addons account in the next screen if you already have one. Please read our privacy statement at http://privacy.supertuxkart.net"/>
<spacer height="20" width="50"/>

View File

@ -2,14 +2,14 @@
<stkgui>
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
<div x="2%" y="1%" width="96%" height="99%" layout="vertical-row" >
<div x="1%" y="1%" width="98%" height="96%" layout="vertical-row" >
<header width="80%" I18N="Section in track selection screen" text="Grand Prix"
align="center" text_align="center" />
<box width="100%" height="195" padding="0">
<scrollable_toolbar id="gps" height="175" y="10" x="10" width="98%" align="center" label_location="each"
square_items="true" child_width="160" child_height="120" />
square_items="true" child_width="175" child_height="120" />
</box>
<header width="100%" I18N="Section in track selection screen" text="All Tracks"

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,6 +328,28 @@ static GLboolean _glewStrSame3 (GLubyte** a, GLuint* na, const GLubyte* b, GLuin
*/
static GLboolean _glewSearchExtension (const char* name, const GLubyte *start, const GLubyte *end)
{
if (ext_hashset != NULL)
{
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;
@ -313,6 +359,7 @@ static GLboolean _glewSearchExtension (const char* name, const GLubyte *start, c
if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE;
p += n+1;
}
}
return GL_FALSE;
}
@ -10055,6 +10102,10 @@ 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;
@ -10115,8 +10166,38 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
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);
}
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,9 +796,10 @@ 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
if (!useCoreContext)
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
Params.HandleSRGB &= ((FeatureAvailable[IRR_ARB_framebuffer_sRGB] || FeatureAvailable[IRR_EXT_framebuffer_sRGB]) &&
@ -814,6 +817,7 @@ bool COpenGLDriver::genericDriverInit()
// glEnable(GL_RESCALE_NORMAL_EXT);
glClearDepth(1.0);
if (!useCoreContext)
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
@ -830,6 +834,7 @@ bool COpenGLDriver::genericDriverInit()
// set the renderstates
setRenderStates3DMode();
if (!useCoreContext)
glAlphaFunc(GL_GREATER, 0.f);
// set fog mode
@ -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.
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,12 +1045,15 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri
uploadClipPlane(i);
// now the real model-view matrix
if (!useCoreContext)
glMultMatrixf(Matrices[ETS_WORLD].pointer());
}
break;
case ETS_PROJECTION:
{
if (!useCoreContext)
glMatrixMode(GL_PROJECTION);
if (!useCoreContext)
glLoadMatrixf(mat.pointer());
}
break;
@ -1060,8 +1070,9 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri
if (MultiTextureExtension)
extGlActiveTexture(GL_TEXTURE0_ARB + i);
if (!useCoreContext)
glMatrixMode(GL_TEXTURE);
if (!isRTT && mat.isIdentity() )
if (!isRTT && mat.isIdentity() && !useCoreContext)
glLoadIdentity();
else
{
@ -1070,6 +1081,7 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri
getGLTextureMatrix(glmat, mat * TextureFlipMatrix);
else
getGLTextureMatrix(glmat, mat);
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,6 +2533,7 @@ bool COpenGLDriver::setActiveTexture(u32 stage, const video::ITexture* texture)
if (!texture)
{
if (!useCoreContext)
glDisable(GL_TEXTURE_2D);
return true;
}
@ -2525,12 +2541,14 @@ bool COpenGLDriver::setActiveTexture(u32 stage, const video::ITexture* texture)
{
if (texture->getDriverType() != EDT_OPENGL)
{
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;
}
if (!useCoreContext)
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,
static_cast<const COpenGLTexture*>(texture)->getOpenGLTextureName());
@ -2647,14 +2665,19 @@ void COpenGLDriver::setRenderStates3DMode()
{
// Reset Texture Stages
glDisable(GL_BLEND);
if (!useCoreContext)
glDisable(GL_ALPHA_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// switch back the matrices
if (!useCoreContext)
glMatrixMode(GL_MODELVIEW);
if (!useCoreContext)
glLoadMatrixf((Matrices[ETS_VIEW] * Matrices[ETS_WORLD]).pointer());
if (!useCoreContext)
glMatrixMode(GL_PROJECTION);
if (!useCoreContext)
glLoadMatrixf(Matrices[ETS_PROJECTION].pointer());
ResetRenderStates = true;
@ -2822,22 +2845,27 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
glDisable(GL_COLOR_MATERIAL);
break;
case ECM_DIFFUSE:
if (!useCoreContext)
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
break;
case ECM_AMBIENT:
if (!useCoreContext)
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT);
break;
case ECM_EMISSIVE:
if (!useCoreContext)
glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION);
break;
case ECM_SPECULAR:
if (!useCoreContext)
glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
break;
case ECM_DIFFUSE_AND_AMBIENT:
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,6 +2886,7 @@ 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;
if (!useCoreContext)
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color);
}
@ -2868,6 +2897,7 @@ 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;
if (!useCoreContext)
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color);
}
@ -2877,6 +2907,7 @@ 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;
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;
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,9 +2936,10 @@ 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
if (!useCoreContext)
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color);
}
@ -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,6 +3477,7 @@ const wchar_t* COpenGLDriver::getName() const
//! deletes all dynamic lights there are
void COpenGLDriver::deleteAllDynamicLights()
{
if (!useCoreContext)
for (s32 i=0; i<MaxLights; ++i)
glDisable(GL_LIGHT0 + i);
@ -3618,6 +3652,7 @@ u32 COpenGLDriver::getMaximalDynamicLightAmount() const
void COpenGLDriver::setAmbientLight(const SColorf& color)
{
GLfloat data[4] = {color.r, color.g, color.b, color.a};
if (!useCoreContext)
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, data);
}
@ -3849,37 +3884,41 @@ void COpenGLDriver::setFog(SColor c, E_FOG_TYPE fogType, f32 start,
{
CNullDriver::setFog(c, fogType, start, end, density, pixelFog, rangeFog);
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)
{
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};
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,6 +568,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
if (Version>102 || FeatureAvailable[IRR_ARB_multitexture])
{
#if defined(GL_MAX_TEXTURE_UNITS)
if (!useCoreContext)
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &num);
#elif defined(GL_MAX_TEXTURE_UNITS_ARB)
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &num);
@ -587,6 +588,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
MaxSupportedTextures=core::max_(MaxSupportedTextures,static_cast<u8>(num));
}
#endif
if (!useCoreContext)
glGetIntegerv(GL_MAX_LIGHTS, &num);
MaxLights=static_cast<u8>(num);
#ifdef GL_EXT_texture_filter_anisotropic
@ -621,6 +623,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
#endif
glGetIntegerv(GL_MAX_CLIP_PLANES, &num);
MaxUserClipPlanes=static_cast<u8>(num);
if (!useCoreContext)
glGetIntegerv(GL_AUX_BUFFERS, &num);
MaxAuxBuffers=static_cast<u8>(num);
#ifdef GL_ARB_draw_buffers
@ -641,6 +644,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
}
#endif
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine);
if (!useCoreContext)
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint);
glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, DimSmoothedLine);
glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, DimSmoothedPoint);

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,6 +50,7 @@ public:
{
// thanks to Murphy, the following line removed some
// bugs with several OpenGL implementations.
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,11 +350,11 @@ 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
else if (!useCoreContext)
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_DONT_CARE);
AutomaticMipmapUpdate=true;
@ -405,6 +405,7 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
if (!MipmapLegacyMode && AutomaticMipmapUpdate)
{
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

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

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

@ -4,6 +4,7 @@
#include <IMaterialRenderer.h>
#include <ISkinnedMesh.h>
#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);
}

View File

@ -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;
case Material::SHADERTYPE_ALPHA_TEST:
return MAT_ALPHA_REF;
case Material::SHADERTYPE_VEGETATION:
return MAT_GRASS;
case Material::SHADERTYPE_SPLATTING:
return MAT_SPLATTING;
case Material::SHADERTYPE_SOLID_UNLIT:
return MAT_UNLIT;
default:
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)
return MAT_ALPHA_REF;
else if (MaterialType == irr_driver->getShader(ES_GRASS) || MaterialType == irr_driver->getShader(ES_GRASS_REF))
return MAT_GRASS;
else if (MaterialType == irr_driver->getShader(ES_SPLATTING))
return MAT_SPLATTING;
else if (MaterialType == irr_driver->getShader(ES_OBJECT_UNLIT))
return MAT_UNLIT;
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))

View File

@ -10,6 +10,8 @@
#include <vector>
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<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);
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);

View File

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

View File

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

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

View File

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

View File

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

View File

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

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,6 +426,7 @@ void RaceGUIBase::renderPlayerView(const Camera *camera, float dt)
glviewport[3] = viewport.LowerRightCorner.Y;
//glGetIntegerv(GL_VIEWPORT, glviewport);
if (!irr::video::useCoreContext)
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
@ -433,6 +442,7 @@ void RaceGUIBase::renderPlayerView(const Camera *camera, float dt)
glVertex3d(glviewport[2],glviewport[3],0);
glVertex3d(glviewport[2],glviewport[1],0);
glEnd();
if (!irr::video::useCoreContext)
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
#endif

View File

@ -79,7 +79,6 @@ void RegisterScreen::init()
m_info_widget = getWidget<LabelWidget>("info");
assert(m_info_widget);
m_info_widget->setDefaultColor();
m_info_widget->setText("", false);
m_options_widget = getWidget<RibbonWidget>("options");
assert(m_options_widget);

View File

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

View File

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

View File

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