Fix crashes when using the uninitialized layer 8 texture

This commit is contained in:
Benau 2016-07-15 15:23:17 +08:00
parent 1d6c7fa60f
commit 9fd6fd2673
9 changed files with 13 additions and 3 deletions

View File

@ -694,6 +694,8 @@ void IrrDriver::createSunInterposer()
getUnicolorTexture(video::SColor(255, 255, 255, 255)));
mb->getMaterial().setTexture(1,
getUnicolorTexture(video::SColor(0, 0, 0, 0)));
mb->getMaterial().setTexture(7,
getUnicolorTexture(video::SColor(0, 0, 0, 0)));
}
m_sun_interposer = new STKMeshSceneNode(sphere,
m_scene_manager->getRootSceneNode(),
@ -1153,6 +1155,7 @@ scene::IMeshSceneNode *IrrDriver::addSphere(float radius,
//m.setTexture(0, getUnicolorTexture(video::SColor(128, 255, 105, 180)));
m.setTexture(0, getUnicolorTexture(color));
m.setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
m.setTexture(7, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
if (CVS->isGLSL())
{

View File

@ -67,6 +67,7 @@ void ShowCurve::addEmptyMesh()
m_buffer = m_mesh->getMeshBuffer(0);
m_buffer->getMaterial().setTexture(0, getUnicolorTexture(video::SColor(128, 255, 105, 180)));
m_buffer->getMaterial().setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
m_buffer->getMaterial().setTexture(7, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
assert(m_buffer->getVertexType()==video::EVT_STANDARD);
} // addEmptyMesh

View File

@ -111,6 +111,7 @@ scene::IMesh* STKTextBillboard::getTextMesh(core::stringw text, gui::ScalableFon
buffer = new scene::SMeshBuffer();
buffer->getMaterial().setTexture(0, m_chars[i].m_texture);
buffer->getMaterial().setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
buffer->getMaterial().setTexture(7, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
buffer->getMaterial().MaterialType = Shaders::getShader(ES_OBJECT_UNLIT);
buffers[m_chars[i].m_texture] = buffer;
}

View File

@ -34,7 +34,6 @@
GLuint getTextureGLuint(irr::video::ITexture *tex)
{
assert(tex != NULL);
#if defined(USE_GLES2)
return static_cast<irr::video::COGLES2Texture*>(tex)->getOpenGLTextureName();
#else

View File

@ -72,6 +72,8 @@ RubberBand::RubberBand(Plunger *plunger, AbstractKart *kart)
mb->getMaterial().setTexture(0, getUnicolorTexture(video::SColor(255, 255, 255, 255)));
// Gloss
mb->getMaterial().setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
// Colorization mask
mb->getMaterial().setTexture(7, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
updatePosition();
m_node = irr_driver->addMesh(m_mesh, "rubberband");
irr_driver->applyObjectPassShader(m_node);

View File

@ -523,7 +523,7 @@ bool KartModel::loadModels(const KartProperties &kart_properties)
&kart_min, &kart_max);
// Test if kart model support colorization
for (int i = 0; i < int(m_mesh->getMeshBufferCount()); i++)
for (u32 i = 0; i < m_mesh->getMeshBufferCount(); i++)
{
scene::IMeshBuffer* mb = m_mesh->getMeshBuffer(i);
Material* material = material_manager->getMaterialFor(mb

View File

@ -103,6 +103,7 @@ CheckLine::CheckLine(const XMLNode &node, unsigned int index)
buffer->recalculateBoundingBox();
buffer->getMaterial().setTexture(0, getUnicolorTexture(video::SColor(128, 255, 105, 180)));
buffer->getMaterial().setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
buffer->getMaterial().setTexture(7, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
buffer->getMaterial().BackfaceCulling = false;
//mesh->setBoundingBox(buffer->getBoundingBox());
m_debug_node = irr_driver->addMesh(mesh, "checkdebug");

View File

@ -107,6 +107,7 @@ void GraphStructure::createMesh(bool show_invisible,
m.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
m.setTexture(0, getUnicolorTexture(video::SColor(255, 255, 255, 255)));
m.setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
m.setTexture(7, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
m_mesh = irr_driver->createQuadMesh(&m);
m_mesh_buffer = m_mesh->getMeshBuffer(0);
assert(m_mesh_buffer->getVertexType()==video::EVT_STANDARD);

View File

@ -780,6 +780,8 @@ void Track::createPhysicsModel(unsigned int main_track_count)
irr_driver->grabAllTextures(mesh);
// Gloss
mb->getMaterial().setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
// Colorization mask
mb->getMaterial().setTexture(7, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
}
else
irr_driver->removeNode(m_static_physics_only_nodes[i]);