Portal:OpenGL Objects/Object Model: Difference between revisions

From OpenGL Wiki
Jump to navigation Jump to search
Good start on Objects portal page.
 
Container objects
Line 1: Line 1:
[[Portal:OpenGL Concepts|OpenGL]] defines the concept of an '''objects''' as being a construct that contains state (ie: values). OpenGL defines a fair number of object types, with many uses throughout the OpenGL API.
[[Portal:OpenGL Concepts|OpenGL]] defines the concept of an '''objects''' as being a construct that contains 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 Context]]s.


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 {{code|GLuint}} integer handles, called "names", that reference the actual data stored in the object. Functions that generate objects will be named {{code|glGen*}}, where * is the object name. Names can be deleted, using a function of the form {{code|glDelete*}}.
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 {{code|GLuint}} integer handles, called "names", that reference the actual data stored in the object. Functions that generate objects will be named {{code|glGen*}}, where * is the object name. Names can be deleted, using a function of the form {{code|glDelete*}}.

Revision as of 13:45, 26 February 2013

OpenGL defines the concept of an objects as being a construct that contains 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.