Here are the quick ones:
- OS: Windows 7 64-bit Home Edition
- GFX: ATi Radeon 6970
- SFML Version: Using SFML 2.0
- Dynamic or Static: Static
For some reason the Texture that I try to draw won't show up on screen.
My theory is that I point to a place in memory that is out of scope before usage. But I don't really know how to solve this. One solution might be to somehow use Smart Pointers but that didn't work out at all and there must be a more simple solution than this.
I am currently following a slightly out of date tutorial on how to make a simple Tile Engine with SFML 2.0 . In the tutorial he uses the Image type instead of Texture, but the problem I had with that, was that Image didn't have a Draw() method. So I switch it out for Textures. I am not sure if this would be the problem.
I don't get any errors, the texture just won't render on screen.
Here are the relevant bits from Engine.cpp:
bool Engine::Init()
{
LoadTextures();
window = new sf::RenderWindow(sf::VideoMode(800,600,32), "RPG");
if(!window)
return false;
return true;
}
void Engine::LoadTextures()
{
sf::Texture sprite;
sprite.loadFromFile("C:\\Users\\Vipar\\Pictures\\sprite1.png");
textureManager.AddTexture(sprite);
testTile = new Tile(textureManager.GetTexture(0));
}
void Engine::RenderFrame()
{
window->clear();
testTile->Draw(0,0,window);
window->display();
}
void Engine::MainLoop()
{
//Loop until our window is closed
while(window->isOpen())
{
ProcessInput();
Update();
RenderFrame();
}
}
Bits from TextureManager.cpp
void TextureManager::AddTexture(sf::Texture texture)
{
textureList.push_back(texture);
}
sf::Texture& TextureManager::GetTexture(int index)
{
return textureList[index];
}
Tried to solve this for a little over 2 hours now.