GPU 깊이 가져오기 (gpu_get_depth)
이 문서는 gpu_get_depth
함수에 대해 설명합니다. 이 함수는 2D 드로잉 함수(스프라이트나 프리미티브 등)에 대한 현재 깊이(즉, z 좌표)를 반환합니다. 기본적으로 이 값은 현재 레이어의 깊이와 동일하지만, gpu_set_depth
함수를 사용하여 변경할 수 있습니다.
문법
gpu_get_depth();
반환값
- 실수형(Real)
예제
var _depth = gpu_get_depth();
show_debug_message($"The depth used for drawing is currently set to: {_depth}");
위의 코드는 gpu_get_depth
를 사용하여 드로잉에 사용되는 현재 깊이 값을 가져오고, 이를 디버그 메시지로 출력합니다.
활용 예제
예제 1: 깊이 값 변경 후 확인하기
gpu_set_depth(5);
var _new_depth = gpu_get_depth();
show_debug_message($"The new depth is set to: {_new_depth}");
예제 2: 깊이에 따라 다른 색상으로 드로잉하기
var _depth = gpu_get_depth();
if (_depth > 0) {
draw_set_color(c_red);
} else {
draw_set_color(c_blue);
}
draw_sprite(spr_example, 0, x, y);
예제 3: 깊이 값에 따라 오브젝트의 위치 조정하기
var _depth = gpu_get_depth();
y += _depth * 10; // 깊이에 따라 y 위치 조정
draw_sprite(spr_example, 0, x, y);
관련 함수
함수 이름 | 설명 |
---|---|
gpu_set_depth | 드로잉 깊이 값을 설정합니다. |
gpu_get_fog | 현재 안개 효과의 상태를 반환합니다. |
이 문서에서는 gpu_get_depth
함수의 사용법과 다양한 활용 예제를 살펴보았습니다.