How can I add color on texture?

Hello.

I’m developing a 2d game, that use glOrtho and some texture, source is png file(includes alpha value).

I have a problem. I don’t know how can I add colors in texture. Example of image file is this…


(It’s existing online game’s sprite)

Now I want to add color in this pixels(consider alpha value).

If that color is white, I set color’s alpha value each frame, and that image effects such as shining, I expect.

I’ve tried a method that ‘make other file with Photoshop and put on original image’, but it’s looks like too stupid, and too static.

If I use this method, whenever add another image files I must make another ‘color’ image files too!

And… I’ve used glColor4f(3,3,3,1) or glColor4f(100,100,100,1), glC… whatever, the value of glColor4f did not exceed ‘1’.(edit : ‘1’ -> ‘original’)
it was useless in this case.

So I ask for help to this site.

How can I add color on texture? and what is the best method?


Now I find a way to upload image on this site, image has uploaded successfully. But problem of openGL is still exist.

Srsly?

the value of glColor4f did not exceed ‘1’

That’s because values are clamped to 1.f …

You need to provide arguments in [0,1]. You simply divide your integer color values by 255 and pass the result to glColor4f.

Sorry, I can’t find a way to upload image files.
I input address in text, it send me an error message.
“Post denied”, I saw this message over than 10 times…
And… I means original -> image’s all pixel turns to wanted rgb value or add rgb value like blend color on original image, consider alpha value.
when I use glColor4f(?.0f,?.0f,?.0f,1.0f), it display only less rgb value… How can I use glColor4f in correct way?

To make anything have half transparency, set it’s RGB values to 1 so the color is unchanged, then modify the 4’th parameter which is for alpha.

glColor4f(1.0f, 1.0f, 1.0f, 0.5f);

Make sure to reset the color after you have drawn it by doing:

glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

Now this site don’t return error message!
The body has edited.

[QUOTE=opty2001;1253425]And… I means original -> image’s all pixel turns to wanted rgb value or add rgb value like blend color on original image, consider alpha value.
when I use glColor4f(?.0f,?.0f,?.0f,1.0f), it display only less rgb value… How can I use glColor4f in correct way?[/QUOTE]
glTexEnv(). E.g.


glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);

will add the current colour to the texture’s colour rather than multiplying it.

If you set the mode to GL_COMBINE (requires OpenGL 1.3 or later), then you can combine colours and textures using complex expressions. But that feature has largely been superseded by shaders.

Thank you! Problem is solved!

And in addition, did anyone know method of image’s all pixel to wanted color?

Thank you! Problem is solved!

And in addition, Is there people who know how to change the texture’s all pixel to targeted color?
[ATTACH=CONFIG]479[/ATTACH]

Anyway, problem is solved. Thank you again!