Hello Guest

[SOLVED] Problem with writing a Colorizer

  • 4 Replies
  • 3727 Views
[SOLVED] Problem with writing a Colorizer
« on: August 16, 2012, 14:29:41 »
« Last Edit: August 18, 2012, 10:05:02 by Bluecode »

Re: Problem with writing a Colorizer
« Reply #1 on: August 17, 2012, 12:59:56 »
Using gradient transparency will screw you over because that changes the color field values.

The simplest thing you can do is render every individual object with your shader Your shader is a bit inefficient but that's what you get with non-optimized palletization (plus it doesn't look like your game is complicated enough for it to really matter).

Really though, this is an offshoot of you using a non-rigorous system - since you are using direct color swapping, as soon as the color is not exact everything gets screwed up.

Re: Problem with writing a Colorizer
« Reply #2 on: August 17, 2012, 18:20:07 »
Thanks for your reply !

I modified my code, and now every sprite render with my shader.
However, I was using glColor calls (for drawing some one-colored elements of the GUI, or for apply some transparency to my objects), and now everything is gone. Is there an alternative to glColor for that, or must I disable my shaders every time I draw something with glColor ? Here is two distinct examples on how I'm using this function :

Code: [Select]
glBegin(GL_QUADS);
glColor4f(color.r / 255f, color.g / 255f, color.b / 255f, color.a / 255f);
glVertex2f(x, y);
glVertex2f(x + width, y);
glVertex2f(x + width, y + height);
glVertex2f(x, y + height);
glEnd();

For this one I can simply call GL20.glUseProgram(0); before glBegin and GL20.glUseProgram(Shader.program); after glEnd, but the following is a little more complicated :

Code: [Select]
GL11.glColor4f(1f, 1f, 1f, 0.5f);
cursor.render(mouseX, mouseY);
GL11.glColor4f(1f, 1f, 1f, 1f);

Here, the cursor's sprite needs to be colorized, so I can't disable my shaders.

Here is a pic showing the bottom info bar and the entity selection background being gone, too :


Re: Problem with writing a Colorizer
« Reply #3 on: August 17, 2012, 23:52:32 »

Re: Problem with writing a Colorizer
« Reply #4 on: August 18, 2012, 10:04:46 »
Oh, ok, didn't know that we can include this color in GLSL !

Everything works fine now, thanks a lot !