Commit 7d00cc91 authored by monstrobishi's avatar monstrobishi

- Renamed texture setting function (setTexture) in most video drivers to...

 - Renamed texture setting function (setTexture) in most video drivers to setActiveTexture and made sure it has the same signature. This avoids confusion with similarly named methods in other classes (Such as SMaterial) and the consolidated method signature will hopefully help future plans for better abstracting texture usage across all drivers.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2438 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 677f750e
......@@ -632,7 +632,7 @@ void CD3D8Driver::setTransform(E_TRANSFORMATION_STATE state,
//! sets the current Texture
bool CD3D8Driver::setTexture(s32 stage, const video::ITexture* texture)
bool CD3D8Driver::setActiveTexture(u32 stage, const video::ITexture* texture)
{
if (CurrentTexture[stage] == texture)
return true;
......@@ -666,7 +666,7 @@ void CD3D8Driver::setMaterial(const SMaterial& material)
for (u32 i=0; i<MaxTextureUnits; ++i)
{
setTexture(i, Material.getTexture(i));
setActiveTexture(i, Material.getTexture(i));
setTransform((E_TRANSFORMATION_STATE) ( ETS_TEXTURE_0 + i ),
material.getTextureMatrix(i));
}
......@@ -925,7 +925,7 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture,
if (!sourceRect.isValid())
return;
if (!setTexture(0, texture))
if (!setActiveTexture(0, texture))
return;
core::position2d<s32> targetPos = pos;
......@@ -1116,7 +1116,7 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture,
useColor[2].getAlpha()<255 || useColor[3].getAlpha()<255,
true, useAlphaChannelOfTexture);
setTexture(0, texture);
setActiveTexture(0, texture);
setVertexShader(EVT_STANDARD);
......@@ -1156,7 +1156,7 @@ void CD3D8Driver::draw2DRectangle(const core::rect<s32>& position,
colorLeftDown.getAlpha() < 255 ||
colorRightDown.getAlpha() < 255, false, false);
setTexture(0,0);
setActiveTexture(0,0);
setVertexShader(EVT_STANDARD);
......@@ -1181,7 +1181,7 @@ void CD3D8Driver::draw2DLine(const core::position2d<s32>& start,
color, 0.0f, 0.0f);
setRenderStates2DMode(color.getAlpha() < 255, false, false);
setTexture(0,0);
setActiveTexture(0,0);
setVertexShader(EVT_STANDARD);
......@@ -1197,7 +1197,7 @@ void CD3D8Driver::drawPixel(u32 x, u32 y, const SColor & color)
return;
setRenderStates2DMode(color.getAlpha() < 255, false, false);
setTexture(0,0);
setActiveTexture(0,0);
setVertexShader(EVT_STANDARD);
......@@ -1537,10 +1537,10 @@ void CD3D8Driver::setRenderStatesStencilShadowMode(bool zfail)
Transformation3DChanged = false;
setTexture(0,0);
setTexture(1,0);
setTexture(2,0);
setTexture(3,0);
setActiveTexture(0,0);
setActiveTexture(1,0);
setActiveTexture(2,0);
setActiveTexture(3,0);
pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE);
pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
......@@ -1942,7 +1942,7 @@ void CD3D8Driver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftU
leftDownEdge.getAlpha() < 255 ||
rightDownEdge.getAlpha() < 255);
setTexture(0,0);
setActiveTexture(0,0);
setVertexShader(EVT_STANDARD);
......
......@@ -238,7 +238,7 @@ namespace video
void setRenderStatesStencilShadowMode(bool zfail);
//! sets the current Texture
bool setTexture(s32 stage, const video::ITexture* texture);
bool setActiveTexture(u32 stage, const video::ITexture* texture);
//! resets the device
bool reset();
......
......@@ -670,7 +670,7 @@ void CD3D9Driver::setTransform(E_TRANSFORMATION_STATE state,
//! sets the current Texture
bool CD3D9Driver::setTexture(s32 stage, const video::ITexture* texture)
bool CD3D9Driver::setActiveTexture(u32 stage, const video::ITexture* texture)
{
if (CurrentTexture[stage] == texture)
return true;
......@@ -704,7 +704,7 @@ void CD3D9Driver::setMaterial(const SMaterial& material)
for (u32 i=0; i<MaxTextureUnits; ++i)
{
setTexture(i, Material.getTexture(i));
setActiveTexture(i, Material.getTexture(i));
setTransform((E_TRANSFORMATION_STATE) ( ETS_TEXTURE_0 + i ),
material.getTextureMatrix(i));
}
......@@ -1283,7 +1283,7 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture,
useColor[2].getAlpha()<255 || useColor[3].getAlpha()<255,
true, useAlphaChannelOfTexture);
setTexture(0, const_cast<video::ITexture*>(texture));
setActiveTexture(0, const_cast<video::ITexture*>(texture));
setVertexShader(EVT_STANDARD);
......@@ -1320,7 +1320,7 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture,
if (!sourceRect.isValid())
return;
if (!setTexture(0, const_cast<video::ITexture*>(texture)))
if (!setActiveTexture(0, const_cast<video::ITexture*>(texture)))
return;
core::position2d<s32> targetPos = pos;
......@@ -1470,7 +1470,7 @@ void CD3D9Driver::draw2DRectangle(const core::rect<s32>& position,
colorLeftDown.getAlpha() < 255 ||
colorRightDown.getAlpha() < 255, false, false);
setTexture(0,0);
setActiveTexture(0,0);
setVertexShader(EVT_STANDARD);
......@@ -1495,7 +1495,7 @@ void CD3D9Driver::draw2DLine(const core::position2d<s32>& start,
color, 0.0f, 0.0f);
setRenderStates2DMode(color.getAlpha() < 255, false, false);
setTexture(0,0);
setActiveTexture(0,0);
setVertexShader(EVT_STANDARD);
......@@ -1512,7 +1512,7 @@ void CD3D9Driver::drawPixel(u32 x, u32 y, const SColor & color)
return;
setRenderStates2DMode(color.getAlpha() < 255, false, false);
setTexture(0,0);
setActiveTexture(0,0);
setVertexShader(EVT_STANDARD);
......@@ -1885,10 +1885,10 @@ void CD3D9Driver::setRenderStatesStencilShadowMode(bool zfail)
Transformation3DChanged = false;
setTexture(0,0);
setTexture(1,0);
setTexture(2,0);
setTexture(3,0);
setActiveTexture(0,0);
setActiveTexture(1,0);
setActiveTexture(2,0);
setActiveTexture(3,0);
pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE);
pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
......@@ -2293,7 +2293,7 @@ void CD3D9Driver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftU
leftDownEdge.getAlpha() < 255 ||
rightDownEdge.getAlpha() < 255);
setTexture(0,0);
setActiveTexture(0,0);
setVertexShader(EVT_STANDARD);
......
......@@ -294,7 +294,7 @@ namespace video
void setRenderStatesStencilShadowMode(bool zfail);
//! sets the current Texture
bool setTexture(s32 stage, const video::ITexture* texture);
bool setActiveTexture(u32 stage, const video::ITexture* texture);
//! resets the device
bool reset();
......
......@@ -1431,7 +1431,7 @@ void COpenGLDriver::draw2DImage(const video::ITexture* texture,
const core::rect<s32> poss(targetPos, sourceSize);
disableTextures(1);
if (!setTexture(0, texture))
if (!setActiveTexture(0, texture))
return;
setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture);
......@@ -1484,7 +1484,7 @@ void COpenGLDriver::draw2DImage(const video::ITexture* texture, const core::rect
const video::SColor* const useColor = colors ? colors : temp;
disableTextures(1);
setTexture(0, texture);
setActiveTexture(0, texture);
setRenderStates2DMode(useColor[0].getAlpha()<255 || useColor[1].getAlpha()<255 ||
useColor[2].getAlpha()<255 || useColor[3].getAlpha()<255,
true, useAlphaChannelOfTexture);
......@@ -1541,7 +1541,7 @@ void COpenGLDriver::draw2DImage(const video::ITexture* texture,
return;
disableTextures(1);
if (!setTexture(0, texture))
if (!setActiveTexture(0, texture))
return;
setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture);
......@@ -1693,7 +1693,7 @@ void COpenGLDriver::drawPixel(u32 x, u32 y, const SColor &color)
glEnd();
}
bool COpenGLDriver::setTexture(u32 stage, const video::ITexture* texture)
bool COpenGLDriver::setActiveTexture(u32 stage, const video::ITexture* texture)
{
if (stage >= MaxTextureUnits)
return false;
......@@ -1734,7 +1734,7 @@ bool COpenGLDriver::disableTextures(u32 fromStage)
{
bool result=true;
for (u32 i=fromStage; i<MaxTextureUnits; ++i)
result &= setTexture(i, 0);
result &= setActiveTexture(i, 0);
return result;
}
......@@ -3064,7 +3064,7 @@ bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuff
// check if we should set the previous RT back
setTexture(0, 0);
setActiveTexture(0, 0);
ResetRenderStates=true;
if (RenderTargetTexture!=0)
{
......
......@@ -228,7 +228,7 @@ namespace video
//! sets the current Texture
//! Returns whether setting was a success or not.
bool setTexture(u32 stage, const video::ITexture* texture);
bool setActiveTexture(u32 stage, const video::ITexture* texture);
//! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled.
//! Returns whether disabling was successful or not.
......
......@@ -87,7 +87,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(1);
Driver->setTexture(0, material.getTexture(0));
Driver->setActiveTexture(0, material.getTexture(0));
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (resetAllRenderstates || (material.MaterialType != lastMaterial.MaterialType))
......@@ -112,7 +112,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(1);
Driver->setTexture(0, material.getTexture(0));
Driver->setActiveTexture(0, material.getTexture(0));
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
// if (material.MaterialType != lastMaterial.MaterialType ||
......@@ -199,8 +199,8 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(2);
Driver->setTexture(1, material.getTexture(1));
Driver->setTexture(0, material.getTexture(0));
Driver->setActiveTexture(1, material.getTexture(1));
Driver->setActiveTexture(0, material.getTexture(0));
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
......@@ -245,7 +245,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(1);
Driver->setTexture(0, material.getTexture(0));
Driver->setActiveTexture(0, material.getTexture(0));
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if ((material.MaterialType != lastMaterial.MaterialType) || resetAllRenderstates)
......@@ -281,7 +281,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(1);
Driver->setTexture(0, material.getTexture(0));
Driver->setActiveTexture(0, material.getTexture(0));
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
......@@ -334,7 +334,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(1);
Driver->setTexture(0, material.getTexture(0));
Driver->setActiveTexture(0, material.getTexture(0));
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates
......@@ -383,7 +383,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(1);
Driver->setTexture(0, material.getTexture(0));
Driver->setActiveTexture(0, material.getTexture(0));
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
......@@ -419,8 +419,8 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(2);
Driver->setTexture(1, material.getTexture(1));
Driver->setTexture(0, material.getTexture(0));
Driver->setActiveTexture(1, material.getTexture(1));
Driver->setActiveTexture(0, material.getTexture(0));
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
......@@ -506,8 +506,8 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(2);
Driver->setTexture(1, material.getTexture(1));
Driver->setTexture(0, material.getTexture(0));
Driver->setActiveTexture(1, material.getTexture(1));
Driver->setActiveTexture(0, material.getTexture(0));
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
......@@ -542,7 +542,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(1);
Driver->setTexture(0, material.getTexture(0));
Driver->setActiveTexture(0, material.getTexture(0));
// texture needs to be flipped for OpenGL
core::matrix4 tmp = Driver->getTransform(ETS_TEXTURE_0);
tmp[5]*=-1;
......@@ -579,8 +579,8 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(2);
Driver->setTexture(1, material.getTexture(1));
Driver->setTexture(0, material.getTexture(0));
Driver->setActiveTexture(1, material.getTexture(1));
Driver->setActiveTexture(0, material.getTexture(0));
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
......@@ -630,8 +630,8 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(2);
Driver->setTexture(1, material.getTexture(1));
Driver->setTexture(0, material.getTexture(0));
Driver->setActiveTexture(1, material.getTexture(1));
Driver->setActiveTexture(0, material.getTexture(0));
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
......
......@@ -154,7 +154,7 @@ void COpenGLSLMaterialRenderer::OnSetMaterial(const video::SMaterial& material,
CallBack->OnSetMaterial(material);
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
Driver->setTexture(i, material.getTexture(i));
Driver->setActiveTexture(i, material.getTexture(i));
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
}
......
......@@ -134,7 +134,7 @@ void COpenGLShaderMaterialRenderer::OnSetMaterial(const video::SMaterial& materi
CallBack->OnSetMaterial(material);
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
Driver->setTexture(i, material.getTexture(i));
Driver->setActiveTexture(i, material.getTexture(i));
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
}
......
......@@ -190,7 +190,7 @@ void COpenGLTexture::copyTexture(bool newTexture)
break;
}
Driver->setTexture(0, this);
Driver->setActiveTexture(0, this);
if (Driver->testGLError())
os::Printer::log("Could not bind Texture", ELL_ERROR);
......@@ -436,7 +436,7 @@ void COpenGLTexture::bindRTT()
//! Unbind Render Target Texture
void COpenGLTexture::unbindRTT()
{
Driver->setTexture(0, this);
Driver->setActiveTexture(0, this);
// Copy Our ViewPort To The Texture
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, getSize().Width, getSize().Height);
......@@ -475,7 +475,7 @@ COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<u32>& size,
// generate color texture
glGenTextures(1, &TextureName);
Driver->setTexture(0, this);
Driver->setActiveTexture(0, this);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, FilteringType);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
......
......@@ -176,7 +176,7 @@ void CSoftwareDriver::setTransform(E_TRANSFORMATION_STATE state, const core::mat
//! sets the current Texture
bool CSoftwareDriver::setTexture(video::ITexture* texture)
bool CSoftwareDriver::setActiveTexture(u32 stage, video::ITexture* texture)
{
if (texture && texture->getDriverType() != EDT_SOFTWARE)
{
......@@ -205,7 +205,7 @@ void CSoftwareDriver::setMaterial(const SMaterial& material)
for (u32 i = 0; i < 1; ++i)
{
setTexture(Material.getTexture(i));
setActiveTexture(i, Material.getTexture(i));
setTransform ((E_TRANSFORMATION_STATE) ( ETS_TEXTURE_0 + i ),
material.getTextureMatrix(i));
}
......
......@@ -124,7 +124,7 @@ namespace video
void setRenderTarget(video::CImage* image);
//! sets the current Texture
bool setTexture(video::ITexture* texture);
bool setActiveTexture(u32 stage, video::ITexture* texture);
//! switches to a triangle renderer
void switchToTriangleRenderer(ETriangleRenderer renderer);
......
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