Graphics Reference
In-Depth Information
Compatibility Mode
OpenGL 4.1 has replaced a number of features of the 2.x and 3.x standards with
much more general functionality. This has increased the power, efficiency, and
generality of the standard, but requires much more planning and setup than
the earlier standard. If you are maintaining OpenGL code that was based on
the 2.x and 3.x standards, or if you simply want to write quick shaders to test
out some ideas, you may want to work in what is called compatibility mode : a
mode in which you can use the earlier OpenGL functionality.
Defining Compatibility Mode
It is quite straightforward to specify that a shader is to be run in compatibility
mode. If you are working in OpenGL 4.x, you can simply put the line
#version 400 compatibility
at the top of any shader source. If you are working in OpenGL 3.3, a similar
command can be used:
#version 330 compatibility
Then you can use any functionality you like from the OpenGL 2.1 standard.
Among the things you might find most useful from the earlier standard
is the set of built-in data. These let you pick up atribute and uniform variables
that are defined by OpenGL 2.1 functions so you can use them easily in your
shaders.
OpenGL 2.1 Built-in Data Types
GLSL originally included some completely new data types that correspond to
functions needed to manage data flow across the spectrum of an application,
the OpenGL API, the onboard data on a graphics card, and the needs of vertex
and fragment shaders. These types are available in OpenGL 2.1 or in compat-
ibility mode for later versions, and are named atribute , uniform , and varying .
Their function is described in this section.
In general, you can differentiate these data types by how often the data
they represent change. Uniform data changes infrequently and never within
a graphics primitive; atribute data changes frequently, often as frequently as
each vertex; and varying data changes most frequently, with each fragment as
it's interpolated by the rasterizer.
Search WWH ::




Custom Search