OpenGL VBO (vertex buffer objecte)
OpenGL Vbo is not difficult, but more cumbersome, in fact, the concept is the same as loading texture:
Initialization phase:
1.Glgenbuffersarb(1, &nvbovertices); Generate a handle
2.Glbindbufferarb(Gl_array_buffer_arb, nvbovertices); Declare the handle as a VBO handle and select the
3.Glbufferdataarb(Gl_array_buffer_arb, sizeof (vertices), vertices,gl_static_draw); Uploading a vertex set to the server side
Use stage:
1.glenableclientstate(Gl_vertex_array); Getting Started with Vbo
2.Glbindbufferarb(Gl_array_buffer_arb, nvbovertices); Select the currently used VBO
3.Glvertexpointer(3, Gl_float, 0, Buffer_offset (0)); Specify VBO vertex format
4.gldrawarrays(gl_triangles, 0, G_pmesh->m_nvertexcount); Draw it.
5.gldisableclientstate(Gl_vertex_array); Stop using VBO
Finishing phase:
1.Gldeletebuffersarb(1,&nvbovertices); Delete the handle while removing the server-side vertex buffer
Let's look at how texture buffering is used, in fact, almost:
Initialization phase:
1.Glgentextures(1, &TEXID);//Create Handle
2.glbindtexture(gl_texture_2d, TEXID); Set Handle type
3.glteximage2d(gl_texture_2d, 0, Gl_rgba, Img->getwidth (), Img->getheight (), 0, Gl_rgba, Gl_unsigned_byte, Raw_rgba); Upload Texture Buffer
Use stage:
1.glenable(gl_texture_2d); Start using texture buffering
2.glbindtexture(gl_texture_2d, TEXID); Select the currently used texture buffer
3. Send vertex and texture coordinates, draw bar ... Omitted
4.gldisable(gl_texture_2d); Stop using textures
Finishing phase:
1.Gldeletetextures(1,&TEXID);//delete handle, while removing server-side buffering
See, is this concept very similar? are:
1. Create a handle
2. Set the handle type
3. Uploading data
4. Start using buffering
5. Select a handle
6. Using buffering
7. Stop using buffering
8. Delete Handles and buffers
This article is from the "11486263" blog, please be sure to keep this source http://11496263.blog.51cto.com/11486263/1826955
OpenGL VBO tips for using