Explicitly Setting Texture Data
In order to describe the process in which texture data is specified to OpenGL, it’s possibly easiest to be able to see the image data directly in your program. Texture data is laid out6 as you might expect it to be—left to right, top to bottom. In Example 6.1, texture data is stored in a constant array declared in C.
6. There are several parameters supported by OpenGL that allow you to change the layout of image data in memory. These are discussed later in this chapter, but the defaults are sufficient for this example.
// The following is an 8x8 checkerboard pattern using// GL_RED, GL_UNSIGNED_BYTE data.static const GLubyte tex_checkerboard_data ...