Creating an OpenGL texture with alpha using NSBitmapImageRep
Posted
by
BROK3N S0UL
on Stack Overflow
See other posts from Stack Overflow
or by BROK3N S0UL
Published on 2011-08-03T09:31:12Z
Indexed on
2012/06/12
4:40 UTC
Read the original article
Hit count: 157
I am loading a PNG using:
theImage = [NSBitmapImageRep imageRepWithContentsOfFile:imagePath];
from which I can successfully create a gl texture and render correctly without any transparency. However, when I switch blending on using:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
The texture renders with the correct transparent background, but the image colours are incorrect.
I have tried several options in the blend function, GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
, GL_ONE
, GL_DST_ALPHA
, etc.
I was taught maybe I need to reorder the bits in the image data, maybe the channels have been mixed up, but I would not expect it to render correctly when blending is off in that case.
Alternatively, I could use libPNG I guess, but I would like to try using a NSBitmapImageRep
if it is possible.
© Stack Overflow or respective owner