I have a buffer (char*) in BGRA that i need to create a sf::Texture of.
I have a sprite that uses sprite.setTexture(renderedTexture) that gets the texture from this:
sf::Texture texture;
Awesomium::BitmapSurface* bitmap = (Awesomium::BitmapSurface*)m_views[name]->surface();
texture.create(bitmap->width(), bitmap->height());
sf::Uint8* rgba = new sf::Uint8[bitmap->width() * bitmap->height() * 4];
for(int i = 0; i < bitmap->width() * bitmap->height(); i++)
{
rgba[(i * 4)] = bitmap->buffer()[(i * 4) + 2];
rgba[(i * 4) + 1] = bitmap->buffer()[(i * 4) + 1];
rgba[(i * 4) + 2] = bitmap->buffer()[(i * 4)];
rgba[(i * 4) + 3] = bitmap->buffer()[(i * 4) + 3];
}
texture.update(rgba);
return texture;
The texture seems to render in the correct size, but all white.
EDIT: I didn't store the texture properly so it was invalidated.