FourTexturesModern is sample C++ code illustrating the use of Modern OpenGL. It is part of a set of programs introducing the use of Modern OpenGL, which are intended to accompany a possible second edition of the book 3D Computer Graphics: A mathematical approach with OpenGL, Cambridge University Press, 2003.

FourTexturesModern shows how to load multiple texture maps from a bitmap files, BMP files, and apply them to a rectangles. Its primary source file is FourTexturesModern.cpp. In addition, it uses RgbImage to load a texture map from a file and GlShaderMgr to read a shader program from a file. Follow these links to download the source files and executable:

Things to try out:

  1. Extract, compile and run the program. You should see four rectangles, with a different texture mapped image applied to each one. Be sure that the GLSL file and the four texture map bitmap files are in the same directory that the program is running in.
  2. Examine the source to see how it:
    • Reads the texture maps from the files, and uses glTexParameteri to set the parameters for each one.
    • Specifies texture coordinates in the array of vertex data loaded into the VBO.
    • Binds the texture map to shader program, and accesses the texture in the fragment shader.
    • Uses glDrawElementsBaseVertex.
  3. See the more detailed description of the software and its functionality.

Version 1.0 of FourTexturesModern, February 24, 2018. Revised September 14, 2020. All rights reserved.