Optimization

Started by
18 comments, last by Sneftel 17 years, 11 months ago
Right now the graphics part of my 2D racing game is really slowing everything down. All I'm rendering is two textured background quads and a bunch of textured triangles in the form of a racetrack. The background is really slowing everything down a lot; without it I get an improvement of around 20 FPS. I will probably cut it down to just one quad to get a little more performance, but does anyone know of a good way to optimize a fairly detailed and large textured quad?
Advertisement
reduce the resolution of the texture, or split the texture into smaller ones on different quads.

What are the dimensions of your background-texture? (e.g. 256x256 or 512x512) Make sure both its width and height are power-of-2 values. Something like 800x600 (non-power-of-2) can seriously slowdown your app.
Will splitting it up really increase the speed very much? Seems like it would be a lot of work, and I don't want to do it for nothing.
depends where the bottle neck is more than anything
Quote:Original post by Mr Awesome
Right now the graphics part of my 2D racing game is really slowing everything down. All I'm rendering is two textured background quads and a bunch of textured triangles in the form of a racetrack. The background is really slowing everything down a lot; without it I get an improvement of around 20 FPS. I will probably cut it down to just one quad to get a little more performance, but does anyone know of a good way to optimize a fairly detailed and large textured quad?


Sounds like something is off in your code. What are you doing to draw the textured quads each frame?
Free Mac Mini (I know, I'm a tool)
The bottleneck is entirely in the graphics rendering. I'm currently using immediate mode to render everything. I tried a display list for the racetrack, but it didn't help one bit.
Two textured quads would not stress any graphics card that has been made in the last several years. From what I can gather without seeing your code, you are doing something very expensive and inefficient (like transferring a large texture over the system bus) every frame.
Free Mac Mini (I know, I'm a tool)
This is the only code getting called with respect to the background:

// Displays part of the image to the screen using the four vertices of a// quad given as the texture's destination.void Texture::Render(int srcLeft, int srcTop, int srcWidth, int srcHeight,                     Vector2D topLeft,    Vector2D topRight,                     Vector2D bottomLeft, Vector2D bottomRight) const{    // Texture Coordinates    float tLeft   = srcLeft              / static_cast<float>(m_Width);    float tRight  = (srcLeft + srcWidth) / static_cast<float>(m_Width);    float tTop    = srcTop               / static_cast<float>(m_Height);    float tBottom = (srcTop + srcHeight) / static_cast<float>(m_Height);    // Prepare for rendering.    glEnable(GL_TEXTURE_2D);    glEnable(GL_BLEND);    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);    glBindTexture(GL_TEXTURE_2D, m_TextureID);    // Render textured quad.    glBegin(GL_QUADS);        glColor3f(1.0f, 1.0f, 1.0f);        // Top-left        glTexCoord2f(tLeft, tTop);        glVertex2f  (topLeft.x, topLeft.y);        // Top-right        glTexCoord2f(tRight, tTop);        glVertex2f  (topRight.x, topRight.y);        // Bottom-right        glTexCoord2f(tRight, tBottom);        glVertex2f  (bottomRight.x, bottomRight.y);        // Bottom-left        glTexCoord2f(tLeft, tBottom);        glVertex2f  (bottomLeft.x, bottomLeft.y);    glEnd();    glDisable(GL_TEXTURE_2D);    glDisable(GL_BLEND);}


I'm definitely not loading the texture more than once; I have a texture manager that makes sure of that. Could it be that the background picture is too high quality?

Also, for the racetrack, would a vertex array possibly give a performance boost?
What is your graphics card? What is the screen resolution and color depth? What is the size of the texture and its color depth?

This topic is closed to new replies.

Advertisement