View Full Version : Alpha component in the PNG files
01-05-2008, 09:17 AM
how can i use alpha channel in the PNG files with glDrawPixels function ( i use DevIL)?
01-06-2008, 10:28 AM
How do you want to use it? If you want to draw transparent images, you need to set up correct blending modes before drawing anything. Check out, glBlend functions. You must also load the image as RGBA image, so it contains the alpha channel.
01-06-2008, 01:24 PM
have a png file with alpha chanel but i cant use the alpha chanel in opengl in other word all of the transparent pixels shown dark
this is my code, where is my problem?
ilGenImages (1, &ImgId);
Width = ilGetInteger(IL_IMAGE_WIDTH);
Height = ilGetInteger(IL_IMAGE_HEIGHT);
sourcedata = ilGetData();
glDrawPixels(Width ,Height,GL_RGBA,GL_UNSIGNED_INT, sourcedata);
and,when i enable bleding any thing dont be shown,
01-06-2008, 01:33 PM
Did you check if the alpha values in sourcedata are non-zero?
01-06-2008, 09:34 PM
Your code doesn't call glEnable(GL_BLEND) to turn on blending.
Also, it is a LOT faster to draw a quad with a texture on it, than it is to draw pixels using glDrawPixels(). I suggest letting IL keep the image around, with a texture ID, and using that.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.