Commit 6c4a691d authored by hybrid's avatar hybrid

Removed unused parameter from win32 OpenGL setup. Separated wrap mode handling...

Removed unused parameter from win32 OpenGL setup. Separated wrap mode handling into new method in ogl driver. Fixed pixel alignment in ogl pixel transfers to avoid problems on special systems. Fixed an info message to be printed always, not just for big endian systems.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1453 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 89b96c66
...@@ -25,7 +25,7 @@ namespace irr ...@@ -25,7 +25,7 @@ namespace irr
{ {
#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_
IVideoDriver* createDirectX8Driver(const core::dimension2d<s32>& screenSize, HWND window, IVideoDriver* createDirectX8Driver(const core::dimension2d<s32>& screenSize, HWND window,
u32 bits, bool fullscreen, bool stencilbuffer, io::IFileSystem* io, u32 bits, bool stencilbuffer, io::IFileSystem* io,
bool pureSoftware, bool highPrecisionFPU, bool vsync, bool antiAlias); bool pureSoftware, bool highPrecisionFPU, bool vsync, bool antiAlias);
#endif #endif
...@@ -37,7 +37,7 @@ namespace irr ...@@ -37,7 +37,7 @@ namespace irr
#ifdef _IRR_COMPILE_WITH_OPENGL_ #ifdef _IRR_COMPILE_WITH_OPENGL_
IVideoDriver* createOpenGLDriver(const core::dimension2d<s32>& screenSize, HWND window, IVideoDriver* createOpenGLDriver(const core::dimension2d<s32>& screenSize, HWND window,
u32 bits, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, u32 bits, bool stencilBuffer, io::IFileSystem* io,
bool vsync, bool antiAlias); bool vsync, bool antiAlias);
#endif #endif
} }
...@@ -366,7 +366,7 @@ CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params) ...@@ -366,7 +366,7 @@ CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params)
HWnd = CreateWindow( ClassName, "", style, windowLeft, windowTop, HWnd = CreateWindow( ClassName, "", style, windowLeft, windowTop,
realWidth, realHeight, NULL, NULL, hInstance, NULL); realWidth, realHeight, NULL, NULL, hInstance, NULL);
ShowWindow(HWnd , SW_SHOW); ShowWindow(HWnd, SW_SHOW);
UpdateWindow(HWnd); UpdateWindow(HWnd);
// fix ugly ATI driver bugs. Thanks to ariaci // fix ugly ATI driver bugs. Thanks to ariaci
......
...@@ -106,13 +106,12 @@ void COctTreeSceneNode::render() ...@@ -106,13 +106,12 @@ void COctTreeSceneNode::render()
//transform the frustum to the current absolute transformation //transform the frustum to the current absolute transformation
core::matrix4 invTrans(AbsoluteTransformation); core::matrix4 invTrans(AbsoluteTransformation);
invTrans.makeInverse(); invTrans.makeInverse();
frust.transform(invTrans);
/* /*
//frust.transform(invTrans);
//const core::aabbox3d<float> &box = frust.getBoundingBox(); //const core::aabbox3d<float> &box = frust.getBoundingBox();
*/ */
frust.transform(invTrans);
switch(vertexType) switch(vertexType)
{ {
case video::EVT_STANDARD: case video::EVT_STANDARD:
......
...@@ -32,7 +32,7 @@ namespace video ...@@ -32,7 +32,7 @@ namespace video
#ifdef _IRR_USE_WINDOWS_DEVICE_ #ifdef _IRR_USE_WINDOWS_DEVICE_
//! Windows constructor and init code //! Windows constructor and init code
COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize,
HWND window, bool fullscreen, bool stencilBuffer, HWND window, bool stencilBuffer,
io::IFileSystem* io, bool antiAlias) io::IFileSystem* io, bool antiAlias)
: CNullDriver(io, screenSize), COpenGLExtensionHandler(), : CNullDriver(io, screenSize), COpenGLExtensionHandler(),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
...@@ -47,7 +47,7 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, ...@@ -47,7 +47,7 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize,
//! inits the open gl driver //! inits the open gl driver
bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize, bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize,
HWND window, u32 bits, bool fullscreen, bool vsync, bool stencilBuffer) HWND window, u32 bits, bool vsync, bool stencilBuffer)
{ {
PIXELFORMATDESCRIPTOR pfd = { PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
...@@ -321,6 +321,7 @@ bool COpenGLDriver::genericDriverInit(const core::dimension2d<s32>& screenSize, ...@@ -321,6 +321,7 @@ bool COpenGLDriver::genericDriverInit(const core::dimension2d<s32>& screenSize,
// We want to read the front buffer to get the latest render finished. // We want to read the front buffer to get the latest render finished.
glReadBuffer(GL_FRONT); glReadBuffer(GL_FRONT);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
// Reset The Current Viewport // Reset The Current Viewport
glViewport(0, 0, screenSize.Width, screenSize.Height); glViewport(0, 0, screenSize.Width, screenSize.Height);
...@@ -1606,6 +1607,85 @@ void COpenGLDriver::setRenderStates3DMode() ...@@ -1606,6 +1607,85 @@ void COpenGLDriver::setRenderStates3DMode()
} }
void COpenGLDriver::setWrapMode(const SMaterial& material)
{
// texture address mode
// Has to be checked always because it depends on the textures
for (u32 u=0; u<MaxTextureUnits; ++u)
{
if (MultiTextureExtension)
extGlActiveTexture(GL_TEXTURE0_ARB + u);
else if (u>0)
break; // stop loop
GLint mode=GL_REPEAT;
switch (material.TextureLayer[u].TextureWrap)
{
case ETC_REPEAT:
mode=GL_REPEAT;
break;
case ETC_CLAMP:
mode=GL_CLAMP;
break;
case ETC_CLAMP_TO_EDGE:
#ifdef GL_VERSION_1_2
if (Version>101)
mode=GL_CLAMP_TO_EDGE;
else
#endif
#ifdef GL_SGIS_texture_edge_clamp
if (FeatureAvailable[IRR_SGIS_texture_edge_clamp])
mode=GL_CLAMP_TO_EDGE_SGIS;
else
#endif
// fallback
mode=GL_CLAMP;
break;
case ETC_CLAMP_TO_BORDER:
#ifdef GL_VERSION_1_3
if (Version>102)
mode=GL_CLAMP_TO_BORDER;
else
#endif
#ifdef GL_ARB_texture_border_clamp
if (FeatureAvailable[IRR_ARB_texture_border_clamp])
mode=GL_CLAMP_TO_BORDER_ARB;
else
#endif
#ifdef GL_SGIS_texture_border_clamp
if (FeatureAvailable[IRR_SGIS_texture_border_clamp])
mode=GL_CLAMP_TO_BORDER_SGIS;
else
#endif
// fallback
mode=GL_CLAMP;
break;
case ETC_MIRROR:
#ifdef GL_VERSION_1_4
if (Version>103)
mode=GL_MIRRORED_REPEAT;
else
#endif
#ifdef GL_ARB_texture_border_clamp
if (FeatureAvailable[IRR_ARB_texture_mirrored_repeat])
mode=GL_MIRRORED_REPEAT_ARB;
else
#endif
#ifdef GL_IBM_texture_mirrored_repeat
if (FeatureAvailable[IRR_IBM_texture_mirrored_repeat])
mode=GL_MIRRORED_REPEAT_IBM;
else
#endif
mode=GL_REPEAT;
break;
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, mode);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, mode);
}
}
//! Can be called by an IMaterialRenderer to make its work easier. //! Can be called by an IMaterialRenderer to make its work easier.
void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,
bool resetAllRenderStates) bool resetAllRenderStates)
...@@ -1790,80 +1870,8 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -1790,80 +1870,8 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
glLineWidth(material.Thickness); glLineWidth(material.Thickness);
} }
// texture address mode setWrapMode(material);
// Has to be checked always because it depends on the textures
for (u32 u=0; u<MaxTextureUnits; ++u)
{
if (MultiTextureExtension)
extGlActiveTexture(GL_TEXTURE0_ARB + u);
else if (u>0)
break; // stop loop
GLint mode=GL_REPEAT;
switch (material.TextureLayer[u].TextureWrap)
{
case ETC_REPEAT:
mode=GL_REPEAT;
break;
case ETC_CLAMP:
mode=GL_CLAMP;
break;
case ETC_CLAMP_TO_EDGE:
#ifdef GL_VERSION_1_2
if (Version>101)
mode=GL_CLAMP_TO_EDGE;
else
#endif
#ifdef GL_SGIS_texture_edge_clamp
if (FeatureAvailable[IRR_SGIS_texture_edge_clamp])
mode=GL_CLAMP_TO_EDGE_SGIS;
else
#endif
// fallback
mode=GL_CLAMP;
break;
case ETC_CLAMP_TO_BORDER:
#ifdef GL_VERSION_1_3
if (Version>102)
mode=GL_CLAMP_TO_BORDER;
else
#endif
#ifdef GL_ARB_texture_border_clamp
if (FeatureAvailable[IRR_ARB_texture_border_clamp])
mode=GL_CLAMP_TO_BORDER_ARB;
else
#endif
#ifdef GL_SGIS_texture_border_clamp
if (FeatureAvailable[IRR_SGIS_texture_border_clamp])
mode=GL_CLAMP_TO_BORDER_SGIS;
else
#endif
// fallback
mode=GL_CLAMP;
break;
case ETC_MIRROR:
#ifdef GL_VERSION_1_4
if (Version>103)
mode=GL_MIRRORED_REPEAT;
else
#endif
#ifdef GL_ARB_texture_border_clamp
if (FeatureAvailable[IRR_ARB_texture_mirrored_repeat])
mode=GL_MIRRORED_REPEAT_ARB;
else
#endif
#ifdef GL_IBM_texture_mirrored_repeat
if (FeatureAvailable[IRR_IBM_texture_mirrored_repeat])
mode=GL_MIRRORED_REPEAT_IBM;
else
#endif
mode=GL_REPEAT;
break;
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, mode);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, mode);
}
// be sure to leave in texture stage 0 // be sure to leave in texture stage 0
if (MultiTextureExtension) if (MultiTextureExtension)
extGlActiveTexture(GL_TEXTURE0_ARB); extGlActiveTexture(GL_TEXTURE0_ARB);
...@@ -2715,11 +2723,11 @@ namespace video ...@@ -2715,11 +2723,11 @@ namespace video
// ----------------------------------- // -----------------------------------
#ifdef _IRR_USE_WINDOWS_DEVICE_ #ifdef _IRR_USE_WINDOWS_DEVICE_
IVideoDriver* createOpenGLDriver(const core::dimension2d<s32>& screenSize, IVideoDriver* createOpenGLDriver(const core::dimension2d<s32>& screenSize,
HWND window, u32 bits, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias) HWND window, u32 bits, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias)
{ {
#ifdef _IRR_COMPILE_WITH_OPENGL_ #ifdef _IRR_COMPILE_WITH_OPENGL_
COpenGLDriver* ogl = new COpenGLDriver(screenSize, window, fullscreen, stencilBuffer, io, antiAlias); COpenGLDriver* ogl = new COpenGLDriver(screenSize, window, stencilBuffer, io, antiAlias);
if (!ogl->initDriver(screenSize, window, bits, fullscreen, vsync, stencilBuffer)) if (!ogl->initDriver(screenSize, window, bits, vsync, stencilBuffer))
{ {
ogl->drop(); ogl->drop();
ogl = 0; ogl = 0;
......
...@@ -73,12 +73,12 @@ namespace video ...@@ -73,12 +73,12 @@ namespace video
#ifdef _IRR_WINDOWS_API_ #ifdef _IRR_WINDOWS_API_
//! win32 constructor //! win32 constructor
COpenGLDriver(const core::dimension2d<s32>& screenSize, HWND window, bool fullscreen, COpenGLDriver(const core::dimension2d<s32>& screenSize, HWND window,
bool stencilBuffer, io::IFileSystem* io, bool antiAlias); bool stencilBuffer, io::IFileSystem* io, bool antiAlias);
//! inits the windows specific parts of the open gl driver //! inits the windows specific parts of the open gl driver
bool initDriver(const core::dimension2d<s32>& screenSize, HWND window, bool initDriver(const core::dimension2d<s32>& screenSize, HWND window,
u32 bits, bool fullscreen, bool vsync, bool stencilBuffer); u32 bits, bool vsync, bool stencilBuffer);
#endif #endif
#if defined(_IRR_USE_LINUX_DEVICE_) || defined(_IRR_USE_SDL_DEVICE_) #if defined(_IRR_USE_LINUX_DEVICE_) || defined(_IRR_USE_SDL_DEVICE_)
...@@ -343,6 +343,9 @@ namespace video ...@@ -343,6 +343,9 @@ namespace video
inline void createGLMatrix(GLfloat gl_matrix[16], const core::matrix4& m); inline void createGLMatrix(GLfloat gl_matrix[16], const core::matrix4& m);
inline void createGLTextureMatrix(GLfloat gl_matrix[16], const core::matrix4& m); inline void createGLTextureMatrix(GLfloat gl_matrix[16], const core::matrix4& m);
//! Set GL pipeline to desired texture wrap modes of the material
void setWrapMode(const SMaterial& material);
//! sets the needed renderstates //! sets the needed renderstates
void setRenderStates3DMode(); void setRenderStates3DMode();
......
...@@ -187,13 +187,14 @@ void CQ3LevelMesh::loadTextures(tBSPLump* l, io::IReadFile* file) ...@@ -187,13 +187,14 @@ void CQ3LevelMesh::loadTextures(tBSPLump* l, io::IReadFile* file)
file->seek(l->offset); file->seek(l->offset);
file->read(Textures, l->length); file->read(Textures, l->length);
#ifdef __BIG_ENDIAN__ for (int i=0;i<NumTextures;++i)
for (int i=0;i<NumTextures;i++)
{ {
#ifdef __BIG_ENDIAN__
Textures[i].flags = os::Byteswap::byteswap(Textures[i].flags); Textures[i].flags = os::Byteswap::byteswap(Textures[i].flags);
Textures[i].contents = os::Byteswap::byteswap(Textures[i].contents); Textures[i].contents = os::Byteswap::byteswap(Textures[i].contents);
}
#endif #endif
os::Printer::log("Loaded texture", Textures[i].strName, ELL_INFORMATION);
}
} }
......
...@@ -587,7 +587,6 @@ ISceneNode* CSceneManager::addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* ...@@ -587,7 +587,6 @@ ISceneNode* CSceneManager::addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode*
} }
//! Adss a scene node for rendering using a octtree. This a good method for rendering //! Adss a scene node for rendering using a octtree. This a good method for rendering
//! scenes with lots of geometry. The Octree is built on the fly from the mesh, much //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much
//! faster then a bsp tree. //! faster then a bsp tree.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment