Portal:OpenGL Concepts/Object Model

From OpenGL Wiki
Jump to navigation Jump to search

Certain OpenGL state values are aggregated into objects. This allows groups of state to be stored and reset with a single command. Most objects in OpenGL are defined as groups of context state, even if that context state is not available if no object is currently in use.

Most objects in OpenGL follow the same general paradigm and naming convention. Object names are GLuints; these are handles used to identify an object. Live objects are created with a function of the form glGen*; those objects are deleted with a call to the equivalent glDelete*. Objects are aggregates of state, and state exists within the OpenGL context. Therefore, to modify an object or to use it to render something, the object must first be bound to the context. The function to do this is of the form glBind*. Any functions that modify or query the state that this object contains will modify/query the object's internal state.

The object 0 is special, and it has different behaviors for different object types. For many objects, 0 represents "not an object", much like a NULL pointer. For a few object types, it is a default object, which can not be destroyed. In general, with the exception of Framebuffers, you should treat 0 like NULL: an invalid object.