Confused by surfaces and shaders

jujubs

Member
So I'm making a game designed to look like it (kinda) runs on the Game Boy. So far, I was making it in black, white, dark grey and light grey, but I tried a shader to turn those colors into shades of green and it looked amazing (or, at least, people I've showed it to seem to think so).


The thing now is: what's the best way to apply this shader to the whole game? I tried setting it to all objects, but couldn't figure out how to make it work with the hud. Also, when I pause the game, now I get a black screen instead of the usual "pause" my control object was drawing. I've read about surfaces, and it appears that drawing everything to a surface then applying the shader to it could be a more efficient solution, but then, would it work with the pause method? What'd be the best way to approach this?
 

Simon Gust

Member
How does your pause work?
In your control, you can set the shader in the draw event, then draw everything from there and reset the shader in the draw GUI event after you've drawn the HUD.
And if your pause system is just a rectangle on top of everything, you can make it draw after you've reset the shader.
 

jujubs

Member
How does your pause work?
In your control, you can set the shader in the draw event, then draw everything from there and reset the shader in the draw GUI event after you've drawn the HUD.
And if your pause system is just a rectangle on top of everything, you can make it draw after you've reset the shader.
I have a control object in the room. In the Step event, I have the following:
Code:
///handles pausing
if(keyboard_check_pressed(vk_escape) || keyboard_check_pressed(ord('P')) || gamepad_button_check_pressed(0, gp_start))
{   if(!pause)
    {
        pause = true;
        audio_pause_all();
        instance_deactivate_all(true);
    }
    else
    {
        pause = false;
        audio_resume_all();
        instance_activate_all();
    }
}
Then, in the Draw event:
Code:
if(pause)
{
    shader_set(shdr_palette_swap); 
    draw_sprite(spr_pause, 0, room_width/2, room_height/2);
    color_set(obj_control);

    shader_reset();
}
As you can see, I even tried setting the shader again, but it didn't work.
 

TheSnidr

Heavy metal viking dentist
GMC Elder
Read a bit about the application surface in the manual - the entire game is actually drawn to a regular surface, and this surface is drawn onto the screen. You can disable this automatic drawing, and then you can manually draw it yourself to the screen with a custom shader. You'll need to mess about with the post draw event (not entirely sure what it's called) and stuff.

This method will affect everything on the screen.
 
Top