@@ -2,7 +2,7 @@ local camera = require "orthographic.camera"
2
2
3
3
if sys .get_config (" script.shared_state" ) ~= " 1" then
4
4
error (" ERROR - camera - 'shared_state' setting in game.project must be enabled for camera to work." )
5
- end
5
+ end
6
6
7
7
local M = {}
8
8
@@ -14,6 +14,7 @@ local SET_CAMERA_OFFSET = hash("set_camera_offset")
14
14
local world_view = vmath .matrix4 ()
15
15
local world_projection = vmath .matrix4 ()
16
16
local screen_view = vmath .matrix4 ()
17
+ local screen_projection = vmath .matrix4 ()
17
18
local camera_offset = nil
18
19
19
20
41
42
function M .screen_projection ()
42
43
local current_window_width = render .get_window_width ()
43
44
local current_window_height = render .get_window_height ()
44
- local left , right , bottom , top
45
- if camera_offset then
46
- left = camera_offset .x
47
- right = left + current_window_width
48
- bottom = camera_offset .y
49
- top = bottom + current_window_height
50
- else
51
- left = 0
52
- right = current_window_width
53
- bottom = 0
54
- top = current_window_height
45
+ if current_window_width ~= 0 and current_window_height ~= 0 then
46
+ local left , right , bottom , top
47
+ if camera_offset then
48
+ left = camera_offset .x
49
+ right = left + current_window_width
50
+ bottom = camera_offset .y
51
+ top = bottom + current_window_height
52
+ else
53
+ left = 0
54
+ right = current_window_width
55
+ bottom = 0
56
+ top = current_window_height
57
+ end
58
+ screen_projection = vmath .matrix4_orthographic (left , right , bottom , top , - 1 , 1 )
55
59
end
56
- return vmath . matrix4_orthographic ( left , right , bottom , top , - 1 , 1 )
60
+ return screen_projection
57
61
end
58
62
59
63
function M .set_screen_view_projection ()
@@ -71,4 +75,4 @@ function M.on_message(_, message_id, message)
71
75
end
72
76
end
73
77
74
- return M
78
+ return M
0 commit comments