OpenGL VBO tips for using

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.