Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the GL_ARRAY_BUFFER target mean in glBindBuffer?

I was confused about the VBO,

glGenBuffers(1, &positionBufferObject);
glBindBuffer(GL_ARRAY_BUFFER, positionBufferObject);

Besides GL_ARRAY_BUFFER, there are other target types: GL_ATOMIC_COUNTER_BUFFER, GL_COPY_READ_BUFFER...

However, the Opengl manual doesn't mention what these targets mean. I checked the glew.h:

#define GL_ARRAY_BUFFER 0x8892

Does this mean the targets (like GL_ARRAY_BUFFER) are addresses?

What does the target--GL_ARRAY_BUFFER mean in glBindBuffer?

like image 730
lightrek Avatar asked Feb 10 '13 21:02

lightrek


People also ask

What are the two constant values used for target parameter in Glbindbuffer ()?

The symbolic constant must be GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER .

What is a target in OpenGL?

What is a Target in OpenGL? Targets, also known as Binding Points, allows objects to be used for different purposes. A target specifies the behavior of the object. The most common binding points are: GL_ARRAY_BUFFER.

What does it mean to bind a buffer?

Binding a buffer to a target is something like setting a global variable. Subsequent function calls then operate on that global data. In the case of OpenGL all the "global variables" together form a GL context. Virtually all GL functions read from that context or modify it in some way.

What does bind mean in OpenGL?

A Binding Point specifies the behavior of the OpenGL object. Binding Points, also known as Targets, allows OpenGL objects to be used for different purposes. The most common binding points are: GL_ARRAy_BUFFER.


2 Answers

In General

Most OpenGL objects must be bound to locations in the OpenGL context called "targets" for them to be used. A target is nothing more than a place in the context where objects are bound.

Different object types (buffers, textures, etc) have different sets of targets. Generally speaking, each target has a specific meaning: to bind one object to one target means that you want to use that object in whatever manner that target uses objects bound to it.

Binding an object to one target does not affect whether the object is bound to another target (unless it's a texture object; they treat targets differently).

There are functions that modify objects or query data from bound objects. They take a target to which the object they are modifying/querying has been bound.

GL_ARRAY_BUFFER

The GL_ARRAY_BUFFER target for buffer objects represents the intent to use that buffer object for vertex attribute data. However, binding to this target alone doesn't do anything; it's only the call to glVertexAttribPointer (or equivalent functions) that uses whatever buffer was bound to that target for the attribute data for that attribute.

like image 124
Nicol Bolas Avatar answered Nov 16 '22 06:11

Nicol Bolas


However, the Opengl manual doesn't mention what these targets mean.

OpenGL 2.1 spec, page 38, section 2.9.1: "Vertex Arrays In Buffer Objects"

Does this mean the targets (like GL_ARRAY_BUFFER) are addresses?

Nope, they're just unsigned ints used like enums.

like image 43
genpfault Avatar answered Nov 16 '22 05:11

genpfault