Making a sprite flash white.

Started by
18 comments, last by GameDev.net 19 years, 6 months ago
What would be the best way to get a textured quad to briefly flash white. I am using the GL_RGBA pixel format and basically what I want is to momentarily change the R G and B values to 1.0. The obvious and brute force way is to manually step through the pixel array and set each individual byte, render and then restore them to their original values. But that would probably be extremely slow and since I am using texture objects I don’t actually have the image saved in memory anywhere. SO, I was thinking there could be some way of doing it by playing with the blending function or lighting and materials.
Advertisement
not sure what you are asking, info you are giving but

glColor3f(r, g, b);
glColor4f(r, g, b, a);

disable your color arrays, if u were using them...
Ok here is my function to render a sprite.


void Sprite::Render(GLuint TexHndl){		glBindTexture(GL_TEXTURE_2D, TexHndl);	glPushMatrix();		glTranslatef((int)Pos.x,(int)Pos.y,0.0f);	glRotatef(angel,0,0,1);	glScalef(size,size,1.0f);	glBegin(GL_QUADS);		glTexCoord2f(0.0f,0.0f); glVertex2f(-w/2.0f,- h/2.0f);		glTexCoord2f(1.0f,0.0f); glVertex2f(w/2.0f,-h/2.0f);		glTexCoord2f(1.0f,1.0f); glVertex2f(w/2.0f,h/2.0f);		glTexCoord2f(0.0f,1.0f); glVertex2f(-w/2.0f,h/2.0f);	glEnd();	glPopMatrix();}

What I want is to instead of using the RGB values I get from glBindTexture(GL_TEXTURE_2D, TexHndl), to use pure white to draw the sprite, but I want to still use the Alpha values from glBindTexture(GL_TEXTURE_2D, TexHndl).
you can try using blending with something like GL_SRC_ALPHA and GL_ONE as the blending function (glBlendFunc(src, dst), glEnable(GL_BLEND), etc) not sure if that does the trick though.
Why not disabling texture and drawing all in white ?
glDisable(GL_TEXTURE_2D);glColor3f(1.0, 1.0, 1.0);// Dont forget to disable lighting too..... draw your mesh here....glEnable(GL_TEXTURE_2D),
- Iliak -
[ ArcEngine: An open source .Net gaming framework ]
[ Dungeon Eye: An open source remake of Eye of the Beholder II ]
Swap the sprite your drawing with just a plain white sprite?
Quote:Original post by BosskIn Soviet Russia, you STFU WITH THOSE LAME JOKES!
Quote:Original post by nts
you can try using blending with something like GL_SRC_ALPHA and GL_ONE as the blending function (glBlendFunc(src, dst), glEnable(GL_BLEND), etc) not sure if that does the trick though.
Gave me transparent Sprites.

Quote:Original post by iliak
Why not disabling texture and drawing all in white ?
This gives me a white square.

Quote:Original post by grekster
Swap the sprite your drawing with just a plain white sprite?
I have over a hundred Sprites It’s just not feasible to make white versions of each one. Plus I would like to extent the ability to use other colors as well.
Quote:Original post by Grain

I have over a hundred Sprites It’s just not feasible to make white versions of each one. Plus I would like to extent the ability to use other colors as well.


Actually you have to make only one and you can use GL_REPEAT and it will be seamless.
The more applications I write, more I find out how less I know
And couldn't you draw a second white transparent sprite above the first ? that would work, even if far from optimized.
Why not use the stencilbuffer?
Or use mascing. See nehe for more infos
“Always programm as if the person who will be maintaining your program is a violent psychopath that knows where you live”

This topic is closed to new replies.

Advertisement