Graphics Reference
In-Depth Information
GLIB File
##OpenGL GLIB
Perspective 70
Texture 5 apples.bmp
Vertex brightness.vert
Fragment brightness.frag
Program Brightness uImageUnit 5
Teapot
Vertex Shader
out vec2 vST;
void main( )
{
vST = aTexCoord0.st;
gl_Position = uModelViewProjectionMatrix * aVertex;
}
Fragment Shader
uniform sampler2D uImageUnit;
in vec2 vST;
out vec4 fFragColor;
void main( )
{
vec3 color = texture( uImageUnit, vST ).rgb;
fFragColor = vec4( color, 1.);
}
The Texture Context
In Figure 9.1, we saw an area identified as “Context” without much explana-
tion. In fact, this is an important idea, and when working with textures, it can
be very helpful to look at the idea of the OpenGL rendering context in more
detail.
When you set up a texture in fixed-function OpenGL, you first get the
identifier for the texture, representing the location where the texture informa-
tion will be. This is done by the two statements
GLuint texA;
glGenTextures( 1, &texA );
Search WWH ::




Custom Search