Jump to content
  • Advertisement
Sign in to follow this  
Mr Awesome

Optimization

This topic is 4529 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

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?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
What is your graphics card? What is the screen resolution and color depth? What is the size of the texture and its color depth?

Share this post


Link to post
Share on other sites
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!