• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED] gpu_set_colorwriteenable(..) Why is image "blued"?

Bentley

Member
I have background sprite that I draw like this:
Code:
gpu_set_colorwriteenable(1, 1, 0, 1);
draw_sprite(sprite_index, 0, 0, 0);
gpu_set_colorwriteenable(1, 1, 1, 1);
When I run the game, the background is tinted blue. My expectation was that pixels with a blue component would get a blue component of 0, as I am disabling the "blue channel".

I am clearly misunderstand this function because I get the opposite: the entire image is tinted blue. Can someone explain my idiocy? Thx for reading.
 
Lets say your appsrf is white.
So 255, 255, 255.

Now you lock the blue channel and draw a solid mid gray onto the appsrf.
So you're drawing 127, 127, 127.

The result will be 127, 127, 255 because the blue channel couldnt change. Thats a light blue.
 
Last edited:

Bentley

Member
Lets say your appsrf is white.
So 255, 255, 255.

Now you lock the blue channel and draw a solid mid gray onto the appsrf.
So you're drawing 127, 127, 127.

The result will be 127, 127, 255 because the blue channel couldnt change. Thats a light blue.
Thanks a lot for the reply Reverend. So I was forgetting about the destination pixel, the application surface in this example? Maybe I should create a surface with 0 alpha.

Am I understanding my misunderstanding? (weirdly worded lol). Thanks again for reply. Appreciate it.
 
Im not sure what you want to happen. But if you want to draw the dprite but without its blue channel, thrn you dont need to lock the destinations colour with gpu_set_colorwriteenable. You'd need to set the drawing colour to orange. I.e. using draw_sprite_ext
 

Bentley

Member
Im not sure what you want to happen. But if you want to draw the dprite but without its blue channel, thrn you dont need to lock the destinations colour with gpu_set_colorwriteenable. You'd need to set the drawing colour to orange. I.e. using draw_sprite_ext
Edit: oh, when you say "the blue channel couldn't change" and is "locked", thats what that function does. Ok.

I thought it actually took out the blue component of spr_background if you disabled the blue channel. I read the manual and it said "disables the channel" and my silly mind thought it zeroed out the blue component or something.

The code I posted is not for a project or anything. I just wanted to learn about this function. Specifically b/c I've seen it used w/ shaders a lot.

Thanks again,
 
Last edited:
Top