Prototype:
Code: Select all
ITexture* addTextureFromSColor(IVideoDriver* driver, SColor& color, c8* name, dimension2di& size = dimension2di(512,512));Code: Select all
ITexture* CResourceManager::addTextureFromSColor(IVideoDriver* driver, SColor& color, c8* name, dimension2di& size)
{
ITexture* texture = driver->addTexture(size, name, ECF_A8R8G8B8);
// Get pointer to texture data which in this case is basicly array of u32 values,
// a cast is needed since the method returns void pointer, however we already
// know the color format and thus what to cast to.
u32* p = (u32*)texture->lock();
// Now use that pointer to acces array
for(s32 i=0; i < texture->getSize().Width * texture->getSize().Height; i++)
{
p[i] = color.color; // color member is the color in A8R8G8B8 Format
}
// Now unlock texture
texture->unlock();
return texture;
}Code: Select all
ITexture* blackTexture = addTextureFromSColor(m_pVideoDriver ,SColor(255,0,0,0), "BlackTexture");
m_pSceneManager->addSkyBoxSceneNode(
blackTexture,
blackTexture,
blackTexture,
blackTexture,
blackTexture,
blackTexture);