PDA

View Full Version : OpenGL Texture Colour Change



code_glitch
11-04-2011, 05:30 PM
I'm sure there is a gl line for this but can't find it anywhere, basically I have a texture loaded (loads of characters) and I am looking for a way to change that white/grey colour in the texture to a specified RGB on the fly...

So basically:
Render a texture that is basically black and white and use the 'greyness' to indicate the shade of the RGB colour to draw whilst keeping the alpha value. If it can be done at all...

Any help would be greatly appreciated, because I have no clue on what gl calls do the job efficiently. ???

chronozphere
11-04-2011, 05:39 PM
Do you render your font's using DirectMode? Then a call to glColor() will probably do. It sets the diffuse color to the desired value. :) It's been a while since I last used colors/materials and I find that it's one of the most complicated parts of the OpenGL fixed function pipe. Personally, I wouldn't bother and start writing shaders instead, but hey that's just me. ;)

I suggest you look up some extra info about colors and materials. Showing us some of your render code can also help. :)

code_glitch
11-04-2011, 05:43 PM
If I use glColor, does it only apply to the quad I'm drawing or everything I draw thereafter, in which case I need to call it again to set it all back?

Cheers,
code_glitch with an inherent hatred for some aspects of OpenGL, notably, colours and rotations ;)

code_glitch
11-04-2011, 06:20 PM
just out of interest, is there also any way to do the same with transparency?

code_glitch
11-04-2011, 06:25 PM
nevermind, found it: glcolour4i haha, i didnt think it was that simple :D guess I may have misjudged OpenGl a little, I now know why everything was coming out funny coloured ;)

chronozphere
11-04-2011, 09:15 PM
Good you could make it work. :)

Yes, colors/materials is a very messy part of OpenGL. There are a lot of calculations and constants involved. Everytime I need to use it, I have to take some time to dive into the documentation. Shaders on the other hand are much cleaner, because they allow you to define your own calculations. There's still alot of learning involved though, but it's less cumbersome.

code_glitch
11-04-2011, 10:02 PM
Oh I take a similar approach, dump it into some API (like prometheus ;)) and never touch it again. You just know its there and it works too so I'm good with that.