ruby_rpg 0.1.12 → 0.1.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e54200c1e0b414244c33df0255ecd386cad9c4af0be1fbaf76840c2e788ce38
4
- data.tar.gz: e177db61ad913529edb6a4df455dea70035f5659122cf1c04b4d406241ee394f
3
+ metadata.gz: bb76dd99560004e92918ecdb5910847e8939eb844488d04b2267c1f1cf044d10
4
+ data.tar.gz: 899699b008c112d351ae98e9ac2162995af0e83e5d001bbfebabc1f470f3821f
5
5
  SHA512:
6
- metadata.gz: 5a9173b8c77ceecabfa5fa84f212775ffd93df183e6b5d6ab31ae69a529de8c2a19274c254d5517811ffe743cf57427ae32b81e44aa77edc702c8c6e23855227
7
- data.tar.gz: a26c43ac5a06fc20793a0d5e45f6898e1eea61f0ec067ac910250f5eb38c37c082298cc8c7decbd01e529d25ab96152ff66816f6f30d434c1c07d3e8983c962b
6
+ metadata.gz: d3a81d3ea6a574b25e7e17de6cf736becfbb2cfba20a82e90c7f0044bc37ab0c282bef5f07cbdb414ff037fe8d9151c281291bf86db9c081ddb3b973961ba8d4
7
+ data.tar.gz: 3141f56c495b22b7ffc587a1b3d136b8546c9da599a7391d63cb5cdee05a20bd0116fe25931365d1c93c4016fda32de1b96074bab7c970d05f3a97039fe32527
@@ -52,6 +52,7 @@ typedef const GLFWvidmode* (*PFN_glfwGetVideoMode)(GLFWmonitor*);
52
52
  typedef const GLFWvidmode* (*PFN_glfwGetVideoModes)(GLFWmonitor*, int*);
53
53
  typedef void (*PFN_glfwSetInputMode)(GLFWwindow*, int, int);
54
54
  typedef int (*PFN_glfwGetInputMode)(GLFWwindow*, int);
55
+ typedef int (*PFN_glfwGetError)(const char**);
55
56
 
56
57
  /* Function pointers storage */
57
58
  static PFN_glfwInit pfn_glfwInit = NULL;
@@ -78,6 +79,7 @@ static PFN_glfwGetVideoMode pfn_glfwGetVideoMode = NULL;
78
79
  static PFN_glfwGetVideoModes pfn_glfwGetVideoModes = NULL;
79
80
  static PFN_glfwSetInputMode pfn_glfwSetInputMode = NULL;
80
81
  static PFN_glfwGetInputMode pfn_glfwGetInputMode = NULL;
82
+ static PFN_glfwGetError pfn_glfwGetError = NULL;
81
83
 
82
84
  /* Library handle */
83
85
  static void* glfw_lib = NULL;
@@ -145,6 +147,7 @@ static VALUE rb_glfw_load_lib(VALUE self, VALUE path) {
145
147
  pfn_glfwGetVideoModes = (PFN_glfwGetVideoModes)load_func("glfwGetVideoModes");
146
148
  pfn_glfwSetInputMode = (PFN_glfwSetInputMode)load_func("glfwSetInputMode");
147
149
  pfn_glfwGetInputMode = (PFN_glfwGetInputMode)load_func("glfwGetInputMode");
150
+ pfn_glfwGetError = (PFN_glfwGetError)load_func("glfwGetError");
148
151
 
149
152
  return Qtrue;
150
153
  }
@@ -215,6 +218,14 @@ static VALUE rb_glfw_set_window_monitor(VALUE self, VALUE window, VALUE monitor,
215
218
  return Qnil;
216
219
  }
217
220
 
221
+ /* GetError() */
222
+ static VALUE rb_glfw_get_error(VALUE self) {
223
+ if (!pfn_glfwGetError) return Qnil;
224
+ const char* description = NULL;
225
+ int code = pfn_glfwGetError(&description);
226
+ return rb_ary_new3(2, INT2NUM(code), description ? rb_str_new2(description) : Qnil);
227
+ }
228
+
218
229
  /* WindowShouldClose(window) */
219
230
  static VALUE rb_glfw_window_should_close(VALUE self, VALUE window) {
220
231
  if (!pfn_glfwWindowShouldClose) rb_raise(rb_eRuntimeError, "GLFW not loaded");
@@ -424,6 +435,7 @@ void Init_glfw_native(void) {
424
435
  rb_define_module_function(mGLFWNative, "set_window_attrib", rb_glfw_set_window_attrib, 3);
425
436
  rb_define_module_function(mGLFWNative, "set_window_title", rb_glfw_set_window_title, 2);
426
437
  rb_define_module_function(mGLFWNative, "set_window_monitor", rb_glfw_set_window_monitor, 7);
438
+ rb_define_module_function(mGLFWNative, "get_error", rb_glfw_get_error, 0);
427
439
  rb_define_module_function(mGLFWNative, "window_should_close", rb_glfw_window_should_close, 1);
428
440
  rb_define_module_function(mGLFWNative, "set_window_should_close", rb_glfw_set_window_should_close, 2);
429
441
  rb_define_module_function(mGLFWNative, "focus_window", rb_glfw_focus_window, 1);
data/lib/engine/engine.rb CHANGED
@@ -4,10 +4,11 @@ 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(close_key: Input::KEY_ESCAPE, debug_key: nil, fullscreen_key: nil, &first_frame_block)
7
+ def self.start(close_key: Input::KEY_ESCAPE, debug_key: nil, fullscreen_key: nil, opengl_version: nil, &first_frame_block)
8
8
  Engine::AutoLoader.load
9
9
  return if ENV["BUILDING"] == "true"
10
10
 
11
+ Window.opengl_version = opengl_version if opengl_version
11
12
  Input.close_key = close_key
12
13
  Input.debug_key = debug_key
13
14
  Input.fullscreen_key = fullscreen_key
data/lib/engine/gl.rb CHANGED
@@ -377,6 +377,7 @@ module Engine
377
377
  READ_FRAMEBUFFER = 0x8CA8
378
378
  READ_WRITE = 0x88BA
379
379
  REPEAT = 0x2901
380
+ RENDERER = 0x1F01
380
381
  REPLACE = 0x1E01
381
382
  RGB = 0x1907
382
383
  RGB16F = 0x881B
@@ -408,6 +409,7 @@ module Engine
408
409
  UNSIGNED_BYTE = 0x1401
409
410
  UNSIGNED_INT = 0x1405
410
411
  UNSIGNED_INT_24_8 = 0x84FA
412
+ VENDOR = 0x1F00
411
413
  VERTEX_SHADER = 0x8B31
412
414
  VERSION = 0x1F02
413
415
 
data/lib/engine/glfw.rb CHANGED
@@ -54,6 +54,10 @@ module GLFW
54
54
  GLFWNative.terminate
55
55
  end
56
56
 
57
+ def GetError
58
+ GLFWNative.get_error
59
+ end
60
+
57
61
  def CreateWindow(width, height, title, monitor, share)
58
62
  GLFWNative.create_window(width, height, title, monitor, share)
59
63
  end
data/lib/engine/window.rb CHANGED
@@ -8,6 +8,7 @@ module Engine
8
8
  class << self
9
9
  attr_accessor :full_screen, :window, :window_title
10
10
  attr_reader :framebuffer_height, :framebuffer_width
11
+ attr_writer :opengl_version
11
12
 
12
13
  def create_window
13
14
  set_opengl_version
@@ -18,6 +19,10 @@ module Engine
18
19
  @window = GLFW.CreateWindow(
19
20
  initial_video_mode.width, initial_video_mode.height, DEFAULT_TITLE, nil, nil
20
21
  )
22
+ if @window.nil?
23
+ code, description = GLFW.GetError
24
+ raise "Failed to create GLFW window (error #{code}: #{description})"
25
+ end
21
26
  GLFW.SetWindowMonitor(
22
27
  @window, nil, 0, 0,
23
28
  initial_video_mode.width, initial_video_mode.height,
@@ -114,9 +119,14 @@ module Engine
114
119
  @framebuffer_height = height_buf.unpack1('L')
115
120
  end
116
121
 
122
+ def opengl_version
123
+ @opengl_version || (OS.mac? ? "4.1" : "4.3")
124
+ end
125
+
117
126
  def set_opengl_version
118
- GLFW.WindowHint(GLFW::CONTEXT_VERSION_MAJOR, 4)
119
- GLFW.WindowHint(GLFW::CONTEXT_VERSION_MINOR, OS.mac? ? 1 : 3)
127
+ major, minor = opengl_version.split(".").map { |part| Integer(part) }
128
+ GLFW.WindowHint(GLFW::CONTEXT_VERSION_MAJOR, major)
129
+ GLFW.WindowHint(GLFW::CONTEXT_VERSION_MINOR, minor)
120
130
  GLFW.WindowHint(GLFW::OPENGL_PROFILE, GLFW::OPENGL_CORE_PROFILE)
121
131
  GLFW.WindowHint(GLFW::OPENGL_FORWARD_COMPAT, GLFW::TRUE)
122
132
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_rpg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Hatfull
@@ -312,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
312
312
  - !ruby/object:Gem::Version
313
313
  version: '0'
314
314
  requirements: []
315
- rubygems_version: 4.0.10
315
+ rubygems_version: 4.0.16
316
316
  specification_version: 4
317
317
  summary: A game engine written in Ruby
318
318
  test_files: []