Problem with sprites and colors

Started by
3 comments, last by PnP Bios 19 years, 3 months ago
Like the title says i am having trouble using sprites and colors together. If i have all the sprites on the screen and than us something like glColor2f(1.0f, 0.0f, 0.0f); It makes all the sprites turn red. Can anyone tell me how to fix it? Many thnx, --mcgrane66
Advertisement
What were you expecting, if not that?

glColour sets the colour state for all vertices rendered from that point until the colour is changed. If you change vertex colours, then unless you change the texture function used in the texture pipeline, the textures on the polys you render will have their pixel colours modulated by the respective fragment colours.
Harry.
Yea i know thats whats happening, but what im asking is can i use colors and textures in anyway - I want to be able to make about 1/4 of the screen gray, without having to use new textures
Perhaps you could give a fuller explanation of precisely what you want. I'm still not sure what you mean.

When you say a quarter of the screen, do you mean you want to have the background colour gray and put sprites over three quarters of the screen? Or that you want to render sprites with the same texture over the whole screen, but have a quarter of them gray? I'm guessing it's the latter.

If you want to render sprites with the same texture but different vertex colours, just set the vertex colour (using glColour) to gray before you render the sprites that you want to be gray. If necessary, set the colour before you render each sprite.
Harry.
use glColor3f(1.0f, 1.0f, 1.0f) before rendering any textured objects.
when you are ready to render your normal objects w/out color, just use glDisable(GL_TEXTURE_2D), then you can color away.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One

This topic is closed to new replies.

Advertisement