Hello.
I am currently trying to find a workaround for my problem with Code::Blocks vs Visual studio.
Am running these codes in IDEs and i get results:
Code::Blocks
void Map::DrawMap(Application& objApp)
{
sf::RenderWindow& Screen = objApp.objWindow.Screen;
int TilesetWidth = objApp.objTextures.TileSheet.getSize().x / TILESIZE;
int Layer2Width = objApp.objTextures.Layer2.getSize().x / TILESIZE;
int TileID = 0;
for(int y = 0; y < MAPSIZE_Y; y++)
{
for(int x = 0; x < MAPSIZE_X; x++)
{
//Tile
sprTile.setTextureRect(sf::IntRect(((TileList[TileID].Layer1 - 1) % TilesetWidth) * TILESIZE,
((TileList[TileID].Layer1 - 1) / TilesetWidth) * TILESIZE, 32 ,32));
sprTile.setPosition(x * TILESIZE, y * TILESIZE);
Screen.draw(sprTile);
//Layer2
if(TileList[TileID].Layer2 > 0) // There is something to be drawn
{
//-1 for Layer2 to grab correct Layer2 icon, so no space is wasted
sprLayer2.setTextureRect(sf::IntRect(((TileList[TileID].Layer2 - 1) % Layer2Width) * TILESIZE,
((TileList[TileID].Layer2 - 1) / Layer2Width) * TILESIZE, 32, 32));
sprLayer2.setPosition(x * TILESIZE, y * TILESIZE);
Screen.draw(sprLayer2);
}
TileID ++;
}
}
}
This is like 1/2 performance of whole program of my per loop for Code::Blocks and i get around 600FPS // when i don't call this function i get around 800-900 fps
Visual studio 2010
void Map::DrawMap(Textures& objTex, sf::RenderWindow& renWin, Camera& objCam)
{
int TileID = 0;
int TilesetWidth = objTex.Global_TileSheet1.getSize().x / TILE_SIZE;
int Layer2Width = objTex.Global_TileSheet2.getSize().x / TILE_SIZE;
int offsetX = objCam.cameraX % TILE_SIZE;
int offsetY = objCam.cameraY % TILE_SIZE;
sprTile.setTextureRect(sf::IntRect((TileList[TileID].Layer1 % TilesetWidth) * TILE_SIZE, (TileList[TileID].Layer1 / TilesetWidth) * TILE_SIZE, 32 ,32));
sprTile.setPosition(32 * TILE_SIZE - offsetX, 364 * TILE_SIZE - offsetY);
sprTile2.setTextureRect(sf::IntRect((TileList[TileID].Layer2 % Layer2Width) * TILE_SIZE, (TileList[TileID].Layer2 / Layer2Width) * TILE_SIZE, 32, 32));
sprTile2.setPosition(32 * TILE_SIZE - offsetX, 64 * TILE_SIZE - offsetY);
for(int y = 0; y < mapSizeY; y++)
{
for(int x = 0; x < mapSizeX; x++)
{
renWin.draw(sprTile);
renWin.draw(sprTile2);
TileID ++;
}
}
}
In this case i get like 1-2 fps, "mapSizeX = 32" "mapSizeY = 24" are in both cases, and i also thought maybe something else is causing problem... Well when i comment out the drawing in the "visual studio 2010" i get around 900 fps witch is my max considering side program.
Question number 1: In both cases i use same program design, any ideas what may be wrong with Visual studio 2010 code?
If you need any more details i will post them.
Edited by BaneTrapper, 08 January 2013 - 11:54 AM.







