1
Graphics / failed to draw sprites stored in a class.
« on: June 18, 2011, 06:48:59 pm »
Just to state this if it wasn't clear, the image was never drawn to the screen.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
The Valgrind output is ok, don't worry about it.
The debugger output would be more helpfulQuoteI'm using sfml2.
Which revision?
#include <SFML/Graphics.hpp>
class GameVars {
public:
GameVars() {
titleImage.LoadFromFile("title.png");
titleSprite.SetImage(titleImage);
titleSprite.SetPosition(0,0);
}
sf::Sprite titleSprite;
sf::Image titleImage;
};
int main() {
GameVars gamevars;
sf::RenderWindow window(sf::VideoMode(320, 200), "tppxx");
while(window.IsOpened()) {
// process events
sf::Event event;
while(window.PollEvent(event)) {
// close window
if(event.Type == sf::Event::Closed) {
// close the window
window.Close();
}
}
// clear screen
window.Clear();
window.Draw(gamevars.titleSprite);
// update window
window.Display();
}
return EXIT_SUCCESS;
}