Rendering without vertex data (gl_VertexID only)

first I’ve written a blog entry about this:
It’s explaining what I am going to say in more details and with screenshots.
I’m going to paraphrase the general concept here though.

My question is whether this idea is valid and whether I can expect it to continue to work with new drivers (it works on my 8600M GT right now) and if anyone knows something better to achieve the same.

So as the topic says, I want to render primitives without specifying any vertex data but generate everything procedurally using gl_VertexID.
gl_VertexID is only supplied by OGL if you bind a vertex buffer to your vertex array.
I’m using an one-element VBO but render more than one vertex out of it - I pretty much ignore the bounds and if I accessed the vertex information at all it would be an out-of-bounds condition.
My GLSL shader doesn’t access gl_Vertex, so there shouldn’t be a problem.

The actual idea is to specify an element array (which sets gl_VertexID) and encode some vertex data in the element array. The advantage over using a vertex array buffer is that the gfx card should be able to use the vertex cache to minimize shader executions.

Again my question is whether anyone knows a better way to achieve all this and/or if my current method is good or too big a hack.
Thanks in advance.


Why don’t you setup a VBO with one point in it, and then render it via instancing n times. You can then use the gl_InstanceID instead of the gl_VertexID, and you are on the save side, not to run over bounds.

Note that i haven’t read your blog yet, so i might be missing something.


Oh right, thanks. This should indeed work well for the first case. I’m going to try that.

However, I doubt there is a way to use this with an element array that encodes some of the vertex data. I guess I could bind the data as texture buffer and use gl_InstanceID as look-up coordinate but I think this would lose the cache advantage the element array approach has.


If you need a feature that’s missing in OpenGL and the other API supports it, you can always raise your opinions in the Talk about your applications thread.