Make most variables in OGLES2Driver private again (had been changed while developing WebGL driver).

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@5446 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2017-04-21 12:32:35 +00:00
parent b8cf4ca4bf
commit 9fb422b496
3 changed files with 37 additions and 42 deletions

View File

@ -412,6 +412,12 @@ COGLES2Driver::~COGLES2Driver()
delete[] fs2DData;
}
bool COGLES2Driver::setMaterialTexture(irr::u32 layerIdx, const irr::video::ITexture* texture)
{
Material.TextureLayer[layerIdx].Texture = const_cast<ITexture*>(texture); // function uses const-pointer for texture because all draw functions use const-pointers already
return CacheHandler->getTextureCache().set(0, texture);
}
bool COGLES2Driver::beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil, const SExposedVideoData& videoData, core::rect<s32>* sourceRect)
{
IRR_PROFILE(CProfileScope p1(EPID_ES2_BEGIN_SCENE);)
@ -983,8 +989,7 @@ COGLES2Driver::~COGLES2Driver()
const core::rect<s32> poss(targetPos, sourceSize);
chooseMaterial2D();
Material.TextureLayer[0].Texture = const_cast<ITexture*>(texture);
if (!CacheHandler->getTextureCache().set(0, texture))
if (!setMaterialTexture(0, texture ))
return;
setRenderStates2DMode(color.getAlpha() < 255, true, useAlphaChannelOfTexture);
@ -1045,8 +1050,7 @@ COGLES2Driver::~COGLES2Driver()
const video::SColor* const useColor = colors ? colors : temp;
chooseMaterial2D();
Material.TextureLayer[0].Texture = const_cast<ITexture*>(texture);
if (!CacheHandler->getTextureCache().set(0, texture))
if (!setMaterialTexture(0, texture ))
return;
setRenderStates2DMode(useColor[0].getAlpha() < 255 || useColor[1].getAlpha() < 255 ||
@ -1096,10 +1100,11 @@ COGLES2Driver::~COGLES2Driver()
void COGLES2Driver::draw2DImage(const video::ITexture* texture, u32 layer, bool flip)
{
chooseMaterial2D();
Material.TextureLayer[0].Texture = const_cast<ITexture*>(texture);
if (!texture)
return;
if (!texture || !CacheHandler->getTextureCache().set(0, texture))
chooseMaterial2D();
if (!setMaterialTexture(0, texture ))
return;
setRenderStates2DMode(false, true, true);
@ -1247,8 +1252,7 @@ COGLES2Driver::~COGLES2Driver()
const core::rect<s32> poss(targetPos, sourceSize);
chooseMaterial2D();
Material.TextureLayer[0].Texture = const_cast<ITexture*>(texture);
if (!CacheHandler->getTextureCache().set(0, texture))
if (!setMaterialTexture(0, texture))
return;
setRenderStates2DMode(color.getAlpha() < 255, true, useAlphaChannelOfTexture);
@ -1311,8 +1315,7 @@ COGLES2Driver::~COGLES2Driver()
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_2DIMAGE_BATCH);)
chooseMaterial2D();
Material.TextureLayer[0].Texture = const_cast<ITexture*>(texture);
if (!CacheHandler->getTextureCache().set(0, texture))
if (!setMaterialTexture(0, texture))
return;
setRenderStates2DMode(color.getAlpha() < 255, true, useAlphaChannelOfTexture);
@ -1404,8 +1407,7 @@ COGLES2Driver::~COGLES2Driver()
IRR_PROFILE(CProfileScope p1(EPID_ES2_DRAW_2DRECTANGLE);)
chooseMaterial2D();
Material.TextureLayer[0].Texture = 0;
CacheHandler->getTextureCache().set(0, 0);
setMaterialTexture(0, 0);
setRenderStates2DMode(color.getAlpha() < 255, false, false);
@ -1458,8 +1460,7 @@ COGLES2Driver::~COGLES2Driver()
return;
chooseMaterial2D();
Material.TextureLayer[0].Texture = 0;
CacheHandler->getTextureCache().set(0, 0);
setMaterialTexture(0, 0);
setRenderStates2DMode(colorLeftUp.getAlpha() < 255 ||
colorRightUp.getAlpha() < 255 ||
@ -1501,8 +1502,7 @@ COGLES2Driver::~COGLES2Driver()
else
{
chooseMaterial2D();
Material.TextureLayer[0].Texture = 0;
CacheHandler->getTextureCache().set(0, 0);
setMaterialTexture(0, 0);
setRenderStates2DMode(color.getAlpha() < 255, false, false);
@ -1537,8 +1537,7 @@ COGLES2Driver::~COGLES2Driver()
return;
chooseMaterial2D();
Material.TextureLayer[0].Texture = 0;
CacheHandler->getTextureCache().set(0, 0);
setMaterialTexture(0, 0);
setRenderStates2DMode(color.getAlpha() < 255, false, false);
@ -2187,8 +2186,7 @@ COGLES2Driver::~COGLES2Driver()
return;
chooseMaterial2D();
Material.TextureLayer[0].Texture = 0;
CacheHandler->getTextureCache().set(0, 0);
setMaterialTexture(0, 0);
setRenderStates2DMode(true, false, false);

View File

@ -362,7 +362,12 @@ namespace video
void loadShaderData(const io::path& vertexShaderName, const io::path& fragmentShaderName, c8** vertexShaderData, c8** fragmentShaderData);
bool setMaterialTexture(irr::u32 layerIdx, const irr::video::ITexture* texture);
COGLES2CacheHandler* CacheHandler;
private:
COGLES2Renderer2D* MaterialRenderer2DActive;
COGLES2Renderer2D* MaterialRenderer2DTexture;
COGLES2Renderer2D* MaterialRenderer2DNoTexture;

View File

@ -193,8 +193,7 @@ void CWebGL1Driver::draw2DImage(const video::ITexture* texture,
const core::rect<s32> poss(targetPos, sourceSize);
chooseMaterial2D();
Material.TextureLayer[0].Texture = const_cast<ITexture*>(texture);
if (!CacheHandler->getTextureCache().set(0, texture))
if ( !setMaterialTexture(0, texture) )
return;
setRenderStates2DMode(color.getAlpha() < 255, true, useAlphaChannelOfTexture);
@ -245,8 +244,7 @@ void CWebGL1Driver::draw2DImage(const video::ITexture* texture, const core::rect
const video::SColor* const useColor = colors ? colors : temp;
chooseMaterial2D();
Material.TextureLayer[0].Texture = const_cast<ITexture*>(texture);
if (!CacheHandler->getTextureCache().set(0, texture))
if ( !setMaterialTexture(0, texture) )
return;
setRenderStates2DMode(useColor[0].getAlpha() < 255 || useColor[1].getAlpha() < 255 ||
@ -288,10 +286,11 @@ void CWebGL1Driver::draw2DImage(const video::ITexture* texture, const core::rect
void CWebGL1Driver::draw2DImage(const video::ITexture* texture, u32 layer, bool flip)
{
chooseMaterial2D();
Material.TextureLayer[0].Texture = const_cast<ITexture*>(texture);
if (!texture )
return;
if (!texture || !CacheHandler->getTextureCache().set(0, texture))
chooseMaterial2D();
if ( !setMaterialTexture(0, texture) )
return;
setRenderStates2DMode(false, true, true);
@ -332,8 +331,7 @@ void CWebGL1Driver::draw2DImageBatch(const video::ITexture* texture,
return;
chooseMaterial2D();
Material.TextureLayer[0].Texture = const_cast<ITexture*>(texture);
if (!CacheHandler->getTextureCache().set(0, texture))
if ( !setMaterialTexture(0, texture) )
return;
setRenderStates2DMode(color.getAlpha() < 255, true, useAlphaChannelOfTexture);
@ -409,8 +407,7 @@ void CWebGL1Driver::draw2DImageBatch(const video::ITexture* texture,
return;
chooseMaterial2D();
Material.TextureLayer[0].Texture = const_cast<ITexture*>(texture);
if (!CacheHandler->getTextureCache().set(0, texture))
if ( !setMaterialTexture(0, texture) )
return;
setRenderStates2DMode(color.getAlpha() < 255, true, useAlphaChannelOfTexture);
@ -532,8 +529,7 @@ void CWebGL1Driver::draw2DRectangle(SColor color,
const core::rect<s32>* clip)
{
chooseMaterial2D();
Material.TextureLayer[0].Texture = 0;
CacheHandler->getTextureCache().set(0, 0);
setMaterialTexture(0, 0);
setRenderStates2DMode(color.getAlpha() < 255, false, false);
lockRenderStateMode();
@ -577,8 +573,7 @@ void CWebGL1Driver::draw2DRectangle(const core::rect<s32>& position,
return;
chooseMaterial2D();
Material.TextureLayer[0].Texture = 0;
CacheHandler->getTextureCache().set(0, 0);
setMaterialTexture(0, 0);
setRenderStates2DMode(colorLeftUp.getAlpha() < 255 ||
colorRightUp.getAlpha() < 255 ||
@ -612,8 +607,7 @@ void CWebGL1Driver::draw2DLine(const core::position2d<s32>& start, const core::p
else
{
chooseMaterial2D();
Material.TextureLayer[0].Texture = 0;
CacheHandler->getTextureCache().set(0, 0);
setMaterialTexture(0, 0);
setRenderStates2DMode(color.getAlpha() < 255, false, false);
lockRenderStateMode();
@ -642,8 +636,7 @@ void CWebGL1Driver::drawPixel(u32 x, u32 y, const SColor & color)
return;
chooseMaterial2D();
Material.TextureLayer[0].Texture = 0;
CacheHandler->getTextureCache().set(0, 0);
setMaterialTexture(0, 0);
setRenderStates2DMode(color.getAlpha() < 255, false, false);
lockRenderStateMode();
@ -691,8 +684,7 @@ void CWebGL1Driver::drawStencilShadow(bool clearStencilBuffer,
return;
chooseMaterial2D();
Material.TextureLayer[0].Texture = 0;
CacheHandler->getTextureCache().set(0, 0);
setMaterialTexture(0, 0);
setRenderStates2DMode(true, false, false);
lockRenderStateMode();