glfw 0.1.0 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +9 -3
- data/.idea/glfw.iml +10 -12
- data/.idea/misc.xml +6 -6
- data/.idea/modules.xml +7 -7
- data/.idea/workspace.xml +44 -159
- data/Makefile +267 -0
- data/README.md +78 -17
- data/Rakefile +15 -3
- data/ext/glfw/common.h +46 -0
- data/ext/glfw/cursor.c +42 -0
- data/ext/glfw/cursor.h +14 -0
- data/ext/glfw/extconf.rb +24 -0
- data/ext/glfw/glfw.c +438 -0
- data/ext/glfw/glfw.h +41 -0
- data/ext/glfw/glfw3.h +4248 -0
- data/ext/glfw/glfw3native.h +456 -0
- data/ext/glfw/image.c +77 -0
- data/ext/glfw/image.h +14 -0
- data/ext/glfw/lib/libglfw3.a +0 -0
- data/ext/glfw/monitor.c +209 -0
- data/ext/glfw/monitor.h +29 -0
- data/ext/glfw/video_mode.c +60 -0
- data/ext/glfw/video_mode.h +21 -0
- data/ext/glfw/vulkan.c +48 -0
- data/ext/glfw/vulkan.h +16 -0
- data/ext/glfw/window.c +708 -0
- data/ext/glfw/window.h +87 -0
- data/glfw-icon.png +0 -0
- data/glfw.gemspec +9 -10
- data/lib/glfw.rb +17 -123
- data/lib/glfw/version.rb +1 -1
- metadata +63 -12
- data/.rspec +0 -3
- data/lib/glfw/window.rb +0 -12
data/README.md
CHANGED
@@ -1,43 +1,104 @@
|
|
1
|
-
#
|
1
|
+
# ![icon](./glfw-icon.png) GLFW
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
This is a Ruby C-extension that for the excellent [GLFW](https://github.com/glfw/glfw) library. Unlike other bindings, this gem goes beyond just providing a 1:1 wrapper of the functions, and has been organized to be used in a more object-oriented, Ruby way. Being statically linked with the included object file during compilation alleviates any headaches with regards to versioning or dependencies, as none are required for this gem.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
|
7
|
+
One of the other advantages this gem offers is that it does not require external dependencies, not even the GLFW3 API. Instead of linking to an extisting library, the gem includes the headers and `glfw3.a` static library to compile against during installation. This offers a much easier, more consistent installation process, without the end-user required to ensure any pre-existing files are properly installed, or concern over versions. As the API the gem is based quite stable and mature, new realeases are uncommon, though this gem will update as they become available to provide the latest version.
|
8
|
+
|
9
|
+
### From [RubyGems.org](https://rubygems.org/gems/glfw)
|
10
|
+
|
11
|
+
$ gem install glfw
|
12
|
+
|
13
|
+
### From Source
|
14
|
+
|
15
|
+
Open a terminal/command prompt in the base directory:
|
16
|
+
|
17
|
+
$ gem build glfw.gemspec
|
18
|
+
$ gem install glfw-[VERSION].gem
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
### Window Creation
|
23
|
+
|
24
|
+
At is simplest, to create a platform-specific window with an OpenGL context requires very little code.
|
10
25
|
|
11
26
|
```ruby
|
12
|
-
|
27
|
+
GLFW::Window.new(800, 600, "Hello, World!") do |window|
|
28
|
+
|
29
|
+
until window.closing?
|
30
|
+
GLFW.poll_events
|
31
|
+
GLFW.swap_buffers
|
32
|
+
# Your rendering code goes here
|
33
|
+
end
|
34
|
+
end
|
13
35
|
```
|
14
36
|
|
15
|
-
|
37
|
+
You will likely want to fine-tune the created context to what your application requires. GLFW exposes these as "hints", which can be set **before** a window is created.
|
16
38
|
|
17
|
-
|
39
|
+
```ruby
|
40
|
+
# Initialize GLFW core
|
41
|
+
GLFW.init
|
18
42
|
|
19
|
-
|
43
|
+
# Load default window hints. This will reset any previous hints given
|
44
|
+
GLFW.default_hints
|
20
45
|
|
21
|
-
|
46
|
+
# Window will be NOT be decorated (title, border, close widget, etc)
|
47
|
+
GLFW.hint(GLFW::HINT_DECORATED, false)
|
22
48
|
|
23
|
-
|
49
|
+
# Specifiy MINIMUM required OpenGL version
|
50
|
+
GLFW.hint(GLFW::HINT_CONTEXT_VERSION_MAJOR, 3)
|
51
|
+
GLFW.hint(GLFW::HINT_CONTEXT_VERSION_MAJOR, 0)
|
52
|
+
```
|
53
|
+
|
54
|
+
All constants for creation hints are prefixed with `HINT`.
|
24
55
|
|
25
|
-
|
56
|
+
### Callbacks
|
26
57
|
|
27
|
-
|
58
|
+
GLFW offers a high-level of control of the application window, including callbacks for nearly every relevant system event that effects the window (see documentation for what all callbacks are available). By default, most of these callbacks are disabled, and need enabled with a method call to have them fired. This for performance reasons, as it is inefficient to have them all being invoked if they are not going to be used.
|
28
59
|
|
29
|
-
|
60
|
+
To enable a callback:
|
30
61
|
|
31
|
-
|
62
|
+
```ruby
|
63
|
+
window.enable_callback(GLFW::CB_RESIZED, true)
|
64
|
+
```
|
65
|
+
|
66
|
+
You then have two options; to either alias the `GLFW::Window` class for the relevant callback, or more commonly is to create your own class the inherits from `GLFW::Window`.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
class MyGame < GLFW::Window
|
70
|
+
|
71
|
+
def initialize
|
72
|
+
super(800, 600, "My Awesome Game Title", fullscreen: true)
|
73
|
+
enable_callback(GLFW::CB_RESIZED, true)
|
74
|
+
end
|
75
|
+
|
76
|
+
# This method will be invoked when the window is resized.
|
77
|
+
def resized(width, hight)
|
78
|
+
# Your code goes here.
|
79
|
+
# The "width/height" arguments passed are the new size
|
80
|
+
end
|
81
|
+
end
|
82
|
+
```
|
83
|
+
|
84
|
+
All constants for callbacks are prefixed with `CB`.
|
85
|
+
|
86
|
+
## Documentation
|
87
|
+
|
88
|
+
The documentation is a work-in-progress.
|
89
|
+
|
90
|
+
The GLFW API offers a very in-depth and detailed [documentation](http://www.glfw.org/docs/latest/intro_guide.html) that may be used as a subsitute until complete, and as a fantastic stand-alone source of information to understanding the linrary.
|
32
91
|
|
33
92
|
## Contributing
|
34
93
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
94
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ForeverZer0/glfw. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
95
|
|
37
96
|
## License
|
38
97
|
|
39
98
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
99
|
|
100
|
+
The [GLFW API](http://www.glfw.org) is is licensed under the [zlib/libpng](http://www.glfw.org/license.html) license.
|
101
|
+
|
41
102
|
## Code of Conduct
|
42
103
|
|
43
|
-
Everyone interacting in the
|
104
|
+
Everyone interacting in the GLFW project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ForeverZer0/glfw/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
require "
|
2
|
+
require "rake/testtask"
|
3
3
|
|
4
|
-
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
8
|
+
end
|
5
9
|
|
6
|
-
|
10
|
+
require "rake/extensiontask"
|
11
|
+
|
12
|
+
task :build => :compile
|
13
|
+
|
14
|
+
Rake::ExtensionTask.new("glfw") do |ext|
|
15
|
+
ext.lib_dir = "lib/glfw"
|
16
|
+
end
|
17
|
+
|
18
|
+
task :default => [:clobber, :compile, :test]
|
data/ext/glfw/common.h
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
#ifndef GLFW_RB_COMMON_H
|
4
|
+
#define GLFW_RB_COMMON_H 1
|
5
|
+
|
6
|
+
#include "glfw3.h"
|
7
|
+
#include "ruby.h"
|
8
|
+
|
9
|
+
#define STR2SYM(str) ID2SYM(rb_intern(str))
|
10
|
+
|
11
|
+
#define INT2BOOL(i) (i ? Qtrue : Qfalse)
|
12
|
+
|
13
|
+
#define WINDOW() \
|
14
|
+
GLFWwindow *w; \
|
15
|
+
Data_Get_Struct(self, GLFWwindow, w)
|
16
|
+
|
17
|
+
enum GLFW_RB_CALLBACK_TYPE {
|
18
|
+
GLFW_RB_MOVED,
|
19
|
+
GLFW_RB_RESIZED,
|
20
|
+
GLFW_RB_FRAMEBUFFER_RESIZED,
|
21
|
+
GLFW_RB_CLOSING,
|
22
|
+
GLFW_RB_REFRESHED,
|
23
|
+
GLFW_RB_FOCUS_CHANGED,
|
24
|
+
GLFW_RB_MINIMIZE_CHANGED,
|
25
|
+
GLFW_RB_MOUSE_MOVE,
|
26
|
+
GLFW_RB_MOUSE_SCROLL,
|
27
|
+
GLFW_RB_MOUSE_BUTTON,
|
28
|
+
GLFW_RB_MOUSE_ENTER,
|
29
|
+
GLFW_RB_KEY,
|
30
|
+
GLFW_RB_CHAR,
|
31
|
+
GLFW_RB_CHAR_MODS,
|
32
|
+
GLFW_RB_FILE_DROP,
|
33
|
+
GLFW_RB_MONITOR,
|
34
|
+
GLFW_RB_JOYSTICK
|
35
|
+
} GLFW_RB_CALLBACK_TYPE;
|
36
|
+
|
37
|
+
extern VALUE rb_mGLFW;
|
38
|
+
extern VALUE rb_eGLFWError;
|
39
|
+
extern VALUE rb_cGLFWwindow;
|
40
|
+
extern VALUE rb_cGLFWmonitor;
|
41
|
+
extern VALUE rb_cGLFWvidmode;
|
42
|
+
extern VALUE rb_cGLFWimage;
|
43
|
+
extern VALUE rb_cGLFWcursor;
|
44
|
+
extern VALUE rb_cGLFWvulkan;
|
45
|
+
|
46
|
+
#endif /* GLFW_RB_COMMON_H */
|
data/ext/glfw/cursor.c
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
#include "cursor.h"
|
3
|
+
|
4
|
+
VALUE rb_cGLFWcursor;
|
5
|
+
|
6
|
+
void Init_glfw_cursor(VALUE module) {
|
7
|
+
rb_cGLFWcursor = rb_define_class_under(module, "Cursor", rb_cObject);
|
8
|
+
rb_define_alloc_func(rb_cGLFWcursor, rb_glfw_cursor_alloc);
|
9
|
+
|
10
|
+
rb_define_method(rb_cGLFWcursor, "initialize", rb_glfw_cursor_initialize, 3);
|
11
|
+
rb_define_method(rb_cGLFWcursor, "destroy", rb_glfw_cursor_destroy, 0);
|
12
|
+
|
13
|
+
rb_define_alias(rb_cGLFWcursor, "dispose", "destroy");
|
14
|
+
|
15
|
+
rb_define_singleton_method(rb_cGLFWcursor, "create", rb_glfw_cursor_standard, 1);
|
16
|
+
}
|
17
|
+
|
18
|
+
static VALUE rb_glfw_cursor_alloc(VALUE klass) {
|
19
|
+
GLFWcursor *c = ruby_xmalloc(SIZEOF_INTPTR_T);
|
20
|
+
memset(c, 0, SIZEOF_INTPTR_T);
|
21
|
+
return Data_Wrap_Struct(klass, NULL, RUBY_DEFAULT_FREE, c);
|
22
|
+
}
|
23
|
+
|
24
|
+
VALUE rb_glfw_cursor_initialize(VALUE self, VALUE image, VALUE xhot, VALUE yhot) {
|
25
|
+
GLFWimage *img;
|
26
|
+
Data_Get_Struct(image, GLFWimage, img);
|
27
|
+
RDATA(self)->data = glfwCreateCursor(img, NUM2INT(xhot), NUM2INT(yhot));
|
28
|
+
return Qnil;
|
29
|
+
}
|
30
|
+
|
31
|
+
VALUE rb_glfw_cursor_standard(VALUE klass, VALUE shape) {
|
32
|
+
GLFWcursor *cursor = glfwCreateStandardCursor(NUM2INT(shape));
|
33
|
+
return Data_Wrap_Struct(klass, NULL, RUBY_DEFAULT_FREE, cursor);
|
34
|
+
}
|
35
|
+
|
36
|
+
VALUE rb_glfw_cursor_destroy(VALUE self) {
|
37
|
+
GLFWcursor *cursor;
|
38
|
+
Data_Get_Struct(self, GLFWcursor, cursor);
|
39
|
+
|
40
|
+
glfwDestroyCursor(cursor);
|
41
|
+
return Qnil;
|
42
|
+
}
|
data/ext/glfw/cursor.h
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
#ifndef GLFW_RB_CURSOR_H
|
3
|
+
#define GLFW_RB_CURSOR_H 1
|
4
|
+
|
5
|
+
#include "common.h"
|
6
|
+
#include "image.h"
|
7
|
+
|
8
|
+
void Init_glfw_cursor(VALUE module);
|
9
|
+
static VALUE rb_glfw_cursor_alloc(VALUE klass);
|
10
|
+
VALUE rb_glfw_cursor_initialize(VALUE self, VALUE image, VALUE xhot, VALUE yhot);
|
11
|
+
VALUE rb_glfw_cursor_standard(VALUE klass, VALUE shape);
|
12
|
+
VALUE rb_glfw_cursor_destroy(VALUE self);
|
13
|
+
|
14
|
+
#endif /* GLFW_RB_CURSOR_H */
|
data/ext/glfw/extconf.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "mkmf"
|
2
|
+
|
3
|
+
LIBDIR = RbConfig::CONFIG['libdir']
|
4
|
+
INCLUDEDIR = RbConfig::CONFIG['includedir']
|
5
|
+
|
6
|
+
HEADER_DIRS = [INCLUDEDIR, File.dirname(__FILE__)]
|
7
|
+
|
8
|
+
# TODO: x86 or x86-64 (ming)
|
9
|
+
|
10
|
+
|
11
|
+
# setup constant that is equal to that of the file path that holds that static libraries that will need to be compiled against
|
12
|
+
LIB_DIRS = [LIBDIR, File.expand_path(File.join(File.dirname(__FILE__), "lib"))]
|
13
|
+
|
14
|
+
# array of all libraries that the C extension should be compiled against
|
15
|
+
libs = ['-lglfw3 -lgdi32 -lopengl32']
|
16
|
+
|
17
|
+
dir_config('glfw', HEADER_DIRS, LIB_DIRS)
|
18
|
+
|
19
|
+
# iterate though the libs array, and append them to the $LOCAL_LIBS array used for the makefile creation
|
20
|
+
libs.each do |lib|
|
21
|
+
$LOCAL_LIBS << "#{lib} "
|
22
|
+
end
|
23
|
+
|
24
|
+
create_makefile("glfw/glfw")
|
data/ext/glfw/glfw.c
ADDED
@@ -0,0 +1,438 @@
|
|
1
|
+
#include "glfw.h"
|
2
|
+
|
3
|
+
VALUE rb_mGLFW;
|
4
|
+
VALUE rb_eGLFWError;
|
5
|
+
|
6
|
+
// TODO: Window class, internal loop timing to reduce overhead
|
7
|
+
|
8
|
+
void Init_glfw(void) {
|
9
|
+
|
10
|
+
glfwSetErrorCallback(rb_glfw_error_callback);
|
11
|
+
rb_mGLFW = rb_define_module("GLFW");
|
12
|
+
rb_eGLFWError = rb_define_class_under(rb_mGLFW, "GLFWError", rb_eStandardError);
|
13
|
+
|
14
|
+
Init_glfw_window(rb_mGLFW);
|
15
|
+
Init_glfw_monitor(rb_mGLFW);
|
16
|
+
Init_glfw_vidmode(rb_mGLFW);
|
17
|
+
Init_glfw_image(rb_mGLFW);
|
18
|
+
Init_glfw_cursor(rb_mGLFW);
|
19
|
+
Init_glfw_vulkan(rb_mGLFW);
|
20
|
+
|
21
|
+
// GLFW Module Functions
|
22
|
+
rb_define_singleton_method(rb_mGLFW, "init", rb_glfw_init, 0);
|
23
|
+
rb_define_singleton_method(rb_mGLFW, "terminate", rb_glfw_terminate, 0);
|
24
|
+
rb_define_singleton_method(rb_mGLFW, "poll_events", rb_glfw_poll_events, 0);
|
25
|
+
rb_define_singleton_method(rb_mGLFW, "wait_events", rb_glfw_wait_events, 0);
|
26
|
+
rb_define_singleton_method(rb_mGLFW, "post_empty_event", rb_glfw_post_empty, 0);
|
27
|
+
rb_define_singleton_method(rb_mGLFW, "swap_interval", rb_glfw_swap_interval, 1);
|
28
|
+
rb_define_singleton_method(rb_mGLFW, "current_context", rb_glfw_current_context, 0);
|
29
|
+
rb_define_singleton_method(rb_mGLFW, "supported?", rb_glfw_supported_p, 1);
|
30
|
+
rb_define_singleton_method(rb_mGLFW, "time", rb_glfw_get_time, 0);
|
31
|
+
rb_define_singleton_method(rb_mGLFW, "time=", rb_glfw_set_time, 1);
|
32
|
+
rb_define_singleton_method(rb_mGLFW, "monitors", rb_glfw_monitors, 0);
|
33
|
+
rb_define_singleton_method(rb_mGLFW, "load_default_hints", rb_glfw_load_default_hints, 0);
|
34
|
+
rb_define_singleton_method(rb_mGLFW, "hint", rb_glfw_window_hint, 2);
|
35
|
+
rb_define_singleton_method(rb_mGLFW, "key_name", rb_glfw_key_name, 2);
|
36
|
+
rb_define_singleton_method(rb_mGLFW, "timer_frequency", rb_glfw_timer_frequency, 0);
|
37
|
+
rb_define_singleton_method(rb_mGLFW, "timer_value", rb_glfw_timer_value, 0);
|
38
|
+
rb_define_singleton_method(rb_mGLFW, "monitor_changed", rb_glfw_monitor_changed, 2);
|
39
|
+
rb_define_singleton_method(rb_mGLFW, "joystick_changed", rb_glfw_joystick_changed, 2);
|
40
|
+
rb_define_singleton_method(rb_mGLFW, "proc_address", rb_glfw_proc_address, 1);
|
41
|
+
|
42
|
+
// API Version
|
43
|
+
rb_define_const(rb_mGLFW, "API_VERSION", rb_sprintf("%d.%d.%d",
|
44
|
+
INT2NUM(GLFW_VERSION_MAJOR), INT2NUM(GLFW_VERSION_MINOR), INT2NUM(GLFW_VERSION_REVISION)));
|
45
|
+
rb_define_const(rb_mGLFW, "API_VERSION_MAJOR", INT2NUM(GLFW_VERSION_MAJOR));
|
46
|
+
rb_define_const(rb_mGLFW, "API_VERSION_MINOR", INT2NUM(GLFW_VERSION_MINOR));
|
47
|
+
rb_define_const(rb_mGLFW, "API_VERSION_REVISION", INT2NUM(GLFW_VERSION_REVISION));
|
48
|
+
rb_define_const(rb_mGLFW, "API_DESCRIPTION", rb_str_new_cstr(glfwGetVersionString()));
|
49
|
+
// Callback Types
|
50
|
+
rb_define_const(rb_mGLFW, "CB_MOVED", INT2NUM(GLFW_RB_MOVED));
|
51
|
+
rb_define_const(rb_mGLFW, "CB_RESIZED", INT2NUM(GLFW_RB_RESIZED));
|
52
|
+
rb_define_const(rb_mGLFW, "CB_FRAMEBUFFER_RESIZED", INT2NUM(GLFW_RB_FRAMEBUFFER_RESIZED));
|
53
|
+
rb_define_const(rb_mGLFW, "CB_CLOSING", INT2NUM(GLFW_RB_CLOSING));
|
54
|
+
rb_define_const(rb_mGLFW, "CB_REFRESHED", INT2NUM(GLFW_RB_REFRESHED));
|
55
|
+
rb_define_const(rb_mGLFW, "CB_FOCUS_CHANGED", INT2NUM(GLFW_RB_FOCUS_CHANGED));
|
56
|
+
rb_define_const(rb_mGLFW, "CB_MINIMIZE_CHANGED", INT2NUM(GLFW_RB_MINIMIZE_CHANGED));
|
57
|
+
rb_define_const(rb_mGLFW, "CB_MOUSE_MOVE", INT2NUM(GLFW_RB_MOUSE_MOVE));
|
58
|
+
rb_define_const(rb_mGLFW, "CB_MOUSE_SCROLL", INT2NUM(GLFW_RB_MOUSE_SCROLL));
|
59
|
+
rb_define_const(rb_mGLFW, "CB_MOUSE_BUTTON", INT2NUM(GLFW_RB_MOUSE_BUTTON));
|
60
|
+
rb_define_const(rb_mGLFW, "CB_MOUSE_ENTER", INT2NUM(GLFW_RB_MOUSE_ENTER));
|
61
|
+
rb_define_const(rb_mGLFW, "CB_KEY", INT2NUM(GLFW_RB_KEY));
|
62
|
+
rb_define_const(rb_mGLFW, "CB_CHAR", INT2NUM(GLFW_RB_CHAR));
|
63
|
+
rb_define_const(rb_mGLFW, "CB_CHAR_MODS", INT2NUM(GLFW_RB_CHAR_MODS));
|
64
|
+
rb_define_const(rb_mGLFW, "CB_FILE_DROP", INT2NUM(GLFW_RB_FILE_DROP));
|
65
|
+
rb_define_const(rb_mGLFW, "CB_MONITOR", INT2NUM(GLFW_RB_MONITOR));
|
66
|
+
rb_define_const(rb_mGLFW, "CB_JOYSTICK", INT2NUM(GLFW_RB_JOYSTICK));
|
67
|
+
// Input Modes
|
68
|
+
rb_define_const(rb_mGLFW, "INPUT_PRESS", INT2NUM(GLFW_PRESS));
|
69
|
+
rb_define_const(rb_mGLFW, "INPUT_RELEASE", INT2NUM(GLFW_RELEASE));
|
70
|
+
rb_define_const(rb_mGLFW, "INPUT_REPEAT", INT2NUM(GLFW_REPEAT));
|
71
|
+
// Hints
|
72
|
+
rb_define_const(rb_mGLFW, "HINT_RESIZABLE", INT2NUM(GLFW_RESIZABLE));
|
73
|
+
rb_define_const(rb_mGLFW, "HINT_VISIBLE", INT2NUM(GLFW_VISIBLE));
|
74
|
+
rb_define_const(rb_mGLFW, "HINT_DECORATED", INT2NUM(GLFW_DECORATED));
|
75
|
+
rb_define_const(rb_mGLFW, "HINT_FOCUSED", INT2NUM(GLFW_FOCUSED));
|
76
|
+
rb_define_const(rb_mGLFW, "HINT_AUTO_ICONIFY", INT2NUM(GLFW_AUTO_ICONIFY));
|
77
|
+
rb_define_const(rb_mGLFW, "HINT_FLOATING", INT2NUM(GLFW_FLOATING));
|
78
|
+
rb_define_const(rb_mGLFW, "HINT_MAXIMIZED", INT2NUM(GLFW_MAXIMIZED));
|
79
|
+
rb_define_const(rb_mGLFW, "HINT_RED_BITS", INT2NUM(GLFW_RED_BITS));
|
80
|
+
rb_define_const(rb_mGLFW, "HINT_GREEN_BITS", INT2NUM(GLFW_GREEN_BITS));
|
81
|
+
rb_define_const(rb_mGLFW, "HINT_BLUE_BITS", INT2NUM(GLFW_BLUE_BITS));
|
82
|
+
rb_define_const(rb_mGLFW, "HINT_ALPHA_BITS", INT2NUM(GLFW_ALPHA_BITS));
|
83
|
+
rb_define_const(rb_mGLFW, "HINT_DEPTH_BITS", INT2NUM(GLFW_DEPTH_BITS));
|
84
|
+
rb_define_const(rb_mGLFW, "HINT_STENCIL_BITS", INT2NUM(GLFW_STENCIL_BITS));
|
85
|
+
rb_define_const(rb_mGLFW, "HINT_ACCUM_RED_BITS", INT2NUM(GLFW_ACCUM_RED_BITS));
|
86
|
+
rb_define_const(rb_mGLFW, "HINT_ACCUM_GREEN_BITS", INT2NUM(GLFW_ACCUM_GREEN_BITS));
|
87
|
+
rb_define_const(rb_mGLFW, "HINT_ACCUM_BLUE_BITS", INT2NUM(GLFW_ACCUM_BLUE_BITS));
|
88
|
+
rb_define_const(rb_mGLFW, "HINT_ACCUM_ALPHA_BITS", INT2NUM(GLFW_ACCUM_ALPHA_BITS));
|
89
|
+
rb_define_const(rb_mGLFW, "HINT_AUX_BUFFERS", INT2NUM(GLFW_AUX_BUFFERS));
|
90
|
+
rb_define_const(rb_mGLFW, "HINT_SAMPLES", INT2NUM(GLFW_SAMPLES));
|
91
|
+
rb_define_const(rb_mGLFW, "HINT_REFRESH_RATE", INT2NUM(GLFW_REFRESH_RATE));
|
92
|
+
rb_define_const(rb_mGLFW, "HINT_STEREO", INT2NUM(GLFW_STEREO));
|
93
|
+
rb_define_const(rb_mGLFW, "HINT_SRGB_CAPABLE", INT2NUM(GLFW_SRGB_CAPABLE));
|
94
|
+
rb_define_const(rb_mGLFW, "HINT_DOUBLEBUFFER", INT2NUM(GLFW_DOUBLEBUFFER));
|
95
|
+
rb_define_const(rb_mGLFW, "HINT_CLIENT_API", INT2NUM(GLFW_CLIENT_API));
|
96
|
+
rb_define_const(rb_mGLFW, "HINT_CONTEXT_CREATION_API", INT2NUM(GLFW_CONTEXT_CREATION_API));
|
97
|
+
rb_define_const(rb_mGLFW, "HINT_CONTEXT_VERSION_MAJOR", INT2NUM(GLFW_CONTEXT_VERSION_MAJOR));
|
98
|
+
rb_define_const(rb_mGLFW, "HINT_CONTEXT_VERSION_MINOR", INT2NUM(GLFW_CONTEXT_VERSION_MINOR));
|
99
|
+
rb_define_const(rb_mGLFW, "HINT_CONTEXT_ROBUSTNESS", INT2NUM(GLFW_CONTEXT_ROBUSTNESS));
|
100
|
+
rb_define_const(rb_mGLFW, "HINT_CONTEXT_RELEASE_BEHAVIOR", INT2NUM(GLFW_CONTEXT_RELEASE_BEHAVIOR));
|
101
|
+
rb_define_const(rb_mGLFW, "HINT_OPENGL_FORWARD_COMPAT", INT2NUM(GLFW_OPENGL_FORWARD_COMPAT));
|
102
|
+
rb_define_const(rb_mGLFW, "HINT_OPENGL_DEBUG_CONTEXT", INT2NUM(GLFW_OPENGL_DEBUG_CONTEXT));
|
103
|
+
rb_define_const(rb_mGLFW, "HINT_OPENGL_PROFILE", INT2NUM(GLFW_OPENGL_PROFILE));
|
104
|
+
// API
|
105
|
+
rb_define_const(rb_mGLFW, "API_OPENGL", INT2NUM(GLFW_OPENGL_API));
|
106
|
+
rb_define_const(rb_mGLFW, "API_OPENGL_ES", INT2NUM(GLFW_OPENGL_ES_API));
|
107
|
+
rb_define_const(rb_mGLFW, "API_NONE", INT2NUM(GLFW_NO_API));
|
108
|
+
// Context
|
109
|
+
rb_define_const(rb_mGLFW, "CONTEXT_NATIVE", INT2NUM(GLFW_NATIVE_CONTEXT_API));
|
110
|
+
rb_define_const(rb_mGLFW, "CONTEXT_EGL", INT2NUM(GLFW_EGL_CONTEXT_API));
|
111
|
+
// Robustness
|
112
|
+
rb_define_const(rb_mGLFW, "ROBUSTNESS_NONE", INT2NUM(GLFW_NO_ROBUSTNESS));
|
113
|
+
rb_define_const(rb_mGLFW, "ROBUSTNESS_NO_NOTIFICATION", INT2NUM(GLFW_NO_RESET_NOTIFICATION));
|
114
|
+
rb_define_const(rb_mGLFW, "ROBUSTNESS_LOSE_CONTEXT", INT2NUM(GLFW_LOSE_CONTEXT_ON_RESET));
|
115
|
+
// Release Behavior
|
116
|
+
rb_define_const(rb_mGLFW, "RELEASE_BEHAVIOR_ANY", INT2NUM(GLFW_ANY_RELEASE_BEHAVIOR));
|
117
|
+
rb_define_const(rb_mGLFW, "RELEASE_BEHAVIOR_FLUSH", INT2NUM(GLFW_RELEASE_BEHAVIOR_FLUSH));
|
118
|
+
rb_define_const(rb_mGLFW, "RELEASE_BEHAVIOR_NONE", INT2NUM(GLFW_RELEASE_BEHAVIOR_NONE));
|
119
|
+
// OpenGL Profile
|
120
|
+
rb_define_const(rb_mGLFW, "PROFILE_ANY", INT2NUM(GLFW_OPENGL_ANY_PROFILE));
|
121
|
+
rb_define_const(rb_mGLFW, "PROFILE_COMPAT", INT2NUM(GLFW_OPENGL_COMPAT_PROFILE));
|
122
|
+
rb_define_const(rb_mGLFW, "PROFILE_CORE", INT2NUM(GLFW_OPENGL_CORE_PROFILE));
|
123
|
+
|
124
|
+
// Keys
|
125
|
+
rb_define_const(rb_mGLFW, "KEY_UNKNOWN", INT2NUM(GLFW_KEY_UNKNOWN));
|
126
|
+
rb_define_const(rb_mGLFW, "KEY_SPACE", INT2NUM(GLFW_KEY_SPACE));
|
127
|
+
rb_define_const(rb_mGLFW, "KEY_APOSTROPHE", INT2NUM(GLFW_KEY_APOSTROPHE));
|
128
|
+
rb_define_const(rb_mGLFW, "KEY_COMMA", INT2NUM(GLFW_KEY_COMMA));
|
129
|
+
rb_define_const(rb_mGLFW, "KEY_MINUS", INT2NUM(GLFW_KEY_MINUS));
|
130
|
+
rb_define_const(rb_mGLFW, "KEY_PERIOD", INT2NUM(GLFW_KEY_PERIOD));
|
131
|
+
rb_define_const(rb_mGLFW, "KEY_SLASH", INT2NUM(GLFW_KEY_SLASH));
|
132
|
+
rb_define_const(rb_mGLFW, "KEY_0", INT2NUM(GLFW_KEY_0));
|
133
|
+
rb_define_const(rb_mGLFW, "KEY_1", INT2NUM(GLFW_KEY_1));
|
134
|
+
rb_define_const(rb_mGLFW, "KEY_2", INT2NUM(GLFW_KEY_2));
|
135
|
+
rb_define_const(rb_mGLFW, "KEY_3", INT2NUM(GLFW_KEY_3));
|
136
|
+
rb_define_const(rb_mGLFW, "KEY_4", INT2NUM(GLFW_KEY_4));
|
137
|
+
rb_define_const(rb_mGLFW, "KEY_5", INT2NUM(GLFW_KEY_5));
|
138
|
+
rb_define_const(rb_mGLFW, "KEY_6", INT2NUM(GLFW_KEY_6));
|
139
|
+
rb_define_const(rb_mGLFW, "KEY_7", INT2NUM(GLFW_KEY_7));
|
140
|
+
rb_define_const(rb_mGLFW, "KEY_8", INT2NUM(GLFW_KEY_8));
|
141
|
+
rb_define_const(rb_mGLFW, "KEY_9", INT2NUM(GLFW_KEY_9));
|
142
|
+
rb_define_const(rb_mGLFW, "KEY_SEMICOLON", INT2NUM(GLFW_KEY_SEMICOLON));
|
143
|
+
rb_define_const(rb_mGLFW, "KEY_EQUAL", INT2NUM(GLFW_KEY_EQUAL));
|
144
|
+
rb_define_const(rb_mGLFW, "KEY_A", INT2NUM(GLFW_KEY_A));
|
145
|
+
rb_define_const(rb_mGLFW, "KEY_B", INT2NUM(GLFW_KEY_B));
|
146
|
+
rb_define_const(rb_mGLFW, "KEY_C", INT2NUM(GLFW_KEY_C));
|
147
|
+
rb_define_const(rb_mGLFW, "KEY_D", INT2NUM(GLFW_KEY_D));
|
148
|
+
rb_define_const(rb_mGLFW, "KEY_E", INT2NUM(GLFW_KEY_E));
|
149
|
+
rb_define_const(rb_mGLFW, "KEY_F", INT2NUM(GLFW_KEY_F));
|
150
|
+
rb_define_const(rb_mGLFW, "KEY_G", INT2NUM(GLFW_KEY_G));
|
151
|
+
rb_define_const(rb_mGLFW, "KEY_H", INT2NUM(GLFW_KEY_H));
|
152
|
+
rb_define_const(rb_mGLFW, "KEY_I", INT2NUM(GLFW_KEY_I));
|
153
|
+
rb_define_const(rb_mGLFW, "KEY_J", INT2NUM(GLFW_KEY_J));
|
154
|
+
rb_define_const(rb_mGLFW, "KEY_K", INT2NUM(GLFW_KEY_K));
|
155
|
+
rb_define_const(rb_mGLFW, "KEY_L", INT2NUM(GLFW_KEY_L));
|
156
|
+
rb_define_const(rb_mGLFW, "KEY_M", INT2NUM(GLFW_KEY_M));
|
157
|
+
rb_define_const(rb_mGLFW, "KEY_N", INT2NUM(GLFW_KEY_N));
|
158
|
+
rb_define_const(rb_mGLFW, "KEY_O", INT2NUM(GLFW_KEY_O));
|
159
|
+
rb_define_const(rb_mGLFW, "KEY_P", INT2NUM(GLFW_KEY_P));
|
160
|
+
rb_define_const(rb_mGLFW, "KEY_Q", INT2NUM(GLFW_KEY_Q));
|
161
|
+
rb_define_const(rb_mGLFW, "KEY_R", INT2NUM(GLFW_KEY_R));
|
162
|
+
rb_define_const(rb_mGLFW, "KEY_S", INT2NUM(GLFW_KEY_S));
|
163
|
+
rb_define_const(rb_mGLFW, "KEY_T", INT2NUM(GLFW_KEY_T));
|
164
|
+
rb_define_const(rb_mGLFW, "KEY_U", INT2NUM(GLFW_KEY_U));
|
165
|
+
rb_define_const(rb_mGLFW, "KEY_V", INT2NUM(GLFW_KEY_V));
|
166
|
+
rb_define_const(rb_mGLFW, "KEY_W", INT2NUM(GLFW_KEY_W));
|
167
|
+
rb_define_const(rb_mGLFW, "KEY_X", INT2NUM(GLFW_KEY_X));
|
168
|
+
rb_define_const(rb_mGLFW, "KEY_Y", INT2NUM(GLFW_KEY_Y));
|
169
|
+
rb_define_const(rb_mGLFW, "KEY_Z", INT2NUM(GLFW_KEY_Z));
|
170
|
+
rb_define_const(rb_mGLFW, "KEY_LEFT_BRACKET", INT2NUM(GLFW_KEY_LEFT_BRACKET));
|
171
|
+
rb_define_const(rb_mGLFW, "KEY_BACKSLASH", INT2NUM(GLFW_KEY_BACKSLASH));
|
172
|
+
rb_define_const(rb_mGLFW, "KEY_RIGHT_BRACKET", INT2NUM(GLFW_KEY_RIGHT_BRACKET));
|
173
|
+
rb_define_const(rb_mGLFW, "KEY_GRAVE_ACCENT", INT2NUM(GLFW_KEY_GRAVE_ACCENT));
|
174
|
+
rb_define_const(rb_mGLFW, "KEY_WORLD_1", INT2NUM(GLFW_KEY_WORLD_1));
|
175
|
+
rb_define_const(rb_mGLFW, "KEY_WORLD_2", INT2NUM(GLFW_KEY_WORLD_2));
|
176
|
+
rb_define_const(rb_mGLFW, "KEY_ESCAPE", INT2NUM(GLFW_KEY_ESCAPE));
|
177
|
+
rb_define_const(rb_mGLFW, "KEY_ENTER", INT2NUM(GLFW_KEY_ENTER));
|
178
|
+
rb_define_const(rb_mGLFW, "KEY_TAB", INT2NUM(GLFW_KEY_TAB));
|
179
|
+
rb_define_const(rb_mGLFW, "KEY_BACKSPACE", INT2NUM(GLFW_KEY_BACKSPACE));
|
180
|
+
rb_define_const(rb_mGLFW, "KEY_INSERT", INT2NUM(GLFW_KEY_INSERT));
|
181
|
+
rb_define_const(rb_mGLFW, "KEY_DELETE", INT2NUM(GLFW_KEY_DELETE));
|
182
|
+
rb_define_const(rb_mGLFW, "KEY_RIGHT", INT2NUM(GLFW_KEY_RIGHT));
|
183
|
+
rb_define_const(rb_mGLFW, "KEY_LEFT", INT2NUM(GLFW_KEY_LEFT));
|
184
|
+
rb_define_const(rb_mGLFW, "KEY_DOWN", INT2NUM(GLFW_KEY_DOWN));
|
185
|
+
rb_define_const(rb_mGLFW, "KEY_UP", INT2NUM(GLFW_KEY_UP));
|
186
|
+
rb_define_const(rb_mGLFW, "KEY_PAGE_UP", INT2NUM(GLFW_KEY_PAGE_UP));
|
187
|
+
rb_define_const(rb_mGLFW, "KEY_PAGE_DOWN", INT2NUM(GLFW_KEY_PAGE_DOWN));
|
188
|
+
rb_define_const(rb_mGLFW, "KEY_HOME", INT2NUM(GLFW_KEY_HOME));
|
189
|
+
rb_define_const(rb_mGLFW, "KEY_END", INT2NUM(GLFW_KEY_END));
|
190
|
+
rb_define_const(rb_mGLFW, "KEY_CAPS_LOCK", INT2NUM(GLFW_KEY_CAPS_LOCK));
|
191
|
+
rb_define_const(rb_mGLFW, "KEY_SCROLL_LOCK", INT2NUM(GLFW_KEY_SCROLL_LOCK));
|
192
|
+
rb_define_const(rb_mGLFW, "KEY_NUM_LOCK", INT2NUM(GLFW_KEY_NUM_LOCK));
|
193
|
+
rb_define_const(rb_mGLFW, "KEY_PRINT_SCREEN", INT2NUM(GLFW_KEY_PRINT_SCREEN));
|
194
|
+
rb_define_const(rb_mGLFW, "KEY_PAUSE", INT2NUM(GLFW_KEY_PAUSE));
|
195
|
+
rb_define_const(rb_mGLFW, "KEY_F1", INT2NUM(GLFW_KEY_F1));
|
196
|
+
rb_define_const(rb_mGLFW, "KEY_F2", INT2NUM(GLFW_KEY_F2));
|
197
|
+
rb_define_const(rb_mGLFW, "KEY_F3", INT2NUM(GLFW_KEY_F3));
|
198
|
+
rb_define_const(rb_mGLFW, "KEY_F4", INT2NUM(GLFW_KEY_F4));
|
199
|
+
rb_define_const(rb_mGLFW, "KEY_F5", INT2NUM(GLFW_KEY_F5));
|
200
|
+
rb_define_const(rb_mGLFW, "KEY_F6", INT2NUM(GLFW_KEY_F6));
|
201
|
+
rb_define_const(rb_mGLFW, "KEY_F7", INT2NUM(GLFW_KEY_F7));
|
202
|
+
rb_define_const(rb_mGLFW, "KEY_F8", INT2NUM(GLFW_KEY_F8));
|
203
|
+
rb_define_const(rb_mGLFW, "KEY_F9", INT2NUM(GLFW_KEY_F9));
|
204
|
+
rb_define_const(rb_mGLFW, "KEY_F10", INT2NUM(GLFW_KEY_F10));
|
205
|
+
rb_define_const(rb_mGLFW, "KEY_F11", INT2NUM(GLFW_KEY_F11));
|
206
|
+
rb_define_const(rb_mGLFW, "KEY_F12", INT2NUM(GLFW_KEY_F12));
|
207
|
+
rb_define_const(rb_mGLFW, "KEY_F13", INT2NUM(GLFW_KEY_F13));
|
208
|
+
rb_define_const(rb_mGLFW, "KEY_F14", INT2NUM(GLFW_KEY_F14));
|
209
|
+
rb_define_const(rb_mGLFW, "KEY_F15", INT2NUM(GLFW_KEY_F15));
|
210
|
+
rb_define_const(rb_mGLFW, "KEY_F16", INT2NUM(GLFW_KEY_F16));
|
211
|
+
rb_define_const(rb_mGLFW, "KEY_F17", INT2NUM(GLFW_KEY_F17));
|
212
|
+
rb_define_const(rb_mGLFW, "KEY_F18", INT2NUM(GLFW_KEY_F18));
|
213
|
+
rb_define_const(rb_mGLFW, "KEY_F19", INT2NUM(GLFW_KEY_F19));
|
214
|
+
rb_define_const(rb_mGLFW, "KEY_F20", INT2NUM(GLFW_KEY_F20));
|
215
|
+
rb_define_const(rb_mGLFW, "KEY_F21", INT2NUM(GLFW_KEY_F21));
|
216
|
+
rb_define_const(rb_mGLFW, "KEY_F22", INT2NUM(GLFW_KEY_F22));
|
217
|
+
rb_define_const(rb_mGLFW, "KEY_F23", INT2NUM(GLFW_KEY_F23));
|
218
|
+
rb_define_const(rb_mGLFW, "KEY_F24", INT2NUM(GLFW_KEY_F24));
|
219
|
+
rb_define_const(rb_mGLFW, "KEY_F25", INT2NUM(GLFW_KEY_F25));
|
220
|
+
rb_define_const(rb_mGLFW, "KEY_KP_0", INT2NUM(GLFW_KEY_KP_0));
|
221
|
+
rb_define_const(rb_mGLFW, "KEY_KP_1", INT2NUM(GLFW_KEY_KP_1));
|
222
|
+
rb_define_const(rb_mGLFW, "KEY_KP_2", INT2NUM(GLFW_KEY_KP_2));
|
223
|
+
rb_define_const(rb_mGLFW, "KEY_KP_3", INT2NUM(GLFW_KEY_KP_3));
|
224
|
+
rb_define_const(rb_mGLFW, "KEY_KP_4", INT2NUM(GLFW_KEY_KP_4));
|
225
|
+
rb_define_const(rb_mGLFW, "KEY_KP_5", INT2NUM(GLFW_KEY_KP_5));
|
226
|
+
rb_define_const(rb_mGLFW, "KEY_KP_6", INT2NUM(GLFW_KEY_KP_6));
|
227
|
+
rb_define_const(rb_mGLFW, "KEY_KP_7", INT2NUM(GLFW_KEY_KP_7));
|
228
|
+
rb_define_const(rb_mGLFW, "KEY_KP_8", INT2NUM(GLFW_KEY_KP_8));
|
229
|
+
rb_define_const(rb_mGLFW, "KEY_KP_9", INT2NUM(GLFW_KEY_KP_9));
|
230
|
+
rb_define_const(rb_mGLFW, "KEY_KP_DECIMAL", INT2NUM(GLFW_KEY_KP_DECIMAL));
|
231
|
+
rb_define_const(rb_mGLFW, "KEY_KP_DIVIDE", INT2NUM(GLFW_KEY_KP_DIVIDE));
|
232
|
+
rb_define_const(rb_mGLFW, "KEY_KP_MULTIPLY", INT2NUM(GLFW_KEY_KP_MULTIPLY));
|
233
|
+
rb_define_const(rb_mGLFW, "KEY_KP_SUBTRACT", INT2NUM(GLFW_KEY_KP_SUBTRACT));
|
234
|
+
rb_define_const(rb_mGLFW, "KEY_KP_ADD", INT2NUM(GLFW_KEY_KP_ADD));
|
235
|
+
rb_define_const(rb_mGLFW, "KEY_KP_ENTER", INT2NUM(GLFW_KEY_KP_ENTER));
|
236
|
+
rb_define_const(rb_mGLFW, "KEY_KP_EQUAL", INT2NUM(GLFW_KEY_KP_EQUAL));
|
237
|
+
rb_define_const(rb_mGLFW, "KEY_LEFT_SHIFT", INT2NUM(GLFW_KEY_LEFT_SHIFT));
|
238
|
+
rb_define_const(rb_mGLFW, "KEY_LEFT_CONTROL", INT2NUM(GLFW_KEY_LEFT_CONTROL));
|
239
|
+
rb_define_const(rb_mGLFW, "KEY_LEFT_ALT", INT2NUM(GLFW_KEY_LEFT_ALT));
|
240
|
+
rb_define_const(rb_mGLFW, "KEY_LEFT_SUPER", INT2NUM(GLFW_KEY_LEFT_SUPER));
|
241
|
+
rb_define_const(rb_mGLFW, "KEY_RIGHT_SHIFT", INT2NUM(GLFW_KEY_RIGHT_SHIFT));
|
242
|
+
rb_define_const(rb_mGLFW, "KEY_RIGHT_CONTROL", INT2NUM(GLFW_KEY_RIGHT_CONTROL));
|
243
|
+
rb_define_const(rb_mGLFW, "KEY_RIGHT_ALT", INT2NUM(GLFW_KEY_RIGHT_ALT));
|
244
|
+
rb_define_const(rb_mGLFW, "KEY_RIGHT_SUPER", INT2NUM(GLFW_KEY_RIGHT_SUPER));
|
245
|
+
rb_define_const(rb_mGLFW, "KEY_MENU", INT2NUM(GLFW_KEY_MENU));
|
246
|
+
// Modifier Keys
|
247
|
+
rb_define_const(rb_mGLFW, "MOD_CONTROL", INT2NUM(GLFW_MOD_CONTROL));
|
248
|
+
rb_define_const(rb_mGLFW, "MOD_SHIFT", INT2NUM(GLFW_MOD_SHIFT));
|
249
|
+
rb_define_const(rb_mGLFW, "MOD_ALT", INT2NUM(GLFW_MOD_ALT));
|
250
|
+
rb_define_const(rb_mGLFW, "MOD_SUPER", INT2NUM(GLFW_MOD_SUPER));
|
251
|
+
// Mouse Buttons
|
252
|
+
rb_define_const(rb_mGLFW, "MOUSE_BUTTON_1", INT2NUM(GLFW_MOUSE_BUTTON_1));
|
253
|
+
rb_define_const(rb_mGLFW, "MOUSE_BUTTON_2", INT2NUM(GLFW_MOUSE_BUTTON_2));
|
254
|
+
rb_define_const(rb_mGLFW, "MOUSE_BUTTON_3", INT2NUM(GLFW_MOUSE_BUTTON_3));
|
255
|
+
rb_define_const(rb_mGLFW, "MOUSE_BUTTON_4", INT2NUM(GLFW_MOUSE_BUTTON_4));
|
256
|
+
rb_define_const(rb_mGLFW, "MOUSE_BUTTON_5", INT2NUM(GLFW_MOUSE_BUTTON_5));
|
257
|
+
rb_define_const(rb_mGLFW, "MOUSE_BUTTON_6", INT2NUM(GLFW_MOUSE_BUTTON_6));
|
258
|
+
rb_define_const(rb_mGLFW, "MOUSE_BUTTON_7", INT2NUM(GLFW_MOUSE_BUTTON_7));
|
259
|
+
rb_define_const(rb_mGLFW, "MOUSE_BUTTON_8", INT2NUM(GLFW_MOUSE_BUTTON_8));
|
260
|
+
rb_define_const(rb_mGLFW, "MOUSE_BUTTON_LAST", INT2NUM(GLFW_MOUSE_BUTTON_LAST));
|
261
|
+
rb_define_const(rb_mGLFW, "MOUSE_BUTTON_LEFT", INT2NUM(GLFW_MOUSE_BUTTON_LEFT));
|
262
|
+
rb_define_const(rb_mGLFW, "MOUSE_BUTTON_RIGHT", INT2NUM(GLFW_MOUSE_BUTTON_RIGHT));
|
263
|
+
rb_define_const(rb_mGLFW, "MOUSE_BUTTON_MIDDLE", INT2NUM(GLFW_MOUSE_BUTTON_MIDDLE));
|
264
|
+
// Cursor Shapes
|
265
|
+
rb_define_const(rb_mGLFW, "CURSOR_ARROW", INT2NUM(GLFW_ARROW_CURSOR));
|
266
|
+
rb_define_const(rb_mGLFW, "CURSOR_IBEAM", INT2NUM(GLFW_IBEAM_CURSOR));
|
267
|
+
rb_define_const(rb_mGLFW, "CURSOR_CROSSHAIR", INT2NUM(GLFW_CROSSHAIR_CURSOR));
|
268
|
+
rb_define_const(rb_mGLFW, "CURSOR_HAND", INT2NUM(GLFW_HAND_CURSOR));
|
269
|
+
rb_define_const(rb_mGLFW, "CURSOR_HRESIZE", INT2NUM(GLFW_HRESIZE_CURSOR));
|
270
|
+
rb_define_const(rb_mGLFW, "CURSOR_VRESIZE", INT2NUM(GLFW_VRESIZE_CURSOR));
|
271
|
+
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
void rb_glfw_error_callback(int error, const char *message) {
|
276
|
+
rb_raise(rb_eGLFWError, message);
|
277
|
+
}
|
278
|
+
|
279
|
+
void rb_glfw_monitor_callback(GLFWmonitor *monitor, int connected) {
|
280
|
+
VALUE m = Data_Wrap_Struct(rb_cGLFWmonitor, NULL, RUBY_DEFAULT_FREE, monitor);
|
281
|
+
rb_funcall(rb_mGLFW, rb_intern("monitor_changed"), 2, m, INT2BOOL(connected));
|
282
|
+
}
|
283
|
+
|
284
|
+
void rb_glfw_joystick_callback(int joystick, int connected) {
|
285
|
+
rb_funcall(rb_mGLFW, rb_intern("joystick_changed"), 2, INT2NUM(joystick), INT2BOOL(connected));
|
286
|
+
}
|
287
|
+
|
288
|
+
VALUE rb_glfw_init(VALUE klass) {
|
289
|
+
if (glfwInit())
|
290
|
+
{
|
291
|
+
glfwSetMonitorCallback(rb_glfw_monitor_callback);
|
292
|
+
glfwSetJoystickCallback(rb_glfw_joystick_callback);
|
293
|
+
return Qtrue;
|
294
|
+
}
|
295
|
+
return Qfalse;
|
296
|
+
}
|
297
|
+
|
298
|
+
VALUE rb_glfw_terminate(VALUE klass) {
|
299
|
+
glfwTerminate();
|
300
|
+
return Qnil;
|
301
|
+
}
|
302
|
+
|
303
|
+
VALUE rb_glfw_poll_events(VALUE klass) {
|
304
|
+
glfwPollEvents();
|
305
|
+
return Qnil;
|
306
|
+
}
|
307
|
+
|
308
|
+
VALUE rb_glfw_wait_events(VALUE klass) {
|
309
|
+
glfwWaitEvents();
|
310
|
+
return Qnil;
|
311
|
+
}
|
312
|
+
|
313
|
+
VALUE rb_glfe_event_timeout(VALUE klass, VALUE timeout) {
|
314
|
+
glfwWaitEventsTimeout(NUM2DBL(timeout));
|
315
|
+
return Qnil;
|
316
|
+
}
|
317
|
+
|
318
|
+
VALUE rb_glfw_get_time(VALUE klass) {
|
319
|
+
return DBL2NUM(glfwGetTime());
|
320
|
+
}
|
321
|
+
|
322
|
+
VALUE rb_glfw_set_time(VALUE klass, VALUE t) {
|
323
|
+
glfwSetTime(NUM2DBL(t));
|
324
|
+
return t;
|
325
|
+
}
|
326
|
+
|
327
|
+
VALUE rb_glfw_swap_interval(VALUE klass, VALUE interval) {
|
328
|
+
glfwSwapInterval(NUM2INT(interval));
|
329
|
+
return interval;
|
330
|
+
}
|
331
|
+
|
332
|
+
VALUE rb_glfw_current_context(VALUE klass) {
|
333
|
+
GLFWwindow *w = glfwGetCurrentContext();
|
334
|
+
return Data_Wrap_Struct(klass, NULL, RUBY_DEFAULT_FREE, w);
|
335
|
+
}
|
336
|
+
|
337
|
+
VALUE rb_glfw_supported_p(VALUE klass, volatile VALUE extension) {
|
338
|
+
const char* ext = rb_string_value_cstr(&extension);
|
339
|
+
return glfwExtensionSupported(ext) ? Qtrue : Qfalse;
|
340
|
+
}
|
341
|
+
|
342
|
+
VALUE rb_glfw_monitors(VALUE klass) {
|
343
|
+
int count;
|
344
|
+
GLFWmonitor** monitors = glfwGetMonitors(&count);
|
345
|
+
VALUE ary = rb_ary_new_capa(count);
|
346
|
+
for (int i = 0; i < count; i++)
|
347
|
+
rb_ary_store(ary, i, Data_Wrap_Struct(rb_cGLFWmonitor, NULL, RUBY_DEFAULT_FREE, monitors[i]));
|
348
|
+
return ary;
|
349
|
+
}
|
350
|
+
|
351
|
+
VALUE rb_glfw_load_default_hints(VALUE klass) {
|
352
|
+
glfwDefaultWindowHints();
|
353
|
+
return Qnil;
|
354
|
+
}
|
355
|
+
|
356
|
+
VALUE rb_glfw_window_hint(VALUE klass, VALUE hint, VALUE value) {
|
357
|
+
int hintvalue;
|
358
|
+
if (NIL_P(value))
|
359
|
+
hintvalue = GLFW_DONT_CARE;
|
360
|
+
else if (FIXNUM_P(value))
|
361
|
+
hintvalue = NUM2INT(value);
|
362
|
+
else
|
363
|
+
hintvalue = RTEST(value);
|
364
|
+
glfwWindowHint(NUM2INT(hint), hintvalue);
|
365
|
+
|
366
|
+
return Qnil;
|
367
|
+
}
|
368
|
+
|
369
|
+
VALUE rb_glfw_key_name(VALUE klass, VALUE key, VALUE scancode) {
|
370
|
+
const char *name = glfwGetKeyName(NUM2INT(key), NUM2INT(scancode));
|
371
|
+
return rb_utf8_str_new_cstr(name);
|
372
|
+
}
|
373
|
+
|
374
|
+
VALUE rb_glfw_post_empty(VALUE klass) {
|
375
|
+
glfwPostEmptyEvent();
|
376
|
+
return Qnil;
|
377
|
+
}
|
378
|
+
|
379
|
+
VALUE rb_glfw_timer_frequency(VALUE klass) {
|
380
|
+
return ULL2NUM(glfwGetTimerFrequency());
|
381
|
+
}
|
382
|
+
|
383
|
+
VALUE rb_glfw_timer_value(VALUE klass) {
|
384
|
+
return ULL2NUM(glfwGetTimerValue());
|
385
|
+
}
|
386
|
+
|
387
|
+
VALUE rb_glfw_joystick_changed(VALUE klass, VALUE joystick, VALUE connected) {
|
388
|
+
return Qnil;
|
389
|
+
}
|
390
|
+
|
391
|
+
VALUE rb_glfw_joystick_buttons(VALUE klass, VALUE joystick) {
|
392
|
+
int count;
|
393
|
+
const unsigned char *buttons = glfwGetJoystickButtons(NUM2INT(joystick), &count);
|
394
|
+
VALUE ary = rb_ary_new_capa(count);
|
395
|
+
for (int i = 0; i < count; i++)
|
396
|
+
rb_ary_store(ary, i, INT2NUM(buttons[i]));
|
397
|
+
return ary;
|
398
|
+
}
|
399
|
+
|
400
|
+
VALUE rb_glfw_joystick_axes(VALUE klass, VALUE joystick) {
|
401
|
+
int count;
|
402
|
+
const float *axes = glfwGetJoystickAxes(NUM2INT(joystick), &count);
|
403
|
+
VALUE ary = rb_ary_new_capa(count);
|
404
|
+
for (int i = 0; i < count; i++)
|
405
|
+
rb_ary_store(ary, i, DBL2NUM(axes[i]));
|
406
|
+
return ary;
|
407
|
+
}
|
408
|
+
|
409
|
+
VALUE rb_glfw_joystick_name(VALUE klass, VALUE joystick) {
|
410
|
+
const char *name = glfwGetJoystickName(NUM2INT(joystick));
|
411
|
+
return rb_utf8_str_new_cstr(name);
|
412
|
+
}
|
413
|
+
|
414
|
+
VALUE rb_glfw_joystick_p(VALUE klass, VALUE joystick) {
|
415
|
+
return INT2BOOL(glfwJoystickPresent(NUM2INT(joystick)));
|
416
|
+
}
|
417
|
+
|
418
|
+
VALUE rb_glfw_monitor_changed(VALUE klass, VALUE monitor, VALUE connected) {
|
419
|
+
return Qnil;
|
420
|
+
}
|
421
|
+
|
422
|
+
VALUE rb_glfw_proc_address(VALUE klass, VALUE name) {
|
423
|
+
Check_Type(name, T_STRING);
|
424
|
+
size_t proc = (size_t) glfwGetProcAddress(StringValueCStr(name));
|
425
|
+
return LL2NUM(proc);
|
426
|
+
}
|
427
|
+
|
428
|
+
/*
|
429
|
+
glfwGetWGLContext
|
430
|
+
glfwGetWin32Adapter
|
431
|
+
glfwGetWin32Monitor
|
432
|
+
glfwGetWin32Window
|
433
|
+
glfwGetEGLContext
|
434
|
+
glfwGetEGLDisplay
|
435
|
+
glfwGetEGLSurface
|
436
|
+
*/
|
437
|
+
|
438
|
+
|