Graphics Reference
In-Depth Information
Chapter 4
Shaders and Programs
Chapter 2, “Hello, Triangle: An OpenGL ES 3.0 Example,” introduced
you to a simple program that draws a single triangle. In that example,
we created two shader objects (one for the vertex shader and one for
the fragment shader) and a single program object to render the triangle.
Shader objects and program objects are fundamental concepts when
working with shaders in OpenGL ES 3.0. In this chapter, we provide
the full details on how to create shaders, compile them, and link them
together into a program object. The details of writing vertex and fragment
shaders come later in this topic. For now, we focus on the following topics:
• Shader and program object overview
• Creating and compiling a shader
• Creating and linking a program
• Getting and setting uniforms
• Getting and setting attributes
• Shader compiler and program binaries
Shaders and Programs
There are two fundamental object types you need to create to render
with shaders: shader objects and program objects . The best way to think of
a shader object and a program object is by comparison to a C compiler
and linker. A C compiler generates object code (e.g., .obj or .o files) for a
piece of source code. After the object files have been created, the C linker
then links the object files into a final program.
 
 
 
Search WWH ::




Custom Search