LWJGL How can I render texture shape in white color

Started by Bluh, November 08, 2014, 01:58:49

Previous topic - Next topic

Bluh

Hi!

I want to render texture shape in plain white. What I mean by that is that I want to render rabbit shape but compleatly black. I have colored texture of rabbit and I wanna use it to render it all white. I want to keep alpha transparent.

I can render it with black by using:

glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);

but how can I do it to achive white?

quew8

It is achievable with OpenGL blending. You can use the GL_CONSTANT_COLOR blend function and set the blend colour to white (or any other colour you like) using glBlendColor(). So code:

glBlendFunc(GL_CONSTANT_COLOR, GL_ZERO); //Or is it "glBlendFunc(GL_ZERO, GL_CONSTANT_COLOR);", I can never remember.
glConstantColor(1, 1, 1, 1); //White, can be whatever you want.


But if you are familiar with shaders, it would be far simpler to implement this with them. If you are not familiar with shaders then I advise getting familiar with them at some point, you will find almost all things far simpler to implement with shaders.

What follows is an advert for shaders. No need to read.
It's like the difference between using a slide rule compared to a computer. Slide rules can be used immediately and are fairly simple to use but if you need to do something they aren't designed for then it becomes increasingly difficult or impossible. A computer on the other hand takes a little more setup time and a greater understanding but ultimately it's programmability will be far simpler, quicker and enable you to do anything. They're even going to be more efficient in 99% of cases.