ruby_rpg 0.1.11 → 0.1.12
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/extconf.rb +5 -0
- data/ext/gl_native/gl_native.c +4 -4
- data/lib/engine/engine.rb +7 -4
- 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: 9e54200c1e0b414244c33df0255ecd386cad9c4af0be1fbaf76840c2e788ce38
|
|
4
|
+
data.tar.gz: e177db61ad913529edb6a4df455dea70035f5659122cf1c04b4d406241ee394f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5a9173b8c77ceecabfa5fa84f212775ffd93df183e6b5d6ab31ae69a529de8c2a19274c254d5517811ffe743cf57427ae32b81e44aa77edc702c8c6e23855227
|
|
7
|
+
data.tar.gz: a26c43ac5a06fc20793a0d5e45f6898e1eea61f0ec067ac910250f5eb38c37c082298cc8c7decbd01e529d25ab96152ff66816f6f30d434c1c07d3e8983c962b
|
data/ext/gl_native/extconf.rb
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
require 'mkmf'
|
|
4
4
|
|
|
5
|
+
# A GL call with no prototype gets an implicit int return, which truncates
|
|
6
|
+
# pointers on 64-bit — fail the build instead
|
|
7
|
+
$CFLAGS << " -Werror=implicit-function-declaration" unless RUBY_PLATFORM =~ /mswin/
|
|
8
|
+
|
|
5
9
|
# Find OpenGL
|
|
6
10
|
case RUBY_PLATFORM
|
|
7
11
|
when /darwin/
|
|
@@ -9,6 +13,7 @@ when /darwin/
|
|
|
9
13
|
$CFLAGS << " -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers"
|
|
10
14
|
when /linux/
|
|
11
15
|
have_library('GL') or abort "OpenGL not found"
|
|
16
|
+
have_library('GLEW') or abort "GLEW not found (install libglew-dev)"
|
|
12
17
|
when /mingw|mswin/
|
|
13
18
|
glew_dir = File.expand_path('../../../vendor/glew-2.2.0-win32', __FILE__)
|
|
14
19
|
$CFLAGS << " -I#{glew_dir}/include"
|
data/ext/gl_native/gl_native.c
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
extern void glBindImageTexture(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
|
|
7
7
|
extern void glDispatchCompute(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);
|
|
8
8
|
extern void glMemoryBarrier(GLbitfield barriers);
|
|
9
|
-
#elif defined(_WIN32) || defined(__MINGW32__)
|
|
9
|
+
#elif defined(_WIN32) || defined(__MINGW32__) || defined(__linux__)
|
|
10
10
|
#include <GL/glew.h>
|
|
11
11
|
#else
|
|
12
12
|
#include <GL/gl.h>
|
|
@@ -490,9 +490,9 @@ static VALUE rb_gl_memory_barrier(VALUE self, VALUE barriers) {
|
|
|
490
490
|
return Qnil;
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
-
/* Initialize GLEW (Windows
|
|
493
|
+
/* Initialize GLEW (Windows and Linux) */
|
|
494
494
|
static VALUE rb_gl_init_glew(VALUE self) {
|
|
495
|
-
#if defined(_WIN32) || defined(__MINGW32__)
|
|
495
|
+
#if defined(_WIN32) || defined(__MINGW32__) || defined(__linux__)
|
|
496
496
|
GLenum err = glewInit();
|
|
497
497
|
if (err != GLEW_OK) {
|
|
498
498
|
rb_raise(rb_eRuntimeError, "Failed to initialize GLEW: %s", glewGetErrorString(err));
|
|
@@ -579,6 +579,6 @@ void Init_gl_native(void) {
|
|
|
579
579
|
rb_define_module_function(mGLNative, "dispatch_compute", rb_gl_dispatch_compute, 3);
|
|
580
580
|
rb_define_module_function(mGLNative, "memory_barrier", rb_gl_memory_barrier, 1);
|
|
581
581
|
|
|
582
|
-
/* GLEW initialization (Windows
|
|
582
|
+
/* GLEW initialization (Windows and Linux, no-op on macOS) */
|
|
583
583
|
rb_define_module_function(mGLNative, "init_glew", rb_gl_init_glew, 0);
|
|
584
584
|
}
|
data/lib/engine/engine.rb
CHANGED
|
@@ -39,7 +39,7 @@ module Engine
|
|
|
39
39
|
Engine::GL.Enable(Engine::GL::CULL_FACE)
|
|
40
40
|
Engine::GL.CullFace(Engine::GL::BACK)
|
|
41
41
|
|
|
42
|
-
GLFW.SwapInterval(OS.
|
|
42
|
+
GLFW.SwapInterval(OS.mac? ? 0 : 1)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def self.main_game_loop(&first_frame_block)
|
|
@@ -74,13 +74,16 @@ module Engine
|
|
|
74
74
|
|
|
75
75
|
Window.get_framebuffer_size
|
|
76
76
|
|
|
77
|
-
if OS.
|
|
78
|
-
|
|
79
|
-
else
|
|
77
|
+
if OS.mac?
|
|
78
|
+
# Async swap keeps the main thread free while waiting on the display link
|
|
80
79
|
@swap_buffers_promise = Concurrent::Promise.new do
|
|
81
80
|
GLFW.SwapBuffers(Window.window)
|
|
82
81
|
end
|
|
83
82
|
@swap_buffers_promise.execute
|
|
83
|
+
else
|
|
84
|
+
# GLX requires SwapBuffers on the thread owning the context, so
|
|
85
|
+
# Windows and Linux swap synchronously
|
|
86
|
+
GLFW.SwapBuffers(Window.window)
|
|
84
87
|
end
|
|
85
88
|
|
|
86
89
|
Engine::Input.update_key_states
|