ruby_rpg 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/gl_native/gl_native.c +14 -0
- data/lib/engine/engine.rb +6 -1
- data/lib/engine/gl.rb +4 -0
- data/lib/engine/input.rb +8 -4
- data/lib/engine/window.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0f42925be918139d2f79f62c119f3097a2c710e0e3d9ac920a77e1acbfc46496
|
|
4
|
+
data.tar.gz: dca570d36818f5659d4ea2624deb545b69dab442120f551ea9950049d2303ec1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 164ed1bd89cf8fd8a9ee698f2e66b1ce65c65cc429591ccf4a6955e5afad60c57001ee77a73d4c38fa293a8e7bec0c19e93eb552b8cda7f101447b2ea3c2440d
|
|
7
|
+
data.tar.gz: a8f3030b5538a9d7c9a38f9666cff978a033b7b6e5a707c5bd11ae73f525bba5235e6cdb21a157d4aa4057fae6e49fd159a4eaea4723a3c867b5413098f13523
|
data/ext/gl_native/gl_native.c
CHANGED
|
@@ -490,6 +490,17 @@ static VALUE rb_gl_memory_barrier(VALUE self, VALUE barriers) {
|
|
|
490
490
|
return Qnil;
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
+
/* Initialize GLEW (Windows only) */
|
|
494
|
+
static VALUE rb_gl_init_glew(VALUE self) {
|
|
495
|
+
#if defined(_WIN32) || defined(__MINGW32__)
|
|
496
|
+
GLenum err = glewInit();
|
|
497
|
+
if (err != GLEW_OK) {
|
|
498
|
+
rb_raise(rb_eRuntimeError, "Failed to initialize GLEW: %s", glewGetErrorString(err));
|
|
499
|
+
}
|
|
500
|
+
#endif
|
|
501
|
+
return Qnil;
|
|
502
|
+
}
|
|
503
|
+
|
|
493
504
|
/* Extension init */
|
|
494
505
|
void Init_gl_native(void) {
|
|
495
506
|
mGLNative = rb_define_module("GLNative");
|
|
@@ -567,4 +578,7 @@ void Init_gl_native(void) {
|
|
|
567
578
|
rb_define_module_function(mGLNative, "bind_image_texture", rb_gl_bind_image_texture, 7);
|
|
568
579
|
rb_define_module_function(mGLNative, "dispatch_compute", rb_gl_dispatch_compute, 3);
|
|
569
580
|
rb_define_module_function(mGLNative, "memory_barrier", rb_gl_memory_barrier, 1);
|
|
581
|
+
|
|
582
|
+
/* GLEW initialization (Windows only, no-op on other platforms) */
|
|
583
|
+
rb_define_module_function(mGLNative, "init_glew", rb_gl_init_glew, 0);
|
|
570
584
|
}
|
data/lib/engine/engine.rb
CHANGED
|
@@ -4,10 +4,14 @@ GAME_DIR = File.expand_path(File.dirname($PROGRAM_NAME))
|
|
|
4
4
|
ENGINE_DIR = File.expand_path(File.dirname(__FILE__))
|
|
5
5
|
|
|
6
6
|
module Engine
|
|
7
|
-
def self.start(&first_frame_block)
|
|
7
|
+
def self.start(close_key: Input::KEY_ESCAPE, debug_key: nil, fullscreen_key: nil, &first_frame_block)
|
|
8
8
|
Engine::AutoLoader.load
|
|
9
9
|
return if ENV["BUILDING"] == "true"
|
|
10
10
|
|
|
11
|
+
Input.close_key = close_key
|
|
12
|
+
Input.debug_key = debug_key
|
|
13
|
+
Input.fullscreen_key = fullscreen_key
|
|
14
|
+
|
|
11
15
|
open_window
|
|
12
16
|
main_game_loop(&first_frame_block)
|
|
13
17
|
terminate
|
|
@@ -23,6 +27,7 @@ module Engine
|
|
|
23
27
|
|
|
24
28
|
Window.create_window
|
|
25
29
|
GLFW.MakeContextCurrent(Window.window)
|
|
30
|
+
Engine::GL.InitGLEW
|
|
26
31
|
|
|
27
32
|
Input.init
|
|
28
33
|
Rendering::GpuTimer.enable if ENV['GPU_PROFILE']
|
data/lib/engine/gl.rb
CHANGED
data/lib/engine/input.rb
CHANGED
|
@@ -109,6 +109,10 @@ module Engine
|
|
|
109
109
|
MOUSE_BUTTON_RIGHT = MOUSE_BUTTON_2
|
|
110
110
|
MOUSE_BUTTON_MIDDLE = MOUSE_BUTTON_3
|
|
111
111
|
|
|
112
|
+
class << self
|
|
113
|
+
attr_accessor :close_key, :debug_key, :fullscreen_key
|
|
114
|
+
end
|
|
115
|
+
|
|
112
116
|
def self.init
|
|
113
117
|
@key_callback = GLFW::create_callback(:GLFWkeyfun) do |window, key, scancode, action, mods|
|
|
114
118
|
Input.key_callback(key, action)
|
|
@@ -151,16 +155,16 @@ module Engine
|
|
|
151
155
|
|
|
152
156
|
def self._on_key_down(key)
|
|
153
157
|
keys[key] = :down
|
|
154
|
-
|
|
158
|
+
|
|
159
|
+
if close_key && key == close_key
|
|
155
160
|
Engine.close
|
|
156
161
|
end
|
|
157
162
|
|
|
158
|
-
if key ==
|
|
163
|
+
if debug_key && key == debug_key
|
|
159
164
|
Engine::Debugging.breakpoint { binding.pry }
|
|
160
|
-
# Engine.breakpoint { debugger }
|
|
161
165
|
end
|
|
162
166
|
|
|
163
|
-
if key ==
|
|
167
|
+
if fullscreen_key && key == fullscreen_key
|
|
164
168
|
Engine::Window.toggle_full_screen
|
|
165
169
|
end
|
|
166
170
|
end
|
data/lib/engine/window.rb
CHANGED