Allow legacy pipeline to use new texture format

This commit is contained in:
Benau 2017-01-06 15:04:15 +08:00
parent 513f1e2edf
commit 827a483e85
32 changed files with 187 additions and 461 deletions

View File

@ -3120,7 +3120,7 @@ namespace video
setActiveTexture(GL_TEXTURE0 + stage);
if(Driver->CurrentTexture[stage])
glBindTexture(GL_TEXTURE_2D, static_cast<const COGLES2Texture*>(Driver->CurrentTexture[stage])->getOpenGLTextureName());
glBindTexture(GL_TEXTURE_2D, Driver->CurrentTexture[stage]->getOpenGLTextureName());
Texture[stage] = Driver->CurrentTexture[stage];
}

View File

@ -2565,8 +2565,7 @@ bool COpenGLDriver::setActiveTexture(u32 stage, const video::ITexture* texture)
if (!useCoreContext)
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,
static_cast<const COpenGLTexture*>(texture)->getOpenGLTextureName());
glBindTexture(GL_TEXTURE_2D, texture->getOpenGLTextureName());
}
return true;
}

View File

@ -21,7 +21,6 @@
#include "graphics/shader.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/stk_mesh.hpp"
#include "graphics/texture_manager.hpp"
// ----------------------------------------------------------------------------
/** Variadic template to draw a mesh (using OpenGL 3.2 function)
@ -87,10 +86,8 @@ struct TexExpanderImpl
Args... args)
{
size_t idx = STK::tuple_get<sizeof...(TupleArgs) - N>(tex_swizzle);
TexExpanderImpl<T, N - 1>::template expandTex( mesh,
tex_swizzle,
args...,
getTextureGLuint(mesh.textures[idx]));
TexExpanderImpl<T, N - 1>::template expandTex(mesh, tex_swizzle,
args..., mesh.textures[idx]->getOpenGLTextureName());
} // ExpandTex
}; // TexExpanderImpl

View File

@ -222,7 +222,10 @@ void renderTransparenPass(const std::vector<RenderGeometry::TexUnit> &TexUnits,
if (CVS->isAZDOEnabled())
Shader::getInstance()->setTextureHandles(mesh.TextureHandles[0]);
else
Shader::getInstance()->setTextureUnits(getTextureGLuint(mesh.textures[0]));
{
Shader::getInstance()->setTextureUnits(mesh.textures[0]
->getOpenGLTextureName());
}
CustomUnrollArgs<List...>::template drawMesh<Shader>(meshes->at(i));
}
} // renderTransparenPass
@ -370,10 +373,10 @@ void AbstractGeometryPasses::renderTransparent(const DrawCalls& draw_calls,
size_t count = mesh.IndexCount;
// Render the effect
DisplaceShader::getInstance()->setTextureUnits(
getTextureGLuint(m_displace_tex),
m_displace_tex->getOpenGLTextureName(),
colors_framebuffer.getRTT()[0],
tmp_framebuffer.getRTT()[0],
getTextureGLuint(mesh.textures[0]));
mesh.textures[0]->getOpenGLTextureName());
DisplaceShader::getInstance()->use();
DisplaceShader::getInstance()->setUniforms(AbsoluteTransformation,
core::vector2df(cb->getDirX(), cb->getDirY()),

View File

@ -753,11 +753,11 @@ void IrrDriver::createSunInterposer()
if (!mb)
continue;
mb->getMaterial().setTexture(0,
getUnicolorTexture(video::SColor(255, 255, 255, 255)));
STKTexManager::getInstance()->getUnicolorTexture(video::SColor(255, 255, 255, 255)));
mb->getMaterial().setTexture(1,
getUnicolorTexture(video::SColor(0, 0, 0, 0)));
STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
mb->getMaterial().setTexture(2,
getUnicolorTexture(video::SColor(0, 0, 0, 0)));
STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
}
m_sun_interposer = new STKMeshSceneNode(sphere,
m_scene_manager->getRootSceneNode(),
@ -1204,10 +1204,10 @@ scene::IMeshSceneNode *IrrDriver::addSphere(float radius,
m.BackfaceCulling = false;
m.MaterialType = video::EMT_SOLID;
#ifndef SERVER_ONLY
//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(2, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
//m.setTexture(0, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(128, 255, 105, 180)));
m.setTexture(0, STKTexManager::getInstance()->getUnicolorTexture(color));
m.setTexture(1, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
m.setTexture(2, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
if (CVS->isGLSL())
{
@ -1677,91 +1677,7 @@ video::ITexture *IrrDriver::getTexture(const std::string &filename,
bool is_prediv,
bool complain_if_not_found)
{
#ifndef SERVER_ONLY
if (CVS->isGLSL())
{
return STKTexManager::getInstance()->getTexture(filename);
}
#endif // !SERVER_ONLY
video::ITexture* out;
if(!is_premul && !is_prediv)
{
if (!complain_if_not_found) m_device->getLogger()->setLogLevel(ELL_NONE);
out = m_video_driver->getTexture(filename.c_str());
if (!complain_if_not_found) m_device->getLogger()->setLogLevel(ELL_WARNING);
}
else
{
// FIXME: can't we just do this externally, and just use the
// modified textures??
video::IImage* img =
m_video_driver->createImageFromFile(filename.c_str());
// PNGs are non premul, but some are used for premul tasks, so convert
// http://home.comcast.net/~tom_forsyth/blog.wiki.html#[[Premultiplied%20alpha]]
// FIXME check param, not name
if(img && is_premul &&
StringUtils::hasSuffix(filename.c_str(), ".png") &&
(img->getColorFormat() == video::ECF_A8R8G8B8) &&
img->lock())
{
core::dimension2d<u32> dim = img->getDimension();
for(unsigned int x = 0; x < dim.Width; x++)
{
for(unsigned int y = 0; y < dim.Height; y++)
{
video::SColor col = img->getPixel(x, y);
unsigned int alpha = col.getAlpha();
unsigned int red = alpha * col.getRed() / 255;
unsigned int blue = alpha * col.getBlue() / 255;
unsigned int green = alpha * col.getGreen() / 255;
col.set(alpha, red, green, blue);
img->setPixel(x, y, col, false);
} // for y
} // for x
img->unlock();
} // if png and ColorFOrmat and lock
// Other formats can be premul, but the tasks can be non premul
// So divide to get the separate RGBA (only possible if alpha!=0)
else if(img && is_prediv &&
(img->getColorFormat() == video::ECF_A8R8G8B8) &&
img->lock())
{
core::dimension2d<u32> dim = img->getDimension();
for(unsigned int x = 0; x < dim.Width; x++)
{
for(unsigned int y = 0; y < dim.Height; y++)
{
video::SColor col = img->getPixel(x, y);
unsigned int alpha = col.getAlpha();
// Avoid divide by zero
if (alpha) {
unsigned int red = 255 * col.getRed() / alpha ;
unsigned int blue = 255 * col.getBlue() / alpha;
unsigned int green = 255 * col.getGreen() / alpha;
col.set(alpha, red, green, blue);
img->setPixel(x, y, col, false);
}
} // for y
} // for x
img->unlock();
} // if premul && color format && lock
out = m_video_driver->addTexture(filename.c_str(), img, NULL);
} // if is_premul or is_prediv
if (complain_if_not_found && out == NULL)
{
if(m_texture_error_message.size()>0)
{
Log::error("irr_driver", m_texture_error_message.c_str());
}
Log::error("irr_driver", "Texture '%s' not found.", filename.c_str());
}
m_texturesFileName[out] = filename;
return out;
return STKTexManager::getInstance()->getTexture(filename);
} // getTexture
// ----------------------------------------------------------------------------
@ -1835,76 +1751,6 @@ void IrrDriver::dropAllTextures(const scene::IMesh *mesh)
} // for i <getMeshBufferCount
} // dropAllTextures
// ----------------------------------------------------------------------------
void IrrDriver::applyMask(video::ITexture* texture,
const std::string& mask_path)
{
#ifndef SERVER_ONLY
const core::dimension2d<u32> size = texture->getSize();
video::IImage* img =
m_video_driver->createImage(texture, core::position2d<s32>(0,0), size);
video::IImage* mask =
m_video_driver->createImageFromFile(mask_path.c_str());
if (img == NULL || mask == NULL)
{
Log::warn("irr_driver", "Applying mask failed for '%s'!",
texture->getName().getPtr());
return;
}
if (mask->getDimension() != size)
{
video::IImage* mask_scaled =
m_video_driver->createImage(texture->getColorFormat(), size);
mask->copyToScaling(mask_scaled);
mask->drop();
mask = mask_scaled;
}
void* dest = img->lock();
if (dest != NULL && mask->lock())
{
core::dimension2d<u32> dim = img->getDimension();
for (unsigned int x = 0; x < dim.Width; x++)
{
for (unsigned int y = 0; y < dim.Height; y++)
{
video::SColor col = img->getPixel(x, y);
video::SColor alpha = mask->getPixel(x, y);
col.setAlpha( alpha.getRed() );
img->setPixel(x, y, col, false);
} // for y
} // for x
if (!CVS->isGLSL())
{
// For new graphical pipeline, it will be done in texture manager
// compressTexture
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(texture));
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, dim.Width, dim.Height,
GL_BGRA, GL_UNSIGNED_BYTE, dest);
glGenerateMipmap(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 0);
}
mask->unlock();
img->unlock();
#if defined(USE_GLES2)
static_cast<irr::video::COGLES2Texture*>(texture)->setImage(img);
#else
static_cast<irr::video::COpenGLTexture*>(texture)->setImage(img);
#endif
mask->drop();
return;
}
Log::warn("irr_driver", "Applying mask failed for '%s'!",
texture->getName().getPtr());
img->drop();
mask->drop();
#endif
} // applyMask
// ----------------------------------------------------------------------------
void IrrDriver::onLoadWorld()
{

View File

@ -220,8 +220,6 @@ public:
void setAllMaterialFlags(scene::IMesh *mesh) const;
scene::IAnimatedMesh *getAnimatedMesh(const std::string &name);
scene::IMesh *getMesh(const std::string &name);
void applyMask(video::ITexture* texture,
const std::string& mask_path);
void displayFPS();
bool OnEvent(const irr::SEvent &event);
void setAmbientLight(const video::SColorf &light,

View File

@ -33,9 +33,7 @@
#include "graphics/irr_driver.hpp"
#include "graphics/particle_kind_manager.hpp"
#include "graphics/shaders.hpp"
#include "graphics/stk_texture.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "graphics/texture_manager.hpp"
#include "io/file_manager.hpp"
#include "race/race_manager.hpp"
#include "io/xml_node.hpp"
@ -508,20 +506,9 @@ void Material::install(bool srgb, bool premul_alpha)
}
else
{
#ifndef SERVER_ONLY
if (CVS->isGLSL())
{
m_texture = STKTexManager::getInstance()->getTexture
(m_full_path, srgb, premul_alpha, false/*set_material*/,
srgb/*mesh_tex*/);
}
else
#endif
{
m_texture = irr_driver->getTexture(m_full_path,
false, //isPreMul(), false, //isPreDiv(),
m_complain_if_not_found);
}
m_texture = STKTexManager::getInstance()->getTexture
(m_full_path, srgb, premul_alpha, false/*set_material*/,
srgb/*mesh_tex*/);
}
if (m_texture == NULL) return;
@ -529,12 +516,6 @@ void Material::install(bool srgb, bool premul_alpha)
// now set the name to the basename, so that all tests work as expected
m_texname = StringUtils::getBasename(m_texname);
#ifndef SERVER_ONLY
if (!CVS->isGLSL() && m_mask.size() > 0)
{
irr_driver->applyMask(m_texture, m_mask);
}
#endif
m_texture->grab();
} // install
@ -772,13 +753,14 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
}
else
{
glossytex = getUnicolorTexture(SColor(0, 0, 0, 0));
glossytex = stm->STKTexManager::getInstance()->getUnicolorTexture(SColor(0, 0, 0, 0));
}
if (!m->getTexture(2))
{
// Only set colorization mask if not set
ITexture *colorization_mask_tex = getUnicolorTexture(SColor(0, 0, 0, 0));
ITexture *colorization_mask_tex =
stm->STKTexManager::getInstance()->getUnicolorTexture(SColor(0, 0, 0, 0));
if (m_colorization_mask.size() > 0)
{
colorization_mask_tex = stm->getTexture(m_colorization_mask,
@ -897,7 +879,10 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
}
if (!m->getTexture(0))
m->setTexture(0, getUnicolorTexture(SColor(255, 255, 255, 255)));
{
m->setTexture(0,
stm->STKTexManager::getInstance()->getUnicolorTexture(SColor(255, 255, 255, 255)));
}
if (m_normal_map_tex.size() > 0)
{
@ -908,7 +893,7 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
true/*mesh_tex*/);
}
else
tex = getUnicolorTexture(SColor(0, 0, 0, 0));
tex = stm->STKTexManager::getInstance()->getUnicolorTexture(SColor(0, 0, 0, 0));
m->setTexture(3, tex);
// Material and shaders
@ -924,7 +909,7 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
if (m->getTexture(1) != glossytex)
m->setTexture(3, m->getTexture(1));
if (!m->getTexture(3))
m->setTexture(3, getUnicolorTexture(SColor(255, 255, 255, 255)));
m->setTexture(3, stm->STKTexManager::getInstance()->getUnicolorTexture(SColor(255, 255, 255, 255)));
}
m->setTexture(1, glossytex);
}

View File

@ -31,7 +31,6 @@
#include "graphics/shaders.hpp"
#include "graphics/shared_gpu_objects.hpp"
#include "graphics/stk_mesh_scene_node.hpp"
#include "graphics/texture_manager.hpp"
#include "graphics/weather.hpp"
#include "io/file_manager.hpp"
#include "karts/abstract_kart.hpp"
@ -380,7 +379,7 @@ public:
setTextureUnits(render_target_bloom_128,
render_target_bloom_256,
render_target_bloom_512,
getTextureGLuint(lensDustTex));
lensDustTex->getOpenGLTextureName());
drawFullScreenEffect();
} // render
}; // BloomBlendShader
@ -705,8 +704,7 @@ public:
GLuint rtt_mlaa_tmp)
{
use();
setTextureUnits(rtt_mlaa_tmp,
getTextureGLuint(area_map));
setTextureUnits(rtt_mlaa_tmp, area_map->getOpenGLTextureName());
drawFullScreenEffect(pixel_size);
} // render

View File

@ -35,7 +35,6 @@
#include "graphics/skybox.hpp"
#include "graphics/stk_mesh_scene_node.hpp"
#include "graphics/spherical_harmonics.hpp"
#include "graphics/texture_manager.hpp"
#include "items/item_manager.hpp"
#include "items/powerup_manager.hpp"
#include "modes/world.hpp"
@ -67,30 +66,6 @@ void ShaderBasedRenderer::setRTT(RTT* rtts)
}
} //setRTT
// ----------------------------------------------------------------------------
void ShaderBasedRenderer::compressPowerUpTextures()
{
for (unsigned i = 0; i < PowerupManager::POWERUP_MAX; i++)
{
scene::IMesh *mesh = powerup_manager->m_all_meshes[i];
if (!mesh)
continue;
for (unsigned j = 0; j < mesh->getMeshBufferCount(); j++)
{
scene::IMeshBuffer *mb = mesh->getMeshBuffer(j);
if (!mb)
continue;
for (unsigned k = 0; k < 4; k++)
{
video::ITexture *tex = mb->getMaterial().getTexture(k);
if (!tex)
continue;
compressTexture(tex, true);
}
}
}
} //compressPowerUpTextures
// ----------------------------------------------------------------------------
void ShaderBasedRenderer::setOverrideMaterial()
{
@ -696,8 +671,6 @@ void ShaderBasedRenderer::onLoadWorld()
size_t height = viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y;
RTT* rtts = new RTT(width, height);
setRTT(rtts);
compressPowerUpTextures();
}
// ----------------------------------------------------------------------------

View File

@ -54,7 +54,6 @@ private:
std::vector<GlowData> m_glowing;
size_t m_nb_static_glowing;
void compressPowerUpTextures();
void setOverrideMaterial();
void addItemsInGlowingList();

View File

@ -21,7 +21,7 @@
#include "graphics/show_curve.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/texture_manager.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "utils/vec3.hpp"
#include <IMeshSceneNode.h>
@ -67,9 +67,9 @@ void ShowCurve::addEmptyMesh()
m_mesh = irr_driver->createQuadMesh(&m,
/*create_one_quad*/ false);
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(2, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
m_buffer->getMaterial().setTexture(0, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(128, 255, 105, 180)));
m_buffer->getMaterial().setTexture(1, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
m_buffer->getMaterial().setTexture(2, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
assert(m_buffer->getVertexType()==video::EVT_STANDARD);
} // addEmptyMesh

View File

@ -23,7 +23,7 @@
#include "graphics/material.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/stk_mesh_scene_node.hpp"
#include "graphics/texture_manager.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "io/file_manager.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/controller/controller.hpp"
@ -102,7 +102,7 @@ SlipStream::SlipStream(AbstractKart* kart) : MovingTexture(0, 0), m_kart(kart)
video::SMaterial &mat = buffer->getMaterial();
// Meshes need a texture, otherwise stk crashes.
#ifndef SERVER_ONLY
video::ITexture *red_texture = getUnicolorTexture(red);
video::ITexture *red_texture = STKTexManager::getInstance()->getUnicolorTexture(red);
mat.setTexture(0, red_texture);
#endif

View File

@ -18,11 +18,9 @@
#include "graphics/stars.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/material.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/stk_texture.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/kart_model.hpp"
@ -42,20 +40,9 @@ Stars::Stars(AbstractKart *kart)
m_parent_kart_node = kart->getNode();
m_enabled = false;
video::ITexture* texture = NULL;
#ifndef SERVER_ONLY
if (CVS->isGLSL())
{
texture = STKTexManager::getInstance()->getTexture
("starparticle.png", true/*srgb*/, true/*premul_alpha*/,
false/*set_material*/, true/*mesh_tex*/);
}
else
#endif
{
texture =
irr_driver->getTexture("starparticle.png");
}
video::ITexture* texture = STKTexManager::getInstance()->getTexture
("starparticle.png", true/*srgb*/, true/*premul_alpha*/,
false/*set_material*/, true/*mesh_tex*/);
Material* star_material =
material_manager->getMaterial("starparticle.png");

View File

@ -25,6 +25,7 @@
#include "graphics/material_manager.hpp"
#include "graphics/materials.hpp"
#include "graphics/shaders.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "graphics/texture_manager.hpp"
#include <ISceneManager.h>
@ -389,7 +390,7 @@ static void setTexture(GLMesh &mesh, unsigned i, bool is_srgb,
mat_name.c_str());
// use unicolor texture to replace missing texture
mesh.textures[i] =
getUnicolorTexture(video::SColor(255, 127, 127, 127));
STKTexManager::getInstance()->getUnicolorTexture(video::SColor(255, 127, 127, 127));
}
compressTexture(mesh.textures[i], is_srgb);
#if !defined(USE_GLES2)
@ -479,7 +480,7 @@ void initTexturesTransparent(GLMesh &mesh)
{
if (!mesh.textures[0])
{
mesh.textures[0] = getUnicolorTexture(video::SColor(255, 255, 255, 255));
mesh.textures[0] = STKTexManager::getInstance()->getUnicolorTexture(video::SColor(255, 255, 255, 255));
}
compressTexture(mesh.textures[0], true);
#if !defined(USE_GLES2)

View File

@ -16,8 +16,6 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "graphics/stk_mesh_loader.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/stk_texture.hpp"
#include "graphics/stk_tex_manager.hpp"
#include <IVideoDriver.h>
@ -1042,7 +1040,6 @@ void STKMeshLoader::loadTextures(SB3dMaterial& material) const
SB3dTexture* B3dTexture = material.Textures[i];
if (B3dTexture && B3dTexture->TextureName.size() && !material.Material.getTexture(i))
{
video::ITexture* tex = NULL;
if (!SceneManager->getParameters()->getAttributeAsBool(scene::B3D_LOADER_IGNORE_MIPMAP_FLAG))
SceneManager->getVideoDriver()->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, (B3dTexture->Flags & 0x8) ? true:false);
io::IFileSystem* fs = SceneManager->getFileSystem();
@ -1060,18 +1057,11 @@ void STKMeshLoader::loadTextures(SB3dMaterial& material) const
else
full_path = fs->getFileBasename(B3dTexture->TextureName);
#ifndef SERVER_ONLY
if (CVS->isGLSL())
{
tex = STKTexManager::getInstance()->getTexture(full_path.c_str(),
i == 0 ? true : false/*is_srgb*/, false/*premul_alpha*/,
true/*set_material*/);
}
else
#endif // !SERVER_ONLY
{
tex = SceneManager->getVideoDriver()->getTexture(full_path);
}
video::ITexture* tex =
STKTexManager::getInstance()->getTexture(full_path.c_str(),
i == 0 ? true : false/*is_srgb*/, false/*premul_alpha*/,
true/*set_material*/);
material.Material.setTexture(i, tex);
if (material.Textures[i]->Flags & 0x10) // Clamp U
material.Material.TextureLayer[i].TextureWrapU=video::ETC_CLAMP;

View File

@ -69,9 +69,10 @@ STKTexture* STKTexManager::findTexturePathless(const std::string& filename)
} // findTexturePathless
// ----------------------------------------------------------------------------
STKTexture* STKTexManager::getTexture(const std::string& path, bool srgb,
bool premul_alpha, bool set_material,
bool mesh_tex, bool no_upload)
video::ITexture* STKTexManager::getTexture(const std::string& path, bool srgb,
bool premul_alpha,
bool set_material, bool mesh_tex,
bool no_upload)
{
auto ret = m_all_textures.find(path);
if (!no_upload && ret != m_all_textures.end())
@ -134,7 +135,7 @@ int STKTexManager::dumpTextureUsage()
} // dumpAllTexture
// ----------------------------------------------------------------------------
STKTexture* STKTexManager::getUnicolorTexture(const irr::video::SColor &c)
video::ITexture* STKTexManager::getUnicolorTexture(const irr::video::SColor &c)
{
std::string name = StringUtils::toString(c.color) + "unic";
auto ret = m_all_textures.find(name);

View File

@ -1,5 +1,5 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2016 SuperTuxKart-Team
// Copyright (C) 2017 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -29,7 +29,7 @@
class STKTexture;
namespace irr
{
namespace video { class SColor; }
namespace video { class ITexture; class SColor; }
}
class STKTexManager : public Singleton<STKTexManager>, NoCopy
@ -37,23 +37,25 @@ class STKTexManager : public Singleton<STKTexManager>, NoCopy
private:
std::unordered_map<std::string, STKTexture*> m_all_textures;
// ------------------------------------------------------------------------
STKTexture* findTexturePathless(const std::string& filename);
// ------------------------------------------------------------------------
STKTexture* findTextureInFileSystem(const std::string& filename,
std::string* full_path);
public:
// ------------------------------------------------------------------------
STKTexManager() {}
// ------------------------------------------------------------------------
~STKTexManager();
// ------------------------------------------------------------------------
STKTexture* findTexturePathless(const std::string& filename);
irr::video::ITexture* getTexture(const std::string& path,
bool srgb = false,
bool premul_alpha = false,
bool set_material = false,
bool mesh_tex = false,
bool no_upload = false);
// ------------------------------------------------------------------------
STKTexture* findTextureInFileSystem(const std::string& filename,
std::string* full_path);
// ------------------------------------------------------------------------
STKTexture* getTexture(const std::string& path, bool srgb = false,
bool premul_alpha = false,
bool set_material = false,
bool mesh_tex = false, bool no_upload = false);
// ------------------------------------------------------------------------
STKTexture* getUnicolorTexture(const irr::video::SColor &c);
irr::video::ITexture* getUnicolorTexture(const irr::video::SColor &c);
// ------------------------------------------------------------------------
void addTexture(STKTexture* t);
// ------------------------------------------------------------------------

View File

@ -22,7 +22,7 @@
#include "graphics/irr_driver.hpp"
#include "graphics/stk_billboard.hpp"
#include "graphics/stk_mesh_scene_node.hpp"
#include "graphics/texture_manager.hpp"
#include "graphics/stk_tex_manager.hpp"
#include <SMesh.h>
#include <SMeshBuffer.h>
#include <ISceneManager.h>
@ -123,8 +123,8 @@ scene::IMesh* STKTextBillboard::getTextMesh(core::stringw text, FontWithFace* fo
{
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(2, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
buffer->getMaterial().setTexture(1, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
buffer->getMaterial().setTexture(2, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
buffer->getMaterial().MaterialType = Shaders::getShader(ES_OBJECT_UNLIT);
buffers[m_chars[i].m_texture] = buffer;
}

View File

@ -39,6 +39,10 @@ STKTexture::STKTexture(const std::string& path, bool srgb, bool premul_alpha,
m_material = material_manager->getMaterialFor(this);
m_mesh_texture = true;
}
#ifndef SERVER_ONLY
if (!CVS->isGLSL())
m_srgb = false;
#endif
reload(no_upload);
} // STKTexture
@ -113,15 +117,19 @@ void STKTexture::reload(bool no_upload, video::IImage* pre_loaded_tex)
video::IImage* new_texture = NULL;
if (pre_loaded_tex == NULL)
{
new_texture = convertImage(&orig_img);
new_texture = resizeImage(orig_img, &m_orig_size, &m_size);
applyMask(new_texture);
}
else
{
new_texture = pre_loaded_tex;
m_orig_size = pre_loaded_tex->getDimension();
m_size = pre_loaded_tex->getDimension();
}
unsigned char* data = (unsigned char*)new_texture->lock();
const unsigned int w = new_texture->getDimension().Width;
const unsigned int h = new_texture->getDimension().Height;
const unsigned int w = m_size.Width;
const unsigned int h = m_size.Height;
unsigned int format = GL_BGRA;
unsigned int internal_format = GL_RGBA;
@ -172,30 +180,24 @@ void STKTexture::reload(bool no_upload, video::IImage* pre_loaded_tex)
glBindTexture(GL_TEXTURE_2D, m_texture_name);
if (!reload)
{
glTexImage2D(GL_TEXTURE_2D, 0, internal_format,
new_texture->getDimension().Width,
new_texture->getDimension().Height, 0, format,
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, w, h, 0, format,
GL_UNSIGNED_BYTE, data);
}
else
{
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
new_texture->getDimension().Width,
new_texture->getDimension().Height, format, GL_UNSIGNED_BYTE,
data);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, format,
GL_UNSIGNED_BYTE, data);
}
new_texture->unlock();
glGenerateMipmap(GL_TEXTURE_2D);
if (hasMipMaps())
glGenerateMipmap(GL_TEXTURE_2D);
}
m_size = new_texture->getDimension();
m_orig_size = orig_img->getDimension();
orig_img->drop();
m_texture_size = m_size.Width * m_size.Height * 4 /*BRGA*/;
if (!no_upload && pre_loaded_tex == NULL)
new_texture->drop();
else if (pre_loaded_tex == NULL)
m_texture_size = w * h * 4 /*BRGA*/;
if (no_upload)
m_texture_image = new_texture;
else
new_texture->drop();
if (!compressed_texture.empty())
saveCompressedTexture(compressed_texture);
@ -207,66 +209,70 @@ void STKTexture::reload(bool no_upload, video::IImage* pre_loaded_tex)
} // reload
// ----------------------------------------------------------------------------
video::IImage* STKTexture::convertImage(video::IImage** orig_img)
video::IImage* STKTexture::resizeImage(video::IImage* orig_img,
core::dimension2du* new_img_size,
core::dimension2du* new_tex_size)
{
#ifndef SERVER_ONLY
video::IImage* image = *orig_img;
core::dimension2du size = image->getDimension();
video::IImage* image = orig_img;
const core::dimension2du& old_size = image->getDimension();
core::dimension2du img_size = old_size;
bool scale_image = false;
const float ratio = float(size.Width) / float(size.Height);
const float ratio = float(img_size.Width) / float(img_size.Height);
const unsigned int drv_max_size =
irr_driver->getVideoDriver()->getMaxTextureSize().Width;
if ((size.Width > drv_max_size) && (ratio >= 1.0f))
if ((img_size.Width > drv_max_size) && (ratio >= 1.0f))
{
size.Width = drv_max_size;
size.Height = (unsigned)(drv_max_size / ratio);
scale_image = true;
img_size.Width = drv_max_size;
img_size.Height = (unsigned)(drv_max_size / ratio);
}
else if (size.Height > drv_max_size)
else if (img_size.Height > drv_max_size)
{
size.Height = drv_max_size;
size.Width = (unsigned)(drv_max_size * ratio);
scale_image = true;
img_size.Height = drv_max_size;
img_size.Width = (unsigned)(drv_max_size * ratio);
}
if (scale_image)
if (img_size != old_size)
{
video::IImage* new_img = irr_driver->getVideoDriver()
->createImage(video::ECF_A8R8G8B8, size);
->createImage(video::ECF_A8R8G8B8, img_size);
image->copyToScaling(new_img);
image->drop();
image = new_img;
*orig_img = new_img;
}
bool scale_texture = false;
size = size.getOptimalSize
core::dimension2du tex_size = img_size.getOptimalSize
(!irr_driver->getVideoDriver()->queryFeature(video::EVDF_TEXTURE_NPOT));
const core::dimension2du& max_size = irr_driver->getVideoDriver()
->getDriverAttributes().getAttributeAsDimension2d("MAX_TEXTURE_SIZE");
if (max_size.Width > 0 && size.Width > max_size.Width)
if (max_size.Width > 0 && tex_size.Width > max_size.Width)
tex_size.Width = max_size.Width;
if (max_size.Height > 0 && tex_size.Height > max_size.Height)
tex_size.Height = max_size.Height;
if (image->getColorFormat() != video::ECF_A8R8G8B8 ||
tex_size != img_size)
{
size.Width = max_size.Width;
scale_texture = true;
}
if (max_size.Height > 0 && size.Height > max_size.Height)
{
size.Height = max_size.Height;
scale_texture = true;
video::IImage* new_texture = irr_driver
->getVideoDriver()->createImage(video::ECF_A8R8G8B8, tex_size);
if (tex_size != img_size)
image->copyToScaling(new_texture);
else
image->copyTo(new_texture);
image->drop();
image = new_texture;
}
video::IImage* new_texture =
irr_driver->getVideoDriver()->createImage(video::ECF_A8R8G8B8, size);
if (scale_texture)
image->copyToScaling(new_texture);
else
image->copyTo(new_texture);
return new_texture;
if (new_img_size && new_tex_size)
{
*new_img_size = img_size;
*new_tex_size = tex_size;
}
return image;
#endif // !SERVER_ONLY
} // convertImage
} // resizeImage
// ----------------------------------------------------------------------------
void STKTexture::applyMask(video::IImage* orig_img)
@ -274,16 +280,15 @@ void STKTexture::applyMask(video::IImage* orig_img)
#ifndef SERVER_ONLY
if (m_material && !m_material->getAlphaMask().empty())
{
video::IImage* tmp_mask = irr_driver->getVideoDriver()
video::IImage* converted_mask = irr_driver->getVideoDriver()
->createImageFromFile(m_material->getAlphaMask().c_str());
if (tmp_mask == NULL)
if (converted_mask == NULL)
{
Log::warn("STKTexture", "Applying mask failed for '%s'!",
m_material->getAlphaMask().c_str());
return;
}
video::IImage* converted_mask = convertImage(&tmp_mask);
tmp_mask->drop();
converted_mask = resizeImage(converted_mask);
if (converted_mask->lock())
{
core::dimension2d<u32> dim = orig_img->getDimension();
@ -298,6 +303,7 @@ void STKTexture::applyMask(video::IImage* orig_img)
} // for y
} // for x
}
converted_mask->unlock();
converted_mask->drop();
}
#endif // !SERVER_ONLY
@ -409,3 +415,13 @@ std::string STKTexture::getHashedName(const std::string& orig_file)
hash << std::hex << hash_1 << hash_2 << max_size.Height;
return result + hash.str() + ".stktz";
} // getHashedName
//-----------------------------------------------------------------------------
bool STKTexture::hasMipMaps() const
{
#ifndef SERVER_ONLY
return CVS->getGLSLVersion() >= 130;
#else
return false;
#endif // !SERVER_ONLY
} // hasMipMaps

View File

@ -46,7 +46,9 @@ private:
video::IImage* m_texture_image;
// ------------------------------------------------------------------------
video::IImage* convertImage(video::IImage** orig_img);
video::IImage* resizeImage(video::IImage* orig_img,
core::dimension2du* new_img_size = NULL,
core::dimension2du* new_tex_size = NULL);
// ------------------------------------------------------------------------
void applyMask(video::IImage* orig_img);
// ------------------------------------------------------------------------
@ -99,6 +101,8 @@ public:
// ------------------------------------------------------------------------
virtual u32 getPitch() const { return 0; }
// ------------------------------------------------------------------------
virtual bool hasMipMaps() const;
// ------------------------------------------------------------------------
virtual void regenerateMipMapLevels(void* mipmap_data = NULL) {}
// ------------------------------------------------------------------------
virtual u32 getOpenGLTextureName() const { return m_texture_name; }

View File

@ -17,12 +17,13 @@
#ifndef SERVER_ONLY
#include "graphics/texture_manager.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/materials.hpp"
#include "graphics/stk_texture.hpp"
#include "graphics/texture_manager.hpp"
#include "utils/string_utils.hpp"
#if defined(USE_GLES2)
@ -244,34 +245,6 @@ void saveCompressedTexture(const std::string& compressed_tex)
#endif
}
video::ITexture* getUnicolorTexture(const video::SColor &c)
{
std::map<int, video::ITexture*>::iterator it = unicolor_cache.find(c.color);
if (it != unicolor_cache.end())
{
return it->second;
}
else
{
unsigned tmp[4] = {
c.color,
c.color,
c.color,
c.color
};
video::IImage *img = irr_driver->getVideoDriver()->createImageFromData(video::ECF_A8R8G8B8, core::dimension2d<u32>(2, 2), tmp);
std::stringstream name;
name << "color" << c.color;
video::ITexture* tex = irr_driver->getVideoDriver()->addTexture(name.str().c_str(), img);
tex->grab();
// Only let our map hold the unicolor texture
irr_driver->getVideoDriver()->removeTexture(tex);
unicolor_cache[c.color] = tex;
img->drop();
return tex;
}
}
core::stringw reloadTexture(const core::stringw& name)
{
if (!CVS->isGLSL())

View File

@ -32,7 +32,6 @@ void cleanUnicolorTextures();
void compressTexture(irr::video::ITexture *tex, bool srgb, bool premul_alpha = false);
bool loadCompressedTexture(const std::string& compressed_tex);
void saveCompressedTexture(const std::string& compressed_tex);
irr::video::ITexture* getUnicolorTexture(const irr::video::SColor &c);
void insertTextureHandle(uint64_t handle);
bool reloadSingleTexture(irr::video::ITexture *tex);
irr::core::stringw reloadTexture(const irr::core::stringw& name);

View File

@ -23,7 +23,7 @@
#include "graphics/irr_driver.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/stk_mesh_scene_node.hpp"
#include "graphics/texture_manager.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "items/plunger.hpp"
#include "items/projectile_manager.hpp"
#include "karts/abstract_kart.hpp"
@ -69,11 +69,11 @@ RubberBand::RubberBand(Plunger *plunger, AbstractKart *kart)
#ifndef SERVER_ONLY
// Color
mb->getMaterial().setTexture(0, getUnicolorTexture(video::SColor(255, 255, 255, 255)));
mb->getMaterial().setTexture(0, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(255, 255, 255, 255)));
// Gloss
mb->getMaterial().setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
mb->getMaterial().setTexture(1, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
// Colorization mask
mb->getMaterial().setTexture(2, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
mb->getMaterial().setTexture(2, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
#endif
updatePosition();
m_node = irr_driver->addMesh(m_mesh, "rubberband");

View File

@ -23,7 +23,7 @@
#ifdef AI_DEBUG
# include "graphics/irr_driver.hpp"
# include "graphics/texture_manager.hpp"
# include "graphics/stk_tex_manager.hpp"
#endif
#include "graphics/show_curve.hpp"
#include "graphics/slip_stream.hpp"
@ -95,8 +95,8 @@ SkiddingAI::SkiddingAI(AbstractKart *kart)
i==2 ? 128 : 0);
m_debug_sphere[i] = irr_driver->addSphere(1.0f, col_debug);
m_debug_sphere[i]->setVisible(false);
m_debug_sphere[i]->setMaterialTexture(0, getUnicolorTexture(video::SColor(128, 255, 105, 180)));
m_debug_sphere[i]->setMaterialTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
m_debug_sphere[i]->setMaterialTexture(0, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(128, 255, 105, 180)));
m_debug_sphere[i]->setMaterialTexture(1, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
}
m_debug_sphere[m_point_selection_algorithm]->setVisible(true);
m_item_sphere = irr_driver->addSphere(1.0f, video::SColor(255, 0, 255, 0));

View File

@ -23,7 +23,7 @@
#ifdef AI_DEBUG
# include "graphics/irr_driver.hpp"
# include "graphics/texture_manager.hpp"
# include "graphics/stk_tex_manager.hpp"
#endif
#include "graphics/show_curve.hpp"
#include "graphics/slip_stream.hpp"
@ -101,8 +101,8 @@ SkiddingAI::SkiddingAI(AbstractKart *kart)
i==2 ? 128 : 0);
m_debug_sphere[i] = irr_driver->addSphere(1.0f, col_debug);
m_debug_sphere[i]->setVisible(false);
m_debug_sphere[i]->setMaterialTexture(0, getUnicolorTexture(video::SColor(128, 255, 105, 180)));
m_debug_sphere[i]->setMaterialTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
m_debug_sphere[i]->setMaterialTexture(0, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(128, 255, 105, 180)));
m_debug_sphere[i]->setMaterialTexture(1, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
}
m_debug_sphere[m_point_selection_algorithm]->setVisible(true);
m_item_sphere = irr_driver->addSphere(1.0f, video::SColor(255, 0, 255, 0));

View File

@ -23,7 +23,7 @@
#include "config/player_manager.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/texture_manager.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "io/file_manager.hpp"
#include "karts/cached_characteristic.hpp"
#include "karts/combined_characteristic.hpp"
@ -252,7 +252,7 @@ void KartProperties::load(const std::string &filename, const std::string &node)
#ifndef SERVER_ONLY
if (m_minimap_icon == NULL)
{
m_minimap_icon = getUnicolorTexture(m_color);
m_minimap_icon = STKTexManager::getInstance()->getUnicolorTexture(m_color);
}
#endif

View File

@ -26,7 +26,6 @@
#include "graphics/irr_driver.hpp"
#include "graphics/render_info.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "graphics/stk_texture.hpp"
#include "karts/kart.hpp"
#include "karts/kart_model.hpp"
#include "karts/kart_properties.hpp"
@ -327,38 +326,18 @@ void SoccerWorld::initKartList()
const unsigned int kart_amount = (unsigned int)m_karts.size();
//Loading the indicator textures
video::ITexture* red = NULL;
video::ITexture* blue = NULL;
std::string red_path =
file_manager->getAsset(FileManager::GUI, "soccer_player_red.png");
std::string blue_path =
file_manager->getAsset(FileManager::GUI, "soccer_player_blue.png");
#ifndef SERVER_ONLY
if (CVS->isGLSL())
{
red = STKTexManager::getInstance()->getTexture
(red_path, true/*srgb*/, true/*premul_alpha*/,
false/*set_material*/, true/*mesh_tex*/);
}
else
#endif
{
red = irr_driver->getTexture(red_path);
}
video::ITexture* red = STKTexManager::getInstance()->getTexture
(red_path, true/*srgb*/, true/*premul_alpha*/, false/*set_material*/,
true/*mesh_tex*/);
#ifndef SERVER_ONLY
if (CVS->isGLSL())
{
blue = STKTexManager::getInstance()->getTexture
(blue_path, true/*srgb*/, true/*premul_alpha*/,
false/*set_material*/, true/*mesh_tex*/);
}
else
#endif
{
blue = irr_driver->getTexture(blue_path);
}
video::ITexture* blue = STKTexManager::getInstance()->getTexture
(blue_path, true/*srgb*/, true/*premul_alpha*/, false/*set_material*/,
true/*mesh_tex*/);
//Assigning indicators
for(unsigned int i = 0; i < kart_amount; i++)

View File

@ -21,10 +21,8 @@
#include "audio/music_manager.hpp"
#include "config/user_config.hpp"
#include "graphics/camera.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "graphics/stk_texture.hpp"
#include "io/file_manager.hpp"
#include "karts/kart.hpp"
#include "karts/controller/spare_tire_ai.hpp"
@ -181,19 +179,9 @@ void ThreeStrikesBattle::kartAdded(AbstractKart* kart, scene::ISceneNode* node)
// Add heart billboard above it
std::string heart_path =
file_manager->getAsset(FileManager::GUI, "heart.png");
video::ITexture* heart = NULL;
#ifndef SERVER_ONLY
if (CVS->isGLSL())
{
heart = STKTexManager::getInstance()->getTexture
(heart_path, true/*srgb*/, true/*premul_alpha*/,
false/*set_material*/, true/*mesh_tex*/);
}
else
#endif
{
heart = irr_driver->getTexture(heart_path);
}
video::ITexture* heart = STKTexManager::getInstance()->getTexture
(heart_path, true/*srgb*/, true/*premul_alpha*/,
false/*set_material*/, true/*mesh_tex*/);
float height = kart->getKartHeight() + 0.5f;

View File

@ -20,7 +20,7 @@
#include "config/user_config.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/texture_manager.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "io/xml_node.hpp"
#include "karts/abstract_kart.hpp"
#include "modes/linear_world.hpp"
@ -103,9 +103,9 @@ CheckLine::CheckLine(const XMLNode &node, unsigned int index)
: video::SColor(128, 128, 128, 128);
}
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(2, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
buffer->getMaterial().setTexture(0, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(128, 255, 105, 180)));
buffer->getMaterial().setTexture(1, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
buffer->getMaterial().setTexture(2, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
buffer->getMaterial().BackfaceCulling = false;
//mesh->setBoundingBox(buffer->getBoundingBox());
m_debug_node = irr_driver->addMesh(mesh, "checkdebug");
@ -153,7 +153,7 @@ void CheckLine::changeDebugColor(bool is_active)
vertices[i].Color = color;
}
#ifndef SERVER_ONLY
buffer->getMaterial().setTexture(0, getUnicolorTexture(color));
buffer->getMaterial().setTexture(0, STKTexManager::getInstance()->getUnicolorTexture(color));
#endif
} // changeDebugColor

View File

@ -21,7 +21,7 @@
#include "config/user_config.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/render_target.hpp"
#include "graphics/texture_manager.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "graphics/vao_manager.hpp"
#include "modes/profile_world.hpp"
#include "tracks/arena_node_3d.hpp"
@ -108,9 +108,9 @@ void Graph::createMesh(bool show_invisible, bool enable_transparency,
m.Lighting = false;
if (enable_transparency)
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(2, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
m.setTexture(0, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(255, 255, 255, 255)));
m.setTexture(1, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
m.setTexture(2, STKTexManager::getInstance()->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

@ -39,7 +39,6 @@
#include "graphics/particle_kind.hpp"
#include "graphics/particle_kind_manager.hpp"
#include "graphics/render_target.hpp"
#include "graphics/stk_texture.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "graphics/texture_manager.hpp"
#include "graphics/vao_manager.hpp"
@ -810,14 +809,14 @@ void Track::createPhysicsModel(unsigned int main_track_count)
// Color
#ifndef SERVER_ONLY
mb->getMaterial().setTexture(0, getUnicolorTexture(video::SColor(255, 255, 105, 180)));
mb->getMaterial().setTexture(0, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(255, 255, 105, 180)));
#endif
irr_driver->grabAllTextures(mesh);
// Gloss
#ifndef SERVER_ONLY
mb->getMaterial().setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
mb->getMaterial().setTexture(1, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
// Colorization mask
mb->getMaterial().setTexture(2, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
mb->getMaterial().setTexture(2, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
#endif
}
else

View File

@ -832,20 +832,9 @@ TrackObjectPresentationBillboard::TrackObjectPresentationBillboard(
xml_node.get("start", &m_fade_out_start);
xml_node.get("end", &m_fade_out_end );
}
video::ITexture* texture = NULL;
#ifndef SERVER_ONLY
if (CVS->isGLSL())
{
texture = STKTexManager::getInstance()->getTexture
(file_manager->searchTexture(texture_name), true/*srgb*/,
true/*premul_alpha*/, false/*set_material*/, true/*mesh_tex*/);
}
else
#endif
{
texture =
irr_driver->getTexture(file_manager->searchTexture(texture_name));
}
video::ITexture* texture = STKTexManager::getInstance()->getTexture
(file_manager->searchTexture(texture_name), true/*srgb*/,
true/*premul_alpha*/, false/*set_material*/, true/*mesh_tex*/);
if (texture == NULL)
{