VirtualBox

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

Last change on this file since 3787 was 3339, checked in by vboxsync, 18 years ago

Export to OSE

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

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