Rendering in Colour or Black/White?

Started by the2bears, December 31, 2003, 02:56:09

Previous topic - Next topic

the2bears

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
the2bears - the indie shmup blog

princec

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:
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 :)

the2bears

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

Bill
the2bears - the indie shmup blog