O'Reilly logo

OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition by Bill M. Licea-Kane, John M. Kessenich, Graham Sellers, Dave Shreiner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

Example 6.1. Direct Specification of Image Data in C

// The following is an 8x8 checkerboard pattern using// GL_RED, GL_UNSIGNED_BYTE data.static const GLubyte tex_checkerboard_data[] ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required