Making a sprite flash white.
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.
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...
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.
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).
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),
Quote:Original post by ntsGave me transparent Sprites.
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.
Quote:Original post by iliakThis gives me a white square.
Why not disabling texture and drawing all in white ?
Quote:Original post by greksterI 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.
Swap the sprite your drawing with just a plain white sprite?
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.
And couldn't you draw a second white transparent sprite above the first ? that would work, even if far from optimized.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement