Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


Needing sugestions on drawing tiled map


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 BaneTrapper   Members   -  Reputation: 1225

Like
0Likes
Like

Posted 08 January 2013 - 11:50 AM

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.

Current projects:
The Wanderer, 2d turn based rpg style game

www.gamedev.net/topic/641117-check-up-the-wanderer/


Sponsor:

#2 BaneTrapper   Members   -  Reputation: 1225

Like
0Likes
Like

Posted 08 January 2013 - 12:04 PM

Sorry for double post, but if i edit, the code gets smashed intro one line...

I just did remove whole program in visual studio and just kept "Map drawing" and "Fps capping" the problem still persists... i will try replacing .dll

This is kinda weird problem that would require inspection of whole program, so if you experienced same issues please share your wisdom!

EDIT:: I would like to note i am using "sfml 2.0" library for this

Edited by BaneTrapper, 08 January 2013 - 12:07 PM.

Current projects:
The Wanderer, 2d turn based rpg style game

www.gamedev.net/topic/641117-check-up-the-wanderer/


#3 SuperVGA   Members   -  Reputation: 1118

Like
0Likes
Like

Posted 08 January 2013 - 12:19 PM

Are you compiling with roughly the same parameters/flags?
Are you compiling and running in release mode with both IDE's(compilers)?
Cause debug modes can really slow some things down...

#4 BaneTrapper   Members   -  Reputation: 1225

Like
0Likes
Like

Posted 08 January 2013 - 12:34 PM

Are you compiling with roughly the same parameters/flags?
Are you compiling and running in release mode with both IDE's(compilers)?
Cause debug modes can really slow some things down...
On Visual studio 2010 i got FPS improved up to 80 from 1-11, but on Code::blocks i went from around 700 too around 800.

I downloaded .dll from official sfml site for codeblocks and i get a massive decrease in fps down to 300-330 with release. Also i noticed with site .dll the sound was tearing "stoping for 0.1 - 0.3 each 1 second, if that describes it.

I will try to build my own Visual studio 2010 .dll and i will give you info

EDIT 2::
Also when using Visual studio 2010 i have "Main menu" "Character creation" "Member edit" all these functions are collision and drawing heavy and i get 400-600 fps in visual studio and 400-600 in code::blocks.

EDIT 3::
After building my own .dll files with cmake for visual studio the program fps on debug increased to 130 and release up to 200...

Don't know why... know know how... its acceptable FPS now "Flips the table"

Edited by BaneTrapper, 08 January 2013 - 03:25 PM.

Current projects:
The Wanderer, 2d turn based rpg style game

www.gamedev.net/topic/641117-check-up-the-wanderer/


#5 Jutaris   Members   -  Reputation: 477

Like
2Likes
Like

Posted 08 January 2013 - 05:19 PM

Are both of these on the same machine, and if not are they on the same OS, do they have the same hardware configuration?

 

If they are on the same machine, are they using different compilers? Far as I know, Code blocks requires you to set one up, and that one can be Visual C++'s compiler or a few others.

 

Finally, regardless of the two question sets above, the code between them seems to be pretty significantly different (e.g. what does renWin.draw do?). Without the full context, comparisons like these mean little.

 

We don't know under what context the draw call is being made, or in the VS case what the draw code is doing at all. Inspect that and see what you find. If you can provide more context on what your scenario is (and what your code is actually doing) we can probably help more.


My Site -- My Music  -- My Ramblings -- My Game

 Basic Flying Rules:Try to stay in the middle of the air. Do not go near the edges of it. The edges of the air can be recognized by the appearance of ground, buildings, sea, trees and interstellar space. It is much more difficult to fly there.

Come join us for some friendly game dev discussions over in XNA Chat!


#6 BaneTrapper   Members   -  Reputation: 1225

Like
0Likes
Like

Posted 09 January 2013 - 07:25 AM

It has to do something with my graphics card being derp, when i get good explanation am gonna post it someone googles this but there ain't much i can ask of people to do now.

Running same executable on my laptop provides allot better FPS then on my main machine witch is allot stronger in all components so... id state compatibility issues...


Current projects:
The Wanderer, 2d turn based rpg style game

www.gamedev.net/topic/641117-check-up-the-wanderer/





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS