VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/OpenGL/MesaGL.cpp@ 8061

Last change on this file since 8061 was 5999, checked in by vboxsync, 17 years ago

The Giant CDDL Dual-License Header Change.

File size: 7.0 KB
Line 
1/** @file
2 *
3 * VirtualBox Windows NT/2000/XP guest OpenGL ICD
4 *
5 * Copyright (C) 2006-2007 innotek GmbH
6 *
7 * This file is part of VirtualBox Open Source Edition (OSE), as
8 * available from http://www.virtualbox.org. This file is free software;
9 * you can redistribute it and/or modify it under the terms of the GNU
10 * General Public License (GPL) as published by the Free Software
11 * Foundation, in version 2 as it comes in the "COPYING" file of the
12 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14 */
15/*
16 * Mesa 3-D graphics library
17 * Version: 6.5.1
18 *
19 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
20 *
21 * Permission is hereby granted, free of charge, to any person obtaining a
22 * copy of this software and associated documentation files (the "Software"),
23 * to deal in the Software without restriction, including without limitation
24 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
25 * and/or sell copies of the Software, and to permit persons to whom the
26 * Software is furnished to do so, subject to the following conditions:
27 *
28 * The above copyright notice and this permission notice shall be included
29 * in all copies or substantial portions of the Software.
30 *
31 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
32 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
34 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
35 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
36 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 */
38#include "VBoxOGL.h"
39#include <iprt/cdefs.h>
40#include <iprt/assert.h>
41
42void APIENTRY glInterleavedArrays (GLenum format, GLsizei stride, const GLvoid *pointer)
43{
44 GLboolean tflag, cflag, nflag; /* enable/disable flags */
45 GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */
46 GLenum ctype = 0; /* color type */
47 GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */
48 const GLint toffset = 0; /* always zero */
49 GLint defstride; /* default stride */
50 GLint c, f;
51
52 f = sizeof(GLfloat);
53 c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f);
54
55 if (stride < 0) {
56 glLogError(GL_INVALID_VALUE);
57 return;
58 }
59
60 switch (format) {
61 case GL_V2F:
62 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE;
63 tcomps = 0; ccomps = 0; vcomps = 2;
64 voffset = 0;
65 defstride = 2*f;
66 break;
67 case GL_V3F:
68 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE;
69 tcomps = 0; ccomps = 0; vcomps = 3;
70 voffset = 0;
71 defstride = 3*f;
72 break;
73 case GL_C4UB_V2F:
74 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
75 tcomps = 0; ccomps = 4; vcomps = 2;
76 ctype = GL_UNSIGNED_BYTE;
77 coffset = 0;
78 voffset = c;
79 defstride = c + 2*f;
80 break;
81 case GL_C4UB_V3F:
82 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
83 tcomps = 0; ccomps = 4; vcomps = 3;
84 ctype = GL_UNSIGNED_BYTE;
85 coffset = 0;
86 voffset = c;
87 defstride = c + 3*f;
88 break;
89 case GL_C3F_V3F:
90 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
91 tcomps = 0; ccomps = 3; vcomps = 3;
92 ctype = GL_FLOAT;
93 coffset = 0;
94 voffset = 3*f;
95 defstride = 6*f;
96 break;
97 case GL_N3F_V3F:
98 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_TRUE;
99 tcomps = 0; ccomps = 0; vcomps = 3;
100 noffset = 0;
101 voffset = 3*f;
102 defstride = 6*f;
103 break;
104 case GL_C4F_N3F_V3F:
105 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_TRUE;
106 tcomps = 0; ccomps = 4; vcomps = 3;
107 ctype = GL_FLOAT;
108 coffset = 0;
109 noffset = 4*f;
110 voffset = 7*f;
111 defstride = 10*f;
112 break;
113 case GL_T2F_V3F:
114 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE;
115 tcomps = 2; ccomps = 0; vcomps = 3;
116 voffset = 2*f;
117 defstride = 5*f;
118 break;
119 case GL_T4F_V4F:
120 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE;
121 tcomps = 4; ccomps = 0; vcomps = 4;
122 voffset = 4*f;
123 defstride = 8*f;
124 break;
125 case GL_T2F_C4UB_V3F:
126 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE;
127 tcomps = 2; ccomps = 4; vcomps = 3;
128 ctype = GL_UNSIGNED_BYTE;
129 coffset = 2*f;
130 voffset = c+2*f;
131 defstride = c+5*f;
132 break;
133 case GL_T2F_C3F_V3F:
134 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE;
135 tcomps = 2; ccomps = 3; vcomps = 3;
136 ctype = GL_FLOAT;
137 coffset = 2*f;
138 voffset = 5*f;
139 defstride = 8*f;
140 break;
141 case GL_T2F_N3F_V3F:
142 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_TRUE;
143 tcomps = 2; ccomps = 0; vcomps = 3;
144 noffset = 2*f;
145 voffset = 5*f;
146 defstride = 8*f;
147 break;
148 case GL_T2F_C4F_N3F_V3F:
149 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE;
150 tcomps = 2; ccomps = 4; vcomps = 3;
151 ctype = GL_FLOAT;
152 coffset = 2*f;
153 noffset = 6*f;
154 voffset = 9*f;
155 defstride = 12*f;
156 break;
157 case GL_T4F_C4F_N3F_V4F:
158 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE;
159 tcomps = 4; ccomps = 4; vcomps = 4;
160 ctype = GL_FLOAT;
161 coffset = 4*f;
162 noffset = 8*f;
163 voffset = 11*f;
164 defstride = 15*f;
165 break;
166 default:
167 glLogError(GL_INVALID_ENUM);
168 return;
169 }
170
171 if (stride==0) {
172 stride = defstride;
173 }
174
175 glDisableClientState( GL_EDGE_FLAG_ARRAY );
176 glDisableClientState( GL_INDEX_ARRAY );
177 /* XXX also disable secondary color and generic arrays? */
178
179 /* Texcoords */
180 if (tflag) {
181 glEnableClientState( GL_TEXTURE_COORD_ARRAY );
182 glTexCoordPointer( tcomps, GL_FLOAT, stride, (GLubyte *) pointer + toffset );
183 }
184 else {
185 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
186 }
187
188 /* Color */
189 if (cflag) {
190 glEnableClientState( GL_COLOR_ARRAY );
191 glColorPointer( ccomps, ctype, stride, (GLubyte *) pointer + coffset );
192 }
193 else {
194 glDisableClientState( GL_COLOR_ARRAY );
195 }
196
197
198 /* Normals */
199 if (nflag) {
200 glEnableClientState( GL_NORMAL_ARRAY );
201 glNormalPointer( GL_FLOAT, stride, (GLubyte *) pointer + noffset );
202 }
203 else {
204 glDisableClientState( GL_NORMAL_ARRAY );
205 }
206
207 /* Vertices */
208 glEnableClientState( GL_VERTEX_ARRAY );
209 glVertexPointer( vcomps, GL_FLOAT, stride, (GLubyte *) pointer + voffset );
210}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette