As OGLers here know, one regularly needs to upload textures that have
an alpha channel (with non-multiplied RGB). Meanwhile,
CGBitmapContextCreate() doesn't support kCGImageAlphaFirst (see Apple
QA 1037), which makes CGBitmapContextCreate() utterly useless for
getting true image RGBA data from a CGImage (see QA1509). Am I going
nuts or is this kind of ridiculous for anyone loading images in to be
used as textures (with alpha) in OpenGL?
Given this, what's the best-performance way to upload images from
arbitrary image files? High performance and low overhead is critical
since we can't keep all the textures that we use memory resident.
I don't appear to be the only one running into this...
I got into this mess because I wanted to move away from all the
deprecated (GWorld) stuff. Now it looks GraphicsImportSetGWorld() is
the only way to get the non-premultiplied image data. So much for
leaving QuickDraw...
Any recommendations would be kindly appreciated.
You could simply upload the textures with pre-multiplied alpha then
blend them using glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );
Alternatively, if you're doing something that doesn't lend itself to
using the textures in their pre-multiplied form, you can upload the
texture to OpenGL as-is, lying about the true ordering of the components
(saying its ARGB when it's really RGBA), and unswizzle the components in
a fragment program.
real_texture.rgba = texture.argb;
At least, I think this should be the correct swizzling...
--
James Milne
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden