Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Colorkey problems (using glAplhaFunc())

This topic is 5812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I''m trying to make a color key using:
glAlphaFunc(GL_GREATER, GL_ZERO); 
But all I get is a black screen (e.g nothing is drawn). I''m extracting a frame from a bmp then adding a aplpha chanel like this:
// Extract the frame

for(y = 0; y < texHeight; y++)
	for(x = 0; x < texWidth * 3; x += 3)
		frame[j] = bitmap->Image((bitmap->Width()*3*(yPos+y))+((xPos*3)+x));
		frame[j+1] = bitmap->Image((bitmap->Width()*3*(yPos+y))+((xPos*3)+x)+1);
		frame[j+2] = bitmap->Image((bitmap->Width()*3*(yPos+y))+((xPos*3)+x)+2);
		// Check if it''s the color key (if so sett to completely transparent)

		if((frame[j] == COLORKEY_RED) && (frame[j+1] == COLORKEY_GREEN) 
			&& (frame[j+2] == COLORKEY_BLUE)) {
			frame[j+3] = 0;
		else {
			frame[j+3] = 255;

		j += 4;

glGenTextures(1, &texID[frameNr]);
glBindTexture(GL_TEXTURE_2D, texID[frameNr]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 
			 0, GL_RGBA, GL_UNSIGNED_BYTE, frame);
The whole frame is drawn correctly (with the color I don''t want) if I don''t enable GL_ALPHA_TEST but when I do nothing at all is drawn. I have also tried with comenting out the if case and just setting frame[j+3] = 255; but that doesn''t help either. What am I doing wrong? Thanks in advance Spearhawk

Share this post

Link to post
Share on other sites
Hehe, never mind that. The code works.
I must have been more tired than I thought, I was working with a overloaded fuction, and of course it was the other "copy" of the fuction than the one that I worked on that was called

Share this post

Link to post
Share on other sites
0 perhaps! which can be representated differently in the machine than 0.0f


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!