Reputation: 121
Which way of rendering two graphic elements with the same shape but different coordinates is more efficient using OpenGL (for eg. one object is upside down)?
Additional question: Is there a possibility to create a set of points inside a shader? (This points will be calculated using sin()
and cos()
functions)
Upvotes: 0
Views: 203
Reputation: 26
If in the first case you're switching buffers between OpenGL function calls then probably both solutions are equally bad. If you're holding two shapes in a single buffer and drawing everything in a single call then it's going to be faster than solution 2, but it requires twice the memory, which is also bad.
( You should have a single buffer for the shape and another one for transformations )
In general, you should use as few OpenGL calls as possible.
Regarding the second question: yes. For example, you could use a hard-coded array or derive the point coordinates from gl_VertexID.
Upvotes: 1