the effects of textures on my frame rate

This is a discussion on the effects of textures on my frame rate within the Game Programming forums, part of the General Programming Boards category; Well, this is my 2nd attempt at writing this post because an error happened the 1st time, so grrr...makes me ...

  1. #1
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738

    the effects of textures on my frame rate

    Well, this is my 2nd attempt at writing this post because an error happened the 1st time, so grrr...makes me mad...oh well...Here goes...

    Many of you know I am working on a Battletech game, very similar to that of Mechwarrior.

    Lately, however, I have come upon a severe bottleneck in my game, and having tried everything I know of, am unable to fix it. Hence I have conducted a series of tests in order to gather data and then present it before you to see if you can give me any help with my problem I have here.

    Here is the basics of the problem: I have my terrain engine. It ran run in two modes: textured and non-textured. When I run it with no textures, I get a frame rate of about 30 fps. When I run it with textures applied, my frame rate drops to about 7 fps.

    Now, to explain the problem further in depth, I will give you some background about my engine:

    I have a "map" which is composed of the terrain that all the units move on, obviously.

    The map is composed of a unit which I call a "hex" (short for hexagon...each piece of the map is a hexagon). The plural is "hexes." So when you see me say hex in this post, I mean a spot on the map, NOT hexidecimal.

    The map is a matrix of hexes. The size is specified by the programmer and the data for the map is loaded in from a file. Right now I am running a map of 30x20 hexes.

    I have 3 textures loaded into memory right now. One is called GRASS, one is called HILL, and one is called WATER. When I load in the height map, textures are automatically applied to each hex.

    All hexes with a height less than or equal to 0 receive a water texture. All hexes with a height between 0 and 2 (non-inclusive) receive a grass texture, and all hexes with a height of 2 or greater receive a hill texture.

    The programmer can choose whether to actually use the textures or not, but nevertheless, each hex is assigned its texture, and the textures are loaded into memory.

    Each texture is a 64x64 pixel 24-bit bitmap.

    That is basically all the info on how I store my map in memory. Now I will show you some code...

    Before you jump to any conclusions, do not tell me to use display lists to boosts my frame rate. I have already tried them.

    The following code is my function to initialize OpenGL. Remember that this function is only called once, so it has no factor whatsoever in my frame rate, but it might give some useful information for all of you:

    Code:
    void setup_opengl( int width, int height )
    {
        float ratio = (float) width / (float) height;
    
    	//Texture Mapping Initialization	
    	InitTextureNames ( );
    	LoadGLTextures();		// Texture Loading Routine
    	BuildFont();
    	glEnable(GL_TEXTURE_2D);// Enable Texture Mapping
    	
    
        /* Our shading model--Gouraud (smooth). */
        glShadeModel( GL_SMOOTH );
    
        /* Set the clear color. */
        glClearColor( 0, 0, 0, 0 );
    
        /* Setup our viewport. */
        glViewport( 0, 0, width, height );
    
        /*
         * Change to the projection matrix and set
         * our viewing volume.
         */
        glMatrixMode( GL_PROJECTION );
        glLoadIdentity( );
    
        gluPerspective( 60.0, ratio, 1.0, 1024.0 );
    
    
    //Create a map of 20x30 hexes of 1 radius each.
    //Set the base elavation of the map to -1.0 on the y-axis.
    //Load and apply the height map.
    //Apply the default terrain colors for when textures are not used.
    //Enable texture mapping, and create a display lists for the map.
    	myMap = new HEXMAP_DTP( 20, 30, 1.0f );
    	myMap->SetBase ( 0.0f, -1.0f, 0.0f );
    	myMap->LoadHeightMap ( "heightmap.dat" );
    	myMap->HeightMap( );
    	myMap->ApplyDefaultTerrainColors();
    	myMap->EnableTextureMapping ( true );
    	myMap->CreateHexDisplayLists ( );
    
    	glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_NORMAL_ARRAY);
        glEnableClientState(GL_COLOR_ARRAY);
    }
    I hope that function is pretty clear and straight forward. If there is any confusion about my code, ask me and I will explain a part of it.

    Here is the next function. This function is my draw function and gets called on every frame:

    Code:
    static void draw_screen( void )
    {    
    
    	GLfloat xtrans = -xpos;
    	GLfloat ztrans = -zpos;		
    	movy -= ypos;
    	GLfloat sceneroty = 360.0f - yrot;
    
        /* Clear the color and depth buffers. */
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    
        /* We don't want to modify the projection matrix. */
        glMatrixMode( GL_MODELVIEW );
        glLoadIdentity( );
    
    	glRotatef(sceneroty,0,1.0f,0);
    	glTranslatef(xtrans, movy, ztrans);
    
    //Draw the map...obviously.  
    	myMap->DrawMap();	
    
    
    //This function is for printing text onto the screen.
    	CyclePrintBuffer ( );
    
        /*
         * Swap the buffers. This this tells the driver to
         * render the next frame from the contents of the
         * back-buffer, and to set all rendering operations
         * to occur on what was the front-buffer.
         *
         * Double buffering prevents nasty visual tearing
         * from the application drawing on areas of the
         * screen that are being updated at the same time.
         */
    
    
        SDL_GL_SwapBuffers( );
    
    	movy += ypos;
    	
    }
    There are some variables in that function that are global variables and declared elsewhere in my code. Just have confidence that they HAVE been decalared. ;-)

    Anyways, I will show you one more function. This is the function where an individual hex is actually drawn onto the screen. Keep in mind that although I am using display lists for the drawing, I have omitted them in this post for the sake that you can see all of the code. This function is called DrawHexTextured(), and is called by the DrawMap() function as the map class draws every hex in the map. The code is identical to the code that draws the map with no-textures, except that this code contains code for textures :-) :

    Code:
    void HEX_DTP::DrawHexTextured ( )
    {
    	//Find out which texture to use
    	if ( level <= 0 )
    		glBindTexture ( GL_TEXTURE_2D, texture[WATER] );
    	else if ( level >= 2 )
    		glBindTexture ( GL_TEXTURE_2D, texture[HILL] );
    	else 
    		glBindTexture ( GL_TEXTURE_2D, texture[GRASS] );
    
    	//account for elevation change at center of hex
    	v[1] += level;
    
    	//radius, x1, z1, and other variables are declared in the class declaration
    	//they are also defined by other functions and by the class constructor
    	//create outer vertexes of hexagon
    	float vertex[6][3] = 
    	{ 
    		{ v[0] - radius,	v[1] - ElevationMod[0],		v[2] },
    		{ v[0] - x1,		v[1] - ElevationMod[1],		v[2] - z1 },
    		{ v[0] + x1,		v[1] - ElevationMod[2],		v[2] - z1 },
    		{ v[0] + radius,	v[1] - ElevationMod[3],		v[2] },
    		{ v[0] + x1,		v[1] - ElevationMod[4],		v[2] + z1 },
    		{ v[0] - x1,		v[1] - ElevationMod[5],		v[2] + z1 }
    	};
    
    
    	glBegin ( GL_TRIANGLES );		
    	
    		glTexCoord2f(0.0f, 0.0f); 
    			glVertex3f ( v[0], v[1], v[2] );	
    		glTexCoord2f(1.0f, 0.0f); 
    			glVertex3f ( vertex[0][0], vertex[0][1], vertex[0][2] );
    		glTexCoord2f(1.0f, 1.0f); 
    			glVertex3f ( vertex[1][0], vertex[1][1], vertex[1][2] );
    	
    		glTexCoord2f(0.0f, 0.0f);
    			glVertex3f ( v[0], v[1], v[2] );	
    		glTexCoord2f(1.0f, 0.0f); 
    			glVertex3f ( vertex[1][0], vertex[1][1], vertex[1][2] );
    		glTexCoord2f(1.0f, 1.0f);
    			glVertex3f ( vertex[2][0], vertex[2][1], vertex[2][2] );
    	
    		glTexCoord2f(0.0f, 0.0f);
    			glVertex3f ( v[0], v[1], v[2] );	
    		glTexCoord2f(1.0f, 0.0f); 
    			glVertex3f ( vertex[2][0], vertex[2][1], vertex[2][2] );
    		glTexCoord2f(1.0f, 1.0f);
    			glVertex3f ( vertex[3][0], vertex[3][1], vertex[3][2] );
    	
    		glTexCoord2f(0.0f, 0.0f);
    			glVertex3f ( v[0], v[1], v[2] );	
    		glTexCoord2f(1.0f, 0.0f); 
    			glVertex3f ( vertex[3][0], vertex[3][1], vertex[3][2] );
    		glTexCoord2f(1.0f, 1.0f);
    			glVertex3f ( vertex[4][0], vertex[4][1], vertex[4][2] );
    	
    		glTexCoord2f(0.0f, 0.0f);
    			glVertex3f ( v[0], v[1], v[2] );	
    		glTexCoord2f(1.0f, 0.0f); 
    			glVertex3f ( vertex[4][0], vertex[4][1], vertex[4][2] );
    		glTexCoord2f(1.0f, 1.0f);
    			glVertex3f ( vertex[5][0], vertex[5][1], vertex[5][2] );		
    	
    		glTexCoord2f(0.0f, 0.0f);
    			glVertex3f ( v[0], v[1], v[2] );	
    		glTexCoord2f(1.0f, 0.0f); 
    			glVertex3f ( vertex[5][0], vertex[5][1], vertex[5][2] );
    		glTexCoord2f(1.0f, 1.0f);
    			glVertex3f ( vertex[0][0], vertex[0][1], vertex[0][2] );
    
    	glEnd ( );
    
    	v[1] -= level;
    }
    Okay, that should be all code relevant to the problem. If you would like to see any other code, just tell me and I will post it, however I think this should suffice.

    If you see anything that could be causing my extreme bottleneck, please tell me. I have tried quite a bit to get this thing to go faster, but nothing seems to work.

    I just don't understand why 3 small textures alone could be dropping my frame rate from 30 fps to 7 fps.

    So any help is appreciated.

    If I have left any information out of this post I apologize. Ask and ye shall receive.

    I will post you a picture of the UNTEXTURED version of the terrain engine so you can get a feel for what it looks like. Notice the clear distinction between each hexagon on the map. It is supposed to be like that:
    Attached Images Attached Images  
    My Website

    "Circular logic is good because it is."

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    You ever tried profiling you rprogram to see where it is slowing down?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    i know where its slowing down. its slowing down whenever I enable texture mapping. So its something dealing with those textures. Everything else runs at desired speeds.
    My Website

    "Circular logic is good because it is."

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    glBindtexture is one of the most expensive calls you can make, so doing it once for every hex that can be seen is the problem.

    you should not bind if the correct texture is alreay bound, and you should sort everything so that you only have to bind each texture 1 time and draw everything that needs that texture at that time.

    Oh and Hi by the way, remember talking to me on IM's years ago, i admire your perserverance, you were working on this way back then.


    Also in your init, you change to GL_PROJECTION, and never change back to GL_MODELVIEW
    Last edited by Eber Kain; 09-22-2003 at 10:05 PM.

  5. #5
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    thanks.

    Yeah I was really wondering how much that glBindTexture was taxing my frame rate.

    Right now I currently just do a for loop and go through and draw each hex one by one.

    I will change that and draw each hex by elevation. That way I will only have to bind each texture one time.

    Thanks for that info, ebar kain! (hopefully now my frame rate will boost)
    My Website

    "Circular logic is good because it is."

  6. #6
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    okay this is what I have done:

    acting on Eber Kain's advice, I created three arrays of pointers:

    WaterHex, GrassHex, and HillHex

    Each array is composed of elements that point to hexes in the HexMap.

    Now, here is how I implement these arrays:

    Code:
    void HEXMAP_DTP::LoadHeightMap ( char *fileName )
    {
    	ifstream load ( fileName );
    	float level;
    
    	for ( int y = 0; y < numY; y++ )
    	{
    		for ( int x = 0; x < numX; x++ )
    		{
    			load >> level;
    			HexMap[x][y].SetLevel ( level );
    
    
    			if ( level <= 0 ) {
    				WaterHex.resize ( WaterHex.length() + 1 );
    				WaterHex [ WaterHex.length() - 1 ] = &HexMap[x][y];
    			}
    			else if ( level >= 2 )
    			{
    				HillHex.resize ( HillHex.length() + 1 );
    				HillHex [ HillHex.length() - 1 ] = &HexMap[x][y];
    			}
    			else {
    				GrassHex.resize ( GrassHex.length() + 1 );
    				GrassHex [ GrassHex.length() - 1 ] = &HexMap[x][y];
    			}
    		}
    	}
    
    	
    
    	load.close();
    }
    So as I load in the height map, I store the height in the proper location in HexMap (thats my matrix of hexes that compose my map).

    I then look at the elevation I just loaded in from the file. Depending on what the elevation is, I make a new element in the proper array point to that corresponding hex in the map.

    Therefore each array points to its corresponding elements. The WaterHex array points to all hexes in the map that are water, the GrassHex array points to all grass hexes, and the HillHex array points to all hexes of a "high" elevation.

    Then this is how I draw now:

    Code:
    void HEXMAP_DTP::DrawMap ( void )
    {
    	int x;
    
    	glBindTexture ( GL_TEXTURE_2D, texture [WATER] );		
    	for ( x = 0; x < WaterHex.length(); x++ )
    	{
    		if ( textureMapEnabled )
    			WaterHex[x]->DrawHexTextured ( );
    		else
    			WaterHex[x]->DrawHex();
    	}
    
    	glBindTexture ( GL_TEXTURE_2D, texture [GRASS] );		
    	for ( x = 0; x < GrassHex.length(); x++ )
    	{
    		if ( textureMapEnabled )
    			GrassHex[x]->DrawHexTextured ( );
    		else
    			GrassHex[x]->DrawHex();
    	}
    
    	glBindTexture ( GL_TEXTURE_2D, texture [HILL] );		
    	for ( x = 0; x < HillHex.length(); x++ )
    	{
    		if ( textureMapEnabled )
    			HillHex[x]->DrawHexTextured ( );
    		else
    			HillHex[x]->DrawHex();
    	}
    }
    So I bind the texture for water, and then I draw all water hexes. Then I bind the texture for grass, and draw all grass hexes.
    Then I bind the texture for hills, and draw all hill hexes.

    I also deleted ALL glBindTexture code from my DrawHexTextured() code...i made sure its all gone.

    So now I only bind a texture 3 times every frame. Before I took eber kain's advice i was binding textures about 600 times a frame.

    However, I'm sorry to say, this has not boosted my frame rate one bit.

    If I have done something wrong, point it out...but to the best of my knowledge I have implemented what Eber Kain said to do in a correct manner.

    I know many people might have used a matrix instead of 3 arrays, but technically all rows of a matrix should be the same length when you resize a matrix, so I chose 3 arrays because all of them are almost definitely going to be different lengths (since there is more of one terrain type than another). Many people would have also chosen a linked list, but I felt 3 resizable arrays was easier to maintain.

    So, now, any suggestions? flames? comments? persecutions? stonings? lol

    Some quick stats:

    Average time in milliseconds it takes to draw one frame textured: 135

    Average time in milliseconds it takes to draw one frame untextured: 32
    Last edited by DavidP; 09-23-2003 at 01:14 AM.
    My Website

    "Circular logic is good because it is."

  7. #7
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    I dont see anything else that is an obvious slowdown...

    how bad of a frame rate drop are we talking about?
    and what are your system specs?

  8. #8
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    what type of *culling* (not clipping) do you do?
    Last edited by Silvercord; 09-23-2003 at 03:12 PM.

  9. #9
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Well, we know that it slows down when you use textures. But... it seems like it's always slow - that scene was NOT complex. You aren't trying to run this on an abbacus, are you?

    Anyway, seriously, USE a profiler. The profiler built into MSVC will tell you how many times each function is called, how much time was spent in each call, and how much total time was spent in each function. I think it sorts them in order of time, too. Soo.... if you do that, you'll be able to determine which functions are taking the most time, and narrow down the problem. Do it. Profilers are a great tool.
    Away.

  10. #10
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    I did not have culling enabled for those tests. The reason is when I have culling enabled I have problems. Here is the culling code, it sits inside the setup_opengl() function that gets called at the beginning of the function:

    glFrontFace( GL_CCW );
    glCullFace( GL_BACK );
    glEnable( GL_CULL_FACE );

    Yes, culling does about double my frame rate, however, here is a picture of what it looks like when I use culling (this is the TEXTURED version). Compare it to my picture of when I don't use culling (the picture of me not using culling is in my first post and does not use textures):
    Attached Images Attached Images  
    My Website

    "Circular logic is good because it is."

  11. #11
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    Okay, I change it from Counter-Clockwise culling to Clock-wise culling, so now it is:

    glFrontFace( GL_CW );
    glCullFace( GL_BACK );
    glEnable( GL_CULL_FACE );

    This does culling properly so things that are supposed to be seen are seen, and other things are not. However now my frame rate has dropped yet again, not quite to what it was, but its not great.

    Frame rate with no culling: 7
    Frame rate with CCW culling: 18 (doesnt look right)
    Frame rate with CW culling: 10

    >and what are your system specs?

    my system specs are:

    GeForce 2 vid card, 64 MB
    384 MB Ram
    AMD Athlon XP 1800+ processor
    40 GB hd

    so the system specs are fine...
    Last edited by DavidP; 09-23-2003 at 04:49 PM.
    My Website

    "Circular logic is good because it is."

  12. #12
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    okay confuted...I did profiled, here are the results:

    I ran the program for about 10 seconds (9.787 to be exact).

    The function times were (in milliseconds):

    Code:
           Func          Func+Child           Hit
            Time   %         Time      %      Count  Function
    ---------------------------------------------------------
        7292.425  75.0     7292.425  75.0    43200 HEX_DTP::DrawHexTextured(void) (main.obj)
        1942.619  20.0     1942.619  20.0       71 _SDL_GL_SwapBuffers (sdl.dll)
         172.387   1.8      172.387   1.8      144 _SDL_PollEvent (sdl.dll)
         116.901   1.2      116.901   1.2        2 _SDL_Init (sdl.dll)
          58.283   0.6       67.226   0.7        1 HEXMAP_DTP::HEXMAP_DTP(int,int,float) (main.obj)
          39.686   0.4       39.686   0.4        1 _SDL_SetVideoMode (sdl.dll)
          16.453   0.2       16.453   0.2      600 HEX_DTP::CreateDisplayList(void) (main.obj)
          13.584   0.1       13.584   0.1      600 HEX_DTP::CreateTexturedDisplayList(void) (main.obj)
          12.685   0.1       12.685   0.1        2 _SDL_Quit (sdl.dll)
           7.943   0.1        7.943   0.1    10736 apvector<class apvector<class HEX_DTP> >::operator[](int) (main.obj)
           7.579   0.1        7.579   0.1      180 glPrint(int,int,char *,int) (main.obj)
           6.727   0.1        6.727   0.1        5 LoadBMP(char *) (main.obj)
           5.675   0.1     9251.162  95.1       71 draw_screen(void) (main.obj)
           5.390   0.1        6.168   0.1        1 HEXMAP_DTP::LoadHeightMap(char *) (main.obj)
           4.443   0.0     7294.680  75.0       71 HEXMAP_DTP::DrawMap(void) (main.obj)
           3.153   0.0        8.658   0.1        1 HEXMAP_DTP::HeightMap(void) (main.obj)
           2.878   0.0        2.878   0.0     7788 HEX_DTP::GetLevel(void) (main.obj)
           2.870   0.0     9710.727  99.8        1 _SDL_main (main.obj)
           2.740   0.0        2.740   0.0        1 BuildFont(void) (main.obj)
           2.691   0.0        9.420   0.1        1 LoadGLTextures(void) (main.obj)
           2.649   0.0        2.649   0.0      600 HEX_DTP::SetRadius(float) (main.obj)
           0.973   0.0        0.973   0.0        1 _cleanup_output (sdl_main.obj)
           0.761   0.0     9725.205 100.0        1 _WinMain@16 (sdl_main.obj)
           0.515   0.0        8.094   0.1       71 CyclePrintBuffer(void) (main.obj)
           0.417   0.0        0.417   0.0     6276 apvector<class HEX_DTP>::operator[](int) (main.obj)
           0.406   0.0        0.406   0.0     6272 apmatrix<class HEX_DTP>::operator[](int) (main.obj)
           0.363   0.0       32.718   0.3        1 HEXMAP_DTP::CreateHexDisplayLists(void) (main.obj)
           0.338   0.0        0.338   0.0      600 HEX_DTP::SetLevel(float) (main.obj)
           0.256   0.0        0.256   0.0      640 operator delete(void *) (delop_s.obj)
           0.230   0.0        0.568   0.0        1 HEXMAP_DTP::ApplyDefaultTerrainColors(void) (main.obj)
           0.133   0.0        0.133   0.0      600 HEX_DTP::HEX_DTP(void) (main.obj)
           0.119   0.0        0.119   0.0     1140 HEX_DTP::SetRGB(float,float,float) (main.obj)
           0.118   0.0        0.254   0.0       20 apvector<class HEX_DTP>::resize(int) (main.obj)
           0.106   0.0        0.106   0.0       71 HandleMovement(void) (main.obj)
           0.100   0.0        0.123   0.0       60 apvector<class HEX_DTP *>::resize(int) (main.obj)
           0.094   0.0        0.094   0.0       71 _SDL_GetTicks (sdl.dll)
           0.092   0.0      127.618   1.3        1 setup_opengl(int,int) (main.obj)
           0.092   0.0        0.092   0.0     1140 HEX_DTP::SetOuterRGB(float,float,float) (main.obj)
           0.066   0.0        0.066   0.0        1 _$E27 (main.obj)
           0.049   0.0        0.049   0.0      600 HEX_DTP::GetZ(void) (main.obj)
           0.047   0.0        0.047   0.0      600 HEX_DTP::GetX(void) (main.obj)
           0.046   0.0        0.046   0.0      600 HEX_DTP::GetRadius(void) (main.obj)
           0.044   0.0        0.044   0.0      601 HEXMAP_DTP::SetBase(float,float,float) (main.obj)
           0.044   0.0        0.044   0.0      601 HEX_DTP::SetPosition(float,float,float) (main.obj)
           0.035   0.0        0.035   0.0      600 HEX_DTP::GetY(void) (main.obj)
           0.023   0.0        0.023   0.0      320 HEX_DTP::SetElevationMod(int,float) (main.obj)
           0.015   0.0        0.015   0.0        1 _$E22 (main.obj)
           0.015   0.0        0.015   0.0        1 _$E23 (main.obj)
           0.015   0.0     9724.442 100.0        1 _main (sdl_main.obj)
           0.012   0.0        0.016   0.0        1 apvector<class apstring>::resize(int) (main.obj)
           0.009   0.0        0.009   0.0        1 _$E20 (main.obj)
           0.006   0.0        0.006   0.0       64 apvector<class HEX_DTP *>::operator[](int) (main.obj)
           0.005   0.0        0.071   0.0        1 _$E30 (main.obj)
           0.005   0.0        0.010   0.0        5 apstring::operator=(char const *) (main.obj)
           0.005   0.0        0.005   0.0        3 Print(char *,int,int,int,int) (main.obj)
           0.004   0.0        0.007   0.0        1 apvector<class apvector<class HEX_DTP> >::resize(int) (main.obj)
           0.004   0.0        0.004   0.0        5 apstring::apstring(void) (main.obj)
           0.003   0.0        0.008   0.0        1 _$E56 (main.obj)
           0.003   0.0        0.005   0.0        1 _$E53 (main.obj)
           0.003   0.0        0.003   0.0        5 _SDL_GL_SetAttribute (sdl.dll)
           0.002   0.0        0.002   0.0        1 _SDL_EnableKeyRepeat (sdl.dll)
           0.002   0.0        0.002   0.0        1 apvector<class apvector<class HEX_DTP> >::apvector<class apvector<class HEX_DTP> >(int) (main.obj)
           0.002   0.0        0.002   0.0        2 LImporter::Clear(void) (l3ds.obj)
           0.002   0.0        0.002   0.0        2 _ParseCommandLine (sdl_main.obj)
           0.002   0.0        0.002   0.0        5 apstring::c_str(void) (main.obj)
           0.002   0.0        0.008   0.0        1 _$E18 (main.obj)
           0.001   0.0        0.004   0.0        1 _$E54 (main.obj)
           0.001   0.0        0.006   0.0        5 apstring::~apstring(void) (main.obj)
           0.001   0.0        0.027   0.0        1 InitTextureNames(void) (main.obj)
           0.001   0.0        0.003   0.0        1 LImporter::~LImporter(void) (l3ds.obj)
           0.001   0.0        0.001   0.0       20 apvector<class HEX_DTP>::apvector<class HEX_DTP>(void) (main.obj)
           0.001   0.0        0.002   0.0        1 LImporter::LImporter(void) (l3ds.obj)
           0.001   0.0        0.016   0.0        1 _$E25 (main.obj)
           0.001   0.0        0.002   0.0        1 _$E28 (main.obj)
           0.000   0.0        0.000   0.0        1 HEXMAP_DTP::EnableTextureMapping(bool) (main.obj)
           0.000   0.0        0.000   0.0        1 _$E17 (main.obj)
           0.000   0.0        0.000   0.0        1 _SDL_SetModuleHandle (sdl.dll)
           0.000   0.0        0.000   0.0        1 L3DS::L3DS(void) (l3ds.obj)
           0.000   0.0        0.000   0.0        1 L3DS::~L3DS(void) (l3ds.obj)
           0.000   0.0        0.000   0.0        1 _$E19 (main.obj)
           0.000   0.0        0.000   0.0        1 _$E24 (main.obj)
           0.000   0.0        0.000   0.0        1 _$E29 (main.obj)
           0.000   0.0        0.000   0.0        1 _$E55 (main.obj)
           0.000   0.0        0.000   0.0        1 apqueue<struct PrintBufferUnit>::apqueue<struct PrintBufferUnit>(void) (main.obj)
           0.000   0.0        0.000   0.0        1 apqueue<struct PrintBufferUnit>::~apqueue<struct PrintBufferUnit>(void) (main.obj)
    So on average it is drawing a textured hex in 5.92 miliseconds.
    Last edited by DavidP; 09-23-2003 at 05:10 PM.
    My Website

    "Circular logic is good because it is."

  13. #13
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    can you upload your profile.dll david?

  14. #14
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    i tried but the attatch file feature on this board only allows you to upload picture files.

    (thats what it told me)

    So I will upload it to my website:

    http://www33.brinkster.com/cyfallshs/

    I assume you are talking about the one in the Visual C++ BIN directory?
    My Website

    "Circular logic is good because it is."

  15. #15
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    The daily bandwidth limit for this customer has been exceeded. Try again after midnight, EST.
    Click here for more information.
    also, about the question I've asked twice so far, what type of culling are you doing? Drawing your hexes is taking 75% of the time according to the profiler. Therefore you need to implement some sort of culling to cut down what is drawn, otherwise I doubt there is hope. You can't just 'draw everything at once'. Most of what is being drawn isn't even visible, but OpenGL still has to perform calculations on it and that takes time. Also, you have too many if statements in your drawing routine, believe it or not that's hurting performance too. What I'd do is compile every type of hex into its own list and render them separately without having to ask what type it is.

    Trade memory for speed whenever possible just as long as it takes up only a reasonable amount of mem.


    EDIT: taking into account I haven't seen your entire engine, so there might still be something wrong, but I believe the problem is ultimately going to involve you not having culling. You need some type of partitioned world. BSP typically isn't best for terrain, octree is best for terrain but i don't know of any octree compilers. Or, I can show you how to split polygons and you can perform your own simple compiler, whcih I don't recommend because writing a robust comiler for maps is probably the most difficult aspect of game programming, period

    EDIT1: and when I say culling I don't mean back face culling, and to be honest I dont necessarily mean frustum culling. I use frustum culling and potential visibility sets but to be honest I think it (frustum culling) is a waste. Quake3 doesn't even do frustum culling, it uses potential visibility sets, and that's the most effective form of culling that there is. What I'm getting around to saying is use quake3 bsp format, there are terrain generation plugins for that.
    Last edited by Silvercord; 09-24-2003 at 11:32 AM.

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting Frame Rate in DirectX
    By Rune Hunter in forum Game Programming
    Replies: 4
    Last Post: 11-02-2005, 02:57 PM
  2. Animation not working....
    By aquinn in forum C Programming
    Replies: 7
    Last Post: 02-19-2005, 05:37 AM
  3. bottleneck in frame rate occurring
    By DavidP in forum Game Programming
    Replies: 10
    Last Post: 09-19-2003, 04:48 PM
  4. Frame Rate
    By Tommaso in forum Game Programming
    Replies: 6
    Last Post: 04-04-2003, 06:40 PM
  5. Whats a good frame rate?
    By compjinx in forum Game Programming
    Replies: 16
    Last Post: 04-07-2002, 06:31 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21