Commit 9d137cc7 authored by hybrid's avatar hybrid

Changed some OpenGL material renderer states. Removed the automatic mipmap...

Changed some OpenGL material renderer states. Removed the automatic mipmap generation after texture unlock for OpenGL to get the same as for d3d drivers.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@855 dfc29bdd-3216-0410-991c-e03cc46cb475
parent cbc0fcc3
...@@ -286,10 +286,13 @@ bool COpenGLDriver::genericDriverInit(const core::dimension2d<s32>& screenSize, ...@@ -286,10 +286,13 @@ bool COpenGLDriver::genericDriverInit(const core::dimension2d<s32>& screenSize,
glViewport(0, 0, screenSize.Width, screenSize.Height); // Reset The Current Viewport glViewport(0, 0, screenSize.Width, screenSize.Height); // Reset The Current Viewport
setAmbientLight(SColorf(0.0f,0.0f,0.0f,0.0f)); setAmbientLight(SColorf(0.0f,0.0f,0.0f,0.0f));
#ifdef GL_EXT_separate_specular_color #ifdef GL_EXT_separate_specular_color
if (SeparateSpecularColorExtension) if (FeatureAvailable[IRR_EXT_separate_specular_color])
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
#endif #endif
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
// This is a fast replacement for NORMALIZE_NORMALS
// if ((Version>101) || FeatureAvailable[IRR_EXT_rescale_normal])
// glEnable(GL_RESCALE_NORMAL_EXT);
glClearDepth(1.0); glClearDepth(1.0);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
...@@ -1269,7 +1272,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -1269,7 +1272,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
if (material.Shininess != 0.0f) if (material.Shininess != 0.0f)
{ {
#ifdef GL_EXT_separate_specular_color #ifdef GL_EXT_separate_specular_color
if (SeparateSpecularColorExtension) if (FeatureAvailable[IRR_EXT_separate_specular_color])
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
#endif #endif
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.Shininess); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.Shininess);
...@@ -1281,7 +1284,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -1281,7 +1284,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
} }
#ifdef GL_EXT_separate_specular_color #ifdef GL_EXT_separate_specular_color
else else
if (SeparateSpecularColorExtension) if (FeatureAvailable[IRR_EXT_separate_specular_color])
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
#endif #endif
......
...@@ -113,7 +113,6 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) ...@@ -113,7 +113,6 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
SeparateStencilExtension = FeatureAvailable[IRR_ATI_separate_stencil]; SeparateStencilExtension = FeatureAvailable[IRR_ATI_separate_stencil];
TextureCompressionExtension = FeatureAvailable[IRR_ARB_texture_compression]; TextureCompressionExtension = FeatureAvailable[IRR_ARB_texture_compression];
PackedDepthStencilExtension = FeatureAvailable[IRR_EXT_packed_depth_stencil]; PackedDepthStencilExtension = FeatureAvailable[IRR_EXT_packed_depth_stencil];
SeparateSpecularColorExtension = FeatureAvailable[IRR_EXT_separate_specular_color];
StencilBuffer=stencilBuffer; StencilBuffer=stencilBuffer;
#ifdef _IRR_WINDOWS_API_ #ifdef _IRR_WINDOWS_API_
......
...@@ -666,7 +666,6 @@ class COpenGLExtensionHandler ...@@ -666,7 +666,6 @@ class COpenGLExtensionHandler
bool SeparateStencilExtension; bool SeparateStencilExtension;
bool TextureCompressionExtension; bool TextureCompressionExtension;
bool PackedDepthStencilExtension; bool PackedDepthStencilExtension;
bool SeparateSpecularColorExtension;
// Some non-boolean properties // Some non-boolean properties
//! Maxmimum texture layers supported by the fixed pipeline //! Maxmimum texture layers supported by the fixed pipeline
......
...@@ -568,20 +568,11 @@ public: ...@@ -568,20 +568,11 @@ public:
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
}
else
{
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
} }
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
} }
} }
...@@ -598,7 +589,7 @@ public: ...@@ -598,7 +589,7 @@ public:
{ {
Driver->extGlActiveTexture(GL_TEXTURE0_ARB); Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // default value glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
} }
} }
}; };
...@@ -639,32 +630,31 @@ public: ...@@ -639,32 +630,31 @@ public:
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
} }
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_BLEND);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T); glEnable(GL_TEXTURE_GEN_T);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
glEnable(GL_BLEND);
} }
glDepthMask(GL_FALSE);
} }
virtual void OnUnsetMaterial() virtual void OnUnsetMaterial()
{ {
if (Driver->queryFeature(EVDF_MULTITEXTURE)) if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE1_ARB); Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
glDisable(GL_BLEND); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T); glDisable(GL_TEXTURE_GEN_T);
if (Driver->queryFeature(EVDF_MULTITEXTURE)) if (Driver->queryFeature(EVDF_MULTITEXTURE))
{ {
Driver->extGlActiveTexture(GL_TEXTURE0_ARB); Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // default value glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
} }
glDisable(GL_BLEND);
} }
//! Returns if the material is transparent. //! Returns if the material is transparent.
......
...@@ -224,7 +224,7 @@ void COpenGLTexture::getImageData(IImage* image) ...@@ -224,7 +224,7 @@ void COpenGLTexture::getImageData(IImage* image)
} }
core::dimension2d<s32> nImageSize; core::dimension2d<s32> nImageSize;
if (Driver && Driver->queryFeature(EVDF_TEXTURE_NPOT)) if (Driver->queryFeature(EVDF_TEXTURE_NPOT))
nImageSize=ImageSize; nImageSize=ImageSize;
else else
{ {
...@@ -272,41 +272,46 @@ void COpenGLTexture::copyTexture(bool newTexture) ...@@ -272,41 +272,46 @@ void COpenGLTexture::copyTexture(bool newTexture)
case ECF_A8R8G8B8: case ECF_A8R8G8B8:
InternalFormat=GL_RGBA; InternalFormat=GL_RGBA;
PixelFormat=GL_BGRA_EXT; PixelFormat=GL_BGRA_EXT;
PixelType=GL_UNSIGNED_INT_8_8_8_8_REV; if (reinterpret_cast<COpenGLDriver*>(Driver)->Version > 101)
PixelType=GL_UNSIGNED_INT_8_8_8_8_REV;
break; break;
default: default:
os::Printer::log("Unsupported texture format", ELL_ERROR); os::Printer::log("Unsupported texture format", ELL_ERROR);
break; break;
} }
#ifndef DISABLE_MIPMAPPING if (newTexture)
if (HasMipMaps && Driver && Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE))
{
// automatically generate and update mipmaps
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
AutomaticMipmapUpdate=true;
}
else
{
AutomaticMipmapUpdate=false;
regenerateMipMapLevels();
}
if (HasMipMaps) // might have changed in regenerateMipMapLevels
{
// enable bilinear mipmap filter
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
else
#else
HasMipMaps=false;
os::Printer::log("Did not create OpenGL texture mip maps.", ELL_ERROR);
#endif
{ {
// enable bilinear filter without mipmaps #ifndef DISABLE_MIPMAPPING
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); if (HasMipMaps && Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE))
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); {
// automatically generate and update mipmaps
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
AutomaticMipmapUpdate=true;
}
else
{
AutomaticMipmapUpdate=false;
regenerateMipMapLevels();
}
if (HasMipMaps) // might have changed in regenerateMipMapLevels
{
// enable bilinear mipmap filter
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
else
#else
HasMipMaps=false;
os::Printer::log("Did not create OpenGL texture mip maps.", ELL_ERROR);
#endif
{
// enable bilinear filter without mipmaps
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
} }
void* source = Image->lock(); void* source = Image->lock();
if (newTexture) if (newTexture)
glTexImage2D(GL_TEXTURE_2D, 0, InternalFormat, Image->getDimension().Width, glTexImage2D(GL_TEXTURE_2D, 0, InternalFormat, Image->getDimension().Width,
......
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