Jump to content
  • Advertisement
Sign in to follow this  
MoonDemon

OpenGL Some help with optimization

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

I am currently writing a little engine based on OpenGL. It will allow somebody to create a 2.5d game ( a 3d looking game based on 2d logic ) by dropping object onto a 2d map. Given the simplicity of this, I am a little concerned by the speed at which this runs on my machine. The scene comprises of backdrops (objects that will not move) and actives (objects that will move at some point). I thought that the best idea would be to draw all of the backdrop objects into a display list. Is this a good idea? The majority of the scene is drawn into a display list. I don't know if this would cause problems given the size of the scene? I have been trying to work out where the bottleneck in the system is and I think it comes from a vertex limitation. My scenes are very simple in the sense that there's no fancy lighting, no texture filtering: it's all very primitive in the grand scheme of things, and almost looks like a raycast engine, so I would expect a higher framerate than what I am getting on my machine. I am surprised that shrinking the farplane value doesn't yield a performance increase. Any insights on this would be very helpful :)

Share this post


Link to post
Share on other sites
Advertisement
A screenshot of what you are currently rendering would be helpful, as would letting us know just how bad the performance is, and on what hardware.

Keep in mind that performance rarely scales in a linear fashion, and frames-per-second isn't a linear measure of performance either.
Quote:
I thought that the best idea would be to draw all of the backdrop objects into a display list. Is this a good idea?
It is certainly a good first step. However, display lists can only optimise if you hand them very specific configurations of vertex data (i.e. all components present for all vertices), so you may not be getting much benefit at the moment.

I would recommend switching to VBO, but this may be a fair amount of work to implement if your current code is not designed with vertex-arrays/VBO in mind.
Quote:
I am surprised that shrinking the farplane value doesn't yield a performance increase.
This would only affect the number of fragments processed (and often minimally at that), since all vertices still have to be transformed and clipped. If you are indeed vertex bound, reducing the far plane distance will not help.

Share this post


Link to post
Share on other sites
If you are vertex bound you probably want to get some culling on the go before you pass the vertices to the GL. It sounds like you're dropping pre-baked objects in a repeating way? If (as swiftcoder suggests) you use VBOs and create these for each object you could then use instancing and some sort of geometry shader culling of the instances. At the very least simple bounding spheres on the CPU side should be used to cut down on the amount of geometry to be processed.

Share this post


Link to post
Share on other sites
Unfortunately I can't produce an image of the said scene (captain's orders), but I can describe it... The user drops squares/cubes onto a 2d grid which represent textured cubes/cuboids in a 3d space. The position of the square in 2d specifies the cube/cuboids x and z position and dimensions, and the object has additional variables for specifying the cube's height and y position. The user is able to specify a texture for each of the 6 faces, and not specifying a texture at all results in that quad not being rendered. In this case there are a lot of redundant quads as the user has specified textures on cube faces that are touching, but I figured it's not exactly the cause of the problem.

I have had numerous thoughts about how to optimise this. At the moment my approach is a little clumsy. For each object in the scene, the "draw cube" function is called. This function draws a maximum of 6 quads, binds their texures and specifies the texture coordinates. In any one scene I can call this function about 200 times. I figured it would be nice and easy to do this just the once and compile those commands into a display list. This makes it very easy for me to redraw the scene with just one call. However I am pretty sure this isn't the most efficient approach.

My first thought was that binding the texture each time is pretty inefficient. I could group quads by texture and draw them in a sorted order. I don't suppose OpenGL can optimise this for me (but it would be awfully nice if it did).

Secondly I could cull a lot of those cubes myself. Clearly not possible with my current displaylist approach. I imagine I could half the number of vertices being used to render the scene.

I do render everything with backface culling turned on, there's no lighting, the texturing mode is GL_DECAL instead of the default GL_MODULATE. The machine I am testing this with has an AMD Turion X2 processor @1.60GHz, 2GB ram and comes with a rather low end integrated ATI graphics card (Xpress 1150 I think). I installed the drivers for my card (ATI's legacy Xpress graphics driver) and the previous owner seemed to play Guildwars on it fine (though with medium/low graphic settings). I would expect the app I am running to do a little better on this spec as I would consider it lightweight (and I would consider this machine more than capable of rendering this in software). At the moment it runs at about 30fps, where my target is 50. Unfortunately I am unable to disconnect the logic speed from the rendering speed with the tools I am using. Obviously this is quite hideous in concept but I have to live with that. I don't think this is too ambitious, but may stand corrected?

Thanks for your help guys.

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!