1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox Windows NT/2000/XP guest OpenGL ICD
|
---|
4 | *
|
---|
5 | * Parameter size helpers
|
---|
6 | *
|
---|
7 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | *
|
---|
21 | */
|
---|
22 |
|
---|
23 | #include "VBoxOGL.h"
|
---|
24 | #include <iprt/cdefs.h>
|
---|
25 | #include <iprt/assert.h>
|
---|
26 |
|
---|
27 | /* DataType */
|
---|
28 | static GLuint glDataTypeSize[11] =
|
---|
29 | {
|
---|
30 | /* GL_BYTE */ sizeof(GLbyte),
|
---|
31 | /* GL_UNSIGNED_BYTE */ sizeof(GLubyte),
|
---|
32 | /* GL_SHORT */ sizeof(GLshort),
|
---|
33 | /* GL_UNSIGNED_SHORT */ sizeof(GLushort),
|
---|
34 | /* GL_INT */ sizeof(GLint),
|
---|
35 | /* GL_UNSIGNED_INT */ sizeof(GLuint),
|
---|
36 | /* GL_FLOAT */ sizeof(GLfloat),
|
---|
37 | /* GL_2_BYTES */ 2,
|
---|
38 | /* GL_3_BYTES */ 3,
|
---|
39 | /* GL_4_BYTES */ 4,
|
---|
40 | /* GL_DOUBLE */ sizeof(GLdouble),
|
---|
41 | };
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Query the size of the specified data type
|
---|
45 | *
|
---|
46 | * @returns type size or 0 if unknown type
|
---|
47 | * @param type data type
|
---|
48 | */
|
---|
49 | GLint glVBoxGetDataTypeSize(GLenum type)
|
---|
50 | {
|
---|
51 | if (type - GL_BYTE >= RT_ELEMENTS(glDataTypeSize))
|
---|
52 | {
|
---|
53 | return 0;
|
---|
54 | }
|
---|
55 | return glDataTypeSize[type-GL_BYTE];
|
---|
56 | }
|
---|
57 |
|
---|
58 | /**
|
---|
59 | * Query the specified cached parameter
|
---|
60 | *
|
---|
61 | * @returns requested cached value
|
---|
62 | * @param type Parameter type (Note: minimal checks only!)
|
---|
63 | */
|
---|
64 | GLint glInternalGetIntegerv(GLenum type)
|
---|
65 | {
|
---|
66 | AssertFailed();
|
---|
67 | return 0;
|
---|
68 | }
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * Query the specified cached texture level parameter
|
---|
72 | *
|
---|
73 | * @returns requested cached value
|
---|
74 | * @param type Parameter type (Note: minimal checks only!)
|
---|
75 | */
|
---|
76 | GLint glInternalGetTexLevelParameteriv(GLenum type)
|
---|
77 | {
|
---|
78 | AssertFailed();
|
---|
79 | return 0;
|
---|
80 | }
|
---|
81 |
|
---|
82 |
|
---|
83 | uint32_t glInternalLightvElem(GLenum pname)
|
---|
84 | {
|
---|
85 | switch (pname)
|
---|
86 | {
|
---|
87 | case GL_AMBIENT:
|
---|
88 | case GL_DIFFUSE:
|
---|
89 | case GL_SPECULAR:
|
---|
90 | case GL_POSITION:
|
---|
91 | return 4;
|
---|
92 |
|
---|
93 | case GL_SPOT_DIRECTION:
|
---|
94 | return 3;
|
---|
95 |
|
---|
96 | case GL_SPOT_EXPONENT:
|
---|
97 | case GL_SPOT_CUTOFF:
|
---|
98 | case GL_CONSTANT_ATTENUATION:
|
---|
99 | case GL_LINEAR_ATTENUATION:
|
---|
100 | case GL_QUADRATIC_ATTENUATION:
|
---|
101 | return 1;
|
---|
102 |
|
---|
103 | default:
|
---|
104 | AssertMsgFailed(("%s Unknown element %x\n", __FUNCTION__, pname));
|
---|
105 | return 0;
|
---|
106 | }
|
---|
107 | }
|
---|
108 |
|
---|
109 |
|
---|
110 | uint32_t glInternalMaterialvElem(GLenum pname)
|
---|
111 | {
|
---|
112 | switch (pname)
|
---|
113 | {
|
---|
114 | case GL_AMBIENT:
|
---|
115 | case GL_DIFFUSE:
|
---|
116 | case GL_SPECULAR:
|
---|
117 | case GL_EMISSION:
|
---|
118 | case GL_AMBIENT_AND_DIFFUSE:
|
---|
119 | return 4;
|
---|
120 |
|
---|
121 | case GL_SHININESS:
|
---|
122 | return 1;
|
---|
123 |
|
---|
124 | case GL_COLOR_INDEXES:
|
---|
125 | return 3;
|
---|
126 |
|
---|
127 | default:
|
---|
128 | AssertMsgFailed(("%s Unknown element %x\n", __FUNCTION__, pname));
|
---|
129 | return 0;
|
---|
130 | }
|
---|
131 | }
|
---|
132 |
|
---|
133 | uint32_t glInternalTexEnvvElem(GLenum pname)
|
---|
134 | {
|
---|
135 | switch (pname)
|
---|
136 | {
|
---|
137 | case GL_TEXTURE_ENV_MODE:
|
---|
138 | return 1;
|
---|
139 |
|
---|
140 | case GL_TEXTURE_ENV_COLOR:
|
---|
141 | return 4;
|
---|
142 |
|
---|
143 | default:
|
---|
144 | AssertMsgFailed(("%s Unknown element %x\n", __FUNCTION__, pname));
|
---|
145 | return 0;
|
---|
146 | }
|
---|
147 | }
|
---|
148 |
|
---|
149 | uint32_t glInternalTexGenvElem(GLenum pname)
|
---|
150 | {
|
---|
151 | switch (pname)
|
---|
152 | {
|
---|
153 | case GL_TEXTURE_GEN_MODE:
|
---|
154 | return 1;
|
---|
155 |
|
---|
156 | case GL_OBJECT_PLANE:
|
---|
157 | case GL_EYE_PLANE:
|
---|
158 | return 4;
|
---|
159 |
|
---|
160 | default:
|
---|
161 | AssertMsgFailed(("%s Unknown element %x\n", __FUNCTION__, pname));
|
---|
162 | return 0;
|
---|
163 | }
|
---|
164 | }
|
---|
165 |
|
---|
166 | uint32_t glInternalTexParametervElem(GLenum pname)
|
---|
167 | {
|
---|
168 | switch (pname)
|
---|
169 | {
|
---|
170 | case GL_TEXTURE_MAG_FILTER:
|
---|
171 | case GL_TEXTURE_MIN_FILTER:
|
---|
172 | case GL_TEXTURE_WRAP_S:
|
---|
173 | case GL_TEXTURE_WRAP_T:
|
---|
174 | case GL_TEXTURE_PRIORITY:
|
---|
175 | return 1;
|
---|
176 |
|
---|
177 | case GL_TEXTURE_BORDER_COLOR:
|
---|
178 | return 4;
|
---|
179 |
|
---|
180 | default:
|
---|
181 | AssertMsgFailed(("%s Unknown element %x\n", __FUNCTION__, pname));
|
---|
182 | return 0;
|
---|
183 | }
|
---|
184 | }
|
---|
185 |
|
---|
186 | /**
|
---|
187 | * Query the number of bytes required for a pixel in the specified format
|
---|
188 | *
|
---|
189 | * @returns requested pixel size
|
---|
190 | * @param type Parameter type
|
---|
191 | */
|
---|
192 | GLint glInternalGetPixelFormatElements(GLenum format)
|
---|
193 | {
|
---|
194 | switch (format)
|
---|
195 | {
|
---|
196 | case GL_COLOR_INDEX:
|
---|
197 | case GL_STENCIL_INDEX:
|
---|
198 | case GL_DEPTH_COMPONENT:
|
---|
199 | case GL_RED:
|
---|
200 | case GL_GREEN:
|
---|
201 | case GL_BLUE:
|
---|
202 | case GL_ALPHA:
|
---|
203 | case GL_LUMINANCE:
|
---|
204 | case GL_LUMINANCE_ALPHA:
|
---|
205 | return 1;
|
---|
206 |
|
---|
207 | case GL_RGB:
|
---|
208 | case GL_BGR_EXT:
|
---|
209 | return 3;
|
---|
210 |
|
---|
211 | case GL_RGBA:
|
---|
212 | case GL_BGRA_EXT:
|
---|
213 | return 4;
|
---|
214 | default:
|
---|
215 | AssertMsgFailed(("%s Unknown format %x\n", __FUNCTION__, format));
|
---|
216 | return 0;
|
---|
217 | }
|
---|
218 | }
|
---|