Advertisement

Blending question

Started by February 25, 2003 04:22 AM
14 comments, last by BigBoy 22 years ago
The first bit of code is part of the initialisation routine :


    glAlphaFunc(GL_GREATER, 128);glDisable( GL_ALPHA_TEST );glEnable(GL_TEXTURE_2D);glClearColor(0.0f, 0.0f, 0.0f, 0.0f);glClearDepth(1.0f);	glDepthFunc(GL_LEQUAL);glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);glEnable(GL_DEPTH_TEST);    


The next bit of code is part of an adaption of Nehe's tutorial 32 glPrint routine. colourVector[] holds the RGB values for an enumerated colour code. All works fine bar the alpha testing:


        glEnable(GL_ALPHA_TEST);glBindTexture(GL_TEXTURE_2D, letters.texID);glColor3fv( colourVector[ GREY ] );glPushMatrix();												glLoadIdentity();glTranslatef(x,y,z);										glListBase(lettersBase-32);										glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);glPopMatrix();												glDisable(ALPHA_TEST);  


I've commented out all other references to blending and alpha testing, but still no joy. The graphics loader is taken from Nehe's tutorial #34.

The game is almost done, and hopefully I will be putting it somewhere come Monday. It's spaghetti code to the max, with coded slapped on and altered everytime I came to the point of adding a new feature to it. Nearly all of it has been coded without any foreward planning, so there's not much in the way of code structure.

My next project will be oh so different. Detailed game analysis & specs, structured code, OO used to the max and swarms of flying pigs. Well, I'll try to have a bit more on paper of how I plan to achieve certain aspects of it.

Please don't sweat about the code - I've managed to get by without the background image. But if there is an obvious mistake, point it out.

Jeroen

edit: changed the typo to [/source]

[edited by - Bigboy on February 28, 2003 9:08:34 AM]
Cheers,Jeroen
Hmm - to be honest, I've never used display lists apart from some very trivial stuff a long long time ago, so I can't really tell you if alpha testing affects them. A couple of things to take notice of, though:

1) You could move your glAlphaFunc() call to the rendering code after enabling alphatesting.
2) Enable alpha testing when building the display list.

Then again, this is pure speculation and most likely isn't the solution.

However - I solved the text problem with blending rather than alpha testing:


    Bind(font_texture);Enable(blending);Disable(depth_testing);SetBlendFunc(src_color, one);SetListBase(mask);CallList();SetBlendFunc(dst_color, one);SetListBase(font);CallList();Enable(depth_testing);Disable(blending);    


Hope this helps,
Crispy

edit - minor typo

[edited by - crispy on February 28, 2003 10:06:21 AM]
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Advertisement
just make sure you are actually loading the textures in the RGBA format and the alpha portion of the texture is being correctly loaded. otherwise the alpha values will all effectivly be 255.

| - Project-X - my mega project.. yup, still cracking along - | - adDeath - an ad blocker I made - | - email me - |
ohh, and if you are using lighting make sure that the ambient and emmision alpha levels are 0.

| - Project-X - my mega project.. yup, still cracking along - | - adDeath - an ad blocker I made - | - email me - |
Admittedly, there''s a mixture of RGB and RGBA. However, the two images that I''m blending & alpha testing are both RGBA. I think they''re set up incorrectly, but don''t know how.

Out of interest, what sort of graphics packages do you giys use? Is there any freeware apps out there that can manipulate alpha channels on images?

Jeroen
Cheers,Jeroen
I build by alpha channels myself (during texture loading) - just check where the color is not black, set the alpha value to some nonezero value.

Crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared

This topic is closed to new replies.

Advertisement