danabr75-opengl 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. data/.autotest +29 -0
  3. data/.gemtest +0 -0
  4. data/.gitignore +6 -0
  5. data/.travis.yml +19 -0
  6. data/Gemfile +8 -0
  7. data/History.md +101 -0
  8. data/MIT-LICENSE +18 -0
  9. data/Manifest.txt +142 -0
  10. data/README.rdoc +105 -0
  11. data/Rakefile +170 -0
  12. data/danabr75-opengl.gemspec +32 -0
  13. data/examples/NeHe/NeHe.png +0 -0
  14. data/examples/NeHe/crate.png +0 -0
  15. data/examples/NeHe/glass.png +0 -0
  16. data/examples/NeHe/nehe_lesson02.rb +117 -0
  17. data/examples/NeHe/nehe_lesson03.rb +123 -0
  18. data/examples/NeHe/nehe_lesson04.rb +132 -0
  19. data/examples/NeHe/nehe_lesson05.rb +182 -0
  20. data/examples/NeHe/nehe_lesson06.rb +186 -0
  21. data/examples/NeHe/nehe_lesson07.rb +240 -0
  22. data/examples/NeHe/nehe_lesson08.rb +255 -0
  23. data/examples/NeHe/nehe_lesson09.rb +203 -0
  24. data/examples/NeHe/nehe_lesson11.rb +176 -0
  25. data/examples/NeHe/nehe_lesson12.rb +203 -0
  26. data/examples/NeHe/nehe_lesson16.rb +211 -0
  27. data/examples/NeHe/nehe_lesson19.rb +209 -0
  28. data/examples/NeHe/nehe_lesson36.rb +308 -0
  29. data/examples/NeHe/particle.png +0 -0
  30. data/examples/NeHe/star.png +0 -0
  31. data/examples/NeHe/tim.png +0 -0
  32. data/examples/OrangeBook/3Dlabs-License.txt +33 -0
  33. data/examples/OrangeBook/brick.frag +36 -0
  34. data/examples/OrangeBook/brick.rb +378 -0
  35. data/examples/OrangeBook/brick.vert +41 -0
  36. data/examples/OrangeBook/particle.frag +17 -0
  37. data/examples/OrangeBook/particle.rb +408 -0
  38. data/examples/OrangeBook/particle.vert +38 -0
  39. data/examples/README +16 -0
  40. data/examples/RedBook/aapoly.rb +143 -0
  41. data/examples/RedBook/aargb.rb +121 -0
  42. data/examples/RedBook/accanti.rb +164 -0
  43. data/examples/RedBook/accpersp.rb +217 -0
  44. data/examples/RedBook/alpha.rb +125 -0
  45. data/examples/RedBook/alpha3D.rb +160 -0
  46. data/examples/RedBook/bezcurve.rb +107 -0
  47. data/examples/RedBook/bezmesh.rb +139 -0
  48. data/examples/RedBook/checker.rb +126 -0
  49. data/examples/RedBook/clip.rb +97 -0
  50. data/examples/RedBook/colormat.rb +137 -0
  51. data/examples/RedBook/cube.rb +71 -0
  52. data/examples/RedBook/depthcue.rb +101 -0
  53. data/examples/RedBook/dof.rb +206 -0
  54. data/examples/RedBook/double.rb +107 -0
  55. data/examples/RedBook/drawf.rb +93 -0
  56. data/examples/RedBook/feedback.rb +147 -0
  57. data/examples/RedBook/fog.rb +168 -0
  58. data/examples/RedBook/font.rb +153 -0
  59. data/examples/RedBook/hello.rb +81 -0
  60. data/examples/RedBook/image.rb +139 -0
  61. data/examples/RedBook/jitter.rb +207 -0
  62. data/examples/RedBook/light.rb +157 -0
  63. data/examples/RedBook/lines.rb +130 -0
  64. data/examples/RedBook/list.rb +113 -0
  65. data/examples/RedBook/material.rb +276 -0
  66. data/examples/RedBook/mipmap.rb +158 -0
  67. data/examples/RedBook/model.rb +115 -0
  68. data/examples/RedBook/movelight.rb +134 -0
  69. data/examples/RedBook/pickdepth.rb +181 -0
  70. data/examples/RedBook/planet.rb +110 -0
  71. data/examples/RedBook/quadric.rb +160 -0
  72. data/examples/RedBook/robot.rb +117 -0
  73. data/examples/RedBook/select.rb +198 -0
  74. data/examples/RedBook/smooth.rb +97 -0
  75. data/examples/RedBook/stencil.rb +165 -0
  76. data/examples/RedBook/stroke.rb +169 -0
  77. data/examples/RedBook/surface.rb +168 -0
  78. data/examples/RedBook/teaambient.rb +134 -0
  79. data/examples/RedBook/teapots.rb +184 -0
  80. data/examples/RedBook/tess.rb +185 -0
  81. data/examples/RedBook/texbind.rb +149 -0
  82. data/examples/RedBook/texgen.rb +171 -0
  83. data/examples/RedBook/texturesurf.rb +130 -0
  84. data/examples/RedBook/varray.rb +161 -0
  85. data/examples/RedBook/wrap.rb +150 -0
  86. data/examples/misc/OGLBench.rb +338 -0
  87. data/examples/misc/anisotropic.rb +196 -0
  88. data/examples/misc/fbo_test.rb +357 -0
  89. data/examples/misc/font-glut.rb +47 -0
  90. data/examples/misc/glfwtest.rb +30 -0
  91. data/examples/misc/plane.rb +161 -0
  92. data/examples/misc/readpixel.rb +66 -0
  93. data/examples/misc/sdltest.rb +36 -0
  94. data/examples/misc/trislam.rb +829 -0
  95. data/ext/opengl/GL/gl.h +2115 -0
  96. data/ext/opengl/GL/glext.h +11770 -0
  97. data/ext/opengl/common.h +372 -0
  98. data/ext/opengl/conv.h +247 -0
  99. data/ext/opengl/extconf.rb +19 -0
  100. data/ext/opengl/fptr_struct.h +912 -0
  101. data/ext/opengl/funcdef.h +279 -0
  102. data/ext/opengl/gl-1.0-1.1.c +3345 -0
  103. data/ext/opengl/gl-1.2.c +155 -0
  104. data/ext/opengl/gl-1.3.c +447 -0
  105. data/ext/opengl/gl-1.4.c +346 -0
  106. data/ext/opengl/gl-1.5.c +225 -0
  107. data/ext/opengl/gl-2.0.c +665 -0
  108. data/ext/opengl/gl-2.1.c +57 -0
  109. data/ext/opengl/gl-3.0.c +502 -0
  110. data/ext/opengl/gl-enums.c +4853 -0
  111. data/ext/opengl/gl-enums.h +14528 -0
  112. data/ext/opengl/gl-error.c +110 -0
  113. data/ext/opengl/gl-error.h +25 -0
  114. data/ext/opengl/gl-ext-3dfx.c +27 -0
  115. data/ext/opengl/gl-ext-arb.c +880 -0
  116. data/ext/opengl/gl-ext-ati.c +41 -0
  117. data/ext/opengl/gl-ext-ext.c +885 -0
  118. data/ext/opengl/gl-ext-gremedy.c +41 -0
  119. data/ext/opengl/gl-ext-nv.c +679 -0
  120. data/ext/opengl/gl.c +265 -0
  121. data/ext/opengl/gl_buffer.c +202 -0
  122. data/ext/opengl/glimpl.c +187 -0
  123. data/ext/opengl/glimpl.h +47 -0
  124. data/ext/opengl/opengl.c +9 -0
  125. data/lib/gl.rb +1 -0
  126. data/lib/opengl.rb +79 -0
  127. data/lib/opengl/bindings_version.rb +4 -0
  128. data/lib/opengl/implementation.rb +38 -0
  129. data/lib/opengl/test_case.rb +86 -0
  130. data/test/dummy.xorg.conf +140 -0
  131. data/test/test_gl.rb +45 -0
  132. data/test/test_gl_10_11.rb +1363 -0
  133. data/test/test_gl_12.rb +71 -0
  134. data/test/test_gl_13.rb +221 -0
  135. data/test/test_gl_14.rb +218 -0
  136. data/test/test_gl_15.rb +258 -0
  137. data/test/test_gl_20.rb +417 -0
  138. data/test/test_gl_21.rb +436 -0
  139. data/test/test_gl_ext_arb.rb +508 -0
  140. data/test/test_gl_ext_ati.rb +28 -0
  141. data/test/test_gl_ext_ext.rb +608 -0
  142. data/test/test_gl_ext_gremedy.rb +29 -0
  143. data/test/test_gl_ext_nv.rb +349 -0
  144. data/test/test_glimpl.rb +23 -0
  145. data/test/test_opengl_buffer.rb +122 -0
  146. data/utils/README +6 -0
  147. data/utils/enumgen.rb +108 -0
  148. data/utils/extlistgen.rb +90 -0
  149. metadata +326 -0
@@ -0,0 +1,155 @@
1
+ /*
2
+ * Copyright (C) 1999 - 2005 Yoshi <yoshi@giganet.net>
3
+ * Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
4
+ * Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz>
5
+ *
6
+ * This program is distributed under the terms of the MIT license.
7
+ * See the included MIT-LICENSE file for the terms of this license.
8
+ *
9
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
12
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
13
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
14
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
15
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ */
17
+
18
+ #include "common.h"
19
+
20
+ /* OpenGL 1.2 functions */
21
+
22
+ GL_FUNC_LOAD_4(BlendColor,GLvoid, GLclampf,GLclampf,GLclampf,GLclampf, "1.2")
23
+ GL_FUNC_LOAD_1(BlendEquation,GLvoid, GLenum, "1.2")
24
+ GL_FUNC_LOAD_9(CopyTexSubImage3D,GLvoid, GLenum,GLint,GLint,GLint,GLint,GLint,GLint,GLsizei,GLsizei, "1.2")
25
+
26
+ static VALUE
27
+ gl_DrawRangeElements(obj,arg1,arg2,arg3,arg4,arg5,arg6)
28
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6;
29
+ {
30
+ GLenum mode;
31
+ GLuint start;
32
+ GLuint end;
33
+ GLsizei count;
34
+ GLenum type;
35
+ DECL_GL_FUNC_PTR(GLvoid,glDrawRangeElements,(GLenum,GLuint,GLuint,GLsizei,GLenum,GLvoid*));
36
+ LOAD_GL_FUNC(glDrawRangeElements, "1.2");
37
+ mode = (GLenum)NUM2INT(arg1);
38
+ start = (GLuint)NUM2UINT(arg2);
39
+ end = (GLuint)NUM2UINT(arg3);
40
+ count = (GLsizei)NUM2UINT(arg4);
41
+ type = (GLenum)NUM2INT(arg5);
42
+ if (CHECK_BUFFER_BINDING(GL_ELEMENT_ARRAY_BUFFER_BINDING)) {
43
+ fptr_glDrawRangeElements(mode, start, end, count, type, (GLvoid *)NUM2SIZET(arg6));
44
+ } else {
45
+ VALUE data;
46
+ data = pack_array_or_pass_string(type,arg6);
47
+ fptr_glDrawRangeElements(mode, start, end, count, type, RSTRING_PTR(data));
48
+ }
49
+ CHECK_GLERROR_FROM("glDrawRangeElements");
50
+ return Qnil;
51
+ }
52
+
53
+ static VALUE
54
+ gl_TexImage3D(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)
55
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10;
56
+ {
57
+ GLenum target;
58
+ GLint level;
59
+ GLint internalFormat;
60
+ GLsizei width;
61
+ GLsizei height;
62
+ GLsizei depth;
63
+ GLint border;
64
+ GLenum format;
65
+ GLenum type;
66
+ const char *pixels;
67
+ DECL_GL_FUNC_PTR(GLvoid,glTexImage3D,(GLenum,GLint,GLint,GLsizei,GLsizei,GLsizei,GLint,GLenum,GLenum,const GLvoid*));
68
+ LOAD_GL_FUNC(glTexImage3D, "1.2");
69
+ target = (GLenum)NUM2INT(arg1);
70
+ level = (GLint)NUM2INT(arg2);
71
+ internalFormat = (GLint)NUM2INT(arg3);
72
+ width = (GLsizei)NUM2UINT(arg4);
73
+ height = (GLsizei)NUM2UINT(arg5);
74
+ depth = (GLsizei)NUM2UINT(arg6);
75
+ border = (GLint)NUM2INT(arg7);
76
+ format = (GLenum)NUM2INT(arg8);
77
+ type = (GLenum)NUM2INT(arg9);
78
+
79
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_UNPACK_BUFFER_BINDING)) {
80
+ fptr_glTexImage3D( target, level, internalFormat, width, height,
81
+ depth, border, format, type,(GLvoid *)NUM2SIZET(arg10));
82
+ CHECK_GLERROR_FROM("glTexImage3D");
83
+ return Qnil;
84
+ }
85
+
86
+ if (target == GL_PROXY_TEXTURE_3D ||
87
+ target == GL_PROXY_TEXTURE_1D_STACK_MESAX ||
88
+ target == GL_PROXY_TEXTURE_2D_STACK_MESAX ||
89
+ target == GL_PROXY_TEXTURE_2D_ARRAY_EXT ||
90
+ NIL_P(arg10)) { /* proxy texture, no data read */
91
+ pixels = NULL;
92
+ } else {
93
+ VALUE data;
94
+ data = pack_array_or_pass_string(type,arg10);
95
+
96
+ CheckDataSize(type,format,width*height*depth,data);
97
+ pixels = RSTRING_PTR(data);
98
+ }
99
+ fptr_glTexImage3D( target, level, internalFormat, width, height,
100
+ depth, border, format, type,pixels);
101
+ CHECK_GLERROR_FROM("glTexImage3D");
102
+ return Qnil;
103
+ }
104
+
105
+ static VALUE
106
+ gl_TexSubImage3D(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11)
107
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11;
108
+ {
109
+ GLenum target;
110
+ GLint level;
111
+ GLint xoffset;
112
+ GLint yoffset;
113
+ GLint zoffset;
114
+ GLsizei width;
115
+ GLsizei height;
116
+ GLsizei depth;
117
+ GLenum format;
118
+ GLenum type;
119
+ DECL_GL_FUNC_PTR(GLvoid,glTexSubImage3D,(GLenum,GLint,GLint,GLint,GLint,GLsizei,GLsizei,GLsizei,GLenum,GLenum,const GLvoid*));
120
+ LOAD_GL_FUNC(glTexSubImage3D, "1.2");
121
+ target = (GLenum)NUM2INT(arg1);
122
+ level = (GLint)NUM2INT(arg2);
123
+ xoffset = (GLint)NUM2INT(arg3);
124
+ yoffset = (GLint)NUM2INT(arg4);
125
+ zoffset = (GLint)NUM2INT(arg5);
126
+ width = (GLsizei)NUM2UINT(arg6);
127
+ height = (GLsizei)NUM2UINT(arg7);
128
+ depth = (GLsizei)NUM2UINT(arg8);
129
+ format = (GLenum)NUM2INT(arg9);
130
+ type = (GLenum)NUM2INT(arg10);
131
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_UNPACK_BUFFER_BINDING)) {
132
+ fptr_glTexSubImage3D( target, level, xoffset, yoffset, zoffset,
133
+ width, height, depth,
134
+ format, type, (GLvoid *)NUM2SIZET(arg11));
135
+ } else {
136
+ VALUE data;
137
+ data = pack_array_or_pass_string(type,arg11);
138
+ CheckDataSize(type,format,height*width*depth,data);
139
+ fptr_glTexSubImage3D( target, level, xoffset, yoffset, zoffset,
140
+ width, height, depth,
141
+ format, type, RSTRING_PTR(data));
142
+ }
143
+ CHECK_GLERROR_FROM("glTexSubImage3D");
144
+ return Qnil;
145
+ }
146
+
147
+ void gl_init_functions_1_2(VALUE klass)
148
+ {
149
+ rb_define_method(klass, "glBlendColor", gl_BlendColor, 4);
150
+ rb_define_method(klass, "glBlendEquation", gl_BlendEquation, 1);
151
+ rb_define_method(klass, "glDrawRangeElements", gl_DrawRangeElements, 6);
152
+ rb_define_method(klass, "glTexImage3D", gl_TexImage3D, 10);
153
+ rb_define_method(klass, "glTexSubImage3D", gl_TexSubImage3D, 11);
154
+ rb_define_method(klass, "glCopyTexSubImage3D", gl_CopyTexSubImage3D, 9);
155
+ }
@@ -0,0 +1,447 @@
1
+ /*
2
+ * Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz>
3
+ *
4
+ * This program is distributed under the terms of the MIT license.
5
+ * See the included MIT-LICENSE file for the terms of this license.
6
+ *
7
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
10
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
11
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
12
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
13
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+ */
15
+
16
+ #include "common.h"
17
+
18
+ /* OpenGL 1.3 functions */
19
+
20
+ GL_FUNC_LOAD_1(ActiveTexture,GLvoid, GLenum, "1.3")
21
+ GL_FUNC_LOAD_1(ClientActiveTexture,GLvoid, GLenum, "1.3")
22
+ GL_FUNC_LOAD_2(MultiTexCoord1d,GLvoid, GLenum,GLdouble, "1.3")
23
+ GL_FUNC_LOAD_2(MultiTexCoord1f,GLvoid, GLenum,GLfloat, "1.3")
24
+ GL_FUNC_LOAD_2(MultiTexCoord1i,GLvoid, GLenum,GLint, "1.3")
25
+ GL_FUNC_LOAD_2(MultiTexCoord1s,GLvoid, GLenum,GLshort, "1.3")
26
+ GL_FUNC_LOAD_3(MultiTexCoord2d,GLvoid, GLenum,GLdouble,GLdouble, "1.3")
27
+ GL_FUNC_LOAD_3(MultiTexCoord2f,GLvoid, GLenum,GLfloat,GLfloat, "1.3")
28
+ GL_FUNC_LOAD_3(MultiTexCoord2i,GLvoid, GLenum,GLint,GLint, "1.3")
29
+ GL_FUNC_LOAD_3(MultiTexCoord2s,GLvoid, GLenum,GLshort,GLshort, "1.3")
30
+ GL_FUNC_LOAD_4(MultiTexCoord3d,GLvoid, GLenum,GLdouble,GLdouble,GLdouble, "1.3")
31
+ GL_FUNC_LOAD_4(MultiTexCoord3f,GLvoid, GLenum,GLfloat,GLfloat,GLfloat, "1.3")
32
+ GL_FUNC_LOAD_4(MultiTexCoord3i,GLvoid, GLenum,GLint,GLint,GLint, "1.3")
33
+ GL_FUNC_LOAD_4(MultiTexCoord3s,GLvoid, GLenum,GLshort,GLshort,GLshort, "1.3")
34
+ GL_FUNC_LOAD_5(MultiTexCoord4d,GLvoid, GLenum,GLdouble,GLdouble,GLdouble,GLdouble, "1.3")
35
+ GL_FUNC_LOAD_5(MultiTexCoord4f,GLvoid, GLenum,GLfloat,GLfloat,GLfloat,GLfloat, "1.3")
36
+ GL_FUNC_LOAD_5(MultiTexCoord4i,GLvoid, GLenum,GLint,GLint,GLint,GLint, "1.3")
37
+ GL_FUNC_LOAD_5(MultiTexCoord4s,GLvoid, GLenum,GLshort,GLshort,GLshort,GLshort, "1.3")
38
+ GL_FUNC_LOAD_2(SampleCoverage,GLvoid, GLclampf,GLboolean, "1.3")
39
+
40
+ #define GLMULTITEXCOORD_VFUNC(_type_) \
41
+ static VALUE \
42
+ gl_MultiTexCoord##_type_##v(argc,argv,obj) \
43
+ int argc; \
44
+ VALUE *argv; \
45
+ VALUE obj; \
46
+ { \
47
+ int num; \
48
+ VALUE ary, args[5]; \
49
+ switch (num = rb_scan_args(argc, argv, "23", &args[0], &args[1], &args[2], &args[3], &args[4])) { \
50
+ case 2: \
51
+ if (TYPE(args[1]) == T_ARRAY) { \
52
+ ary = args[1]; \
53
+ switch (RARRAY_LEN(ary)) { \
54
+ case 1: \
55
+ gl_MultiTexCoord1##_type_(obj,args[0],RARRAY_PTR(ary)[0]); \
56
+ break; \
57
+ case 2: \
58
+ gl_MultiTexCoord2##_type_(obj,args[0],RARRAY_PTR(ary)[0],RARRAY_PTR(ary)[1]); \
59
+ break; \
60
+ case 3: \
61
+ gl_MultiTexCoord3##_type_(obj,args[0],RARRAY_PTR(ary)[0],RARRAY_PTR(ary)[1],RARRAY_PTR(ary)[2]); \
62
+ break; \
63
+ case 4: \
64
+ gl_MultiTexCoord4##_type_(obj,args[0],RARRAY_PTR(ary)[0],RARRAY_PTR(ary)[1],RARRAY_PTR(ary)[2],RARRAY_PTR(ary)[3]); \
65
+ break; \
66
+ default: \
67
+ rb_raise(rb_eArgError, "array length:%d", num); \
68
+ } \
69
+ } \
70
+ else { \
71
+ gl_MultiTexCoord1##_type_(obj,args[0], args[1]); \
72
+ break; \
73
+ } \
74
+ break; \
75
+ case 3: \
76
+ gl_MultiTexCoord2##_type_(obj,args[0], args[1], args[2]); \
77
+ break; \
78
+ case 4: \
79
+ gl_MultiTexCoord3##_type_(obj,args[0], args[1], args[2], args[3]); \
80
+ break; \
81
+ case 5: \
82
+ gl_MultiTexCoord4##_type_(obj,args[0], args[1], args[2], args[3], args[4]); \
83
+ break; \
84
+ default: \
85
+ rb_raise(rb_eArgError, "too many arguments"); \
86
+ break; \
87
+ } \
88
+ return Qnil; \
89
+ }
90
+
91
+ GLMULTITEXCOORD_VFUNC(d)
92
+ GLMULTITEXCOORD_VFUNC(f)
93
+ GLMULTITEXCOORD_VFUNC(i)
94
+ GLMULTITEXCOORD_VFUNC(s)
95
+ #undef GLTEXCOORD_VFUNC
96
+
97
+ #define TRANSPOSEMATRIX_FUNC(_name_,_type_) \
98
+ static VALUE \
99
+ gl_##_name_(obj,arg1) \
100
+ VALUE obj,arg1; \
101
+ { \
102
+ _type_ m[4*4]; \
103
+ DECL_GL_FUNC_PTR(GLvoid,gl##_name_,(const _type_[])); \
104
+ LOAD_GL_FUNC(gl##_name_, "1.3"); \
105
+ ary2cmat##_type_(arg1, m, 4, 4); \
106
+ fptr_gl##_name_(m); \
107
+ CHECK_GLERROR_FROM("gl" #_name_); \
108
+ return Qnil; \
109
+ }
110
+
111
+ TRANSPOSEMATRIX_FUNC(LoadTransposeMatrixf,float)
112
+ TRANSPOSEMATRIX_FUNC(LoadTransposeMatrixd,double)
113
+ TRANSPOSEMATRIX_FUNC(MultTransposeMatrixf,float)
114
+ TRANSPOSEMATRIX_FUNC(MultTransposeMatrixd,double)
115
+
116
+ #undef TRANSPOSEMATRIX_FUNC
117
+
118
+ static VALUE
119
+ gl_CompressedTexImage3D(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
120
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9;
121
+ {
122
+ GLenum target;
123
+ GLint level;
124
+ GLenum internalformat;
125
+ GLsizei width;
126
+ GLsizei height;
127
+ GLsizei depth;
128
+ GLint border;
129
+ GLsizei imagesize;
130
+ GLvoid *pixels;
131
+ DECL_GL_FUNC_PTR(GLvoid,glCompressedTexImage3D,(GLenum,GLint,GLenum,GLsizei,GLsizei,GLsizei,GLint,GLsizei,GLvoid*));
132
+ LOAD_GL_FUNC(glCompressedTexImage3D, "1.3");
133
+ target = (GLenum)NUM2INT(arg1);
134
+ level = (GLint)NUM2INT(arg2);
135
+ internalformat = (GLenum)NUM2INT(arg3);
136
+ width = (GLsizei)NUM2UINT(arg4);
137
+ height = (GLsizei)NUM2UINT(arg5);
138
+ depth = (GLsizei)NUM2UINT(arg6);
139
+ border = (GLint)NUM2INT(arg7);
140
+ imagesize = (GLsizei)NUM2UINT(arg8);
141
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_UNPACK_BUFFER_BINDING)) {
142
+ fptr_glCompressedTexImage3D(target,level,internalformat,width,height,depth,border,imagesize,(GLvoid *)NUM2SIZET(arg9));
143
+ } else {
144
+ if (TYPE(arg9) == T_STRING || TYPE(arg9) == T_ARRAY) {
145
+ VALUE data;
146
+ data = pack_array_or_pass_string(GL_UNSIGNED_BYTE,arg9);
147
+ if (RSTRING_LEN(data) < imagesize)
148
+ rb_raise(rb_eArgError, "string length:%li",RSTRING_LEN(data));
149
+ pixels = RSTRING_PTR(data);
150
+ } else if (NIL_P(arg9)) {
151
+ pixels = NULL;
152
+ } else {
153
+ Check_Type(arg9,T_STRING); /* force exception */
154
+ return Qnil;
155
+ }
156
+ fptr_glCompressedTexImage3D(target,level,internalformat,width,height,depth,border,imagesize,pixels);
157
+ }
158
+ CHECK_GLERROR_FROM("glCompressedTexImage3D");
159
+ return Qnil;
160
+ }
161
+
162
+ static VALUE
163
+ gl_CompressedTexImage2D(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)
164
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8;
165
+ {
166
+ GLenum target;
167
+ GLint level;
168
+ GLenum internalformat;
169
+ GLsizei width;
170
+ GLsizei height;
171
+ GLint border;
172
+ GLsizei imagesize;
173
+ GLvoid *pixels;
174
+ DECL_GL_FUNC_PTR(GLvoid,glCompressedTexImage2D,(GLenum,GLint,GLenum,GLsizei,GLsizei,GLint,GLsizei,GLvoid*));
175
+ LOAD_GL_FUNC(glCompressedTexImage2D, "1.3");
176
+ target = (GLenum)NUM2INT(arg1);
177
+ level = (GLint)NUM2INT(arg2);
178
+ internalformat = (GLenum)NUM2INT(arg3);
179
+ width = (GLsizei)NUM2UINT(arg4);
180
+ height = (GLsizei)NUM2UINT(arg5);
181
+ border = (GLint)NUM2INT(arg6);
182
+ imagesize = (GLsizei)NUM2UINT(arg7);
183
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_UNPACK_BUFFER_BINDING)) {
184
+ fptr_glCompressedTexImage2D(target,level,internalformat,width,height,border,imagesize,(GLvoid *)NUM2SIZET(arg8));
185
+ } else {
186
+ if (TYPE(arg8) == T_STRING || TYPE(arg8) == T_ARRAY) {
187
+ VALUE data;
188
+ data = pack_array_or_pass_string(GL_UNSIGNED_BYTE,arg8);
189
+ if (RSTRING_LEN(data) < imagesize)
190
+ rb_raise(rb_eArgError, "string length:%li",RSTRING_LEN(data));
191
+ pixels = RSTRING_PTR(data);
192
+ } else if (NIL_P(arg8)) {
193
+ pixels = NULL;
194
+ } else {
195
+ Check_Type(arg8,T_STRING); /* force exception */
196
+ return Qnil;
197
+ }
198
+ fptr_glCompressedTexImage2D(target,level,internalformat,width,height,border,imagesize,pixels);
199
+ }
200
+ CHECK_GLERROR_FROM("glCompressedTexImage2D");
201
+ return Qnil;
202
+ }
203
+
204
+ static VALUE
205
+ gl_CompressedTexImage1D(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
206
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7;
207
+ {
208
+ GLenum target;
209
+ GLint level;
210
+ GLenum internalformat;
211
+ GLsizei width;
212
+ GLint border;
213
+ GLsizei imagesize;
214
+ GLvoid *pixels;
215
+ DECL_GL_FUNC_PTR(GLvoid,glCompressedTexImage1D,(GLenum,GLint,GLenum,GLsizei,GLint,GLsizei,GLvoid*));
216
+ LOAD_GL_FUNC(glCompressedTexImage1D, "1.3");
217
+ target = (GLenum)NUM2INT(arg1);
218
+ level = (GLint)NUM2INT(arg2);
219
+ internalformat = (GLenum)NUM2INT(arg3);
220
+ width = (GLsizei)NUM2UINT(arg4);
221
+ border = (GLint)NUM2INT(arg5);
222
+ imagesize = (GLsizei)NUM2UINT(arg6);
223
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_UNPACK_BUFFER_BINDING)) {
224
+ fptr_glCompressedTexImage1D(target,level,internalformat,width,border,imagesize,(GLvoid *)NUM2SIZET(arg7));
225
+ } else {
226
+ if (TYPE(arg7) == T_STRING || TYPE(arg7) == T_ARRAY) {
227
+ VALUE data;
228
+ data = pack_array_or_pass_string(GL_UNSIGNED_BYTE,arg7);
229
+ if (RSTRING_LEN(data) < imagesize)
230
+ rb_raise(rb_eArgError, "string length:%li",RSTRING_LEN(data));
231
+ pixels = RSTRING_PTR(data);
232
+ } else if (NIL_P(arg7)) {
233
+ pixels = NULL;
234
+ } else {
235
+ Check_Type(arg7,T_STRING); /* force exception */
236
+ return Qnil;
237
+ }
238
+ fptr_glCompressedTexImage1D(target,level,internalformat,width,border,imagesize,pixels);
239
+ }
240
+ CHECK_GLERROR_FROM("glCompressedTexImage1D");
241
+ return Qnil;
242
+ }
243
+
244
+ static VALUE
245
+ gl_CompressedTexSubImage3D(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11)
246
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11;
247
+ {
248
+ GLenum target;
249
+ GLint level;
250
+ GLint xoffset;
251
+ GLint yoffset;
252
+ GLint zoffset;
253
+ GLsizei width;
254
+ GLsizei height;
255
+ GLsizei depth;
256
+ GLenum format;
257
+ GLsizei imagesize;
258
+ GLvoid *pixels;
259
+ DECL_GL_FUNC_PTR(GLvoid,glCompressedTexSubImage3D,(GLenum,GLint,GLint,GLint,GLint,GLsizei,GLsizei,GLsizei,GLenum,GLsizei,GLvoid*));
260
+ LOAD_GL_FUNC(glCompressedTexSubImage3D, "1.3");
261
+ target = (GLenum)NUM2INT(arg1);
262
+ level = (GLint)NUM2INT(arg2);
263
+ xoffset = (GLint)NUM2INT(arg3);
264
+ yoffset = (GLint)NUM2INT(arg4);
265
+ zoffset = (GLint)NUM2INT(arg5);
266
+ width = (GLsizei)NUM2UINT(arg6);
267
+ height = (GLsizei)NUM2UINT(arg7);
268
+ depth = (GLsizei)NUM2UINT(arg8);
269
+ format = (GLenum)NUM2INT(arg9);
270
+ imagesize = (GLsizei)NUM2UINT(arg10);
271
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_UNPACK_BUFFER_BINDING)) {
272
+ fptr_glCompressedTexSubImage3D(target,level,xoffset,yoffset,zoffset,width,height,depth,format,imagesize,(GLvoid *)NUM2SIZET(arg11));
273
+ } else {
274
+ VALUE data;
275
+ data = pack_array_or_pass_string(GL_UNSIGNED_BYTE,arg11);
276
+ if (RSTRING_LEN(data) < imagesize)
277
+ rb_raise(rb_eArgError, "string length:%li",RSTRING_LEN(data));
278
+ pixels = RSTRING_PTR(data);
279
+
280
+ fptr_glCompressedTexSubImage3D(target,level,xoffset,yoffset,zoffset,width,height,depth,format,imagesize,pixels);
281
+ }
282
+ CHECK_GLERROR_FROM("glCompressedTexSubImage3D");
283
+ return Qnil;
284
+ }
285
+
286
+ static VALUE
287
+ gl_CompressedTexSubImage2D(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
288
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9;
289
+ {
290
+ GLenum target;
291
+ GLint level;
292
+ GLint xoffset;
293
+ GLint yoffset;
294
+ GLsizei width;
295
+ GLsizei height;
296
+ GLenum format;
297
+ GLsizei imagesize;
298
+ GLvoid *pixels;
299
+ DECL_GL_FUNC_PTR(GLvoid,glCompressedTexSubImage2D,(GLenum,GLint,GLint,GLint,GLsizei,GLsizei,GLenum,GLsizei,GLvoid*));
300
+ LOAD_GL_FUNC(glCompressedTexSubImage2D, "1.3");
301
+ target = (GLenum)NUM2INT(arg1);
302
+ level = (GLint)NUM2INT(arg2);
303
+ xoffset = (GLint)NUM2INT(arg3);
304
+ yoffset = (GLint)NUM2INT(arg4);
305
+ width = (GLsizei)NUM2UINT(arg5);
306
+ height = (GLsizei)NUM2UINT(arg6);
307
+ format = (GLenum)NUM2INT(arg7);
308
+ imagesize = (GLsizei)NUM2UINT(arg8);
309
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_UNPACK_BUFFER_BINDING)) {
310
+ fptr_glCompressedTexSubImage2D(target,level,xoffset,yoffset,width,height,format,imagesize,(GLvoid *)NUM2SIZET(arg9));
311
+ } else {
312
+ VALUE data;
313
+ data = pack_array_or_pass_string(GL_UNSIGNED_BYTE,arg9);
314
+ if (RSTRING_LEN(data) < imagesize)
315
+ rb_raise(rb_eArgError, "string length:%li",RSTRING_LEN(data));
316
+ pixels = RSTRING_PTR(data);
317
+ fptr_glCompressedTexSubImage2D(target,level,xoffset,yoffset,width,height,format,imagesize,pixels);
318
+ }
319
+ CHECK_GLERROR_FROM("glCompressedTexSubImage2D");
320
+ return Qnil;
321
+ }
322
+
323
+ static VALUE
324
+ gl_CompressedTexSubImage1D(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
325
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7;
326
+ {
327
+ GLenum target;
328
+ GLint level;
329
+ GLint xoffset;
330
+ GLsizei width;
331
+ GLenum format;
332
+ GLsizei imagesize;
333
+ GLvoid *pixels;
334
+ DECL_GL_FUNC_PTR(GLvoid,glCompressedTexSubImage1D,(GLenum,GLint,GLint,GLsizei,GLenum,GLsizei,GLvoid*));
335
+ LOAD_GL_FUNC(glCompressedTexSubImage1D, "1.3");
336
+ target = (GLenum)NUM2INT(arg1);
337
+ level = (GLint)NUM2INT(arg2);
338
+ xoffset = (GLint)NUM2INT(arg3);
339
+ width = (GLsizei)NUM2UINT(arg4);
340
+ format = (GLenum)NUM2INT(arg5);
341
+ imagesize = (GLsizei)NUM2UINT(arg6);
342
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_UNPACK_BUFFER_BINDING)) {
343
+ fptr_glCompressedTexSubImage1D(target,level,xoffset,width,format,imagesize,(GLvoid *)NUM2SIZET(arg7));
344
+ } else {
345
+ VALUE data;
346
+ data = pack_array_or_pass_string(GL_UNSIGNED_BYTE,arg7);
347
+ if (RSTRING_LEN(data) < imagesize)
348
+ rb_raise(rb_eArgError, "string length:%li",RSTRING_LEN(data));
349
+ pixels = RSTRING_PTR(data);
350
+ fptr_glCompressedTexSubImage1D(target,level,xoffset,width,format,imagesize,pixels);
351
+ }
352
+ CHECK_GLERROR_FROM("glCompressedTexSubImage1D");
353
+ return Qnil;
354
+ }
355
+
356
+ static VALUE
357
+ gl_GetCompressedTexImage(argc,argv,obj)
358
+ int argc;
359
+ VALUE *argv;
360
+ VALUE obj;
361
+ {
362
+ GLenum target;
363
+ GLint lod;
364
+ GLsizei size = 0;
365
+ VALUE data;
366
+ VALUE args[3];
367
+ int numargs;
368
+ DECL_GL_FUNC_PTR(GLvoid,glGetCompressedTexImage,(GLenum,GLint,GLvoid*));
369
+ LOAD_GL_FUNC(glGetCompressedTexImage, "1.3");
370
+ numargs = rb_scan_args(argc, argv, "21", &args[0], &args[1], &args[2]);
371
+ target = (GLenum)NUM2INT(args[0]);
372
+ lod = (GLenum)NUM2INT(args[1]);
373
+ switch(numargs) {
374
+ default:
375
+ case 2:
376
+ if (CHECK_BUFFER_BINDING(GL_PIXEL_PACK_BUFFER_BINDING))
377
+ rb_raise(rb_eArgError, "Pixel pack buffer bound, but offset argument missing");
378
+ {
379
+ DECL_GL_FUNC_PTR(void,glGetTexLevelParameteriv,(GLenum target, GLint level, GLenum pname, GLint *params));
380
+ LOAD_GL_FUNC(glGetTexLevelParameteriv, NULL);
381
+ fptr_glGetTexLevelParameteriv(target,lod,GL_TEXTURE_COMPRESSED_IMAGE_SIZE,&size); /* 1.0 function */
382
+ }
383
+ CHECK_GLERROR_FROM("glGetTexLevelParameteriv");
384
+ data = allocate_buffer_with_string(size);
385
+ fptr_glGetCompressedTexImage(target,lod,(GLvoid*)RSTRING_PTR(data));
386
+ CHECK_GLERROR_FROM("glGetCompressedTexImage");
387
+ return data;
388
+ case 3:
389
+ fptr_glGetCompressedTexImage(target,lod,(GLvoid*)NUM2SIZET(args[2]));
390
+ CHECK_GLERROR_FROM("glGetCompressedTexImage");
391
+ return Qnil;
392
+ }
393
+ }
394
+
395
+ void gl_init_functions_1_3(VALUE klass)
396
+ {
397
+ rb_define_method(klass, "glActiveTexture", gl_ActiveTexture, 1);
398
+ rb_define_method(klass, "glClientActiveTexture", gl_ClientActiveTexture, 1);
399
+ rb_define_method(klass, "glMultiTexCoord1d", gl_MultiTexCoord1d, 2);
400
+ rb_define_method(klass, "glMultiTexCoord1f", gl_MultiTexCoord1f, 2);
401
+ rb_define_method(klass, "glMultiTexCoord1i", gl_MultiTexCoord1i, 2);
402
+ rb_define_method(klass, "glMultiTexCoord1s", gl_MultiTexCoord1s, 2);
403
+ rb_define_method(klass, "glMultiTexCoord2d", gl_MultiTexCoord2d, 3);
404
+ rb_define_method(klass, "glMultiTexCoord2f", gl_MultiTexCoord2f, 3);
405
+ rb_define_method(klass, "glMultiTexCoord2i", gl_MultiTexCoord2i, 3);
406
+ rb_define_method(klass, "glMultiTexCoord2s", gl_MultiTexCoord2s, 3);
407
+ rb_define_method(klass, "glMultiTexCoord3d", gl_MultiTexCoord3d, 4);
408
+ rb_define_method(klass, "glMultiTexCoord3f", gl_MultiTexCoord3f, 4);
409
+ rb_define_method(klass, "glMultiTexCoord3i", gl_MultiTexCoord3i, 4);
410
+ rb_define_method(klass, "glMultiTexCoord3s", gl_MultiTexCoord3s, 4);
411
+ rb_define_method(klass, "glMultiTexCoord4d", gl_MultiTexCoord4d, 5);
412
+ rb_define_method(klass, "glMultiTexCoord4f", gl_MultiTexCoord4f, 5);
413
+ rb_define_method(klass, "glMultiTexCoord4i", gl_MultiTexCoord4i, 5);
414
+ rb_define_method(klass, "glMultiTexCoord4s", gl_MultiTexCoord4s, 5);
415
+ rb_define_method(klass, "glLoadTransposeMatrixf", gl_LoadTransposeMatrixf, 1);
416
+ rb_define_method(klass, "glLoadTransposeMatrixd", gl_LoadTransposeMatrixd, 1);
417
+ rb_define_method(klass, "glMultTransposeMatrixf", gl_MultTransposeMatrixf, 1);
418
+ rb_define_method(klass, "glMultTransposeMatrixd", gl_MultTransposeMatrixd, 1);
419
+ rb_define_method(klass, "glSampleCoverage", gl_SampleCoverage, 2);
420
+ rb_define_method(klass, "glCompressedTexImage3D", gl_CompressedTexImage3D, 9);
421
+ rb_define_method(klass, "glCompressedTexImage2D", gl_CompressedTexImage2D, 8);
422
+ rb_define_method(klass, "glCompressedTexImage1D", gl_CompressedTexImage1D, 7);
423
+ rb_define_method(klass, "glCompressedTexSubImage3D", gl_CompressedTexSubImage3D, 11);
424
+ rb_define_method(klass, "glCompressedTexSubImage2D", gl_CompressedTexSubImage2D, 9);
425
+ rb_define_method(klass, "glCompressedTexSubImage1D", gl_CompressedTexSubImage1D, 7);
426
+ rb_define_method(klass, "glGetCompressedTexImage", gl_GetCompressedTexImage, -1);
427
+
428
+ /* Additional functions */
429
+
430
+ rb_define_method(klass, "glMultiTexCoord", gl_MultiTexCoorddv, -1);
431
+ rb_define_method(klass, "glMultiTexCoord1dv", gl_MultiTexCoorddv, -1);
432
+ rb_define_method(klass, "glMultiTexCoord1fv", gl_MultiTexCoordfv, -1);
433
+ rb_define_method(klass, "glMultiTexCoord1iv", gl_MultiTexCoordiv, -1);
434
+ rb_define_method(klass, "glMultiTexCoord1sv", gl_MultiTexCoordsv, -1);
435
+ rb_define_method(klass, "glMultiTexCoord2dv", gl_MultiTexCoorddv, -1);
436
+ rb_define_method(klass, "glMultiTexCoord2fv", gl_MultiTexCoordfv, -1);
437
+ rb_define_method(klass, "glMultiTexCoord2iv", gl_MultiTexCoordiv, -1);
438
+ rb_define_method(klass, "glMultiTexCoord2sv", gl_MultiTexCoordsv, -1);
439
+ rb_define_method(klass, "glMultiTexCoord3dv", gl_MultiTexCoorddv, -1);
440
+ rb_define_method(klass, "glMultiTexCoord3fv", gl_MultiTexCoordfv, -1);
441
+ rb_define_method(klass, "glMultiTexCoord3iv", gl_MultiTexCoordiv, -1);
442
+ rb_define_method(klass, "glMultiTexCoord3sv", gl_MultiTexCoordsv, -1);
443
+ rb_define_method(klass, "glMultiTexCoord4dv", gl_MultiTexCoorddv, -1);
444
+ rb_define_method(klass, "glMultiTexCoord4fv", gl_MultiTexCoordfv, -1);
445
+ rb_define_method(klass, "glMultiTexCoord4iv", gl_MultiTexCoordiv, -1);
446
+ rb_define_method(klass, "glMultiTexCoord4sv", gl_MultiTexCoordsv, -1);
447
+ }