Graphics Reference
In-Depth Information
floating-point value. This would be similar to casting the variable that is
not a float type to float. The following code gives an example:
GLfloat f;
GLbyte b;
f = (GLfloat)b; // f represents values in the range [-128.0,
// 127.0]
If the normalized flag is true, the vertex data is mapped to the [-1.0, 1.0]
range if the data type is GL_BYTE , GL_SHORT , or GL_FIXED , or to the [0.0,
1.0] range if the data type is GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT .
Table 6-1 describes conversion of non-floating-point data types with the
normalized flag set. The value c in the second column of Table 6-1 refers
to a value of the format specified in the first column.
Table 6-1 Data Conversions
Vertex Data Format
Conversion to Floating Point
GL_BYTE
max( c / (2 7 - 1), -1.0)
GL_UNSIGNED_BYTE
c / (2 8 - 1)
GL_SHORT
max( c / (2 16 - 1), -1.0)
GL_UNSIGNED_SHORT
c / (2 16 - l)
GL_FIXED
c /2 16
GL_FLOAT
c
GL_HALF_FLOAT_OES
c
It is also possible to access integer vertex attribute data as integers in the
vertex shader rather than having them be converted to floats. In this case,
the glVertexAttribIPointer function should be used and the vertex
attribute should be declared to be of an integer type in the vertex shader.
Selecting Between a Constant Vertex Attribute or a Vertex Array
The application can enable OpenGL ES to use either the constant data or
data from vertex array. Figure 6-3 describes how this works in OpenGL ES 3.0.
The commands glEnableVertexAttribArray and glDisableVertex-
AttribArray are used to enable and disable a generic vertex attribute
array, respectively. If the vertex attribute array is disabled for a generic
attribute index, the constant vertex attribute data specified for that index
will be used.
 
 
Search WWH ::




Custom Search