Using OpenGL's Vertex Buffer Extension (ARB_vertex_buffer_object)
来源:互联网 发布:台海网络电视台tv透 编辑:程序博客网 时间:2024/05/03 13:27
Introduction
Note: This tutorial assumes basic OpenGL/extensions knowledge.
The ARB_vertex_buffer_object extension was approved by the Architecture Review Board (ARB) on February 12th, 2003. It works on most graphics cards (providing you have the right drivers). But what is it?
This extension moves vertex array data onto the graphics card's memory, which allows for extremely quick access.
Initialization
First of all, we need to be able to actually use the extension's functions. Since the OpenGL headers and library files haven't been updated since OpenGL 1.1 (on Windows), we need to use wglGetProcAddress() to get the functions.
PFNGLBINDBUFFERARBPROC glBindBufferARB = NULL;PFNGLGENBUFFERSARBPROC glGenBuffersARB = NULL;PFNGLBUFFERDATAARBPROC glBufferDataARB = NULL;[check whether extension is supported]glBindBufferARB = (PFNGLBINDBUFFERARBPROC) wglGetProcAddress("glBindBufferARB");glGenBuffersARB = (PFNGLGENBUFFERSARBPROC) wglGetProcAddress("glGenBuffersARB");glBufferDataARB = (PFNGLBUFFERDATAARBPROC) wglGetProcAddress("glBufferDataARB");
We also need a buffer and something to put in it.
GLfloat data[] = { -1.0f, 1.0f, 0.0f, -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f };GLuint buffer = 0;
Creating a buffer
The functions used for creating buffers are just like the standard OpenGL texture functions.
glGenBuffersARB(1, &buffer);glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(data), data, GL_STATIC_DRAW_ARB);
So what does this block of code do? glGenBuffersARB creates a buffer, glBindBufferARB binds it (duh) and glBufferDataARB uploads the vertex array to the graphics card.
Using the buffer
This is the easy part :)
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);glVertexPointer(3, GL_FLOAT, 0, 0);glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
- Using OpenGL's Vertex Buffer Extension (ARB_vertex_buffer_object)
- Using Vertex Buffer Objects
- OpenGL Vertex Buffer Objects(VBOs)
- OpenGL Vertex Buffer Object (VBO)
- OpenGL Vertex Buffer Object (VBO)
- OpenGL Vertex Buffer Objects(VBOs)
- OpenGL Vertex Buffer Object (VBO)【转】
- [转]OpenGL Vertex Buffer Object (VBO)
- OZone3D OpenGL Vertex Buffer Objects 1/3
- OZone3D OpenGL Vertex Buffer Objects 2/3
- OZone3D OpenGL Vertex Buffer Objects 3/3
- OpenGL ES3.0 《学习笔记 六》 Vertex Attributes, Vertex Arrays, and Buffer Objects
- OpenGL ES2.0 Programming Guide - chapter 6:Vertex attributes, vertex array and buffer objects
- OpenGL ES3.0 《学习笔记 六》 Vertex Attributes, Vertex Arrays, and Buffer Objects
- Apple's OpenGL——Vertex Shader基础
- Apple's OpenGL——Vertex Shader基础
- opengl extension
- Vertex Cache (OpenGL实现)
- 解决Weblogic 8.1和Hibernate 3的冲突
- 怎么避免ACTIVEX工程和DSHOW类库冲突
- 组件属性输入和显示演示代码
- 定义const 型指针
- 解析#pragma指令
- Using OpenGL's Vertex Buffer Extension (ARB_vertex_buffer_object)
- ASP 中数据库调用中常见错误的现象和解决
- C++类型转换操作符(cast operator)
- asp错误代码大全
- 关于类型转换
- #if 0 #endif的含义
- 关于far*指针
- 关于名字空间namespace
- MSDN处理异常的例子