iDevGames Forums
Confusion about native pixel format - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Confusion about native pixel format (/thread-7762.html)

Confusion about native pixel format - tigakub - May 14, 2002 12:14 PM

There's a demo at

that shows how to optimize for Mac's ARBG pixel format. However, in that demo, it makes the following call:


which is supposed to make OpenGL use the application copy of the texture. The documentation that came with the demo claims that this results in a 70% speed improvement.

How can this be? How can pulling data through the AGP be faster than using resident textures? (Or can I assume that the demo was written with the software renderer in mind?)

Also, does anyone know where I can get my hands on some CGL documentation/reference material? All I can seem to find is AGL stuff.


Confusion about native pixel format - OneSadCookie - May 14, 2002 01:51 PM

* the CGL header (<OpenGL/OpenGL.h>) is pretty good documentation. It all works the same way as AGL, anyway, so the documentation for either is pretty much good for both Smile

* When you create a texture in OpenGL, the specification mandates that OpenGL remember the texture image, regardless of how many other textures you might be using. This means that it can't assume they all fit in VRAM, so it must keep a copy of the image in main memory.

OpenGL also can't assume that the pixel buffer you pass to glTexImage2D will last beyond that point. It's fairly common, after all, to do glTexImage2D(..., buffer); free(buffer);. That means that it has to make its copy of the data when you call glTexImage2D.

GL_APPLE_client_storage gets around the necessity of making this extra copy. You guarantee that you will keep your copy of the texture image around for OpenGL to use when it needs. The extension doesn't change any other behavior -- the texture will still be copied to VRAM, for example.

There is a second Apple extension which helps out with texture uploads, and that is the glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 0);. This is a hint to the card that the texture image should be stored in AGP memory (not quite sure how this works). This makes for very fast uploads to the card, and so is very useful if you are using animated textures (a movie, for example Wink

The 70% performance improvement refers to texture upload times only, but in my experience that's a reasonable figure.

Confusion about native pixel format - tigakub - May 14, 2002 02:05 PM

Thanks OneSadCookie. That clarified it quite nicely. I'm so glad I stumbled on this site. For the longest time I've been frustrated with the level of support out there for aspiring Mac developers.

- tigakub

Confusion about native pixel format - OneSadCookie - May 14, 2002 02:45 PM

You might also be interested in the MacGameWiki, or in the Apple-run Mac-Games-Dev and Mac-OpenGL mailing lists. They have very manageable volumes, and often contain useful information. You can subscribe at