Search code examples
openglglslopengl-4

glsl double-precision vertex buffer


If I create a double-precision vertex buffer, for example:

GLuint vertBuffer, spanBuffer, spanCount, patchSize, program; // already setup
glUseProgram (program);
glEnableClientState (GL_VERTEX_ARRAY);
glBindBuffer (GL_ARRAY_BUFFER, vertBuffer);
glVertexPointer (3, GL_DOUBLE, 0, 0);
glPatchParameteri (GL_PATCH_VERTICES, patchSize);
glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, spanBuffer);
glDrawElements (GL_PATCHES,  spanCount * patchSize, GL_UNSIGNED_INT, 0);

How do I access the double precision data in my vertex shader? Should I be able to do this?

// GLSL VERTEX SHADER
#version 410

in dvec4 gl_Vertex;

void main ()
{
<snip>

Solution

  • You don't. At least, not that way.

    If you want to use OpenGL 4.x+'s ability to read double-precision values into your shader, then you must use generic vertex attributes. You can't use old fixed-function gl_Vertex and glVertexPointer anymore. You must use glVertexAttribLPointer, with a proper generic vertex attribute index.