glfw3 0.1.1 → 0.2.0

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.
data/lib/glfw3.rb CHANGED
@@ -2,5 +2,11 @@ require 'glfw3/glfw3'
2
2
  require 'glfw3/callbacks'
3
3
  require 'glfw3/window'
4
4
 
5
+ #
6
+ # The core Glfw module, contains functions for setting error and monitor
7
+ # callbacks, joystick input, constants, timing, event handling, and so on.
8
+ #
9
+ # See also Glfw::Window, Glfw::Monitor, and Glfw::VideoMode.
10
+ #
5
11
  module Glfw
6
12
  end
@@ -4,26 +4,71 @@ module Glfw
4
4
  @@error_callback__ = nil
5
5
  @@monitor_callback__ = nil
6
6
 
7
+ #
8
+ # Gets the current error callback object.
9
+ #
10
+ # call-seq:
11
+ # error_callback -> obj or nil
12
+ #
7
13
  def self.error_callback
8
14
  @@error_callback
9
15
  end
10
16
 
17
+ #
18
+ # Sets the current error callback object to the given value. Presumably a
19
+ # Proc or some other object, but one that implements a call(...) function.
20
+ #
21
+ # If set to nil, any GLFW error will raise a RuntimeError exception.
22
+ #
23
+ # The error callback is expected to take two arguments: the error code and a
24
+ # description of the error. For example:
25
+ #
26
+ # Glfw.error_callback = lambda { |error_code, description|
27
+ # raise RuntimeError, "GLFW Error #{error_code}: #{description}"
28
+ # }
29
+ #
11
30
  def self.error_callback=(lambda)
12
31
  @@error_callback = lambda
13
32
  end
14
33
 
34
+ #
35
+ # Sets the current error callback to a Proc generated from the provided block.
36
+ #
15
37
  def self.set_error_callback(&block)
16
38
  self.error_callback = lambda(&block)
17
39
  end
18
40
 
41
+ #
42
+ # Gets the current monitor callback object.
43
+ #
44
+ # call-seq:
45
+ # monitor_callback -> obj or nil
46
+ #
19
47
  def self.monitor_callback
20
48
  @@monitor_callback
21
49
  end
22
50
 
51
+ #
52
+ # Sets the current monitor callback object to the given object. Presumably a
53
+ # Proc or some other object, but one that implements a call(...) function.
54
+ #
55
+ # If set to nil, the callback is disabled.
56
+ #
57
+ # The monitor callback is expected to take two arguments: the monitor and an
58
+ # event (one of either Glfw::CONNECTED or Glfw::DISCONNECTED). For example:
59
+ #
60
+ # Glfw.monitor_callback = lambda { |monitor, event|
61
+ # # ...
62
+ # }
63
+ #
23
64
  def self.monitor_callback=(lambda)
24
65
  @@monitor_callback = lambda
25
66
  end
26
67
 
68
+ #
69
+ # Sets the current monitor callback to a Proc generated from the provided
70
+ # block.
71
+ #
27
72
  def self.set_monitor_callback(&block)
28
73
  self.monitor_callback = lambda(&block)
29
74
  end
data/lib/glfw3/window.rb CHANGED
@@ -2,26 +2,71 @@ require 'glfw3/glfw3'
2
2
 
3
3
  module Glfw; end
4
4
 
5
+ #
6
+ # A GLFW window. These contain a context, optionally one shared with other
7
+ # windows and generate events. Each window maintains its own event callbacks.
8
+ #
9
+ # Wraps GLFWwindow and its associated functions, for the most part.
10
+ #
11
+ #
12
+ # === Event Callbacks
13
+ #
14
+ # All window event callbacks' first argument is the window that generated the
15
+ # event. These event callbacks all receive the same arguments as their GLFW C
16
+ # counterparts, so refer to the
17
+ # {GLFW 3 documentation}[http://www.glfw.org/docs/3.0/group__input.html]
18
+ # for that.
19
+ #
20
+ #
21
+ # === User Data
22
+ #
23
+ # If you need to associate a particular object or value with a window, you can
24
+ # use its #user_data attribute to store and retreive an arbitrary object for
25
+ # the window. If you need to store multiple values with the window, you might
26
+ # set its user data object to a Hash.
27
+ #
5
28
  class Glfw::Window
6
29
 
30
+ #
31
+ # User data attribute, can be set to any arbitrary object. Used to associate
32
+ # any object with the window for later retrieval.
33
+ #
7
34
  attr_accessor :user_data
8
35
 
36
+ #
37
+ # Returns an array of all allocated GLFW windows.
38
+ #
39
+ # call-seq:
40
+ # windows -> [Glfw::Window, ...]
41
+ #
9
42
  def windows
10
43
  @__windows.values
11
44
  end
12
45
 
46
+ #
47
+ # Gets the X position of the window in screen space. See also #position.
48
+ #
13
49
  def x
14
50
  position[0]
15
51
  end
16
52
 
53
+ #
54
+ # Gets the Y position of the window in screen space. See also #position.
55
+ #
17
56
  def y
18
57
  position[1]
19
58
  end
20
59
 
60
+ #
61
+ # Gets the width of the window. See also #size.
62
+ #
21
63
  def width
22
64
  size[0]
23
65
  end
24
66
 
67
+ #
68
+ # Gets the width of the window. See also #size.
69
+ #
25
70
  def height
26
71
  size[1]
27
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glfw3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noel Raymond Cower
@@ -15,19 +15,29 @@ email: ncower@gmail.com
15
15
  executables: []
16
16
  extensions:
17
17
  - ext/glfw3/extconf.rb
18
- extra_rdoc_files: []
18
+ extra_rdoc_files:
19
+ - ext/glfw3/glfw3.c
20
+ - README.md
21
+ - COPYING
19
22
  files:
20
23
  - lib/glfw3/callbacks.rb
21
24
  - lib/glfw3/window.rb
22
25
  - lib/glfw3.rb
23
26
  - ext/glfw3/glfw3.c
24
27
  - ext/glfw3/extconf.rb
28
+ - COPYING
29
+ - README.md
25
30
  homepage: https://github.com/nilium/ruby-glfw3
26
31
  licenses:
27
32
  - Simplified BSD
28
33
  metadata: {}
29
34
  post_install_message:
30
- rdoc_options: []
35
+ rdoc_options:
36
+ - --title
37
+ - core-opengl -- OpenGL Core Profile Bindings
38
+ - --main
39
+ - README.md
40
+ - --line-numbers
31
41
  require_paths:
32
42
  - lib
33
43
  required_ruby_version: !ruby/object:Gem::Requirement