本文介绍了OpenGL跨度glVertexPointer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OpenGL 2.0渲染器( https://bitbucket.org/mattiascibien/anima-render ),实际上我碰到了一点我根本不了解的东西,这是 glVertexPointer()指令的一大步.其实我的代码看起来像这样

I am working on a OpenGL 2.0 renderer (https://bitbucket.org/mattiascibien/anima-render) and I actually came across smething I cannot understand at all which is the stride for the glVertexPointer() instruction. Actually my code looks like this

glBindBuffer(GL_ARRAY_BUFFER, data.vertex_buffer);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(
    3,
    GL_FLOAT,
    sizeof(GLfloat)*3,
    (void*)0
    );

但是我实际上发现,通过阅读OpenGL文档,步幅实际上应该为0.更改它不会改变模型的呈现方式.

but I actually found that by reading OpenGL documentation the stride should actually be 0. Changing it does not change how the model is rendered.

什么值是正确的?为什么更改此参数没有区别?

What value is correct? Why does changing this parameter makes no difference?

数据存储在

std::vector<GLFloat>

使用sizeof(GLfloat)* 2或0的glTexCoordPointer也会发生同样的情况

same happens with glTexCoordPointer using sizeof(GLfloat)*2 or 0

推荐答案

https://www.opengl.org/sdk/docs/man2/xhtml/glInterleavedArrays.xml 提供了有关它的更多信息.

https://www.opengl.org/sdk/docs/man2/xhtml/glInterleavedArrays.xml gives more infos about it.

在提供跨度时,即0或您的结构"大小(3 * sizeof(GLFloat)),这是相同的.但是在这种情况下,我会选择0.

while you are providing a stride, that is 0 or your "struct" size (3*sizeof(GLFloat)) this is the same. Yet I'd go with 0 in this case.

这篇关于OpenGL跨度glVertexPointer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 23:10