PDA

View Full Version : Partial Redraw



Stiggz
07-09-2010, 11:34 AM
Hi,

I've written a .OBJ loader that loads all vertices and faces in a given .obj file into arrays, and then uses those arrays to render an openGL scene. I'm loading 3 different files, and thus drawing three different objects in the scene. One of these objects has about 1 million vertices, and the other two have about half that. The more complex object does not need to be redrawn very often, so I'm wondering if it's possible to only redraw the objects I need, while leaving the third as is. I did a little googling and didn't find any commonly accepted way of doing this.

If it's not possible, what else can I do to speed up my program? I'd like movement to be smooth (at least for the two smaller objects), and it's very choppy right now.

Thanks,
Zach

Rosario Leonardi
07-09-2010, 12:07 PM
1 million vertex are not too much for a modern graphic card.
Which technique are you using? If you use VBO (or even display list) you can draw them quite fast.

Returning to your problem.
If the camera don't move you can render your heavy object on a texture and then drawing a big quad with your object and then the other object.

This should work if the other objects don't intersect with your heavy object.
If you need intersection you can save the color of the object on a texture and the depth on another (if you want dynamic light you can save the normal on another texture).

Then render a quad with a shader that use your textures (color, depth and optionally normal) and you can reconstruct all the information of your original object.

carsten neumann
07-09-2010, 03:09 PM
The technique Rosario describes is often called 'Impostor' which itself is a special type of billboarding. Just in case you want to google this some more :)

GL Starter
07-09-2010, 10:26 PM
If you create a call list for rendering complex objects, then you can avoid CPU to GPU transfer of vertex data.

In this method, redrawing of all objects( complex and other objects) will happen. But reading of data and transfer of vertex data from CPU to GPU can be avoided.

GLUint gComplexObjects = 0;

LoadComplexObject() // Once create complex object.
{
// Initially create complex object as a call list.
gComplexObjects = glGenLists(1);

// read Vertex data from File.

glNewList( gComplexObjects , GL_COMPILE );

// Here put all glVertex and other opengl calls for rendering complex object.

glEndList();
}

RenderAllObjects()
{
glCallList( gComplexObjects );// Complex object redrawing wih less load.
// Draw non complex objects.
}