Cocoa Design Patterns
Learning OpenGL ES for iOS
Presentations
Buy at Amazon Now
  • Cocoa Design Patterns
    Cocoa Design Patterns
    by Erik M. Buck, Donald A. Yacktman
  • Learning OpenGL ES for iOS: A Hands-on Guide to Modern 3D Graphics Programming
    Learning OpenGL ES for iOS: A Hands-on Guide to Modern 3D Graphics Programming
    by Erik M. Buck

Errata > Determine number of texture units (chapter 3)

In chapter 3, when explaining Multi-Texturing, the text recommends determining the maximum number of texture units by using the code glGetIntegerv(GL_MAX_TEXTURE_UNITS, &iUnits); However, this parameter is not valid in open gl ES 2.0. I believe the correct parameter would be one of either: GL_MAX_TEXTURE_IMAGE_UNITS
, GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS or perhaps GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, which gives the combined MAX for both VERTEX AND FRAGMENT shaders.
November 19, 2012 | Unregistered CommenterRaul Teixeira
You are exactly correct. Thank you for the good catch.


http://www.opengl.org/wiki/Textures_-_more provides a brief explanation including the following:
"Never call glGetIntegerv(GL_MAX_TEXTURE_UNITS, &MaxTextureUnits);"


It is unclear to me why OpenGL ES particularly needed a new constant, GL_MAX_TEXTURE_IMAGE_UNITS, instead of GL_MAX_TEXTURE_UNITS, but they surely had a good reason.

I did not catch this change when transitioning my own code to OpenGL ES 2.0. There is no warning or indication of problem using GL_MAX_TEXTURE_UNITS. OpenGL ES 2.0 just returns the "wrong" answer. There is no indication the constant is deprecated other than the brief mention cited above. The man page is currently broken but correctly does not mention GL_MAX_TEXTURE_UNITS as an option at http://www.khronos.org/opengles/sdk/docs/man/glGet.xml.

I'm worried that there may be other similar issues lurking in my own projects. I encourage everyone to post errata just like this (for my own benefit).

Also, Apple now/currently provides pertinent information at http://developer.apple.com/library/ios/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/DeterminingOpenGLESCapabilities/DeterminingOpenGLESCapabilities.html
November 20, 2012 | Registered CommenterErik Buck