ruby-opengl 0.33.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +129 -0
- data/doc/build_install.txt +53 -0
- data/doc/history.txt +48 -0
- data/doc/requirements_and_design.txt +131 -0
- data/doc/roadmap.txt +19 -0
- data/doc/scientific_use.txt +28 -0
- data/doc/supplies/page_template.html +63 -0
- data/doc/thanks.txt +23 -0
- data/doc/tutorial.txt +160 -0
- data/examples/README +36 -0
- data/examples/aaindex.rb +97 -0
- data/examples/all_tests.rb +24 -0
- data/examples/plane.rb +161 -0
- data/examples/smooth.rb +40 -0
- data/examples/smooth_prev.rb +40 -0
- data/examples/test.rb +64 -0
- data/ext/common/Rakefile +39 -0
- data/ext/common/gl-enums.h +10349 -0
- data/ext/common/rbogl.c +260 -0
- data/ext/common/rbogl.h +52 -0
- data/ext/gl/gl-1.0-1.1.c +5152 -0
- data/ext/gl/gl-1.2.c +166 -0
- data/ext/gl/gl-enums.c +2905 -0
- data/ext/gl/gl.c +31 -0
- data/ext/gl/mkrf_conf.rb +27 -0
- data/ext/glu/glu.c +1636 -0
- data/ext/glu/mkrf_conf.rb +28 -0
- data/ext/glut/glut.c +1776 -0
- data/ext/glut/mkrf_conf.rb +28 -0
- data/lib/gl_prev.rb +45 -0
- data/lib/glu_prev.rb +45 -0
- data/lib/glut_prev.rb +45 -0
- data/test/README +23 -0
- data/test/runtests.sh +7 -0
- data/test/tc_gl_vertex.rb +180 -0
- data/test/tc_include_gl.rb +35 -0
- data/test/tc_opengl_namespace.rb +40 -0
- data/test/tc_require_gl.rb +34 -0
- metadata +96 -0
data/ext/common/rbogl.c
ADDED
@@ -0,0 +1,260 @@
|
|
1
|
+
/*
|
2
|
+
* Last edit by previous maintainer:
|
3
|
+
* 2003/08/17 03:46:15, yoshi
|
4
|
+
*
|
5
|
+
* Copyright (C) 1999 - 2005 Yoshi <yoshi@giganet.net>
|
6
|
+
* Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
|
7
|
+
*
|
8
|
+
* This program is distributed under the terms of the MIT license.
|
9
|
+
* See the included MIT-LICENSE file for the terms of this license.
|
10
|
+
*
|
11
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
12
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
13
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
14
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
15
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
16
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
17
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
18
|
+
*/
|
19
|
+
|
20
|
+
#ifdef __APPLE__
|
21
|
+
#include <OpenGL/gl.h>
|
22
|
+
#elif defined WIN32
|
23
|
+
#include <windows.h>
|
24
|
+
#include <GL/gl.h>
|
25
|
+
#else
|
26
|
+
#include <GL/gl.h>
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#include "rbogl.h"
|
30
|
+
#include "gl-enums.h"
|
31
|
+
|
32
|
+
/* -------------------------------------------------------------------- */
|
33
|
+
#ifdef _NO_NUM2DBL_
|
34
|
+
extern double num2double( VALUE val )
|
35
|
+
{
|
36
|
+
struct RFloat* flt;
|
37
|
+
if (NIL_P(val)) return 0;
|
38
|
+
flt = RFLOAT(f_float(0, val));
|
39
|
+
return flt->value;
|
40
|
+
}
|
41
|
+
#endif
|
42
|
+
|
43
|
+
/* -------------------------------------------------------------------- */
|
44
|
+
#define ARY2INTEGRAL(_type_) \
|
45
|
+
extern int ary2c##_type_( arg, cary, maxlen ) \
|
46
|
+
VALUE arg; \
|
47
|
+
GL##_type_ cary[]; \
|
48
|
+
int maxlen; \
|
49
|
+
{ \
|
50
|
+
int i; \
|
51
|
+
struct RArray* ary; \
|
52
|
+
VALUE entry; \
|
53
|
+
ary = RARRAY(rb_Array(arg)); \
|
54
|
+
if (maxlen < 1) \
|
55
|
+
maxlen = ary->len; \
|
56
|
+
else \
|
57
|
+
maxlen = maxlen < ary->len ? maxlen : ary->len; \
|
58
|
+
for (i=0; i < maxlen; i++) \
|
59
|
+
{ \
|
60
|
+
entry = rb_ary_entry((VALUE)ary,i); \
|
61
|
+
cary[i] = (GL##_type_)NUM2INT(entry); \
|
62
|
+
} \
|
63
|
+
return i; \
|
64
|
+
}
|
65
|
+
|
66
|
+
ARY2INTEGRAL(int)
|
67
|
+
ARY2INTEGRAL(uint)
|
68
|
+
ARY2INTEGRAL(byte)
|
69
|
+
ARY2INTEGRAL(ubyte)
|
70
|
+
ARY2INTEGRAL(short)
|
71
|
+
ARY2INTEGRAL(ushort)
|
72
|
+
ARY2INTEGRAL(boolean)
|
73
|
+
#undef ARY2INTEGRAL
|
74
|
+
|
75
|
+
/* -------------------------------------------------------------------- */
|
76
|
+
extern int ary2cflt(arg, cary, maxlen)
|
77
|
+
VALUE arg;
|
78
|
+
float cary[];
|
79
|
+
int maxlen;
|
80
|
+
{
|
81
|
+
int i;
|
82
|
+
struct RArray* ary;
|
83
|
+
ary = RARRAY(rb_Array(arg));
|
84
|
+
if (maxlen < 1)
|
85
|
+
maxlen = ary->len;
|
86
|
+
else
|
87
|
+
maxlen = maxlen < ary->len ? maxlen : ary->len;
|
88
|
+
for (i=0; i < maxlen; i++)
|
89
|
+
cary[i] = (float)NUM2DBL(rb_ary_entry((VALUE)ary,i));
|
90
|
+
return i;
|
91
|
+
}
|
92
|
+
|
93
|
+
/* -------------------------------------------------------------------- */
|
94
|
+
extern int ary2cdbl(arg, cary, maxlen)
|
95
|
+
VALUE arg;
|
96
|
+
double cary[];
|
97
|
+
int maxlen;
|
98
|
+
{
|
99
|
+
int i;
|
100
|
+
struct RArray* ary;
|
101
|
+
ary = RARRAY(rb_Array(arg));
|
102
|
+
if (maxlen < 1)
|
103
|
+
maxlen = ary->len;
|
104
|
+
else
|
105
|
+
maxlen = maxlen < ary->len ? maxlen : ary->len;
|
106
|
+
for (i=0; i < maxlen; i++)
|
107
|
+
cary[i] = NUM2DBL(rb_ary_entry((VALUE)ary,i));
|
108
|
+
return i;
|
109
|
+
}
|
110
|
+
|
111
|
+
/* -------------------------------------------------------------------- */
|
112
|
+
extern void mary2ary(src, ary)
|
113
|
+
VALUE src;
|
114
|
+
VALUE ary;
|
115
|
+
{
|
116
|
+
struct RArray* tmp_ary;
|
117
|
+
int i;
|
118
|
+
tmp_ary = RARRAY(rb_Array(src));
|
119
|
+
for (i = 0; i < tmp_ary->len; i++)
|
120
|
+
{
|
121
|
+
if (TYPE(tmp_ary->ptr[i]) == T_ARRAY)
|
122
|
+
mary2ary((VALUE)tmp_ary, ary);
|
123
|
+
else
|
124
|
+
rb_ary_push(ary, tmp_ary->ptr[i]);
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
/* -------------------------------------------------------------------- */
|
129
|
+
extern void ary2cmat4x4dbl(ary, cary)
|
130
|
+
VALUE ary;
|
131
|
+
double cary[];
|
132
|
+
{
|
133
|
+
int i,j;
|
134
|
+
RArray *ary_r,*ary_c;
|
135
|
+
memset(cary, 0x0, sizeof(double[4*4]));
|
136
|
+
ary_c = RARRAY(rb_Array(ary));
|
137
|
+
if (TYPE(ary_c->ptr[0]) != T_ARRAY)
|
138
|
+
ary2cdbl((VALUE)ary_c, cary, 16);
|
139
|
+
else
|
140
|
+
{
|
141
|
+
for (i = 0; i < ary_c->len && i < 4; i++)
|
142
|
+
{
|
143
|
+
ary_r = RARRAY(rb_Array(ary_c->ptr[i]));
|
144
|
+
for(j = 0; j < ary_r->len && j < 4; j++)
|
145
|
+
cary[i*4+j] = (GLdouble)NUM2DBL(ary_r->ptr[j]);
|
146
|
+
}
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
extern void ary2cmat4x4flt(ary, cary)
|
151
|
+
VALUE ary;
|
152
|
+
float cary[];
|
153
|
+
{
|
154
|
+
int i,j;
|
155
|
+
RArray *ary_r,*ary_c;
|
156
|
+
memset(cary, 0x0, sizeof(float[4*4]));
|
157
|
+
ary_c = RARRAY(rb_Array(ary));
|
158
|
+
if (TYPE(ary_c->ptr[0]) != T_ARRAY)
|
159
|
+
ary2cflt((VALUE)ary_c, cary, 16);
|
160
|
+
else
|
161
|
+
{
|
162
|
+
for (i = 0; i < ary_c->len && i < 4; i++)
|
163
|
+
{
|
164
|
+
ary_r = RARRAY(rb_Array(ary_c->ptr[i]));
|
165
|
+
for(j = 0; j < ary_r->len && j < 4; j++)
|
166
|
+
cary[i*4+j] = (GLfloat)NUM2DBL(ary_r->ptr[j]);
|
167
|
+
}
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
/* -------------------------------------------------------------------- */
|
172
|
+
/*Need to find proper size for glReadPixels array*/
|
173
|
+
int glformat_size(GLenum format)
|
174
|
+
{
|
175
|
+
switch(format)
|
176
|
+
{
|
177
|
+
case GL_COLOR_INDEX:
|
178
|
+
case GL_RED:
|
179
|
+
case GL_GREEN:
|
180
|
+
case GL_BLUE:
|
181
|
+
case GL_ALPHA:
|
182
|
+
case GL_STENCIL_INDEX:
|
183
|
+
case GL_DEPTH_COMPONENT:
|
184
|
+
case GL_LUMINANCE:
|
185
|
+
return 1;
|
186
|
+
|
187
|
+
case GL_LUMINANCE_ALPHA:
|
188
|
+
return 2;
|
189
|
+
|
190
|
+
case GL_RGB:
|
191
|
+
case GL_BGR_EXT:
|
192
|
+
return 3;
|
193
|
+
|
194
|
+
case GL_RGBA:
|
195
|
+
case GL_BGRA_EXT:
|
196
|
+
case GL_ABGR_EXT:
|
197
|
+
return 4;
|
198
|
+
case 1:
|
199
|
+
case 2:
|
200
|
+
case 3:
|
201
|
+
case 4:
|
202
|
+
return format;
|
203
|
+
default:
|
204
|
+
return -1;
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
/* -------------------------------------------------------------------- */
|
209
|
+
int gltype_size(GLenum type)
|
210
|
+
{
|
211
|
+
switch(type)
|
212
|
+
{
|
213
|
+
case GL_BYTE:
|
214
|
+
case GL_UNSIGNED_BYTE:
|
215
|
+
case GL_UNSIGNED_BYTE_3_3_2:
|
216
|
+
case GL_UNSIGNED_BYTE_2_3_3_REV:
|
217
|
+
return 8;
|
218
|
+
|
219
|
+
case GL_SHORT:
|
220
|
+
case GL_UNSIGNED_SHORT:
|
221
|
+
case GL_UNSIGNED_SHORT_5_6_5:
|
222
|
+
case GL_UNSIGNED_SHORT_5_6_5_REV:
|
223
|
+
case GL_UNSIGNED_SHORT_4_4_4_4:
|
224
|
+
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
|
225
|
+
case GL_UNSIGNED_SHORT_5_5_5_1:
|
226
|
+
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
|
227
|
+
return 16;
|
228
|
+
|
229
|
+
case GL_INT:
|
230
|
+
case GL_UNSIGNED_INT:
|
231
|
+
case GL_FLOAT:
|
232
|
+
case GL_UNSIGNED_INT_8_8_8_8:
|
233
|
+
case GL_UNSIGNED_INT_8_8_8_8_REV:
|
234
|
+
case GL_UNSIGNED_INT_10_10_10_2:
|
235
|
+
case GL_UNSIGNED_INT_2_10_10_10_REV:
|
236
|
+
return 32;
|
237
|
+
|
238
|
+
case GL_BITMAP:
|
239
|
+
return 1;
|
240
|
+
|
241
|
+
default:
|
242
|
+
return -1;
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
/* -------------------------------------------------------------------- */
|
247
|
+
VALUE allocate_buffer_with_string( int size )
|
248
|
+
{
|
249
|
+
return rb_str_new(NULL, size);
|
250
|
+
}
|
251
|
+
|
252
|
+
/* -------------------------------------------------------------------- */
|
253
|
+
void Init_gl(void);
|
254
|
+
|
255
|
+
void Init_opengl()
|
256
|
+
{
|
257
|
+
Init_gl(); /* is this needed ? */
|
258
|
+
/* RxINC: InitializeGLU(); */
|
259
|
+
}
|
260
|
+
|
data/ext/common/rbogl.h
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
/*
|
2
|
+
* Last edit by previous maintainer:
|
3
|
+
* 2000/01/06 16:37:43, kusano
|
4
|
+
*
|
5
|
+
* Copyright (C) 1999 - 2005 Yoshi <yoshi@giganet.net>
|
6
|
+
* Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
|
7
|
+
*
|
8
|
+
* This program is distributed under the terms of the MIT license.
|
9
|
+
* See the included MIT-LICENSE file for the terms of this license.
|
10
|
+
*
|
11
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
12
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
13
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
14
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
15
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
16
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
17
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
18
|
+
*/
|
19
|
+
|
20
|
+
#ifndef _RBOGL_H_
|
21
|
+
#define _RBOGL_H_
|
22
|
+
|
23
|
+
#include <ruby.h>
|
24
|
+
|
25
|
+
typedef struct RArray RArray;
|
26
|
+
|
27
|
+
extern VALUE cProc;
|
28
|
+
|
29
|
+
int ary2cint( VALUE, GLint[], int );
|
30
|
+
int ary2cuint( VALUE, GLuint[], int );
|
31
|
+
int ary2cshort( VALUE, GLshort[], int );
|
32
|
+
int ary2cushort( VALUE, GLushort[], int );
|
33
|
+
int ary2cbyte( VALUE, GLbyte[], int );
|
34
|
+
int ary2cubyte( VALUE, GLubyte[], int );
|
35
|
+
int ary2cboolean( VALUE, GLboolean[], int );
|
36
|
+
int ary2cdbl( VALUE, double[], int );
|
37
|
+
int ary2cflt( VALUE, float[], int );
|
38
|
+
void mary2ary( VALUE, VALUE );
|
39
|
+
void ary2cmat4x4dbl( VALUE, double[] );
|
40
|
+
void ary2cmat4x4flt( VALUE, float[] );
|
41
|
+
VALUE allocate_buffer_with_string( int );
|
42
|
+
|
43
|
+
#ifndef NUM2DBL
|
44
|
+
double num2double( VALUE );
|
45
|
+
#define _NO_NUM2DBL_
|
46
|
+
#define NUM2DBL(_val) num2double(_val)
|
47
|
+
#endif /* NUM2DBL */
|
48
|
+
|
49
|
+
int gltype_size(GLenum type);
|
50
|
+
int glformat_size(GLenum format);
|
51
|
+
|
52
|
+
#endif /* _RBOGL_H_ */
|