diff --git a/src/graphics/glwrap.cpp b/src/graphics/glwrap.cpp index f9e5118cc..75aac3ec9 100644 --- a/src/graphics/glwrap.cpp +++ b/src/graphics/glwrap.cpp @@ -474,6 +474,20 @@ void saveCompressedTexture(const std::string& compressed_tex) delete[] data; } +static unsigned colorcount = 0; + +video::ITexture* getUnicolorTexture(video::SColor c) +{ + video::SColor tmp[4] = { + c, c, c, c + }; + video::IImage *img = irr_driver->getVideoDriver()->createImageFromData(video::ECF_A8R8G8B8, core::dimension2d(2, 2), tmp); + img->grab(); + std::string name("color"); + name += colorcount++; + return irr_driver->getVideoDriver()->addTexture(name.c_str(), img); +} + void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter, bool allowAF) { glActiveTexture(GL_TEXTURE0 + TextureUnit); diff --git a/src/graphics/glwrap.hpp b/src/graphics/glwrap.hpp index 1556ee662..186e0c9dc 100644 --- a/src/graphics/glwrap.hpp +++ b/src/graphics/glwrap.hpp @@ -109,6 +109,7 @@ extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB; void initGL(); GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount); +video::ITexture* getUnicolorTexture(video::SColor c); void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter, bool allowAF = false); GLuint LoadShader(const char * file, unsigned type); diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp index 12a294598..ac737f39d 100644 --- a/src/graphics/render.cpp +++ b/src/graphics/render.cpp @@ -528,24 +528,12 @@ void IrrDriver::renderSolidFirstPass() glUseProgram(MeshShader::ObjectPass1Shader::Program); for (unsigned i = 0; i < GroupedFPSM::MeshSet.size(); ++i) { - const GLMesh &mesh = *GroupedFPSM::MeshSet[i]; - if (mesh.textures[0]) - { - compressTexture(mesh.textures[0], true); - setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); - } - else - { - setTexture(0, 0, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, false); - GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ONE }; - glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); - } - draw(mesh, mesh.vao, GroupedFPSM::MVPSet[i], GroupedFPSM::TIMVSet[i], 0); + GLMesh &mesh = *GroupedFPSM::MeshSet[i]; if (!mesh.textures[0]) - { - GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; - glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); - } + mesh.textures[0] = getUnicolorTexture(video::SColor(255, 255, 255, 255)); + compressTexture(mesh.textures[0], true); + setTexture(0, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); + draw(mesh, mesh.vao, GroupedFPSM::MVPSet[i], GroupedFPSM::TIMVSet[i], 0); } glUseProgram(MeshShader::ObjectRefPass1Shader::Program);