1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include "state.h"
|
---|
8 | #include "state/cr_statetypes.h"
|
---|
9 | #include "state/cr_texture.h"
|
---|
10 | #include "cr_hash.h"
|
---|
11 | #include "cr_string.h"
|
---|
12 | #include "cr_mem.h"
|
---|
13 | #include "cr_version.h"
|
---|
14 | #include "state_internals.h"
|
---|
15 |
|
---|
16 | #define UNUSED(x) ((void) (x))
|
---|
17 |
|
---|
18 | #define GET_TOBJ(tobj, state, id) \
|
---|
19 | tobj = (CRTextureObj *) crHashtableSearch(g->shared->textureTable, id);
|
---|
20 |
|
---|
21 |
|
---|
22 | void crStateTextureDestroy(CRContext *ctx)
|
---|
23 | {
|
---|
24 | crStateDeleteTextureObjectData(&ctx->texture.base1D);
|
---|
25 | crStateDeleteTextureObjectData(&ctx->texture.proxy1D);
|
---|
26 | crStateDeleteTextureObjectData(&ctx->texture.base2D);
|
---|
27 | crStateDeleteTextureObjectData(&ctx->texture.proxy2D);
|
---|
28 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
29 | crStateDeleteTextureObjectData(&ctx->texture.base3D);
|
---|
30 | crStateDeleteTextureObjectData(&ctx->texture.proxy3D);
|
---|
31 | #endif
|
---|
32 | #ifdef CR_ARB_texture_cube_map
|
---|
33 | crStateDeleteTextureObjectData(&ctx->texture.baseCubeMap);
|
---|
34 | crStateDeleteTextureObjectData(&ctx->texture.proxyCubeMap);
|
---|
35 | #endif
|
---|
36 | #ifdef CR_NV_texture_rectangle
|
---|
37 | crStateDeleteTextureObjectData(&ctx->texture.baseRect);
|
---|
38 | crStateDeleteTextureObjectData(&ctx->texture.proxyRect);
|
---|
39 | #endif
|
---|
40 | }
|
---|
41 |
|
---|
42 |
|
---|
43 | void crStateTextureInit(CRContext *ctx)
|
---|
44 | {
|
---|
45 | CRLimitsState *limits = &ctx->limits;
|
---|
46 | CRTextureState *t = &ctx->texture;
|
---|
47 | CRStateBits *sb = GetCurrentBits();
|
---|
48 | CRTextureBits *tb = &(sb->texture);
|
---|
49 | unsigned int i;
|
---|
50 | unsigned int a;
|
---|
51 | GLvectorf zero_vector = {0.0f, 0.0f, 0.0f, 0.0f};
|
---|
52 | GLcolorf zero_color = {0.0f, 0.0f, 0.0f, 0.0f};
|
---|
53 | GLvectorf x_vector = {1.0f, 0.0f, 0.0f, 0.0f};
|
---|
54 | GLvectorf y_vector = {0.0f, 1.0f, 0.0f, 0.0f};
|
---|
55 |
|
---|
56 | /* compute max levels from max sizes */
|
---|
57 | for (i=0, a=limits->maxTextureSize; a; i++, a=a>>1);
|
---|
58 | t->maxLevel = i;
|
---|
59 | for (i=0, a=limits->max3DTextureSize; a; i++, a=a>>1);
|
---|
60 | t->max3DLevel = i;
|
---|
61 | #ifdef CR_ARB_texture_cube_map
|
---|
62 | for (i=0, a=limits->maxCubeMapTextureSize; a; i++, a=a>>1);
|
---|
63 | t->maxCubeMapLevel = i;
|
---|
64 | #endif
|
---|
65 | #ifdef CR_NV_texture_rectangle
|
---|
66 | for (i=0, a=limits->maxRectTextureSize; a; i++, a=a>>1);
|
---|
67 | t->maxRectLevel = i;
|
---|
68 | #endif
|
---|
69 |
|
---|
70 | crStateTextureInitTextureObj(ctx, &(t->base1D), 0, GL_TEXTURE_1D);
|
---|
71 | crStateTextureInitTextureObj(ctx, &(t->base2D), 0, GL_TEXTURE_2D);
|
---|
72 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
73 | crStateTextureInitTextureObj(ctx, &(t->base3D), 0, GL_TEXTURE_3D);
|
---|
74 | #endif
|
---|
75 | #ifdef CR_ARB_texture_cube_map
|
---|
76 | crStateTextureInitTextureObj(ctx, &(t->baseCubeMap), 0,
|
---|
77 | GL_TEXTURE_CUBE_MAP_ARB);
|
---|
78 | #endif
|
---|
79 | #ifdef CR_NV_texture_rectangle
|
---|
80 | crStateTextureInitTextureObj(ctx, &(t->baseRect), 0,
|
---|
81 | GL_TEXTURE_RECTANGLE_NV);
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | crStateTextureInitTextureObj(ctx, &(t->proxy1D), 0, GL_TEXTURE_1D);
|
---|
85 | crStateTextureInitTextureObj(ctx, &(t->proxy2D), 0, GL_TEXTURE_2D);
|
---|
86 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
87 | crStateTextureInitTextureObj(ctx, &(t->proxy3D), 0, GL_TEXTURE_3D);
|
---|
88 | #endif
|
---|
89 | #ifdef CR_ARB_texture_cube_map
|
---|
90 | crStateTextureInitTextureObj(ctx, &(t->proxyCubeMap), 0,
|
---|
91 | GL_TEXTURE_CUBE_MAP_ARB);
|
---|
92 | #endif
|
---|
93 | #ifdef CR_NV_texture_rectangle
|
---|
94 | crStateTextureInitTextureObj(ctx, &(t->proxyRect), 0,
|
---|
95 | GL_TEXTURE_RECTANGLE_NV);
|
---|
96 | #endif
|
---|
97 |
|
---|
98 | t->curTextureUnit = 0;
|
---|
99 |
|
---|
100 | /* Per-unit initialization */
|
---|
101 | for (i = 0; i < limits->maxTextureUnits; i++)
|
---|
102 | {
|
---|
103 | t->unit[i].currentTexture1D = &(t->base1D);
|
---|
104 | t->unit[i].currentTexture2D = &(t->base2D);
|
---|
105 | t->unit[i].currentTexture3D = &(t->base3D);
|
---|
106 | #ifdef CR_ARB_texture_cube_map
|
---|
107 | t->unit[i].currentTextureCubeMap = &(t->baseCubeMap);
|
---|
108 | #endif
|
---|
109 | #ifdef CR_NV_texture_rectangle
|
---|
110 | t->unit[i].currentTextureRect = &(t->baseRect);
|
---|
111 | #endif
|
---|
112 |
|
---|
113 | t->unit[i].enabled1D = GL_FALSE;
|
---|
114 | t->unit[i].enabled2D = GL_FALSE;
|
---|
115 | t->unit[i].enabled3D = GL_FALSE;
|
---|
116 | t->unit[i].enabledCubeMap = GL_FALSE;
|
---|
117 | #ifdef CR_NV_texture_rectangle
|
---|
118 | t->unit[i].enabledRect = GL_FALSE;
|
---|
119 | #endif
|
---|
120 | t->unit[i].textureGen.s = GL_FALSE;
|
---|
121 | t->unit[i].textureGen.t = GL_FALSE;
|
---|
122 | t->unit[i].textureGen.r = GL_FALSE;
|
---|
123 | t->unit[i].textureGen.q = GL_FALSE;
|
---|
124 |
|
---|
125 | t->unit[i].gen.s = GL_EYE_LINEAR;
|
---|
126 | t->unit[i].gen.t = GL_EYE_LINEAR;
|
---|
127 | t->unit[i].gen.r = GL_EYE_LINEAR;
|
---|
128 | t->unit[i].gen.q = GL_EYE_LINEAR;
|
---|
129 |
|
---|
130 | t->unit[i].objSCoeff = x_vector;
|
---|
131 | t->unit[i].objTCoeff = y_vector;
|
---|
132 | t->unit[i].objRCoeff = zero_vector;
|
---|
133 | t->unit[i].objQCoeff = zero_vector;
|
---|
134 |
|
---|
135 | t->unit[i].eyeSCoeff = x_vector;
|
---|
136 | t->unit[i].eyeTCoeff = y_vector;
|
---|
137 | t->unit[i].eyeRCoeff = zero_vector;
|
---|
138 | t->unit[i].eyeQCoeff = zero_vector;
|
---|
139 | t->unit[i].envMode = GL_MODULATE;
|
---|
140 | t->unit[i].envColor = zero_color;
|
---|
141 |
|
---|
142 | t->unit[i].combineModeRGB = GL_MODULATE;
|
---|
143 | t->unit[i].combineModeA = GL_MODULATE;
|
---|
144 | t->unit[i].combineSourceRGB[0] = GL_TEXTURE;
|
---|
145 | t->unit[i].combineSourceRGB[1] = GL_PREVIOUS_EXT;
|
---|
146 | t->unit[i].combineSourceRGB[2] = GL_CONSTANT_EXT;
|
---|
147 | t->unit[i].combineSourceA[0] = GL_TEXTURE;
|
---|
148 | t->unit[i].combineSourceA[1] = GL_PREVIOUS_EXT;
|
---|
149 | t->unit[i].combineSourceA[2] = GL_CONSTANT_EXT;
|
---|
150 | t->unit[i].combineOperandRGB[0] = GL_SRC_COLOR;
|
---|
151 | t->unit[i].combineOperandRGB[1] = GL_SRC_COLOR;
|
---|
152 | t->unit[i].combineOperandRGB[2] = GL_SRC_ALPHA;
|
---|
153 | t->unit[i].combineOperandA[0] = GL_SRC_ALPHA;
|
---|
154 | t->unit[i].combineOperandA[1] = GL_SRC_ALPHA;
|
---|
155 | t->unit[i].combineOperandA[2] = GL_SRC_ALPHA;
|
---|
156 | t->unit[i].combineScaleRGB = 1.0F;
|
---|
157 | t->unit[i].combineScaleA = 1.0F;
|
---|
158 | #ifdef CR_EXT_texture_lod_bias
|
---|
159 | t->unit[i].lodBias = 0.0F;
|
---|
160 | #endif
|
---|
161 | RESET(tb->enable[i], ctx->bitid);
|
---|
162 | RESET(tb->current[i], ctx->bitid);
|
---|
163 | RESET(tb->objGen[i], ctx->bitid);
|
---|
164 | RESET(tb->eyeGen[i], ctx->bitid);
|
---|
165 | RESET(tb->genMode[i], ctx->bitid);
|
---|
166 | RESET(tb->envBit[i], ctx->bitid);
|
---|
167 | }
|
---|
168 | RESET(tb->dirty, ctx->bitid);
|
---|
169 | }
|
---|
170 |
|
---|
171 |
|
---|
172 | void
|
---|
173 | crStateTextureInitTextureObj(CRContext *ctx, CRTextureObj *tobj,
|
---|
174 | GLuint name, GLenum target)
|
---|
175 | {
|
---|
176 | const CRTextureState *t = &(ctx->texture);
|
---|
177 | int i, face;
|
---|
178 |
|
---|
179 | tobj->borderColor.r = 0.0f;
|
---|
180 | tobj->borderColor.g = 0.0f;
|
---|
181 | tobj->borderColor.b = 0.0f;
|
---|
182 | tobj->borderColor.a = 0.0f;
|
---|
183 | tobj->minFilter = GL_NEAREST_MIPMAP_LINEAR;
|
---|
184 | tobj->magFilter = GL_LINEAR;
|
---|
185 | tobj->wrapS = GL_REPEAT;
|
---|
186 | tobj->wrapT = GL_REPEAT;
|
---|
187 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
188 | tobj->wrapR = GL_REPEAT;
|
---|
189 | tobj->priority = 1.0f;
|
---|
190 | tobj->minLod = -1000.0;
|
---|
191 | tobj->maxLod = 1000.0;
|
---|
192 | tobj->baseLevel = 0;
|
---|
193 | tobj->maxLevel = 1000;
|
---|
194 | #endif
|
---|
195 | tobj->target = target;
|
---|
196 | tobj->name = name;
|
---|
197 |
|
---|
198 | CRASSERT(t->maxLevel);
|
---|
199 |
|
---|
200 | /* XXX don't always need all six faces */
|
---|
201 | for (face = 0; face < 6; face++) {
|
---|
202 | /* allocate array of mipmap levels */
|
---|
203 | CRASSERT(t->maxLevel < CR_MAX_MIPMAP_LEVELS);
|
---|
204 | tobj->level[face] = (CRTextureLevel *)
|
---|
205 | crCalloc(sizeof(CRTextureLevel) * CR_MAX_MIPMAP_LEVELS);
|
---|
206 |
|
---|
207 | if (!tobj->level[face])
|
---|
208 | return; /* out of memory */
|
---|
209 |
|
---|
210 | /* init non-zero fields */
|
---|
211 | for (i = 0; i <= t->maxLevel; i++) {
|
---|
212 | CRTextureLevel *tl = &(tobj->level[face][i]);
|
---|
213 | tl->internalFormat = GL_ONE;
|
---|
214 | tl->format = GL_RGBA;
|
---|
215 | tl->type = GL_UNSIGNED_BYTE;
|
---|
216 | crStateTextureInitTextureFormat( tl, tl->internalFormat );
|
---|
217 | }
|
---|
218 | }
|
---|
219 |
|
---|
220 | #ifdef CR_EXT_texture_filter_anisotropic
|
---|
221 | tobj->maxAnisotropy = 1.0f;
|
---|
222 | #endif
|
---|
223 |
|
---|
224 | #ifdef CR_ARB_depth_texture
|
---|
225 | tobj->depthMode = GL_LUMINANCE;
|
---|
226 | #endif
|
---|
227 |
|
---|
228 | #ifdef CR_ARB_shadow
|
---|
229 | tobj->compareMode = GL_NONE;
|
---|
230 | tobj->compareFunc = GL_LEQUAL;
|
---|
231 | #endif
|
---|
232 |
|
---|
233 | #ifdef CR_ARB_shadow_ambient
|
---|
234 | tobj->compareFailValue = 0.0;
|
---|
235 | #endif
|
---|
236 |
|
---|
237 | RESET(tobj->dirty, ctx->bitid);
|
---|
238 | RESET(tobj->imageBit, ctx->bitid);
|
---|
239 | for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++)
|
---|
240 | {
|
---|
241 | RESET(tobj->paramsBit[i], ctx->bitid);
|
---|
242 | }
|
---|
243 | }
|
---|
244 |
|
---|
245 |
|
---|
246 | /* ================================================================
|
---|
247 | * Texture internal formats:
|
---|
248 | */
|
---|
249 |
|
---|
250 | const CRTextureFormat _texformat_rgba8888 = {
|
---|
251 | 8, /* RedBits */
|
---|
252 | 8, /* GreenBits */
|
---|
253 | 8, /* BlueBits */
|
---|
254 | 8, /* AlphaBits */
|
---|
255 | 0, /* LuminanceBits */
|
---|
256 | 0, /* IntensityBits */
|
---|
257 | 0, /* IndexBits */
|
---|
258 | };
|
---|
259 |
|
---|
260 | const CRTextureFormat _texformat_argb8888 = {
|
---|
261 | 8, /* RedBits */
|
---|
262 | 8, /* GreenBits */
|
---|
263 | 8, /* BlueBits */
|
---|
264 | 8, /* AlphaBits */
|
---|
265 | 0, /* LuminanceBits */
|
---|
266 | 0, /* IntensityBits */
|
---|
267 | 0, /* IndexBits */
|
---|
268 | };
|
---|
269 |
|
---|
270 | const CRTextureFormat _texformat_rgb888 = {
|
---|
271 | 8, /* RedBits */
|
---|
272 | 8, /* GreenBits */
|
---|
273 | 8, /* BlueBits */
|
---|
274 | 0, /* AlphaBits */
|
---|
275 | 0, /* LuminanceBits */
|
---|
276 | 0, /* IntensityBits */
|
---|
277 | 0, /* IndexBits */
|
---|
278 | };
|
---|
279 |
|
---|
280 | const CRTextureFormat _texformat_rgb565 = {
|
---|
281 | 5, /* RedBits */
|
---|
282 | 6, /* GreenBits */
|
---|
283 | 5, /* BlueBits */
|
---|
284 | 0, /* AlphaBits */
|
---|
285 | 0, /* LuminanceBits */
|
---|
286 | 0, /* IntensityBits */
|
---|
287 | 0, /* IndexBits */
|
---|
288 | };
|
---|
289 |
|
---|
290 | const CRTextureFormat _texformat_argb4444 = {
|
---|
291 | 4, /* RedBits */
|
---|
292 | 4, /* GreenBits */
|
---|
293 | 4, /* BlueBits */
|
---|
294 | 4, /* AlphaBits */
|
---|
295 | 0, /* LuminanceBits */
|
---|
296 | 0, /* IntensityBits */
|
---|
297 | 0, /* IndexBits */
|
---|
298 | };
|
---|
299 |
|
---|
300 | const CRTextureFormat _texformat_argb1555 = {
|
---|
301 | 5, /* RedBits */
|
---|
302 | 5, /* GreenBits */
|
---|
303 | 5, /* BlueBits */
|
---|
304 | 1, /* AlphaBits */
|
---|
305 | 0, /* LuminanceBits */
|
---|
306 | 0, /* IntensityBits */
|
---|
307 | 0, /* IndexBits */
|
---|
308 | };
|
---|
309 |
|
---|
310 | const CRTextureFormat _texformat_al88 = {
|
---|
311 | 0, /* RedBits */
|
---|
312 | 0, /* GreenBits */
|
---|
313 | 0, /* BlueBits */
|
---|
314 | 8, /* AlphaBits */
|
---|
315 | 8, /* LuminanceBits */
|
---|
316 | 0, /* IntensityBits */
|
---|
317 | 0, /* IndexBits */
|
---|
318 | };
|
---|
319 |
|
---|
320 | const CRTextureFormat _texformat_rgb332 = {
|
---|
321 | 3, /* RedBits */
|
---|
322 | 3, /* GreenBits */
|
---|
323 | 2, /* BlueBits */
|
---|
324 | 0, /* AlphaBits */
|
---|
325 | 0, /* LuminanceBits */
|
---|
326 | 0, /* IntensityBits */
|
---|
327 | 0, /* IndexBits */
|
---|
328 | };
|
---|
329 |
|
---|
330 | const CRTextureFormat _texformat_a8 = {
|
---|
331 | 0, /* RedBits */
|
---|
332 | 0, /* GreenBits */
|
---|
333 | 0, /* BlueBits */
|
---|
334 | 8, /* AlphaBits */
|
---|
335 | 0, /* LuminanceBits */
|
---|
336 | 0, /* IntensityBits */
|
---|
337 | 0, /* IndexBits */
|
---|
338 | };
|
---|
339 |
|
---|
340 | const CRTextureFormat _texformat_l8 = {
|
---|
341 | 0, /* RedBits */
|
---|
342 | 0, /* GreenBits */
|
---|
343 | 0, /* BlueBits */
|
---|
344 | 0, /* AlphaBits */
|
---|
345 | 8, /* LuminanceBits */
|
---|
346 | 0, /* IntensityBits */
|
---|
347 | 0, /* IndexBits */
|
---|
348 | };
|
---|
349 |
|
---|
350 | const CRTextureFormat _texformat_i8 = {
|
---|
351 | 0, /* RedBits */
|
---|
352 | 0, /* GreenBits */
|
---|
353 | 0, /* BlueBits */
|
---|
354 | 0, /* AlphaBits */
|
---|
355 | 0, /* LuminanceBits */
|
---|
356 | 8, /* IntensityBits */
|
---|
357 | 0, /* IndexBits */
|
---|
358 | };
|
---|
359 |
|
---|
360 | const CRTextureFormat _texformat_ci8 = {
|
---|
361 | 0, /* RedBits */
|
---|
362 | 0, /* GreenBits */
|
---|
363 | 0, /* BlueBits */
|
---|
364 | 0, /* AlphaBits */
|
---|
365 | 0, /* LuminanceBits */
|
---|
366 | 0, /* IntensityBits */
|
---|
367 | 8, /* IndexBits */
|
---|
368 | };
|
---|
369 |
|
---|
370 |
|
---|
371 | /**
|
---|
372 | * Given an internal texture format enum or 1, 2, 3, 4 initialize the
|
---|
373 | * texture levels texture format. This basically just indicates the
|
---|
374 | * number of red, green, blue, alpha, luminance, etc. bits are used to
|
---|
375 | * store the image.
|
---|
376 | */
|
---|
377 | void
|
---|
378 | crStateTextureInitTextureFormat( CRTextureLevel *tl, GLenum internalFormat )
|
---|
379 | {
|
---|
380 | switch (internalFormat) {
|
---|
381 | case 4:
|
---|
382 | case GL_RGBA:
|
---|
383 | case GL_COMPRESSED_RGBA_ARB:
|
---|
384 | #ifdef CR_EXT_texture_sRGB
|
---|
385 | case GL_SRGB_ALPHA_EXT:
|
---|
386 | case GL_SRGB8_ALPHA8_EXT:
|
---|
387 | case GL_COMPRESSED_SRGB_ALPHA_EXT:
|
---|
388 | #endif
|
---|
389 | tl->texFormat = &_texformat_rgba8888;
|
---|
390 | break;
|
---|
391 |
|
---|
392 | case 3:
|
---|
393 | case GL_RGB:
|
---|
394 | case GL_COMPRESSED_RGB_ARB:
|
---|
395 | #ifdef CR_EXT_texture_sRGB
|
---|
396 | case GL_SRGB_EXT:
|
---|
397 | case GL_SRGB8_EXT:
|
---|
398 | case GL_COMPRESSED_SRGB_EXT:
|
---|
399 | #endif
|
---|
400 | tl->texFormat = &_texformat_rgb888;
|
---|
401 | break;
|
---|
402 |
|
---|
403 | case GL_RGBA2:
|
---|
404 | case GL_RGBA4:
|
---|
405 | case GL_RGB5_A1:
|
---|
406 | case GL_RGBA8:
|
---|
407 | case GL_RGB10_A2:
|
---|
408 | case GL_RGBA12:
|
---|
409 | case GL_RGBA16:
|
---|
410 | tl->texFormat = &_texformat_rgba8888;
|
---|
411 | break;
|
---|
412 |
|
---|
413 | case GL_R3_G3_B2:
|
---|
414 | tl->texFormat = &_texformat_rgb332;
|
---|
415 | break;
|
---|
416 | case GL_RGB4:
|
---|
417 | case GL_RGB5:
|
---|
418 | case GL_RGB8:
|
---|
419 | case GL_RGB10:
|
---|
420 | case GL_RGB12:
|
---|
421 | case GL_RGB16:
|
---|
422 | tl->texFormat = &_texformat_rgb888;
|
---|
423 | break;
|
---|
424 |
|
---|
425 | case GL_ALPHA:
|
---|
426 | case GL_ALPHA4:
|
---|
427 | case GL_ALPHA8:
|
---|
428 | case GL_ALPHA12:
|
---|
429 | case GL_ALPHA16:
|
---|
430 | case GL_COMPRESSED_ALPHA_ARB:
|
---|
431 | tl->texFormat = &_texformat_a8;
|
---|
432 | break;
|
---|
433 |
|
---|
434 | case 1:
|
---|
435 | case GL_LUMINANCE:
|
---|
436 | case GL_LUMINANCE4:
|
---|
437 | case GL_LUMINANCE8:
|
---|
438 | case GL_LUMINANCE12:
|
---|
439 | case GL_LUMINANCE16:
|
---|
440 | case GL_COMPRESSED_LUMINANCE_ARB:
|
---|
441 | #ifdef CR_EXT_texture_sRGB
|
---|
442 | case GL_SLUMINANCE_EXT:
|
---|
443 | case GL_SLUMINANCE8_EXT:
|
---|
444 | case GL_COMPRESSED_SLUMINANCE_EXT:
|
---|
445 | #endif
|
---|
446 | tl->texFormat = &_texformat_l8;
|
---|
447 | break;
|
---|
448 |
|
---|
449 | case 2:
|
---|
450 | case GL_LUMINANCE_ALPHA:
|
---|
451 | case GL_LUMINANCE4_ALPHA4:
|
---|
452 | case GL_LUMINANCE6_ALPHA2:
|
---|
453 | case GL_LUMINANCE8_ALPHA8:
|
---|
454 | case GL_LUMINANCE12_ALPHA4:
|
---|
455 | case GL_LUMINANCE12_ALPHA12:
|
---|
456 | case GL_LUMINANCE16_ALPHA16:
|
---|
457 | case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
|
---|
458 | #ifdef CR_EXT_texture_sRGB
|
---|
459 | case GL_SLUMINANCE_ALPHA_EXT:
|
---|
460 | case GL_SLUMINANCE8_ALPHA8_EXT:
|
---|
461 | case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
|
---|
462 | #endif
|
---|
463 | tl->texFormat = &_texformat_al88;
|
---|
464 | break;
|
---|
465 |
|
---|
466 | case GL_INTENSITY:
|
---|
467 | case GL_INTENSITY4:
|
---|
468 | case GL_INTENSITY8:
|
---|
469 | case GL_INTENSITY12:
|
---|
470 | case GL_INTENSITY16:
|
---|
471 | case GL_COMPRESSED_INTENSITY_ARB:
|
---|
472 | tl->texFormat = &_texformat_i8;
|
---|
473 | break;
|
---|
474 |
|
---|
475 | case GL_COLOR_INDEX:
|
---|
476 | case GL_COLOR_INDEX1_EXT:
|
---|
477 | case GL_COLOR_INDEX2_EXT:
|
---|
478 | case GL_COLOR_INDEX4_EXT:
|
---|
479 | case GL_COLOR_INDEX8_EXT:
|
---|
480 | case GL_COLOR_INDEX12_EXT:
|
---|
481 | case GL_COLOR_INDEX16_EXT:
|
---|
482 | tl->texFormat = &_texformat_ci8;
|
---|
483 | break;
|
---|
484 |
|
---|
485 | default:
|
---|
486 | return;
|
---|
487 | }
|
---|
488 | }
|
---|
489 |
|
---|
490 | #if 0
|
---|
491 | void crStateTextureInitTexture (GLuint name)
|
---|
492 | {
|
---|
493 | CRContext *g = GetCurrentContext();
|
---|
494 | CRTextureState *t = &(g->texture);
|
---|
495 | CRTextureObj *tobj;
|
---|
496 |
|
---|
497 | GET_TOBJ(tobj, name);
|
---|
498 | if (!tobj) return;
|
---|
499 |
|
---|
500 | crStateTextureInitTextureObj(g, tobj, name, GL_NONE);
|
---|
501 | }
|
---|
502 | #endif
|
---|
503 |
|
---|
504 |
|
---|
505 |
|
---|
506 | /**
|
---|
507 | * Return the texture object corresponding to the given target and ID.
|
---|
508 | */
|
---|
509 | CRTextureObj *
|
---|
510 | crStateTextureGet(GLenum target, GLuint name)
|
---|
511 | {
|
---|
512 | CRContext *g = GetCurrentContext();
|
---|
513 | CRTextureState *t = &(g->texture);
|
---|
514 | CRTextureObj *tobj;
|
---|
515 |
|
---|
516 | if (name == 0)
|
---|
517 | {
|
---|
518 | switch (target) {
|
---|
519 | case GL_TEXTURE_1D:
|
---|
520 | return &t->base1D;
|
---|
521 | case GL_TEXTURE_2D:
|
---|
522 | return &t->base2D;
|
---|
523 | case GL_TEXTURE_3D:
|
---|
524 | return &t->base3D;
|
---|
525 | #ifdef CR_ARB_texture_cube_map
|
---|
526 | case GL_TEXTURE_CUBE_MAP_ARB:
|
---|
527 | return &t->baseCubeMap;
|
---|
528 | #endif
|
---|
529 | #ifdef CR_NV_texture_rectangle
|
---|
530 | case GL_TEXTURE_RECTANGLE_NV:
|
---|
531 | return &t->baseRect;
|
---|
532 | #endif
|
---|
533 | default:
|
---|
534 | return NULL;
|
---|
535 | }
|
---|
536 | }
|
---|
537 |
|
---|
538 | GET_TOBJ(tobj, g, name);
|
---|
539 |
|
---|
540 | return tobj;
|
---|
541 | }
|
---|
542 |
|
---|
543 |
|
---|
544 | /*
|
---|
545 | * Allocate a new texture object with the given name.
|
---|
546 | * Also insert into hash table.
|
---|
547 | */
|
---|
548 | static CRTextureObj *
|
---|
549 | crStateTextureAllocate_t(CRContext *ctx, GLuint name)
|
---|
550 | {
|
---|
551 | CRTextureObj *tobj;
|
---|
552 |
|
---|
553 | if (!name)
|
---|
554 | return NULL;
|
---|
555 |
|
---|
556 | tobj = crCalloc(sizeof(CRTextureObj));
|
---|
557 | if (!tobj)
|
---|
558 | return NULL;
|
---|
559 |
|
---|
560 | crHashtableAdd( ctx->shared->textureTable, name, (void *) tobj );
|
---|
561 |
|
---|
562 | crStateTextureInitTextureObj(ctx, tobj, name, GL_NONE);
|
---|
563 |
|
---|
564 | return tobj;
|
---|
565 | }
|
---|
566 |
|
---|
567 |
|
---|
568 | /**
|
---|
569 | * Delete all the data that hangs off a CRTextureObj, but don't
|
---|
570 | * delete the texture object itself, since it may not have been
|
---|
571 | * dynamically allocated.
|
---|
572 | */
|
---|
573 | void
|
---|
574 | crStateDeleteTextureObjectData(CRTextureObj *tobj)
|
---|
575 | {
|
---|
576 | int k;
|
---|
577 | int face;
|
---|
578 |
|
---|
579 | CRASSERT(tobj);
|
---|
580 |
|
---|
581 | /* Free the texture images */
|
---|
582 | for (face = 0; face < 6; face++) {
|
---|
583 | CRTextureLevel *levels = NULL;
|
---|
584 | levels = tobj->level[face];
|
---|
585 | if (levels) {
|
---|
586 | /* free all mipmap levels for this face */
|
---|
587 | for (k = 0; k < CR_MAX_MIPMAP_LEVELS; k++) {
|
---|
588 | CRTextureLevel *tl = levels + k;
|
---|
589 | if (tl->img) {
|
---|
590 | crFree(tl->img);
|
---|
591 | tl->img = NULL;
|
---|
592 | tl->bytes = 0;
|
---|
593 | }
|
---|
594 | }
|
---|
595 | crFree(levels);
|
---|
596 | }
|
---|
597 | tobj->level[face] = NULL;
|
---|
598 | }
|
---|
599 | }
|
---|
600 |
|
---|
601 |
|
---|
602 | void
|
---|
603 | crStateDeleteTextureObject(CRTextureObj *tobj)
|
---|
604 | {
|
---|
605 | crStateDeleteTextureObjectData(tobj);
|
---|
606 | crFree(tobj);
|
---|
607 | }
|
---|
608 |
|
---|
609 | void STATE_APIENTRY crStateGenTextures(GLsizei n, GLuint *textures)
|
---|
610 | {
|
---|
611 | CRContext *g = GetCurrentContext();
|
---|
612 | GLint start;
|
---|
613 |
|
---|
614 | FLUSH();
|
---|
615 |
|
---|
616 | if (g->current.inBeginEnd)
|
---|
617 | {
|
---|
618 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
619 | "glGenTextures called in Begin/End");
|
---|
620 | return;
|
---|
621 | }
|
---|
622 |
|
---|
623 | if (n < 0)
|
---|
624 | {
|
---|
625 | crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
|
---|
626 | "Negative n passed to glGenTextures: %d", n);
|
---|
627 | return;
|
---|
628 | }
|
---|
629 |
|
---|
630 | start = crHashtableAllocKeys(g->shared->textureTable, n);
|
---|
631 | if (start)
|
---|
632 | {
|
---|
633 | GLint i;
|
---|
634 | for (i = 0; i < n; i++)
|
---|
635 | textures[i] = (GLuint) (start + i);
|
---|
636 | }
|
---|
637 | else
|
---|
638 | {
|
---|
639 | crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glGenTextures");
|
---|
640 | }
|
---|
641 | }
|
---|
642 |
|
---|
643 | static void crStateTextureCheckFBOAPs(GLenum target, GLuint texture)
|
---|
644 | {
|
---|
645 | GLuint u;
|
---|
646 | CRFBOAttachmentPoint *ap;
|
---|
647 | CRContext *g = GetCurrentContext();
|
---|
648 | CRFramebufferObjectState *fbo = &g->framebufferobject;
|
---|
649 | CRFramebufferObject *pFBO;
|
---|
650 |
|
---|
651 | pFBO = GL_READ_FRAMEBUFFER==target ? fbo->readFB : fbo->drawFB;
|
---|
652 | if (!pFBO) return;
|
---|
653 |
|
---|
654 | for (u=0; u<CR_MAX_COLOR_ATTACHMENTS; ++u)
|
---|
655 | {
|
---|
656 | ap = &pFBO->color[u];
|
---|
657 | if (ap->type==GL_TEXTURE && ap->name==texture)
|
---|
658 | {
|
---|
659 | crStateFramebufferTexture1DEXT(target, u+GL_COLOR_ATTACHMENT0_EXT, 0, 0, 0);
|
---|
660 | }
|
---|
661 | }
|
---|
662 |
|
---|
663 | ap = &pFBO->depth;
|
---|
664 | if (ap->type==GL_TEXTURE && ap->name==texture)
|
---|
665 | {
|
---|
666 | crStateFramebufferTexture1DEXT(target, GL_DEPTH_ATTACHMENT_EXT, 0, 0, 0);
|
---|
667 | }
|
---|
668 |
|
---|
669 | ap = &pFBO->stencil;
|
---|
670 | if (ap->type==GL_TEXTURE && ap->name==texture)
|
---|
671 | {
|
---|
672 | crStateFramebufferTexture1DEXT(target, GL_STENCIL_ATTACHMENT_EXT, 0, 0, 0);
|
---|
673 | }
|
---|
674 | }
|
---|
675 |
|
---|
676 | void STATE_APIENTRY crStateDeleteTextures(GLsizei n, const GLuint *textures)
|
---|
677 | {
|
---|
678 | CRContext *g = GetCurrentContext();
|
---|
679 | CRTextureState *t = &(g->texture);
|
---|
680 | CRStateBits *sb = GetCurrentBits();
|
---|
681 | CRTextureBits *tb = &(sb->texture);
|
---|
682 | int i;
|
---|
683 |
|
---|
684 | FLUSH();
|
---|
685 |
|
---|
686 | if (g->current.inBeginEnd)
|
---|
687 | {
|
---|
688 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
689 | "glDeleteTextures called in Begin/End");
|
---|
690 | return;
|
---|
691 | }
|
---|
692 |
|
---|
693 | if (n < 0)
|
---|
694 | {
|
---|
695 | crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
|
---|
696 | "Negative n passed to glDeleteTextures: %d", n);
|
---|
697 | return;
|
---|
698 | }
|
---|
699 |
|
---|
700 | for (i=0; i<n; i++)
|
---|
701 | {
|
---|
702 | GLuint name = textures[i];
|
---|
703 | CRTextureObj *tObj;
|
---|
704 | GET_TOBJ(tObj, g, name);
|
---|
705 | if (name && tObj)
|
---|
706 | {
|
---|
707 | GLuint u;
|
---|
708 | /* remove from hashtable */
|
---|
709 | crHashtableDelete(g->shared->textureTable, name, NULL);
|
---|
710 |
|
---|
711 | /* if the currentTexture is deleted,
|
---|
712 | ** reset back to the base texture.
|
---|
713 | */
|
---|
714 | for (u = 0; u < g->limits.maxTextureUnits; u++)
|
---|
715 | {
|
---|
716 | if (tObj == t->unit[u].currentTexture1D)
|
---|
717 | {
|
---|
718 | t->unit[u].currentTexture1D = &(t->base1D);
|
---|
719 | }
|
---|
720 | if (tObj == t->unit[u].currentTexture2D)
|
---|
721 | {
|
---|
722 | t->unit[u].currentTexture2D = &(t->base2D);
|
---|
723 | }
|
---|
724 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
725 | if (tObj == t->unit[u].currentTexture3D)
|
---|
726 | {
|
---|
727 | t->unit[u].currentTexture3D = &(t->base3D);
|
---|
728 | }
|
---|
729 | #endif
|
---|
730 | #ifdef CR_ARB_texture_cube_map
|
---|
731 | if (tObj == t->unit[u].currentTextureCubeMap)
|
---|
732 | {
|
---|
733 | t->unit[u].currentTextureCubeMap = &(t->baseCubeMap);
|
---|
734 | }
|
---|
735 | #endif
|
---|
736 | #ifdef CR_NV_texture_rectangle
|
---|
737 | if (tObj == t->unit[u].currentTextureRect)
|
---|
738 | {
|
---|
739 | t->unit[u].currentTextureRect = &(t->baseRect);
|
---|
740 | }
|
---|
741 | #endif
|
---|
742 | }
|
---|
743 |
|
---|
744 | #ifdef CR_EXT_framebuffer_object
|
---|
745 | crStateTextureCheckFBOAPs(GL_DRAW_FRAMEBUFFER, name);
|
---|
746 | crStateTextureCheckFBOAPs(GL_READ_FRAMEBUFFER, name);
|
---|
747 | #endif
|
---|
748 | crStateDeleteTextureObject(tObj);
|
---|
749 | }
|
---|
750 | }
|
---|
751 |
|
---|
752 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
753 | DIRTY(tb->current[t->curTextureUnit], g->neg_bitid);
|
---|
754 | }
|
---|
755 |
|
---|
756 |
|
---|
757 |
|
---|
758 | void STATE_APIENTRY crStateClientActiveTextureARB( GLenum texture )
|
---|
759 | {
|
---|
760 | CRContext *g = GetCurrentContext();
|
---|
761 | CRClientState *c = &(g->client);
|
---|
762 |
|
---|
763 | FLUSH();
|
---|
764 |
|
---|
765 | if (!g->extensions.ARB_multitexture) {
|
---|
766 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
767 | "glClientActiveTextureARB not available");
|
---|
768 | return;
|
---|
769 | }
|
---|
770 |
|
---|
771 | if (g->current.inBeginEnd)
|
---|
772 | {
|
---|
773 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
774 | "glClientActiveTextureARB called in Begin/End");
|
---|
775 | return;
|
---|
776 | }
|
---|
777 |
|
---|
778 | if ( texture < GL_TEXTURE0_ARB ||
|
---|
779 | texture >= GL_TEXTURE0_ARB + g->limits.maxTextureUnits)
|
---|
780 | {
|
---|
781 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
782 | "crStateClientActiveTexture: unit = %d (max is %d)",
|
---|
783 | texture, g->limits.maxTextureUnits );
|
---|
784 | return;
|
---|
785 | }
|
---|
786 |
|
---|
787 | c->curClientTextureUnit = texture - GL_TEXTURE0_ARB;
|
---|
788 | }
|
---|
789 |
|
---|
790 | void STATE_APIENTRY crStateActiveTextureARB( GLenum texture )
|
---|
791 | {
|
---|
792 | CRContext *g = GetCurrentContext();
|
---|
793 | CRTextureState *t = &(g->texture);
|
---|
794 |
|
---|
795 | FLUSH();
|
---|
796 |
|
---|
797 | if (!g->extensions.ARB_multitexture) {
|
---|
798 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
799 | "glActiveTextureARB not available");
|
---|
800 | return;
|
---|
801 | }
|
---|
802 |
|
---|
803 | if (g->current.inBeginEnd)
|
---|
804 | {
|
---|
805 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glActiveTextureARB called in Begin/End");
|
---|
806 | return;
|
---|
807 | }
|
---|
808 |
|
---|
809 | if ( texture < GL_TEXTURE0_ARB || texture >= GL_TEXTURE0_ARB + g->limits.maxTextureUnits)
|
---|
810 | {
|
---|
811 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "Bad texture unit passed to crStateActiveTexture: %d (max is %d)", texture, g->limits.maxTextureUnits );
|
---|
812 | return;
|
---|
813 | }
|
---|
814 |
|
---|
815 | t->curTextureUnit = texture - GL_TEXTURE0_ARB;
|
---|
816 |
|
---|
817 | /* update the current matrix pointer, etc. */
|
---|
818 | if (g->transform.matrixMode == GL_TEXTURE) {
|
---|
819 | crStateMatrixMode(GL_TEXTURE);
|
---|
820 | }
|
---|
821 | }
|
---|
822 |
|
---|
823 | void STATE_APIENTRY crStateBindTexture(GLenum target, GLuint texture)
|
---|
824 | {
|
---|
825 | CRContext *g = GetCurrentContext();
|
---|
826 | CRTextureState *t = &(g->texture);
|
---|
827 | CRTextureObj *tobj;
|
---|
828 | CRStateBits *sb = GetCurrentBits();
|
---|
829 | CRTextureBits *tb = &(sb->texture);
|
---|
830 |
|
---|
831 | FLUSH();
|
---|
832 |
|
---|
833 | if (g->current.inBeginEnd)
|
---|
834 | {
|
---|
835 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glBindTexture called in Begin/End");
|
---|
836 | return;
|
---|
837 | }
|
---|
838 |
|
---|
839 | /* Special Case name = 0 */
|
---|
840 | if (!texture)
|
---|
841 | {
|
---|
842 | switch (target)
|
---|
843 | {
|
---|
844 | case GL_TEXTURE_1D:
|
---|
845 | t->unit[t->curTextureUnit].currentTexture1D = &(t->base1D);
|
---|
846 | break;
|
---|
847 | case GL_TEXTURE_2D:
|
---|
848 | t->unit[t->curTextureUnit].currentTexture2D = &(t->base2D);
|
---|
849 | break;
|
---|
850 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
851 | case GL_TEXTURE_3D:
|
---|
852 | t->unit[t->curTextureUnit].currentTexture3D = &(t->base3D);
|
---|
853 | break;
|
---|
854 | #endif
|
---|
855 | #ifdef CR_ARB_texture_cube_map
|
---|
856 | case GL_TEXTURE_CUBE_MAP_ARB:
|
---|
857 | if (!g->extensions.ARB_texture_cube_map) {
|
---|
858 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
859 | "Invalid target passed to glBindTexture: %d", target);
|
---|
860 | return;
|
---|
861 | }
|
---|
862 | t->unit[t->curTextureUnit].currentTextureCubeMap = &(t->baseCubeMap);
|
---|
863 | break;
|
---|
864 | #endif
|
---|
865 | #ifdef CR_NV_texture_rectangle
|
---|
866 | case GL_TEXTURE_RECTANGLE_NV:
|
---|
867 | if (!g->extensions.NV_texture_rectangle) {
|
---|
868 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
869 | "Invalid target passed to glBindTexture: %d", target);
|
---|
870 | return;
|
---|
871 | }
|
---|
872 | t->unit[t->curTextureUnit].currentTextureRect = &(t->baseRect);
|
---|
873 | break;
|
---|
874 | #endif
|
---|
875 | default:
|
---|
876 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid target passed to glBindTexture: %d", target);
|
---|
877 | return;
|
---|
878 | }
|
---|
879 |
|
---|
880 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
881 | DIRTY(tb->current[t->curTextureUnit], g->neg_bitid);
|
---|
882 | return;
|
---|
883 | }
|
---|
884 |
|
---|
885 | /* texture != 0 */
|
---|
886 | /* Get the texture */
|
---|
887 | GET_TOBJ(tobj, g, texture);
|
---|
888 | if (!tobj)
|
---|
889 | {
|
---|
890 | tobj = crStateTextureAllocate_t(g, texture);
|
---|
891 | }
|
---|
892 |
|
---|
893 | /* Check the targets */
|
---|
894 | if (tobj->target == GL_NONE)
|
---|
895 | {
|
---|
896 | /* Target isn't set so set it now.*/
|
---|
897 | tobj->target = target;
|
---|
898 | }
|
---|
899 | else if (tobj->target != target)
|
---|
900 | {
|
---|
901 | crWarning( "You called glBindTexture with a target of 0x%x, but the texture you wanted was target 0x%x [1D: %x 2D: %x 3D: %x cube: %x]", (int) target, (int) tobj->target, GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, GL_TEXTURE_CUBE_MAP );
|
---|
902 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "Attempt to bind a texture of diffent dimenions");
|
---|
903 | return;
|
---|
904 | }
|
---|
905 |
|
---|
906 | /* Set the current texture */
|
---|
907 | switch (target)
|
---|
908 | {
|
---|
909 | case GL_TEXTURE_1D:
|
---|
910 | t->unit[t->curTextureUnit].currentTexture1D = tobj;
|
---|
911 | break;
|
---|
912 | case GL_TEXTURE_2D:
|
---|
913 | t->unit[t->curTextureUnit].currentTexture2D = tobj;
|
---|
914 | break;
|
---|
915 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
916 | case GL_TEXTURE_3D:
|
---|
917 | t->unit[t->curTextureUnit].currentTexture3D = tobj;
|
---|
918 | break;
|
---|
919 | #endif
|
---|
920 | #ifdef CR_ARB_texture_cube_map
|
---|
921 | case GL_TEXTURE_CUBE_MAP_ARB:
|
---|
922 | t->unit[t->curTextureUnit].currentTextureCubeMap = tobj;
|
---|
923 | break;
|
---|
924 | #endif
|
---|
925 | #ifdef CR_NV_texture_rectangle
|
---|
926 | case GL_TEXTURE_RECTANGLE_NV:
|
---|
927 | t->unit[t->curTextureUnit].currentTextureRect = tobj;
|
---|
928 | break;
|
---|
929 | #endif
|
---|
930 | default:
|
---|
931 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
932 | "Invalid target passed to glBindTexture: %d", target);
|
---|
933 | return;
|
---|
934 | }
|
---|
935 |
|
---|
936 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
937 | DIRTY(tb->current[t->curTextureUnit], g->neg_bitid);
|
---|
938 | }
|
---|
939 |
|
---|
940 |
|
---|
941 | void STATE_APIENTRY
|
---|
942 | crStateTexParameterfv(GLenum target, GLenum pname, const GLfloat *param)
|
---|
943 | {
|
---|
944 | CRContext *g = GetCurrentContext();
|
---|
945 | CRTextureObj *tobj = NULL;
|
---|
946 | CRTextureLevel *tl = NULL;
|
---|
947 | GLenum e = (GLenum) *param;
|
---|
948 | CRStateBits *sb = GetCurrentBits();
|
---|
949 | CRTextureBits *tb = &(sb->texture);
|
---|
950 | unsigned int i;
|
---|
951 |
|
---|
952 | FLUSH();
|
---|
953 |
|
---|
954 | if (g->current.inBeginEnd)
|
---|
955 | {
|
---|
956 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
957 | "TexParameterfv called in Begin/End");
|
---|
958 | return;
|
---|
959 | }
|
---|
960 |
|
---|
961 | crStateGetTextureObjectAndImage(g, target, 0, &tobj, &tl);
|
---|
962 | if (!tobj) {
|
---|
963 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
964 | "TexParamterfv(invalid target=0x%x)", target);
|
---|
965 | return;
|
---|
966 | }
|
---|
967 |
|
---|
968 | switch (pname)
|
---|
969 | {
|
---|
970 | case GL_TEXTURE_MIN_FILTER:
|
---|
971 | if (e != GL_NEAREST &&
|
---|
972 | e != GL_LINEAR &&
|
---|
973 | e != GL_NEAREST_MIPMAP_NEAREST &&
|
---|
974 | e != GL_LINEAR_MIPMAP_NEAREST &&
|
---|
975 | e != GL_NEAREST_MIPMAP_LINEAR &&
|
---|
976 | e != GL_LINEAR_MIPMAP_LINEAR)
|
---|
977 | {
|
---|
978 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
979 | "TexParamterfv: GL_TEXTURE_MIN_FILTER invalid param: %d", e);
|
---|
980 | return;
|
---|
981 | }
|
---|
982 | tobj->minFilter = e;
|
---|
983 | break;
|
---|
984 | case GL_TEXTURE_MAG_FILTER:
|
---|
985 | if (e != GL_NEAREST && e != GL_LINEAR)
|
---|
986 | {
|
---|
987 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
988 | "TexParamterfv: GL_TEXTURE_MAG_FILTER invalid param: %d", e);
|
---|
989 | return;
|
---|
990 | }
|
---|
991 | tobj->magFilter = e;
|
---|
992 | break;
|
---|
993 | case GL_TEXTURE_WRAP_S:
|
---|
994 | if (e == GL_CLAMP || e == GL_REPEAT) {
|
---|
995 | tobj->wrapS = e;
|
---|
996 | }
|
---|
997 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
998 | else if (e == GL_CLAMP_TO_EDGE) {
|
---|
999 | tobj->wrapS = e;
|
---|
1000 | }
|
---|
1001 | #endif
|
---|
1002 | #ifdef GL_CLAMP_TO_EDGE_EXT
|
---|
1003 | else if (e == GL_CLAMP_TO_EDGE_EXT && g->extensions.EXT_texture_edge_clamp) {
|
---|
1004 | tobj->wrapS = e;
|
---|
1005 | }
|
---|
1006 | #endif
|
---|
1007 | #ifdef CR_ARB_texture_border_clamp
|
---|
1008 | else if (e == GL_CLAMP_TO_BORDER_ARB && g->extensions.ARB_texture_border_clamp) {
|
---|
1009 | tobj->wrapS = e;
|
---|
1010 | }
|
---|
1011 | #endif
|
---|
1012 | #ifdef CR_ARB_texture_mirrored_repeat
|
---|
1013 | else if (e == GL_MIRRORED_REPEAT_ARB && g->extensions.ARB_texture_mirrored_repeat) {
|
---|
1014 | tobj->wrapS = e;
|
---|
1015 | }
|
---|
1016 | #endif
|
---|
1017 | else {
|
---|
1018 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
1019 | "TexParameterfv: GL_TEXTURE_WRAP_S invalid param: 0x%x", e);
|
---|
1020 | return;
|
---|
1021 | }
|
---|
1022 | break;
|
---|
1023 | case GL_TEXTURE_WRAP_T:
|
---|
1024 | if (e == GL_CLAMP || e == GL_REPEAT) {
|
---|
1025 | tobj->wrapT = e;
|
---|
1026 | }
|
---|
1027 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
1028 | else if (e == GL_CLAMP_TO_EDGE) {
|
---|
1029 | tobj->wrapT = e;
|
---|
1030 | }
|
---|
1031 | #endif
|
---|
1032 | #ifdef GL_CLAMP_TO_EDGE_EXT
|
---|
1033 | else if (e == GL_CLAMP_TO_EDGE_EXT && g->extensions.EXT_texture_edge_clamp) {
|
---|
1034 | tobj->wrapT = e;
|
---|
1035 | }
|
---|
1036 | #endif
|
---|
1037 | #ifdef CR_ARB_texture_border_clamp
|
---|
1038 | else if (e == GL_CLAMP_TO_BORDER_ARB && g->extensions.ARB_texture_border_clamp) {
|
---|
1039 | tobj->wrapT = e;
|
---|
1040 | }
|
---|
1041 | #endif
|
---|
1042 | #ifdef CR_ARB_texture_mirrored_repeat
|
---|
1043 | else if (e == GL_MIRRORED_REPEAT_ARB && g->extensions.ARB_texture_mirrored_repeat) {
|
---|
1044 | tobj->wrapT = e;
|
---|
1045 | }
|
---|
1046 | #endif
|
---|
1047 | else {
|
---|
1048 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
1049 | "TexParameterfv: GL_TEXTURE_WRAP_T invalid param: 0x%x", e);
|
---|
1050 | return;
|
---|
1051 | }
|
---|
1052 | break;
|
---|
1053 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
1054 | case GL_TEXTURE_WRAP_R:
|
---|
1055 | if (e == GL_CLAMP || e == GL_REPEAT) {
|
---|
1056 | tobj->wrapR = e;
|
---|
1057 | }
|
---|
1058 | else if (e == GL_CLAMP_TO_EDGE) {
|
---|
1059 | tobj->wrapR = e;
|
---|
1060 | }
|
---|
1061 | #ifdef GL_CLAMP_TO_EDGE_EXT
|
---|
1062 | else if (e == GL_CLAMP_TO_EDGE_EXT && g->extensions.EXT_texture_edge_clamp) {
|
---|
1063 | tobj->wrapR = e;
|
---|
1064 | }
|
---|
1065 | #endif
|
---|
1066 | #ifdef CR_ARB_texture_border_clamp
|
---|
1067 | else if (e == GL_CLAMP_TO_BORDER_ARB && g->extensions.ARB_texture_border_clamp) {
|
---|
1068 | tobj->wrapR = e;
|
---|
1069 | }
|
---|
1070 | #endif
|
---|
1071 | #ifdef CR_ARB_texture_mirrored_repeat
|
---|
1072 | else if (e == GL_MIRRORED_REPEAT_ARB && g->extensions.ARB_texture_mirrored_repeat) {
|
---|
1073 | tobj->wrapR = e;
|
---|
1074 | }
|
---|
1075 | #endif
|
---|
1076 | else {
|
---|
1077 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
1078 | "TexParameterfv: GL_TEXTURE_WRAP_R invalid param: 0x%x", e);
|
---|
1079 | return;
|
---|
1080 | }
|
---|
1081 | break;
|
---|
1082 | case GL_TEXTURE_PRIORITY:
|
---|
1083 | tobj->priority = param[0];
|
---|
1084 | break;
|
---|
1085 | case GL_TEXTURE_MIN_LOD:
|
---|
1086 | tobj->minLod = param[0];
|
---|
1087 | break;
|
---|
1088 | case GL_TEXTURE_MAX_LOD:
|
---|
1089 | tobj->maxLod = param[0];
|
---|
1090 | break;
|
---|
1091 | case GL_TEXTURE_BASE_LEVEL:
|
---|
1092 | if (e < 0.0f)
|
---|
1093 | {
|
---|
1094 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
1095 | "TexParameterfv: GL_TEXTURE_BASE_LEVEL invalid param: 0x%x", e);
|
---|
1096 | return;
|
---|
1097 | }
|
---|
1098 | tobj->baseLevel = e;
|
---|
1099 | break;
|
---|
1100 | case GL_TEXTURE_MAX_LEVEL:
|
---|
1101 | if (e < 0.0f)
|
---|
1102 | {
|
---|
1103 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
1104 | "TexParameterfv: GL_TEXTURE_MAX_LEVEL invalid param: 0x%x", e);
|
---|
1105 | return;
|
---|
1106 | }
|
---|
1107 | tobj->maxLevel = e;
|
---|
1108 | break;
|
---|
1109 | #endif
|
---|
1110 | case GL_TEXTURE_BORDER_COLOR:
|
---|
1111 | tobj->borderColor.r = param[0];
|
---|
1112 | tobj->borderColor.g = param[1];
|
---|
1113 | tobj->borderColor.b = param[2];
|
---|
1114 | tobj->borderColor.a = param[3];
|
---|
1115 | break;
|
---|
1116 | #ifdef CR_EXT_texture_filter_anisotropic
|
---|
1117 | case GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
---|
1118 | if (g->extensions.EXT_texture_filter_anisotropic) {
|
---|
1119 | if (param[0] < 1.0f)
|
---|
1120 | {
|
---|
1121 | crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
|
---|
1122 | "TexParameterfv: GL_TEXTURE_MAX_ANISOTROPY_EXT called with parameter less than 1: %f", param[0]);
|
---|
1123 | return;
|
---|
1124 | }
|
---|
1125 | tobj->maxAnisotropy = param[0];
|
---|
1126 | if (tobj->maxAnisotropy > g->limits.maxTextureAnisotropy)
|
---|
1127 | {
|
---|
1128 | tobj->maxAnisotropy = g->limits.maxTextureAnisotropy;
|
---|
1129 | }
|
---|
1130 | }
|
---|
1131 | break;
|
---|
1132 | #endif
|
---|
1133 | #ifdef CR_ARB_depth_texture
|
---|
1134 | case GL_DEPTH_TEXTURE_MODE_ARB:
|
---|
1135 | if (g->extensions.ARB_depth_texture) {
|
---|
1136 | if (param[0] == GL_LUMINANCE ||
|
---|
1137 | param[0] == GL_INTENSITY ||
|
---|
1138 | param[0] == GL_ALPHA) {
|
---|
1139 | tobj->depthMode = (GLenum) param[0];
|
---|
1140 | }
|
---|
1141 | else
|
---|
1142 | {
|
---|
1143 | crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
|
---|
1144 | "TexParameterfv: GL_DEPTH_TEXTURE_MODE_ARB called with invalid parameter: 0x%x", param[0]);
|
---|
1145 | return;
|
---|
1146 | }
|
---|
1147 | }
|
---|
1148 | break;
|
---|
1149 | #endif
|
---|
1150 | #ifdef CR_ARB_shadow
|
---|
1151 | case GL_TEXTURE_COMPARE_MODE_ARB:
|
---|
1152 | if (g->extensions.ARB_shadow) {
|
---|
1153 | if (param[0] == GL_NONE ||
|
---|
1154 | param[0] == GL_COMPARE_R_TO_TEXTURE_ARB) {
|
---|
1155 | tobj->compareMode = (GLenum) param[0];
|
---|
1156 | }
|
---|
1157 | else
|
---|
1158 | {
|
---|
1159 | crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
|
---|
1160 | "TexParameterfv: GL_TEXTURE_COMPARE_MODE_ARB called with invalid parameter: 0x%x", param[0]);
|
---|
1161 | return;
|
---|
1162 | }
|
---|
1163 | }
|
---|
1164 | break;
|
---|
1165 | case GL_TEXTURE_COMPARE_FUNC_ARB:
|
---|
1166 | if (g->extensions.ARB_shadow) {
|
---|
1167 | if (param[0] == GL_LEQUAL ||
|
---|
1168 | param[0] == GL_GEQUAL) {
|
---|
1169 | tobj->compareFunc = (GLenum) param[0];
|
---|
1170 | }
|
---|
1171 | }
|
---|
1172 | #ifdef CR_EXT_shadow_funcs
|
---|
1173 | else if (g->extensions.EXT_shadow_funcs) {
|
---|
1174 | if (param[0] == GL_LEQUAL ||
|
---|
1175 | param[0] == GL_GEQUAL ||
|
---|
1176 | param[0] == GL_LESS ||
|
---|
1177 | param[0] == GL_GREATER ||
|
---|
1178 | param[0] == GL_ALWAYS ||
|
---|
1179 | param[0] == GL_NEVER ) {
|
---|
1180 | tobj->compareFunc = (GLenum) param[0];
|
---|
1181 | }
|
---|
1182 | }
|
---|
1183 | #endif
|
---|
1184 | else {
|
---|
1185 | crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
|
---|
1186 | "TexParameterfv: GL_TEXTURE_COMPARE_FUNC_ARB called with invalid parameter: 0x%x", param[0]);
|
---|
1187 | return;
|
---|
1188 | }
|
---|
1189 | break;
|
---|
1190 | #endif
|
---|
1191 | #ifdef CR_ARB_shadow_ambient
|
---|
1192 | case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
|
---|
1193 | if (g->extensions.ARB_shadow_ambient) {
|
---|
1194 | tobj->compareFailValue = param[0];
|
---|
1195 | }
|
---|
1196 | break;
|
---|
1197 | #endif
|
---|
1198 | #ifdef CR_SGIS_generate_mipmap
|
---|
1199 | case GL_GENERATE_MIPMAP_SGIS:
|
---|
1200 | if (g->extensions.SGIS_generate_mipmap) {
|
---|
1201 | tobj->generateMipmap = param[0] ? GL_TRUE : GL_FALSE;
|
---|
1202 | }
|
---|
1203 | break;
|
---|
1204 | #endif
|
---|
1205 | default:
|
---|
1206 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
1207 | "TexParamterfv: Invalid pname: %d", pname);
|
---|
1208 | return;
|
---|
1209 | }
|
---|
1210 |
|
---|
1211 | DIRTY(tobj->dirty, g->neg_bitid);
|
---|
1212 | for (i = 0; i < g->limits.maxTextureUnits; i++)
|
---|
1213 | {
|
---|
1214 | DIRTY(tobj->paramsBit[i], g->neg_bitid);
|
---|
1215 | }
|
---|
1216 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
1217 | }
|
---|
1218 |
|
---|
1219 |
|
---|
1220 | void STATE_APIENTRY
|
---|
1221 | crStateTexParameteriv(GLenum target, GLenum pname, const GLint *param)
|
---|
1222 | {
|
---|
1223 | GLfloat f_param;
|
---|
1224 | GLcolor f_color;
|
---|
1225 | switch (pname)
|
---|
1226 | {
|
---|
1227 | case GL_TEXTURE_MIN_FILTER:
|
---|
1228 | case GL_TEXTURE_MAG_FILTER:
|
---|
1229 | case GL_TEXTURE_WRAP_S:
|
---|
1230 | case GL_TEXTURE_WRAP_T:
|
---|
1231 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
1232 | case GL_TEXTURE_WRAP_R:
|
---|
1233 | case GL_TEXTURE_PRIORITY:
|
---|
1234 | case GL_TEXTURE_MIN_LOD:
|
---|
1235 | case GL_TEXTURE_MAX_LOD:
|
---|
1236 | case GL_TEXTURE_BASE_LEVEL:
|
---|
1237 | case GL_TEXTURE_MAX_LEVEL:
|
---|
1238 | #endif
|
---|
1239 | #ifdef CR_EXT_texture_filter_anisotropic
|
---|
1240 | case GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
---|
1241 | #endif
|
---|
1242 | #ifdef CR_ARB_depth_texture
|
---|
1243 | case GL_DEPTH_TEXTURE_MODE_ARB:
|
---|
1244 | #endif
|
---|
1245 | #ifdef CR_ARB_shadow
|
---|
1246 | case GL_TEXTURE_COMPARE_MODE_ARB:
|
---|
1247 | case GL_TEXTURE_COMPARE_FUNC_ARB:
|
---|
1248 | #endif
|
---|
1249 | #ifdef CR_ARB_shadow_ambinet
|
---|
1250 | case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
|
---|
1251 | #endif
|
---|
1252 | #ifdef CR_SGIS_generate_mipmap
|
---|
1253 | case GL_GENERATE_MIPMAP_SGIS:
|
---|
1254 | #endif
|
---|
1255 | f_param = (GLfloat) (*param);
|
---|
1256 | crStateTexParameterfv( target, pname, &(f_param) );
|
---|
1257 | break;
|
---|
1258 | case GL_TEXTURE_BORDER_COLOR:
|
---|
1259 | f_color.r = ((GLfloat) param[0])/CR_MAXINT;
|
---|
1260 | f_color.g = ((GLfloat) param[1])/CR_MAXINT;
|
---|
1261 | f_color.b = ((GLfloat) param[2])/CR_MAXINT;
|
---|
1262 | f_color.a = ((GLfloat) param[3])/CR_MAXINT;
|
---|
1263 | crStateTexParameterfv( target, pname, (const GLfloat *) &(f_color) );
|
---|
1264 | break;
|
---|
1265 | default:
|
---|
1266 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
1267 | "TexParamteriv: Invalid pname: %d", pname);
|
---|
1268 | return;
|
---|
1269 | }
|
---|
1270 | }
|
---|
1271 |
|
---|
1272 |
|
---|
1273 | void STATE_APIENTRY
|
---|
1274 | crStateTexParameterf(GLenum target, GLenum pname, GLfloat param)
|
---|
1275 | {
|
---|
1276 | crStateTexParameterfv( target, pname, ¶m );
|
---|
1277 | }
|
---|
1278 |
|
---|
1279 |
|
---|
1280 | void STATE_APIENTRY
|
---|
1281 | crStateTexParameteri(GLenum target, GLenum pname, GLint param) {
|
---|
1282 | GLfloat f_param = (GLfloat) param;
|
---|
1283 | crStateTexParameterfv( target, pname, &f_param );
|
---|
1284 | }
|
---|
1285 |
|
---|
1286 |
|
---|
1287 | void STATE_APIENTRY
|
---|
1288 | crStateTexEnvfv(GLenum target, GLenum pname, const GLfloat *param)
|
---|
1289 | {
|
---|
1290 | CRContext *g = GetCurrentContext();
|
---|
1291 | CRTextureState *t = &(g->texture);
|
---|
1292 | CRStateBits *sb = GetCurrentBits();
|
---|
1293 | CRTextureBits *tb = &(sb->texture);
|
---|
1294 | GLenum e;
|
---|
1295 | GLcolorf c;
|
---|
1296 | GLuint stage = 0;
|
---|
1297 |
|
---|
1298 | (void) stage;
|
---|
1299 |
|
---|
1300 | FLUSH();
|
---|
1301 |
|
---|
1302 | if (g->current.inBeginEnd)
|
---|
1303 | {
|
---|
1304 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
1305 | "glTexEnvfv called in begin/end");
|
---|
1306 | return;
|
---|
1307 | }
|
---|
1308 |
|
---|
1309 | #if CR_EXT_texture_lod_bias
|
---|
1310 | if (target == GL_TEXTURE_FILTER_CONTROL_EXT) {
|
---|
1311 | if (!g->extensions.EXT_texture_lod_bias || pname != GL_TEXTURE_LOD_BIAS_EXT) {
|
---|
1312 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnv");
|
---|
1313 | }
|
---|
1314 | else {
|
---|
1315 | t->unit[t->curTextureUnit].lodBias = *param;
|
---|
1316 | DIRTY(tb->envBit[t->curTextureUnit], g->neg_bitid);
|
---|
1317 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
1318 | }
|
---|
1319 | return;
|
---|
1320 | }
|
---|
1321 | else
|
---|
1322 | #endif
|
---|
1323 | #if CR_ARB_point_sprite
|
---|
1324 | if (target == GL_POINT_SPRITE_ARB) {
|
---|
1325 | if (!g->extensions.ARB_point_sprite || pname != GL_COORD_REPLACE_ARB) {
|
---|
1326 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnv");
|
---|
1327 | }
|
---|
1328 | else {
|
---|
1329 | CRPointBits *pb = &(sb->point);
|
---|
1330 | g->point.coordReplacement[t->curTextureUnit] = *param ? GL_TRUE : GL_FALSE;
|
---|
1331 | DIRTY(pb->coordReplacement[t->curTextureUnit], g->neg_bitid);
|
---|
1332 | DIRTY(pb->dirty, g->neg_bitid);
|
---|
1333 | }
|
---|
1334 | return;
|
---|
1335 | }
|
---|
1336 | else
|
---|
1337 | #endif
|
---|
1338 | if (target != GL_TEXTURE_ENV)
|
---|
1339 | {
|
---|
1340 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
1341 | "glTexEnvfv: target != GL_TEXTURE_ENV: %d", target);
|
---|
1342 | return;
|
---|
1343 | }
|
---|
1344 |
|
---|
1345 | switch (pname)
|
---|
1346 | {
|
---|
1347 | case GL_TEXTURE_ENV_MODE:
|
---|
1348 | e = (GLenum) *param;
|
---|
1349 | if (e != GL_MODULATE &&
|
---|
1350 | e != GL_DECAL &&
|
---|
1351 | e != GL_BLEND &&
|
---|
1352 | e != GL_ADD &&
|
---|
1353 | e != GL_REPLACE &&
|
---|
1354 | e != GL_COMBINE_ARB)
|
---|
1355 | {
|
---|
1356 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
1357 | "glTexEnvfv: invalid param: %f", *param);
|
---|
1358 | return;
|
---|
1359 | }
|
---|
1360 | t->unit[t->curTextureUnit].envMode = e;
|
---|
1361 | break;
|
---|
1362 | case GL_TEXTURE_ENV_COLOR:
|
---|
1363 | c.r = param[0];
|
---|
1364 | c.g = param[1];
|
---|
1365 | c.b = param[2];
|
---|
1366 | c.a = param[3];
|
---|
1367 | if (c.r > 1.0f) c.r = 1.0f;
|
---|
1368 | if (c.g > 1.0f) c.g = 1.0f;
|
---|
1369 | if (c.b > 1.0f) c.b = 1.0f;
|
---|
1370 | if (c.a > 1.0f) c.a = 1.0f;
|
---|
1371 | if (c.r < 0.0f) c.r = 0.0f;
|
---|
1372 | if (c.g < 0.0f) c.g = 0.0f;
|
---|
1373 | if (c.b < 0.0f) c.b = 0.0f;
|
---|
1374 | if (c.a < 0.0f) c.a = 0.0f;
|
---|
1375 | t->unit[t->curTextureUnit].envColor = c;
|
---|
1376 | break;
|
---|
1377 |
|
---|
1378 | #ifdef CR_ARB_texture_env_combine
|
---|
1379 | case GL_COMBINE_RGB_ARB:
|
---|
1380 | e = (GLenum) (GLint) *param;
|
---|
1381 | if (g->extensions.ARB_texture_env_combine &&
|
---|
1382 | (e == GL_REPLACE ||
|
---|
1383 | e == GL_MODULATE ||
|
---|
1384 | e == GL_ADD ||
|
---|
1385 | e == GL_ADD_SIGNED_ARB ||
|
---|
1386 | e == GL_INTERPOLATE_ARB ||
|
---|
1387 | e == GL_SUBTRACT_ARB)) {
|
---|
1388 | t->unit[t->curTextureUnit].combineModeRGB = e;
|
---|
1389 | }
|
---|
1390 | #ifdef CR_ARB_texture_env_dot3
|
---|
1391 | else if (g->extensions.ARB_texture_env_dot3 &&
|
---|
1392 | (e == GL_DOT3_RGB_ARB ||
|
---|
1393 | e == GL_DOT3_RGBA_ARB ||
|
---|
1394 | e == GL_DOT3_RGB_EXT ||
|
---|
1395 | e == GL_DOT3_RGBA_EXT)) {
|
---|
1396 | t->unit[t->curTextureUnit].combineModeRGB = e;
|
---|
1397 | }
|
---|
1398 | #endif
|
---|
1399 | else {
|
---|
1400 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv(param=0x%x", e);
|
---|
1401 | return;
|
---|
1402 | }
|
---|
1403 | break;
|
---|
1404 | case GL_COMBINE_ALPHA_EXT:
|
---|
1405 | e = (GLenum) *param;
|
---|
1406 | if (g->extensions.ARB_texture_env_combine &&
|
---|
1407 | (e == GL_REPLACE ||
|
---|
1408 | e == GL_MODULATE ||
|
---|
1409 | e == GL_ADD ||
|
---|
1410 | e == GL_ADD_SIGNED_ARB ||
|
---|
1411 | e == GL_INTERPOLATE_ARB ||
|
---|
1412 | e == GL_SUBTRACT_ARB)) {
|
---|
1413 | t->unit[t->curTextureUnit].combineModeA = e;
|
---|
1414 | }
|
---|
1415 | else {
|
---|
1416 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv");
|
---|
1417 | return;
|
---|
1418 | }
|
---|
1419 | break;
|
---|
1420 | case GL_SOURCE0_RGB_ARB:
|
---|
1421 | case GL_SOURCE1_RGB_ARB:
|
---|
1422 | case GL_SOURCE2_RGB_ARB:
|
---|
1423 | e = (GLenum) *param;
|
---|
1424 | stage = pname - GL_SOURCE0_RGB_ARB;
|
---|
1425 | if (g->extensions.ARB_texture_env_combine &&
|
---|
1426 | (e == GL_TEXTURE ||
|
---|
1427 | e == GL_CONSTANT_ARB ||
|
---|
1428 | e == GL_PRIMARY_COLOR_ARB ||
|
---|
1429 | e == GL_PREVIOUS_ARB)) {
|
---|
1430 | t->unit[t->curTextureUnit].combineSourceRGB[stage] = e;
|
---|
1431 | }
|
---|
1432 | else if (g->extensions.ARB_texture_env_crossbar &&
|
---|
1433 | e >= GL_TEXTURE0_ARB &&
|
---|
1434 | e < GL_TEXTURE0_ARB + g->limits.maxTextureUnits) {
|
---|
1435 | t->unit[t->curTextureUnit].combineSourceRGB[stage] = e;
|
---|
1436 | }
|
---|
1437 | else {
|
---|
1438 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv");
|
---|
1439 | return;
|
---|
1440 | }
|
---|
1441 | break;
|
---|
1442 | case GL_SOURCE0_ALPHA_ARB:
|
---|
1443 | case GL_SOURCE1_ALPHA_ARB:
|
---|
1444 | case GL_SOURCE2_ALPHA_ARB:
|
---|
1445 | e = (GLenum) *param;
|
---|
1446 | stage = pname - GL_SOURCE0_ALPHA_ARB;
|
---|
1447 | if (g->extensions.ARB_texture_env_combine &&
|
---|
1448 | (e == GL_TEXTURE ||
|
---|
1449 | e == GL_CONSTANT_ARB ||
|
---|
1450 | e == GL_PRIMARY_COLOR_ARB ||
|
---|
1451 | e == GL_PREVIOUS_ARB)) {
|
---|
1452 | t->unit[t->curTextureUnit].combineSourceA[stage] = e;
|
---|
1453 | }
|
---|
1454 | else if (g->extensions.ARB_texture_env_crossbar &&
|
---|
1455 | e >= GL_TEXTURE0_ARB &&
|
---|
1456 | e < GL_TEXTURE0_ARB + g->limits.maxTextureUnits) {
|
---|
1457 | t->unit[t->curTextureUnit].combineSourceA[stage] = e;
|
---|
1458 | }
|
---|
1459 | else {
|
---|
1460 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv");
|
---|
1461 | return;
|
---|
1462 | }
|
---|
1463 | break;
|
---|
1464 | case GL_OPERAND0_RGB_ARB:
|
---|
1465 | case GL_OPERAND1_RGB_ARB:
|
---|
1466 | case GL_OPERAND2_RGB_ARB:
|
---|
1467 | e = (GLenum) *param;
|
---|
1468 | stage = pname - GL_OPERAND0_RGB_ARB;
|
---|
1469 | if (g->extensions.ARB_texture_env_combine &&
|
---|
1470 | (e == GL_SRC_COLOR ||
|
---|
1471 | e == GL_ONE_MINUS_SRC_COLOR ||
|
---|
1472 | e == GL_SRC_ALPHA ||
|
---|
1473 | e == GL_ONE_MINUS_SRC_ALPHA)) {
|
---|
1474 | t->unit[t->curTextureUnit].combineOperandRGB[stage] = e;
|
---|
1475 | }
|
---|
1476 | else {
|
---|
1477 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv");
|
---|
1478 | return;
|
---|
1479 | }
|
---|
1480 | break;
|
---|
1481 | case GL_OPERAND0_ALPHA_ARB:
|
---|
1482 | case GL_OPERAND1_ALPHA_ARB:
|
---|
1483 | case GL_OPERAND2_ALPHA_ARB:
|
---|
1484 | e = (GLenum) *param;
|
---|
1485 | stage = pname - GL_OPERAND0_ALPHA_ARB;
|
---|
1486 | if (g->extensions.ARB_texture_env_combine &&
|
---|
1487 | (e == GL_SRC_ALPHA ||
|
---|
1488 | e == GL_ONE_MINUS_SRC_ALPHA)) {
|
---|
1489 | t->unit[t->curTextureUnit].combineOperandA[stage] = e;
|
---|
1490 | }
|
---|
1491 | else {
|
---|
1492 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv(param=0x%x)", e);
|
---|
1493 | return;
|
---|
1494 | }
|
---|
1495 | break;
|
---|
1496 | case GL_RGB_SCALE_ARB:
|
---|
1497 | if (g->extensions.ARB_texture_env_combine &&
|
---|
1498 | (*param == 1.0 ||
|
---|
1499 | *param == 2.0 ||
|
---|
1500 | *param == 4.0)) {
|
---|
1501 | t->unit[t->curTextureUnit].combineScaleRGB = *param;
|
---|
1502 | }
|
---|
1503 | else {
|
---|
1504 | crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glTexEnvfv");
|
---|
1505 | return;
|
---|
1506 | }
|
---|
1507 | break;
|
---|
1508 | case GL_ALPHA_SCALE:
|
---|
1509 | if (g->extensions.ARB_texture_env_combine &&
|
---|
1510 | (*param == 1.0 ||
|
---|
1511 | *param == 2.0 ||
|
---|
1512 | *param == 4.0)) {
|
---|
1513 | t->unit[t->curTextureUnit].combineScaleA = *param;
|
---|
1514 | }
|
---|
1515 | else {
|
---|
1516 | crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glTexEnvfv");
|
---|
1517 | return;
|
---|
1518 | }
|
---|
1519 | break;
|
---|
1520 | #endif /* CR_ARB_texture_env_combine */
|
---|
1521 |
|
---|
1522 | default:
|
---|
1523 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
1524 | "glTexEnvfv: invalid pname: %d", pname);
|
---|
1525 | return;
|
---|
1526 | }
|
---|
1527 |
|
---|
1528 | DIRTY(tb->envBit[t->curTextureUnit], g->neg_bitid);
|
---|
1529 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
1530 | }
|
---|
1531 |
|
---|
1532 |
|
---|
1533 | void STATE_APIENTRY
|
---|
1534 | crStateTexEnviv(GLenum target, GLenum pname, const GLint *param)
|
---|
1535 | {
|
---|
1536 | GLfloat f_param;
|
---|
1537 | GLcolor f_color;
|
---|
1538 |
|
---|
1539 | switch (pname) {
|
---|
1540 | case GL_TEXTURE_ENV_MODE:
|
---|
1541 | f_param = (GLfloat) (*param);
|
---|
1542 | crStateTexEnvfv( target, pname, &f_param );
|
---|
1543 | break;
|
---|
1544 | case GL_TEXTURE_ENV_COLOR:
|
---|
1545 | f_color.r = ((GLfloat) param[0]) / CR_MAXINT;
|
---|
1546 | f_color.g = ((GLfloat) param[1]) / CR_MAXINT;
|
---|
1547 | f_color.b = ((GLfloat) param[2]) / CR_MAXINT;
|
---|
1548 | f_color.a = ((GLfloat) param[3]) / CR_MAXINT;
|
---|
1549 | crStateTexEnvfv( target, pname, (const GLfloat *) &f_color );
|
---|
1550 | break;
|
---|
1551 | #ifdef CR_ARB_texture_env_combine
|
---|
1552 | case GL_COMBINE_RGB_ARB:
|
---|
1553 | case GL_COMBINE_ALPHA_EXT:
|
---|
1554 | case GL_SOURCE0_RGB_ARB:
|
---|
1555 | case GL_SOURCE1_RGB_ARB:
|
---|
1556 | case GL_SOURCE2_RGB_ARB:
|
---|
1557 | case GL_SOURCE0_ALPHA_ARB:
|
---|
1558 | case GL_SOURCE1_ALPHA_ARB:
|
---|
1559 | case GL_SOURCE2_ALPHA_ARB:
|
---|
1560 | case GL_OPERAND0_RGB_ARB:
|
---|
1561 | case GL_OPERAND1_RGB_ARB:
|
---|
1562 | case GL_OPERAND2_RGB_ARB:
|
---|
1563 | case GL_OPERAND0_ALPHA_ARB:
|
---|
1564 | case GL_OPERAND1_ALPHA_ARB:
|
---|
1565 | case GL_OPERAND2_ALPHA_ARB:
|
---|
1566 | case GL_RGB_SCALE_ARB:
|
---|
1567 | case GL_ALPHA_SCALE:
|
---|
1568 | f_param = (GLfloat) (*param);
|
---|
1569 | crStateTexEnvfv( target, pname, &f_param );
|
---|
1570 | break;
|
---|
1571 | #endif
|
---|
1572 | #ifdef CR_EXT_texture_lod_bias
|
---|
1573 | case GL_TEXTURE_LOD_BIAS_EXT:
|
---|
1574 | f_param = (GLfloat) (*param);
|
---|
1575 | crStateTexEnvfv( target, pname, &f_param);
|
---|
1576 | break;
|
---|
1577 | #endif
|
---|
1578 | #ifdef CR_ARB_point_sprite
|
---|
1579 | case GL_COORD_REPLACE_ARB:
|
---|
1580 | f_param = (GLfloat) *param;
|
---|
1581 | crStateTexEnvfv( target, pname, &f_param);
|
---|
1582 | break;
|
---|
1583 | #endif
|
---|
1584 |
|
---|
1585 | default:
|
---|
1586 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
1587 | "glTexEnvfv: invalid pname: %d", pname);
|
---|
1588 | return;
|
---|
1589 | }
|
---|
1590 | }
|
---|
1591 |
|
---|
1592 |
|
---|
1593 | void STATE_APIENTRY
|
---|
1594 | crStateTexEnvf(GLenum target, GLenum pname, GLfloat param)
|
---|
1595 | {
|
---|
1596 | crStateTexEnvfv( target, pname, ¶m );
|
---|
1597 | }
|
---|
1598 |
|
---|
1599 |
|
---|
1600 | void STATE_APIENTRY
|
---|
1601 | crStateTexEnvi(GLenum target, GLenum pname, GLint param)
|
---|
1602 | {
|
---|
1603 | GLfloat f_param = (GLfloat) param;
|
---|
1604 | crStateTexEnvfv( target, pname, &f_param );
|
---|
1605 | }
|
---|
1606 |
|
---|
1607 |
|
---|
1608 | void STATE_APIENTRY
|
---|
1609 | crStateGetTexEnvfv(GLenum target, GLenum pname, GLfloat *param)
|
---|
1610 | {
|
---|
1611 | CRContext *g = GetCurrentContext();
|
---|
1612 | CRTextureState *t = &(g->texture);
|
---|
1613 |
|
---|
1614 | if (g->current.inBeginEnd)
|
---|
1615 | {
|
---|
1616 | crStateError(__LINE__, __FILE__,GL_INVALID_OPERATION,
|
---|
1617 | "glGetTexEnvfv called in begin/end");
|
---|
1618 | return;
|
---|
1619 | }
|
---|
1620 |
|
---|
1621 | #if CR_EXT_texture_lod_bias
|
---|
1622 | if (target == GL_TEXTURE_FILTER_CONTROL_EXT) {
|
---|
1623 | if (!g->extensions.EXT_texture_lod_bias || pname != GL_TEXTURE_LOD_BIAS_EXT) {
|
---|
1624 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnv");
|
---|
1625 | }
|
---|
1626 | else {
|
---|
1627 | *param = t->unit[t->curTextureUnit].lodBias;
|
---|
1628 | }
|
---|
1629 | return;
|
---|
1630 | }
|
---|
1631 | else
|
---|
1632 | #endif
|
---|
1633 | #if CR_ARB_point_sprite
|
---|
1634 | if (target == GL_POINT_SPRITE_ARB) {
|
---|
1635 | if (!g->extensions.ARB_point_sprite || pname != GL_COORD_REPLACE_ARB) {
|
---|
1636 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnv");
|
---|
1637 | }
|
---|
1638 | else {
|
---|
1639 | *param = (GLfloat) g->point.coordReplacement[t->curTextureUnit];
|
---|
1640 | }
|
---|
1641 | return;
|
---|
1642 | }
|
---|
1643 | else
|
---|
1644 | #endif
|
---|
1645 | if (target != GL_TEXTURE_ENV)
|
---|
1646 | {
|
---|
1647 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
1648 | "glGetTexEnvfv: target != GL_TEXTURE_ENV: %d", target);
|
---|
1649 | return;
|
---|
1650 | }
|
---|
1651 |
|
---|
1652 | switch (pname) {
|
---|
1653 | case GL_TEXTURE_ENV_MODE:
|
---|
1654 | *param = (GLfloat) t->unit[t->curTextureUnit].envMode;
|
---|
1655 | break;
|
---|
1656 | case GL_TEXTURE_ENV_COLOR:
|
---|
1657 | param[0] = t->unit[t->curTextureUnit].envColor.r;
|
---|
1658 | param[1] = t->unit[t->curTextureUnit].envColor.g;
|
---|
1659 | param[2] = t->unit[t->curTextureUnit].envColor.b;
|
---|
1660 | param[3] = t->unit[t->curTextureUnit].envColor.a;
|
---|
1661 | break;
|
---|
1662 | case GL_COMBINE_RGB_ARB:
|
---|
1663 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1664 | *param = (GLfloat) t->unit[t->curTextureUnit].combineModeRGB;
|
---|
1665 | }
|
---|
1666 | else {
|
---|
1667 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
|
---|
1668 | return;
|
---|
1669 | }
|
---|
1670 | break;
|
---|
1671 | case GL_COMBINE_ALPHA_ARB:
|
---|
1672 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1673 | *param = (GLfloat) t->unit[t->curTextureUnit].combineModeA;
|
---|
1674 | }
|
---|
1675 | else {
|
---|
1676 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
|
---|
1677 | return;
|
---|
1678 | }
|
---|
1679 | break;
|
---|
1680 | case GL_SOURCE0_RGB_ARB:
|
---|
1681 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1682 | *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceRGB[0];
|
---|
1683 | }
|
---|
1684 | else {
|
---|
1685 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
|
---|
1686 | return;
|
---|
1687 | }
|
---|
1688 | break;
|
---|
1689 | case GL_SOURCE1_RGB_ARB:
|
---|
1690 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1691 | *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceRGB[1];
|
---|
1692 | }
|
---|
1693 | else {
|
---|
1694 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
|
---|
1695 | return;
|
---|
1696 | }
|
---|
1697 | break;
|
---|
1698 | case GL_SOURCE2_RGB_ARB:
|
---|
1699 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1700 | *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceRGB[2];
|
---|
1701 | }
|
---|
1702 | else {
|
---|
1703 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
|
---|
1704 | return;
|
---|
1705 | }
|
---|
1706 | break;
|
---|
1707 | case GL_SOURCE0_ALPHA_ARB:
|
---|
1708 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1709 | *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceA[0];
|
---|
1710 | }
|
---|
1711 | else {
|
---|
1712 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
|
---|
1713 | return;
|
---|
1714 | }
|
---|
1715 | break;
|
---|
1716 | case GL_SOURCE1_ALPHA_ARB:
|
---|
1717 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1718 | *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceA[1];
|
---|
1719 | }
|
---|
1720 | else {
|
---|
1721 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
|
---|
1722 | return;
|
---|
1723 | }
|
---|
1724 | break;
|
---|
1725 | case GL_SOURCE2_ALPHA_ARB:
|
---|
1726 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1727 | *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceA[2];
|
---|
1728 | }
|
---|
1729 | else {
|
---|
1730 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
|
---|
1731 | return;
|
---|
1732 | }
|
---|
1733 | break;
|
---|
1734 | case GL_OPERAND0_RGB_ARB:
|
---|
1735 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1736 | *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandRGB[0];
|
---|
1737 | }
|
---|
1738 | else {
|
---|
1739 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
|
---|
1740 | return;
|
---|
1741 | }
|
---|
1742 | break;
|
---|
1743 | case GL_OPERAND1_RGB_ARB:
|
---|
1744 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1745 | *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandRGB[1];
|
---|
1746 | }
|
---|
1747 | else {
|
---|
1748 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
|
---|
1749 | return;
|
---|
1750 | }
|
---|
1751 | break;
|
---|
1752 | case GL_OPERAND2_RGB_ARB:
|
---|
1753 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1754 | *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandRGB[2];
|
---|
1755 | }
|
---|
1756 | else {
|
---|
1757 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
|
---|
1758 | return;
|
---|
1759 | }
|
---|
1760 | break;
|
---|
1761 | case GL_OPERAND0_ALPHA_ARB:
|
---|
1762 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1763 | *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandA[0];
|
---|
1764 | }
|
---|
1765 | else {
|
---|
1766 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
|
---|
1767 | return;
|
---|
1768 | }
|
---|
1769 | break;
|
---|
1770 | case GL_OPERAND1_ALPHA_ARB:
|
---|
1771 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1772 | *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandA[1];
|
---|
1773 | }
|
---|
1774 | else {
|
---|
1775 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
|
---|
1776 | return;
|
---|
1777 | }
|
---|
1778 | break;
|
---|
1779 | case GL_OPERAND2_ALPHA_ARB:
|
---|
1780 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1781 | *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandA[2];
|
---|
1782 | }
|
---|
1783 | else {
|
---|
1784 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
|
---|
1785 | return;
|
---|
1786 | }
|
---|
1787 | break;
|
---|
1788 | case GL_RGB_SCALE_ARB:
|
---|
1789 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1790 | *param = t->unit[t->curTextureUnit].combineScaleRGB;
|
---|
1791 | }
|
---|
1792 | else {
|
---|
1793 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
|
---|
1794 | return;
|
---|
1795 | }
|
---|
1796 | break;
|
---|
1797 | case GL_ALPHA_SCALE:
|
---|
1798 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1799 | *param = t->unit[t->curTextureUnit].combineScaleA;
|
---|
1800 | }
|
---|
1801 | else {
|
---|
1802 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
|
---|
1803 | return;
|
---|
1804 | }
|
---|
1805 | break;
|
---|
1806 | default:
|
---|
1807 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
1808 | "glGetTexEnvfv: invalid pname: %d", pname);
|
---|
1809 | return;
|
---|
1810 | }
|
---|
1811 | }
|
---|
1812 |
|
---|
1813 |
|
---|
1814 | void STATE_APIENTRY
|
---|
1815 | crStateGetTexEnviv(GLenum target, GLenum pname, GLint *param)
|
---|
1816 | {
|
---|
1817 | CRContext *g = GetCurrentContext();
|
---|
1818 | CRTextureState *t = &(g->texture);
|
---|
1819 |
|
---|
1820 | if (g->current.inBeginEnd)
|
---|
1821 | {
|
---|
1822 | crStateError(__LINE__, __FILE__,GL_INVALID_OPERATION,
|
---|
1823 | "glGetTexEnviv called in begin/end");
|
---|
1824 | return;
|
---|
1825 | }
|
---|
1826 |
|
---|
1827 | #if CR_EXT_texture_lod_bias
|
---|
1828 | if (target == GL_TEXTURE_FILTER_CONTROL_EXT) {
|
---|
1829 | if (!g->extensions.EXT_texture_lod_bias || pname != GL_TEXTURE_LOD_BIAS_EXT) {
|
---|
1830 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnv");
|
---|
1831 | }
|
---|
1832 | else {
|
---|
1833 | *param = (GLint) t->unit[t->curTextureUnit].lodBias;
|
---|
1834 | }
|
---|
1835 | return;
|
---|
1836 | }
|
---|
1837 | else
|
---|
1838 | #endif
|
---|
1839 | #if CR_ARB_point_sprite
|
---|
1840 | if (target == GL_POINT_SPRITE_ARB) {
|
---|
1841 | if (!g->extensions.ARB_point_sprite || pname != GL_COORD_REPLACE_ARB) {
|
---|
1842 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnv");
|
---|
1843 | }
|
---|
1844 | else {
|
---|
1845 | *param = (GLint) g->point.coordReplacement[t->curTextureUnit];
|
---|
1846 | }
|
---|
1847 | return;
|
---|
1848 | }
|
---|
1849 | else
|
---|
1850 | #endif
|
---|
1851 | if (target != GL_TEXTURE_ENV)
|
---|
1852 | {
|
---|
1853 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
1854 | "glGetTexEnviv: target != GL_TEXTURE_ENV: %d", target);
|
---|
1855 | return;
|
---|
1856 | }
|
---|
1857 |
|
---|
1858 | switch (pname) {
|
---|
1859 | case GL_TEXTURE_ENV_MODE:
|
---|
1860 | *param = (GLint) t->unit[t->curTextureUnit].envMode;
|
---|
1861 | break;
|
---|
1862 | case GL_TEXTURE_ENV_COLOR:
|
---|
1863 | param[0] = (GLint) (t->unit[t->curTextureUnit].envColor.r * CR_MAXINT);
|
---|
1864 | param[1] = (GLint) (t->unit[t->curTextureUnit].envColor.g * CR_MAXINT);
|
---|
1865 | param[2] = (GLint) (t->unit[t->curTextureUnit].envColor.b * CR_MAXINT);
|
---|
1866 | param[3] = (GLint) (t->unit[t->curTextureUnit].envColor.a * CR_MAXINT);
|
---|
1867 | break;
|
---|
1868 | case GL_COMBINE_RGB_ARB:
|
---|
1869 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1870 | *param = (GLint) t->unit[t->curTextureUnit].combineModeRGB;
|
---|
1871 | }
|
---|
1872 | else {
|
---|
1873 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
|
---|
1874 | return;
|
---|
1875 | }
|
---|
1876 | break;
|
---|
1877 | case GL_COMBINE_ALPHA_ARB:
|
---|
1878 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1879 | *param = (GLint) t->unit[t->curTextureUnit].combineModeA;
|
---|
1880 | }
|
---|
1881 | else {
|
---|
1882 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
|
---|
1883 | return;
|
---|
1884 | }
|
---|
1885 | break;
|
---|
1886 | case GL_SOURCE0_RGB_ARB:
|
---|
1887 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1888 | *param = (GLint) t->unit[t->curTextureUnit].combineSourceRGB[0];
|
---|
1889 | }
|
---|
1890 | else {
|
---|
1891 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
|
---|
1892 | return;
|
---|
1893 | }
|
---|
1894 | break;
|
---|
1895 | case GL_SOURCE1_RGB_ARB:
|
---|
1896 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1897 | *param = (GLint) t->unit[t->curTextureUnit].combineSourceRGB[1];
|
---|
1898 | }
|
---|
1899 | else {
|
---|
1900 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
|
---|
1901 | return;
|
---|
1902 | }
|
---|
1903 | break;
|
---|
1904 | case GL_SOURCE2_RGB_ARB:
|
---|
1905 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1906 | *param = (GLint) t->unit[t->curTextureUnit].combineSourceRGB[2];
|
---|
1907 | }
|
---|
1908 | else {
|
---|
1909 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
|
---|
1910 | return;
|
---|
1911 | }
|
---|
1912 | break;
|
---|
1913 | case GL_SOURCE0_ALPHA_ARB:
|
---|
1914 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1915 | *param = (GLint) t->unit[t->curTextureUnit].combineSourceA[0];
|
---|
1916 | }
|
---|
1917 | else {
|
---|
1918 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
|
---|
1919 | return;
|
---|
1920 | }
|
---|
1921 | break;
|
---|
1922 | case GL_SOURCE1_ALPHA_ARB:
|
---|
1923 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1924 | *param = (GLint) t->unit[t->curTextureUnit].combineSourceA[1];
|
---|
1925 | }
|
---|
1926 | else {
|
---|
1927 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
|
---|
1928 | return;
|
---|
1929 | }
|
---|
1930 | break;
|
---|
1931 | case GL_SOURCE2_ALPHA_ARB:
|
---|
1932 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1933 | *param = (GLint) t->unit[t->curTextureUnit].combineSourceA[2];
|
---|
1934 | }
|
---|
1935 | else {
|
---|
1936 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
|
---|
1937 | return;
|
---|
1938 | }
|
---|
1939 | break;
|
---|
1940 | case GL_OPERAND0_RGB_ARB:
|
---|
1941 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1942 | *param = (GLint) t->unit[t->curTextureUnit].combineOperandRGB[0];
|
---|
1943 | }
|
---|
1944 | else {
|
---|
1945 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
|
---|
1946 | return;
|
---|
1947 | }
|
---|
1948 | break;
|
---|
1949 | case GL_OPERAND1_RGB_ARB:
|
---|
1950 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1951 | *param = (GLint) t->unit[t->curTextureUnit].combineOperandRGB[1];
|
---|
1952 | }
|
---|
1953 | else {
|
---|
1954 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
|
---|
1955 | return;
|
---|
1956 | }
|
---|
1957 | break;
|
---|
1958 | case GL_OPERAND2_RGB_ARB:
|
---|
1959 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1960 | *param = (GLint) t->unit[t->curTextureUnit].combineOperandRGB[2];
|
---|
1961 | }
|
---|
1962 | else {
|
---|
1963 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
|
---|
1964 | return;
|
---|
1965 | }
|
---|
1966 | break;
|
---|
1967 | case GL_OPERAND0_ALPHA_ARB:
|
---|
1968 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1969 | *param = (GLint) t->unit[t->curTextureUnit].combineOperandA[0];
|
---|
1970 | }
|
---|
1971 | else {
|
---|
1972 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
|
---|
1973 | return;
|
---|
1974 | }
|
---|
1975 | break;
|
---|
1976 | case GL_OPERAND1_ALPHA_ARB:
|
---|
1977 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1978 | *param = (GLint) t->unit[t->curTextureUnit].combineOperandA[1];
|
---|
1979 | }
|
---|
1980 | else {
|
---|
1981 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
|
---|
1982 | return;
|
---|
1983 | }
|
---|
1984 | break;
|
---|
1985 | case GL_OPERAND2_ALPHA_ARB:
|
---|
1986 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1987 | *param = (GLint) t->unit[t->curTextureUnit].combineOperandA[2];
|
---|
1988 | }
|
---|
1989 | else {
|
---|
1990 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
|
---|
1991 | return;
|
---|
1992 | }
|
---|
1993 | break;
|
---|
1994 | case GL_RGB_SCALE_ARB:
|
---|
1995 | if (g->extensions.ARB_texture_env_combine) {
|
---|
1996 | *param = (GLint) t->unit[t->curTextureUnit].combineScaleRGB;
|
---|
1997 | }
|
---|
1998 | else {
|
---|
1999 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
|
---|
2000 | return;
|
---|
2001 | }
|
---|
2002 | break;
|
---|
2003 | case GL_ALPHA_SCALE:
|
---|
2004 | if (g->extensions.ARB_texture_env_combine) {
|
---|
2005 | *param = (GLint) t->unit[t->curTextureUnit].combineScaleA;
|
---|
2006 | }
|
---|
2007 | else {
|
---|
2008 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
|
---|
2009 | return;
|
---|
2010 | }
|
---|
2011 | break;
|
---|
2012 | default:
|
---|
2013 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2014 | "glGetTexEnviv: invalid pname: %d", pname);
|
---|
2015 | return;
|
---|
2016 | }
|
---|
2017 | }
|
---|
2018 |
|
---|
2019 |
|
---|
2020 | void STATE_APIENTRY
|
---|
2021 | crStateTexGendv(GLenum coord, GLenum pname, const GLdouble *param)
|
---|
2022 | {
|
---|
2023 | CRContext *g = GetCurrentContext();
|
---|
2024 | CRTextureState *t = &(g->texture);
|
---|
2025 | CRTransformState *trans = &(g->transform);
|
---|
2026 | GLvectorf v;
|
---|
2027 | GLenum e;
|
---|
2028 | CRmatrix inv;
|
---|
2029 | CRStateBits *sb = GetCurrentBits();
|
---|
2030 | CRTextureBits *tb = &(sb->texture);
|
---|
2031 |
|
---|
2032 | FLUSH();
|
---|
2033 |
|
---|
2034 | if (g->current.inBeginEnd)
|
---|
2035 | {
|
---|
2036 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
2037 | "glTexGen called in begin/end");
|
---|
2038 | return;
|
---|
2039 | }
|
---|
2040 |
|
---|
2041 | switch (coord)
|
---|
2042 | {
|
---|
2043 | case GL_S:
|
---|
2044 | switch (pname)
|
---|
2045 | {
|
---|
2046 | case GL_TEXTURE_GEN_MODE:
|
---|
2047 | e = (GLenum) *param;
|
---|
2048 | if (e == GL_OBJECT_LINEAR ||
|
---|
2049 | e == GL_EYE_LINEAR ||
|
---|
2050 | e == GL_SPHERE_MAP
|
---|
2051 | #if defined(GL_ARB_texture_cube_map) || defined(GL_EXT_texture_cube_map) || defined(GL_NV_texgen_reflection)
|
---|
2052 | || ((e == GL_REFLECTION_MAP_ARB || e == GL_NORMAL_MAP_ARB)
|
---|
2053 | && g->extensions.ARB_texture_cube_map)
|
---|
2054 | #endif
|
---|
2055 | ) {
|
---|
2056 | t->unit[t->curTextureUnit].gen.s = e;
|
---|
2057 | DIRTY(tb->genMode[t->curTextureUnit], g->neg_bitid);
|
---|
2058 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
2059 | }
|
---|
2060 | else {
|
---|
2061 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2062 | "glTexGendv called with bad param: %lf", *param);
|
---|
2063 | return;
|
---|
2064 | }
|
---|
2065 | break;
|
---|
2066 | case GL_OBJECT_PLANE:
|
---|
2067 | v.x = (GLfloat) param[0];
|
---|
2068 | v.y = (GLfloat) param[1];
|
---|
2069 | v.z = (GLfloat) param[2];
|
---|
2070 | v.w = (GLfloat) param[3];
|
---|
2071 | t->unit[t->curTextureUnit].objSCoeff = v;
|
---|
2072 | DIRTY(tb->objGen[t->curTextureUnit], g->neg_bitid);
|
---|
2073 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
2074 | break;
|
---|
2075 | case GL_EYE_PLANE:
|
---|
2076 | v.x = (GLfloat) param[0];
|
---|
2077 | v.y = (GLfloat) param[1];
|
---|
2078 | v.z = (GLfloat) param[2];
|
---|
2079 | v.w = (GLfloat) param[3];
|
---|
2080 | crMatrixInvertTranspose(&inv, trans->modelViewStack.top);
|
---|
2081 | crStateTransformXformPointMatrixf(&inv, &v);
|
---|
2082 | t->unit[t->curTextureUnit].eyeSCoeff = v;
|
---|
2083 | DIRTY(tb->eyeGen[t->curTextureUnit], g->neg_bitid);
|
---|
2084 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
2085 | break;
|
---|
2086 | default:
|
---|
2087 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2088 | "glTexGendv called with bogus pname: %d", pname);
|
---|
2089 | return;
|
---|
2090 | }
|
---|
2091 | break;
|
---|
2092 | case GL_T:
|
---|
2093 | switch (pname) {
|
---|
2094 | case GL_TEXTURE_GEN_MODE:
|
---|
2095 | e = (GLenum) *param;
|
---|
2096 | if (e == GL_OBJECT_LINEAR ||
|
---|
2097 | e == GL_EYE_LINEAR ||
|
---|
2098 | e == GL_SPHERE_MAP
|
---|
2099 | #if defined(GL_ARB_texture_cube_map) || defined(GL_EXT_texture_cube_map) || defined(GL_NV_texgen_reflection)
|
---|
2100 | || ((e == GL_REFLECTION_MAP_ARB || e == GL_NORMAL_MAP_ARB)
|
---|
2101 | && g->extensions.ARB_texture_cube_map)
|
---|
2102 | #endif
|
---|
2103 | ) {
|
---|
2104 | t->unit[t->curTextureUnit].gen.t = e;
|
---|
2105 | DIRTY(tb->genMode[t->curTextureUnit], g->neg_bitid);
|
---|
2106 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
2107 | }
|
---|
2108 | else {
|
---|
2109 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2110 | "glTexGendv called with bad param: %lf", *param);
|
---|
2111 | return;
|
---|
2112 | }
|
---|
2113 | break;
|
---|
2114 | case GL_OBJECT_PLANE:
|
---|
2115 | v.x = (GLfloat) param[0];
|
---|
2116 | v.y = (GLfloat) param[1];
|
---|
2117 | v.z = (GLfloat) param[2];
|
---|
2118 | v.w = (GLfloat) param[3];
|
---|
2119 | t->unit[t->curTextureUnit].objTCoeff = v;
|
---|
2120 | DIRTY(tb->objGen[t->curTextureUnit], g->neg_bitid);
|
---|
2121 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
2122 | break;
|
---|
2123 | case GL_EYE_PLANE:
|
---|
2124 | v.x = (GLfloat) param[0];
|
---|
2125 | v.y = (GLfloat) param[1];
|
---|
2126 | v.z = (GLfloat) param[2];
|
---|
2127 | v.w = (GLfloat) param[3];
|
---|
2128 | crMatrixInvertTranspose(&inv, trans->modelViewStack.top);
|
---|
2129 | crStateTransformXformPointMatrixf(&inv, &v);
|
---|
2130 | t->unit[t->curTextureUnit].eyeTCoeff = v;
|
---|
2131 | DIRTY(tb->eyeGen[t->curTextureUnit], g->neg_bitid);
|
---|
2132 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
2133 | break;
|
---|
2134 | default:
|
---|
2135 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2136 | "glTexGen called with bogus pname: %d", pname);
|
---|
2137 | return;
|
---|
2138 | }
|
---|
2139 | break;
|
---|
2140 | case GL_R:
|
---|
2141 | switch (pname) {
|
---|
2142 | case GL_TEXTURE_GEN_MODE:
|
---|
2143 | e = (GLenum) *param;
|
---|
2144 | if (e == GL_OBJECT_LINEAR ||
|
---|
2145 | e == GL_EYE_LINEAR ||
|
---|
2146 | e == GL_SPHERE_MAP
|
---|
2147 | #if defined(GL_ARB_texture_cube_map) || defined(GL_EXT_texture_cube_map) || defined(GL_NV_texgen_reflection)
|
---|
2148 | || ((e == GL_REFLECTION_MAP_ARB || e == GL_NORMAL_MAP_ARB)
|
---|
2149 | && g->extensions.ARB_texture_cube_map)
|
---|
2150 | #endif
|
---|
2151 | ) {
|
---|
2152 | t->unit[t->curTextureUnit].gen.r = e;
|
---|
2153 | DIRTY(tb->genMode[t->curTextureUnit], g->neg_bitid);
|
---|
2154 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
2155 | }
|
---|
2156 | else {
|
---|
2157 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2158 | "glTexGen called with bad param: %lf", *param);
|
---|
2159 | return;
|
---|
2160 | }
|
---|
2161 | break;
|
---|
2162 | case GL_OBJECT_PLANE:
|
---|
2163 | v.x = (GLfloat) param[0];
|
---|
2164 | v.y = (GLfloat) param[1];
|
---|
2165 | v.z = (GLfloat) param[2];
|
---|
2166 | v.w = (GLfloat) param[3];
|
---|
2167 | t->unit[t->curTextureUnit].objRCoeff = v;
|
---|
2168 | DIRTY(tb->objGen[t->curTextureUnit], g->neg_bitid);
|
---|
2169 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
2170 | break;
|
---|
2171 | case GL_EYE_PLANE:
|
---|
2172 | v.x = (GLfloat) param[0];
|
---|
2173 | v.y = (GLfloat) param[1];
|
---|
2174 | v.z = (GLfloat) param[2];
|
---|
2175 | v.w = (GLfloat) param[3];
|
---|
2176 | crMatrixInvertTranspose(&inv, trans->modelViewStack.top);
|
---|
2177 | crStateTransformXformPointMatrixf(&inv, &v);
|
---|
2178 | t->unit[t->curTextureUnit].eyeRCoeff = v;
|
---|
2179 | DIRTY(tb->eyeGen[t->curTextureUnit], g->neg_bitid);
|
---|
2180 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
2181 | break;
|
---|
2182 | default:
|
---|
2183 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2184 | "glTexGen called with bogus pname: %d", pname);
|
---|
2185 | return;
|
---|
2186 | }
|
---|
2187 | break;
|
---|
2188 | case GL_Q:
|
---|
2189 | switch (pname) {
|
---|
2190 | case GL_TEXTURE_GEN_MODE:
|
---|
2191 | e = (GLenum) *param;
|
---|
2192 | if (e == GL_OBJECT_LINEAR ||
|
---|
2193 | e == GL_EYE_LINEAR ||
|
---|
2194 | e == GL_SPHERE_MAP)
|
---|
2195 | {
|
---|
2196 | t->unit[t->curTextureUnit].gen.q = e;
|
---|
2197 | DIRTY(tb->genMode[t->curTextureUnit], g->neg_bitid);
|
---|
2198 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
2199 | }
|
---|
2200 | else {
|
---|
2201 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2202 | "glTexGen called with bad param: %lf", *param);
|
---|
2203 | return;
|
---|
2204 | }
|
---|
2205 | break;
|
---|
2206 | case GL_OBJECT_PLANE:
|
---|
2207 | v.x = (GLfloat) param[0];
|
---|
2208 | v.y = (GLfloat) param[1];
|
---|
2209 | v.z = (GLfloat) param[2];
|
---|
2210 | v.w = (GLfloat) param[3];
|
---|
2211 | t->unit[t->curTextureUnit].objQCoeff = v;
|
---|
2212 | DIRTY(tb->objGen[t->curTextureUnit], g->neg_bitid);
|
---|
2213 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
2214 | break;
|
---|
2215 | case GL_EYE_PLANE:
|
---|
2216 | v.x = (GLfloat) param[0];
|
---|
2217 | v.y = (GLfloat) param[1];
|
---|
2218 | v.z = (GLfloat) param[2];
|
---|
2219 | v.w = (GLfloat) param[3];
|
---|
2220 | crMatrixInvertTranspose(&inv, trans->modelViewStack.top);
|
---|
2221 | crStateTransformXformPointMatrixf(&inv, &v);
|
---|
2222 | t->unit[t->curTextureUnit].eyeQCoeff = v;
|
---|
2223 | DIRTY(tb->eyeGen[t->curTextureUnit], g->neg_bitid);
|
---|
2224 | DIRTY(tb->dirty, g->neg_bitid);
|
---|
2225 | break;
|
---|
2226 | default:
|
---|
2227 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2228 | "glTexGen called with bogus pname: %d", pname);
|
---|
2229 | return;
|
---|
2230 | }
|
---|
2231 | break;
|
---|
2232 | default:
|
---|
2233 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2234 | "glTexGen called with bogus coord: %d", coord);
|
---|
2235 | return;
|
---|
2236 | }
|
---|
2237 | }
|
---|
2238 |
|
---|
2239 |
|
---|
2240 | void STATE_APIENTRY
|
---|
2241 | crStateTexGenfv(GLenum coord, GLenum pname, const GLfloat *param)
|
---|
2242 | {
|
---|
2243 | GLdouble d_param;
|
---|
2244 | GLvectord d_vector;
|
---|
2245 | switch (pname)
|
---|
2246 | {
|
---|
2247 | case GL_TEXTURE_GEN_MODE:
|
---|
2248 | d_param = (GLdouble) *param;
|
---|
2249 | crStateTexGendv( coord, pname, &d_param );
|
---|
2250 | break;
|
---|
2251 | case GL_OBJECT_PLANE:
|
---|
2252 | case GL_EYE_PLANE:
|
---|
2253 | d_vector.x = (GLdouble) param[0];
|
---|
2254 | d_vector.y = (GLdouble) param[1];
|
---|
2255 | d_vector.z = (GLdouble) param[2];
|
---|
2256 | d_vector.w = (GLdouble) param[3];
|
---|
2257 | crStateTexGendv( coord, pname, (const double *) &d_vector );
|
---|
2258 | break;
|
---|
2259 | default:
|
---|
2260 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2261 | "glTexGen called with bogus pname: %d", pname);
|
---|
2262 | return;
|
---|
2263 | }
|
---|
2264 | }
|
---|
2265 |
|
---|
2266 |
|
---|
2267 | void STATE_APIENTRY
|
---|
2268 | crStateTexGeniv(GLenum coord, GLenum pname, const GLint *param)
|
---|
2269 | {
|
---|
2270 | GLdouble d_param;
|
---|
2271 | GLvectord d_vector;
|
---|
2272 | switch (pname)
|
---|
2273 | {
|
---|
2274 | case GL_TEXTURE_GEN_MODE:
|
---|
2275 | d_param = (GLdouble) *param;
|
---|
2276 | crStateTexGendv( coord, pname, &d_param );
|
---|
2277 | break;
|
---|
2278 | case GL_OBJECT_PLANE:
|
---|
2279 | case GL_EYE_PLANE:
|
---|
2280 | d_vector.x = (GLdouble) param[0];
|
---|
2281 | d_vector.y = (GLdouble) param[1];
|
---|
2282 | d_vector.z = (GLdouble) param[2];
|
---|
2283 | d_vector.w = (GLdouble) param[3];
|
---|
2284 | crStateTexGendv( coord, pname, (const double *) &d_vector );
|
---|
2285 | break;
|
---|
2286 | default:
|
---|
2287 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2288 | "glTexGen called with bogus pname: %d", pname);
|
---|
2289 | return;
|
---|
2290 | }
|
---|
2291 | }
|
---|
2292 |
|
---|
2293 |
|
---|
2294 | void STATE_APIENTRY
|
---|
2295 | crStateTexGend (GLenum coord, GLenum pname, GLdouble param)
|
---|
2296 | {
|
---|
2297 | crStateTexGendv( coord, pname, ¶m );
|
---|
2298 | }
|
---|
2299 |
|
---|
2300 |
|
---|
2301 | void STATE_APIENTRY
|
---|
2302 | crStateTexGenf(GLenum coord, GLenum pname, GLfloat param)
|
---|
2303 | {
|
---|
2304 | GLdouble d_param = (GLdouble) param;
|
---|
2305 | crStateTexGendv( coord, pname, &d_param );
|
---|
2306 | }
|
---|
2307 |
|
---|
2308 |
|
---|
2309 | void STATE_APIENTRY
|
---|
2310 | crStateTexGeni(GLenum coord, GLenum pname, GLint param)
|
---|
2311 | {
|
---|
2312 | GLdouble d_param = (GLdouble) param;
|
---|
2313 | crStateTexGendv( coord, pname, &d_param );
|
---|
2314 | }
|
---|
2315 |
|
---|
2316 |
|
---|
2317 | void STATE_APIENTRY
|
---|
2318 | crStateGetTexGendv(GLenum coord, GLenum pname, GLdouble *param)
|
---|
2319 | {
|
---|
2320 | CRContext *g = GetCurrentContext();
|
---|
2321 | CRTextureState *t = &(g->texture);
|
---|
2322 |
|
---|
2323 | if (g->current.inBeginEnd)
|
---|
2324 | {
|
---|
2325 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
2326 | "glGetTexGen called in begin/end");
|
---|
2327 | return;
|
---|
2328 | }
|
---|
2329 |
|
---|
2330 | switch (pname) {
|
---|
2331 | case GL_TEXTURE_GEN_MODE:
|
---|
2332 | switch (coord) {
|
---|
2333 | case GL_S:
|
---|
2334 | *param = (GLdouble) t->unit[t->curTextureUnit].gen.s;
|
---|
2335 | break;
|
---|
2336 | case GL_T:
|
---|
2337 | *param = (GLdouble) t->unit[t->curTextureUnit].gen.t;
|
---|
2338 | break;
|
---|
2339 | case GL_R:
|
---|
2340 | *param = (GLdouble) t->unit[t->curTextureUnit].gen.r;
|
---|
2341 | break;
|
---|
2342 | case GL_Q:
|
---|
2343 | *param = (GLdouble) t->unit[t->curTextureUnit].gen.q;
|
---|
2344 | break;
|
---|
2345 | default:
|
---|
2346 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2347 | "glGetTexGen called with bogus coord: %d", coord);
|
---|
2348 | return;
|
---|
2349 | }
|
---|
2350 | break;
|
---|
2351 | case GL_OBJECT_PLANE:
|
---|
2352 | switch (coord) {
|
---|
2353 | case GL_S:
|
---|
2354 | param[0] = (GLdouble) t->unit[t->curTextureUnit].objSCoeff.x;
|
---|
2355 | param[1] = (GLdouble) t->unit[t->curTextureUnit].objSCoeff.y;
|
---|
2356 | param[2] = (GLdouble) t->unit[t->curTextureUnit].objSCoeff.z;
|
---|
2357 | param[3] = (GLdouble) t->unit[t->curTextureUnit].objSCoeff.w;
|
---|
2358 | break;
|
---|
2359 | case GL_T:
|
---|
2360 | param[0] = (GLdouble) t->unit[t->curTextureUnit].objTCoeff.x;
|
---|
2361 | param[1] = (GLdouble) t->unit[t->curTextureUnit].objTCoeff.y;
|
---|
2362 | param[2] = (GLdouble) t->unit[t->curTextureUnit].objTCoeff.z;
|
---|
2363 | param[3] = (GLdouble) t->unit[t->curTextureUnit].objTCoeff.w;
|
---|
2364 | break;
|
---|
2365 | case GL_R:
|
---|
2366 | param[0] = (GLdouble) t->unit[t->curTextureUnit].objRCoeff.x;
|
---|
2367 | param[1] = (GLdouble) t->unit[t->curTextureUnit].objRCoeff.y;
|
---|
2368 | param[2] = (GLdouble) t->unit[t->curTextureUnit].objRCoeff.z;
|
---|
2369 | param[3] = (GLdouble) t->unit[t->curTextureUnit].objRCoeff.w;
|
---|
2370 | break;
|
---|
2371 | case GL_Q:
|
---|
2372 | param[0] = (GLdouble) t->unit[t->curTextureUnit].objQCoeff.x;
|
---|
2373 | param[1] = (GLdouble) t->unit[t->curTextureUnit].objQCoeff.y;
|
---|
2374 | param[2] = (GLdouble) t->unit[t->curTextureUnit].objQCoeff.z;
|
---|
2375 | param[3] = (GLdouble) t->unit[t->curTextureUnit].objQCoeff.w;
|
---|
2376 | break;
|
---|
2377 | default:
|
---|
2378 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2379 | "glGetTexGen called with bogus coord: %d", coord);
|
---|
2380 | return;
|
---|
2381 | }
|
---|
2382 | break;
|
---|
2383 | case GL_EYE_PLANE:
|
---|
2384 | switch (coord) {
|
---|
2385 | case GL_S:
|
---|
2386 | param[0] = (GLdouble) t->unit[t->curTextureUnit].eyeSCoeff.x;
|
---|
2387 | param[1] = (GLdouble) t->unit[t->curTextureUnit].eyeSCoeff.y;
|
---|
2388 | param[2] = (GLdouble) t->unit[t->curTextureUnit].eyeSCoeff.z;
|
---|
2389 | param[3] = (GLdouble) t->unit[t->curTextureUnit].eyeSCoeff.w;
|
---|
2390 | break;
|
---|
2391 | case GL_T:
|
---|
2392 | param[0] = (GLdouble) t->unit[t->curTextureUnit].eyeTCoeff.x;
|
---|
2393 | param[1] = (GLdouble) t->unit[t->curTextureUnit].eyeTCoeff.y;
|
---|
2394 | param[2] = (GLdouble) t->unit[t->curTextureUnit].eyeTCoeff.z;
|
---|
2395 | param[3] = (GLdouble) t->unit[t->curTextureUnit].eyeTCoeff.w;
|
---|
2396 | break;
|
---|
2397 | case GL_R:
|
---|
2398 | param[0] = (GLdouble) t->unit[t->curTextureUnit].eyeRCoeff.x;
|
---|
2399 | param[1] = (GLdouble) t->unit[t->curTextureUnit].eyeRCoeff.y;
|
---|
2400 | param[2] = (GLdouble) t->unit[t->curTextureUnit].eyeRCoeff.z;
|
---|
2401 | param[3] = (GLdouble) t->unit[t->curTextureUnit].eyeRCoeff.w;
|
---|
2402 | break;
|
---|
2403 | case GL_Q:
|
---|
2404 | param[0] = (GLdouble) t->unit[t->curTextureUnit].eyeQCoeff.x;
|
---|
2405 | param[1] = (GLdouble) t->unit[t->curTextureUnit].eyeQCoeff.y;
|
---|
2406 | param[2] = (GLdouble) t->unit[t->curTextureUnit].eyeQCoeff.z;
|
---|
2407 | param[3] = (GLdouble) t->unit[t->curTextureUnit].eyeQCoeff.w;
|
---|
2408 | break;
|
---|
2409 | default:
|
---|
2410 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2411 | "glGetTexGen called with bogus coord: %d", coord);
|
---|
2412 | return;
|
---|
2413 | }
|
---|
2414 | break;
|
---|
2415 | default:
|
---|
2416 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2417 | "glGetTexGen called with bogus pname: %d", pname);
|
---|
2418 | return;
|
---|
2419 | }
|
---|
2420 | }
|
---|
2421 |
|
---|
2422 |
|
---|
2423 | void STATE_APIENTRY
|
---|
2424 | crStateGetTexGenfv(GLenum coord, GLenum pname, GLfloat *param)
|
---|
2425 | {
|
---|
2426 | CRContext *g = GetCurrentContext();
|
---|
2427 | CRTextureState *t = &(g->texture);
|
---|
2428 |
|
---|
2429 | if (g->current.inBeginEnd)
|
---|
2430 | {
|
---|
2431 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
2432 | "glGetTexGenfv called in begin/end");
|
---|
2433 | return;
|
---|
2434 | }
|
---|
2435 |
|
---|
2436 | switch (pname) {
|
---|
2437 | case GL_TEXTURE_GEN_MODE:
|
---|
2438 | switch (coord) {
|
---|
2439 | case GL_S:
|
---|
2440 | *param = (GLfloat) t->unit[t->curTextureUnit].gen.s;
|
---|
2441 | break;
|
---|
2442 | case GL_T:
|
---|
2443 | *param = (GLfloat) t->unit[t->curTextureUnit].gen.t;
|
---|
2444 | break;
|
---|
2445 | case GL_R:
|
---|
2446 | *param = (GLfloat) t->unit[t->curTextureUnit].gen.r;
|
---|
2447 | break;
|
---|
2448 | case GL_Q:
|
---|
2449 | *param = (GLfloat) t->unit[t->curTextureUnit].gen.q;
|
---|
2450 | break;
|
---|
2451 | default:
|
---|
2452 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2453 | "glGetTexGenfv called with bogus coord: %d", coord);
|
---|
2454 | return;
|
---|
2455 | }
|
---|
2456 | break;
|
---|
2457 | case GL_OBJECT_PLANE:
|
---|
2458 | switch (coord) {
|
---|
2459 | case GL_S:
|
---|
2460 | param[0] = t->unit[t->curTextureUnit].objSCoeff.x;
|
---|
2461 | param[1] = t->unit[t->curTextureUnit].objSCoeff.y;
|
---|
2462 | param[2] = t->unit[t->curTextureUnit].objSCoeff.z;
|
---|
2463 | param[3] = t->unit[t->curTextureUnit].objSCoeff.w;
|
---|
2464 | break;
|
---|
2465 | case GL_T:
|
---|
2466 | param[0] = t->unit[t->curTextureUnit].objTCoeff.x;
|
---|
2467 | param[1] = t->unit[t->curTextureUnit].objTCoeff.y;
|
---|
2468 | param[2] = t->unit[t->curTextureUnit].objTCoeff.z;
|
---|
2469 | param[3] = t->unit[t->curTextureUnit].objTCoeff.w;
|
---|
2470 | break;
|
---|
2471 | case GL_R:
|
---|
2472 | param[0] = t->unit[t->curTextureUnit].objRCoeff.x;
|
---|
2473 | param[1] = t->unit[t->curTextureUnit].objRCoeff.y;
|
---|
2474 | param[2] = t->unit[t->curTextureUnit].objRCoeff.z;
|
---|
2475 | param[3] = t->unit[t->curTextureUnit].objRCoeff.w;
|
---|
2476 | break;
|
---|
2477 | case GL_Q:
|
---|
2478 | param[0] = t->unit[t->curTextureUnit].objQCoeff.x;
|
---|
2479 | param[1] = t->unit[t->curTextureUnit].objQCoeff.y;
|
---|
2480 | param[2] = t->unit[t->curTextureUnit].objQCoeff.z;
|
---|
2481 | param[3] = t->unit[t->curTextureUnit].objQCoeff.w;
|
---|
2482 | break;
|
---|
2483 | default:
|
---|
2484 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2485 | "glGetTexGenfv called with bogus coord: %d", coord);
|
---|
2486 | return;
|
---|
2487 | }
|
---|
2488 | break;
|
---|
2489 | case GL_EYE_PLANE:
|
---|
2490 | switch (coord) {
|
---|
2491 | case GL_S:
|
---|
2492 | param[0] = t->unit[t->curTextureUnit].eyeSCoeff.x;
|
---|
2493 | param[1] = t->unit[t->curTextureUnit].eyeSCoeff.y;
|
---|
2494 | param[2] = t->unit[t->curTextureUnit].eyeSCoeff.z;
|
---|
2495 | param[3] = t->unit[t->curTextureUnit].eyeSCoeff.w;
|
---|
2496 | break;
|
---|
2497 | case GL_T:
|
---|
2498 | param[0] = t->unit[t->curTextureUnit].eyeTCoeff.x;
|
---|
2499 | param[1] = t->unit[t->curTextureUnit].eyeTCoeff.y;
|
---|
2500 | param[2] = t->unit[t->curTextureUnit].eyeTCoeff.z;
|
---|
2501 | param[3] = t->unit[t->curTextureUnit].eyeTCoeff.w;
|
---|
2502 | break;
|
---|
2503 | case GL_R:
|
---|
2504 | param[0] = t->unit[t->curTextureUnit].eyeRCoeff.x;
|
---|
2505 | param[1] = t->unit[t->curTextureUnit].eyeRCoeff.y;
|
---|
2506 | param[2] = t->unit[t->curTextureUnit].eyeRCoeff.z;
|
---|
2507 | param[3] = t->unit[t->curTextureUnit].eyeRCoeff.w;
|
---|
2508 | break;
|
---|
2509 | case GL_Q:
|
---|
2510 | param[0] = t->unit[t->curTextureUnit].eyeQCoeff.x;
|
---|
2511 | param[1] = t->unit[t->curTextureUnit].eyeQCoeff.y;
|
---|
2512 | param[2] = t->unit[t->curTextureUnit].eyeQCoeff.z;
|
---|
2513 | param[3] = t->unit[t->curTextureUnit].eyeQCoeff.w;
|
---|
2514 | break;
|
---|
2515 | default:
|
---|
2516 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2517 | "glGetTexGenfv called with bogus coord: %d", coord);
|
---|
2518 | return;
|
---|
2519 | }
|
---|
2520 | break;
|
---|
2521 | default:
|
---|
2522 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2523 | "glGetTexGenfv called with bogus pname: %d", pname);
|
---|
2524 | return;
|
---|
2525 | }
|
---|
2526 | }
|
---|
2527 |
|
---|
2528 |
|
---|
2529 | void STATE_APIENTRY
|
---|
2530 | crStateGetTexGeniv(GLenum coord, GLenum pname, GLint *param)
|
---|
2531 | {
|
---|
2532 | CRContext *g = GetCurrentContext();
|
---|
2533 | CRTextureState *t = &(g->texture);
|
---|
2534 |
|
---|
2535 | if (g->current.inBeginEnd)
|
---|
2536 | {
|
---|
2537 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
2538 | "glGetTexGeniv called in begin/end");
|
---|
2539 | return;
|
---|
2540 | }
|
---|
2541 |
|
---|
2542 | switch (pname) {
|
---|
2543 | case GL_TEXTURE_GEN_MODE:
|
---|
2544 | switch (coord) {
|
---|
2545 | case GL_S:
|
---|
2546 | *param = (GLint) t->unit[t->curTextureUnit].gen.s;
|
---|
2547 | break;
|
---|
2548 | case GL_T:
|
---|
2549 | *param = (GLint) t->unit[t->curTextureUnit].gen.t;
|
---|
2550 | break;
|
---|
2551 | case GL_R:
|
---|
2552 | *param = (GLint) t->unit[t->curTextureUnit].gen.r;
|
---|
2553 | break;
|
---|
2554 | case GL_Q:
|
---|
2555 | *param = (GLint) t->unit[t->curTextureUnit].gen.q;
|
---|
2556 | break;
|
---|
2557 | default:
|
---|
2558 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2559 | "glGetTexGeniv called with bogus coord: %d", coord);
|
---|
2560 | return;
|
---|
2561 | }
|
---|
2562 | break;
|
---|
2563 | case GL_OBJECT_PLANE:
|
---|
2564 | switch (coord) {
|
---|
2565 | case GL_S:
|
---|
2566 | param[0] = (GLint) t->unit[t->curTextureUnit].objSCoeff.x;
|
---|
2567 | param[1] = (GLint) t->unit[t->curTextureUnit].objSCoeff.y;
|
---|
2568 | param[2] = (GLint) t->unit[t->curTextureUnit].objSCoeff.z;
|
---|
2569 | param[3] = (GLint) t->unit[t->curTextureUnit].objSCoeff.w;
|
---|
2570 | break;
|
---|
2571 | case GL_T:
|
---|
2572 | param[0] = (GLint) t->unit[t->curTextureUnit].objTCoeff.x;
|
---|
2573 | param[1] = (GLint) t->unit[t->curTextureUnit].objTCoeff.y;
|
---|
2574 | param[2] = (GLint) t->unit[t->curTextureUnit].objTCoeff.z;
|
---|
2575 | param[3] = (GLint) t->unit[t->curTextureUnit].objTCoeff.w;
|
---|
2576 | break;
|
---|
2577 | case GL_R:
|
---|
2578 | param[0] = (GLint) t->unit[t->curTextureUnit].objRCoeff.x;
|
---|
2579 | param[1] = (GLint) t->unit[t->curTextureUnit].objRCoeff.y;
|
---|
2580 | param[2] = (GLint) t->unit[t->curTextureUnit].objRCoeff.z;
|
---|
2581 | param[3] = (GLint) t->unit[t->curTextureUnit].objRCoeff.w;
|
---|
2582 | break;
|
---|
2583 | case GL_Q:
|
---|
2584 | param[0] = (GLint) t->unit[t->curTextureUnit].objQCoeff.x;
|
---|
2585 | param[1] = (GLint) t->unit[t->curTextureUnit].objQCoeff.y;
|
---|
2586 | param[2] = (GLint) t->unit[t->curTextureUnit].objQCoeff.z;
|
---|
2587 | param[3] = (GLint) t->unit[t->curTextureUnit].objQCoeff.w;
|
---|
2588 | break;
|
---|
2589 | default:
|
---|
2590 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2591 | "glGetTexGeniv called with bogus coord: %d", coord);
|
---|
2592 | return;
|
---|
2593 | }
|
---|
2594 | break;
|
---|
2595 | case GL_EYE_PLANE:
|
---|
2596 | switch (coord) {
|
---|
2597 | case GL_S:
|
---|
2598 | param[0] = (GLint) t->unit[t->curTextureUnit].eyeSCoeff.x;
|
---|
2599 | param[1] = (GLint) t->unit[t->curTextureUnit].eyeSCoeff.y;
|
---|
2600 | param[2] = (GLint) t->unit[t->curTextureUnit].eyeSCoeff.z;
|
---|
2601 | param[3] = (GLint) t->unit[t->curTextureUnit].eyeSCoeff.w;
|
---|
2602 | break;
|
---|
2603 | case GL_T:
|
---|
2604 | param[0] = (GLint) t->unit[t->curTextureUnit].eyeTCoeff.x;
|
---|
2605 | param[1] = (GLint) t->unit[t->curTextureUnit].eyeTCoeff.y;
|
---|
2606 | param[2] = (GLint) t->unit[t->curTextureUnit].eyeTCoeff.z;
|
---|
2607 | param[3] = (GLint) t->unit[t->curTextureUnit].eyeTCoeff.w;
|
---|
2608 | break;
|
---|
2609 | case GL_R:
|
---|
2610 | param[0] = (GLint) t->unit[t->curTextureUnit].eyeRCoeff.x;
|
---|
2611 | param[1] = (GLint) t->unit[t->curTextureUnit].eyeRCoeff.y;
|
---|
2612 | param[2] = (GLint) t->unit[t->curTextureUnit].eyeRCoeff.z;
|
---|
2613 | param[3] = (GLint) t->unit[t->curTextureUnit].eyeRCoeff.w;
|
---|
2614 | break;
|
---|
2615 | case GL_Q:
|
---|
2616 | param[0] = (GLint) t->unit[t->curTextureUnit].eyeQCoeff.x;
|
---|
2617 | param[1] = (GLint) t->unit[t->curTextureUnit].eyeQCoeff.y;
|
---|
2618 | param[2] = (GLint) t->unit[t->curTextureUnit].eyeQCoeff.z;
|
---|
2619 | param[3] = (GLint) t->unit[t->curTextureUnit].eyeQCoeff.w;
|
---|
2620 | break;
|
---|
2621 | default:
|
---|
2622 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2623 | "glGetTexGeniv called with bogus coord: %d", coord);
|
---|
2624 | return;
|
---|
2625 | }
|
---|
2626 | break;
|
---|
2627 | default:
|
---|
2628 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2629 | "glGetTexGen called with bogus pname: %d", pname);
|
---|
2630 | return;
|
---|
2631 | }
|
---|
2632 | }
|
---|
2633 |
|
---|
2634 |
|
---|
2635 | void STATE_APIENTRY
|
---|
2636 | crStateGetTexLevelParameterfv(GLenum target, GLint level,
|
---|
2637 | GLenum pname, GLfloat *params)
|
---|
2638 | {
|
---|
2639 | CRContext *g = GetCurrentContext();
|
---|
2640 | CRTextureState *t = &(g->texture);
|
---|
2641 | CRTextureObj *tobj;
|
---|
2642 | CRTextureLevel *timg;
|
---|
2643 |
|
---|
2644 | if (g->current.inBeginEnd)
|
---|
2645 | {
|
---|
2646 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
2647 | "glGetTexLevelParameterfv called in begin/end");
|
---|
2648 | return;
|
---|
2649 | }
|
---|
2650 |
|
---|
2651 | if (level < 0 && level > t->maxLevel)
|
---|
2652 | {
|
---|
2653 | crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
|
---|
2654 | "glGetTexLevelParameterfv: Invalid level: %d", level);
|
---|
2655 | return;
|
---|
2656 | }
|
---|
2657 |
|
---|
2658 | crStateGetTextureObjectAndImage(g, target, level, &tobj, &timg);
|
---|
2659 | if (!timg)
|
---|
2660 | {
|
---|
2661 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2662 | "GetTexLevelParameterfv: invalid target: 0x%x or level %d",
|
---|
2663 | target, level);
|
---|
2664 | return;
|
---|
2665 | }
|
---|
2666 |
|
---|
2667 | switch (pname)
|
---|
2668 | {
|
---|
2669 | case GL_TEXTURE_WIDTH:
|
---|
2670 | *params = (GLfloat) timg->width;
|
---|
2671 | break;
|
---|
2672 | case GL_TEXTURE_HEIGHT:
|
---|
2673 | *params = (GLfloat) timg->height;
|
---|
2674 | break;
|
---|
2675 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
2676 | case GL_TEXTURE_DEPTH:
|
---|
2677 | *params = (GLfloat) timg->depth;
|
---|
2678 | break;
|
---|
2679 | #endif
|
---|
2680 | case GL_TEXTURE_INTERNAL_FORMAT:
|
---|
2681 | *params = (GLfloat) timg->internalFormat;
|
---|
2682 | break;
|
---|
2683 | case GL_TEXTURE_BORDER:
|
---|
2684 | *params = (GLfloat) timg->border;
|
---|
2685 | break;
|
---|
2686 | case GL_TEXTURE_RED_SIZE:
|
---|
2687 | *params = (GLfloat) timg->texFormat->redbits;
|
---|
2688 | break;
|
---|
2689 | case GL_TEXTURE_GREEN_SIZE:
|
---|
2690 | *params = (GLfloat) timg->texFormat->greenbits;
|
---|
2691 | break;
|
---|
2692 | case GL_TEXTURE_BLUE_SIZE:
|
---|
2693 | *params = (GLfloat) timg->texFormat->bluebits;
|
---|
2694 | break;
|
---|
2695 | case GL_TEXTURE_ALPHA_SIZE:
|
---|
2696 | *params = (GLfloat) timg->texFormat->alphabits;
|
---|
2697 | break;
|
---|
2698 | case GL_TEXTURE_INTENSITY_SIZE:
|
---|
2699 | *params = (GLfloat) timg->texFormat->intensitybits;
|
---|
2700 | break;
|
---|
2701 | case GL_TEXTURE_LUMINANCE_SIZE:
|
---|
2702 | *params = (GLfloat) timg->texFormat->luminancebits;
|
---|
2703 | break;
|
---|
2704 | #if CR_ARB_texture_compression
|
---|
2705 | case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB:
|
---|
2706 | *params = (GLfloat) timg->bytes;
|
---|
2707 | break;
|
---|
2708 | case GL_TEXTURE_COMPRESSED_ARB:
|
---|
2709 | *params = (GLfloat) timg->compressed;
|
---|
2710 | break;
|
---|
2711 | #endif
|
---|
2712 | default:
|
---|
2713 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2714 | "GetTexLevelParameterfv: invalid pname: 0x%x",
|
---|
2715 | pname);
|
---|
2716 | return;
|
---|
2717 | }
|
---|
2718 | }
|
---|
2719 |
|
---|
2720 |
|
---|
2721 | void STATE_APIENTRY
|
---|
2722 | crStateGetTexLevelParameteriv(GLenum target, GLint level,
|
---|
2723 | GLenum pname, GLint *params)
|
---|
2724 | {
|
---|
2725 | CRContext *g = GetCurrentContext();
|
---|
2726 | CRTextureState *t = &(g->texture);
|
---|
2727 | CRTextureObj *tobj;
|
---|
2728 | CRTextureLevel *timg;
|
---|
2729 |
|
---|
2730 | if (g->current.inBeginEnd)
|
---|
2731 | {
|
---|
2732 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
2733 | "glGetTexLevelParameteriv called in begin/end");
|
---|
2734 | return;
|
---|
2735 | }
|
---|
2736 |
|
---|
2737 | if (level < 0 && level > t->maxLevel)
|
---|
2738 | {
|
---|
2739 | crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
|
---|
2740 | "glGetTexLevelParameteriv: Invalid level: %d", level);
|
---|
2741 | return;
|
---|
2742 | }
|
---|
2743 |
|
---|
2744 | crStateGetTextureObjectAndImage(g, target, level, &tobj, &timg);
|
---|
2745 | if (!timg)
|
---|
2746 | {
|
---|
2747 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2748 | "GetTexLevelParameteriv: invalid target: 0x%x",
|
---|
2749 | target);
|
---|
2750 | return;
|
---|
2751 | }
|
---|
2752 |
|
---|
2753 | switch (pname)
|
---|
2754 | {
|
---|
2755 | case GL_TEXTURE_WIDTH:
|
---|
2756 | *params = (GLint) timg->width;
|
---|
2757 | break;
|
---|
2758 | case GL_TEXTURE_HEIGHT:
|
---|
2759 | *params = (GLint) timg->height;
|
---|
2760 | break;
|
---|
2761 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
2762 | case GL_TEXTURE_DEPTH:
|
---|
2763 | *params = (GLint) timg->depth;
|
---|
2764 | break;
|
---|
2765 | #endif
|
---|
2766 | case GL_TEXTURE_INTERNAL_FORMAT:
|
---|
2767 | *params = (GLint) timg->internalFormat;
|
---|
2768 | break;
|
---|
2769 | case GL_TEXTURE_BORDER:
|
---|
2770 | *params = (GLint) timg->border;
|
---|
2771 | break;
|
---|
2772 | case GL_TEXTURE_RED_SIZE:
|
---|
2773 | *params = (GLint) timg->texFormat->redbits;
|
---|
2774 | break;
|
---|
2775 | case GL_TEXTURE_GREEN_SIZE:
|
---|
2776 | *params = (GLint) timg->texFormat->greenbits;
|
---|
2777 | break;
|
---|
2778 | case GL_TEXTURE_BLUE_SIZE:
|
---|
2779 | *params = (GLint) timg->texFormat->bluebits;
|
---|
2780 | break;
|
---|
2781 | case GL_TEXTURE_ALPHA_SIZE:
|
---|
2782 | *params = (GLint) timg->texFormat->alphabits;
|
---|
2783 | break;
|
---|
2784 | case GL_TEXTURE_INTENSITY_SIZE:
|
---|
2785 | *params = (GLint) timg->texFormat->intensitybits;
|
---|
2786 | break;
|
---|
2787 | case GL_TEXTURE_LUMINANCE_SIZE:
|
---|
2788 | *params = (GLint) timg->texFormat->luminancebits;
|
---|
2789 | break;
|
---|
2790 |
|
---|
2791 | #if 0
|
---|
2792 | /* XXX TODO */
|
---|
2793 | case GL_TEXTURE_DEPTH_SIZE:
|
---|
2794 | *params = (GLint) timg->texFormat->depthSize;
|
---|
2795 | break;
|
---|
2796 | #endif
|
---|
2797 | #if CR_ARB_texture_compression
|
---|
2798 | case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB:
|
---|
2799 | *params = (GLint) timg->bytes;
|
---|
2800 | break;
|
---|
2801 | case GL_TEXTURE_COMPRESSED_ARB:
|
---|
2802 | *params = (GLint) timg->compressed;
|
---|
2803 | break;
|
---|
2804 | #endif
|
---|
2805 | default:
|
---|
2806 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2807 | "GetTexLevelParameteriv: invalid pname: 0x%x",
|
---|
2808 | pname);
|
---|
2809 | return;
|
---|
2810 | }
|
---|
2811 | }
|
---|
2812 |
|
---|
2813 |
|
---|
2814 | void STATE_APIENTRY
|
---|
2815 | crStateGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
|
---|
2816 | {
|
---|
2817 | CRContext *g = GetCurrentContext();
|
---|
2818 | CRTextureObj *tobj;
|
---|
2819 | CRTextureLevel *tl;
|
---|
2820 |
|
---|
2821 | if (g->current.inBeginEnd)
|
---|
2822 | {
|
---|
2823 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
2824 | "glGetTexParameterfv called in begin/end");
|
---|
2825 | return;
|
---|
2826 | }
|
---|
2827 |
|
---|
2828 | crStateGetTextureObjectAndImage(g, target, 0, &tobj, &tl);
|
---|
2829 | if (!tobj)
|
---|
2830 | {
|
---|
2831 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2832 | "glGetTexParameterfv: invalid target: 0x%x", target);
|
---|
2833 | return;
|
---|
2834 | }
|
---|
2835 |
|
---|
2836 | switch (pname)
|
---|
2837 | {
|
---|
2838 | case GL_TEXTURE_MAG_FILTER:
|
---|
2839 | *params = (GLfloat) tobj->magFilter;
|
---|
2840 | break;
|
---|
2841 | case GL_TEXTURE_MIN_FILTER:
|
---|
2842 | *params = (GLfloat) tobj->minFilter;
|
---|
2843 | break;
|
---|
2844 | case GL_TEXTURE_WRAP_S:
|
---|
2845 | *params = (GLfloat) tobj->wrapS;
|
---|
2846 | break;
|
---|
2847 | case GL_TEXTURE_WRAP_T:
|
---|
2848 | *params = (GLfloat) tobj->wrapT;
|
---|
2849 | break;
|
---|
2850 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
2851 | case GL_TEXTURE_WRAP_R:
|
---|
2852 | *params = (GLfloat) tobj->wrapR;
|
---|
2853 | break;
|
---|
2854 | case GL_TEXTURE_PRIORITY:
|
---|
2855 | *params = (GLfloat) tobj->priority;
|
---|
2856 | break;
|
---|
2857 | #endif
|
---|
2858 | case GL_TEXTURE_BORDER_COLOR:
|
---|
2859 | params[0] = tobj->borderColor.r;
|
---|
2860 | params[1] = tobj->borderColor.g;
|
---|
2861 | params[2] = tobj->borderColor.b;
|
---|
2862 | params[3] = tobj->borderColor.a;
|
---|
2863 | break;
|
---|
2864 | #ifdef CR_EXT_texture_filter_anisotropic
|
---|
2865 | case GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
---|
2866 | if (g->extensions.EXT_texture_filter_anisotropic) {
|
---|
2867 | *params = (GLfloat) tobj->maxAnisotropy;
|
---|
2868 | }
|
---|
2869 | else {
|
---|
2870 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2871 | "glGetTexParameterfv: invalid pname: 0x%x", pname);
|
---|
2872 | return;
|
---|
2873 | }
|
---|
2874 | break;
|
---|
2875 | #endif
|
---|
2876 | #ifdef CR_ARB_depth_texture
|
---|
2877 | case GL_DEPTH_TEXTURE_MODE_ARB:
|
---|
2878 | if (g->extensions.ARB_depth_texture) {
|
---|
2879 | *params = (GLfloat) tobj->depthMode;
|
---|
2880 | }
|
---|
2881 | else {
|
---|
2882 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2883 | "glGetTexParameter: invalid pname: 0x%x", pname);
|
---|
2884 | return;
|
---|
2885 | }
|
---|
2886 | break;
|
---|
2887 | #endif
|
---|
2888 | #ifdef CR_ARB_shadow
|
---|
2889 | case GL_TEXTURE_COMPARE_MODE_ARB:
|
---|
2890 | if (g->extensions.ARB_shadow) {
|
---|
2891 | *params = (GLfloat) tobj->compareMode;
|
---|
2892 | }
|
---|
2893 | else {
|
---|
2894 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2895 | "glGetTexParameter: invalid pname: 0x%x", pname);
|
---|
2896 | return;
|
---|
2897 | }
|
---|
2898 | break;
|
---|
2899 | case GL_TEXTURE_COMPARE_FUNC_ARB:
|
---|
2900 | if (g->extensions.ARB_shadow) {
|
---|
2901 | *params = (GLfloat) tobj->compareFunc;
|
---|
2902 | }
|
---|
2903 | else {
|
---|
2904 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2905 | "glGetTexParameter: invalid pname: 0x%x", pname);
|
---|
2906 | return;
|
---|
2907 | }
|
---|
2908 | break;
|
---|
2909 | #endif
|
---|
2910 | #ifdef CR_ARB_shadow_ambient
|
---|
2911 | case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
|
---|
2912 | if (g->extensions.ARB_shadow_ambient) {
|
---|
2913 | *params = (GLfloat) tobj->compareFailValue;
|
---|
2914 | }
|
---|
2915 | else {
|
---|
2916 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2917 | "glGetTexParameter: invalid pname: 0x%x", pname);
|
---|
2918 | return;
|
---|
2919 | }
|
---|
2920 | break;
|
---|
2921 | #endif
|
---|
2922 | #ifdef CR_SGIS_generate_mipmap
|
---|
2923 | case GL_GENERATE_MIPMAP_SGIS:
|
---|
2924 | if (g->extensions.SGIS_generate_mipmap) {
|
---|
2925 | *params = (GLfloat) tobj->generateMipmap;
|
---|
2926 | }
|
---|
2927 | else {
|
---|
2928 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2929 | "glGetTexParameter: invalid pname: 0x%x", pname);
|
---|
2930 | return;
|
---|
2931 | }
|
---|
2932 | break;
|
---|
2933 | #endif
|
---|
2934 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
2935 | case GL_TEXTURE_MIN_LOD:
|
---|
2936 | *params = (GLfloat) tobj->minLod;
|
---|
2937 | break;
|
---|
2938 | case GL_TEXTURE_MAX_LOD:
|
---|
2939 | *params = (GLfloat) tobj->maxLod;
|
---|
2940 | break;
|
---|
2941 | case GL_TEXTURE_BASE_LEVEL:
|
---|
2942 | *params = (GLfloat) tobj->baseLevel;
|
---|
2943 | break;
|
---|
2944 | case GL_TEXTURE_MAX_LEVEL:
|
---|
2945 | *params = (GLfloat) tobj->maxLevel;
|
---|
2946 | break;
|
---|
2947 | #endif
|
---|
2948 | #if 0
|
---|
2949 | case GL_TEXTURE_LOD_BIAS_EXT:
|
---|
2950 | /* XXX todo */
|
---|
2951 | *params = (GLfloat) tobj->lodBias;
|
---|
2952 | break;
|
---|
2953 | #endif
|
---|
2954 | case GL_TEXTURE_RESIDENT:
|
---|
2955 | /* XXX todo */
|
---|
2956 | crWarning("glGetTexParameterfv GL_TEXTURE_RESIDENT is unimplemented");
|
---|
2957 | break;
|
---|
2958 | default:
|
---|
2959 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2960 | "glGetTexParameterfv: invalid pname: %d", pname);
|
---|
2961 | return;
|
---|
2962 | }
|
---|
2963 | }
|
---|
2964 |
|
---|
2965 |
|
---|
2966 | void STATE_APIENTRY
|
---|
2967 | crStateGetTexParameteriv(GLenum target, GLenum pname, GLint *params)
|
---|
2968 | {
|
---|
2969 | CRContext *g = GetCurrentContext();
|
---|
2970 | CRTextureObj *tobj;
|
---|
2971 | CRTextureLevel *tl;
|
---|
2972 |
|
---|
2973 | if (g->current.inBeginEnd)
|
---|
2974 | {
|
---|
2975 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
2976 | "glGetTexParameter called in begin/end");
|
---|
2977 | return;
|
---|
2978 | }
|
---|
2979 |
|
---|
2980 | crStateGetTextureObjectAndImage(g, target, 0, &tobj, &tl);
|
---|
2981 | if (!tobj)
|
---|
2982 | {
|
---|
2983 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
2984 | "glGetTexParameteriv: invalid target: 0x%x", target);
|
---|
2985 | return;
|
---|
2986 | }
|
---|
2987 |
|
---|
2988 | switch (pname)
|
---|
2989 | {
|
---|
2990 | case GL_TEXTURE_MAG_FILTER:
|
---|
2991 | *params = (GLint) tobj->magFilter;
|
---|
2992 | break;
|
---|
2993 | case GL_TEXTURE_MIN_FILTER:
|
---|
2994 | *params = (GLint) tobj->minFilter;
|
---|
2995 | break;
|
---|
2996 | case GL_TEXTURE_WRAP_S:
|
---|
2997 | *params = (GLint) tobj->wrapS;
|
---|
2998 | break;
|
---|
2999 | case GL_TEXTURE_WRAP_T:
|
---|
3000 | *params = (GLint) tobj->wrapT;
|
---|
3001 | break;
|
---|
3002 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
3003 | case GL_TEXTURE_WRAP_R:
|
---|
3004 | *params = (GLint) tobj->wrapR;
|
---|
3005 | break;
|
---|
3006 | case GL_TEXTURE_PRIORITY:
|
---|
3007 | *params = (GLint) tobj->priority;
|
---|
3008 | break;
|
---|
3009 | #endif
|
---|
3010 | case GL_TEXTURE_BORDER_COLOR:
|
---|
3011 | params[0] = (GLint) (tobj->borderColor.r * CR_MAXINT);
|
---|
3012 | params[1] = (GLint) (tobj->borderColor.g * CR_MAXINT);
|
---|
3013 | params[2] = (GLint) (tobj->borderColor.b * CR_MAXINT);
|
---|
3014 | params[3] = (GLint) (tobj->borderColor.a * CR_MAXINT);
|
---|
3015 | break;
|
---|
3016 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
3017 | case GL_TEXTURE_MIN_LOD:
|
---|
3018 | *params = (GLint) tobj->minLod;
|
---|
3019 | break;
|
---|
3020 | case GL_TEXTURE_MAX_LOD:
|
---|
3021 | *params = (GLint) tobj->maxLod;
|
---|
3022 | break;
|
---|
3023 | case GL_TEXTURE_BASE_LEVEL:
|
---|
3024 | *params = (GLint) tobj->baseLevel;
|
---|
3025 | break;
|
---|
3026 | case GL_TEXTURE_MAX_LEVEL:
|
---|
3027 | *params = (GLint) tobj->maxLevel;
|
---|
3028 | break;
|
---|
3029 | #endif
|
---|
3030 | #ifdef CR_EXT_texture_filter_anisotropic
|
---|
3031 | case GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
---|
3032 | if (g->extensions.EXT_texture_filter_anisotropic) {
|
---|
3033 | *params = (GLint) tobj->maxAnisotropy;
|
---|
3034 | }
|
---|
3035 | else {
|
---|
3036 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
3037 | "glGetTexParameter: invalid pname: 0x%x", pname);
|
---|
3038 | return;
|
---|
3039 | }
|
---|
3040 | break;
|
---|
3041 | #endif
|
---|
3042 | #ifdef CR_ARB_depth_texture
|
---|
3043 | case GL_DEPTH_TEXTURE_MODE_ARB:
|
---|
3044 | if (g->extensions.ARB_depth_texture) {
|
---|
3045 | *params = (GLint) tobj->depthMode;
|
---|
3046 | }
|
---|
3047 | else {
|
---|
3048 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
3049 | "glGetTexParameter: invalid pname: 0x%x", pname);
|
---|
3050 | return;
|
---|
3051 | }
|
---|
3052 | break;
|
---|
3053 | #endif
|
---|
3054 | #ifdef CR_ARB_shadow
|
---|
3055 | case GL_TEXTURE_COMPARE_MODE_ARB:
|
---|
3056 | if (g->extensions.ARB_shadow) {
|
---|
3057 | *params = (GLint) tobj->compareMode;
|
---|
3058 | }
|
---|
3059 | else {
|
---|
3060 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
3061 | "glGetTexParameter: invalid pname: 0x%x", pname);
|
---|
3062 | return;
|
---|
3063 | }
|
---|
3064 | break;
|
---|
3065 | case GL_TEXTURE_COMPARE_FUNC_ARB:
|
---|
3066 | if (g->extensions.ARB_shadow) {
|
---|
3067 | *params = (GLint) tobj->compareFunc;
|
---|
3068 | }
|
---|
3069 | else {
|
---|
3070 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
3071 | "glGetTexParameter: invalid pname: 0x%x", pname);
|
---|
3072 | return;
|
---|
3073 | }
|
---|
3074 | break;
|
---|
3075 | #endif
|
---|
3076 | #ifdef CR_ARB_shadow_ambient
|
---|
3077 | case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
|
---|
3078 | if (g->extensions.ARB_shadow_ambient) {
|
---|
3079 | *params = (GLint) tobj->compareFailValue;
|
---|
3080 | }
|
---|
3081 | else {
|
---|
3082 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
3083 | "glGetTexParameter: invalid pname: 0x%x", pname);
|
---|
3084 | return;
|
---|
3085 | }
|
---|
3086 | break;
|
---|
3087 | #endif
|
---|
3088 | #ifdef CR_SGIS_generate_mipmap
|
---|
3089 | case GL_GENERATE_MIPMAP_SGIS:
|
---|
3090 | if (g->extensions.SGIS_generate_mipmap) {
|
---|
3091 | *params = (GLint) tobj->generateMipmap;
|
---|
3092 | }
|
---|
3093 | else {
|
---|
3094 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
3095 | "glGetTexParameter: invalid pname: 0x%x", pname);
|
---|
3096 | return;
|
---|
3097 | }
|
---|
3098 | break;
|
---|
3099 | #endif
|
---|
3100 | case GL_TEXTURE_RESIDENT:
|
---|
3101 | /* XXX todo */
|
---|
3102 | crWarning("glGetTexParameteriv GL_TEXTURE_RESIDENT is unimplemented");
|
---|
3103 | break;
|
---|
3104 | default:
|
---|
3105 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
3106 | "glGetTexParameter: invalid pname: %d", pname);
|
---|
3107 | return;
|
---|
3108 | }
|
---|
3109 | }
|
---|
3110 |
|
---|
3111 |
|
---|
3112 | void STATE_APIENTRY
|
---|
3113 | crStatePrioritizeTextures(GLsizei n, const GLuint *textures,
|
---|
3114 | const GLclampf *priorities)
|
---|
3115 | {
|
---|
3116 | UNUSED(n);
|
---|
3117 | UNUSED(textures);
|
---|
3118 | UNUSED(priorities);
|
---|
3119 | /* TODO: */
|
---|
3120 | return;
|
---|
3121 | }
|
---|
3122 |
|
---|
3123 |
|
---|
3124 | GLboolean STATE_APIENTRY
|
---|
3125 | crStateAreTexturesResident(GLsizei n, const GLuint *textures,
|
---|
3126 | GLboolean *residences)
|
---|
3127 | {
|
---|
3128 | UNUSED(n);
|
---|
3129 | UNUSED(textures);
|
---|
3130 | UNUSED(residences);
|
---|
3131 | /* TODO: */
|
---|
3132 | return GL_TRUE;
|
---|
3133 | }
|
---|
3134 |
|
---|
3135 |
|
---|
3136 | GLboolean STATE_APIENTRY
|
---|
3137 | crStateIsTexture(GLuint texture)
|
---|
3138 | {
|
---|
3139 | CRContext *g = GetCurrentContext();
|
---|
3140 | CRTextureObj *tobj;
|
---|
3141 |
|
---|
3142 | GET_TOBJ(tobj, g, texture);
|
---|
3143 | return tobj != NULL;
|
---|
3144 | }
|
---|