View Full Version : Need help with rendering several models
01-12-2012, 05:10 PM
I'm actually trying to render a scene containing several models. Each model has his own modelview matrix, so I cannot just specify one modelview matrix and use it for all the geometry, it will lead to undesired results.
Now the problem is that I simply do not now what is the procedure of rendering several models with different modeling transformations. Should I specify the geometry several times and call drawTriangles several times before swapping the buffers?
sorry for the silly question.
01-12-2012, 11:33 PM
Yes of course.
01-13-2012, 02:02 AM
I suppose you are using the Fixed function pipeline (http://www.opengl.org/wiki/Fixed_Function_Pipeline). If you need better performance, it may be an advantage to use your own shaders with vertex buffers (http://www.opengl.org/wiki/Vertex_Buffer_Object).
That way, you define the geometry and download it to the graphic card only once, then only have to update the model+view matrix between every draw() call.
01-13-2012, 02:49 AM
Thank you for the answer.
Actually yes, I am using shaders with quite big models.
I guess I will need to figure out what's the maximum capacity of a vertex array befure uploading all the data to the card...
01-13-2012, 03:11 AM
Just a notice: I have a similar situation, with big models and lots of data. At first, I was greedy and defined the data of the type GL_BYTE instead of GL_FLOAT. While it saved GPU memory, it is not the "native format", and there was a performance penalty. I suppose the penalty will vary for different graphic cards.
Using indexed drawing (with glDrawElements) can allow you to use fewer vertices. With some luck, every vertex is used 6 times in a mesh. It also speeds up rendering, as the graphic card will use the cache and only execute the fragment shader once.
01-13-2012, 01:21 PM
[quite] It also speeds up rendering, as the graphic card will use the cache and only execute the fragment shader once. [/QUOTE]
I think you mean "it can caches already processed vertices so it doesn't have to run the vertex shader again". :)
heinz: How big are we talking here?
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.