Jump to content
  • Advertisement
Sign in to follow this  
mkes

Why so SLOW GPU.

This topic is 4500 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I have comeback to a project that I banged together some years ago now; After numerous h/w upgrades, this code is still only hitting 60 fps. At the time I thought that this was the hardware limit! GeForce2 (without asm) (Although; running on win 98 SE has 25% speed increase over Win XP) As this is quite unsettling. I would like some suggestion as to why this FPS is still unchanged. FPS Code:
static float fps           = 0.0f;
static float previousTime  = 0.0f;	
	static char  strFPS[20]    = {0};
	float currentTime = (GetTickCount() * 0.001f);
 ++fps;	// Increment the FPS counter
if( currentTime - previousTime > 1.0f )
    	{
previousTime = currentTime;
//g_Log->printf(LOG_WARNING,"FPS: %d", int(fps));
sprintf(strFPS, "FPS: %d", int(fps));
SetWindowText(Main->hWnd, strFPS);
fps = 0.0f;
 	}

Set Camera
	POINT mousePos;	
	int mid_x = wndWidth  >> 1;	
	int mid_y = wndHeight >> 1;	
	float angle_y  = 0.0f;				
	float angle_z  = 0.0f;							
	GetCursorPos(&mousePos);	
	if( (mousePos.x == mid_x) && (mousePos.y == mid_y) ) return;
	SetCursorPos(mid_x, mid_y);
	angle_y = (float)( (mid_x - mousePos.x) ) / 1000;		
	angle_z = (float)( (mid_y - mousePos.y) ) / 1000;
	mView.y += angle_z * 2;
	if(mView.y > 3.5f)		mView.y = 3.5f;
	if(mView.y < 0.4f)		mView.y = 0.4f;
	Rotate_Position(-angle_y);

Draw Cube Code: void OGL_::DrawTile(float Y){
glBindTexture(GL_TEXTURE_2D,TextureArray[Dung[CDX][CDY].texID[TFACE_Front]]);
    glBegin(GL_QUADS);
     glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
     glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
     glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f + Y, 1.0f);
     glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f + Y,  1.0f);
    glEnd();
    glBindTexture(GL_TEXTURE_2D,TextureArray[Dung[CDX][CDY].texID[TFACE_Back]]);
    glBegin(GL_QUADS);
     glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
     glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f + Y, -1.0f);
     glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f + Y, -1.0f);
     glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
    glEnd();
    glBindTexture(GL_TEXTURE_2D,TextureArray[Dung[CDX][CDY].texID[TFACE_Top]]);
    glBegin(GL_QUADS);
     glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f + Y, -1.0f);
     glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,  1.0f + Y,  1.0f);
     glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,  1.0f + Y,  1.0f);
     glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f + Y, -1.0f);
    glEnd();
    glBindTexture(GL_TEXTURE_2D,TextureArray[Dung[CDX][CDY].texID[TFACE_Right]]);
    glBegin(GL_QUADS);
     glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
     glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f + Y, -1.0f);
     glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f + Y,  1.0f);
     glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	glEnd();
     glBindTexture(GL_TEXTURE_2D,TextureArray[Dung[CDX][CDY].texID[TFACE_Left]]);
    glBegin(GL_QUADS);
     glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
     glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);
     glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f + Y,  1.0f);
     glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f + Y, -1.0f);
    glEnd();

void OGL_::Draw_HighLitTile(float Yh){
    float Y = Yh + 1.02f;
    glBindTexture(GL_TEXTURE_2D,TextureArray[TFACE_Top_HighLight]);
    glBegin(GL_QUADS);
      glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  Y, -1.0f);
      glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,  Y,  1.0f);
      glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,  Y,  1.0f);
      glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  Y, -1.0f);
    glEnd();
};
[/source

Draw Scene

     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glLoadIdentity();
     TargetLookAt();
     glEnable(GL_TEXTURE_2D);
     glColor3f(1.0f,1.0f,1.0f);
     for( CDX=1; CDX<MAP_X; CDX++ ) {
       for( CDY=1; CDY<MAP_Y; CDY++)	{
	glPushMatrix();
        glTranslated(TsX[CDX][CDY],0,TsZ[CDX][CDY]);
	  Draw_Tile(Dung[CDX][CDY].height);
	if( TilesSelected[CDX][CDY] == true )
	  Draw_HighLitTile(Dung[CDX][CDY].height);
	glPopMatrix();
	}
    }


Draw M3d models


  #pragma omp parallel for
  for(n=0;n<64;n++)
  {
    glPushMatrix();
    glTranslated(npc[n].x,npc[n].y,npc[n].z);
      pModel[npc[n].mdl]->draw();
    glPopMatrix();
  }

All suggestions are welcome [needed]; TIA

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!