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 |
|
---|
18 | #include "VBoxOGL.h"
|
---|
19 | #include <iprt/cdefs.h>
|
---|
20 | #include <iprt/assert.h>
|
---|
21 |
|
---|
22 | /* DataType */
|
---|
23 | static GLuint glDataTypeSize[11] =
|
---|
24 | {
|
---|
25 | /* GL_BYTE */ sizeof(GLbyte),
|
---|
26 | /* GL_UNSIGNED_BYTE */ sizeof(GLubyte),
|
---|
27 | /* GL_SHORT */ sizeof(GLshort),
|
---|
28 | /* GL_UNSIGNED_SHORT */ sizeof(GLushort),
|
---|
29 | /* GL_INT */ sizeof(GLint),
|
---|
30 | /* GL_UNSIGNED_INT */ sizeof(GLuint),
|
---|
31 | /* GL_FLOAT */ sizeof(GLfloat),
|
---|
32 | /* GL_2_BYTES */ 2,
|
---|
33 | /* GL_3_BYTES */ 3,
|
---|
34 | /* GL_4_BYTES */ 4,
|
---|
35 | /* GL_DOUBLE */ sizeof(GLdouble),
|
---|
36 | };
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * Query the size of the specified data type
|
---|
40 | *
|
---|
41 | * @returns type size or 0 if unknown type
|
---|
42 | * @param type data type
|
---|
43 | */
|
---|
44 | GLint glVBoxGetDataTypeSize(GLenum type)
|
---|
45 | {
|
---|
46 | if (type - GL_BYTE >= RT_ELEMENTS(glDataTypeSize))
|
---|
47 | {
|
---|
48 | return 0;
|
---|
49 | }
|
---|
50 | return glDataTypeSize[type-GL_BYTE];
|
---|
51 | }
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * Query the specified cached parameter
|
---|
55 | *
|
---|
56 | * @returns requested cached value
|
---|
57 | * @param type Parameter type (Note: minimal checks only!)
|
---|
58 | */
|
---|
59 | GLint glInternalGetIntegerv(GLenum type)
|
---|
60 | {
|
---|
61 | AssertFailed();
|
---|
62 | return 0;
|
---|
63 | }
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Query the specified cached texture level parameter
|
---|
67 | *
|
---|
68 | * @returns requested cached value
|
---|
69 | * @param type Parameter type (Note: minimal checks only!)
|
---|
70 | */
|
---|
71 | GLint glInternalGetTexLevelParameteriv(GLenum type)
|
---|
72 | {
|
---|
73 | AssertFailed();
|
---|
74 | return 0;
|
---|
75 | }
|
---|
76 |
|
---|
77 |
|
---|
78 | uint32_t glInternalLightvElem(GLenum pname)
|
---|
79 | {
|
---|
80 | switch (pname)
|
---|
81 | {
|
---|
82 | case GL_AMBIENT:
|
---|
83 | case GL_DIFFUSE:
|
---|
84 | case GL_SPECULAR:
|
---|
85 | case GL_POSITION:
|
---|
86 | return 4;
|
---|
87 |
|
---|
88 | case GL_SPOT_DIRECTION:
|
---|
89 | return 3;
|
---|
90 |
|
---|
91 | case GL_SPOT_EXPONENT:
|
---|
92 | case GL_SPOT_CUTOFF:
|
---|
93 | case GL_CONSTANT_ATTENUATION:
|
---|
94 | case GL_LINEAR_ATTENUATION:
|
---|
95 | case GL_QUADRATIC_ATTENUATION:
|
---|
96 | return 1;
|
---|
97 |
|
---|
98 | default:
|
---|
99 | AssertMsgFailed(("%s Unknown element %x\n", __FUNCTION__, pname));
|
---|
100 | return 0;
|
---|
101 | }
|
---|
102 | }
|
---|
103 |
|
---|
104 |
|
---|
105 | uint32_t glInternalMaterialvElem(GLenum pname)
|
---|
106 | {
|
---|
107 | switch (pname)
|
---|
108 | {
|
---|
109 | case GL_AMBIENT:
|
---|
110 | case GL_DIFFUSE:
|
---|
111 | case GL_SPECULAR:
|
---|
112 | case GL_EMISSION:
|
---|
113 | case GL_AMBIENT_AND_DIFFUSE:
|
---|
114 | return 4;
|
---|
115 |
|
---|
116 | case GL_SHININESS:
|
---|
117 | return 1;
|
---|
118 |
|
---|
119 | case GL_COLOR_INDEXES:
|
---|
120 | return 3;
|
---|
121 |
|
---|
122 | default:
|
---|
123 | AssertMsgFailed(("%s Unknown element %x\n", __FUNCTION__, pname));
|
---|
124 | return 0;
|
---|
125 | }
|
---|
126 | }
|
---|
127 |
|
---|
128 | uint32_t glInternalTexEnvvElem(GLenum pname)
|
---|
129 | {
|
---|
130 | switch (pname)
|
---|
131 | {
|
---|
132 | case GL_TEXTURE_ENV_MODE:
|
---|
133 | return 1;
|
---|
134 |
|
---|
135 | case GL_TEXTURE_ENV_COLOR:
|
---|
136 | return 4;
|
---|
137 |
|
---|
138 | default:
|
---|
139 | AssertMsgFailed(("%s Unknown element %x\n", __FUNCTION__, pname));
|
---|
140 | return 0;
|
---|
141 | }
|
---|
142 | }
|
---|
143 |
|
---|
144 | uint32_t glInternalTexGenvElem(GLenum pname)
|
---|
145 | {
|
---|
146 | switch (pname)
|
---|
147 | {
|
---|
148 | case GL_TEXTURE_GEN_MODE:
|
---|
149 | return 1;
|
---|
150 |
|
---|
151 | case GL_OBJECT_PLANE:
|
---|
152 | case GL_EYE_PLANE:
|
---|
153 | return 4;
|
---|
154 |
|
---|
155 | default:
|
---|
156 | AssertMsgFailed(("%s Unknown element %x\n", __FUNCTION__, pname));
|
---|
157 | return 0;
|
---|
158 | }
|
---|
159 | }
|
---|
160 |
|
---|
161 | uint32_t glInternalTexParametervElem(GLenum pname)
|
---|
162 | {
|
---|
163 | switch (pname)
|
---|
164 | {
|
---|
165 | case GL_TEXTURE_MAG_FILTER:
|
---|
166 | case GL_TEXTURE_MIN_FILTER:
|
---|
167 | case GL_TEXTURE_WRAP_S:
|
---|
168 | case GL_TEXTURE_WRAP_T:
|
---|
169 | case GL_TEXTURE_PRIORITY:
|
---|
170 | return 1;
|
---|
171 |
|
---|
172 | case GL_TEXTURE_BORDER_COLOR:
|
---|
173 | return 4;
|
---|
174 |
|
---|
175 | default:
|
---|
176 | AssertMsgFailed(("%s Unknown element %x\n", __FUNCTION__, pname));
|
---|
177 | return 0;
|
---|
178 | }
|
---|
179 | }
|
---|
180 |
|
---|
181 | /**
|
---|
182 | * Query the number of bytes required for a pixel in the specified format
|
---|
183 | *
|
---|
184 | * @returns requested pixel size
|
---|
185 | * @param type Parameter type
|
---|
186 | */
|
---|
187 | GLint glInternalGetPixelFormatElements(GLenum format)
|
---|
188 | {
|
---|
189 | switch (format)
|
---|
190 | {
|
---|
191 | case GL_COLOR_INDEX:
|
---|
192 | case GL_STENCIL_INDEX:
|
---|
193 | case GL_DEPTH_COMPONENT:
|
---|
194 | case GL_RED:
|
---|
195 | case GL_GREEN:
|
---|
196 | case GL_BLUE:
|
---|
197 | case GL_ALPHA:
|
---|
198 | case GL_LUMINANCE:
|
---|
199 | case GL_LUMINANCE_ALPHA:
|
---|
200 | return 1;
|
---|
201 |
|
---|
202 | case GL_RGB:
|
---|
203 | case GL_BGR_EXT:
|
---|
204 | return 3;
|
---|
205 |
|
---|
206 | case GL_RGBA:
|
---|
207 | case GL_BGRA_EXT:
|
---|
208 | return 4;
|
---|
209 | default:
|
---|
210 | AssertMsgFailed(("%s Unknown format %x\n", __FUNCTION__, format));
|
---|
211 | return 0;
|
---|
212 | }
|
---|
213 | }
|
---|