Portal:OpenGL Objects/Object Model

From OpenGL.org
Jump to: navigation, search

OpenGL defines the concept of an object as being an OpenGL construct that contains some amount of state (ie: values). OpenGL defines a fair number of object types, with many uses throughout the OpenGL API. Some object types are container objects; these objects primarily store references to other objects. Container objects cannot be shared across OpenGL Contexts.

Most OpenGL objects follow a certain set of conventions as to their APIs and use. Objects are not implemented in a C or C++ style, as pointers to some data. They are GLuint​ integer handles, called "names", that reference the actual data stored in the object. Functions that generate objects will be named glGen*​, where * is the object name. Names can be deleted, using a function of the form glDelete*​.

Generating a name does not (usually) create the object itself. To do that, it must first be bound to the context. Binding an object to the context means that the object's contained state now becomes part of the context's state. Functions that modify or query those pieces of state will set or retrieve values stored in the object. And rendering functions that rely on these pieces of state will get their data from the object.

Objects are bound with functions of the form glBind*​, where * is the object type. Most OpenGL objects can be bound to multiple locations in the context. These locations, or targets, represent different places where the object's state can be used in different ways. So how rendering works can change based on which target an object is bound to.