high,
I have been working on a 2D action / RPG for the past few months now. When i first started to make the game, i was using SDL for the rendering. This proved to be much too slow for my game, so i started reading up on OpenGL. It only took me about a week to port the code to using OpenGL..
Anyway, my framerate on my computer is awesome! I get ~350 FPS in windowed mode, and ~500 FPS in windowed mode. Sadly though, im running a 3 gig p4 w / Radeon 9600 and 512 megs of RAM, with the latest drivers...
On lower end machines, like 500 mhz or 800 mhz or whatever, the game slows to a crawl! One tester (actually, my team-mate), running a 500 mhz machine, gets about 5 FPS in windowed mode! Lucky for fullscreen, he gets around 60 FPS. Other people have tested, and have smiliar results, some even worse then these =(.
I know its my game, because these people run commercial games just fine, games like unreal tournmanet or sim city 3000 run reasonably well. Also, SDL is telling me that these people DO have hardware accceleration / hardware blits enabled! one person who didnt have hardware accel / blits enabled, got 3 FPS in both windowed AND fullscreen! and his machine ran sim city 3000 at 50 FPS!!
I ran a profiler with my game, and im not positive i did it right, but im pretty sure its telling me ~50% of the time is spent in my Map::Update() function. All this function does, is render my tiles to the screen. (This is a tile based game). Anyway, this Map::Update() function will draw my map to the screen. I have it limited to draw only what the player can see, which is ~400 tiles / quads. Im using 2d Ortho mode with the origin at the top left corner, so each unit is == one pixel. Im drawing each tile 32 pixels/units big.
Also, there is only one texture for the tiles. its a tilemap (128x128) which i "slice" via glTexCoord() to render a piece of this tilemap image onto the quad. I bind this texture only one time before i draw any of the tiles... Here is my Map::Update() function which will draw the map:
bool Map::Update()
{
glBindTexture(GL_TEXTURE_2D,tilemap_texture);
int x, y; //screen pixel x,y coordinate to draw the current tile to
int mx, my;
int sx = 0 - (scroll_x%TILESIZE);
int smx = (sx+scroll_x)/TILESIZE;
for(y = 0 - (scroll_y%TILESIZE), my = (y+scroll_y)/TILESIZE; y < VIEWHEIGHT; y+=TILESIZE)
{ //y draw coordinate, the offset is for smooth scrolling
for( x = sx, mx = smx; x < VIEWWIDTH; x+=TILESIZE)
{
systm->Draw_Tile((float)x,(float)y,current_map[my][mx]->x_map_loc,current_map[my][mx]->y_map_loc);
mx++;
// if(Get_Flags(mx,my) & MAPSWAPTILE)
// cout<<" THERES DEFINETLY A MST HERE!!!!"<<endl;
}
my++;
}
return true;
}
now, here is my Map::Draw_Tile() function which draws the actual tile
void System::Draw_Tile(float x, float y, float x_loc, float y_loc)
{
//glEnable(GL_BLEND);
//bind the texture we sent in to this quad
//THIS WAS MOVED TO INSIDE MAP UPDATE AND ONLY CALLED ONCE BY FRUNY"S RECOMMENDATION
// glBindTexture(GL_TEXTURE_2D,map_data->tilemap_texture);
//draw this quad white
glColor3f(1.0f,1.0f,1.0f);
//float corner_offset = 32.0f/64.0f; //(map.tmap_height*TILESIZE);
//the width/height of a tile in percent-wise (to calc the edges of a tile.. ie x,y is top left, x + (t_perc)w is right corner
float t_perc_w = 32.0f/((float)map_data->tmap_width*(float)TILESIZE);
float t_perc_h = 32.0f/((float)map_data->tmap_height*(float)TILESIZE);
glBegin(GL_QUADS);
/* Bottom Left */
glTexCoord2f(x_loc, y_loc + t_perc_h); //was 0.0f,1.0f
glVertex2f(x, y + 32.0f);
/* Bottom Right */
glTexCoord2f(x_loc + t_perc_w , y_loc + t_perc_h); //was 1.0, 1.0
glVertex2f(x + 32.0f,y + 32.0f);
/* Top Right */
glTexCoord2f(x_loc + t_perc_w , y_loc); //was 1.0,0.0
glVertex2f(x + 32.0f,y);
/* Top Left */
glTexCoord2f(x_loc,y_loc); //was 0.0 0.0
glVertex2f(x,y);
glEnd();
}
Thanks for any help! im really hoping someon here can help me... someone had told me to use vertex / texture coord arrays, but then someone in this forum told me that it wont help because im not doing complicated geometry. Thanks for any help, and if you need more info just ask!