glsl double-precision vertex buffer

微笑、不失礼 提交于 2019-12-22 09:51:41

问题


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>

回答1:


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.



来源:https://stackoverflow.com/questions/10823811/glsl-double-precision-vertex-buffer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!