clip cursor by crosshair dimensions
This commit is contained in:
parent
8b5b32ba76
commit
edadca820a
BIN
res/graphics/crosshair.ase
(Stored with Git LFS)
BIN
res/graphics/crosshair.ase
(Stored with Git LFS)
Binary file not shown.
17
src/user.c
17
src/user.c
@ -527,9 +527,6 @@ INTERNAL void user_update(void)
|
||||
}
|
||||
|
||||
if (L.debug_camera) {
|
||||
sys_window_cursor_disable_clip(L.window);
|
||||
sys_window_cursor_show(L.window);
|
||||
|
||||
/* Pan view */
|
||||
if (L.bind_states[USER_BIND_KIND_PAN].is_held) {
|
||||
if (!L.debug_camera_panning) {
|
||||
@ -567,10 +564,6 @@ INTERNAL void user_update(void)
|
||||
L.world_view = xform_translate(L.world_view, v2_neg(world_cursor));
|
||||
}
|
||||
} else {
|
||||
/* Keep cursor invisible and in screen */
|
||||
sys_window_cursor_hide(L.window);
|
||||
sys_window_cursor_enable_clip(L.window, RECT(0, 0, L.screen_size.x, L.screen_size.y));
|
||||
|
||||
struct v2 center = active_camera->world_xform.og;
|
||||
f32 rot = xform_get_rotation(active_camera->world_xform);
|
||||
f32 zoom = active_camera->camera_zoom;
|
||||
@ -786,17 +779,25 @@ INTERNAL void user_update(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw crosshair */
|
||||
/* Draw crosshair or enable cursor */
|
||||
if (!L.debug_camera) {
|
||||
struct v2 crosshair_pos = L.screen_cursor;
|
||||
u32 tint = RGBA_F(1, 1, 1, 0.5);
|
||||
|
||||
struct v2 size = V2(0, 0);
|
||||
struct texture *t = texture_load_async(STR("res/graphics/crosshair.ase"));
|
||||
if (t) {
|
||||
size = t->size;
|
||||
struct xform xf = XFORM_TRS(.t = crosshair_pos, .s = t->size);
|
||||
struct quad quad = quad_mul_xform(QUAD_UNIT_SQUARE_CENTERED, xf);
|
||||
draw_texture_quad(L.screen_canvas, DRAW_TEXTURE_PARAMS(.texture = t, .tint = tint), quad);
|
||||
}
|
||||
|
||||
sys_window_cursor_hide(L.window);
|
||||
sys_window_cursor_enable_clip(L.window, RECT(size.x / 2, size.y / 2, L.screen_size.x - size.x, L.screen_size.y - size.y));
|
||||
} else {
|
||||
sys_window_cursor_disable_clip(L.window);
|
||||
sys_window_cursor_show(L.window);
|
||||
}
|
||||
|
||||
/* ========================== *
|
||||
|
||||
Loading…
Reference in New Issue
Block a user