Results 1 to 7 of 7

Thread: OpenGL Texture Colour Change

  1. #1
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45

    OpenGL Texture Colour Change

    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.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  2. #2
    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.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  3. #3
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    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
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  4. #4
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    just out of interest, is there also any way to do the same with transparency?
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  5. #5
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    nevermind, found it: glcolour4i haha, i didnt think it was that simple guess I may have misjudged OpenGl a little, I now know why everything was coming out funny coloured
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  6. #6
    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.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  7. #7
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    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.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •