Sure, on each game loop's draw command the following takes place:
void VideoManager::Draw(){
std::lock_guard<std::mutex> lk(videoMutex);
// Clear screen
Game.Application->clear();
Game.CurrentMap->Draw();
Game.Application->display();
for(unsigned i=0;i<RenderQueue.size();++i) {
if(RenderQueue[i]){
RenderQueue[i]->Draw();
}
}
if(consoleView->Visible()){
consoleView->Draw();
}
// Finally, display the rendered frame on screen
Game.Application->display();
}
Where RenderQueue is a vector of SSprites, which are shared pointers to my classes that implement drawing. One of these is the control shown above in the screenshot, that draws tiled images.
On the create method it currently defines some hard coded values, all of the images referenced exist, so the problem's not to do with that:
//Create our section data
std::vector<MapSection> sectionRow;
MapSection section;
//Create a fake tileset with our debug tiles
Tileset[0] = Data.TextureResourceWithID("Data/Map/BlankTile.png");
Tileset[1] = Data.TextureResourceWithID("Data/Map/DebugTile.png");
Tileset[2] = Data.TextureResourceWithID("Data/Map/BlockedTile.png");
//Fill our section data with tiles
for(int X = 0; X < SECTION_TILE_COUNT_X; X++){
std::vector<int> currentRow;
for(int Y=0; Y < SECTION_TILE_COUNT_Y; Y++){
currentRow.push_back(2);
}
section.Tiles.push_back(currentRow);
}
//Set up our data
currentSectionX = 0;
currentSectionY = 0;
currentX = 0;
currentY = 0;
sectionRow.push_back(section);
Sections.push_back(sectionRow);
//Finally assign our Sprite & Texture, and refresh the view
MapTexture.create(Video.GetScreenDimensions().width+TILE_WIDTH,Video.GetScreenDimensions().height+TILE_HEIGHT);
MapSprite = sf::Sprite(MapTexture.getTexture());
MapSprite.setPosition(-TILE_WIDTH, -TILE_HEIGHT);
the Draw command firstly calls Refresh, and then calls the RenderWindow's Draw command, pointing it to the MapSprite sprite:
Game.Application->draw(MapSprite);
The Refresh command looks like this:
void Map::Refresh(){
MapTexture.clear(sf::Color::Transparent);
MapTexture.display();
for(int X = 0 - TILE_WIDTH; X < SECTION_TILE_COUNT_X; X++){
for(int Y=0 - TILE_HEIGHT; Y < SECTION_TILE_COUNT_Y; Y++){
sf::Texture *tex = Tileset[2].get();
tileBlitter = sf::Sprite(*tex);
tileBlitter.setPosition(X*TILE_WIDTH, Y*TILE_HEIGHT);
MapTexture.draw(tileBlitter);
}
}
MapTexture.display();
}
I should note that yes I know calling refresh on every draw is expensive, but it's the only way to ever get anything more than garbage displaying for this view.
I've used an identical method for another view and that seems to work fine, I think it might be my reuse of sprites, but I did remember trying creating a new sprite to draw each tile during the loop and that didn't help either. Does SFML require sprites to exist after the data is rendered to the texture?