1
Graphics / failed to draw sprites stored in a class.
« on: June 18, 2011, 04:50:01 pm »
I can't seem to figure out what should be a simple example.
I'm using sfml2.
Running the following code will return 1 in the bash prompt.
it immediately returns 1, and running it through valgrind produces:
==10707== Conditional jump or move depends on uninitialised value(s)
==10707== at 0x4E543DE: sf::Renderer::SetShader(sf::Shader const*) (in /usr/lib/libsfml-graphics.so.2.0)
==10707== by 0x4E553EB: sf::RenderTarget::Draw(sf::Drawable const&) (in /usr/lib/libsfml-graphics.so.2.0)
==10707== by 0x401583: main (in /home/tom/The-Puzzle-Pits/tppxx/test)
==10707==
==10707== Conditional jump or move depends on uninitialised value(s)
==10707== at 0x4E54229: sf::Renderer::SetBlendMode(sf::Blend::Mode) (in /usr/lib/libsfml-graphics.so.2.0)
==10707== by 0x4E3BC82: sf::Drawable::Draw(sf::RenderTarget&, sf::Renderer&) const (in /usr/lib/libsfml-graphics.so.2.0)
==10707== by 0x4E553F9: sf::RenderTarget::Draw(sf::Drawable const&) (in /usr/lib/libsfml-graphics.so.2.0)
==10707== by 0x401583: main (in /home/tom/The-Puzzle-Pits/tppxx/test)
==10707==
==10707== Conditional jump or move depends on uninitialised value(s)
==10707== at 0x4E5432E: sf::Renderer::SetTexture(sf::Image const*) (in /usr/lib/libsfml-graphics.so.2.0)
==10707== by 0x4E58CB1: sf::Sprite::Render(sf::RenderTarget&, sf::Renderer&) const (in /usr/lib/libsfml-graphics.so.2.0)
==10707== by 0x4E553F9: sf::RenderTarget::Draw(sf::Drawable const&) (in /usr/lib/libsfml-graphics.so.2.0)
==10707== by 0x401583: main (in /home/tom/The-Puzzle-Pits/tppxx/test)
I'm using sfml2.
Running the following code will return 1 in the bash prompt.
Code: [Select]
#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;
}
it immediately returns 1, and running it through valgrind produces:
==10707== Conditional jump or move depends on uninitialised value(s)
==10707== at 0x4E543DE: sf::Renderer::SetShader(sf::Shader const*) (in /usr/lib/libsfml-graphics.so.2.0)
==10707== by 0x4E553EB: sf::RenderTarget::Draw(sf::Drawable const&) (in /usr/lib/libsfml-graphics.so.2.0)
==10707== by 0x401583: main (in /home/tom/The-Puzzle-Pits/tppxx/test)
==10707==
==10707== Conditional jump or move depends on uninitialised value(s)
==10707== at 0x4E54229: sf::Renderer::SetBlendMode(sf::Blend::Mode) (in /usr/lib/libsfml-graphics.so.2.0)
==10707== by 0x4E3BC82: sf::Drawable::Draw(sf::RenderTarget&, sf::Renderer&) const (in /usr/lib/libsfml-graphics.so.2.0)
==10707== by 0x4E553F9: sf::RenderTarget::Draw(sf::Drawable const&) (in /usr/lib/libsfml-graphics.so.2.0)
==10707== by 0x401583: main (in /home/tom/The-Puzzle-Pits/tppxx/test)
==10707==
==10707== Conditional jump or move depends on uninitialised value(s)
==10707== at 0x4E5432E: sf::Renderer::SetTexture(sf::Image const*) (in /usr/lib/libsfml-graphics.so.2.0)
==10707== by 0x4E58CB1: sf::Sprite::Render(sf::RenderTarget&, sf::Renderer&) const (in /usr/lib/libsfml-graphics.so.2.0)
==10707== by 0x4E553F9: sf::RenderTarget::Draw(sf::Drawable const&) (in /usr/lib/libsfml-graphics.so.2.0)
==10707== by 0x401583: main (in /home/tom/The-Puzzle-Pits/tppxx/test)