Merge remote-tracking branch 'origin/master' into nw
This commit is contained in:
@@ -46,12 +46,6 @@ if(USE_GLES2)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_OGLES2_ -DNO_IRR_COMPILE_WITH_SOFTWARE_ -DNO_IRR_COMPILE_WITH_BURNINGSVIDEO_ -DNO_IRR_COMPILE_WITH_OGLES1_ -DNO_IRR_COMPILE_WITH_OPENGL_ -DNO_IRR_USE_NON_SYSTEM_JPEG_LIB_ -DNO_IRR_USE_NON_SYSTEM_LIB_PNG_ -DNO_IRR_USE_NON_SYSTEM_ZLIB_)
|
||||
endif()
|
||||
|
||||
# Xrandr
|
||||
if(UNIX AND NOT APPLE)
|
||||
add_definitions(-DNO_IRR_LINUX_X11_VIDMODE_)
|
||||
add_definitions(-D_IRR_LINUX_X11_RANDR_)
|
||||
endif()
|
||||
|
||||
if(CYGWIN)
|
||||
add_definitions(-DNO_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
|
||||
endif()
|
||||
@@ -187,6 +181,7 @@ source/Irrlicht/CZipReader.cpp
|
||||
source/Irrlicht/Irrlicht.cpp
|
||||
source/Irrlicht/irrXML.cpp
|
||||
source/Irrlicht/os.cpp
|
||||
source/Irrlicht/COpenGLNormalMapRenderer.cpp
|
||||
source/Irrlicht/BuiltInFont.h
|
||||
source/Irrlicht/CAnimatedMeshSceneNode.h
|
||||
source/Irrlicht/CAttributeImpl.h
|
||||
@@ -339,6 +334,7 @@ source/Irrlicht/S4DVertex.h
|
||||
source/Irrlicht/SoftwareDriver2_compile_config.h
|
||||
source/Irrlicht/SoftwareDriver2_helper.h
|
||||
source/Irrlicht/wglext.h
|
||||
source/Irrlicht/COpenGLNormalMapRenderer.h
|
||||
|
||||
include/aabbox3d.h
|
||||
include/CDynamicMeshBuffer.h
|
||||
|
||||
@@ -95,6 +95,8 @@ public:
|
||||
\param s String of symbols which are not send down to the videodriver
|
||||
*/
|
||||
virtual void setInvisibleCharacters( const wchar_t *s ) = 0;
|
||||
|
||||
virtual u32 addLazyLoadCharacters(const wchar_t *s) { return 0; }
|
||||
};
|
||||
|
||||
} // end namespace gui
|
||||
|
||||
@@ -119,10 +119,8 @@
|
||||
|
||||
#if !defined(_IRR_WINDOWS_API_) && !defined(_IRR_OSX_PLATFORM_) && !defined(_IRR_ANDROID_PLATFORM_)
|
||||
#ifndef _IRR_SOLARIS_PLATFORM_
|
||||
#if !defined(__linux__) && !defined(__FreeBSD__)
|
||||
#define _IRR_LINUX_PLATFORM_
|
||||
#endif
|
||||
#endif
|
||||
#define _IRR_POSIX_API_
|
||||
#define _IRR_COMPILE_WITH_X11_DEVICE_
|
||||
#endif
|
||||
@@ -232,8 +230,8 @@ define out. */
|
||||
//! to remove the dependencies such that Irrlicht will compile on those systems, too.
|
||||
//! If you don't need colored cursors you can also disable the Xcursor extension
|
||||
#if defined(_IRR_LINUX_PLATFORM_) && defined(_IRR_COMPILE_WITH_X11_)
|
||||
#define _IRR_LINUX_X11_VIDMODE_
|
||||
//#define _IRR_LINUX_X11_RANDR_
|
||||
//#define _IRR_LINUX_X11_VIDMODE_
|
||||
#define _IRR_LINUX_X11_RANDR_
|
||||
#ifdef NO_IRR_LINUX_X11_VIDMODE_
|
||||
#undef _IRR_LINUX_X11_VIDMODE_
|
||||
#endif
|
||||
|
||||
@@ -700,17 +700,20 @@ namespace video
|
||||
//! normal map lookup 32 bit version
|
||||
inline f32 nml32(int x, int y, int pitch, int height, s32 *p) const
|
||||
{
|
||||
if (x < 0) x = pitch-1; if (x >= pitch) x = 0;
|
||||
if (y < 0) y = height-1; if (y >= height) y = 0;
|
||||
if (x < 0) x = pitch-1;
|
||||
if (x >= pitch) x = 0;
|
||||
if (y < 0) y = height-1;
|
||||
if (y >= height) y = 0;
|
||||
return (f32)(((p[(y * pitch) + x])>>16) & 0xff);
|
||||
}
|
||||
|
||||
//! normal map lookup 16 bit version
|
||||
inline f32 nml16(int x, int y, int pitch, int height, s16 *p) const
|
||||
{
|
||||
if (x < 0) x = pitch-1; if (x >= pitch) x = 0;
|
||||
if (y < 0) y = height-1; if (y >= height) y = 0;
|
||||
|
||||
if (x < 0) x = pitch-1;
|
||||
if (x >= pitch) x = 0;
|
||||
if (y < 0) y = height-1;
|
||||
if (y >= height) y = 0;
|
||||
return (f32) getAverage ( p[(y * pitch) + x] );
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ extern bool GLContextDebugBit;
|
||||
#include "COpenGLMaterialRenderer.h"
|
||||
#include "COpenGLShaderMaterialRenderer.h"
|
||||
#include "COpenGLSLMaterialRenderer.h"
|
||||
#include "COpenGLNormalMapRenderer.h"
|
||||
#include "COpenGLParallaxMapRenderer.h"
|
||||
#include "os.h"
|
||||
|
||||
@@ -29,7 +30,7 @@ namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
bool useCoreContext;
|
||||
bool useCoreContext;
|
||||
// -----------------------------------------------------------------------
|
||||
// WINDOWS CONSTRUCTOR
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -85,107 +86,107 @@ static PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs_ARB;
|
||||
|
||||
static HGLRC getMeAGLContext(HDC HDc, bool force_legacy_context)
|
||||
{
|
||||
if (!force_legacy_context)
|
||||
{
|
||||
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_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
if (!force_legacy_context)
|
||||
{
|
||||
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_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
|
||||
int ctx44[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
int ctx44[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
|
||||
hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx44debug : ctx44);
|
||||
if (hrc)
|
||||
return hrc;
|
||||
hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx44debug : ctx44);
|
||||
if (hrc)
|
||||
return hrc;
|
||||
|
||||
int ctx40debug[] =
|
||||
{
|
||||
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_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
int ctx40debug[] =
|
||||
{
|
||||
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_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
|
||||
int ctx40[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 0,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
int ctx40[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 0,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
|
||||
hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx40debug : ctx40);
|
||||
if (hrc)
|
||||
return hrc;
|
||||
hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx40debug : ctx40);
|
||||
if (hrc)
|
||||
return hrc;
|
||||
|
||||
int ctx33debug[] =
|
||||
{
|
||||
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_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
int ctx33debug[] =
|
||||
{
|
||||
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_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
|
||||
int ctx33[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
int ctx33[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
|
||||
hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx33debug : ctx33);
|
||||
if (hrc)
|
||||
return hrc;
|
||||
hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx33debug : ctx33);
|
||||
if (hrc)
|
||||
return hrc;
|
||||
|
||||
int ctx31debug[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
|
||||
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
int ctx31debug[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
|
||||
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
|
||||
int ctx31[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
int ctx31[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
|
||||
hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx31debug : ctx31);
|
||||
if (hrc)
|
||||
return hrc;
|
||||
} // if (!force_legacy_context)
|
||||
hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx31debug : ctx31);
|
||||
if (hrc)
|
||||
return hrc;
|
||||
} // if (!force_legacy_context)
|
||||
|
||||
useCoreContext = false;
|
||||
int legacyctx[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 2,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
|
||||
0
|
||||
};
|
||||
HGLRC hrc = wglCreateContextAttribs_ARB(HDc, 0, legacyctx);
|
||||
if (hrc)
|
||||
return hrc;
|
||||
useCoreContext = false;
|
||||
int legacyctx[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 2,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
|
||||
0
|
||||
};
|
||||
HGLRC hrc = wglCreateContextAttribs_ARB(HDc, 0, legacyctx);
|
||||
if (hrc)
|
||||
return hrc;
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//! inits the open gl driver
|
||||
@@ -513,8 +514,8 @@ bool COpenGLDriver::initDriver(CIrrDeviceWin32* device)
|
||||
#ifdef WGL_ARB_create_context
|
||||
if (wglCreateContextAttribs_ARB)
|
||||
{
|
||||
hrc = getMeAGLContext(HDc, Params.ForceLegacyDevice);
|
||||
}
|
||||
hrc = getMeAGLContext(HDc, Params.ForceLegacyDevice);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
hrc=wglCreateContext(HDc);
|
||||
@@ -797,11 +798,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] && !useCoreContext)
|
||||
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);
|
||||
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]);
|
||||
@@ -820,8 +821,8 @@ bool COpenGLDriver::genericDriverInit()
|
||||
// glEnable(GL_RESCALE_NORMAL_EXT);
|
||||
|
||||
glClearDepth(1.0);
|
||||
if (!useCoreContext)
|
||||
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);
|
||||
@@ -837,8 +838,8 @@ bool COpenGLDriver::genericDriverInit()
|
||||
// set the renderstates
|
||||
setRenderStates3DMode();
|
||||
|
||||
if (!useCoreContext)
|
||||
glAlphaFunc(GL_GREATER, 0.f);
|
||||
if (!useCoreContext)
|
||||
glAlphaFunc(GL_GREATER, 0.f);
|
||||
|
||||
// set fog mode
|
||||
setFog(FogColor, FogType, FogStart, FogEnd, FogDensity, PixelFog, RangeFog);
|
||||
@@ -885,6 +886,15 @@ void COpenGLDriver::createMaterialRenderers()
|
||||
// add normal map renderers
|
||||
s32 tmp = 0;
|
||||
video::IMaterialRenderer* renderer = 0;
|
||||
if (!useCoreContext)
|
||||
{
|
||||
renderer = new COpenGLNormalMapRenderer(this, tmp, MaterialRenderers[EMT_SOLID].Renderer);
|
||||
renderer->drop();
|
||||
renderer = new COpenGLNormalMapRenderer(this, tmp, MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer);
|
||||
renderer->drop();
|
||||
renderer = new COpenGLNormalMapRenderer(this, tmp, MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer);
|
||||
renderer->drop();
|
||||
}
|
||||
|
||||
// add parallax map renderers
|
||||
renderer = new COpenGLParallaxMapRenderer(this, tmp, MaterialRenderers[EMT_SOLID].Renderer);
|
||||
@@ -1025,29 +1035,31 @@ 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);
|
||||
if (!useCoreContext)
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
// first load the viewing transformation for user clip planes
|
||||
if (!useCoreContext)
|
||||
glLoadMatrixf((Matrices[ETS_VIEW]).pointer());
|
||||
if (!useCoreContext)
|
||||
glLoadMatrixf((Matrices[ETS_VIEW]).pointer());
|
||||
|
||||
// we have to update the clip planes to the latest view matrix
|
||||
for (u32 i=0; i<MaxUserClipPlanes; ++i)
|
||||
{
|
||||
if (UserClipPlanes[i].Enabled)
|
||||
uploadClipPlane(i);
|
||||
}
|
||||
|
||||
// now the real model-view matrix
|
||||
if (!useCoreContext)
|
||||
glMultMatrixf(Matrices[ETS_WORLD].pointer());
|
||||
if (!useCoreContext)
|
||||
glMultMatrixf(Matrices[ETS_WORLD].pointer());
|
||||
}
|
||||
break;
|
||||
case ETS_PROJECTION:
|
||||
{
|
||||
if (!useCoreContext)
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
if (!useCoreContext)
|
||||
glLoadMatrixf(mat.pointer());
|
||||
if (!useCoreContext)
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
if (!useCoreContext)
|
||||
glLoadMatrixf(mat.pointer());
|
||||
}
|
||||
break;
|
||||
case ETS_COUNT:
|
||||
@@ -1063,9 +1075,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() && !useCoreContext)
|
||||
if (!useCoreContext)
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
if (!isRTT && mat.isIdentity() && !useCoreContext)
|
||||
glLoadIdentity();
|
||||
else
|
||||
{
|
||||
@@ -1074,8 +1086,8 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri
|
||||
getGLTextureMatrix(glmat, mat * TextureFlipMatrix);
|
||||
else
|
||||
getGLTextureMatrix(glmat, mat);
|
||||
if (!useCoreContext)
|
||||
glLoadMatrixf(glmat);
|
||||
if (!useCoreContext)
|
||||
glLoadMatrixf(glmat);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1846,8 +1858,8 @@ void COpenGLDriver::draw2DVertexPrimitiveList(const void* vertices, u32 vertexCo
|
||||
if (!primitiveCount || !vertexCount)
|
||||
return;
|
||||
|
||||
if (useCoreContext)
|
||||
return;
|
||||
if (useCoreContext)
|
||||
return;
|
||||
|
||||
if (!checkPrimitiveCount(primitiveCount))
|
||||
return;
|
||||
@@ -2526,23 +2538,23 @@ bool COpenGLDriver::setActiveTexture(u32 stage, const video::ITexture* texture)
|
||||
|
||||
if (!texture)
|
||||
{
|
||||
if (!useCoreContext)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
if (!useCoreContext)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (texture->getDriverType() != EDT_OPENGL)
|
||||
{
|
||||
if (!useCoreContext)
|
||||
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;
|
||||
}
|
||||
|
||||
if (!useCoreContext)
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
if (!useCoreContext)
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D,
|
||||
static_cast<const COpenGLTexture*>(texture)->getOpenGLTextureName());
|
||||
}
|
||||
@@ -2658,20 +2670,20 @@ void COpenGLDriver::setRenderStates3DMode()
|
||||
{
|
||||
// Reset Texture Stages
|
||||
glDisable(GL_BLEND);
|
||||
if (!useCoreContext)
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
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_MODELVIEW);
|
||||
if (!useCoreContext)
|
||||
glLoadMatrixf((Matrices[ETS_VIEW] * Matrices[ETS_WORLD]).pointer());
|
||||
|
||||
if (!useCoreContext)
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
if (!useCoreContext)
|
||||
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
|
||||
@@ -2838,27 +2850,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);
|
||||
if (!useCoreContext)
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
||||
break;
|
||||
case ECM_AMBIENT:
|
||||
if (!useCoreContext)
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT);
|
||||
if (!useCoreContext)
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT);
|
||||
break;
|
||||
case ECM_EMISSIVE:
|
||||
if (!useCoreContext)
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION);
|
||||
if (!useCoreContext)
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION);
|
||||
break;
|
||||
case ECM_SPECULAR:
|
||||
if (!useCoreContext)
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_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);
|
||||
if (!useCoreContext)
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
||||
break;
|
||||
}
|
||||
if (material.ColorMaterial != ECM_NONE && !useCoreContext)
|
||||
if (material.ColorMaterial != ECM_NONE && !useCoreContext)
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
}
|
||||
|
||||
@@ -2879,8 +2891,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;
|
||||
if (!useCoreContext)
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color);
|
||||
if (!useCoreContext)
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color);
|
||||
}
|
||||
|
||||
if ((material.ColorMaterial != video::ECM_DIFFUSE) &&
|
||||
@@ -2890,8 +2902,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;
|
||||
if (!useCoreContext)
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color);
|
||||
if (!useCoreContext)
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color);
|
||||
}
|
||||
|
||||
if (material.ColorMaterial != video::ECM_EMISSIVE)
|
||||
@@ -2900,8 +2912,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;
|
||||
if (!useCoreContext)
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color);
|
||||
if (!useCoreContext)
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2913,14 +2925,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);
|
||||
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] && !useCoreContext)
|
||||
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;
|
||||
@@ -2929,11 +2941,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] && !useCoreContext)
|
||||
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);
|
||||
if (!useCoreContext)
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color);
|
||||
}
|
||||
|
||||
// Texture filter
|
||||
@@ -2987,18 +2999,18 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
|
||||
// shademode
|
||||
if (resetAllRenderStates || (lastmaterial.GouraudShading != material.GouraudShading))
|
||||
{
|
||||
if (material.GouraudShading && !useCoreContext)
|
||||
if (material.GouraudShading && !useCoreContext)
|
||||
glShadeModel(GL_SMOOTH);
|
||||
else if (!useCoreContext)
|
||||
else if (!useCoreContext)
|
||||
glShadeModel(GL_FLAT);
|
||||
}
|
||||
|
||||
// lighting
|
||||
if (resetAllRenderStates || (lastmaterial.Lighting != material.Lighting))
|
||||
{
|
||||
if (material.Lighting && !useCoreContext)
|
||||
if (material.Lighting && !useCoreContext)
|
||||
glEnable(GL_LIGHTING);
|
||||
else if (!useCoreContext)
|
||||
else if (!useCoreContext)
|
||||
glDisable(GL_LIGHTING);
|
||||
}
|
||||
|
||||
@@ -3079,18 +3091,18 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
|
||||
// fog
|
||||
if (resetAllRenderStates || lastmaterial.FogEnable != material.FogEnable)
|
||||
{
|
||||
if (material.FogEnable && !useCoreContext)
|
||||
if (material.FogEnable && !useCoreContext)
|
||||
glEnable(GL_FOG);
|
||||
else if (!useCoreContext)
|
||||
else if (!useCoreContext)
|
||||
glDisable(GL_FOG);
|
||||
}
|
||||
|
||||
// normalization
|
||||
if (resetAllRenderStates || lastmaterial.NormalizeNormals != material.NormalizeNormals)
|
||||
{
|
||||
if (material.NormalizeNormals && !useCoreContext)
|
||||
if (material.NormalizeNormals && !useCoreContext)
|
||||
glEnable(GL_NORMALIZE);
|
||||
else if (!useCoreContext)
|
||||
else if (!useCoreContext)
|
||||
glDisable(GL_NORMALIZE);
|
||||
}
|
||||
|
||||
@@ -3470,9 +3482,11 @@ 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);
|
||||
if (!useCoreContext)
|
||||
{
|
||||
for (s32 i=0; i<MaxLights; ++i)
|
||||
glDisable(GL_LIGHT0 + i);
|
||||
}
|
||||
|
||||
RequestedLights.clear();
|
||||
|
||||
@@ -3645,8 +3659,8 @@ 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);
|
||||
if (!useCoreContext)
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, data);
|
||||
}
|
||||
|
||||
|
||||
@@ -3877,42 +3891,42 @@ 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));
|
||||
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] && !useCoreContext)
|
||||
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 && !useCoreContext)
|
||||
if (rangeFog && !useCoreContext)
|
||||
glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV);
|
||||
else if (!useCoreContext)
|
||||
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);
|
||||
if (!useCoreContext)
|
||||
glFogf(GL_FOG_START, start);
|
||||
if (!useCoreContext)
|
||||
glFogf(GL_FOG_END, end);
|
||||
}
|
||||
else if (!useCoreContext)
|
||||
else if (!useCoreContext)
|
||||
glFogf(GL_FOG_DENSITY, density);
|
||||
|
||||
if (pixelFog && !useCoreContext)
|
||||
if (pixelFog && !useCoreContext)
|
||||
glHint(GL_FOG_HINT, GL_NICEST);
|
||||
else if (!useCoreContext)
|
||||
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);
|
||||
if (!useCoreContext)
|
||||
glFogfv(GL_FOG_COLOR, data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
291
lib/irrlicht/source/Irrlicht/COpenGLNormalMapRenderer.cpp
Normal file
291
lib/irrlicht/source/Irrlicht/COpenGLNormalMapRenderer.cpp
Normal file
@@ -0,0 +1,291 @@
|
||||
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
|
||||
#include "COpenGLNormalMapRenderer.h"
|
||||
#include "IGPUProgrammingServices.h"
|
||||
#include "IShaderConstantSetCallBack.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "os.h"
|
||||
#include "COpenGLDriver.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
// Irrlicht Engine OpenGL render path normal map vertex shader
|
||||
// I guess it could be optimized a lot, because I wrote it in D3D ASM and
|
||||
// transferred it 1:1 to OpenGL
|
||||
const char OPENGL_NORMAL_MAP_VSH[] =
|
||||
"!!ARBvp1.0\n"\
|
||||
"#input\n"\
|
||||
"# 0-3: transposed world matrix;\n"\
|
||||
"#;12: Light01 position \n"\
|
||||
"#;13: x,y,z: Light01 color; .w: 1/LightRadius^2 \n"\
|
||||
"#;14: Light02 position \n"\
|
||||
"#;15: x,y,z: Light02 color; .w: 1/LightRadius^2 \n"\
|
||||
"\n"\
|
||||
"ATTRIB InPos = vertex.position;\n"\
|
||||
"ATTRIB InColor = vertex.color;\n"\
|
||||
"ATTRIB InNormal = vertex.normal;\n"\
|
||||
"ATTRIB InTexCoord = vertex.texcoord[0];\n"\
|
||||
"ATTRIB InTangent = vertex.texcoord[1];\n"\
|
||||
"ATTRIB InBinormal = vertex.texcoord[2];\n"\
|
||||
"\n"\
|
||||
"#output\n"\
|
||||
"OUTPUT OutPos = result.position;\n"\
|
||||
"OUTPUT OutLightColor1 = result.color.primary;\n"\
|
||||
"OUTPUT OutLightColor2 = result.color.secondary;\n"\
|
||||
"OUTPUT OutTexCoord = result.texcoord[0];\n"\
|
||||
"OUTPUT OutLightVector1 = result.texcoord[1];\n"\
|
||||
"OUTPUT OutLightVector2 = result.texcoord[2];\n"\
|
||||
"\n"\
|
||||
"PARAM MVP[4] = { state.matrix.mvp }; # modelViewProjection matrix.\n"\
|
||||
"TEMP Temp;\n"\
|
||||
"TEMP TempColor;\n"\
|
||||
"TEMP TempLightVector1;\n"\
|
||||
"TEMP TempLightVector2;\n"\
|
||||
"TEMP TempTransLightV1;\n"\
|
||||
"TEMP TempTransLightV2;\n"\
|
||||
"\n"\
|
||||
"# transform position to clip space \n"\
|
||||
"DP4 OutPos.x, MVP[0], InPos;\n"\
|
||||
"DP4 OutPos.y, MVP[1], InPos;\n"\
|
||||
"DP4 Temp.z, MVP[2], InPos;\n"\
|
||||
"DP4 OutPos.w, MVP[3], InPos;\n"\
|
||||
"MOV OutPos.z, Temp.z;\n"\
|
||||
"MOV result.fogcoord.x, Temp.z;\n"\
|
||||
"\n"\
|
||||
"# vertex - lightpositions \n"\
|
||||
"SUB TempLightVector1, program.local[12], InPos; \n"\
|
||||
"SUB TempLightVector2, program.local[14], InPos; \n"\
|
||||
"\n"\
|
||||
"# transform the light vector 1 with U, V, W \n"\
|
||||
"DP3 TempTransLightV1.x, InTangent, TempLightVector1; \n"\
|
||||
"DP3 TempTransLightV1.y, InBinormal, TempLightVector1; \n"\
|
||||
"DP3 TempTransLightV1.z, InNormal, TempLightVector1; \n"\
|
||||
"\n"\
|
||||
"# transform the light vector 2 with U, V, W \n"\
|
||||
"DP3 TempTransLightV2.x, InTangent, TempLightVector2; \n"\
|
||||
"DP3 TempTransLightV2.y, InBinormal, TempLightVector2; \n"\
|
||||
"DP3 TempTransLightV2.z, InNormal, TempLightVector2; \n"\
|
||||
"\n"\
|
||||
"# normalize light vector 1 \n"\
|
||||
"DP3 TempTransLightV1.w, TempTransLightV1, TempTransLightV1; \n"\
|
||||
"RSQ TempTransLightV1.w, TempTransLightV1.w; \n"\
|
||||
"MUL TempTransLightV1, TempTransLightV1, TempTransLightV1.w;\n"\
|
||||
"\n"\
|
||||
"# normalize light vector 2 \n"\
|
||||
"DP3 TempTransLightV2.w, TempTransLightV2, TempTransLightV2; \n"\
|
||||
"RSQ TempTransLightV2.w, TempTransLightV2.w; \n"\
|
||||
"MUL TempTransLightV2, TempTransLightV2, TempTransLightV2.w;\n"\
|
||||
"\n"\
|
||||
"\n"\
|
||||
"# move light vectors out\n"\
|
||||
"MAD OutLightVector1, TempTransLightV1, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\
|
||||
"MAD OutLightVector2, TempTransLightV2, {0.5,0.5,0.5,0.5}, {0.5,0.5,0.5,0.5}; \n"\
|
||||
"\n"\
|
||||
"# calculate attenuation of light 1\n"\
|
||||
"MOV TempLightVector1.w, {0,0,0,0}; \n"\
|
||||
"DP3 TempLightVector1.x, TempLightVector1, TempLightVector1; \n"\
|
||||
"MUL TempLightVector1.x, TempLightVector1.x, program.local[13].w; \n"\
|
||||
"RSQ TempLightVector1, TempLightVector1.x; \n"\
|
||||
"MUL OutLightColor1, TempLightVector1, program.local[13]; # resulting light color = lightcolor * attenuation \n"\
|
||||
"\n"\
|
||||
"# calculate attenuation of light 2\n"\
|
||||
"MOV TempLightVector2.w, {0,0,0,0}; \n"\
|
||||
"DP3 TempLightVector2.x, TempLightVector2, TempLightVector2; \n"\
|
||||
"MUL TempLightVector2.x, TempLightVector2.x, program.local[15].w; \n"\
|
||||
"RSQ TempLightVector2, TempLightVector2.x; \n"\
|
||||
"MUL OutLightColor2, TempLightVector2, program.local[15]; # resulting light color = lightcolor * attenuation \n"\
|
||||
"\n"\
|
||||
"# move out texture coordinates and original alpha value\n"\
|
||||
"MOV OutTexCoord, InTexCoord; \n"\
|
||||
"MOV OutLightColor1.w, InColor.w; \n"\
|
||||
"\n"\
|
||||
"END\n";
|
||||
|
||||
// Irrlicht Engine OpenGL render path normal map pixel shader
|
||||
// I guess it could be optimized a bit, because I wrote it in D3D ASM and
|
||||
// transfered it 1:1 to OpenGL
|
||||
const char OPENGL_NORMAL_MAP_PSH[] =
|
||||
"!!ARBfp1.0\n"\
|
||||
"#_IRR_FOG_MODE_\n"\
|
||||
"\n"\
|
||||
"#Input\n"\
|
||||
"ATTRIB inTexCoord = fragment.texcoord[0]; \n"\
|
||||
"ATTRIB light1Vector = fragment.texcoord[1]; \n"\
|
||||
"ATTRIB light2Vector = fragment.texcoord[2]; \n"\
|
||||
"ATTRIB light1Color = fragment.color.primary; \n"\
|
||||
"ATTRIB light2Color = fragment.color.secondary; \n"\
|
||||
"\n"\
|
||||
"#Output\n"\
|
||||
"OUTPUT outColor = result.color;\n"\
|
||||
"TEMP temp;\n"\
|
||||
"TEMP temp2;\n"\
|
||||
"TEMP colorMapColor;\n"\
|
||||
"TEMP normalMapColor;\n"\
|
||||
"\n"\
|
||||
"# fetch color and normal map; \n"\
|
||||
"TXP colorMapColor, inTexCoord, texture[0], 2D; \n"\
|
||||
"TXP normalMapColor, inTexCoord, texture[1], 2D; \n"\
|
||||
"\n"\
|
||||
"# calculate color of light1; \n"\
|
||||
"MAD normalMapColor, normalMapColor, {2,2,2,2}, {-1,-1,-1,-1}; \n"\
|
||||
"MAD temp, light1Vector, {2,2,2,2}, {-1,-1,-1,-1}; \n"\
|
||||
"DP3_SAT temp, normalMapColor, temp; \n"\
|
||||
"MUL temp, light1Color, temp; \n"\
|
||||
"\n"\
|
||||
"# calculate color of light2; \n"\
|
||||
"MAD temp2, light2Vector, {2,2,2,2}, {-1,-1,-1,-1}; \n"\
|
||||
"DP3_SAT temp2, normalMapColor, temp2; \n"\
|
||||
"MAD temp, light2Color, temp2, temp; \n"\
|
||||
"\n"\
|
||||
"# luminance * base color; \n"\
|
||||
"MUL outColor, temp, colorMapColor; \n"\
|
||||
"MOV outColor.a, light1Color.a; #write interpolated vertex alpha value\n"\
|
||||
"\n"\
|
||||
"END\n";
|
||||
|
||||
//! Constructor
|
||||
COpenGLNormalMapRenderer::COpenGLNormalMapRenderer(video::COpenGLDriver* driver,
|
||||
s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial)
|
||||
: COpenGLShaderMaterialRenderer(driver, 0, baseMaterial), CompiledShaders(true)
|
||||
{
|
||||
|
||||
#ifdef _DEBUG
|
||||
setDebugName("COpenGLNormalMapRenderer");
|
||||
#endif
|
||||
|
||||
// set this as callback. We could have done this in
|
||||
// the initialization list, but some compilers don't like it.
|
||||
|
||||
CallBack = this;
|
||||
|
||||
// basically, this thing simply compiles the hardcoded shaders if the
|
||||
// hardware is able to do them, otherwise it maps to the base material
|
||||
|
||||
if (!driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1) ||
|
||||
!driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1))
|
||||
{
|
||||
// this hardware is not able to do shaders. Fall back to
|
||||
// base material.
|
||||
outMaterialTypeNr = driver->addMaterialRenderer(this);
|
||||
return;
|
||||
}
|
||||
|
||||
// check if already compiled normal map shaders are there.
|
||||
|
||||
video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_NORMAL_MAP_SOLID);
|
||||
|
||||
if (renderer)
|
||||
{
|
||||
// use the already compiled shaders
|
||||
video::COpenGLNormalMapRenderer* nmr = reinterpret_cast<video::COpenGLNormalMapRenderer*>(renderer);
|
||||
CompiledShaders = false;
|
||||
|
||||
VertexShader = nmr->VertexShader;
|
||||
PixelShader = nmr->PixelShader;
|
||||
|
||||
outMaterialTypeNr = driver->addMaterialRenderer(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
// compile shaders on our own
|
||||
init(outMaterialTypeNr, OPENGL_NORMAL_MAP_VSH, OPENGL_NORMAL_MAP_PSH, EVT_TANGENTS);
|
||||
}
|
||||
|
||||
// fallback if compilation has failed
|
||||
if (-1==outMaterialTypeNr)
|
||||
outMaterialTypeNr = driver->addMaterialRenderer(this);
|
||||
}
|
||||
|
||||
|
||||
//! Destructor
|
||||
COpenGLNormalMapRenderer::~COpenGLNormalMapRenderer()
|
||||
{
|
||||
if (CallBack == this)
|
||||
CallBack = 0;
|
||||
|
||||
if (!CompiledShaders)
|
||||
{
|
||||
// prevent this from deleting shaders we did not create
|
||||
VertexShader = 0;
|
||||
PixelShader.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Returns the render capability of the material.
|
||||
s32 COpenGLNormalMapRenderer::getRenderCapability() const
|
||||
{
|
||||
if (Driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1) &&
|
||||
Driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//! Called by the engine when the vertex and/or pixel shader constants for an
|
||||
//! material renderer should be set.
|
||||
void COpenGLNormalMapRenderer::OnSetConstants(IMaterialRendererServices* services, s32 userData)
|
||||
{
|
||||
video::IVideoDriver* driver = services->getVideoDriver();
|
||||
|
||||
// set transposed world matrix
|
||||
const core::matrix4& tWorld = driver->getTransform(video::ETS_WORLD).getTransposed();
|
||||
services->setVertexShaderConstant(tWorld.pointer(), 0, 4);
|
||||
|
||||
// set transposed worldViewProj matrix
|
||||
core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION));
|
||||
worldViewProj *= driver->getTransform(video::ETS_VIEW);
|
||||
worldViewProj *= driver->getTransform(video::ETS_WORLD);
|
||||
core::matrix4 tr(worldViewProj.getTransposed());
|
||||
services->setVertexShaderConstant(tr.pointer(), 8, 4);
|
||||
|
||||
// here we fetch the fixed function lights from the driver
|
||||
// and set them as constants
|
||||
|
||||
u32 cnt = driver->getDynamicLightCount();
|
||||
|
||||
// Load the inverse world matrix.
|
||||
core::matrix4 invWorldMat;
|
||||
driver->getTransform(video::ETS_WORLD).getInverse(invWorldMat);
|
||||
|
||||
for (u32 i=0; i<2; ++i)
|
||||
{
|
||||
video::SLight light;
|
||||
|
||||
if (i<cnt)
|
||||
light = driver->getDynamicLight(i);
|
||||
else
|
||||
{
|
||||
light.DiffuseColor.set(0,0,0); // make light dark
|
||||
light.Radius = 1.0f;
|
||||
}
|
||||
|
||||
light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation
|
||||
|
||||
// Transform the light by the inverse world matrix to get it into object space.
|
||||
invWorldMat.transformVect(light.Position);
|
||||
|
||||
services->setVertexShaderConstant(
|
||||
reinterpret_cast<const f32*>(&light.Position), 12+(i*2), 1);
|
||||
|
||||
services->setVertexShaderConstant(
|
||||
reinterpret_cast<const f32*>(&light.DiffuseColor), 13+(i*2), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
49
lib/irrlicht/source/Irrlicht/COpenGLNormalMapRenderer.h
Normal file
49
lib/irrlicht/source/Irrlicht/COpenGLNormalMapRenderer.h
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_OPENGL_NORMAL_MAP_RENDERER_H_INCLUDED__
|
||||
#define __C_OPENGL_NORMAL_MAP_RENDERER_H_INCLUDED__
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
|
||||
#include "COpenGLShaderMaterialRenderer.h"
|
||||
#include "IShaderConstantSetCallBack.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
//! Class for rendering normal maps with OpenGL
|
||||
class COpenGLNormalMapRenderer : public COpenGLShaderMaterialRenderer, public IShaderConstantSetCallBack
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
COpenGLNormalMapRenderer(video::COpenGLDriver* driver,
|
||||
s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial);
|
||||
|
||||
//! Destructor
|
||||
~COpenGLNormalMapRenderer();
|
||||
|
||||
//! Called by the engine when the vertex and/or pixel shader constants for an
|
||||
//! material renderer should be set.
|
||||
virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData);
|
||||
|
||||
//! Returns the render capability of the material.
|
||||
virtual s32 getRenderCapability() const;
|
||||
|
||||
protected:
|
||||
|
||||
bool CompiledShaders;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -114,10 +114,12 @@ CBillboardTextSceneNode::CBillboardTextSceneNode(ISceneNode* parent, ISceneManag
|
||||
{
|
||||
Font = (gui::IGUIFontBitmap*)font;
|
||||
Font->grab();
|
||||
u32 texture_count = Font->addLazyLoadCharacters(text);
|
||||
_IRR_DEBUG_BREAK_IF(texture_count==0);
|
||||
|
||||
// mesh with one buffer per texture
|
||||
Mesh = new SMesh();
|
||||
for (u32 i=0; i<Font->getSpriteBank()->getTextureCount(); ++i)
|
||||
for (u32 i=0; i<texture_count; ++i)
|
||||
{
|
||||
SMeshBuffer *mb = new SMeshBuffer();
|
||||
mb->Material = Material;
|
||||
|
||||
@@ -400,13 +400,13 @@ namespace UserConfigParams
|
||||
"Enable multitouch support.") );
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_multitouch_deadzone_center
|
||||
PARAM_DEFAULT( FloatUserConfigParam(0.15f, "multitouch_deadzone_center",
|
||||
PARAM_DEFAULT( FloatUserConfigParam(0.1f, "multitouch_deadzone_center",
|
||||
&m_multitouch_group,
|
||||
"A parameter in range [0, 0.5] that determines the zone that is "
|
||||
"considered as centered in steering button."));
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_multitouch_deadzone_edge
|
||||
PARAM_DEFAULT( FloatUserConfigParam(0.15f, "multitouch_deadzone_edge",
|
||||
PARAM_DEFAULT( FloatUserConfigParam(0.25f, "multitouch_deadzone_edge",
|
||||
&m_multitouch_group,
|
||||
"A parameter in range [0, 0.5] that determines the zone that is "
|
||||
"considered as max value in steering button."));
|
||||
|
||||
@@ -29,8 +29,6 @@ class FaceTTF;
|
||||
class DigitFace : public FontWithFace
|
||||
{
|
||||
private:
|
||||
virtual bool supportLazyLoadChar() const OVERRIDE { return false; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual unsigned int getGlyphPageSize() const OVERRIDE { return 256; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual float getScalingFactorOne() const OVERRIDE { return 0.7f; }
|
||||
@@ -45,6 +43,8 @@ public:
|
||||
virtual void init() OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void reset() OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual bool supportLazyLoadChar() const OVERRIDE { return false; }
|
||||
|
||||
}; // DigitFace
|
||||
|
||||
|
||||
@@ -92,39 +92,6 @@ protected:
|
||||
/** Used in top side bearing calculation. */
|
||||
int m_glyph_max_height;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Check characters to see if they are loaded in font, if not load them.
|
||||
* For font that doesn't need lazy loading, nothing will be done.
|
||||
* \param in_ptr Characters to check.
|
||||
* \param first_load If true, it will ignore \ref supportLazyLoadChar,
|
||||
* which is called in \ref reset. */
|
||||
void insertCharacters(const wchar_t* in_ptr, bool first_load = false)
|
||||
{
|
||||
if (!supportLazyLoadChar() && !first_load) return;
|
||||
|
||||
for (const wchar_t* p = in_ptr; *p; ++p)
|
||||
{
|
||||
if (*p == L'\r' || *p == L'\n' || *p < (wchar_t)32)
|
||||
continue;
|
||||
if (!loadedChar(*p))
|
||||
{
|
||||
loadGlyphInfo(*p);
|
||||
if (supportChar(*p))
|
||||
addLazyLoadChar(*p);
|
||||
else if (m_fallback_font != NULL)
|
||||
{
|
||||
if (!m_fallback_font->loadedChar(*p))
|
||||
{
|
||||
m_fallback_font->loadGlyphInfo(*p);
|
||||
if (m_fallback_font->supportChar(*p))
|
||||
m_fallback_font->addLazyLoadChar(*p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
void updateCharactersList();
|
||||
// ------------------------------------------------------------------------
|
||||
/** Set the fallback font for this font, so if some character is missing in
|
||||
* this font, it will use that fallback font to try rendering it.
|
||||
@@ -239,8 +206,6 @@ private:
|
||||
// ------------------------------------------------------------------------
|
||||
void loadGlyphInfo(wchar_t c);
|
||||
// ------------------------------------------------------------------------
|
||||
void createNewGlyphPage();
|
||||
// ------------------------------------------------------------------------
|
||||
/** Add a character into \ref m_new_char_holder for lazy loading later. */
|
||||
void addLazyLoadChar(wchar_t c) { m_new_char_holder.insert(c); }
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -248,9 +213,6 @@ private:
|
||||
// ------------------------------------------------------------------------
|
||||
void setDPI();
|
||||
// ------------------------------------------------------------------------
|
||||
/** Override it if sub-class should not do lazy loading characters. */
|
||||
virtual bool supportLazyLoadChar() const { return true; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Defined by sub-class about the texture size of glyph page, it should be
|
||||
* a power of two. */
|
||||
virtual unsigned int getGlyphPageSize() const = 0;
|
||||
@@ -304,6 +266,44 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Return the dpi of this face. */
|
||||
unsigned int getDPI() const { return m_face_dpi; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Override it if sub-class should not do lazy loading characters. */
|
||||
virtual bool supportLazyLoadChar() const { return true; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Check characters to see if they are loaded in font, if not load them.
|
||||
* For font that doesn't need lazy loading, nothing will be done.
|
||||
* \param in_ptr Characters to check.
|
||||
* \param first_load If true, it will ignore \ref supportLazyLoadChar,
|
||||
* which is called in \ref reset. */
|
||||
void insertCharacters(const wchar_t* in_ptr, bool first_load = false)
|
||||
{
|
||||
if (!supportLazyLoadChar() && !first_load) return;
|
||||
|
||||
for (const wchar_t* p = in_ptr; *p; ++p)
|
||||
{
|
||||
if (*p == L'\r' || *p == L'\n' || *p < (wchar_t)32)
|
||||
continue;
|
||||
if (!loadedChar(*p))
|
||||
{
|
||||
loadGlyphInfo(*p);
|
||||
if (supportChar(*p))
|
||||
addLazyLoadChar(*p);
|
||||
else if (m_fallback_font != NULL)
|
||||
{
|
||||
if (!m_fallback_font->loadedChar(*p))
|
||||
{
|
||||
m_fallback_font->loadGlyphInfo(*p);
|
||||
if (m_fallback_font->supportChar(*p))
|
||||
m_fallback_font->addLazyLoadChar(*p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
void updateCharactersList();
|
||||
// ------------------------------------------------------------------------
|
||||
void createNewGlyphPage();
|
||||
|
||||
}; // FontWithFace
|
||||
|
||||
|
||||
@@ -50,8 +50,9 @@ void DrawCalls::clearLists()
|
||||
{
|
||||
ListBlendTransparent::getInstance()->clear();
|
||||
ListAdditiveTransparent::getInstance()->clear();
|
||||
ListGhostKart::getInstance()->clear();
|
||||
ListGhostKartTangents::getInstance()->clear();
|
||||
ListTranslucentStandard::getInstance()->clear();
|
||||
ListTranslucentTangents::getInstance()->clear();
|
||||
ListTranslucent2TCoords::getInstance()->clear();
|
||||
ListBlendTransparentFog::getInstance()->clear();
|
||||
ListAdditiveTransparentFog::getInstance()->clear();
|
||||
ListDisplacement::getInstance()->clear();
|
||||
@@ -175,10 +176,12 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
|
||||
custom_alpha = y > 128.0f ? 0.5f : 0.35f;
|
||||
}
|
||||
|
||||
for (GLMesh *mesh : node->TransparentMesh[TM_GHOST_KART])
|
||||
pushVector(ListGhostKart::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->TextureMatrix, custom_alpha);
|
||||
for (GLMesh *mesh : node->TransparentMesh[TM_GHOST_KART_TANGENTS])
|
||||
pushVector(ListGhostKartTangents::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->TextureMatrix, custom_alpha);
|
||||
for (GLMesh *mesh : node->TransparentMesh[TM_TRANSLUCENT_STD])
|
||||
pushVector(ListTranslucentStandard::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->TextureMatrix, custom_alpha);
|
||||
for (GLMesh *mesh : node->TransparentMesh[TM_TRANSLUCENT_TAN])
|
||||
pushVector(ListTranslucentTangents::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->TextureMatrix, custom_alpha);
|
||||
for (GLMesh *mesh : node->TransparentMesh[TM_TRANSLUCENT_2TC])
|
||||
pushVector(ListTranslucent2TCoords::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->TextureMatrix, custom_alpha);
|
||||
for (GLMesh *mesh : node->TransparentMesh[TM_DISPLACEMENT])
|
||||
pushVector(ListDisplacement::getInstance(), mesh, Node->getAbsoluteTransformation());
|
||||
|
||||
|
||||
@@ -250,11 +250,15 @@ void AbstractGeometryPasses::renderTransparent(const DrawCalls& draw_calls,
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
renderTransparenPass<Shaders::TransparentShader, video::EVT_STANDARD, 3, 2, 1>(
|
||||
TexUnits(RenderGeometry::TexUnit(0, true)),
|
||||
ListGhostKart::getInstance());
|
||||
ListTranslucentStandard::getInstance());
|
||||
|
||||
renderTransparenPass<Shaders::TransparentShader, video::EVT_TANGENTS, 3, 2, 1>(
|
||||
TexUnits(RenderGeometry::TexUnit(0, true)),
|
||||
ListGhostKartTangents::getInstance());
|
||||
ListTranslucentTangents::getInstance());
|
||||
|
||||
renderTransparenPass<Shaders::TransparentShader, video::EVT_2TCOORDS, 3, 2, 1>(
|
||||
TexUnits(RenderGeometry::TexUnit(0, true)),
|
||||
ListTranslucent2TCoords::getInstance());
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
@@ -2196,9 +2196,11 @@ scene::ISceneNode *IrrDriver::addLight(const core::vector3df &pos,
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_scene_manager
|
||||
scene::ILightSceneNode* light = m_scene_manager
|
||||
->addLightSceneNode(m_scene_manager->getRootSceneNode(),
|
||||
pos, video::SColorf(1.0f, r, g, b));
|
||||
light->setRadius(radius);
|
||||
return light;
|
||||
}
|
||||
} // addLight
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "graphics/camera.hpp"
|
||||
#include "graphics/central_settings.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/lod_node.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
@@ -253,6 +254,14 @@ void LODNode::OnRegisterSceneNode()
|
||||
|
||||
m_previous_visibility = (shown ? WAS_SHOWN : WAS_HIDDEN);
|
||||
m_last_tick = now;
|
||||
if (!CVS->isGLSL())
|
||||
{
|
||||
for (core::list<ISceneNode*>::Iterator it = Children.begin();
|
||||
it != Children.end(); it++)
|
||||
{
|
||||
(*it)->updateAbsolutePosition();
|
||||
}
|
||||
}
|
||||
|
||||
scene::ISceneNode::OnRegisterSceneNode();
|
||||
}
|
||||
|
||||
@@ -427,9 +427,18 @@ int ParticleEmitter::getCreationRate()
|
||||
*/
|
||||
void ParticleEmitter::setPosition(const Vec3 &pos)
|
||||
{
|
||||
m_node->setPosition(pos.toIrrVector());
|
||||
m_node->setPosition(pos.toIrrVector());
|
||||
} // setPosition
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Sets the rotation of the particle emitter.
|
||||
* \param pos The rotation for the particle emitter.
|
||||
*/
|
||||
void ParticleEmitter::setRotation(const Vec3 &rot)
|
||||
{
|
||||
m_node->setRotation(rot.toIrrVector());
|
||||
} // setRotation
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ParticleEmitter::clearParticles()
|
||||
@@ -512,14 +521,6 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
|
||||
m_node->setMaterialTexture(0, material->getTexture());
|
||||
|
||||
mat0.ZWriteEnable = !material->isTransparent(); // disable z-buffer writes if material is transparent
|
||||
|
||||
// fallback for old render engine
|
||||
if (material->getShaderType() == Material::SHADERTYPE_ADDITIVE)
|
||||
mat0.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
|
||||
else if (material->getShaderType() == Material::SHADERTYPE_ALPHA_BLEND)
|
||||
mat0.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
else if (material->getShaderType() == Material::SHADERTYPE_ALPHA_TEST)
|
||||
mat0.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -94,6 +94,7 @@ public:
|
||||
int getCreationRate();
|
||||
|
||||
void setPosition(const Vec3 &pos);
|
||||
void setRotation(const Vec3 &rot);
|
||||
|
||||
const ParticleKind* getParticlesInfo() const { return m_particle_type; }
|
||||
|
||||
|
||||
@@ -170,9 +170,9 @@ void STKAnimatedMesh::updateNoGL()
|
||||
else if (mesh.m_render_info != NULL && mesh.m_render_info->isTransparent())
|
||||
{
|
||||
if (mesh.VAOType == video::EVT_TANGENTS)
|
||||
TransparentMesh[TM_GHOST_KART_TANGENTS].push_back(&mesh);
|
||||
TransparentMesh[TM_TRANSLUCENT_TAN].push_back(&mesh);
|
||||
else
|
||||
TransparentMesh[TM_GHOST_KART].push_back(&mesh);
|
||||
TransparentMesh[TM_TRANSLUCENT_STD].push_back(&mesh);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -57,7 +57,12 @@ TransparentMaterial getTransparentMaterialFromType(video::E_MATERIAL_TYPE type,
|
||||
Material* material)
|
||||
{
|
||||
if (type == Shaders::getShader(ES_DISPLACE))
|
||||
return TM_DISPLACEMENT;
|
||||
{
|
||||
if (CVS->isDefferedEnabled())
|
||||
return TM_DISPLACEMENT;
|
||||
else
|
||||
return TM_TRANSLUCENT_2TC;
|
||||
}
|
||||
if (material->getShaderType() == Material::SHADERTYPE_ADDITIVE)
|
||||
return TM_ADDITIVE;
|
||||
return TM_DEFAULT;
|
||||
|
||||
@@ -37,8 +37,9 @@ enum TransparentMaterial
|
||||
TM_DEFAULT,
|
||||
TM_ADDITIVE,
|
||||
TM_DISPLACEMENT,
|
||||
TM_GHOST_KART,
|
||||
TM_GHOST_KART_TANGENTS,
|
||||
TM_TRANSLUCENT_STD,
|
||||
TM_TRANSLUCENT_TAN,
|
||||
TM_TRANSLUCENT_2TC,
|
||||
TM_COUNT
|
||||
}; // TransparentMaterial
|
||||
|
||||
@@ -169,13 +170,19 @@ class ListAdditiveTransparent : public MiscList<ListAdditiveTransparent,
|
||||
{};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class ListGhostKart : public MiscList<ListGhostKart,
|
||||
class ListTranslucentStandard : public MiscList<ListTranslucentStandard,
|
||||
GLMesh *, core::matrix4,
|
||||
core::matrix4, float>
|
||||
{};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class ListGhostKartTangents : public MiscList<ListGhostKartTangents,
|
||||
class ListTranslucentTangents : public MiscList<ListTranslucentTangents,
|
||||
GLMesh *, core::matrix4,
|
||||
core::matrix4, float>
|
||||
{};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class ListTranslucent2TCoords : public MiscList<ListTranslucent2TCoords,
|
||||
GLMesh *, core::matrix4,
|
||||
core::matrix4, float>
|
||||
{};
|
||||
|
||||
@@ -209,9 +209,9 @@ void STKMeshSceneNode::updateNoGL()
|
||||
{
|
||||
assert(!immediate_draw);
|
||||
if (mesh.VAOType == video::EVT_TANGENTS)
|
||||
TransparentMesh[TM_GHOST_KART_TANGENTS].push_back(&mesh);
|
||||
TransparentMesh[TM_TRANSLUCENT_TAN].push_back(&mesh);
|
||||
else
|
||||
TransparentMesh[TM_GHOST_KART].push_back(&mesh);
|
||||
TransparentMesh[TM_TRANSLUCENT_STD].push_back(&mesh);
|
||||
}
|
||||
else if (rnd->isTransparent())
|
||||
{
|
||||
|
||||
@@ -125,5 +125,33 @@ u32 ScalableFont::getSpriteNoFromChar(const wchar_t *c) const
|
||||
return area.spriteno;
|
||||
} // getSpriteNoFromChar
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
u32 ScalableFont::addLazyLoadCharacters(const wchar_t *c)
|
||||
{
|
||||
IGUISpriteBank* sp = m_face->getSpriteBank();
|
||||
u32 tex_count = sp->getTextureCount();
|
||||
if (!m_face->supportLazyLoadChar()) return tex_count;
|
||||
|
||||
m_face->insertCharacters(c);
|
||||
m_face->updateCharactersList();
|
||||
|
||||
// Make sure text of billboard wasn't located in the last texture
|
||||
for (const wchar_t p = *c; *c; c++)
|
||||
{
|
||||
const core::array<SGUISprite>& s = sp->getSprites();
|
||||
const FontWithFace::FontArea& area =
|
||||
m_face->getAreaFromCharacter(p, NULL/*fallback_font*/);
|
||||
u32 cur_tex_no = s[area.spriteno].Frames[0].textureNumber;
|
||||
if (cur_tex_no == (tex_count -1))
|
||||
{
|
||||
m_face->createNewGlyphPage();
|
||||
return tex_count;
|
||||
}
|
||||
}
|
||||
|
||||
return tex_count -1;
|
||||
|
||||
} // addLazyLoadCharacters
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
@@ -86,6 +86,8 @@ public:
|
||||
/** returns the sprite number from a given character */
|
||||
virtual u32 getSpriteNoFromChar(const wchar_t *c) const;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual u32 addLazyLoadCharacters(const wchar_t *s);
|
||||
// ------------------------------------------------------------------------
|
||||
// Below is not used:
|
||||
/** set an Pixel Offset on Drawing ( scale position on width ) */
|
||||
virtual void setKerningWidth (s32 kerning) {}
|
||||
|
||||
@@ -104,7 +104,7 @@ CGUIEditBox::~CGUIEditBox()
|
||||
|
||||
if (Operator)
|
||||
Operator->drop();
|
||||
#ifdef _IRR_COMPILE_WITH_X11_
|
||||
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
|
||||
CIrrDeviceLinux* dl = dynamic_cast<CIrrDeviceLinux*>(irr_driver->getDevice());
|
||||
dl->setIMEEnable(false);
|
||||
#endif
|
||||
@@ -248,12 +248,12 @@ bool CGUIEditBox::OnEvent(const SEvent& event)
|
||||
MouseMarking = false;
|
||||
setTextMarkers(0,0);
|
||||
}
|
||||
#ifdef _IRR_COMPILE_WITH_X11_
|
||||
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
|
||||
CIrrDeviceLinux* dl = dynamic_cast<CIrrDeviceLinux*>(irr_driver->getDevice());
|
||||
dl->setIMEEnable(false);
|
||||
#endif
|
||||
}
|
||||
#ifdef _IRR_COMPILE_WITH_X11_
|
||||
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
|
||||
else if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUSED)
|
||||
{
|
||||
CIrrDeviceLinux* dl = dynamic_cast<CIrrDeviceLinux*>(irr_driver->getDevice());
|
||||
@@ -872,7 +872,7 @@ bool CGUIEditBox::processIMEEvent(const SEvent& event)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_)
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
//! calculate the position of input composition window
|
||||
core::position2di CGUIEditBox::calculateICPos()
|
||||
{
|
||||
@@ -1609,7 +1609,7 @@ void CGUIEditBox::calculateScrollPos()
|
||||
VScrollPos = 0;
|
||||
|
||||
// todo: adjust scrollbar
|
||||
#if defined(_IRR_COMPILE_WITH_X11_)
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
CIrrDeviceLinux* dl = dynamic_cast<CIrrDeviceLinux*>(irr_driver->getDevice());
|
||||
if (dl)
|
||||
{
|
||||
|
||||
@@ -140,7 +140,7 @@ using namespace gui;
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
|
||||
bool processIMEEvent(const SEvent& event);
|
||||
#endif
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_)
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
//! calculates the input composition position
|
||||
core::position2di calculateICPos();
|
||||
#endif
|
||||
|
||||
@@ -182,7 +182,6 @@ void MultitouchDevice::updateDeviceState(unsigned int event_id)
|
||||
button->event_id = 0;
|
||||
button->axis_x = 0.0f;
|
||||
button->axis_y = 0.0f;
|
||||
update_controls = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -211,10 +210,11 @@ void MultitouchDevice::updateDeviceState(unsigned int event_id)
|
||||
update_controls = true;
|
||||
}
|
||||
}
|
||||
else if (prev_button_state != button->pressed)
|
||||
{
|
||||
update_controls = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (prev_button_state != button->pressed)
|
||||
{
|
||||
update_controls = true;
|
||||
}
|
||||
|
||||
if (update_controls)
|
||||
@@ -225,6 +225,21 @@ void MultitouchDevice::updateDeviceState(unsigned int event_id)
|
||||
}
|
||||
} // updateDeviceState
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Helper function that returns a steering factor for steering button.
|
||||
* \param value The axis value from 0 to 1.
|
||||
*/
|
||||
float MultitouchDevice::getSteeringFactor(float value)
|
||||
{
|
||||
if (m_deadzone_edge + m_deadzone_center >= 1.0f)
|
||||
return 1.0f;
|
||||
|
||||
assert(m_deadzone_edge + m_deadzone_center != 1.0f);
|
||||
|
||||
return std::min((value - m_deadzone_center) / (1.0f - m_deadzone_edge -
|
||||
m_deadzone_center), 1.0f);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Sends proper action for player controller depending on the button type
|
||||
* and state.
|
||||
@@ -255,18 +270,14 @@ void MultitouchDevice::handleControls(MultitouchButton* button)
|
||||
|
||||
if (button->type == MultitouchButtonType::BUTTON_STEERING)
|
||||
{
|
||||
assert(m_deadzone_edge != 1.0f);
|
||||
|
||||
if (button->axis_y < -m_deadzone_center)
|
||||
{
|
||||
float factor = std::min(std::abs(button->axis_y) / (1 -
|
||||
m_deadzone_edge), 1.0f);
|
||||
float factor = getSteeringFactor(std::abs(button->axis_y));
|
||||
controller->action(PA_ACCEL, factor * Input::MAX_VALUE);
|
||||
}
|
||||
else if (button->axis_y > m_deadzone_center)
|
||||
{
|
||||
float factor = std::min(std::abs(button->axis_y) / (1 -
|
||||
m_deadzone_edge), 1.0f);
|
||||
float factor = getSteeringFactor(std::abs(button->axis_y));
|
||||
controller->action(PA_BRAKE, factor * Input::MAX_VALUE);
|
||||
}
|
||||
else
|
||||
@@ -277,14 +288,12 @@ void MultitouchDevice::handleControls(MultitouchButton* button)
|
||||
|
||||
if (button->axis_x < -m_deadzone_center)
|
||||
{
|
||||
float factor = std::min(std::abs(button->axis_x) / (1 -
|
||||
m_deadzone_edge), 1.0f);
|
||||
float factor = getSteeringFactor(std::abs(button->axis_x));
|
||||
controller->action(PA_STEER_LEFT, factor * Input::MAX_VALUE);
|
||||
}
|
||||
else if (button->axis_x > m_deadzone_center)
|
||||
{
|
||||
float factor = std::min(std::abs(button->axis_x) / (1 -
|
||||
m_deadzone_edge), 1.0f);
|
||||
float factor = getSteeringFactor(std::abs(button->axis_x));
|
||||
controller->action(PA_STEER_RIGHT, factor * Input::MAX_VALUE);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -77,6 +77,8 @@ private:
|
||||
/** The parameter that is used for steering button and determines dead area
|
||||
* at the edge of button */
|
||||
float m_deadzone_edge;
|
||||
|
||||
float getSteeringFactor(float value);
|
||||
|
||||
public:
|
||||
/** The array that contains data for all multitouch input events */
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/particle_emitter.hpp"
|
||||
#include "graphics/particle_kind.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "items/attachment.hpp"
|
||||
#include "items/item.hpp"
|
||||
@@ -39,6 +41,7 @@
|
||||
#include "network/race_event_manager.hpp"
|
||||
#include "race/history.hpp"
|
||||
#include "states_screens/race_gui_base.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
@@ -52,7 +55,7 @@
|
||||
*/
|
||||
LocalPlayerController::LocalPlayerController(AbstractKart *kart,
|
||||
StateManager::ActivePlayer *player)
|
||||
: PlayerController(kart)
|
||||
: PlayerController(kart), m_sky_particles_emitter(NULL)
|
||||
{
|
||||
m_player = player;
|
||||
if(player)
|
||||
@@ -67,6 +70,25 @@ LocalPlayerController::LocalPlayerController(AbstractKart *kart,
|
||||
m_ugh_sound = SFXManager::get()->createSoundSource("ugh");
|
||||
m_grab_sound = SFXManager::get()->createSoundSource("grab_collectable");
|
||||
m_full_sound = SFXManager::get()->createSoundSource("energy_bar_full");
|
||||
|
||||
// Attach Particle System
|
||||
Track *track = World::getWorld()->getTrack();
|
||||
if (UserConfigParams::m_weather_effects &&
|
||||
track->getSkyParticles() != NULL)
|
||||
{
|
||||
track->getSkyParticles()->setBoxSizeXZ(150.0f, 150.0f);
|
||||
|
||||
m_sky_particles_emitter =
|
||||
new ParticleEmitter(track->getSkyParticles(),
|
||||
core::vector3df(0.0f, 30.0f, 100.0f),
|
||||
m_kart->getNode(),
|
||||
true);
|
||||
|
||||
// FIXME: in multiplayer mode, this will result in several instances
|
||||
// of the heightmap being calculated and kept in memory
|
||||
m_sky_particles_emitter->addHeightMapAffector(track);
|
||||
}
|
||||
|
||||
} // LocalPlayerController
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -79,6 +101,8 @@ LocalPlayerController::~LocalPlayerController()
|
||||
m_ugh_sound ->deleteSFX();
|
||||
m_grab_sound->deleteSFX();
|
||||
m_full_sound->deleteSFX();
|
||||
if (m_sky_particles_emitter)
|
||||
delete m_sky_particles_emitter;
|
||||
} // ~LocalPlayerController
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -174,11 +198,23 @@ void LocalPlayerController::update(float dt)
|
||||
m_kart->getSpeed() < -UserConfigParams::m_reverse_look_threshold))
|
||||
{
|
||||
camera->setMode(Camera::CM_REVERSE);
|
||||
if (m_sky_particles_emitter)
|
||||
{
|
||||
m_sky_particles_emitter->setPosition(Vec3(0, 30, -100));
|
||||
m_sky_particles_emitter->setRotation(Vec3(0, 180, 0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (camera->getMode() == Camera::CM_REVERSE)
|
||||
{
|
||||
camera->setMode(Camera::CM_NORMAL);
|
||||
if (m_sky_particles_emitter)
|
||||
{
|
||||
m_sky_particles_emitter->setPosition(Vec3(0, 30, 100));
|
||||
m_sky_particles_emitter->setRotation(Vec3(0, 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "karts/controller/player_controller.hpp"
|
||||
|
||||
class AbstractKart;
|
||||
class Player;
|
||||
class ParticleEmitter;
|
||||
class SFXBase;
|
||||
|
||||
/** PlayerKart manages control events from the player and moves
|
||||
@@ -41,6 +41,7 @@ private:
|
||||
|
||||
bool m_sound_schedule;
|
||||
|
||||
ParticleEmitter* m_sky_particles_emitter;
|
||||
|
||||
/** The index of the camera attached to the kart for this controller. The
|
||||
* camera object is managed in the Camera class, so no need to free it. */
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
#include "graphics/particle_emitter.hpp"
|
||||
#include "graphics/particle_kind.hpp"
|
||||
#include "graphics/particle_kind_manager.hpp"
|
||||
#include "graphics/render_info.hpp"
|
||||
#include "graphics/shadow.hpp"
|
||||
@@ -137,7 +136,6 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
|
||||
m_controller = NULL;
|
||||
m_saved_controller = NULL;
|
||||
m_flying = false;
|
||||
m_sky_particles_emitter= NULL;
|
||||
m_stars_effect = NULL;
|
||||
m_is_jumping = false;
|
||||
m_min_nitro_time = 0.0f;
|
||||
@@ -261,7 +259,6 @@ Kart::~Kart()
|
||||
if(m_previous_terrain_sound) m_previous_terrain_sound->deleteSFX();
|
||||
if(m_collision_particles) delete m_collision_particles;
|
||||
if(m_slipstream) delete m_slipstream;
|
||||
if(m_sky_particles_emitter) delete m_sky_particles_emitter;
|
||||
if(m_attachment) delete m_attachment;
|
||||
if(m_stars_effect) delete m_stars_effect;
|
||||
|
||||
@@ -2536,28 +2533,6 @@ void Kart::loadData(RaceManager::KartType type, bool is_animated_model)
|
||||
m_attachment = new Attachment(this);
|
||||
createPhysics();
|
||||
|
||||
// Attach Particle System
|
||||
|
||||
Track *track = World::getWorld()->getTrack();
|
||||
if (type == RaceManager::KT_PLAYER &&
|
||||
UserConfigParams::m_weather_effects &&
|
||||
track->getSkyParticles() != NULL)
|
||||
{
|
||||
track->getSkyParticles()->setBoxSizeXZ(150.0f, 150.0f);
|
||||
|
||||
m_sky_particles_emitter =
|
||||
new ParticleEmitter(track->getSkyParticles(),
|
||||
core::vector3df(0.0f, 30.0f, 100.0f),
|
||||
getNode(),
|
||||
true);
|
||||
|
||||
// FIXME: in multiplayer mode, this will result in several instances
|
||||
// of the heightmap being calculated and kept in memory
|
||||
m_sky_particles_emitter->addHeightMapAffector(track);
|
||||
}
|
||||
|
||||
Vec3 position(0, getKartHeight()*0.35f, -getKartLength()*0.35f);
|
||||
|
||||
m_slipstream = new SlipStream(this);
|
||||
|
||||
if (m_kart_properties->getSkidEnabled())
|
||||
@@ -2833,7 +2808,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
|
||||
{
|
||||
const bool emergency = getKartAnimation() != NULL;
|
||||
m_shadow->update(isOnGround() && !emergency,
|
||||
m_terrain_info->getHoT() - getXYZ().getY()
|
||||
getTrans().inverse()(m_terrain_info->getHitPoint()).getY()
|
||||
- m_skidding->getGraphicalJumpOffset()
|
||||
- m_graphical_y_offset
|
||||
- m_kart_model->getLowestPoint());
|
||||
|
||||
@@ -178,8 +178,6 @@ protected:
|
||||
/** The shadow of a kart. */
|
||||
Shadow *m_shadow;
|
||||
|
||||
ParticleEmitter *m_sky_particles_emitter;
|
||||
|
||||
/** All particle effects. */
|
||||
KartGFX *m_kart_gfx;
|
||||
|
||||
|
||||
@@ -53,7 +53,8 @@ KartGFX::KartGFX(const AbstractKart *kart)
|
||||
// Create nitro light
|
||||
core::vector3df location(0.0f, 0.5f, -0.5f*length - 0.05f);
|
||||
m_nitro_light = irr_driver->addLight(location, /*force*/ 0.4f,
|
||||
/*radius*/5.0f, 0.0f, 0.4f, 1.0f,
|
||||
/*radius*/CVS->isGLSL() ? 5.0f : 1.0f,
|
||||
0.0f, 0.4f, 1.0f,
|
||||
false, node);
|
||||
m_nitro_light->setVisible(false);
|
||||
#ifdef DEBUG
|
||||
@@ -65,7 +66,8 @@ KartGFX::KartGFX(const AbstractKart *kart)
|
||||
// For the first skidding level
|
||||
m_skidding_light_1 =
|
||||
irr_driver->addLight(core::vector3df(0.0f, 0.1f, -0.5f*length - 0.05f),
|
||||
/* force */ 0.3f, /* radius */ 3.0f,
|
||||
/* force */ 0.3f,
|
||||
/*radius*/CVS->isGLSL() ? 3.0f : 1.0f,
|
||||
1.0f, 0.6f, 0.0f, false, node);
|
||||
m_skidding_light_1->setVisible(false);
|
||||
m_skidding_light_1->setName( ("skidding emitter 1 (" + m_kart->getIdent()
|
||||
@@ -74,7 +76,8 @@ KartGFX::KartGFX(const AbstractKart *kart)
|
||||
// For the second skidding level
|
||||
m_skidding_light_2 =
|
||||
irr_driver->addLight(core::vector3df(0.0f, 0.1f, -0.5f*length - 0.05f),
|
||||
/* force */0.4f, /*radius*/ 4.0f,
|
||||
/* force */0.4f,
|
||||
/*radius*/CVS->isGLSL() ? 4.0f : 1.0f,
|
||||
1.0f, 0.0f, 0.0f, false, node);
|
||||
m_skidding_light_2->setVisible(false);
|
||||
m_skidding_light_2->setName( ("skidding emitter 2 (" + m_kart->getIdent()
|
||||
|
||||
Reference in New Issue
Block a user