• 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!

GameMaker Drawing Surface Issue

J

Jordan Robinson

Guest
I might just be missing something obvious, but for the life of me I cannot get this to work.

In this example, I am attempting to use a surface to draw a black rectangle in the top left corner of the room from the draw_end event of an instance.


Code:
var surface = surface_create(_game_width, _game_height);

surface_set_target(surface);

draw_rectangle(0, 0, _game_width, _game_height, false);

surface_reset_target();

draw_surface(surface, 0, 0);

surface_free(surface);
This does not appear to do anything. Am I missing something obvious? If I just put
Code:
draw_rectangle(0, 0, _game_width, _game_height, false);
then it draws the black rectangle as intended.
 

obscene

Member
This looks correct to me, assuming it's as you say and that code is in the draw event and nothing is going on with views, GUI etc.

I don't know if it's a good idea to create a temp surface and immediately clear it after use. Never done that, so not sure if it could be causing an issue. But typically you create it in the create event and only free it when you are done with it (room end or destroy event).

And I assume you are normal blend mode?
 
J

Jordan Robinson

Guest
I discovered the solution on another forum. I needed to add
Code:
camera_apply(view_get_camera(0));
and it solved everything. Very tricky to find that info... I didn't realise that the camera system was so affected by surfaces
 
Top