PDA

View Full Version : Transparent, blend help



GL_ZERO
07-25-2003, 06:30 AM
I am able to do some blending and stuff but i want it to be more efficient cuz the current method i use costs me 2 mutch cpu power.

Here you see the scene im working on.
http://members.home.nl/skynet2097/Images/PlayStation%202.jpg

The logo in the left lower corner is made with this code :

================================================== ==========================================

void drawFrame(int x, int y, int width, int height, int textID, int blendID)
{
glBlendFunc(GL_DST_COLOR,GL_ZERO);
glEnable(GL_BLEND);

(*glActiveTextureARB)(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);

(*glActiveTextureARB)(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, texture[textID]);

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 1.0f); glVertex2f(0 + x, 0 + y);
glTexCoord2f(0.0f, 0.0f); glVertex2f(0 + x, height + y);
glTexCoord2f(1.0f, 0.0f); glVertex2f(width + x, height + y);
glTexCoord2f(1.0f, 1.0f); glVertex2f(width + x, 0 + y);
glEnd();

glBlendFunc(GL_ONE,GL_ONE);

(*glActiveTextureARB)(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, texture[blendID]);

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 1.0f); glVertex2f(0 + x, 0 + y);
glTexCoord2f(0.0f, 0.0f); glVertex2f(0 + x, height + y);
glTexCoord2f(1.0f, 0.0f); glVertex2f(width + x, height + y);
glTexCoord2f(1.0f, 1.0f); glVertex2f(width + x, 0 + y);
glEnd();

glDisable(GL_BLEND);

(*glActiveTextureARB)(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
}

================================================== ==========================================

Basicly im drawing the same quad object twice, and its a waste of cpu power. So i was thinking there has 2 be antoher way. How can i blend the tetxture and draw only the object once??

Edit

once more thing, i disable the GL_TEXTURE1_ARB because its for the multi texturing. But i wanna use it blend the textures.. but how and is it possible?

[This message has been edited by GL_ZERO (edited 07-25-2003).]

GL_ZERO
07-25-2003, 06:38 AM
lol i fixed it http://www.opengl.org/discussion_boards/ubb/tongue.gif

================================================== ==========================================
void drawFrame(int x, int y, int width, int height, int textID, int blendID)
{
glBlendFunc(GL_DST_COLOR,GL_ZERO);
glEnable(GL_BLEND);

(*glActiveTextureARB)(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, texture[textID]);

glBlendFunc(GL_ONE,GL_ONE);

(*glActiveTextureARB)(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, texture[blendID]);

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 1.0f); glVertex2f(0 + x, 0 + y);
glTexCoord2f(0.0f, 0.0f); glVertex2f(0 + x, height + y);
glTexCoord2f(1.0f, 0.0f); glVertex2f(width + x, height + y);
glTexCoord2f(1.0f, 1.0f); glVertex2f(width + x, 0 + y);
glEnd();
glDisable(GL_BLEND);
}
==============================================

[This message has been edited by GL_ZERO (edited 07-25-2003).]

[This message has been edited by GL_ZERO (edited 07-25-2003).]