Lefteris
07-18-2011, 09:15 AM
Hello,
In my application I have many routines which create 2D (x,y) surfaces, triangulate them and upload them to a 2D VBO. So no Z coordinate is actually in play. Later I draw with glDrawElements() and glOrtho and all is fine and 2D.
My first question is in here. What's the default z that is given when glDrawElements() is used in such a situation?
Now I have started to have the need to extrude some of these surfaces. So from 2d they will go to 3d.
I thought that the solution would be to go to perspective projection, draw the surface once, translate on the z axis by the depth I would like the extruded surface to have and then redraw the surface. And after that I would only need to draw the triangles that connect these two surfaces and voila, we have an extruded surface.
The problem is this though:
How can this be done without reading data from the VBO with glMapBuffer or similar functions? What would generally be the fastest way to do this?
I thought of doing it with glMapBuffer but I am afraid it would end up being too slow. Another option would be to use geometry shaders. Would that be faster? I did it simply with glBegin-glEnd but I am afraid that when my application scales up it will become impossible to keep it like that.
In my application I have many routines which create 2D (x,y) surfaces, triangulate them and upload them to a 2D VBO. So no Z coordinate is actually in play. Later I draw with glDrawElements() and glOrtho and all is fine and 2D.
My first question is in here. What's the default z that is given when glDrawElements() is used in such a situation?
Now I have started to have the need to extrude some of these surfaces. So from 2d they will go to 3d.
I thought that the solution would be to go to perspective projection, draw the surface once, translate on the z axis by the depth I would like the extruded surface to have and then redraw the surface. And after that I would only need to draw the triangles that connect these two surfaces and voila, we have an extruded surface.
The problem is this though:
How can this be done without reading data from the VBO with glMapBuffer or similar functions? What would generally be the fastest way to do this?
I thought of doing it with glMapBuffer but I am afraid it would end up being too slow. Another option would be to use geometry shaders. Would that be faster? I did it simply with glBegin-glEnd but I am afraid that when my application scales up it will become impossible to keep it like that.