ruby-opengl 0.33.0

Sign up to get free protection for your applications and to get access to all the features.
data/ext/gl/gl-1.2.c ADDED
@@ -0,0 +1,166 @@
1
+ /*
2
+ * Copyright (C) 1999 - 2005 Yoshi <yoshi@giganet.net>
3
+ * Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
4
+ *
5
+ * This program is distributed under the terms of the MIT license.
6
+ * See the included MIT-LICENSE file for the terms of this license.
7
+ *
8
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
9
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
11
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
12
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
13
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
14
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ */
16
+
17
+ #ifdef __APPLE__
18
+ #include <OpenGL/gl.h>
19
+ #elif defined WIN32
20
+ #include <windows.h>
21
+ #include <GL/gl.h>
22
+ #else
23
+ #include <GL/gl.h>
24
+ #endif
25
+ #include "../common/rbogl.h"
26
+ #include "../common/gl-enums.h"
27
+
28
+ /* OpenGL 1.2 functions */
29
+
30
+ /*
31
+ VALUE
32
+ gl_DrawRangeElements(obj,arg1,arg2,arg3,arg4,arg5,arg6)
33
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6;
34
+ {
35
+ GLenum mode;
36
+ GLuint start;
37
+ GLuint end;
38
+ GLsizei count;
39
+ GLenum type;
40
+ mode = (GLenum)NUM2INT(arg1);
41
+ start = (GLuint)NUM2INT(arg2);
42
+ end = (GLuint)NUM2INT(arg3);
43
+ count = (GLsizei)NUM2INT(arg4);
44
+ type = (GLenum)NUM2INT(arg5);
45
+ Check_Type(arg6, T_STRING);
46
+ glDrawRangeElements(mode, start, end, count, type, RSTRING(arg6)->ptr);
47
+ return Qnil;
48
+ }
49
+ VALUE
50
+ gl_TexImage3D(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)
51
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10;
52
+ {
53
+ GLenum target;
54
+ GLint level;
55
+ GLint internalFormat;
56
+ GLsizei width;
57
+ GLsizei height;
58
+ GLsizei depth;
59
+ GLint border;
60
+ GLenum format;
61
+ GLenum type;
62
+ int size;
63
+ int type_size;
64
+ int format_size;
65
+ target = (GLenum)NUM2INT(arg1);
66
+ level = (GLint)NUM2INT(arg2);
67
+ internalFormat = (GLint)NUM2INT(arg3);
68
+ width = (GLsizei)NUM2INT(arg4);
69
+ height = (GLsizei)NUM2INT(arg5);
70
+ depth = (GLsizei)NUM2INT(arg6);
71
+ border = (GLint)NUM2INT(arg7);
72
+ format = (GLenum)NUM2INT(arg8);
73
+ type = (GLenum)NUM2INT(arg9);
74
+ Check_Type(arg10, T_STRING);
75
+ type_size = gltype_size(type) / 8;
76
+ format_size = glformat_size(format);
77
+ if (type_size == -1 || format_size == -1)
78
+ return Qnil;
79
+ size = type_size*format_size*height*width*depth;
80
+ if (RSTRING(arg10)->len < size)
81
+ rb_raise(rb_eArgError, "string length:%d",RSTRING(arg10)->len);
82
+ glTexImage3D( target, level, internalFormat, width, height,
83
+ depth, border, format, type,
84
+ (const GLvoid*)RSTRING(arg10)->ptr);
85
+ return Qnil;
86
+ }
87
+ VALUE
88
+ gl_TexSubImage3D(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11)
89
+ VALUE arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11;
90
+ {
91
+ GLenum target;
92
+ GLint level;
93
+ GLint xoffset;
94
+ GLint yoffset;
95
+ GLint zoffset;
96
+ GLsizei width;
97
+ GLsizei height;
98
+ GLsizei depth;
99
+ GLenum format;
100
+ GLenum type;
101
+ int size;
102
+ int type_size;
103
+ int format_size;
104
+ target = (GLenum)NUM2INT(arg1);
105
+ level = (GLint)NUM2INT(arg2);
106
+ xoffset = (GLint)NUM2INT(arg3);
107
+ yoffset = (GLint)NUM2INT(arg4);
108
+ zoffset = (GLint)NUM2INT(arg5);
109
+ width = (GLsizei)NUM2INT(arg6);
110
+ height = (GLsizei)NUM2INT(arg7);
111
+ depth = (GLsizei)NUM2INT(arg8);
112
+ format = (GLenum)NUM2INT(arg9);
113
+ type = (GLenum)NUM2INT(arg10);
114
+ Check_Type(arg11, T_STRING);
115
+ type_size = gltype_size(type) / 8;
116
+ format_size = glformat_size(format);
117
+ if (type_size == -1 || format_size == -1)
118
+ return Qnil;
119
+ size = type_size*format_size*height*width*depth;
120
+ if (RSTRING(arg11)->len < size)
121
+ rb_raise(rb_eArgError, "string length:%d",RSTRING(arg11)->len);
122
+ glTexSubImage3D( target, level, xoffset, yoffset, zoffset,
123
+ width, height, depth,
124
+ format, type, RSTRING(arg11)->ptr);
125
+ return Qnil;
126
+ }
127
+ VALUE
128
+ gl_CopyTexSubImage3D(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
129
+ VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9;
130
+ {
131
+ GLenum target;
132
+ GLint level;
133
+ GLint xoffset;
134
+ GLint yoffset;
135
+ GLint zoffset;
136
+ GLint x;
137
+ GLint y;
138
+ GLsizei width;
139
+ GLsizei height;
140
+ target = (GLenum)NUM2INT(arg1);
141
+ level = (GLint)NUM2INT(arg2);
142
+ xoffset = (GLint)NUM2INT(arg3);
143
+ yoffset = (GLint)NUM2INT(arg4);
144
+ zoffset = (GLint)NUM2INT(arg5);
145
+ x = (GLint)NUM2INT(arg6);
146
+ y = (GLint)NUM2INT(arg7);
147
+ width = (GLsizei)NUM2INT(arg8);
148
+ height = (GLsizei)NUM2INT(arg9);
149
+ glCopyTexSubImage3D( target, level,
150
+ xoffset, yoffset, zoffset,
151
+ x, y, width, height );
152
+ return Qnil;
153
+ }
154
+ */
155
+
156
+
157
+
158
+ void gl_init_functions_1_2(VALUE module)
159
+ {
160
+ /*
161
+ rb_define_module_function(module, "glDrawRangeElements", gl_DrawRangeElements, 6);
162
+ rb_define_module_function(module, "glTexImage3D", gl_TexImage3D, 10);
163
+ rb_define_module_function(module, "glTexSubImage3D", gl_TexSubImage3D, 11);
164
+ rb_define_module_function(module, "glCopyTexSubImage3D", gl_CopyTexSubImage3D, 9);
165
+ */
166
+ }