What Is an OpenGL® Function?

Article Details
  • Written By: Eugene P.
  • Edited By: Angela B.
  • Last Modified Date: 02 February 2017
  • Copyright Protected:
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog


An OpenGL® function is a block of executable code that is called from within a computer program by using the name of the function and any associated parameters. A function parameter is some variable or information that needs to be added after the name of the OpenGL® function to direct the action that will be taken. OpenGL® has a large array of functions that are used to draw, manipulate and render a three-dimensional (3D) scene and to change the values of different variables that can affect the appearance or speed of the rendering. All of the functions in the OpenGL® function library use a strict naming convention that described what parameters are expected and in what library the function is contained.

The naming convention for an OpenGL® function consists of four parts that form the actual name of a function. The first part is called the prefix and indicates the library to which the function belongs. For core functions, this prefix is "gl", standing for "graphics library". Other prefixes include "glut" for "graphics library utility tools", and two-letter codes that represent the manufacturers of graphics hardware that require special functions for their specific cards to access features unavailable to other devices.

The second part of an OpenGL® function name is the name itself. This can refer directly to a value to be changed or an action to be taken. Examples of the name portion of a function include "color", "vertex", "clear" and "deleteTextures". The name immediately follows the prefix and is usually capitalized to distinguish it from the prefix and make the code more readable.

The third element of an OpenGL® function name is the number of parameters the function accepts. These also can be called arguments. This is simply a number. So a function that requires three arguments will have the numeral 3 in this position, directly after the function name.

The final element of an OpenGL® function name is the data type of the variable expected as a parameter. This is an abbreviation that helps to remind the programmer what data are expected and also allows a single function to have multiple predictable variations that accept arguments of a different data type. Examples of this are "f" for a floating point number, "i" for an integer or "b" for a byte.

By these rules, a full OpenGL® function name for creating a vertex point at a 3D location defined in floating point numbers would be "glVertex3f". The function can be logically changed to accept integers by simply modifying the last part so it reads glVertex3i. One part of the success of OpenGL® is the strict adherence to standards such as the function-naming conventions.


You might also Like


Discuss this Article

Post your comments

Post Anonymously


forgot password?