Commit 38a44116 authored by hybrid's avatar hybrid

Change the 2d material interface. Renamed methods and cleaned up reset scheme.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3031 dfc29bdd-3216-0410-991c-e03cc46cb475
parent c9c108ea
...@@ -1336,12 +1336,12 @@ namespace video ...@@ -1336,12 +1336,12 @@ namespace video
\return Material reference which should be altered to reflect \return Material reference which should be altered to reflect
the new settings. the new settings.
*/ */
virtual SMaterial& getInitMaterial2D() =0; virtual SMaterial& getMaterial2D() =0;
//! Enable the 2d override material //! Enable the 2d override material
/** \param enable Flag which tells whether the material shall be /** \param enable Flag which tells whether the material shall be
enabled or disabled. */ enabled or disabled. */
virtual void enableInitMaterial2D(bool enable=true) =0; virtual void enableMaterial2D(bool enable=true) =0;
//! Returns the graphics card vendor name. //! Returns the graphics card vendor name.
virtual core::stringc getVendorInfo() =0; virtual core::stringc getVendorInfo() =0;
......
...@@ -74,7 +74,7 @@ IImageWriter* createImageWriterPPM(); ...@@ -74,7 +74,7 @@ IImageWriter* createImageWriterPPM();
CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& screenSize) CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& screenSize)
: FileSystem(io), MeshManipulator(0), ViewPort(0,0,0,0), ScreenSize(screenSize), : FileSystem(io), MeshManipulator(0), ViewPort(0,0,0,0), ScreenSize(screenSize),
PrimitivesDrawn(0), MinVertexCountForVBO(500), TextureCreationFlags(0), PrimitivesDrawn(0), MinVertexCountForVBO(500), TextureCreationFlags(0),
InitMaterial2DEnabled(false), AllowZWriteOnTransparent(false) OverrideMaterial2DEnabled(false), AllowZWriteOnTransparent(false)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CNullDriver"); setDebugName("CNullDriver");
...@@ -161,6 +161,7 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& scre ...@@ -161,6 +161,7 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& scre
InitMaterial2D.TextureLayer[i].TextureWrapU=video::ETC_REPEAT; InitMaterial2D.TextureLayer[i].TextureWrapU=video::ETC_REPEAT;
InitMaterial2D.TextureLayer[i].TextureWrapV=video::ETC_REPEAT; InitMaterial2D.TextureLayer[i].TextureWrapV=video::ETC_REPEAT;
} }
OverrideMaterial2D=InitMaterial2D;
} }
...@@ -2165,16 +2166,16 @@ SOverrideMaterial& CNullDriver::getOverrideMaterial() ...@@ -2165,16 +2166,16 @@ SOverrideMaterial& CNullDriver::getOverrideMaterial()
//! Get the 2d override material for altering its values //! Get the 2d override material for altering its values
SMaterial& CNullDriver::getInitMaterial2D() SMaterial& CNullDriver::getMaterial2D()
{ {
return InitMaterial2D; return OverrideMaterial2D;
} }
//! Enable the 2d override material //! Enable the 2d override material
void CNullDriver::enableInitMaterial2D(bool enable) void CNullDriver::enableMaterial2D(bool enable)
{ {
InitMaterial2DEnabled=enable; OverrideMaterial2DEnabled=enable;
} }
......
...@@ -581,10 +581,10 @@ namespace video ...@@ -581,10 +581,10 @@ namespace video
virtual SOverrideMaterial& getOverrideMaterial(); virtual SOverrideMaterial& getOverrideMaterial();
//! Get the 2d override material for altering its values //! Get the 2d override material for altering its values
virtual SMaterial& getInitMaterial2D(); virtual SMaterial& getMaterial2D();
//! Enable the 2d override material //! Enable the 2d override material
virtual void enableInitMaterial2D(bool enable=true); virtual void enableMaterial2D(bool enable=true);
//! Only used by the engine internally. //! Only used by the engine internally.
virtual void setAllowZWriteOnTransparent(bool flag) virtual void setAllowZWriteOnTransparent(bool flag)
...@@ -708,8 +708,9 @@ namespace video ...@@ -708,8 +708,9 @@ namespace video
SExposedVideoData ExposedData; SExposedVideoData ExposedData;
SOverrideMaterial OverrideMaterial; SOverrideMaterial OverrideMaterial;
SMaterial OverrideMaterial2D;
SMaterial InitMaterial2D; SMaterial InitMaterial2D;
bool InitMaterial2DEnabled; bool OverrideMaterial2DEnabled;
E_FOG_TYPE FogType; E_FOG_TYPE FogType;
bool PixelFog; bool PixelFog;
......
...@@ -2779,11 +2779,11 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -2779,11 +2779,11 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
//! Enable the 2d override material //! Enable the 2d override material
void COpenGLDriver::enableInitMaterial2D(bool enable) void COpenGLDriver::enableMaterial2D(bool enable)
{ {
if (!enable) if (!enable)
CurrentRenderMode = ERM_NONE; CurrentRenderMode = ERM_NONE;
CNullDriver::enableInitMaterial2D(enable); CNullDriver::enableMaterial2D(enable);
} }
...@@ -2820,25 +2820,20 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh ...@@ -2820,25 +2820,20 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh
Transformation3DChanged = false; Transformation3DChanged = false;
} }
if (!InitMaterial2DEnabled) if (!OverrideMaterial2DEnabled)
{ {
SMaterial mat; setBasicRenderStates(InitMaterial2D, LastMaterial, true);
mat.Lighting=false; LastMaterial = InitMaterial2D;
mat.ZBuffer=ECFN_NEVER;
mat.ZWriteEnable=false;
setBasicRenderStates(mat, LastMaterial, true);
LastMaterial = mat;
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
} }
} }
if (InitMaterial2DEnabled) if (OverrideMaterial2DEnabled)
{ {
SMaterial mat(InitMaterial2D); OverrideMaterial2D.Lighting=false;
mat.Lighting=false; OverrideMaterial2D.ZBuffer=ECFN_NEVER;
mat.ZBuffer=ECFN_NEVER; OverrideMaterial2D.ZWriteEnable=false;
mat.ZWriteEnable=false; setBasicRenderStates(OverrideMaterial2D, LastMaterial, false);
setBasicRenderStates(mat, LastMaterial, false); LastMaterial = OverrideMaterial2D;
LastMaterial = mat;
} }
if (alphaChannel || alpha) if (alphaChannel || alpha)
...@@ -2855,7 +2850,7 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh ...@@ -2855,7 +2850,7 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh
if (texture) if (texture)
{ {
if (!InitMaterial2DEnabled) if (!OverrideMaterial2DEnabled)
{ {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
......
...@@ -337,7 +337,7 @@ namespace video ...@@ -337,7 +337,7 @@ namespace video
virtual void enableClipPlane(u32 index, bool enable); virtual void enableClipPlane(u32 index, bool enable);
//! Enable the 2d override material //! Enable the 2d override material
virtual void enableInitMaterial2D(bool enable=true); virtual void enableMaterial2D(bool enable=true);
//! Returns the graphics card vendor name. //! Returns the graphics card vendor name.
virtual core::stringc getVendorInfo() {return VendorName;} virtual core::stringc getVendorInfo() {return VendorName;}
......
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