• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Draw gui event being disabled?


Your Creator!
I was porting over my windows 3.1 remake (https://forum.yoyogames.com/index.php?threads/uiz-windows-3-1-made-in-uiz-in-game-maker.12624/) over to game maker studio 2, and noticed some weird behavior.

Whenever open a new window, It isn't being drawn. It's there and it's step event is being executed however, It's not being drawn. The single window which does work for reason makes the entire screen update. So when I open up a clock window, I cant see it until I slightly move my main window. Then the clock windows works, and I can see the clock move. Then if I move the clock window slightly it freezes again and is only getting moved in the background, and I again have to press my main window which makes my clock animation continue.

Here is an example video:

After some digging around, and trying some debug messages, I figures out that my draw gui event is not being executed. My step event is being executed fine, just the gui doesn't work for some reason. The debug messages are placed at the exact beginnings of my code without any other functions or statements in between. I'm also not using draw_enable_drawevent or anything.

What's practically happening is that every object is placed on the same layer and then there are depth varies inside that layer, which can go to quite extreme depths up into the -100000ths.
This is a big project, so to find the exact source of my problems could take a while.
For this reason my question is if anyone knows of any other mechanics that could break my code and prevent my draw gui event from being executed. Maybe some depth issues or something?.


YoYo Games Staff
YYG Staff
OK the default behaviour is to use the depth value as the Z for any gpu primitives that are generated, this means that you are limited to the Z depth range of the perspective matrix in the camera used for rendering so you have 2 options at this point

1) Change the camera so the Z range is correct for the depths that you wish to render


2) use the following functions to force the Z to be used for this layer when rendering (NOTE: does not affect the order in which the primitives are generated only the value used for Z testing and writing when rendering)
  • layer_force_draw_depth(force,depth) - force all layers to be drawn at a specific Z depth (does not change ordering)
  • layer_is_draw_depth_forced() - true if currently being rendered with draw depth forced
  • layer_get_forced_depth() - get the value of the depth that rendering is enforcing
Hope that clears it up.



I had a similar problem (Draw GUI not triggering) - turned out I'd disabled the object's layer (with layer_set_visible(), in order to depth sort the layer myself). I just moved my GUI code to another object instead.
@MaddeMichael @rwkay But is that (-)16000 limit for layers themselves, for depth within layers or these two factors combined?
Btw tanks @rwkay, I'll try that in a minute.
Depth isn't the same thing it used to be, and depth isn't per layer (though that'd be really neat) - now depth creates an internally managed layer that are handled purely by the engine - hence, I'd imagine these internal layers have the same restrictions.


YoYo Games Staff
YYG Staff
The limit is only present because the default camera has that limitation for the Z buffer (anything lower than -16000 is behind the camera and so is rejected by the Z buffer) this behaviour can be changed as the above post illustrates (and this is what we do on 1.4 project import, to mimic the default behaviour of 1.4).

The hard numbers can be changed if you replace the camera with a code created one that you have made yourself.

Effectively what is happening is you are saying that any layers lower than -16000 are behind the actual camera (in space) and so cannot be rendered by that camera.



Your Creator!
Thanks guys, I think I understand most of the basics now. I'm looking at the best solution for my projects.
How I used to have it setup is last 3 digits depths of playroom for objects. digits 4-6 room for frames and digits 7-9 room for windows. That explains why my code uses such high depth. So I'm going to see what I can do to shorten these margins, maybe even shift everything downwards where a depth of 0 is something like 10000, because I wasn't using positive values anyways.

And if I get it right, the view depth distance of the camera is then 320000, and then the camera is placed at -160000.