Advertisement

Textures slowing the program?

Started by February 22, 2005 02:36 PM
0 comments, last by TerraX 20 years ago
I use a 512x512 texture as a background of the main menu of the game. I have added some menuitems there with normal fonts, createfont etc. If I put the texture on the backgound, the menuitems dont activate as quick as they did before(if you push up, menuitem text changes color). So is there an easy way to do this working? I think the problem is the large quad on the background.. Here some code:

void PiirraMenu(GLuint menutausta, int valittu)
{
    glEnable(GL_TEXTURE_2D);
    glMatrixMode(GL_PROJECTION);
    glBindTexture(GL_TEXTURE_2D, menutausta);
    
    glBegin(GL_QUADS);
      glTexCoord2f(0, 1);
      glVertex2f(-400, -300);
      glTexCoord2f(0, 0);
      glVertex2f(-400, 300);
      glTexCoord2f(1, 0);
      glVertex2f(400, 300);
      glTexCoord2f(1, 1);
      glVertex2f(400, -300);
    glEnd(); 
    
    glDisable(GL_TEXTURE_2D);
    
    if(valittu == 1)
        glColor3f(1, 1, 1);
    else
        glColor3f(0, 0, 0);
    glRasterPos2f(0, 100);
    glPrint("NEW GAME");
    
    if(valittu == 2)
        glColor3f(1, 1, 1);
    else
        glColor3f(0, 0, 0);
    glRasterPos2f(0, 40);
    glPrint("OPTIONS");
    
    if(valittu == 3)
        glColor3f(1, 1, 1);
    else
        glColor3f(0, 0, 0);
    glRasterPos2f(0, -20);
    glPrint("HISCORES");
    
    glColor3f(1.0f, 1.0f, 1.0f);
    
    return;
}    


Tiritomba
Are you running on old gfx hardware?
If so, rendering something which covers the entire backbuffer's dimensions will slow down the app slightly (In 640x480 = 307200 pixels), have you tried running the application in a really low res like 320x240.. is the slowdown with the background being rendered less noticable? If so, fillrate on your old hardware is limited.

Also... with blending enabled, this causes even more work for the graphics card, so before rendering the background, make sure you disable blending with glDisable(GL_BLEND), if however, you require blending, you may be able to get away with additive blending by setting the blending mode to glBlendFunc(GL_SRC_ALPHA, GL_ONE), instead of glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) which greatly speeds things up.

I appologize for being in-specific, I'd require a look-see at your source, if you can upload the project's source directory (If it's MSVC 6->7) somewhere where I can download it, I'll take a gander, try and help you out.

EDIT:
Also, if you're running on older gfx hardware, try using 256x256 texture for background as this will speed things up too.

EDIT2:
Using glRasterPos() looks like you're using some glPixels thingy function for drawing each pixel to the backbuffer, which is slow, try NeHe's font tutorial number 17 for faster text rendering.

EDIT3:
"(if you push up, menuitem text changes color). "
glDisable(GL_TEXTURE_2D);
Before rendering any text.
Also, glColor4f(1,1,1,1); (Or whatever) :)


[Edited by - TerraX on February 26, 2005 4:04:35 AM]

This topic is closed to new replies.

Advertisement