Jump to content
  • Advertisement
Sign in to follow this  
Grain

Making a sprite flash white.

This topic is 5040 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

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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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),

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
And couldn't you draw a second white transparent sprite above the first ? that would work, even if far from optimized.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!