   Having trouble with optimization
  Hello! I'm not really new to programming, but I wouldn't exactly consider myself too advanced at the OpenGL API, if you know what I mean. I've written myself a 2D side-scroll game in my spare time, and it's coming along very well, but there's one problem--it's optimized for my PC only. It runs at just the right speed and the physics work just right on my computer, but when I copied the game to my friend's quad-core laptop(with internal graphics), my character barely moves an inch a second. I've designed my game loop over and over again to control the frame rate, separating the UpdateMath() and Draw() functions and using GetTickCount() procedures to control how quickly the game updates itself, but I've had no luck. The game runs incredibly slow on PC's that have inferior graphics cards(at least, I would assume it would be the graphics card). I'd be testing my game on other computers, but I just moved into my new apartment and all my other PC's are back home, so I'm stuck with this, and my thinkpad X41 running slackware...so there's not much room for me to play around and experiment if you catch my drift.Anyways, my program loads tiles from a map file and each tile has its own .TGA texture with alpha blending for transparency. Each tile is 100x100px, and on average on the screen there's only about 10-12 textured polygons being drawn on the screen. I was hoping if somebody here could lend me a hand as to where the bottleneck lies in terms of performance. Here's a few snippets of code that I hope may give some clues as to what I'm missing(please excuse the sloppy code, all I've been doing is experimenting):int Draw(){glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);// Clear Screen And Depth BufferglColor4f(1.0f,1.0f,1.0f,1.0f);glEnable(GL_BLEND);glEnable(GL_TEXTURE_2D);glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);glLoadIdentity();glTranslatef(0.0f,0.0f,-1.0f);glColor3f(1.0f,1.0f,1.0f);glRasterPos2f(-0.51f,0.15f);glLoadIdentity();glTranslatef(0.0f,0.0f,-1.0f);glColor3f(1.0f,1.0f,1.0f);glRasterPos2f(-0.51f,0.35f);//glShadeModel(GL_SMOOTH);glPrint("LeftMom: %f, RightMom: %f WallLeft: %d Frame: %d", Player->fLeftmomentum, Player->fRightmomentum, bHitWallLeft, framecount);//, (int)bXGrav);glPushMatrix();glLoadIdentity();glMatrixMode(GL_MODELVIEW);glBindTexture(GL_TEXTURE_2D,8);   glBegin(GL_QUADS)   /*Draw sky...etc..etc..*/glEnd();    //Generate Mapfor(int x=0; x<NUM_OF_TILES; x++){if(tiles[x].x <= 8.5f && tiles[x].x >= -8.5){ //render tiles that are only within the camera's viewglLoadIdentity();gluLookAt (Camera->x, Camera->y, 1.0, 0.0, Camera->y, 0.0,0.0, 1.0, 0.0); glTranslatef(tiles[x].x, tiles[x].y, -10.0f);if(tiles[x].identifier == 1 || tiles[x].identifier == 4)glBindTexture(GL_TEXTURE_2D,1);else if(tiles[x].identifier == 2)glBindTexture(GL_TEXTURE_2D,1);else if(tiles[x].identifier == 3)glBindTexture(GL_TEXTURE_2D,7);//else//LoadTexture("NOTEX.tga", NULL);glBegin(GL_QUADS);glTexCoord2f(0.0f, 0.99f);glVertex2f(-1.0f, -1.0f);glTexCoord2f(1.0f, 0.99f);glVertex2f( 1.0f, -1.0f);glTexCoord2f(1.0f, 0.01f);glVertex2f( 1.0f,  1.0f);glTexCoord2f(0.0f, 0.01f);glVertex2f(-1.0f,  1.0f); glEnd();}}  /*Draw player...*/glLoadIdentity();gluLookAt (Camera->x, Camera->y, 1.0, /* position of eye */0.0, Camera->y, 0.0, /* at, where pointing at */0.0, 1.0, 0.0); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);glTranslatef(Player->XPos,Player->YPos,-10.0f);//glMatrixMode(GL_MODELVIEW);glBindTexture(GL_TEXTURE_2D, 2);//LoadTexture(Player->sSprite[Player->iCurrentSprite],NULL);glBegin(GL_QUADS);if(Player->cDirection == 'R'){glTexCoord2f(0.0f, 1.0f);glVertex2f(-1.0f, -1.0f);glTexCoord2f(1.0f, 1.0f);glVertex2f( 1.0f, -1.0f);glTexCoord2f(1.0f, 0.0f);glVertex2f(1.0f,  1.0f);glTexCoord2f(0.0f, 0.0f);glVertex2f(-1.0f,  1.0f); glEnd();}else if(Player->cDirection == 'L'){glTexCoord2f(1.0f, 1.0f);  glVertex2f(-1.0f, -1.0f);//bottom leftglTexCoord2f(0.0f, 1.0f);  glVertex2f( 1.0f, -1.0f); //bottom rightglTexCoord2f(0.0f, 0.0f);  glVertex2f(1.0f,  1.0f); //top rightglTexCoord2f(1.0f, 0.0f);  glVertex2f(-1.0f,  1.0f); //top leftglEnd();}   /*and some more drawing ensues....*/    /*once all the drawing is done(all similar to above)...*/   glDisable(GL_BLEND);glPopMatrix();glEnd();glFinish();And then a small snippet of my UpdateMath() Function:(I'm not sure if you really need to see this, but just in case it pertains to the problem--sorry for the spamming of code :P )if(!mapinited){for(int x = 0; x<NUM_OF_TILES; x++){tiles[x].bGoingDown = false;tiles[x].bGoingUp = false;tiles[x].bInMotion = false;tiles[x].OriginalY = mapcoordsY[x];}mapinited = true;}if(!GetAsyncKeyState(VK_UP))bUpUnpressed = true;//glAlphaFunc(GL_NOTEQUAL,1.0f);//9.006//Player->XPos += 0.00611444444f;//#ifndef goddamnmedre//Player->XPos = -3.503f;//Player->YPos = 48.00f;//Prep for map generationfor(int x=0; x<NUM_OF_TILES; x++){tiles[x].x = mapcoordsX[x];tiles[x].y = mapcoordsY[x];tiles[x].identifier = map[x];//tiles[x].YGroundPoint = 1.05f;tiles[x].XSidePoint = 1.0f;if(tiles[x].identifier == 1 || tiles[x].identifier == 4){tiles[x].YGroundPt[0] = 1.05f;tiles[x].YGroundPt[1] = 1.05f;tiles[x].YGroundPt[2] = 1.05f;tiles[x].YGroundPt[3] = 1.05f;tiles[x].YGroundPt[4] = 1.05f;tiles[x].YGroundPt[5] = 1.05f;tiles[x].YGroundPt[6] = 1.05f;tiles[x].YGroundPt[7] = 1.05f;tiles[x].YGroundPt[8] = 1.05f;tiles[x].YGroundPt[9] = 1.05f;tiles[x].YGroundPt[10] = 1.05f;tiles[x].YGroundPt[11] = 1.05f;tiles[x].YGroundPt[12] = 1.05f;tiles[x].YGroundPt[13] = 1.05f;tiles[x].YGroundPt[14] = 1.05f;tiles[x].YGroundPt[15] = 1.05f;tiles[x].YGroundPt[16] = 1.05f;tiles[x].YGroundPt[17] = 1.05f;tiles[x].YGroundPt[18] = 1.05f;tiles[x].YGroundPt[19] = 1.05f;}if(tiles[x].identifier == 3){tiles[x].YGroundPt[0] = 1.05f;tiles[x].YGroundPt[1] = 1.05f;tiles[x].YGroundPt[2] = 1.05f;tiles[x].YGroundPt[3] = 1.05f;tiles[x].YGroundPt[4] = 1.05f;tiles[x].YGroundPt[5] = 1.05f;tiles[x].YGroundPt[6] = 1.05f;tiles[x].YGroundPt[7] = 1.05f;tiles[x].YGroundPt[8] = 1.05f;tiles[x].YGroundPt[9] = 1.05f;tiles[x].YGroundPt[10] = 1.09f;tiles[x].YGroundPt[11] = 1.13f;tiles[x].YGroundPt[12] = 1.17f;tiles[x].YGroundPt[13] = 1.21f;tiles[x].YGroundPt[14] = 1.25f;tiles[x].YGroundPt[15] = 1.29f;tiles[x].YGroundPt[16] = 1.33f;tiles[x].YGroundPt[17] = 1.37f;tiles[x].YGroundPt[18] = 1.41f;tiles[x].YGroundPt[19] = 1.45f;}}//#define goddamnmedre//#endiffor(int x = 0; x<NUM_OF_TILES; x++){if(tiles[x].identifier == 4){if(!tiles[x].bInMotion){tiles[x].OriginalY = mapcoordsY[x];tiles[x].bInMotion = true;tiles[x].bGoingUp = true;}else if(tiles[x].bInMotion){if(tiles[x].bGoingUp){mapcoordsY[x] += 0.035f;if(tiles[x].y >= tiles[x].OriginalY+2.3f){tiles[x].bGoingUp = false;tiles[x].bGoingDown = true;}}if(tiles[x].bGoingDown){mapcoordsY[x] -= 0.035f;if(tiles[x].y <= tiles[x].OriginalY){tiles[x].bGoingUp = true;tiles[x].bGoingDown = false;}}}}}if(!bYGrav)momentum -= 0.003f;if(Player->fLeftVelocity < 0.0f)Player->fLeftVelocity = 0.0f;if(Player->fRightVelocity < 0.0f)Player->fRightVelocity = 0.0f;if(Player->fLeftmomentum < 0.0f)Player->fLeftmomentum = 0.0f;if(Player->fLeftmomentum > 0.2f)Player->fLeftmomentum = 0.2f;if(Player->fRightVelocity > 0.2f)Player->fRightVelocity = 0.2f;if(Player->fLeftVelocity > 0.2f)Player->fLeftVelocity = 0.2f;if(Player->fRightmomentum > 0.2f)Player->fRightmomentum = 0.2f;if(Player->fRightmomentum > 0.0f){Player->fRightVelocity = Player->fRightmomentum;Player->cDirection = 'R';}else if(Player->fLeftmomentum > 0.0f){Player->fLeftVelocity = Player->fLeftmomentum;Player->cDirection = 'L';}if(Player->fLeftVelocity > 0.003f || Player->fRightVelocity > 0.003f){if(Player->iCurrentSprite < 4)Player->iCurrentSprite ++;else if(Player->iCurrentSprite >= 4)Player->iCurrentSprite = 0;}else{Player->iCurrentSprite = 0;}//glShadeModel(GL_SMOOTH);if(GetAsyncKeyState(VK_UP) && !bHitWallBottom && !bJumping && bYGrav && bUpUnpressed == true){bJumping = true;bUpUnpressed = false;iJumpCount = 0;}if(bJumping && !bHitWallBottom){Player->YPos += 0.3f;iJumpCount ++;}if(bHitWallBottom && bJumping){iJumpCount = 0;bJumping = false;}if(iJumpCount >= 10)bJumping = false;if((GetAsyncKeyState(VK_LEFT) || (Player->fLeftmomentum > 0.0f)) && Player->XPos > -0.64f && !bHitWallRight){bFutureCollide = false;for(int x = 0; x<NUM_OF_TILES; x++){if( Player->XPos-0.1f <= (tiles[x].x+1.5) && Player->XPos-0.1f >= (tiles[x].x-1.5f )){if(Player->YPos <= (tiles[x].y) + tiles[x].YGroundPoint-0.1f){if(Player->YPos >= tiles[x].y-1.0f){if(Player->XPos-0.1f < tiles[x].x){bFutureCollide = true;//Player->fLeftmomentum = 0.0f;}}}}}if(!bFutureCollide){if(Player->fRightmomentum <= 0.0f){//increase momentum only if player is continually inputting leftif(GetAsyncKeyState(VK_LEFT))Player->fLeftmomentum += 0.003f;Player->XPos-=Player->fLeftVelocity;}}}if(GetAsyncKeyState(VK_DOWN))Player->YPos-=0.003f;if(bGravity && !bJumping){Player->YPos-=0.2f;}//Player is trying to change direction, adjust momentum accordinglyif(Player->fRightmomentum > 0.0f && GetAsyncKeyState(VK_LEFT) && !GetAsyncKeyState(VK_RIGHT)){Player->fRightmomentum -= 0.03f;}if(Player->fLeftmomentum > 0.0f && GetAsyncKeyState(VK_RIGHT) && !GetAsyncKeyState(VK_LEFT)){Player->fLeftmomentum -= 0.03f;}//Decrease momentum as long as there's no inputif(!GetAsyncKeyState(VK_RIGHT) && !GetAsyncKeyState(VK_LEFT)){if(Player->fRightmomentum >= 0.0f){Player->fRightmomentum -= 0.003f;}if(Player->fLeftmomentum >= 0.0f){Player->fLeftmomentum -= 0.003f;}}if(Player->fRightmomentum > 0.0f)Player->fLeftmomentum = 0.0f;else if(Player->fLeftmomentum > 0.0f)Player->fRightmomentum = 0.0f;//Camera->y = Player->YPos;if(Camera->y > Player->YPos+1.0f){Camera->y -= 0.10f;}if(Camera->y < Player->YPos-1.0f){Camera->y += 0.1f;}if((GetAsyncKeyState(VK_RIGHT) || Player->fRightmomentum > 0.0f) && Player->XPos < 0.64f && !bHitWallLeft){bFutureCollide = false;for(int x = 0; x<NUM_OF_TILES; x++){if( (Player->XPos+0.2f) <= (tiles[x].x+1.5) && Player->XPos+0.2f >= (tiles[x].x-1.5f )){if(Player->YPos <= (tiles[x].y) + tiles[x].YGroundPoint-0.1f){if(Player->YPos >= tiles[x].y-0.1f){if(Player->XPos+0.2f< tiles[x].x){bFutureCollide = true;//Player->fRightmomentum = 0.0f;}}}}}if(!bFutureCollide){if(Player->fLeftmomentum <= 0.0f){if(GetAsyncKeyState(VK_RIGHT))Player->fRightmomentum+=0.003f;Player->XPos+=Player->fRightVelocity;}}}if((GetAsyncKeyState(VK_RIGHT) || Player->fRightmomentum > 0.0f) && Player->XPos >= 0.64f && !bHitWallLeft){if(bYGrav)momentum += 0.003f;bFutureCollide = false;for(int x = 0; x<NUM_OF_TILES; x++){if( Player->XPos+0.1f <= (tiles[x].x+1.5) && Player->XPos+0.1f >= (tiles[x].x-1.5f )){if(Player->YPos <= (tiles[x].y) + tiles[x].YGroundPoint-0.1f){if(Player->YPos >= tiles[x].y-1.0f){if(Player->XPos+0.1f < tiles[x].x){bFutureCollide = true;//Player->fRightmomentum = 0.0f;}}}}}if(!bFutureCollide){if(Player->fLeftmomentum <= 0.0f){if(GetAsyncKeyState(VK_RIGHT))Player->fRightmomentum += 0.003f;for(int x = 0; x < NUM_OF_TILES; x++){mapcoordsX[x]-=Player->fRightVelocity;}}}}if((GetAsyncKeyState(VK_LEFT) || Player->fLeftmomentum > 0.0f) && Player->XPos <= -0.64f &&!bHitWallRight){bFutureCollide = false;for(int x = 0; x<NUM_OF_TILES; x++){if( Player->XPos-0.1f <= (tiles[x].x+1.5) && Player->XPos-0.1f >= (tiles[x].x-1.5f )){if(Player->YPos <= (tiles[x].y) + tiles[x].YGroundPoint-0.1f){if(Player->YPos >= tiles[x].y-1.0f){if(Player->XPos-0.1f < tiles[x].x)bFutureCollide = true;}}}}if(!bFutureCollide){if(Player->fRightmomentum <= 0.0f){if(GetAsyncKeyState(VK_LEFT))Player->fLeftmomentum += 0.003f;for(int x = 0; x < NUM_OF_TILES; x++){mapcoordsX[x] += Player->fLeftVelocity;}}}}bGravity = true;currenttile = -1;bXGrav = false;bYGrav = false;xtile = -1;iXCount  =0;bHitWallLeft = false;bHitWallRight = false;bHitWallBottom = false;first=false;second = false;third = false;//if(Player->XPos <= (tiles[currenttile].x + 1.0f) && Player->XPos >= (tiles[currenttile].x-1.0f))//{//}for(int x = 0; x<NUM_OF_TILES; x++){if( Player->XPos <= (tiles[x].x+1.5) && Player->XPos >= (tiles[x].x-1.5f )){bXGrav = true;xtile = x;iXCount ++;if(Player->YPos >= (tiles[x].y+tiles[x].YGroundPoint-0.4f) && (Player->YPos <= (tiles[x].y) + tiles[x].YGroundPoint)){Player->YPos = (tiles[x].y+tiles[x].YGroundPoint);bYGrav = true;bGravity = false;currenttile = x;//break;}}}for(int x = 0; x<NUM_OF_TILES; x++){if(Player->XPos <= ((tiles[x].x-1.0f)+(2.0f/10.0f))) //&& Player->XPos >= (tiles[currenttile].x-1.0f)){tiles[x].YGroundPoint = tiles[x].YGroundPt[0];}for(int n = 1; n < 20; n++){if(Player->XPos <= ((tiles[x].x-1.0f)+(2.0f/20.0f)+((2.0f/20.0f)*n)) && Player->XPos > ((tiles[x].x-1.0f)+((2.0f/20.0f)*n))){tiles[x].YGroundPoint = tiles[x].YGroundPt[n];}}}for(int x = 0; x<NUM_OF_TILES; x++){if( Player->XPos <= (tiles[x].x+1.3) && Player->XPos >= (tiles[x].x-1.3f )){if(Player->YPos >= tiles[x].y-1.5f && Player->YPos <= tiles[x].y-0.5f)bHitWallBottom = true;}}for(int x = 0; x<NUM_OF_TILES; x++){if( Player->XPos <= (tiles[x].x+1.5) && Player->XPos >= (tiles[x].x-1.5f )){first = true;if(Player->YPos <= (tiles[x].y) + tiles[x].YGroundPoint-0.1f){second = true;if(Player->YPos >= tiles[x].y-1.0f){third = true;if(Player->XPos > tiles[x].x){bHitWallRight = true;//Player->fLeftmomentum = 0.0f;}if(Player->XPos < tiles[x].x){bHitWallLeft = true;//Player->fRightmomentum = 0.0f;}}}}}And that really about does it for my Draw() and UpdateMath() functions. In my window.cpp file, where the functions themselves are called, I've played around a bit with trying to control the framerate, as you can see for yourself:if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))// Is There A Message Waiting?{if (msg.message==WM_QUIT)// Have We Received A Quit Message?{done=TRUE;// If So done=TRUE}else// If Not, Deal With Window Messages{TranslateMessage(&msg);// Translate The MessageDispatchMessage(&msg);// Dispatch The Message}}else// If There Are No Messages{//FirstCount = (GLfloat)GetTickCount();// Draw The Scene.  Watch For ESC Key And Quit Messages From DrawGLScene()//glFinish();//CurrentCount = GetTickCount();//if(CurrentCount > (FirstCount+20))//{//FirstCount = CurrentCount;UpdateMath();//}//CurrentCount2 = GetTickCount();//if(CurrentCount2 > (FirstCount2+20))//{//FirstCount2 = CurrentCount2;//glFlush();DrawScene();//}Obviously with all the commenting-out it's pretty apparent I've been playing with this for awhile, building the project and copying it to my friend's laptop, just to have it go to a screeching halt once run. I know for a fact the problem is not on his end, he has a pretty decent thinkpad running Windows 7 that he just purchased, and it runs other games just fine. I'm at a complete loss here, and I have no room for any more trial and error because I'm starting my biochemistry classes Wednesday. Does it have something to do with too many textures being displayed at once? Are the textures themselves too large in size or dimension? I've noticed a few times before I implemented a framerate loop that the more polygons that had 32-bit TARGA's with alpha channels on them caused the game to slow a bit and become choppy. So, to all you OpenGL experts out there, what am I missing? Would 12 or so textured polygons really cause the game to come to screeching halt? I forgot to mention, I'm on a ten year old PC and using an old AGP graphics card, my friend's laptop is superior in every way except in terms of graphics acceleration. I hope it's a quick fix of some sort, but knowing my luck...enh. I really appreciate your help and look forward to your replies. Thanks again guys!   