cwiid 0.1.1 → 0.1.2

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.
Files changed (3) hide show
  1. data/README.md +45 -31
  2. data/Rakefile +1 -1
  3. metadata +3 -3
data/README.md CHANGED
@@ -35,27 +35,43 @@ Here's a small example displaying the state of the accelerometer:
35
35
  require 'opengl'
36
36
  require 'cwiid'
37
37
  wiimote = WiiMote.new
38
+ wiimote.rpt_mode = WiiMote::RPT_BTN | WiiMote::RPT_ACC
39
+ $list = nil
40
+ def init
41
+ GL.ClearColor 0.0, 0.0, 0.0, 1.0
42
+ GL.Light GL_LIGHT0, GL_POSITION, [ 0.5, 0.5, 1.0, 0.0 ]
43
+ GL.Enable GL_LIGHTING
44
+ GL.Enable GL_LIGHT0
45
+ GL.DepthFunc GL_LESS
46
+ GL.Enable GL_DEPTH_TEST
47
+ $list = GL.GenLists 1
48
+ GL.NewList $list, GL_COMPILE
49
+ GL.Material GL_FRONT, GL_SPECULAR, [ 1.0, 1.0, 1.0, 0.15 ]
50
+ GL.Material GL_FRONT, GL_SHININESS, [ 100.0 ]
51
+ GL.Material GL_FRONT, GL_EMISSION, [ 0.0, 0.2, 0.0, 1.0 ]
52
+ GL.Material GL_FRONT, GL_DIFFUSE, [ 0.1, 0.8, 0.1, 1.0 ]
53
+ GLUT.SolidSphere 0.4, 16, 16
54
+ GL.EndList
55
+ end
38
56
  display = proc do
39
57
  acc = wiimote.acc
40
- glClear GL_COLOR_BUFFER_BIT
41
- glLineWidth 3.0
42
- glColor 1.0, 0.0, 0.0
43
- glBegin GL_LINES
44
- glVertex 120, 120
45
- glVertex acc[0], acc[2]
46
- glEnd
47
- glColor 0.0, 1.0, 0.0
48
- glBegin GL_LINES
49
- glVertex 120, 120
50
- glVertex acc[1], acc[2]
51
- glEnd
52
- glutSwapBuffers
58
+ GL.Clear GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
59
+ GL.PushMatrix
60
+ GL.Translate( ( acc[0] - 120 ) * 0.01,
61
+ ( 120 - acc[2] ) * 0.01,
62
+ ( 120 - acc[1] ) * 0.01 )
63
+ GL.CallList $list
64
+ GL.PopMatrix
65
+ GLUT.SwapBuffers
53
66
  end
54
67
  reshape = proc do |w, h|
55
- glViewport 0, 0, w, h
56
- glMatrixMode GL_PROJECTION
57
- glLoadIdentity
58
- GLU.Ortho2D 0.0, w, 0.0, h
68
+ GL.Viewport 0, 0, w, h
69
+ GL.MatrixMode GL_PROJECTION
70
+ GL.LoadIdentity
71
+ GLU.Perspective 60.0, w.to_f/h, 1.0, 20.0
72
+ GL.MatrixMode GL_MODELVIEW
73
+ GL.LoadIdentity
74
+ GL.Translate 0.0, 0.0, -3.5
59
75
  end
60
76
  keyboard = proc do |key, x, y|
61
77
  case key
@@ -66,18 +82,16 @@ Here's a small example displaying the state of the accelerometer:
66
82
  animate = proc do
67
83
  wiimote.get_state
68
84
  exit 0 if wiimote.buttons == WiiMote::BTN_1
69
- glutPostRedisplay
85
+ GLUT.PostRedisplay
70
86
  end
71
- glutInit
72
- glutInitDisplayMode GLUT_DOUBLE | GLUT_RGB
73
- glutInitWindowSize 240, 240
74
- glutCreateWindow 'Wii Remote'
75
- glClearColor 1.0, 1.0, 1.0, 0.0
76
- glShadeModel GL_FLAT
77
-
78
- glutDisplayFunc display
79
- glutReshapeFunc reshape
80
- glutKeyboardFunc keyboard
81
- glutIdleFunc animate
82
- glutMainLoop
83
-
87
+ GLUT.Init
88
+ GLUT.InitDisplayMode GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH
89
+ GLUT.InitWindowSize 640, 480
90
+ GLUT.CreateWindow 'Wii Remote'
91
+ init
92
+ GLUT.DisplayFunc display
93
+ GLUT.ReshapeFunc reshape
94
+ GLUT.KeyboardFunc keyboard
95
+ GLUT.IdleFunc animate
96
+ GLUT.MainLoop
97
+
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rake/loaders/makefile'
7
7
  require 'rbconfig'
8
8
 
9
9
  PKG_NAME = 'cwiid'
10
- PKG_VERSION = '0.1.1'
10
+ PKG_VERSION = '0.1.2'
11
11
  CFG = RbConfig::CONFIG
12
12
  CXX = ENV[ 'CXX' ] || 'g++'
13
13
  RB_FILES = FileList[ 'lib/**/*.rb' ]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jan Wedekind
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-25 00:00:00 +00:00
17
+ date: 2010-12-27 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency