English 中文(简体)
VAO/VBO的开放式结构与移动部件的模型?
原标题:OpenGL structure of VAO/VBO for model with moving parts?
  • 时间:2012-01-14 13:42:57
  •  标签:
  • opengl
  • vbo
最佳回答

首先,在VAO之外,只有“成员”最后的纵向归属约束(以及VBO对指数缓冲(GL_ELEMENT_ARRAY_BUFFER_BINDING)具有约束力,如果有的话。 因此,在<条码>glDrawElements()中,你无需记住这一点,在使用日志时,你必须说这一点。 它不妨碍你使用环绕阵列。 请允许我解释:

int vbo[3];
glGenBuffers(3, vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
glBufferData(GL_ARRAY_BUFFER, data0, size0);
glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
glBufferData(GL_ARRAY_BUFFER, data1, size1);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo[2]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, data2, size2);
// create some buffers and fill them with data

int vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
// create a VAO

{
    glBindBuffer(GL_ARRAY_BUFFER, vbo[0]); // not saved in VAO
    glVertexAttribPointer(0, 3, GL_FLOAT, false, 3 * sizeof(float), NULL); // this is VAO saved state
    glEnableVertexAttribArray(0); // this is VAO saved state
    // sets up one vertex attrib array from vbo[0] (say positions)

    glBindBuffer(GL_ARRAY_BUFFER, vbo[1]); // not saved in VAO
    glVertexAttribPointer(1, 3, GL_FLOAT, false, 5 * sizeof(float), NULL); // this is VAO saved state
    glVertexAttribPointer(2, 2, GL_FLOAT, false, 5 * sizeof(float), (const void*)(2 * sizeof(float))); // this is VAO saved state
    glEnableVertexAttribArray(1); // this is VAO saved state
    glEnableVertexAttribArray(2); // this is VAO saved state
    // sets up two more VAAs from vbo[1] (say normals interleaved with texcoords)

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo[2]); // this is VAO saved state
    // uses the third buffer as the source for indices
}
// set up state that VAO "remembers"

glBindVertexArray(0); // bind different vaos, etc ...

后来......

glBindVertexArray(vao); // bind our VAO (so we have VAAs 0, 1 and 2 as well as index buffer)
glDrawElements(GL_TRIANGLE_STRIP, 57, GL_UNSIGNED_INT, NULL);
glDrawElements(GL_TRIANGLE_STRIP, 23, GL_UNSIGNED_INT, (const void*)(57 * sizeof(unsigned int)));
// draws two parts of the mesh as triangle strips

因此,请见......您使用单一甚小分辨率和一个或多个甚低分辨率分辨率分辨率阵列。

为了回答你提问的第二部分,您要么可以有不同的甚小分辨率和低分辨率分辨率分辨率分数,要么可以将其全部用到一个千分辨率高分辨率高的舱面(因此,你不需要打上<代码>glBind*() ,并且使用多个密码) 电话,以提取小小小小小小小小小小小sh(如上面的代码所示) ——想象第一部<编码>(glDrawElements() 船舶,而第2版) 检索,你只是更新中间线。

由于浏览器可以包含多种穿制服的模型矩阵,因此,你还可以将斜体编码为另一个垂直特性,让透镜选择根据这一特性将哪些矩阵用于改变垂直。 也可将这一想法扩大到使用每个单项中值的多个矩阵,每个矩阵的加权数。 这通常用于对诸如角色特性(ook“亲属”)等有机物进行估算。

作为统一的缓冲物体,唯一的好处是,你能够把许多数据包装到这些物体中,并且能够很容易地在弹).之间分享(使UBO与能够使用的任何弹).合)。 在为你使用这些物品方面没有任何实际好处,除非您有1OOO基斯的物体。

Also, i wrote the source codes above from memory. Let me know if there are some errors / problems ...

问题回答

@theswine

Not binding this during VAO initialization causes my program to crash, but binding it after binding the VAO causes it to run correctly. Are you sure this isn t saved in the VAO?

glBindBuffer(GL_ARRAY_BUFFER, vbo[0]); // not saved in VAO

(BTW: 抱歉提出老话题,我只是认为这对其他人有用,这肯定是!) (这提醒我,感谢你!)





相关问题
OpenGL 3D Selection

I am trying to create a 3D robot that should perform certain actions when certain body parts are clicked. I have successfully (sort of) implemented picking in that if you click on any x-plane part, it ...

CVDisplayLink instead of NSTimer

I have started to implement cvDisplayLink to drive the render loop instead of nstimer, as detailed in this technical note https://developer.apple.com/library/archive/qa/qa1385/_index.html Is it ...

Can the iPhone simulator handle PVR textures?

I have a really weird problem with PVR textures on the iPhone simulator- the framerate falls through the floor on the iPhone simulator, but on the iPhone itself it works just fine. Has anyone had any ...

Calculate fps (frames per second) for iphone app

I am using an opengl es iphone application. What is the most accurate way to calculate the frames per second of my application for performance tuning?

Java - Zoom / 3D Data Visualization Libraries

What are the best libraries/frameworks for doing 3D and/or Zoom interfaces in Java? I d like to be able to do some prototyping of creating new types of interfaces for navigating within data and ...

FLTK in Cygwin using Eclipse (Linking errors)

I have this assignment due that requires the usage of FLTK. The code is given to us and it should compile straight off of the bat, but I am having linking errors and do not know which other libraries ...

热门标签