Having a hell of a time getting this PNG to draw. Certain code blips have gotten it to draw in the past, but I've since re-written a large portion of the code and it's refusing to work. I've followed all the tutorials and looked at a ton of issues posted on the forum. The code just seems right, but it won't work.
Png class that extends `sf::Sprite`
RGPng::RGPng(string path)
{
// Store
_path = path;
//setPosition(0, 0);
// Create image
if(!_image.loadFromFile(path))
{
// Throw
throw new RException("Could not load PNG image '%s'", path.c_str());
}
// Create texture
_tex.loadFromImage(_image);
// Load into sprite
setTexture(_tex, true);
sf::IntRect r = getTextureRect(); // Confirmed; 0,0, correct w, correct h
}
Code that extends another drawable (debugging confirms this is being called)
RGPng* png; // = new RGPng("test.png");
// The SFML 'draw(target,states)' method calls this.
void OnDraw(sf::RenderTarget& target, sf::RenderStates states) const
{
target.draw(*png);
}
And then the window's draw code (which eventually draws the above object)
void Draw()
{
// Are we open?
if(!isOpen() || !this) return;
// Draw
setActive(true);
pushGLStates();
clear(_(RIT_THEME, R_THEME)->Window.BaseColor);
draw(*_manager);
display();
popGLStates();
setActive(false);
}
Fraps is confirming I have ~30 FPS, so it's definitely being updated. I've also successfully drawn a simple triangle to the window using the same architecture in my program. Everything works fine up until I try to get this PNG to display.
Again,
This PNG has worked just fine with SFML in past versions of the code before the engine was re-written.
Am I missing a fundamental idea behind the texture/sprite system? Am I missing a step?