LWJGL
May 24, 2013, 13:40:14 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL is now using GitHub
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: Rendering in Colour or Black/White?  (Read 3610 times)
the2bears
Talks Too Much
***
Posts: 117



WWW
« on: December 30, 2003, 18:56:09 »

Hi,

Many of you know more about OpenGL than I so I'll ask a question.  I'm slowly learning but I've yet to see an answer to what I'd like to do.  I want at times to render a Sprite in black and white that is normally in colour.  I'll assume for now I'm using textures as the Sprite images (SPGL).  

Is this possible, is it easy, and most importantly does it make sense?  I could also have a second set of textures that are of course already black and white and switch at runtime those I render to the screen.  This is not too inelegant a solution.

Thanks for your help,

Bill
Logged

the2bears - the indie shmup blog
princec
Nerdus Imperius
*****
Posts: 1870



WWW
« Reply #1 on: December 31, 2003, 03:06:00 »

I used EXT_secondary_color to do it in AF when the gidrahs with more than 1 hitpoint get shot. Here's a bit of code I used to set up the state in SPGL:
Code:

if (GLCaps.GL_EXT_secondary_color) {
GL.glEnable(GL.GL_COLOR_SUM_EXT);
GL.glSecondaryColor3ubEXT((byte)255, (byte)255, (byte)255);
}
GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE);
GL.glEnableClientState(GL.GL_VERTEX_ARRAY);
GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
GL.glEnableClientState(GL.GL_COLOR_ARRAY);
GL.glEnable(GL.GL_TEXTURE_2D);
GL.glEnable(GL.GL_BLEND);
GL.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE);

That draws a white sprite like it's been struck by a bullet. Perfect. Works sorta ok if EXT_secondary_color is not supported as well but nearly all cards support it so that's not a problem.

Cas Smiley
Logged

the2bears
Talks Too Much
***
Posts: 117



WWW
« Reply #2 on: December 31, 2003, 05:04:06 »

Thanks... have I used up my three free questions yet?Smiley

Bill
Logged

the2bears - the indie shmup blog
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!