Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

You can think of my application as drawing a very large ball-and-stick diagram (or graph). At times, this graph can get very large, where the number of elements even outnumbers the pixels on the screen. Currently I am simply passing all of my textures (as GL_POINTS) and lines to the graphics card using VBO's.

When the number of elements outnumbers the number of pixels, is this the most efficient way to do this? Or should I do some calculations on the CPU side before handing everything over to the GPU?

If it matters, I do use GL_DEPTH_TEST and GL_ALPHA_TEST. I do some alpha blending, but probably not enough to make a huge performance difference.

My scene can be static at times, but the user has control over a typical arc-ball camera and can pan, rotate, or zoom. It is during these operations that performance degradation is noticeable.

share|improve this question
add comment

2 Answers

If there is more than one element per pixel on the screen there is no point in rendering all of them. Try to find a way to cull elements that either aren't visible anymore or don't contribute to the final image.

It's also a good idea to consider using a dynamic level of detail reduction on your model to reduce the load.

share|improve this answer
    
Those are great general concepts, and I figured the answers would circle around something like that. What I'd really like to know is if OpenGL can do any of this automatically for me. Or do I have to write all of my own culling and DLOD math? Or are there 3rd party options (I'm in Java using JOGL 2.0). –  Luke Jun 22 '12 at 13:12
    
No. OpenGL is a hardware rendering API, not a scene graph or graphics engine. Such packages exist (OpenSceneGraph, for example), but are not a part of OpenGL or D3D. –  Sean Middleditch Jun 23 '12 at 19:34
add comment

Unfortunately to find the fastest solution you might need to implement and test several, because it can vary depending on your graphics card manufacturer, driver version, etc.

For example, rendering as points & lines might actually be slower than rendering them as textured quads (pairs of triangles) - triangle rendering is the most common use case, so manufacturers focus optimisations on this path. Some drivers may just implement points and lines as triangles anyway, so you may not notice any difference if you make the change.

If you have many similar sprites you should also look at instancing techniques, which will reduce the amount of data you need to send to the GPU and may improve performance.

share|improve this answer
    
The main reason I'm currently using Points is to reduce the amount of data sent to the card. That is, I can describe a point with 3 floats, vs. 12 floats for a quad. I'm not familiar with instancing, can you provide more information on that? For the most part, all of my textures are the same (for now). –  Luke Jun 27 '12 at 12:25
    
Here's a decent looking tutorial on OpenGL instancing: link. Sounds like it does what you're after - you describe the initial shape (a quad) with 4 verts, and then pass a buffer full of locations to draw this shape at. In that sample they have a full matrix for each instance, but if you're only bothered about position it should be possible to just use a vector per instance and handle it as appropriate in your shader code. –  BpHinch Jun 27 '12 at 15:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.