blob: 434514f7d303d548725c608528091f9f49788658 [file] [log] [blame]
shannon.woods@transgaming.combdf2d802013-02-28 23:16:20 +00001#include "precompiled.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002//
shannon.woods%transgaming.com@gtempaccount.com8dce6512013-04-13 03:42:19 +00003// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004// Use of this source code is governed by a BSD-style license that can be
5// found in the LICENSE file.
6//
7
8// libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions.
9
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +000010#include "common/version.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000011
12#include "libGLESv2/main.h"
shannonwoods@chromium.orga2ecfcc2013-05-30 00:11:59 +000013#include "common/utilities.h"
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +000014#include "libGLESv2/formatutils.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000015#include "libGLESv2/Buffer.h"
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000016#include "libGLESv2/Fence.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000017#include "libGLESv2/Framebuffer.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000018#include "libGLESv2/Renderbuffer.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000019#include "libGLESv2/Program.h"
apatrick@chromium.orgea09f9b2012-06-08 00:45:32 +000020#include "libGLESv2/ProgramBinary.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000021#include "libGLESv2/Texture.h"
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000022#include "libGLESv2/Query.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000023#include "libGLESv2/Context.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000024
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +000025bool validImageSize(const gl::Context *context, GLint level, GLsizei width, GLsizei height, GLsizei depth)
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000026{
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +000027 if (level < 0 || width < 0 || height < 0 || depth < 0)
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000028 {
29 return false;
30 }
31
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +000032 if (context->supportsNonPower2Texture())
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000033 {
34 return true;
35 }
36
37 if (level == 0)
38 {
39 return true;
40 }
41
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +000042 if (gl::isPow2(width) && gl::isPow2(height) && gl::isPow2(depth))
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000043 {
44 return true;
45 }
46
47 return false;
48}
49
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +000050bool validCompressedImageSize(GLsizei width, GLsizei height)
51{
52 if (width != 1 && width != 2 && width % 4 != 0)
53 {
54 return false;
55 }
56
57 if (height != 1 && height != 2 && height % 4 != 0)
58 {
59 return false;
60 }
61
62 return true;
63}
64
daniel@transgaming.com8833dd22012-06-05 19:49:58 +000065// Verify that format/type are one of the combinations from table 3.4.
66bool checkTextureFormatType(GLenum format, GLenum type)
67{
68 // validate <format> by itself (used as secondary key below)
69 switch (format)
70 {
71 case GL_RGBA:
72 case GL_BGRA_EXT:
73 case GL_RGB:
74 case GL_ALPHA:
75 case GL_LUMINANCE:
76 case GL_LUMINANCE_ALPHA:
77 case GL_DEPTH_COMPONENT:
78 case GL_DEPTH_STENCIL_OES:
79 break;
80 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000081 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +000082 }
83
84 // invalid <type> -> sets INVALID_ENUM
85 // invalid <format>+<type> combination -> sets INVALID_OPERATION
86 switch (type)
87 {
88 case GL_UNSIGNED_BYTE:
89 switch (format)
90 {
91 case GL_RGBA:
92 case GL_BGRA_EXT:
93 case GL_RGB:
94 case GL_ALPHA:
95 case GL_LUMINANCE:
96 case GL_LUMINANCE_ALPHA:
97 return true;
98 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000099 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000100 }
101
102 case GL_FLOAT:
103 case GL_HALF_FLOAT_OES:
104 switch (format)
105 {
106 case GL_RGBA:
107 case GL_RGB:
108 case GL_ALPHA:
109 case GL_LUMINANCE:
110 case GL_LUMINANCE_ALPHA:
111 return true;
112 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000113 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000114 }
115
116 case GL_UNSIGNED_SHORT_4_4_4_4:
117 case GL_UNSIGNED_SHORT_5_5_5_1:
118 switch (format)
119 {
120 case GL_RGBA:
121 return true;
122 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000123 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000124 }
125
126 case GL_UNSIGNED_SHORT_5_6_5:
127 switch (format)
128 {
129 case GL_RGB:
130 return true;
131 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000132 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000133 }
134
135 case GL_UNSIGNED_SHORT:
136 case GL_UNSIGNED_INT:
137 switch (format)
138 {
139 case GL_DEPTH_COMPONENT:
140 return true;
141 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000142 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000143 }
144
145 case GL_UNSIGNED_INT_24_8_OES:
146 switch (format)
147 {
148 case GL_DEPTH_STENCIL_OES:
149 return true;
150 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000151 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000152 }
153
154 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000155 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000156 }
157}
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000158
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000159bool validateSubImageParams2D(bool compressed, GLsizei width, GLsizei height,
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000160 GLint xoffset, GLint yoffset, GLint level, GLenum format, GLenum type,
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000161 gl::Texture2D *texture)
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000162{
163 if (!texture)
164 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000165 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000166 }
167
daniel@transgaming.com92f49922012-05-09 15:49:19 +0000168 if (compressed != texture->isCompressed(level))
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000169 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000170 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000171 }
172
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000173 if (format != GL_NONE)
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000174 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000175 GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000176 if (internalformat != texture->getInternalFormat(level))
177 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000178 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000179 }
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000180 }
181
182 if (compressed)
183 {
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000184 if ((width % 4 != 0 && width != texture->getWidth(0)) ||
185 (height % 4 != 0 && height != texture->getHeight(0)))
186 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000187 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000188 }
189 }
190
191 if (xoffset + width > texture->getWidth(level) ||
192 yoffset + height > texture->getHeight(level))
193 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000194 return gl::error(GL_INVALID_VALUE, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000195 }
196
197 return true;
198}
199
200bool validateSubImageParamsCube(bool compressed, GLsizei width, GLsizei height,
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000201 GLint xoffset, GLint yoffset, GLenum target, GLint level, GLenum format, GLenum type,
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000202 gl::TextureCubeMap *texture)
203{
204 if (!texture)
205 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000206 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000207 }
208
daniel@transgaming.com4df88e82012-05-09 15:49:24 +0000209 if (compressed != texture->isCompressed(target, level))
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000210 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000211 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000212 }
213
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000214 if (format != GL_NONE)
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000215 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000216 GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000217 if (internalformat != texture->getInternalFormat(target, level))
218 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000219 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000220 }
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000221 }
222
223 if (compressed)
224 {
daniel@transgaming.com4df88e82012-05-09 15:49:24 +0000225 if ((width % 4 != 0 && width != texture->getWidth(target, 0)) ||
226 (height % 4 != 0 && height != texture->getHeight(target, 0)))
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000227 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000228 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000229 }
230 }
231
daniel@transgaming.com4df88e82012-05-09 15:49:24 +0000232 if (xoffset + width > texture->getWidth(target, level) ||
233 yoffset + height > texture->getHeight(target, level))
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000234 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000235 return gl::error(GL_INVALID_VALUE, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000236 }
237
238 return true;
239}
240
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000241bool validateES2TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage,
242 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
243 GLint border, GLenum format, GLenum type, const GLvoid *pixels)
244{
245 if (!validImageSize(context, level, width, height, 1))
246 {
247 return gl::error(GL_INVALID_VALUE, false);
248 }
249
250 if (isCompressed && !validCompressedImageSize(width, height))
251 {
252 return gl::error(GL_INVALID_OPERATION, false);
253 }
254
255 if (level < 0 || xoffset < 0 ||
256 std::numeric_limits<GLsizei>::max() - xoffset < width ||
257 std::numeric_limits<GLsizei>::max() - yoffset < height)
258 {
259 return gl::error(GL_INVALID_VALUE, false);
260 }
261
262 if (!isSubImage && !isCompressed && internalformat != GLint(format))
263 {
264 return gl::error(GL_INVALID_OPERATION, false);
265 }
266
267 gl::Texture *texture = NULL;
268 bool textureCompressed = false;
269 GLenum textureInternalFormat = GL_NONE;
270 GLint textureLevelWidth = 0;
271 GLint textureLevelHeight = 0;
272 switch (target)
273 {
274 case GL_TEXTURE_2D:
275 {
276 if (width > (context->getMaximum2DTextureDimension() >> level) ||
277 height > (context->getMaximum2DTextureDimension() >> level))
278 {
279 return gl::error(GL_INVALID_VALUE, false);
280 }
281
282 gl::Texture2D *tex2d = context->getTexture2D();
283 if (tex2d)
284 {
285 textureCompressed = tex2d->isCompressed(level);
286 textureInternalFormat = tex2d->getInternalFormat(level);
287 textureLevelWidth = tex2d->getWidth(level);
288 textureLevelHeight = tex2d->getHeight(level);
289 texture = tex2d;
290 }
291
292 if (isSubImage && !validateSubImageParams2D(isCompressed, width, height, xoffset, yoffset,
293 level, format, type, tex2d))
294 {
295 return false;
296 }
297
298 texture = tex2d;
299 }
300 break;
301
302 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
303 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
304 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
305 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
306 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
307 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
308 {
309 if (!isSubImage && width != height)
310 {
311 return gl::error(GL_INVALID_VALUE, false);
312 }
313
314 if (width > (context->getMaximumCubeTextureDimension() >> level) ||
315 height > (context->getMaximumCubeTextureDimension() >> level))
316 {
317 return gl::error(GL_INVALID_VALUE, false);
318 }
319
320 gl::TextureCubeMap *texCube = context->getTextureCubeMap();
321 if (texCube)
322 {
323 textureCompressed = texCube->isCompressed(target, level);
324 textureInternalFormat = texCube->getInternalFormat(target, level);
325 textureLevelWidth = texCube->getWidth(target, level);
326 textureLevelHeight = texCube->getHeight(target, level);
327 texture = texCube;
328 }
329
330 if (isSubImage && !validateSubImageParamsCube(isCompressed, width, height, xoffset, yoffset,
331 target, level, format, type, texCube))
332 {
333 return false;
334 }
335 }
336 break;
337
338 default:
339 return gl::error(GL_INVALID_ENUM, false);
340 }
341
342 if (!texture)
343 {
344 return gl::error(GL_INVALID_OPERATION, false);
345 }
346
347 if (!isSubImage && texture->isImmutable())
348 {
349 return gl::error(GL_INVALID_OPERATION, false);
350 }
351
352 // Verify zero border
353 if (border != 0)
354 {
355 return gl::error(GL_INVALID_VALUE, false);
356 }
357
358 // Verify texture is not requesting more mip levels than are available.
359 if (level > context->getMaximumTextureLevel())
360 {
361 return gl::error(GL_INVALID_VALUE, false);
362 }
363
364 GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat;
365 if (isCompressed)
366 {
367 switch (actualInternalFormat)
368 {
369 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
370 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
371 if (!context->supportsDXT1Textures())
372 {
373 return gl::error(GL_INVALID_ENUM, false);
374 }
375 break;
376 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
377 if (!context->supportsDXT3Textures())
378 {
379 return gl::error(GL_INVALID_ENUM, false);
380 }
381 break;
382 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
383 if (!context->supportsDXT5Textures())
384 {
385 return gl::error(GL_INVALID_ENUM, false);
386 }
387 break;
388 default:
389 return gl::error(GL_INVALID_ENUM, false);
390 }
391 }
392 else
393 {
394 // validate <type> by itself (used as secondary key below)
395 switch (type)
396 {
397 case GL_UNSIGNED_BYTE:
398 case GL_UNSIGNED_SHORT_5_6_5:
399 case GL_UNSIGNED_SHORT_4_4_4_4:
400 case GL_UNSIGNED_SHORT_5_5_5_1:
401 case GL_UNSIGNED_SHORT:
402 case GL_UNSIGNED_INT:
403 case GL_UNSIGNED_INT_24_8_OES:
404 case GL_HALF_FLOAT_OES:
405 case GL_FLOAT:
406 break;
407 default:
408 return gl::error(GL_INVALID_ENUM, false);
409 }
410
411 // validate <format> + <type> combinations
412 // - invalid <format> -> sets INVALID_ENUM
413 // - invalid <format>+<type> combination -> sets INVALID_OPERATION
414 switch (format)
415 {
416 case GL_ALPHA:
417 case GL_LUMINANCE:
418 case GL_LUMINANCE_ALPHA:
419 switch (type)
420 {
421 case GL_UNSIGNED_BYTE:
422 case GL_FLOAT:
423 case GL_HALF_FLOAT_OES:
424 break;
425 default:
426 return gl::error(GL_INVALID_OPERATION, false);
427 }
428 break;
429 case GL_RGB:
430 switch (type)
431 {
432 case GL_UNSIGNED_BYTE:
433 case GL_UNSIGNED_SHORT_5_6_5:
434 case GL_FLOAT:
435 case GL_HALF_FLOAT_OES:
436 break;
437 default:
438 return gl::error(GL_INVALID_OPERATION, false);
439 }
440 break;
441 case GL_RGBA:
442 switch (type)
443 {
444 case GL_UNSIGNED_BYTE:
445 case GL_UNSIGNED_SHORT_4_4_4_4:
446 case GL_UNSIGNED_SHORT_5_5_5_1:
447 case GL_FLOAT:
448 case GL_HALF_FLOAT_OES:
449 break;
450 default:
451 return gl::error(GL_INVALID_OPERATION, false);
452 }
453 break;
454 case GL_BGRA_EXT:
455 switch (type)
456 {
457 case GL_UNSIGNED_BYTE:
458 break;
459 default:
460 return gl::error(GL_INVALID_OPERATION, false);
461 }
462 break;
463 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below
464 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
465 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
466 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
467 break;
468 case GL_DEPTH_COMPONENT:
469 switch (type)
470 {
471 case GL_UNSIGNED_SHORT:
472 case GL_UNSIGNED_INT:
473 break;
474 default:
475 return gl::error(GL_INVALID_OPERATION, false);
476 }
477 break;
478 case GL_DEPTH_STENCIL_OES:
479 switch (type)
480 {
481 case GL_UNSIGNED_INT_24_8_OES:
482 break;
483 default:
484 return gl::error(GL_INVALID_OPERATION, false);
485 }
486 break;
487 default:
488 return gl::error(GL_INVALID_ENUM, false);
489 }
490
491 switch (format)
492 {
493 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
494 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
495 if (context->supportsDXT1Textures())
496 {
497 return gl::error(GL_INVALID_OPERATION, false);
498 }
499 else
500 {
501 return gl::error(GL_INVALID_ENUM, false);
502 }
503 break;
504 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
505 if (context->supportsDXT3Textures())
506 {
507 return gl::error(GL_INVALID_OPERATION, false);
508 }
509 else
510 {
511 return gl::error(GL_INVALID_ENUM, false);
512 }
513 break;
514 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
515 if (context->supportsDXT5Textures())
516 {
517 return gl::error(GL_INVALID_OPERATION, false);
518 }
519 else
520 {
521 return gl::error(GL_INVALID_ENUM, false);
522 }
523 break;
524 case GL_DEPTH_COMPONENT:
525 case GL_DEPTH_STENCIL_OES:
526 if (!context->supportsDepthTextures())
527 {
528 return gl::error(GL_INVALID_VALUE, false);
529 }
530 if (target != GL_TEXTURE_2D)
531 {
532 return gl::error(GL_INVALID_OPERATION, false);
533 }
534 // OES_depth_texture supports loading depth data and multiple levels,
535 // but ANGLE_depth_texture does not
536 if (pixels != NULL || level != 0)
537 {
538 return gl::error(GL_INVALID_OPERATION, false);
539 }
540 break;
541 default:
542 break;
543 }
544
545 if (type == GL_FLOAT)
546 {
547 if (!context->supportsFloat32Textures())
548 {
549 return gl::error(GL_INVALID_ENUM, false);
550 }
551 }
552 else if (type == GL_HALF_FLOAT_OES)
553 {
554 if (!context->supportsFloat16Textures())
555 {
556 return gl::error(GL_INVALID_ENUM, false);
557 }
558 }
559 }
560
561 return true;
562}
563
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +0000564bool validateES3TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage,
565 GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
566 GLint border, GLenum format, GLenum type)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000567{
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000568 // Validate image size
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000569 if (!validImageSize(context, level, width, height, depth))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000570 {
571 return gl::error(GL_INVALID_VALUE, false);
572 }
573
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000574 if (isCompressed && !validCompressedImageSize(width, height))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000575 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000576 return gl::error(GL_INVALID_OPERATION, false);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000577 }
578
579 // Verify zero border
580 if (border != 0)
581 {
582 return gl::error(GL_INVALID_VALUE, false);
583 }
584
585 // Validate dimensions based on Context limits and validate the texture
586 if (level > context->getMaximumTextureLevel())
587 {
588 return gl::error(GL_INVALID_VALUE, false);
589 }
590
591 gl::Texture *texture = NULL;
592 bool textureCompressed = false;
593 GLenum textureInternalFormat = GL_NONE;
594 GLint textureLevelWidth = 0;
595 GLint textureLevelHeight = 0;
596 GLint textureLevelDepth = 0;
597 switch (target)
598 {
599 case GL_TEXTURE_2D:
600 {
601 if (width > (context->getMaximum2DTextureDimension() >> level) ||
602 height > (context->getMaximum2DTextureDimension() >> level))
603 {
604 return gl::error(GL_INVALID_VALUE, false);
605 }
606
607 gl::Texture2D *texture2d = context->getTexture2D();
608 if (texture2d)
609 {
610 textureCompressed = texture2d->isCompressed(level);
611 textureInternalFormat = texture2d->getInternalFormat(level);
612 textureLevelWidth = texture2d->getWidth(level);
613 textureLevelHeight = texture2d->getHeight(level);
614 textureLevelDepth = 1;
615 texture = texture2d;
616 }
617 }
618 break;
619
620 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
621 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
622 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
623 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
624 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
625 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
626 {
shannonwoods@chromium.org92852cf2013-05-30 00:14:12 +0000627 if (!isSubImage && width != height)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000628 {
629 return gl::error(GL_INVALID_VALUE, false);
630 }
631
632 if (width > (context->getMaximumCubeTextureDimension() >> level))
633 {
634 return gl::error(GL_INVALID_VALUE, false);
635 }
636
637 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
638 if (textureCube)
639 {
640 textureCompressed = textureCube->isCompressed(target, level);
641 textureInternalFormat = textureCube->getInternalFormat(target, level);
642 textureLevelWidth = textureCube->getWidth(target, level);
643 textureLevelHeight = textureCube->getHeight(target, level);
644 textureLevelDepth = 1;
645 texture = textureCube;
646 }
647 }
648 break;
649
650 case GL_TEXTURE_3D:
651 {
652 if (width > (context->getMaximum3DTextureDimension() >> level) ||
653 height > (context->getMaximum3DTextureDimension() >> level) ||
654 depth > (context->getMaximum3DTextureDimension() >> level))
655 {
656 return gl::error(GL_INVALID_VALUE, false);
657 }
658
659 gl::Texture3D *texture3d = context->getTexture3D();
660 if (texture3d)
661 {
662 textureCompressed = texture3d->isCompressed(level);
663 textureInternalFormat = texture3d->getInternalFormat(level);
664 textureLevelWidth = texture3d->getWidth(level);
665 textureLevelHeight = texture3d->getHeight(level);
666 textureLevelDepth = texture3d->getDepth(level);
667 texture = texture3d;
668 }
669 }
670 break;
671
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +0000672 case GL_TEXTURE_2D_ARRAY:
673 {
674 if (width > (context->getMaximum2DTextureDimension() >> level) ||
675 height > (context->getMaximum2DTextureDimension() >> level) ||
676 depth > (context->getMaximum2DArrayTextureLayers() >> level))
677 {
678 return gl::error(GL_INVALID_VALUE, false);
679 }
680
681 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
682 if (texture2darray)
683 {
684 textureCompressed = texture2darray->isCompressed(level);
685 textureInternalFormat = texture2darray->getInternalFormat(level);
686 textureLevelWidth = texture2darray->getWidth(level);
687 textureLevelHeight = texture2darray->getHeight(level);
688 textureLevelDepth = texture2darray->getDepth(level);
689 texture = texture2darray;
690 }
691 }
692 break;
693
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000694 default:
695 return gl::error(GL_INVALID_ENUM, false);
696 }
697
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000698 if (!texture)
699 {
700 return gl::error(GL_INVALID_OPERATION, false);
701 }
702
shannonwoods@chromium.orgcf2533c2013-05-30 00:14:18 +0000703 if (texture->isImmutable() && !isSubImage)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000704 {
705 return gl::error(GL_INVALID_OPERATION, false);
706 }
707
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000708 // Validate texture formats
709 GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat;
710 if (isCompressed)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000711 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000712 if (!gl::IsFormatCompressed(actualInternalFormat, context->getClientVersion()))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000713 {
714 return gl::error(GL_INVALID_ENUM, false);
715 }
716
717 if (target == GL_TEXTURE_3D)
718 {
719 return gl::error(GL_INVALID_OPERATION, false);
720 }
721 }
722 else
723 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000724 if (!gl::IsValidInternalFormat(actualInternalFormat, context) ||
725 !gl::IsValidFormat(format, context->getClientVersion()) ||
726 !gl::IsValidType(type, context->getClientVersion()))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000727 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000728 return gl::error(GL_INVALID_ENUM, false);
729 }
730
731 if (!gl::IsValidFormatCombination(actualInternalFormat, format, type, context->getClientVersion()))
732 {
733 return gl::error(GL_INVALID_OPERATION, false);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000734 }
735
736 if ((target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) &&
737 (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL))
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000738 {
739 return gl::error(GL_INVALID_OPERATION, false);
740 }
741 }
742
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000743 // Validate sub image parameters
744 if (isSubImage)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000745 {
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000746 if (isCompressed != textureCompressed)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000747 {
748 return gl::error(GL_INVALID_OPERATION, false);
749 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000750
751 if (format != GL_NONE)
752 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000753 GLenum internalformat = gl::GetSizedInternalFormat(format, type, context->getClientVersion());
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000754 if (internalformat != textureInternalFormat)
755 {
756 return gl::error(GL_INVALID_OPERATION, false);
757 }
758 }
759
760 if (isCompressed)
761 {
762 if ((width % 4 != 0 && width != textureLevelWidth) ||
763 (height % 4 != 0 && height != textureLevelHeight))
764 {
765 return gl::error(GL_INVALID_OPERATION, false);
766 }
767 }
768
769 if (width == 0 || height == 0 || depth == 0)
770 {
771 return false;
772 }
773
774 if (xoffset < 0 || yoffset < 0 || zoffset < 0)
775 {
776 return gl::error(GL_INVALID_VALUE, false);
777 }
778
779 if (std::numeric_limits<GLsizei>::max() - xoffset < width ||
780 std::numeric_limits<GLsizei>::max() - yoffset < height ||
781 std::numeric_limits<GLsizei>::max() - zoffset < depth)
782 {
783 return gl::error(GL_INVALID_VALUE, false);
784 }
785
786 if (xoffset + width > textureLevelWidth ||
787 yoffset + height > textureLevelHeight ||
788 zoffset + depth > textureLevelDepth)
789 {
790 return gl::error(GL_INVALID_VALUE, false);
791 }
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000792 }
793
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000794 return true;
795}
796
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000797
798bool validateES2CopyTexImageParameters(gl::Context* context, GLenum target, GLint level, GLenum internalformat, bool isSubImage,
799 GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height,
800 GLint border)
801{
802 if (!gl::IsInternalTextureTarget(target))
803 {
804 return gl::error(GL_INVALID_ENUM, false);
805 }
806
807 if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0)
808 {
809 return gl::error(GL_INVALID_VALUE, false);
810 }
811
812 if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
813 {
814 return gl::error(GL_INVALID_VALUE, false);
815 }
816
817 if (width == 0 || height == 0)
818 {
819 return false;
820 }
821
822 // Verify zero border
823 if (border != 0)
824 {
825 return gl::error(GL_INVALID_VALUE, false);
826 }
827
828 // Validate dimensions based on Context limits and validate the texture
829 if (level > context->getMaximumTextureLevel())
830 {
831 return gl::error(GL_INVALID_VALUE, false);
832 }
833
834 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
835
836 if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
837 {
838 return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
839 }
840
841 if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0)
842 {
843 return gl::error(GL_INVALID_OPERATION, false);
844 }
845
846 GLenum colorbufferFormat = framebuffer->getReadColorbuffer()->getInternalFormat();
847 gl::Texture *texture = NULL;
848 GLenum textureFormat = GL_RGBA;
849
850 switch (target)
851 {
852 case GL_TEXTURE_2D:
853 {
854 if (width > (context->getMaximum2DTextureDimension() >> level) ||
855 height > (context->getMaximum2DTextureDimension() >> level))
856 {
857 return gl::error(GL_INVALID_VALUE, false);
858 }
859
860 gl::Texture2D *tex2d = context->getTexture2D();
861 if (tex2d)
862 {
863 if (isSubImage && !validateSubImageParams2D(false, width, height, xoffset, yoffset, level, GL_NONE, GL_NONE, tex2d))
864 {
865 return false; // error already registered by validateSubImageParams
866 }
867 texture = tex2d;
868 textureFormat = gl::GetFormat(tex2d->getInternalFormat(level), context->getClientVersion());
869 }
870 }
871 break;
872
873 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
874 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
875 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
876 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
877 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
878 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
879 {
880 if (!isSubImage && width != height)
881 {
882 return gl::error(GL_INVALID_VALUE, false);
883 }
884
885 if (width > (context->getMaximumCubeTextureDimension() >> level) ||
886 height > (context->getMaximumCubeTextureDimension() >> level))
887 {
888 return gl::error(GL_INVALID_VALUE, false);
889 }
890
891 gl::TextureCubeMap *texcube = context->getTextureCubeMap();
892 if (texcube)
893 {
894 if (isSubImage && !validateSubImageParamsCube(false, width, height, xoffset, yoffset, target, level, GL_NONE, GL_NONE, texcube))
895 {
896 return false; // error already registered by validateSubImageParams
897 }
898 texture = texcube;
899 textureFormat = gl::GetFormat(texcube->getInternalFormat(target, level), context->getClientVersion());
900 }
901 }
902 break;
903
904 default:
905 return gl::error(GL_INVALID_ENUM, false);
906 }
907
908 if (!texture)
909 {
910 return gl::error(GL_INVALID_OPERATION, false);
911 }
912
913 if (texture->isImmutable() && !isSubImage)
914 {
915 return gl::error(GL_INVALID_OPERATION, false);
916 }
917
918
919 // [OpenGL ES 2.0.24] table 3.9
920 if (isSubImage)
921 {
922 switch (textureFormat)
923 {
924 case GL_ALPHA:
925 if (colorbufferFormat != GL_ALPHA8_EXT &&
926 colorbufferFormat != GL_RGBA4 &&
927 colorbufferFormat != GL_RGB5_A1 &&
928 colorbufferFormat != GL_RGBA8_OES)
929 {
930 return gl::error(GL_INVALID_OPERATION, false);
931 }
932 break;
933 case GL_LUMINANCE:
934 case GL_RGB:
935 if (colorbufferFormat != GL_RGB565 &&
936 colorbufferFormat != GL_RGB8_OES &&
937 colorbufferFormat != GL_RGBA4 &&
938 colorbufferFormat != GL_RGB5_A1 &&
939 colorbufferFormat != GL_RGBA8_OES)
940 {
941 return gl::error(GL_INVALID_OPERATION, false);
942 }
943 break;
944 case GL_LUMINANCE_ALPHA:
945 case GL_RGBA:
946 if (colorbufferFormat != GL_RGBA4 &&
947 colorbufferFormat != GL_RGB5_A1 &&
948 colorbufferFormat != GL_RGBA8_OES)
949 {
950 return gl::error(GL_INVALID_OPERATION, false);
951 }
952 break;
953 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
954 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
955 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
956 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
957 return gl::error(GL_INVALID_OPERATION, false);
958 case GL_DEPTH_COMPONENT:
959 case GL_DEPTH_STENCIL_OES:
960 return gl::error(GL_INVALID_OPERATION, false);
961 default:
962 return gl::error(GL_INVALID_OPERATION, false);
963 }
964 }
965 else
966 {
967 switch (internalformat)
968 {
969 case GL_ALPHA:
970 if (colorbufferFormat != GL_ALPHA8_EXT &&
971 colorbufferFormat != GL_RGBA4 &&
972 colorbufferFormat != GL_RGB5_A1 &&
973 colorbufferFormat != GL_BGRA8_EXT &&
974 colorbufferFormat != GL_RGBA8_OES)
975 {
976 return gl::error(GL_INVALID_OPERATION, false);
977 }
978 break;
979 case GL_LUMINANCE:
980 case GL_RGB:
981 if (colorbufferFormat != GL_RGB565 &&
982 colorbufferFormat != GL_RGB8_OES &&
983 colorbufferFormat != GL_RGBA4 &&
984 colorbufferFormat != GL_RGB5_A1 &&
985 colorbufferFormat != GL_BGRA8_EXT &&
986 colorbufferFormat != GL_RGBA8_OES)
987 {
988 return gl::error(GL_INVALID_OPERATION, false);
989 }
990 break;
991 case GL_LUMINANCE_ALPHA:
992 case GL_RGBA:
993 if (colorbufferFormat != GL_RGBA4 &&
994 colorbufferFormat != GL_RGB5_A1 &&
995 colorbufferFormat != GL_BGRA8_EXT &&
996 colorbufferFormat != GL_RGBA8_OES)
997 {
998 return gl::error(GL_INVALID_OPERATION, false);
999 }
1000 break;
1001 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1002 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1003 if (context->supportsDXT1Textures())
1004 {
1005 return gl::error(GL_INVALID_OPERATION, false);
1006 }
1007 else
1008 {
1009 return gl::error(GL_INVALID_ENUM, false);
1010 }
1011 break;
1012 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
1013 if (context->supportsDXT3Textures())
1014 {
1015 return gl::error(GL_INVALID_OPERATION, false);
1016 }
1017 else
1018 {
1019 return gl::error(GL_INVALID_ENUM, false);
1020 }
1021 break;
1022 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
1023 if (context->supportsDXT5Textures())
1024 {
1025 return gl::error(GL_INVALID_OPERATION, false);
1026 }
1027 else
1028 {
1029 return gl::error(GL_INVALID_ENUM, false);
1030 }
1031 break;
1032 case GL_DEPTH_COMPONENT:
1033 case GL_DEPTH_COMPONENT16:
1034 case GL_DEPTH_COMPONENT32_OES:
1035 case GL_DEPTH_STENCIL_OES:
1036 case GL_DEPTH24_STENCIL8_OES:
1037 if (context->supportsDepthTextures())
1038 {
1039 return gl::error(GL_INVALID_OPERATION, false);
1040 }
1041 else
1042 {
1043 return gl::error(GL_INVALID_ENUM, false);
1044 }
1045 default:
1046 return gl::error(GL_INVALID_ENUM, false);
1047 }
1048 }
1049
1050 return true;
1051}
1052
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001053bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLint level, GLenum internalformat,
1054 bool isSubImage, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y,
1055 GLsizei width, GLsizei height, GLint border)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001056{
1057 if (level < 0 || xoffset < 0 || yoffset < 0 || zoffset < 0 || width < 0 || height < 0)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +00001058 {
1059 return gl::error(GL_INVALID_VALUE, false);
1060 }
1061
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001062 if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
1063 {
1064 return gl::error(GL_INVALID_VALUE, false);
1065 }
1066
1067 if (width == 0 || height == 0)
1068 {
1069 return false;
1070 }
1071
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001072 if (border != 0)
1073 {
1074 return gl::error(GL_INVALID_VALUE, false);
1075 }
1076
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001077 if (level > context->getMaximumTextureLevel())
1078 {
1079 return gl::error(GL_INVALID_VALUE, false);
1080 }
1081
1082 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
1083
1084 if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
1085 {
1086 return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
1087 }
1088
1089 if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0)
1090 {
1091 return gl::error(GL_INVALID_OPERATION, false);
1092 }
1093
1094 gl::Renderbuffer *source = framebuffer->getReadColorbuffer();
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001095 GLenum colorbufferInternalFormat = source->getInternalFormat();
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001096 gl::Texture *texture = NULL;
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001097 GLenum textureInternalFormat = GL_NONE;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001098 bool textureCompressed = false;
1099 GLint textureLevelWidth = 0;
1100 GLint textureLevelHeight = 0;
1101 GLint textureLevelDepth = 0;
1102 switch (target)
1103 {
1104 case GL_TEXTURE_2D:
1105 {
1106 gl::Texture2D *texture2d = context->getTexture2D();
1107 if (texture2d)
1108 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001109 textureInternalFormat = texture2d->getInternalFormat(level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001110 textureCompressed = texture2d->isCompressed(level);
1111 textureLevelWidth = texture2d->getWidth(level);
1112 textureLevelHeight = texture2d->getHeight(level);
1113 textureLevelDepth = 1;
1114 texture = texture2d;
1115 }
1116 }
1117 break;
1118
1119 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1120 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1121 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1122 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1123 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1124 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1125 {
1126 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
1127 if (textureCube)
1128 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001129 textureInternalFormat = textureCube->getInternalFormat(target, level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001130 textureCompressed = textureCube->isCompressed(target, level);
1131 textureLevelWidth = textureCube->getWidth(target, level);
1132 textureLevelHeight = textureCube->getHeight(target, level);
1133 textureLevelDepth = 1;
1134 texture = textureCube;
1135 }
1136 }
1137 break;
1138
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001139 case GL_TEXTURE_2D_ARRAY:
1140 {
1141 gl::Texture2DArray *texture2dArray = context->getTexture2DArray();
1142 if (texture2dArray)
1143 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001144 textureInternalFormat = texture2dArray->getInternalFormat(level);
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001145 textureCompressed = texture2dArray->isCompressed(level);
1146 textureLevelWidth = texture2dArray->getWidth(level);
1147 textureLevelHeight = texture2dArray->getHeight(level);
1148 textureLevelDepth = texture2dArray->getDepth(level);
1149 texture = texture2dArray;
1150 }
1151 }
1152 break;
1153
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001154 case GL_TEXTURE_3D:
1155 {
1156 gl::Texture3D *texture3d = context->getTexture3D();
1157 if (texture3d)
1158 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001159 textureInternalFormat = texture3d->getInternalFormat(level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001160 textureCompressed = texture3d->isCompressed(level);
1161 textureLevelWidth = texture3d->getWidth(level);
1162 textureLevelHeight = texture3d->getHeight(level);
1163 textureLevelDepth = texture3d->getDepth(level);
1164 texture = texture3d;
1165 }
1166 }
1167 break;
1168
1169 default:
1170 return gl::error(GL_INVALID_ENUM, false);
1171 }
1172
1173 if (!texture)
1174 {
1175 return gl::error(GL_INVALID_OPERATION, false);
1176 }
1177
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001178 if (texture->isImmutable() && !isSubImage)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001179 {
1180 return gl::error(GL_INVALID_OPERATION, false);
1181 }
1182
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001183 if (textureCompressed)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001184 {
1185 if ((width % 4 != 0 && width != textureLevelWidth) ||
1186 (height % 4 != 0 && height != textureLevelHeight))
1187 {
1188 return gl::error(GL_INVALID_OPERATION, false);
1189 }
1190 }
1191
1192 if (xoffset + width > textureLevelWidth ||
1193 yoffset + height > textureLevelHeight ||
1194 zoffset >= textureLevelDepth)
1195 {
1196 return gl::error(GL_INVALID_VALUE, false);
1197 }
1198
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001199 if (!gl::IsValidCopyTexImageCombination(textureInternalFormat, colorbufferInternalFormat,
1200 context->getClientVersion()))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001201 {
1202 return gl::error(GL_INVALID_OPERATION, false);
1203 }
1204
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +00001205 return true;
1206}
1207
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00001208bool validateES2TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat,
1209 GLsizei width, GLsizei height)
1210{
1211 if (target != GL_TEXTURE_2D && target != GL_TEXTURE_CUBE_MAP)
1212 {
1213 return gl::error(GL_INVALID_ENUM, false);
1214 }
1215
1216 if (width < 1 || height < 1 || levels < 1)
1217 {
1218 return gl::error(GL_INVALID_VALUE, false);
1219 }
1220
1221 if (target == GL_TEXTURE_CUBE_MAP && width != height)
1222 {
1223 return gl::error(GL_INVALID_VALUE, false);
1224 }
1225
1226 if (levels != 1 && levels != gl::log2(std::max(width, height)) + 1)
1227 {
1228 return gl::error(GL_INVALID_OPERATION, false);
1229 }
1230
1231 GLenum format = gl::GetFormat(internalformat, context->getClientVersion());
1232 GLenum type = gl::GetType(internalformat, context->getClientVersion());
1233
1234 if (format == GL_NONE || type == GL_NONE)
1235 {
1236 return gl::error(GL_INVALID_ENUM, false);
1237 }
1238
1239 switch (target)
1240 {
1241 case GL_TEXTURE_2D:
1242 if (width > context->getMaximum2DTextureDimension() ||
1243 height > context->getMaximum2DTextureDimension())
1244 {
1245 return gl::error(GL_INVALID_VALUE, false);
1246 }
1247 break;
1248 case GL_TEXTURE_CUBE_MAP:
1249 if (width > context->getMaximumCubeTextureDimension() ||
1250 height > context->getMaximumCubeTextureDimension())
1251 {
1252 return gl::error(GL_INVALID_VALUE, false);
1253 }
1254 break;
1255 default:
1256 return gl::error(GL_INVALID_ENUM, false);
1257 }
1258
1259 if (levels != 1 && !context->supportsNonPower2Texture())
1260 {
1261 if (!gl::isPow2(width) || !gl::isPow2(height))
1262 {
1263 return gl::error(GL_INVALID_OPERATION, false);
1264 }
1265 }
1266
1267 switch (internalformat)
1268 {
1269 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1270 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1271 if (!context->supportsDXT1Textures())
1272 {
1273 return gl::error(GL_INVALID_ENUM, false);
1274 }
1275 break;
1276 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
1277 if (!context->supportsDXT3Textures())
1278 {
1279 return gl::error(GL_INVALID_ENUM, false);
1280 }
1281 break;
1282 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
1283 if (!context->supportsDXT5Textures())
1284 {
1285 return gl::error(GL_INVALID_ENUM, false);
1286 }
1287 break;
1288 case GL_RGBA32F_EXT:
1289 case GL_RGB32F_EXT:
1290 case GL_ALPHA32F_EXT:
1291 case GL_LUMINANCE32F_EXT:
1292 case GL_LUMINANCE_ALPHA32F_EXT:
1293 if (!context->supportsFloat32Textures())
1294 {
1295 return gl::error(GL_INVALID_ENUM, false);
1296 }
1297 break;
1298 case GL_RGBA16F_EXT:
1299 case GL_RGB16F_EXT:
1300 case GL_ALPHA16F_EXT:
1301 case GL_LUMINANCE16F_EXT:
1302 case GL_LUMINANCE_ALPHA16F_EXT:
1303 if (!context->supportsFloat16Textures())
1304 {
1305 return gl::error(GL_INVALID_ENUM, false);
1306 }
1307 break;
1308 case GL_DEPTH_COMPONENT16:
1309 case GL_DEPTH_COMPONENT32_OES:
1310 case GL_DEPTH24_STENCIL8_OES:
1311 if (!context->supportsDepthTextures())
1312 {
1313 return gl::error(GL_INVALID_ENUM, false);
1314 }
1315 if (target != GL_TEXTURE_2D)
1316 {
1317 return gl::error(GL_INVALID_OPERATION, false);
1318 }
1319 // ANGLE_depth_texture only supports 1-level textures
1320 if (levels != 1)
1321 {
1322 return gl::error(GL_INVALID_OPERATION, false);
1323 }
1324 break;
1325 default:
1326 break;
1327 }
1328
1329 gl::Texture *texture = NULL;
1330 switch(target)
1331 {
1332 case GL_TEXTURE_2D:
1333 texture = context->getTexture2D();
1334 break;
1335 case GL_TEXTURE_CUBE_MAP:
1336 texture = context->getTextureCubeMap();
1337 break;
1338 default:
1339 UNREACHABLE();
1340 }
1341
1342 if (!texture || texture->id() == 0)
1343 {
1344 return gl::error(GL_INVALID_OPERATION, false);
1345 }
1346
1347 if (texture->isImmutable())
1348 {
1349 return gl::error(GL_INVALID_OPERATION, false);
1350 }
1351
1352 return true;
1353}
1354
1355bool validateES3TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat,
1356 GLsizei width, GLsizei height, GLsizei depth)
1357{
1358 if (width < 1 || height < 1 || depth < 1 || levels < 1)
1359 {
1360 return gl::error(GL_INVALID_VALUE, false);
1361 }
1362
1363 if (levels > gl::log2(std::max(std::max(width, height), depth)) + 1)
1364 {
1365 return gl::error(GL_INVALID_OPERATION, false);
1366 }
1367
1368 gl::Texture *texture = NULL;
1369 switch (target)
1370 {
1371 case GL_TEXTURE_2D:
1372 {
1373 texture = context->getTexture2D();
1374
1375 if (width > (context->getMaximum2DTextureDimension()) ||
1376 height > (context->getMaximum2DTextureDimension()))
1377 {
1378 return gl::error(GL_INVALID_VALUE, false);
1379 }
1380 }
1381 break;
1382
1383 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1384 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1385 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1386 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1387 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1388 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1389 {
1390 texture = context->getTextureCubeMap();
1391
1392 if (width != height)
1393 {
1394 return gl::error(GL_INVALID_VALUE, false);
1395 }
1396
1397 if (width > (context->getMaximumCubeTextureDimension()))
1398 {
1399 return gl::error(GL_INVALID_VALUE, false);
1400 }
1401 }
1402 break;
1403
1404 case GL_TEXTURE_3D:
1405 {
1406 texture = context->getTexture3D();
1407
1408 if (width > (context->getMaximum3DTextureDimension()) ||
1409 height > (context->getMaximum3DTextureDimension()) ||
1410 depth > (context->getMaximum3DTextureDimension()))
1411 {
1412 return gl::error(GL_INVALID_VALUE, false);
1413 }
1414 }
1415 break;
1416
1417 case GL_TEXTURE_2D_ARRAY:
1418 {
1419 texture = context->getTexture2DArray();
1420
1421 if (width > (context->getMaximum2DTextureDimension()) ||
1422 height > (context->getMaximum2DTextureDimension()) ||
1423 depth > (context->getMaximum2DArrayTextureLayers()))
1424 {
1425 return gl::error(GL_INVALID_VALUE, false);
1426 }
1427 }
1428 break;
1429
1430 default:
1431 return gl::error(GL_INVALID_ENUM, false);
1432 }
1433
1434 if (!texture || texture->id() == 0)
1435 {
1436 return gl::error(GL_INVALID_OPERATION, false);
1437 }
1438
1439 if (texture->isImmutable())
1440 {
1441 return gl::error(GL_INVALID_OPERATION, false);
1442 }
1443
1444 if (!gl::IsValidInternalFormat(internalformat, context))
1445 {
1446 return gl::error(GL_INVALID_ENUM, false);
1447 }
1448
1449 if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion()))
1450 {
1451 return gl::error(GL_INVALID_ENUM, false);
1452 }
1453
1454 return true;
1455}
1456
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00001457// check for combinations of format and type that are valid for ReadPixels
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00001458bool validES2ReadFormatType(GLenum format, GLenum type)
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00001459{
1460 switch (format)
1461 {
1462 case GL_RGBA:
1463 switch (type)
1464 {
1465 case GL_UNSIGNED_BYTE:
1466 break;
1467 default:
1468 return false;
1469 }
1470 break;
1471 case GL_BGRA_EXT:
1472 switch (type)
1473 {
1474 case GL_UNSIGNED_BYTE:
1475 case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
1476 case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
1477 break;
1478 default:
1479 return false;
1480 }
1481 break;
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00001482 default:
1483 return false;
1484 }
1485 return true;
1486}
1487
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00001488bool validES3ReadFormatType(GLenum internalFormat, GLenum format, GLenum type)
1489{
1490 switch (format)
1491 {
1492 case GL_RGBA:
1493 switch (type)
1494 {
1495 case GL_UNSIGNED_BYTE:
1496 break;
1497 case GL_UNSIGNED_INT_2_10_10_10_REV:
1498 if (internalFormat != GL_RGB10_A2)
1499 {
1500 return false;
1501 }
1502 break;
1503 default:
1504 return false;
1505 }
1506 break;
1507 case GL_RGBA_INTEGER:
1508 switch (type)
1509 {
1510 case GL_INT:
1511 case GL_UNSIGNED_INT:
1512 break;
1513 default:
1514 return false;
1515 }
1516 break;
1517 case GL_BGRA_EXT:
1518 switch (type)
1519 {
1520 case GL_UNSIGNED_BYTE:
1521 case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
1522 case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
1523 break;
1524 default:
1525 return false;
1526 }
1527 break;
1528 default:
1529 return false;
1530 }
1531 return true;
1532}
1533
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00001534bool validateInvalidateFramebufferParameters(gl::Context *context, GLenum target, GLsizei numAttachments,
1535 const GLenum* attachments)
1536{
1537 bool defaultFramebuffer = false;
1538
1539 switch (target)
1540 {
1541 case GL_DRAW_FRAMEBUFFER:
1542 case GL_FRAMEBUFFER:
1543 defaultFramebuffer = context->getDrawFramebufferHandle() == 0;
1544 break;
1545 case GL_READ_FRAMEBUFFER:
1546 defaultFramebuffer = context->getReadFramebufferHandle() == 0;
1547 break;
1548 default:
1549 return gl::error(GL_INVALID_ENUM, false);
1550 }
1551
1552 for (int i = 0; i < numAttachments; ++i)
1553 {
1554 if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15)
1555 {
1556 if (defaultFramebuffer)
1557 {
1558 return gl::error(GL_INVALID_ENUM, false);
1559 }
1560
1561 if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getMaximumRenderTargets())
1562 {
1563 return gl::error(GL_INVALID_OPERATION, false);
1564 }
1565 }
1566 else
1567 {
1568 switch (attachments[i])
1569 {
1570 case GL_DEPTH_ATTACHMENT:
1571 case GL_STENCIL_ATTACHMENT:
1572 case GL_DEPTH_STENCIL_ATTACHMENT:
1573 if (defaultFramebuffer)
1574 {
1575 return gl::error(GL_INVALID_ENUM, false);
1576 }
1577 break;
1578 case GL_COLOR:
1579 case GL_DEPTH:
1580 case GL_STENCIL:
1581 if (!defaultFramebuffer)
1582 {
1583 return gl::error(GL_INVALID_ENUM, false);
1584 }
1585 break;
1586 default:
1587 return gl::error(GL_INVALID_ENUM, false);
1588 }
1589 }
1590 }
1591
1592 return true;
1593}
1594
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001595extern "C"
1596{
1597
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00001598// OpenGL ES 2.0 functions
1599
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001600void __stdcall glActiveTexture(GLenum texture)
1601{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001602 EVENT("(GLenum texture = 0x%X)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001603
1604 try
1605 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001606 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001607
1608 if (context)
1609 {
daniel@transgaming.com3f74c7a2011-05-11 15:36:51 +00001610 if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1)
1611 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001612 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3f74c7a2011-05-11 15:36:51 +00001613 }
1614
daniel@transgaming.com428d1582010-05-04 03:35:25 +00001615 context->setActiveSampler(texture - GL_TEXTURE0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001616 }
1617 }
1618 catch(std::bad_alloc&)
1619 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001620 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001621 }
1622}
1623
1624void __stdcall glAttachShader(GLuint program, GLuint shader)
1625{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001626 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001627
1628 try
1629 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001630 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001631
1632 if (context)
1633 {
1634 gl::Program *programObject = context->getProgram(program);
1635 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00001636
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001637 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001638 {
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001639 if (context->getShader(program))
1640 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001641 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001642 }
1643 else
1644 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001645 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001646 }
1647 }
1648
1649 if (!shaderObject)
1650 {
1651 if (context->getProgram(shader))
1652 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001653 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001654 }
1655 else
1656 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001657 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001658 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001659 }
1660
1661 if (!programObject->attachShader(shaderObject))
1662 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001663 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001664 }
1665 }
1666 }
1667 catch(std::bad_alloc&)
1668 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001669 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001670 }
1671}
1672
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001673void __stdcall glBeginQueryEXT(GLenum target, GLuint id)
1674{
1675 EVENT("(GLenum target = 0x%X, GLuint %d)", target, id);
1676
1677 try
1678 {
1679 switch (target)
1680 {
1681 case GL_ANY_SAMPLES_PASSED_EXT:
1682 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
1683 break;
1684 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001685 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001686 }
1687
1688 if (id == 0)
1689 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001690 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001691 }
1692
1693 gl::Context *context = gl::getNonLostContext();
1694
1695 if (context)
1696 {
1697 context->beginQuery(target, id);
1698 }
1699 }
1700 catch(std::bad_alloc&)
1701 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001702 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001703 }
1704}
1705
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001706void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001707{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001708 EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001709
1710 try
1711 {
1712 if (index >= gl::MAX_VERTEX_ATTRIBS)
1713 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001714 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001715 }
1716
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001717 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001718
1719 if (context)
1720 {
1721 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00001722
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001723 if (!programObject)
1724 {
daniel@transgaming.com98079832010-04-13 03:26:29 +00001725 if (context->getShader(program))
1726 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001727 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com98079832010-04-13 03:26:29 +00001728 }
1729 else
1730 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001731 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com98079832010-04-13 03:26:29 +00001732 }
1733 }
1734
1735 if (strncmp(name, "gl_", 3) == 0)
1736 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001737 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001738 }
1739
1740 programObject->bindAttributeLocation(index, name);
1741 }
1742 }
1743 catch(std::bad_alloc&)
1744 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001745 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001746 }
1747}
1748
1749void __stdcall glBindBuffer(GLenum target, GLuint buffer)
1750{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001751 EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001752
1753 try
1754 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001755 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001756
1757 if (context)
1758 {
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00001759 // Check ES3 specific targets
1760 switch (target)
1761 {
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00001762 case GL_COPY_READ_BUFFER:
1763 case GL_COPY_WRITE_BUFFER:
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00001764 case GL_PIXEL_PACK_BUFFER:
1765 case GL_PIXEL_UNPACK_BUFFER:
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00001766 case GL_UNIFORM_BUFFER:
1767 case GL_TRANSFORM_FEEDBACK_BUFFER:
1768 if (context->getClientVersion() < 3)
1769 {
1770 return gl::error(GL_INVALID_ENUM);
1771 }
1772 }
1773
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001774 switch (target)
1775 {
1776 case GL_ARRAY_BUFFER:
1777 context->bindArrayBuffer(buffer);
1778 return;
1779 case GL_ELEMENT_ARRAY_BUFFER:
1780 context->bindElementArrayBuffer(buffer);
1781 return;
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00001782 case GL_COPY_READ_BUFFER:
1783 context->bindCopyReadBuffer(buffer);
1784 return;
1785 case GL_COPY_WRITE_BUFFER:
1786 context->bindCopyWriteBuffer(buffer);
1787 return;
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00001788 case GL_PIXEL_PACK_BUFFER:
1789 context->bindPixelPackBuffer(buffer);
1790 return;
1791 case GL_PIXEL_UNPACK_BUFFER:
1792 context->bindPixelUnpackBuffer(buffer);
1793 return;
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00001794 case GL_UNIFORM_BUFFER:
1795 context->bindGenericUniformBuffer(buffer);
1796 return;
1797 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.org7a1ebad2013-05-30 00:05:20 +00001798 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00001799 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001800 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001801 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001802 }
1803 }
1804 }
1805 catch(std::bad_alloc&)
1806 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001807 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001808 }
1809}
1810
1811void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer)
1812{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001813 EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001814
1815 try
1816 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00001817 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001818 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001819 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001820 }
1821
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001822 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001823
1824 if (context)
1825 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00001826 if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
1827 {
1828 context->bindReadFramebuffer(framebuffer);
1829 }
1830
1831 if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
1832 {
1833 context->bindDrawFramebuffer(framebuffer);
1834 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001835 }
1836 }
1837 catch(std::bad_alloc&)
1838 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001839 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001840 }
1841}
1842
1843void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer)
1844{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001845 EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001846
1847 try
1848 {
1849 if (target != GL_RENDERBUFFER)
1850 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001851 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001852 }
1853
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001854 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001855
1856 if (context)
1857 {
1858 context->bindRenderbuffer(renderbuffer);
1859 }
1860 }
1861 catch(std::bad_alloc&)
1862 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001863 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001864 }
1865}
1866
1867void __stdcall glBindTexture(GLenum target, GLuint texture)
1868{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001869 EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001870
1871 try
1872 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001873 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001874
1875 if (context)
1876 {
1877 gl::Texture *textureObject = context->getTexture(texture);
1878
1879 if (textureObject && textureObject->getTarget() != target && texture != 0)
1880 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001881 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001882 }
1883
1884 switch (target)
1885 {
1886 case GL_TEXTURE_2D:
1887 context->bindTexture2D(texture);
1888 return;
1889 case GL_TEXTURE_CUBE_MAP:
1890 context->bindTextureCubeMap(texture);
1891 return;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00001892 case GL_TEXTURE_3D:
1893 if (context->getClientVersion() < 3)
1894 {
1895 return gl::error(GL_INVALID_ENUM);
1896 }
1897 context->bindTexture3D(texture);
1898 return;
shannon.woods%transgaming.com@gtempaccount.com90dbc442013-04-13 03:46:14 +00001899 case GL_TEXTURE_2D_ARRAY:
1900 if (context->getClientVersion() < 3)
1901 {
1902 return gl::error(GL_INVALID_ENUM);
1903 }
1904 context->bindTexture2DArray(texture);
1905 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001906 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001907 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001908 }
1909 }
1910 }
1911 catch(std::bad_alloc&)
1912 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001913 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001914 }
1915}
1916
1917void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
1918{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001919 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001920 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001921
1922 try
1923 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001924 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001925
1926 if (context)
1927 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00001928 context->setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001929 }
1930 }
1931 catch(std::bad_alloc&)
1932 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001933 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001934 }
1935}
1936
1937void __stdcall glBlendEquation(GLenum mode)
1938{
1939 glBlendEquationSeparate(mode, mode);
1940}
1941
1942void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
1943{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001944 EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001945
1946 try
1947 {
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +00001948 gl::Context *context = gl::getNonLostContext();
1949
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001950 switch (modeRGB)
1951 {
1952 case GL_FUNC_ADD:
1953 case GL_FUNC_SUBTRACT:
1954 case GL_FUNC_REVERSE_SUBTRACT:
1955 break;
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +00001956
1957 case GL_MIN:
1958 case GL_MAX:
1959 if (context && context->getClientVersion() < 3)
1960 {
1961 return gl::error(GL_INVALID_ENUM);
1962 }
1963 break;
1964
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001965 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001966 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001967 }
1968
1969 switch (modeAlpha)
1970 {
1971 case GL_FUNC_ADD:
1972 case GL_FUNC_SUBTRACT:
1973 case GL_FUNC_REVERSE_SUBTRACT:
1974 break;
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +00001975
1976 case GL_MIN:
1977 case GL_MAX:
1978 if (context && context->getClientVersion() < 3)
1979 {
1980 return gl::error(GL_INVALID_ENUM);
1981 }
1982 break;
1983
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001984 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001985 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001986 }
1987
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001988 if (context)
1989 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00001990 context->setBlendEquation(modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001991 }
1992 }
1993 catch(std::bad_alloc&)
1994 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001995 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001996 }
1997}
1998
1999void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor)
2000{
2001 glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
2002}
2003
2004void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
2005{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002006 EVENT("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002007 srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002008
2009 try
2010 {
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +00002011 gl::Context *context = gl::getNonLostContext();
2012
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002013 switch (srcRGB)
2014 {
2015 case GL_ZERO:
2016 case GL_ONE:
2017 case GL_SRC_COLOR:
2018 case GL_ONE_MINUS_SRC_COLOR:
2019 case GL_DST_COLOR:
2020 case GL_ONE_MINUS_DST_COLOR:
2021 case GL_SRC_ALPHA:
2022 case GL_ONE_MINUS_SRC_ALPHA:
2023 case GL_DST_ALPHA:
2024 case GL_ONE_MINUS_DST_ALPHA:
2025 case GL_CONSTANT_COLOR:
2026 case GL_ONE_MINUS_CONSTANT_COLOR:
2027 case GL_CONSTANT_ALPHA:
2028 case GL_ONE_MINUS_CONSTANT_ALPHA:
2029 case GL_SRC_ALPHA_SATURATE:
2030 break;
2031 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002032 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002033 }
2034
2035 switch (dstRGB)
2036 {
2037 case GL_ZERO:
2038 case GL_ONE:
2039 case GL_SRC_COLOR:
2040 case GL_ONE_MINUS_SRC_COLOR:
2041 case GL_DST_COLOR:
2042 case GL_ONE_MINUS_DST_COLOR:
2043 case GL_SRC_ALPHA:
2044 case GL_ONE_MINUS_SRC_ALPHA:
2045 case GL_DST_ALPHA:
2046 case GL_ONE_MINUS_DST_ALPHA:
2047 case GL_CONSTANT_COLOR:
2048 case GL_ONE_MINUS_CONSTANT_COLOR:
2049 case GL_CONSTANT_ALPHA:
2050 case GL_ONE_MINUS_CONSTANT_ALPHA:
2051 break;
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +00002052
2053 case GL_SRC_ALPHA_SATURATE:
2054 if (!context || context->getClientVersion() < 3)
2055 {
2056 return gl::error(GL_INVALID_ENUM);
2057 }
2058 break;
2059
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002060 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002061 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002062 }
2063
2064 switch (srcAlpha)
2065 {
2066 case GL_ZERO:
2067 case GL_ONE:
2068 case GL_SRC_COLOR:
2069 case GL_ONE_MINUS_SRC_COLOR:
2070 case GL_DST_COLOR:
2071 case GL_ONE_MINUS_DST_COLOR:
2072 case GL_SRC_ALPHA:
2073 case GL_ONE_MINUS_SRC_ALPHA:
2074 case GL_DST_ALPHA:
2075 case GL_ONE_MINUS_DST_ALPHA:
2076 case GL_CONSTANT_COLOR:
2077 case GL_ONE_MINUS_CONSTANT_COLOR:
2078 case GL_CONSTANT_ALPHA:
2079 case GL_ONE_MINUS_CONSTANT_ALPHA:
2080 case GL_SRC_ALPHA_SATURATE:
2081 break;
2082 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002083 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002084 }
2085
2086 switch (dstAlpha)
2087 {
2088 case GL_ZERO:
2089 case GL_ONE:
2090 case GL_SRC_COLOR:
2091 case GL_ONE_MINUS_SRC_COLOR:
2092 case GL_DST_COLOR:
2093 case GL_ONE_MINUS_DST_COLOR:
2094 case GL_SRC_ALPHA:
2095 case GL_ONE_MINUS_SRC_ALPHA:
2096 case GL_DST_ALPHA:
2097 case GL_ONE_MINUS_DST_ALPHA:
2098 case GL_CONSTANT_COLOR:
2099 case GL_ONE_MINUS_CONSTANT_COLOR:
2100 case GL_CONSTANT_ALPHA:
2101 case GL_ONE_MINUS_CONSTANT_ALPHA:
2102 break;
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +00002103
2104 case GL_SRC_ALPHA_SATURATE:
2105 if (!context || context->getClientVersion() < 3)
2106 {
2107 return gl::error(GL_INVALID_ENUM);
2108 }
2109 break;
2110
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002111 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002112 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002113 }
2114
daniel@transgaming.comfe453652010-03-16 06:23:28 +00002115 bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
2116 dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
2117
2118 bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
2119 dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
2120
2121 if (constantColorUsed && constantAlphaUsed)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002122 {
daniel@transgaming.comfe453652010-03-16 06:23:28 +00002123 ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR invalid under WebGL");
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002124 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002125 }
2126
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002127 if (context)
2128 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002129 context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002130 }
2131 }
2132 catch(std::bad_alloc&)
2133 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002134 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002135 }
2136}
2137
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002138void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002139{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002140 EVENT("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p, GLenum usage = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002141 target, size, data, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002142
2143 try
2144 {
2145 if (size < 0)
2146 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002147 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002148 }
2149
shannon.woods%transgaming.com@gtempaccount.comf2db40b2013-04-13 03:37:09 +00002150 gl::Context *context = gl::getNonLostContext();
2151
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002152 switch (usage)
2153 {
2154 case GL_STREAM_DRAW:
2155 case GL_STATIC_DRAW:
2156 case GL_DYNAMIC_DRAW:
2157 break;
shannon.woods%transgaming.com@gtempaccount.comf2db40b2013-04-13 03:37:09 +00002158
2159 case GL_STREAM_READ:
2160 case GL_STREAM_COPY:
2161 case GL_STATIC_READ:
2162 case GL_STATIC_COPY:
2163 case GL_DYNAMIC_READ:
2164 case GL_DYNAMIC_COPY:
2165 if (context && context->getClientVersion() < 3)
2166 {
2167 return gl::error(GL_INVALID_ENUM);
2168 }
2169 break;
2170
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002171 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002172 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002173 }
2174
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002175 if (context)
2176 {
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002177 // Check ES3 specific targets
2178 switch (target)
2179 {
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002180 case GL_COPY_READ_BUFFER:
2181 case GL_COPY_WRITE_BUFFER:
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002182 case GL_PIXEL_PACK_BUFFER:
2183 case GL_PIXEL_UNPACK_BUFFER:
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002184 case GL_UNIFORM_BUFFER:
2185 case GL_TRANSFORM_FEEDBACK_BUFFER:
2186 if (context->getClientVersion() < 3)
2187 {
2188 return gl::error(GL_INVALID_ENUM);
2189 }
2190 }
2191
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002192 gl::Buffer *buffer;
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00002193
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002194 switch (target)
2195 {
2196 case GL_ARRAY_BUFFER:
2197 buffer = context->getArrayBuffer();
2198 break;
2199 case GL_ELEMENT_ARRAY_BUFFER:
2200 buffer = context->getElementArrayBuffer();
2201 break;
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002202 case GL_COPY_READ_BUFFER:
2203 buffer = context->getCopyReadBuffer();
2204 break;
2205 case GL_COPY_WRITE_BUFFER:
2206 buffer = context->getCopyWriteBuffer();
2207 break;
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002208 case GL_PIXEL_PACK_BUFFER:
2209 buffer = context->getPixelPackBuffer();
2210 break;
2211 case GL_PIXEL_UNPACK_BUFFER:
2212 buffer = context->getPixelUnpackBuffer();
2213 break;
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002214 case GL_TRANSFORM_FEEDBACK_BUFFER:
2215 buffer = context->getGenericTransformFeedbackBuffer();
2216 break;
2217 case GL_UNIFORM_BUFFER:
2218 buffer = context->getGenericUniformBuffer();
2219 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002220 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002221 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002222 }
2223
2224 if (!buffer)
2225 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002226 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002227 }
2228
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002229 buffer->bufferData(data, size, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002230 }
2231 }
2232 catch(std::bad_alloc&)
2233 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002234 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002235 }
2236}
2237
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002238void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002239{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002240 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002241 target, offset, size, data);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002242
2243 try
2244 {
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +00002245 if (size < 0 || offset < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002246 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002247 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002248 }
2249
daniel@transgaming.comd4620a32010-03-21 04:31:28 +00002250 if (data == NULL)
2251 {
2252 return;
2253 }
2254
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002255 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002256
2257 if (context)
2258 {
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002259 // Check ES3 specific targets
2260 switch (target)
2261 {
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002262 case GL_COPY_READ_BUFFER:
2263 case GL_COPY_WRITE_BUFFER:
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002264 case GL_PIXEL_PACK_BUFFER:
2265 case GL_PIXEL_UNPACK_BUFFER:
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002266 case GL_UNIFORM_BUFFER:
2267 case GL_TRANSFORM_FEEDBACK_BUFFER:
2268 if (context->getClientVersion() < 3)
2269 {
2270 return gl::error(GL_INVALID_ENUM);
2271 }
2272 }
2273
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002274 gl::Buffer *buffer;
2275
2276 switch (target)
2277 {
2278 case GL_ARRAY_BUFFER:
2279 buffer = context->getArrayBuffer();
2280 break;
2281 case GL_ELEMENT_ARRAY_BUFFER:
2282 buffer = context->getElementArrayBuffer();
2283 break;
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002284 case GL_COPY_READ_BUFFER:
2285 buffer = context->getCopyReadBuffer();
2286 break;
2287 case GL_COPY_WRITE_BUFFER:
2288 buffer = context->getCopyWriteBuffer();
2289 break;
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002290 case GL_PIXEL_PACK_BUFFER:
2291 buffer = context->getPixelPackBuffer();
2292 break;
2293 case GL_PIXEL_UNPACK_BUFFER:
2294 buffer = context->getPixelUnpackBuffer();
2295 break;
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002296 case GL_TRANSFORM_FEEDBACK_BUFFER:
2297 buffer = context->getGenericTransformFeedbackBuffer();
2298 break;
2299 case GL_UNIFORM_BUFFER:
2300 buffer = context->getGenericUniformBuffer();
2301 break;
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002302 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002303 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002304 }
2305
2306 if (!buffer)
2307 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002308 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002309 }
2310
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +00002311 if ((size_t)size + offset > buffer->size())
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002312 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002313 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002314 }
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +00002315
2316 buffer->bufferSubData(data, size, offset);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002317 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002318 }
2319 catch(std::bad_alloc&)
2320 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002321 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002322 }
2323}
2324
2325GLenum __stdcall glCheckFramebufferStatus(GLenum target)
2326{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002327 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002328
2329 try
2330 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002331 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002332 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002333 return gl::error(GL_INVALID_ENUM, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002334 }
2335
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002336 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002337
2338 if (context)
2339 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002340 gl::Framebuffer *framebuffer = NULL;
2341 if (target == GL_READ_FRAMEBUFFER_ANGLE)
2342 {
2343 framebuffer = context->getReadFramebuffer();
2344 }
2345 else
2346 {
2347 framebuffer = context->getDrawFramebuffer();
2348 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002349
2350 return framebuffer->completeness();
2351 }
2352 }
2353 catch(std::bad_alloc&)
2354 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002355 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002356 }
2357
2358 return 0;
2359}
2360
2361void __stdcall glClear(GLbitfield mask)
2362{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00002363 EVENT("(GLbitfield mask = 0x%X)", mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002364
2365 try
2366 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002367 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002368
2369 if (context)
2370 {
2371 context->clear(mask);
2372 }
2373 }
2374 catch(std::bad_alloc&)
2375 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002376 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002377 }
2378}
2379
2380void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
2381{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002382 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002383 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002384
2385 try
2386 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002387 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002388
2389 if (context)
2390 {
2391 context->setClearColor(red, green, blue, alpha);
2392 }
2393 }
2394 catch(std::bad_alloc&)
2395 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002396 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002397 }
2398}
2399
2400void __stdcall glClearDepthf(GLclampf depth)
2401{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002402 EVENT("(GLclampf depth = %f)", depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002403
2404 try
2405 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002406 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002407
2408 if (context)
2409 {
2410 context->setClearDepth(depth);
2411 }
2412 }
2413 catch(std::bad_alloc&)
2414 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002415 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002416 }
2417}
2418
2419void __stdcall glClearStencil(GLint s)
2420{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002421 EVENT("(GLint s = %d)", s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002422
2423 try
2424 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002425 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002426
2427 if (context)
2428 {
2429 context->setClearStencil(s);
2430 }
2431 }
2432 catch(std::bad_alloc&)
2433 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002434 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002435 }
2436}
2437
2438void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
2439{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00002440 EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002441 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002442
2443 try
2444 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002445 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002446
2447 if (context)
2448 {
daniel@transgaming.coma36f98e2010-05-18 18:51:09 +00002449 context->setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002450 }
2451 }
2452 catch(std::bad_alloc&)
2453 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002454 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002455 }
2456}
2457
2458void __stdcall glCompileShader(GLuint shader)
2459{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002460 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002461
2462 try
2463 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002464 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002465
2466 if (context)
2467 {
2468 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00002469
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002470 if (!shaderObject)
2471 {
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +00002472 if (context->getProgram(shader))
2473 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002474 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +00002475 }
2476 else
2477 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002478 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +00002479 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002480 }
2481
2482 shaderObject->compile();
2483 }
2484 }
2485 catch(std::bad_alloc&)
2486 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002487 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002488 }
2489}
2490
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002491void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
2492 GLint border, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002493{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002494 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002495 "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002496 target, level, internalformat, width, height, border, imageSize, data);
2497
2498 try
2499 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002500 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com01868132010-08-24 19:21:17 +00002501
2502 if (context)
2503 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002504 if (context->getClientVersion() < 3 &&
2505 !validateES2TexImageParameters(context, target, level, internalformat, true, false,
2506 0, 0, width, height, 0, GL_NONE, GL_NONE, data))
2507 {
2508 return;
2509 }
2510
2511 if (context->getClientVersion() >= 3 &&
2512 !validateES3TexImageParameters(context, target, level, internalformat, true, false,
2513 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE))
2514 {
2515 return;
2516 }
2517
2518 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002519 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002520 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002521 }
2522
2523 switch (target)
2524 {
2525 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002526 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002527 gl::Texture2D *texture = context->getTexture2D();
2528 texture->setCompressedImage(level, internalformat, width, height, imageSize, data);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002529 }
2530 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002531
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002532 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2533 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2534 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2535 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2536 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2537 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002538 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002539 gl::TextureCubeMap *texture = context->getTextureCubeMap();
2540 texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002541 }
2542 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002543
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002544 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002545 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002546 }
daniel@transgaming.com01868132010-08-24 19:21:17 +00002547 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002548 }
2549 catch(std::bad_alloc&)
2550 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002551 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002552 }
2553}
2554
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002555void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
2556 GLenum format, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002557{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002558 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002559 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002560 "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002561 target, level, xoffset, yoffset, width, height, format, imageSize, data);
2562
2563 try
2564 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002565 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com01868132010-08-24 19:21:17 +00002566
2567 if (context)
2568 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002569 if (context->getClientVersion() < 3 &&
2570 !validateES2TexImageParameters(context, target, level, GL_NONE, true, true,
2571 xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
2572 {
2573 return;
2574 }
2575
2576 if (context->getClientVersion() >= 3 &&
2577 !validateES3TexImageParameters(context, target, level, GL_NONE, true, true,
2578 xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE))
2579 {
2580 return;
2581 }
2582
2583 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002584 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002585 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002586 }
2587
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002588 switch (target)
daniel@transgaming.com01868132010-08-24 19:21:17 +00002589 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002590 case GL_TEXTURE_2D:
daniel@transgaming.com01868132010-08-24 19:21:17 +00002591 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002592 gl::Texture2D *texture = context->getTexture2D();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00002593 texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
daniel@transgaming.com01868132010-08-24 19:21:17 +00002594 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002595 break;
2596
2597 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2598 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2599 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2600 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2601 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2602 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com01868132010-08-24 19:21:17 +00002603 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002604 gl::TextureCubeMap *texture = context->getTextureCubeMap();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00002605 texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
daniel@transgaming.com01868132010-08-24 19:21:17 +00002606 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002607 break;
2608
2609 default:
2610 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com01868132010-08-24 19:21:17 +00002611 }
2612 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002613 }
2614 catch(std::bad_alloc&)
2615 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002616 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002617 }
2618}
2619
2620void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
2621{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002622 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002623 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002624 target, level, internalformat, x, y, width, height, border);
2625
2626 try
2627 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002628 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002629
2630 if (context)
2631 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002632 if (context->getClientVersion() < 3 &&
2633 !validateES2CopyTexImageParameters(context, target, level, internalformat, false,
2634 0, 0, x, y, width, height, border))
daniel@transgaming.com32b11442011-11-19 02:42:48 +00002635 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002636 return;
daniel@transgaming.com32b11442011-11-19 02:42:48 +00002637 }
2638
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002639 if (context->getClientVersion() >= 3 &&
2640 !validateES3CopyTexImageParameters(context, target, level, internalformat, false,
2641 0, 0, 0, x, y, width, height, border))
2642 {
2643 return;
2644 }
2645
2646 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
2647
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002648 switch (target)
2649 {
2650 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002651 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002652 gl::Texture2D *texture = context->getTexture2D();
2653 texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002654 }
2655 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002656
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002657 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2658 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2659 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2660 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2661 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2662 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002663 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002664 gl::TextureCubeMap *texture = context->getTextureCubeMap();
2665 texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002666 }
2667 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002668
2669 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002670 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002671 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002672 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002673 }
2674 catch(std::bad_alloc&)
2675 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002676 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002677 }
2678}
2679
2680void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
2681{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002682 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002683 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002684 target, level, xoffset, yoffset, x, y, width, height);
2685
2686 try
2687 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002688 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002689
2690 if (context)
2691 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002692 if (context->getClientVersion() < 3 &&
2693 !validateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
2694 xoffset, yoffset, x, y, width, height, 0))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002695 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002696 return;
2697 }
2698
2699 if (context->getClientVersion() >= 3 &&
2700 !validateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
2701 xoffset, yoffset, 0, x, y, width, height, 0))
2702 {
2703 return;
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002704 }
2705
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002706 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00002707
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002708 switch (target)
daniel@transgaming.combbc57792010-07-28 19:21:05 +00002709 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002710 case GL_TEXTURE_2D:
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +00002711 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002712 gl::Texture2D *texture = context->getTexture2D();
2713 texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00002714 }
2715 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002716
2717 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2718 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2719 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2720 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2721 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2722 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com6452adf2012-10-17 18:22:35 +00002723 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002724 gl::TextureCubeMap *texture = context->getTextureCubeMap();
2725 texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +00002726 }
2727 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002728
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00002729 default:
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002730 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00002731 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002732 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002733 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002734
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002735 catch(std::bad_alloc&)
2736 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002737 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002738 }
2739}
2740
2741GLuint __stdcall glCreateProgram(void)
2742{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002743 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002744
2745 try
2746 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002747 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002748
2749 if (context)
2750 {
2751 return context->createProgram();
2752 }
2753 }
2754 catch(std::bad_alloc&)
2755 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002756 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002757 }
2758
2759 return 0;
2760}
2761
2762GLuint __stdcall glCreateShader(GLenum type)
2763{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002764 EVENT("(GLenum type = 0x%X)", type);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002765
2766 try
2767 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002768 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002769
2770 if (context)
2771 {
2772 switch (type)
2773 {
2774 case GL_FRAGMENT_SHADER:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00002775 case GL_VERTEX_SHADER:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002776 return context->createShader(type);
2777 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002778 return gl::error(GL_INVALID_ENUM, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002779 }
2780 }
2781 }
2782 catch(std::bad_alloc&)
2783 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002784 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002785 }
2786
2787 return 0;
2788}
2789
2790void __stdcall glCullFace(GLenum mode)
2791{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002792 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002793
2794 try
2795 {
2796 switch (mode)
2797 {
2798 case GL_FRONT:
2799 case GL_BACK:
2800 case GL_FRONT_AND_BACK:
2801 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002802 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002803
2804 if (context)
2805 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002806 context->setCullMode(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002807 }
2808 }
2809 break;
2810 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002811 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002812 }
2813 }
2814 catch(std::bad_alloc&)
2815 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002816 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002817 }
2818}
2819
2820void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers)
2821{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002822 EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002823
2824 try
2825 {
2826 if (n < 0)
2827 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002828 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002829 }
2830
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002831 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002832
2833 if (context)
2834 {
2835 for (int i = 0; i < n; i++)
2836 {
2837 context->deleteBuffer(buffers[i]);
2838 }
2839 }
2840 }
2841 catch(std::bad_alloc&)
2842 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002843 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002844 }
2845}
2846
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002847void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences)
2848{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002849 EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002850
2851 try
2852 {
2853 if (n < 0)
2854 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002855 return gl::error(GL_INVALID_VALUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002856 }
2857
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002858 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002859
2860 if (context)
2861 {
2862 for (int i = 0; i < n; i++)
2863 {
2864 context->deleteFence(fences[i]);
2865 }
2866 }
2867 }
2868 catch(std::bad_alloc&)
2869 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002870 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002871 }
2872}
2873
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002874void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
2875{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002876 EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002877
2878 try
2879 {
2880 if (n < 0)
2881 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002882 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002883 }
2884
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002885 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002886
2887 if (context)
2888 {
2889 for (int i = 0; i < n; i++)
2890 {
2891 if (framebuffers[i] != 0)
2892 {
2893 context->deleteFramebuffer(framebuffers[i]);
2894 }
2895 }
2896 }
2897 }
2898 catch(std::bad_alloc&)
2899 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002900 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002901 }
2902}
2903
2904void __stdcall glDeleteProgram(GLuint program)
2905{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002906 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002907
2908 try
2909 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00002910 if (program == 0)
2911 {
2912 return;
2913 }
2914
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002915 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002916
2917 if (context)
2918 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00002919 if (!context->getProgram(program))
2920 {
2921 if(context->getShader(program))
2922 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002923 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00002924 }
2925 else
2926 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002927 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00002928 }
2929 }
2930
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002931 context->deleteProgram(program);
2932 }
2933 }
2934 catch(std::bad_alloc&)
2935 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002936 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002937 }
2938}
2939
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002940void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
2941{
2942 EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
2943
2944 try
2945 {
2946 if (n < 0)
2947 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002948 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002949 }
2950
2951 gl::Context *context = gl::getNonLostContext();
2952
2953 if (context)
2954 {
2955 for (int i = 0; i < n; i++)
2956 {
2957 context->deleteQuery(ids[i]);
2958 }
2959 }
2960 }
2961 catch(std::bad_alloc&)
2962 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002963 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002964 }
2965}
2966
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002967void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
2968{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002969 EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002970
2971 try
2972 {
2973 if (n < 0)
2974 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002975 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002976 }
2977
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002978 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002979
2980 if (context)
2981 {
daniel@transgaming.come2b22122010-03-11 19:22:14 +00002982 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002983 {
2984 context->deleteRenderbuffer(renderbuffers[i]);
2985 }
2986 }
2987 }
2988 catch(std::bad_alloc&)
2989 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002990 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002991 }
2992}
2993
2994void __stdcall glDeleteShader(GLuint shader)
2995{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002996 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002997
2998 try
2999 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003000 if (shader == 0)
3001 {
3002 return;
3003 }
3004
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003005 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003006
3007 if (context)
3008 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003009 if (!context->getShader(shader))
3010 {
3011 if(context->getProgram(shader))
3012 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003013 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003014 }
3015 else
3016 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003017 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003018 }
3019 }
3020
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003021 context->deleteShader(shader);
3022 }
3023 }
3024 catch(std::bad_alloc&)
3025 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003026 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003027 }
3028}
3029
3030void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures)
3031{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003032 EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003033
3034 try
3035 {
3036 if (n < 0)
3037 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003038 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003039 }
3040
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003041 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003042
3043 if (context)
3044 {
3045 for (int i = 0; i < n; i++)
3046 {
3047 if (textures[i] != 0)
3048 {
3049 context->deleteTexture(textures[i]);
3050 }
3051 }
3052 }
3053 }
3054 catch(std::bad_alloc&)
3055 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003056 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003057 }
3058}
3059
3060void __stdcall glDepthFunc(GLenum func)
3061{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003062 EVENT("(GLenum func = 0x%X)", func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003063
3064 try
3065 {
3066 switch (func)
3067 {
3068 case GL_NEVER:
3069 case GL_ALWAYS:
3070 case GL_LESS:
3071 case GL_LEQUAL:
3072 case GL_EQUAL:
3073 case GL_GREATER:
3074 case GL_GEQUAL:
3075 case GL_NOTEQUAL:
3076 break;
3077 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003078 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003079 }
3080
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003081 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003082
3083 if (context)
3084 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003085 context->setDepthFunc(func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003086 }
3087 }
3088 catch(std::bad_alloc&)
3089 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003090 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003091 }
3092}
3093
3094void __stdcall glDepthMask(GLboolean flag)
3095{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00003096 EVENT("(GLboolean flag = %u)", flag);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003097
3098 try
3099 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003100 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003101
3102 if (context)
3103 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003104 context->setDepthMask(flag != GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003105 }
3106 }
3107 catch(std::bad_alloc&)
3108 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003109 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003110 }
3111}
3112
3113void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar)
3114{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003115 EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003116
3117 try
3118 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003119 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003120
3121 if (context)
3122 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003123 context->setDepthRange(zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003124 }
3125 }
3126 catch(std::bad_alloc&)
3127 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003128 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003129 }
3130}
3131
3132void __stdcall glDetachShader(GLuint program, GLuint shader)
3133{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003134 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003135
3136 try
3137 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003138 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003139
3140 if (context)
3141 {
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003142
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003143 gl::Program *programObject = context->getProgram(program);
3144 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003145
3146 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003147 {
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003148 gl::Shader *shaderByProgramHandle;
3149 shaderByProgramHandle = context->getShader(program);
3150 if (!shaderByProgramHandle)
3151 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003152 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003153 }
3154 else
3155 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003156 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003157 }
3158 }
3159
3160 if (!shaderObject)
3161 {
3162 gl::Program *programByShaderHandle = context->getProgram(shader);
3163 if (!programByShaderHandle)
3164 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003165 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003166 }
3167 else
3168 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003169 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003170 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003171 }
3172
3173 if (!programObject->detachShader(shaderObject))
3174 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003175 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003176 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003177 }
3178 }
3179 catch(std::bad_alloc&)
3180 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003181 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003182 }
3183}
3184
3185void __stdcall glDisable(GLenum cap)
3186{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003187 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003188
3189 try
3190 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003191 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003192
3193 if (context)
3194 {
3195 switch (cap)
3196 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003197 case GL_CULL_FACE: context->setCullFace(false); break;
3198 case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break;
3199 case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break;
3200 case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break;
3201 case GL_SCISSOR_TEST: context->setScissorTest(false); break;
3202 case GL_STENCIL_TEST: context->setStencilTest(false); break;
3203 case GL_DEPTH_TEST: context->setDepthTest(false); break;
3204 case GL_BLEND: context->setBlend(false); break;
3205 case GL_DITHER: context->setDither(false); break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00003206
3207 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
3208 case GL_RASTERIZER_DISCARD:
3209 if (context->getClientVersion() < 3)
3210 {
3211 return gl::error(GL_INVALID_ENUM);
3212 }
3213 UNIMPLEMENTED();
3214 break;
3215
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003216 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003217 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003218 }
3219 }
3220 }
3221 catch(std::bad_alloc&)
3222 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003223 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003224 }
3225}
3226
3227void __stdcall glDisableVertexAttribArray(GLuint index)
3228{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003229 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003230
3231 try
3232 {
3233 if (index >= gl::MAX_VERTEX_ATTRIBS)
3234 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003235 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003236 }
3237
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003238 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003239
3240 if (context)
3241 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00003242 context->setEnableVertexAttribArray(index, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003243 }
3244 }
3245 catch(std::bad_alloc&)
3246 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003247 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003248 }
3249}
3250
3251void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count)
3252{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003253 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003254
3255 try
3256 {
3257 if (count < 0 || first < 0)
3258 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003259 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003260 }
3261
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003262 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003263
3264 if (context)
3265 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003266 context->drawArrays(mode, first, count, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003267 }
3268 }
3269 catch(std::bad_alloc&)
3270 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003271 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003272 }
3273}
3274
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003275void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
3276{
3277 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
3278
3279 try
3280 {
3281 if (count < 0 || first < 0 || primcount < 0)
3282 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003283 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003284 }
3285
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003286 if (primcount > 0)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003287 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003288 gl::Context *context = gl::getNonLostContext();
3289
3290 if (context)
3291 {
3292 context->drawArrays(mode, first, count, primcount);
3293 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003294 }
3295 }
3296 catch(std::bad_alloc&)
3297 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003298 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003299 }
3300}
3301
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003302void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003303{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003304 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003305 mode, count, type, indices);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003306
3307 try
3308 {
3309 if (count < 0)
3310 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003311 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003312 }
3313
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003314 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003315
3316 if (context)
3317 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00003318 switch (type)
3319 {
3320 case GL_UNSIGNED_BYTE:
3321 case GL_UNSIGNED_SHORT:
3322 break;
3323 case GL_UNSIGNED_INT:
3324 if (!context->supports32bitIndices())
3325 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003326 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com83921382011-01-08 05:46:00 +00003327 }
3328 break;
3329 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003330 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com83921382011-01-08 05:46:00 +00003331 }
3332
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003333 context->drawElements(mode, count, type, indices, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003334 }
3335 }
3336 catch(std::bad_alloc&)
3337 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003338 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003339 }
3340}
3341
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003342void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
3343{
3344 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
3345 mode, count, type, indices, primcount);
3346
3347 try
3348 {
3349 if (count < 0 || primcount < 0)
3350 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003351 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003352 }
3353
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003354 if (primcount > 0)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003355 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003356 gl::Context *context = gl::getNonLostContext();
3357
3358 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003359 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003360 switch (type)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003361 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003362 case GL_UNSIGNED_BYTE:
3363 case GL_UNSIGNED_SHORT:
3364 break;
3365 case GL_UNSIGNED_INT:
3366 if (!context->supports32bitIndices())
3367 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003368 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003369 }
3370 break;
3371 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003372 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003373 }
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003374
3375 context->drawElements(mode, count, type, indices, primcount);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003376 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003377 }
3378 }
3379 catch(std::bad_alloc&)
3380 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003381 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003382 }
3383}
3384
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003385void __stdcall glEnable(GLenum cap)
3386{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003387 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003388
3389 try
3390 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003391 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003392
3393 if (context)
3394 {
3395 switch (cap)
3396 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003397 case GL_CULL_FACE: context->setCullFace(true); break;
3398 case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break;
3399 case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break;
3400 case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break;
3401 case GL_SCISSOR_TEST: context->setScissorTest(true); break;
3402 case GL_STENCIL_TEST: context->setStencilTest(true); break;
3403 case GL_DEPTH_TEST: context->setDepthTest(true); break;
3404 case GL_BLEND: context->setBlend(true); break;
3405 case GL_DITHER: context->setDither(true); break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003406 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003407 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003408 }
3409 }
3410 }
3411 catch(std::bad_alloc&)
3412 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003413 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003414 }
3415}
3416
3417void __stdcall glEnableVertexAttribArray(GLuint index)
3418{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003419 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003420
3421 try
3422 {
3423 if (index >= gl::MAX_VERTEX_ATTRIBS)
3424 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003425 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003426 }
3427
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003428 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003429
3430 if (context)
3431 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00003432 context->setEnableVertexAttribArray(index, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003433 }
3434 }
3435 catch(std::bad_alloc&)
3436 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003437 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003438 }
3439}
3440
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003441void __stdcall glEndQueryEXT(GLenum target)
3442{
3443 EVENT("GLenum target = 0x%X)", target);
3444
3445 try
3446 {
3447 switch (target)
3448 {
3449 case GL_ANY_SAMPLES_PASSED_EXT:
3450 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
3451 break;
3452 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003453 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003454 }
3455
3456 gl::Context *context = gl::getNonLostContext();
3457
3458 if (context)
3459 {
3460 context->endQuery(target);
3461 }
3462 }
3463 catch(std::bad_alloc&)
3464 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003465 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003466 }
3467}
3468
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003469void __stdcall glFinishFenceNV(GLuint fence)
3470{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003471 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003472
3473 try
3474 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003475 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003476
3477 if (context)
3478 {
3479 gl::Fence* fenceObject = context->getFence(fence);
3480
3481 if (fenceObject == NULL)
3482 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003483 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003484 }
3485
3486 fenceObject->finishFence();
3487 }
3488 }
3489 catch(std::bad_alloc&)
3490 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003491 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003492 }
3493}
3494
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003495void __stdcall glFinish(void)
3496{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003497 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003498
3499 try
3500 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003501 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003502
3503 if (context)
3504 {
daniel@transgaming.com0d86aa72011-10-26 02:35:10 +00003505 context->sync(true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003506 }
3507 }
3508 catch(std::bad_alloc&)
3509 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003510 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003511 }
3512}
3513
3514void __stdcall glFlush(void)
3515{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003516 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003517
3518 try
3519 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003520 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003521
3522 if (context)
3523 {
daniel@transgaming.com0d86aa72011-10-26 02:35:10 +00003524 context->sync(false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003525 }
3526 }
3527 catch(std::bad_alloc&)
3528 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003529 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003530 }
3531}
3532
3533void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
3534{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003535 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003536 "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003537
3538 try
3539 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003540 if ((target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com2fa45512011-10-04 18:43:18 +00003541 || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003542 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003543 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003544 }
3545
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003546 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003547
3548 if (context)
3549 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003550 gl::Framebuffer *framebuffer = NULL;
3551 GLuint framebufferHandle = 0;
3552 if (target == GL_READ_FRAMEBUFFER_ANGLE)
3553 {
3554 framebuffer = context->getReadFramebuffer();
3555 framebufferHandle = context->getReadFramebufferHandle();
3556 }
daniel@transgaming.com2fa45512011-10-04 18:43:18 +00003557 else
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003558 {
3559 framebuffer = context->getDrawFramebuffer();
3560 framebufferHandle = context->getDrawFramebufferHandle();
3561 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003562
daniel@transgaming.com2fa45512011-10-04 18:43:18 +00003563 if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003564 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003565 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003566 }
3567
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003568 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003569 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003570 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
3571
3572 if (colorAttachment >= context->getMaximumRenderTargets())
3573 {
3574 return gl::error(GL_INVALID_VALUE);
3575 }
3576
3577 framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer);
3578 }
3579 else
3580 {
3581 switch (attachment)
3582 {
3583 case GL_DEPTH_ATTACHMENT:
3584 framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer);
3585 break;
3586 case GL_STENCIL_ATTACHMENT:
3587 framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer);
3588 break;
3589 default:
3590 return gl::error(GL_INVALID_ENUM);
3591 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003592 }
3593 }
3594 }
3595 catch(std::bad_alloc&)
3596 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003597 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003598 }
3599}
3600
3601void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
3602{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003603 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003604 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003605
3606 try
3607 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003608 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003609 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003610 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003611 }
3612
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003613 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003614
3615 if (context)
3616 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003617 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
3618 {
3619 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
3620
3621 if (colorAttachment >= context->getMaximumRenderTargets())
3622 {
3623 return gl::error(GL_INVALID_VALUE);
3624 }
3625 }
3626 else
3627 {
3628 switch (attachment)
3629 {
3630 case GL_DEPTH_ATTACHMENT:
3631 case GL_STENCIL_ATTACHMENT:
3632 break;
3633 default:
3634 return gl::error(GL_INVALID_ENUM);
3635 }
3636 }
3637
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003638 if (texture == 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003639 {
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003640 textarget = GL_NONE;
3641 }
3642 else
3643 {
3644 gl::Texture *tex = context->getTexture(texture);
3645
3646 if (tex == NULL)
3647 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003648 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003649 }
3650
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003651 switch (textarget)
3652 {
3653 case GL_TEXTURE_2D:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003654 {
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003655 if (tex->getTarget() != GL_TEXTURE_2D)
3656 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003657 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003658 }
3659 gl::Texture2D *tex2d = static_cast<gl::Texture2D *>(tex);
daniel@transgaming.com92f49922012-05-09 15:49:19 +00003660 if (tex2d->isCompressed(0))
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003661 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003662 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003663 }
3664 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003665 }
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003666
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003667 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003668 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003669 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003670 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003671 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003672 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003673 {
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003674 if (tex->getTarget() != GL_TEXTURE_CUBE_MAP)
3675 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003676 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003677 }
3678 gl::TextureCubeMap *texcube = static_cast<gl::TextureCubeMap *>(tex);
daniel@transgaming.com4df88e82012-05-09 15:49:24 +00003679 if (texcube->isCompressed(textarget, level))
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003680 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003681 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003682 }
3683 break;
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003684 }
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003685
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003686 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003687 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003688 }
3689
3690 if (level != 0)
3691 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003692 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003693 }
3694 }
3695
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003696 gl::Framebuffer *framebuffer = NULL;
3697 GLuint framebufferHandle = 0;
3698 if (target == GL_READ_FRAMEBUFFER_ANGLE)
3699 {
3700 framebuffer = context->getReadFramebuffer();
3701 framebufferHandle = context->getReadFramebufferHandle();
3702 }
3703 else
3704 {
3705 framebuffer = context->getDrawFramebuffer();
3706 framebufferHandle = context->getDrawFramebufferHandle();
3707 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003708
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003709 if (framebufferHandle == 0 || !framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003710 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003711 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003712 }
3713
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003714 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00003715 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003716 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
3717
3718 if (colorAttachment >= context->getMaximumRenderTargets())
3719 {
3720 return gl::error(GL_INVALID_VALUE);
3721 }
3722
3723 framebuffer->setColorbuffer(colorAttachment, textarget, texture);
3724 }
3725 else
3726 {
3727 switch (attachment)
3728 {
3729 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break;
3730 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break;
3731 }
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00003732 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003733 }
3734 }
3735 catch(std::bad_alloc&)
3736 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003737 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003738 }
3739}
3740
3741void __stdcall glFrontFace(GLenum mode)
3742{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003743 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003744
3745 try
3746 {
3747 switch (mode)
3748 {
3749 case GL_CW:
3750 case GL_CCW:
3751 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003752 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003753
3754 if (context)
3755 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003756 context->setFrontFace(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003757 }
3758 }
3759 break;
3760 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003761 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003762 }
3763 }
3764 catch(std::bad_alloc&)
3765 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003766 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003767 }
3768}
3769
3770void __stdcall glGenBuffers(GLsizei n, GLuint* buffers)
3771{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003772 EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003773
3774 try
3775 {
3776 if (n < 0)
3777 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003778 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003779 }
3780
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003781 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003782
3783 if (context)
3784 {
3785 for (int i = 0; i < n; i++)
3786 {
3787 buffers[i] = context->createBuffer();
3788 }
3789 }
3790 }
3791 catch(std::bad_alloc&)
3792 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003793 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003794 }
3795}
3796
3797void __stdcall glGenerateMipmap(GLenum target)
3798{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003799 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003800
3801 try
3802 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003803 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003804
3805 if (context)
3806 {
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003807 switch (target)
3808 {
3809 case GL_TEXTURE_2D:
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003810 {
3811 gl::Texture2D *tex2d = context->getTexture2D();
3812
daniel@transgaming.com92f49922012-05-09 15:49:19 +00003813 if (tex2d->isCompressed(0))
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003814 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003815 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003816 }
daniel@transgaming.com0c854682012-05-31 01:14:11 +00003817 if (tex2d->isDepth(0))
3818 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003819 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com0c854682012-05-31 01:14:11 +00003820 }
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003821
3822 tex2d->generateMipmaps();
3823 break;
3824 }
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003825
3826 case GL_TEXTURE_CUBE_MAP:
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003827 {
3828 gl::TextureCubeMap *texcube = context->getTextureCubeMap();
3829
daniel@transgaming.com4df88e82012-05-09 15:49:24 +00003830 if (texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0))
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003831 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003832 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003833 }
3834
3835 texcube->generateMipmaps();
3836 break;
3837 }
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003838
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00003839 case GL_TEXTURE_3D:
3840 {
3841 if (context->getClientVersion() < 3)
3842 {
3843 return gl::error(GL_INVALID_ENUM);
3844 }
3845
3846 gl::Texture3D *tex3D = context->getTexture3D();
3847 if (tex3D->isCompressed(0))
3848 {
3849 return gl::error(GL_INVALID_OPERATION);
3850 }
3851
3852 tex3D->generateMipmaps();
3853 break;
3854 }
3855
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00003856 case GL_TEXTURE_2D_ARRAY:
3857 {
3858 if (context->getClientVersion() < 3)
3859 {
3860 return gl::error(GL_INVALID_ENUM);
3861 }
3862
3863 gl::Texture2DArray *tex2darr = context->getTexture2DArray();
3864 if (tex2darr->isCompressed(0))
3865 {
3866 return gl::error(GL_INVALID_OPERATION);
3867 }
3868
3869 tex2darr->generateMipmaps();
3870 break;
3871 }
3872
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003873 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003874 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003875 }
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003876 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003877 }
3878 catch(std::bad_alloc&)
3879 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003880 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003881 }
3882}
3883
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003884void __stdcall glGenFencesNV(GLsizei n, GLuint* fences)
3885{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003886 EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003887
3888 try
3889 {
3890 if (n < 0)
3891 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003892 return gl::error(GL_INVALID_VALUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003893 }
3894
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003895 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003896
3897 if (context)
3898 {
3899 for (int i = 0; i < n; i++)
3900 {
3901 fences[i] = context->createFence();
3902 }
3903 }
3904 }
3905 catch(std::bad_alloc&)
3906 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003907 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003908 }
3909}
3910
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003911void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers)
3912{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003913 EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003914
3915 try
3916 {
3917 if (n < 0)
3918 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003919 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003920 }
3921
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003922 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003923
3924 if (context)
3925 {
3926 for (int i = 0; i < n; i++)
3927 {
3928 framebuffers[i] = context->createFramebuffer();
3929 }
3930 }
3931 }
3932 catch(std::bad_alloc&)
3933 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003934 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003935 }
3936}
3937
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003938void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids)
3939{
3940 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
3941
3942 try
3943 {
3944 if (n < 0)
3945 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003946 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003947 }
3948
3949 gl::Context *context = gl::getNonLostContext();
3950
3951 if (context)
3952 {
3953 for (int i = 0; i < n; i++)
3954 {
3955 ids[i] = context->createQuery();
3956 }
3957 }
3958 }
3959 catch(std::bad_alloc&)
3960 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003961 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003962 }
3963}
3964
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003965void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
3966{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003967 EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003968
3969 try
3970 {
3971 if (n < 0)
3972 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003973 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003974 }
3975
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003976 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003977
3978 if (context)
3979 {
3980 for (int i = 0; i < n; i++)
3981 {
3982 renderbuffers[i] = context->createRenderbuffer();
3983 }
3984 }
3985 }
3986 catch(std::bad_alloc&)
3987 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003988 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003989 }
3990}
3991
3992void __stdcall glGenTextures(GLsizei n, GLuint* textures)
3993{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003994 EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003995
3996 try
3997 {
3998 if (n < 0)
3999 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004000 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004001 }
4002
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004003 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004004
4005 if (context)
4006 {
4007 for (int i = 0; i < n; i++)
4008 {
4009 textures[i] = context->createTexture();
4010 }
4011 }
4012 }
4013 catch(std::bad_alloc&)
4014 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004015 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004016 }
4017}
4018
daniel@transgaming.com85423182010-04-22 13:35:27 +00004019void __stdcall glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004020{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004021 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
daniel@transgaming.com85423182010-04-22 13:35:27 +00004022 "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004023 program, index, bufsize, length, size, type, name);
4024
4025 try
4026 {
4027 if (bufsize < 0)
4028 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004029 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004030 }
4031
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004032 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com85423182010-04-22 13:35:27 +00004033
4034 if (context)
4035 {
4036 gl::Program *programObject = context->getProgram(program);
4037
4038 if (!programObject)
4039 {
4040 if (context->getShader(program))
4041 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004042 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com85423182010-04-22 13:35:27 +00004043 }
4044 else
4045 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004046 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com85423182010-04-22 13:35:27 +00004047 }
4048 }
4049
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004050 if (index >= (GLuint)programObject->getActiveAttributeCount())
daniel@transgaming.com85423182010-04-22 13:35:27 +00004051 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004052 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com85423182010-04-22 13:35:27 +00004053 }
4054
4055 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
4056 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004057 }
4058 catch(std::bad_alloc&)
4059 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004060 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004061 }
4062}
4063
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004064void __stdcall glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004065{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004066 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004067 "GLsizei* length = 0x%0.8p, GLint* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004068 program, index, bufsize, length, size, type, name);
4069
4070 try
4071 {
4072 if (bufsize < 0)
4073 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004074 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004075 }
4076
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004077 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004078
4079 if (context)
4080 {
4081 gl::Program *programObject = context->getProgram(program);
4082
4083 if (!programObject)
4084 {
4085 if (context->getShader(program))
4086 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004087 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004088 }
4089 else
4090 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004091 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004092 }
4093 }
4094
4095 if (index >= (GLuint)programObject->getActiveUniformCount())
4096 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004097 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004098 }
4099
4100 programObject->getActiveUniform(index, bufsize, length, size, type, name);
4101 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004102 }
4103 catch(std::bad_alloc&)
4104 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004105 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004106 }
4107}
4108
4109void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
4110{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004111 EVENT("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = 0x%0.8p, GLuint* shaders = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004112 program, maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004113
4114 try
4115 {
4116 if (maxcount < 0)
4117 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004118 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004119 }
4120
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004121 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com6c785212010-03-30 03:36:17 +00004122
4123 if (context)
4124 {
4125 gl::Program *programObject = context->getProgram(program);
4126
4127 if (!programObject)
4128 {
daniel@transgaming.com23953e32010-04-13 19:53:31 +00004129 if (context->getShader(program))
4130 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004131 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com23953e32010-04-13 19:53:31 +00004132 }
4133 else
4134 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004135 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com23953e32010-04-13 19:53:31 +00004136 }
daniel@transgaming.com6c785212010-03-30 03:36:17 +00004137 }
4138
4139 return programObject->getAttachedShaders(maxcount, count, shaders);
4140 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004141 }
4142 catch(std::bad_alloc&)
4143 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004144 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004145 }
4146}
4147
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004148int __stdcall glGetAttribLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004149{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004150 EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004151
4152 try
4153 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004154 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004155
4156 if (context)
4157 {
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004158
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004159 gl::Program *programObject = context->getProgram(program);
4160
4161 if (!programObject)
4162 {
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004163 if (context->getShader(program))
4164 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004165 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004166 }
4167 else
4168 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004169 return gl::error(GL_INVALID_VALUE, -1);
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004170 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004171 }
4172
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00004173 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
daniel@transgaming.com716056c2012-07-24 18:38:59 +00004174 if (!programObject->isLinked() || !programBinary)
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00004175 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004176 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00004177 }
4178
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00004179 return programBinary->getAttributeLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004180 }
4181 }
4182 catch(std::bad_alloc&)
4183 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004184 return gl::error(GL_OUT_OF_MEMORY, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004185 }
4186
4187 return -1;
4188}
4189
4190void __stdcall glGetBooleanv(GLenum pname, GLboolean* params)
4191{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004192 EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004193
4194 try
4195 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004196 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004197
4198 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004199 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004200 if (!(context->getBooleanv(pname, params)))
4201 {
4202 GLenum nativeType;
4203 unsigned int numParams = 0;
4204 if (!context->getQueryParameterInfo(pname, &nativeType, &numParams))
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004205 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004206
4207 if (numParams == 0)
4208 return; // it is known that the pname is valid, but there are no parameters to return
4209
4210 if (nativeType == GL_FLOAT)
4211 {
4212 GLfloat *floatParams = NULL;
4213 floatParams = new GLfloat[numParams];
4214
4215 context->getFloatv(pname, floatParams);
4216
4217 for (unsigned int i = 0; i < numParams; ++i)
4218 {
4219 if (floatParams[i] == 0.0f)
4220 params[i] = GL_FALSE;
4221 else
4222 params[i] = GL_TRUE;
4223 }
4224
4225 delete [] floatParams;
4226 }
4227 else if (nativeType == GL_INT)
4228 {
4229 GLint *intParams = NULL;
4230 intParams = new GLint[numParams];
4231
4232 context->getIntegerv(pname, intParams);
4233
4234 for (unsigned int i = 0; i < numParams; ++i)
4235 {
4236 if (intParams[i] == 0)
4237 params[i] = GL_FALSE;
4238 else
4239 params[i] = GL_TRUE;
4240 }
4241
4242 delete [] intParams;
4243 }
4244 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004245 }
4246 }
4247 catch(std::bad_alloc&)
4248 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004249 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004250 }
4251}
4252
4253void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
4254{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004255 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004256
4257 try
4258 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004259 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004260
4261 if (context)
4262 {
4263 gl::Buffer *buffer;
4264
4265 switch (target)
4266 {
4267 case GL_ARRAY_BUFFER:
4268 buffer = context->getArrayBuffer();
4269 break;
4270 case GL_ELEMENT_ARRAY_BUFFER:
4271 buffer = context->getElementArrayBuffer();
4272 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004273 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004274 }
4275
4276 if (!buffer)
4277 {
4278 // A null buffer means that "0" is bound to the requested buffer target
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004279 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004280 }
4281
4282 switch (pname)
4283 {
4284 case GL_BUFFER_USAGE:
4285 *params = buffer->usage();
4286 break;
4287 case GL_BUFFER_SIZE:
4288 *params = buffer->size();
4289 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004290 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004291 }
4292 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004293 }
4294 catch(std::bad_alloc&)
4295 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004296 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004297 }
4298}
4299
4300GLenum __stdcall glGetError(void)
4301{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004302 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004303
4304 gl::Context *context = gl::getContext();
4305
4306 if (context)
4307 {
daniel@transgaming.com82b28912011-12-12 21:01:35 +00004308 return context->getError();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004309 }
4310
4311 return GL_NO_ERROR;
4312}
4313
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004314void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
4315{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004316 EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004317
4318 try
4319 {
4320
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004321 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004322
4323 if (context)
4324 {
4325 gl::Fence *fenceObject = context->getFence(fence);
4326
4327 if (fenceObject == NULL)
4328 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004329 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004330 }
4331
4332 fenceObject->getFenceiv(pname, params);
4333 }
4334 }
4335 catch(std::bad_alloc&)
4336 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004337 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004338 }
4339}
4340
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004341void __stdcall glGetFloatv(GLenum pname, GLfloat* params)
4342{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004343 EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004344
4345 try
4346 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004347 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004348
4349 if (context)
4350 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004351 if (!(context->getFloatv(pname, params)))
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004352 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004353 GLenum nativeType;
4354 unsigned int numParams = 0;
4355 if (!context->getQueryParameterInfo(pname, &nativeType, &numParams))
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004356 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004357
4358 if (numParams == 0)
4359 return; // it is known that the pname is valid, but that there are no parameters to return.
4360
4361 if (nativeType == GL_BOOL)
4362 {
4363 GLboolean *boolParams = NULL;
4364 boolParams = new GLboolean[numParams];
4365
4366 context->getBooleanv(pname, boolParams);
4367
4368 for (unsigned int i = 0; i < numParams; ++i)
4369 {
4370 if (boolParams[i] == GL_FALSE)
4371 params[i] = 0.0f;
4372 else
4373 params[i] = 1.0f;
4374 }
4375
4376 delete [] boolParams;
4377 }
4378 else if (nativeType == GL_INT)
4379 {
4380 GLint *intParams = NULL;
4381 intParams = new GLint[numParams];
4382
4383 context->getIntegerv(pname, intParams);
4384
4385 for (unsigned int i = 0; i < numParams; ++i)
4386 {
4387 params[i] = (GLfloat)intParams[i];
4388 }
4389
4390 delete [] intParams;
4391 }
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004392 }
4393 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004394 }
4395 catch(std::bad_alloc&)
4396 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004397 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004398 }
4399}
4400
4401void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
4402{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004403 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004404 target, attachment, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004405
4406 try
4407 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004408 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004409
4410 if (context)
4411 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004412 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004413 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004414 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004415 }
4416
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004417 gl::Framebuffer *framebuffer = NULL;
4418 if (target == GL_READ_FRAMEBUFFER_ANGLE)
4419 {
4420 if(context->getReadFramebufferHandle() == 0)
4421 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004422 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004423 }
4424
4425 framebuffer = context->getReadFramebuffer();
4426 }
4427 else
4428 {
4429 if (context->getDrawFramebufferHandle() == 0)
4430 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004431 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004432 }
4433
4434 framebuffer = context->getDrawFramebuffer();
4435 }
4436
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004437 GLenum attachmentType;
4438 GLuint attachmentHandle;
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00004439
4440 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004441 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00004442 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
4443
4444 if (colorAttachment >= context->getMaximumRenderTargets())
4445 {
4446 return gl::error(GL_INVALID_ENUM);
4447 }
4448
4449 attachmentType = framebuffer->getColorbufferType(colorAttachment);
4450 attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment);
4451 }
4452 else
4453 {
4454 switch (attachment)
4455 {
4456 case GL_DEPTH_ATTACHMENT:
4457 attachmentType = framebuffer->getDepthbufferType();
4458 attachmentHandle = framebuffer->getDepthbufferHandle();
4459 break;
4460 case GL_STENCIL_ATTACHMENT:
4461 attachmentType = framebuffer->getStencilbufferType();
4462 attachmentHandle = framebuffer->getStencilbufferHandle();
4463 break;
4464 default: return gl::error(GL_INVALID_ENUM);
4465 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004466 }
4467
4468 GLenum attachmentObjectType; // Type category
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00004469 if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004470 {
4471 attachmentObjectType = attachmentType;
4472 }
apatrick@chromium.org551022e2012-01-23 19:56:54 +00004473 else if (gl::IsInternalTextureTarget(attachmentType))
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004474 {
4475 attachmentObjectType = GL_TEXTURE;
4476 }
apatrick@chromium.orga1d80592012-01-25 21:52:10 +00004477 else
4478 {
4479 UNREACHABLE();
4480 return;
4481 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004482
4483 switch (pname)
4484 {
4485 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
4486 *params = attachmentObjectType;
4487 break;
4488 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
4489 if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE)
4490 {
4491 *params = attachmentHandle;
4492 }
4493 else
4494 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004495 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004496 }
4497 break;
4498 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
4499 if (attachmentObjectType == GL_TEXTURE)
4500 {
4501 *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0
4502 }
4503 else
4504 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004505 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004506 }
4507 break;
4508 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
4509 if (attachmentObjectType == GL_TEXTURE)
4510 {
daniel@transgaming.com19ffc242010-05-04 03:35:21 +00004511 if (gl::IsCubemapTextureTarget(attachmentType))
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004512 {
4513 *params = attachmentType;
4514 }
4515 else
4516 {
4517 *params = 0;
4518 }
4519 }
4520 else
4521 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004522 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004523 }
4524 break;
4525 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004526 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004527 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004528 }
4529 }
4530 catch(std::bad_alloc&)
4531 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004532 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004533 }
4534}
4535
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00004536GLenum __stdcall glGetGraphicsResetStatusEXT(void)
4537{
4538 EVENT("()");
4539
4540 try
4541 {
4542 gl::Context *context = gl::getContext();
4543
4544 if (context)
4545 {
4546 return context->getResetStatus();
4547 }
4548
4549 return GL_NO_ERROR;
4550 }
4551 catch(std::bad_alloc&)
4552 {
4553 return GL_OUT_OF_MEMORY;
4554 }
4555}
4556
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004557void __stdcall glGetIntegerv(GLenum pname, GLint* params)
4558{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004559 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004560
4561 try
4562 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004563 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004564
4565 if (context)
4566 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004567 if (!(context->getIntegerv(pname, params)))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004568 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004569 GLenum nativeType;
4570 unsigned int numParams = 0;
4571 if (!context->getQueryParameterInfo(pname, &nativeType, &numParams))
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004572 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004573
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004574 if (numParams == 0)
4575 return; // it is known that pname is valid, but there are no parameters to return
4576
4577 if (nativeType == GL_BOOL)
4578 {
4579 GLboolean *boolParams = NULL;
4580 boolParams = new GLboolean[numParams];
4581
4582 context->getBooleanv(pname, boolParams);
4583
4584 for (unsigned int i = 0; i < numParams; ++i)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004585 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004586 if (boolParams[i] == GL_FALSE)
4587 params[i] = 0;
4588 else
4589 params[i] = 1;
4590 }
4591
4592 delete [] boolParams;
4593 }
4594 else if (nativeType == GL_FLOAT)
4595 {
4596 GLfloat *floatParams = NULL;
4597 floatParams = new GLfloat[numParams];
4598
4599 context->getFloatv(pname, floatParams);
4600
4601 for (unsigned int i = 0; i < numParams; ++i)
4602 {
daniel@transgaming.comc1641352010-04-26 15:33:36 +00004603 if (pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE || pname == GL_BLEND_COLOR)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004604 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004605 params[i] = (GLint)(((GLfloat)(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004606 }
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004607 else
4608 params[i] = (GLint)(floatParams[i] > 0.0f ? floor(floatParams[i] + 0.5) : ceil(floatParams[i] - 0.5));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004609 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004610
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004611 delete [] floatParams;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004612 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004613 }
4614 }
4615 }
4616 catch(std::bad_alloc&)
4617 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004618 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004619 }
4620}
4621
4622void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params)
4623{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004624 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004625
4626 try
4627 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004628 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004629
4630 if (context)
4631 {
4632 gl::Program *programObject = context->getProgram(program);
4633
4634 if (!programObject)
4635 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004636 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004637 }
4638
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00004639 if (context->getClientVersion() < 3)
4640 {
4641 switch (pname)
4642 {
4643 case GL_ACTIVE_UNIFORM_BLOCKS:
4644 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
4645 return gl::error(GL_INVALID_ENUM);
4646 }
4647 }
4648
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004649 switch (pname)
4650 {
4651 case GL_DELETE_STATUS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004652 *params = programObject->isFlaggedForDeletion();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004653 return;
4654 case GL_LINK_STATUS:
daniel@transgaming.com716056c2012-07-24 18:38:59 +00004655 *params = programObject->isLinked();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004656 return;
4657 case GL_VALIDATE_STATUS:
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004658 *params = programObject->isValidated();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004659 return;
4660 case GL_INFO_LOG_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004661 *params = programObject->getInfoLogLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004662 return;
4663 case GL_ATTACHED_SHADERS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004664 *params = programObject->getAttachedShadersCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004665 return;
4666 case GL_ACTIVE_ATTRIBUTES:
daniel@transgaming.com85423182010-04-22 13:35:27 +00004667 *params = programObject->getActiveAttributeCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004668 return;
4669 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
daniel@transgaming.com85423182010-04-22 13:35:27 +00004670 *params = programObject->getActiveAttributeMaxLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004671 return;
4672 case GL_ACTIVE_UNIFORMS:
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004673 *params = programObject->getActiveUniformCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004674 return;
4675 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004676 *params = programObject->getActiveUniformMaxLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004677 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00004678 case GL_PROGRAM_BINARY_LENGTH_OES:
apatrick@chromium.org90080e32012-07-09 22:15:33 +00004679 *params = programObject->getProgramBinaryLength();
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00004680 return;
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00004681 case GL_ACTIVE_UNIFORM_BLOCKS:
4682 *params = programObject->getActiveUniformBlockCount();
4683 return;
4684 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
4685 *params = programObject->getActiveUniformBlockMaxLength();
4686 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004687 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004688 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004689 }
4690 }
4691 }
4692 catch(std::bad_alloc&)
4693 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004694 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004695 }
4696}
4697
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004698void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004699{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004700 EVENT("(GLuint program = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004701 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004702
4703 try
4704 {
4705 if (bufsize < 0)
4706 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004707 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004708 }
4709
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004710 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004711
4712 if (context)
4713 {
4714 gl::Program *programObject = context->getProgram(program);
4715
4716 if (!programObject)
4717 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004718 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004719 }
4720
4721 programObject->getInfoLog(bufsize, length, infolog);
4722 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004723 }
4724 catch(std::bad_alloc&)
4725 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004726 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004727 }
4728}
4729
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004730void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
4731{
4732 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
4733
4734 try
4735 {
4736 switch (pname)
4737 {
4738 case GL_CURRENT_QUERY_EXT:
4739 break;
4740 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004741 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004742 }
4743
4744 gl::Context *context = gl::getNonLostContext();
4745
4746 if (context)
4747 {
4748 params[0] = context->getActiveQuery(target);
4749 }
4750 }
4751 catch(std::bad_alloc&)
4752 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004753 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004754 }
4755}
4756
4757void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
4758{
4759 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
4760
4761 try
4762 {
4763 switch (pname)
4764 {
4765 case GL_QUERY_RESULT_EXT:
4766 case GL_QUERY_RESULT_AVAILABLE_EXT:
4767 break;
4768 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004769 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004770 }
4771 gl::Context *context = gl::getNonLostContext();
4772
4773 if (context)
4774 {
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004775 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
4776
4777 if (!queryObject)
4778 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004779 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004780 }
4781
4782 if (context->getActiveQuery(queryObject->getType()) == id)
4783 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004784 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004785 }
4786
4787 switch(pname)
4788 {
4789 case GL_QUERY_RESULT_EXT:
4790 params[0] = queryObject->getResult();
4791 break;
4792 case GL_QUERY_RESULT_AVAILABLE_EXT:
4793 params[0] = queryObject->isResultAvailable();
4794 break;
4795 default:
4796 ASSERT(false);
4797 }
4798 }
4799 }
4800 catch(std::bad_alloc&)
4801 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004802 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004803 }
4804}
4805
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004806void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
4807{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004808 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004809
4810 try
4811 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004812 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004813
4814 if (context)
4815 {
4816 if (target != GL_RENDERBUFFER)
4817 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004818 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004819 }
4820
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004821 if (context->getRenderbufferHandle() == 0)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004822 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004823 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004824 }
4825
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004826 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle());
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004827
4828 switch (pname)
4829 {
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00004830 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
4831 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
4832 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
4833 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
4834 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
4835 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
4836 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
4837 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
4838 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00004839 case GL_RENDERBUFFER_SAMPLES_ANGLE:
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00004840 if (context->getMaxSupportedSamples() != 0)
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00004841 {
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00004842 *params = renderbuffer->getSamples();
4843 }
4844 else
4845 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004846 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00004847 }
4848 break;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004849 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004850 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004851 }
4852 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004853 }
4854 catch(std::bad_alloc&)
4855 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004856 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004857 }
4858}
4859
4860void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
4861{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004862 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004863
4864 try
4865 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004866 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004867
4868 if (context)
4869 {
4870 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004871
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004872 if (!shaderObject)
4873 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004874 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004875 }
4876
4877 switch (pname)
4878 {
4879 case GL_SHADER_TYPE:
4880 *params = shaderObject->getType();
4881 return;
4882 case GL_DELETE_STATUS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004883 *params = shaderObject->isFlaggedForDeletion();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004884 return;
4885 case GL_COMPILE_STATUS:
4886 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
4887 return;
4888 case GL_INFO_LOG_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004889 *params = shaderObject->getInfoLogLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004890 return;
4891 case GL_SHADER_SOURCE_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004892 *params = shaderObject->getSourceLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004893 return;
zmo@google.coma574f782011-10-03 21:45:23 +00004894 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
4895 *params = shaderObject->getTranslatedSourceLength();
4896 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004897 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004898 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004899 }
4900 }
4901 }
4902 catch(std::bad_alloc&)
4903 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004904 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004905 }
4906}
4907
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004908void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004909{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004910 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004911 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004912
4913 try
4914 {
4915 if (bufsize < 0)
4916 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004917 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004918 }
4919
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004920 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004921
4922 if (context)
4923 {
4924 gl::Shader *shaderObject = context->getShader(shader);
4925
4926 if (!shaderObject)
4927 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004928 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004929 }
4930
4931 shaderObject->getInfoLog(bufsize, length, infolog);
4932 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004933 }
4934 catch(std::bad_alloc&)
4935 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004936 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004937 }
4938}
4939
4940void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
4941{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004942 EVENT("(GLenum shadertype = 0x%X, GLenum precisiontype = 0x%X, GLint* range = 0x%0.8p, GLint* precision = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004943 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004944
4945 try
4946 {
daniel@transgaming.com6c785212010-03-30 03:36:17 +00004947 switch (shadertype)
4948 {
4949 case GL_VERTEX_SHADER:
4950 case GL_FRAGMENT_SHADER:
4951 break;
4952 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004953 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com6c785212010-03-30 03:36:17 +00004954 }
4955
4956 switch (precisiontype)
4957 {
4958 case GL_LOW_FLOAT:
4959 case GL_MEDIUM_FLOAT:
4960 case GL_HIGH_FLOAT:
4961 // Assume IEEE 754 precision
4962 range[0] = 127;
4963 range[1] = 127;
daniel@transgaming.comc5c15382010-04-23 18:34:49 +00004964 *precision = 23;
daniel@transgaming.com6c785212010-03-30 03:36:17 +00004965 break;
4966 case GL_LOW_INT:
4967 case GL_MEDIUM_INT:
4968 case GL_HIGH_INT:
4969 // Some (most) hardware only supports single-precision floating-point numbers,
4970 // which can accurately represent integers up to +/-16777216
4971 range[0] = 24;
4972 range[1] = 24;
daniel@transgaming.comc5c15382010-04-23 18:34:49 +00004973 *precision = 0;
daniel@transgaming.com6c785212010-03-30 03:36:17 +00004974 break;
4975 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004976 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com6c785212010-03-30 03:36:17 +00004977 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004978 }
4979 catch(std::bad_alloc&)
4980 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004981 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004982 }
4983}
4984
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004985void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004986{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004987 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004988 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004989
4990 try
4991 {
4992 if (bufsize < 0)
4993 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004994 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004995 }
4996
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004997 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004998
4999 if (context)
5000 {
5001 gl::Shader *shaderObject = context->getShader(shader);
5002
5003 if (!shaderObject)
5004 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005005 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005006 }
5007
5008 shaderObject->getSource(bufsize, length, source);
5009 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005010 }
5011 catch(std::bad_alloc&)
5012 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005013 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005014 }
5015}
5016
zmo@google.coma574f782011-10-03 21:45:23 +00005017void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
5018{
5019 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
5020 shader, bufsize, length, source);
5021
5022 try
5023 {
5024 if (bufsize < 0)
5025 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005026 return gl::error(GL_INVALID_VALUE);
zmo@google.coma574f782011-10-03 21:45:23 +00005027 }
5028
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005029 gl::Context *context = gl::getNonLostContext();
zmo@google.coma574f782011-10-03 21:45:23 +00005030
5031 if (context)
5032 {
5033 gl::Shader *shaderObject = context->getShader(shader);
5034
5035 if (!shaderObject)
5036 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005037 return gl::error(GL_INVALID_OPERATION);
zmo@google.coma574f782011-10-03 21:45:23 +00005038 }
5039
5040 shaderObject->getTranslatedSource(bufsize, length, source);
5041 }
5042 }
5043 catch(std::bad_alloc&)
5044 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005045 return gl::error(GL_OUT_OF_MEMORY);
zmo@google.coma574f782011-10-03 21:45:23 +00005046 }
5047}
5048
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005049const GLubyte* __stdcall glGetString(GLenum name)
5050{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005051 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005052
5053 try
5054 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005055 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00005056
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005057 switch (name)
5058 {
5059 case GL_VENDOR:
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +00005060 return (GLubyte*)"Google Inc.";
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005061 case GL_RENDERER:
daniel@transgaming.comc23ff642011-08-16 20:28:45 +00005062 return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005063 case GL_VERSION:
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00005064 if (context->getClientVersion() == 2)
5065 {
5066 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")";
5067 }
5068 else
5069 {
5070 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")";
5071 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005072 case GL_SHADING_LANGUAGE_VERSION:
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00005073 if (context->getClientVersion() == 2)
5074 {
5075 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")";
5076 }
5077 else
5078 {
5079 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")";
5080 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005081 case GL_EXTENSIONS:
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00005082 return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : "");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005083 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005084 return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005085 }
5086 }
5087 catch(std::bad_alloc&)
5088 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005089 return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005090 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005091}
5092
5093void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
5094{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005095 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005096
5097 try
5098 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005099 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005100
5101 if (context)
5102 {
5103 gl::Texture *texture;
5104
5105 switch (target)
5106 {
5107 case GL_TEXTURE_2D:
5108 texture = context->getTexture2D();
5109 break;
5110 case GL_TEXTURE_CUBE_MAP:
5111 texture = context->getTextureCubeMap();
5112 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00005113 case GL_TEXTURE_3D:
5114 if (context->getClientVersion() < 3)
5115 {
5116 return gl::error(GL_INVALID_ENUM);
5117 }
5118 texture = context->getTexture3D();
5119 break;
shannonwoods@chromium.org0c611d12013-05-30 00:15:05 +00005120 case GL_TEXTURE_2D_ARRAY:
5121 if (context->getClientVersion() < 3)
5122 {
5123 return gl::error(GL_INVALID_ENUM);
5124 }
5125 texture = context->getTexture2DArray();
5126 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005127 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005128 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005129 }
5130
5131 switch (pname)
5132 {
5133 case GL_TEXTURE_MAG_FILTER:
5134 *params = (GLfloat)texture->getMagFilter();
5135 break;
5136 case GL_TEXTURE_MIN_FILTER:
5137 *params = (GLfloat)texture->getMinFilter();
5138 break;
5139 case GL_TEXTURE_WRAP_S:
5140 *params = (GLfloat)texture->getWrapS();
5141 break;
5142 case GL_TEXTURE_WRAP_T:
5143 *params = (GLfloat)texture->getWrapT();
5144 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00005145 case GL_TEXTURE_WRAP_R:
5146 if (context->getClientVersion() < 3)
5147 {
5148 return gl::error(GL_INVALID_ENUM);
5149 }
5150 *params = (GLfloat)texture->getWrapR();
5151 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005152 case GL_TEXTURE_IMMUTABLE_FORMAT:
5153 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
daniel@transgaming.comd30bd0a2011-11-11 04:10:34 +00005154 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
5155 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005156 case GL_TEXTURE_IMMUTABLE_LEVELS:
5157 if (context->getClientVersion() < 3)
5158 {
5159 return gl::error(GL_INVALID_ENUM);
5160 }
5161 *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0);
5162 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00005163 case GL_TEXTURE_USAGE_ANGLE:
5164 *params = (GLfloat)texture->getUsage();
5165 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005166 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
5167 if (!context->supportsTextureFilterAnisotropy())
5168 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005169 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005170 }
5171 *params = (GLfloat)texture->getMaxAnisotropy();
5172 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005173 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005174 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005175 }
5176 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005177 }
5178 catch(std::bad_alloc&)
5179 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005180 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005181 }
5182}
5183
5184void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
5185{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005186 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005187
5188 try
5189 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005190 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005191
5192 if (context)
5193 {
5194 gl::Texture *texture;
5195
5196 switch (target)
5197 {
5198 case GL_TEXTURE_2D:
5199 texture = context->getTexture2D();
5200 break;
5201 case GL_TEXTURE_CUBE_MAP:
5202 texture = context->getTextureCubeMap();
5203 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00005204 case GL_TEXTURE_3D:
5205 if (context->getClientVersion() < 3)
5206 {
5207 return gl::error(GL_INVALID_ENUM);
5208 }
5209 texture = context->getTexture3D();
5210 break;
shannonwoods@chromium.org0c611d12013-05-30 00:15:05 +00005211 case GL_TEXTURE_2D_ARRAY:
5212 if (context->getClientVersion() < 3)
5213 {
5214 return gl::error(GL_INVALID_ENUM);
5215 }
5216 texture = context->getTexture2DArray();
5217 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005218 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005219 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005220 }
5221
5222 switch (pname)
5223 {
5224 case GL_TEXTURE_MAG_FILTER:
5225 *params = texture->getMagFilter();
5226 break;
5227 case GL_TEXTURE_MIN_FILTER:
5228 *params = texture->getMinFilter();
5229 break;
5230 case GL_TEXTURE_WRAP_S:
5231 *params = texture->getWrapS();
5232 break;
5233 case GL_TEXTURE_WRAP_T:
5234 *params = texture->getWrapT();
5235 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00005236 case GL_TEXTURE_WRAP_R:
5237 if (context->getClientVersion() < 3)
5238 {
5239 return gl::error(GL_INVALID_ENUM);
5240 }
5241 *params = texture->getWrapR();
5242 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005243 case GL_TEXTURE_IMMUTABLE_FORMAT:
5244 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
daniel@transgaming.comd30bd0a2011-11-11 04:10:34 +00005245 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
5246 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005247 case GL_TEXTURE_IMMUTABLE_LEVELS:
5248 if (context->getClientVersion() < 3)
5249 {
5250 return gl::error(GL_INVALID_ENUM);
5251 }
5252 *params = texture->isImmutable() ? texture->levelCount() : 0;
5253 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00005254 case GL_TEXTURE_USAGE_ANGLE:
5255 *params = texture->getUsage();
5256 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005257 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
5258 if (!context->supportsTextureFilterAnisotropy())
5259 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005260 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005261 }
5262 *params = (GLint)texture->getMaxAnisotropy();
5263 break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00005264
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005265 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005266 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005267 }
5268 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005269 }
5270 catch(std::bad_alloc&)
5271 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005272 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005273 }
5274}
5275
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005276void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
5277{
5278 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
5279 program, location, bufSize, params);
5280
5281 try
5282 {
5283 if (bufSize < 0)
5284 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005285 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005286 }
5287
5288 gl::Context *context = gl::getNonLostContext();
5289
5290 if (context)
5291 {
5292 if (program == 0)
5293 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005294 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005295 }
5296
5297 gl::Program *programObject = context->getProgram(program);
5298
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005299 if (!programObject || !programObject->isLinked())
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005300 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005301 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005302 }
5303
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005304 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5305 if (!programBinary)
5306 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005307 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005308 }
5309
5310 if (!programBinary->getUniformfv(location, &bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005311 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005312 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005313 }
5314 }
5315 }
5316 catch(std::bad_alloc&)
5317 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005318 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005319 }
5320}
5321
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005322void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params)
5323{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005324 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005325
5326 try
5327 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005328 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005329
5330 if (context)
5331 {
5332 if (program == 0)
5333 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005334 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005335 }
5336
5337 gl::Program *programObject = context->getProgram(program);
5338
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005339 if (!programObject || !programObject->isLinked())
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005340 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005341 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005342 }
5343
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005344 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5345 if (!programBinary)
5346 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005347 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005348 }
5349
5350 if (!programBinary->getUniformfv(location, NULL, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005351 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005352 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005353 }
5354 }
5355 }
5356 catch(std::bad_alloc&)
5357 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005358 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005359 }
5360}
5361
5362void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
5363{
5364 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
5365 program, location, bufSize, params);
5366
5367 try
5368 {
5369 if (bufSize < 0)
5370 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005371 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005372 }
5373
5374 gl::Context *context = gl::getNonLostContext();
5375
5376 if (context)
5377 {
5378 if (program == 0)
5379 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005380 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005381 }
5382
5383 gl::Program *programObject = context->getProgram(program);
5384
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005385 if (!programObject || !programObject->isLinked())
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005386 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005387 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005388 }
5389
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005390 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5391 if (!programBinary)
5392 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005393 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005394 }
5395
5396 if (!programBinary->getUniformiv(location, &bufSize, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005397 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005398 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005399 }
5400 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005401 }
5402 catch(std::bad_alloc&)
5403 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005404 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005405 }
5406}
5407
5408void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params)
5409{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005410 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005411
5412 try
5413 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005414 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005415
5416 if (context)
5417 {
5418 if (program == 0)
5419 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005420 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005421 }
5422
5423 gl::Program *programObject = context->getProgram(program);
5424
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005425 if (!programObject || !programObject->isLinked())
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005426 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005427 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005428 }
5429
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005430 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5431 if (!programBinary)
5432 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005433 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005434 }
5435
5436 if (!programBinary->getUniformiv(location, NULL, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005437 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005438 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005439 }
5440 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005441 }
5442 catch(std::bad_alloc&)
5443 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005444 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005445 }
5446}
5447
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005448int __stdcall glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005449{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005450 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005451
5452 try
5453 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005454 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005455
5456 if (strstr(name, "gl_") == name)
5457 {
5458 return -1;
5459 }
5460
5461 if (context)
5462 {
5463 gl::Program *programObject = context->getProgram(program);
5464
5465 if (!programObject)
5466 {
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00005467 if (context->getShader(program))
5468 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005469 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00005470 }
5471 else
5472 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005473 return gl::error(GL_INVALID_VALUE, -1);
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00005474 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005475 }
5476
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005477 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005478 if (!programObject->isLinked() || !programBinary)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005479 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005480 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005481 }
5482
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005483 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005484 }
5485 }
5486 catch(std::bad_alloc&)
5487 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005488 return gl::error(GL_OUT_OF_MEMORY, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005489 }
5490
5491 return -1;
5492}
5493
5494void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
5495{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005496 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005497
5498 try
5499 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005500 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005501
daniel@transgaming.come0078962010-04-15 20:45:08 +00005502 if (context)
5503 {
5504 if (index >= gl::MAX_VERTEX_ATTRIBS)
5505 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005506 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005507 }
5508
daniel@transgaming.com83921382011-01-08 05:46:00 +00005509 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005510
daniel@transgaming.come0078962010-04-15 20:45:08 +00005511 switch (pname)
5512 {
5513 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
daniel@transgaming.com83921382011-01-08 05:46:00 +00005514 *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005515 break;
5516 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005517 *params = (GLfloat)attribState.mSize;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005518 break;
5519 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005520 *params = (GLfloat)attribState.mStride;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005521 break;
5522 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005523 *params = (GLfloat)attribState.mType;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005524 break;
5525 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005526 *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005527 break;
5528 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +00005529 *params = (GLfloat)attribState.mBoundBuffer.id();
daniel@transgaming.come0078962010-04-15 20:45:08 +00005530 break;
5531 case GL_CURRENT_VERTEX_ATTRIB:
5532 for (int i = 0; i < 4; ++i)
5533 {
shannon.woods%transgaming.com@gtempaccount.com3026dc72013-04-13 03:37:27 +00005534 params[i] = attribState.mCurrentValue.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00005535 }
5536 break;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00005537 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
5538 // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses
5539 // the same constant.
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005540 *params = (GLfloat)attribState.mDivisor;
5541 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005542 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005543 }
5544 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005545 }
5546 catch(std::bad_alloc&)
5547 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005548 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005549 }
5550}
5551
5552void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
5553{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005554 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005555
5556 try
5557 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005558 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005559
daniel@transgaming.come0078962010-04-15 20:45:08 +00005560 if (context)
5561 {
5562 if (index >= gl::MAX_VERTEX_ATTRIBS)
5563 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005564 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005565 }
5566
daniel@transgaming.com83921382011-01-08 05:46:00 +00005567 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005568
daniel@transgaming.come0078962010-04-15 20:45:08 +00005569 switch (pname)
5570 {
5571 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
daniel@transgaming.com83921382011-01-08 05:46:00 +00005572 *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005573 break;
5574 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005575 *params = attribState.mSize;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005576 break;
5577 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005578 *params = attribState.mStride;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005579 break;
5580 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005581 *params = attribState.mType;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005582 break;
5583 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005584 *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005585 break;
5586 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +00005587 *params = attribState.mBoundBuffer.id();
daniel@transgaming.come0078962010-04-15 20:45:08 +00005588 break;
5589 case GL_CURRENT_VERTEX_ATTRIB:
5590 for (int i = 0; i < 4; ++i)
5591 {
shannon.woods%transgaming.com@gtempaccount.com3026dc72013-04-13 03:37:27 +00005592 float currentValue = attribState.mCurrentValue.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00005593 params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f));
5594 }
5595 break;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00005596 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
5597 // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses
5598 // the same constant.
5599 META_ASSERT(GL_VERTEX_ATTRIB_ARRAY_DIVISOR == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005600 *params = (GLint)attribState.mDivisor;
5601 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005602 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005603 }
5604 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005605 }
5606 catch(std::bad_alloc&)
5607 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005608 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005609 }
5610}
5611
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005612void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005613{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005614 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005615
5616 try
5617 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005618 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005619
daniel@transgaming.come0078962010-04-15 20:45:08 +00005620 if (context)
5621 {
5622 if (index >= gl::MAX_VERTEX_ATTRIBS)
5623 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005624 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005625 }
5626
5627 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
5628 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005629 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005630 }
5631
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005632 *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index));
daniel@transgaming.come0078962010-04-15 20:45:08 +00005633 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005634 }
5635 catch(std::bad_alloc&)
5636 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005637 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005638 }
5639}
5640
5641void __stdcall glHint(GLenum target, GLenum mode)
5642{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005643 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005644
5645 try
5646 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005647 switch (mode)
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005648 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005649 case GL_FASTEST:
5650 case GL_NICEST:
5651 case GL_DONT_CARE:
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005652 break;
5653 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005654 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005655 }
5656
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005657 gl::Context *context = gl::getNonLostContext();
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005658 switch (target)
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005659 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005660 case GL_GENERATE_MIPMAP_HINT:
5661 if (context) context->setGenerateMipmapHint(mode);
5662 break;
5663 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
5664 if (context) context->setFragmentShaderDerivativeHint(mode);
5665 break;
5666 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005667 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005668 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005669 }
5670 catch(std::bad_alloc&)
5671 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005672 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005673 }
5674}
5675
5676GLboolean __stdcall glIsBuffer(GLuint buffer)
5677{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005678 EVENT("(GLuint buffer = %d)", buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005679
5680 try
5681 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005682 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005683
5684 if (context && buffer)
5685 {
5686 gl::Buffer *bufferObject = context->getBuffer(buffer);
5687
5688 if (bufferObject)
5689 {
5690 return GL_TRUE;
5691 }
5692 }
5693 }
5694 catch(std::bad_alloc&)
5695 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005696 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005697 }
5698
5699 return GL_FALSE;
5700}
5701
5702GLboolean __stdcall glIsEnabled(GLenum cap)
5703{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005704 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005705
5706 try
5707 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005708 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005709
5710 if (context)
5711 {
5712 switch (cap)
5713 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005714 case GL_CULL_FACE: return context->isCullFaceEnabled();
5715 case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled();
5716 case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled();
5717 case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled();
5718 case GL_SCISSOR_TEST: return context->isScissorTestEnabled();
5719 case GL_STENCIL_TEST: return context->isStencilTestEnabled();
5720 case GL_DEPTH_TEST: return context->isDepthTestEnabled();
5721 case GL_BLEND: return context->isBlendEnabled();
5722 case GL_DITHER: return context->isDitherEnabled();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005723 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005724 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005725 }
5726 }
5727 }
5728 catch(std::bad_alloc&)
5729 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005730 return gl::error(GL_OUT_OF_MEMORY, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005731 }
5732
5733 return false;
5734}
5735
daniel@transgaming.comfe208882010-09-01 15:47:57 +00005736GLboolean __stdcall glIsFenceNV(GLuint fence)
5737{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005738 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00005739
5740 try
5741 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005742 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00005743
5744 if (context)
5745 {
5746 gl::Fence *fenceObject = context->getFence(fence);
5747
5748 if (fenceObject == NULL)
5749 {
5750 return GL_FALSE;
5751 }
5752
5753 return fenceObject->isFence();
5754 }
5755 }
5756 catch(std::bad_alloc&)
5757 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005758 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00005759 }
5760
5761 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00005762}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00005763
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005764GLboolean __stdcall glIsFramebuffer(GLuint framebuffer)
5765{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005766 EVENT("(GLuint framebuffer = %d)", framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005767
5768 try
5769 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005770 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005771
5772 if (context && framebuffer)
5773 {
5774 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
5775
5776 if (framebufferObject)
5777 {
5778 return GL_TRUE;
5779 }
5780 }
5781 }
5782 catch(std::bad_alloc&)
5783 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005784 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005785 }
5786
5787 return GL_FALSE;
5788}
5789
5790GLboolean __stdcall glIsProgram(GLuint program)
5791{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005792 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005793
5794 try
5795 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005796 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005797
5798 if (context && program)
5799 {
5800 gl::Program *programObject = context->getProgram(program);
5801
5802 if (programObject)
5803 {
5804 return GL_TRUE;
5805 }
5806 }
5807 }
5808 catch(std::bad_alloc&)
5809 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005810 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005811 }
5812
5813 return GL_FALSE;
5814}
5815
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00005816GLboolean __stdcall glIsQueryEXT(GLuint id)
5817{
5818 EVENT("(GLuint id = %d)", id);
5819
5820 try
5821 {
5822 if (id == 0)
5823 {
5824 return GL_FALSE;
5825 }
5826
5827 gl::Context *context = gl::getNonLostContext();
5828
5829 if (context)
5830 {
5831 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
5832
5833 if (queryObject)
5834 {
5835 return GL_TRUE;
5836 }
5837 }
5838 }
5839 catch(std::bad_alloc&)
5840 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005841 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00005842 }
5843
5844 return GL_FALSE;
5845}
5846
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005847GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer)
5848{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005849 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005850
5851 try
5852 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005853 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005854
5855 if (context && renderbuffer)
5856 {
5857 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
5858
5859 if (renderbufferObject)
5860 {
5861 return GL_TRUE;
5862 }
5863 }
5864 }
5865 catch(std::bad_alloc&)
5866 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005867 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005868 }
5869
5870 return GL_FALSE;
5871}
5872
5873GLboolean __stdcall glIsShader(GLuint shader)
5874{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005875 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005876
5877 try
5878 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005879 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005880
5881 if (context && shader)
5882 {
5883 gl::Shader *shaderObject = context->getShader(shader);
5884
5885 if (shaderObject)
5886 {
5887 return GL_TRUE;
5888 }
5889 }
5890 }
5891 catch(std::bad_alloc&)
5892 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005893 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005894 }
5895
5896 return GL_FALSE;
5897}
5898
5899GLboolean __stdcall glIsTexture(GLuint texture)
5900{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005901 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005902
5903 try
5904 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005905 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005906
5907 if (context && texture)
5908 {
5909 gl::Texture *textureObject = context->getTexture(texture);
5910
5911 if (textureObject)
5912 {
5913 return GL_TRUE;
5914 }
5915 }
5916 }
5917 catch(std::bad_alloc&)
5918 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005919 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005920 }
5921
5922 return GL_FALSE;
5923}
5924
5925void __stdcall glLineWidth(GLfloat width)
5926{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005927 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005928
5929 try
5930 {
5931 if (width <= 0.0f)
5932 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005933 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005934 }
5935
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005936 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00005937
5938 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005939 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005940 context->setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005941 }
5942 }
5943 catch(std::bad_alloc&)
5944 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005945 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005946 }
5947}
5948
5949void __stdcall glLinkProgram(GLuint program)
5950{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005951 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005952
5953 try
5954 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005955 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005956
5957 if (context)
5958 {
5959 gl::Program *programObject = context->getProgram(program);
5960
5961 if (!programObject)
5962 {
daniel@transgaming.com277b7142010-04-13 03:26:44 +00005963 if (context->getShader(program))
5964 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005965 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com277b7142010-04-13 03:26:44 +00005966 }
5967 else
5968 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005969 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com277b7142010-04-13 03:26:44 +00005970 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005971 }
5972
daniel@transgaming.com95d29422012-07-24 18:36:10 +00005973 context->linkProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005974 }
5975 }
5976 catch(std::bad_alloc&)
5977 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005978 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005979 }
5980}
5981
5982void __stdcall glPixelStorei(GLenum pname, GLint param)
5983{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005984 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005985
5986 try
5987 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005988 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00005989
5990 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005991 {
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00005992 switch (pname)
5993 {
5994 case GL_UNPACK_ALIGNMENT:
5995 if (param != 1 && param != 2 && param != 4 && param != 8)
5996 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005997 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00005998 }
5999
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006000 context->setUnpackAlignment(param);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006001 break;
6002
6003 case GL_PACK_ALIGNMENT:
6004 if (param != 1 && param != 2 && param != 4 && param != 8)
6005 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006006 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006007 }
6008
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006009 context->setPackAlignment(param);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006010 break;
6011
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00006012 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
6013 context->setPackReverseRowOrder(param != 0);
6014 break;
6015
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00006016 case GL_UNPACK_IMAGE_HEIGHT:
6017 case GL_UNPACK_SKIP_IMAGES:
6018 case GL_UNPACK_ROW_LENGTH:
6019 case GL_UNPACK_SKIP_ROWS:
6020 case GL_UNPACK_SKIP_PIXELS:
6021 case GL_PACK_ROW_LENGTH:
6022 case GL_PACK_SKIP_ROWS:
6023 case GL_PACK_SKIP_PIXELS:
6024 if (context->getClientVersion() < 3)
6025 {
6026 return gl::error(GL_INVALID_ENUM);
6027 }
6028 UNIMPLEMENTED();
6029 break;
6030
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006031 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006032 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006033 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006034 }
6035 }
6036 catch(std::bad_alloc&)
6037 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006038 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006039 }
6040}
6041
6042void __stdcall glPolygonOffset(GLfloat factor, GLfloat units)
6043{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006044 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006045
6046 try
6047 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006048 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comaede6302010-04-29 03:35:48 +00006049
6050 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006051 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006052 context->setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006053 }
6054 }
6055 catch(std::bad_alloc&)
6056 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006057 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006058 }
6059}
6060
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006061void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
6062 GLenum format, GLenum type, GLsizei bufSize,
6063 GLvoid *data)
6064{
6065 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
6066 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
6067 x, y, width, height, format, type, bufSize, data);
6068
6069 try
6070 {
6071 if (width < 0 || height < 0 || bufSize < 0)
6072 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006073 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006074 }
6075
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006076 gl::Context *context = gl::getNonLostContext();
6077
6078 if (context)
6079 {
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006080 GLint currentInternalFormat;
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006081 GLenum currentFormat, currentType;
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006082
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006083 // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound,
6084 // and attempting to read back if that's the case is an error. The error will be registered
6085 // by getCurrentReadFormat.
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006086 if (!context->getCurrentReadFormatType(&currentInternalFormat, &currentFormat, &currentType))
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006087 return;
6088
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006089 bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) :
6090 validES3ReadFormatType(currentInternalFormat, format, type);
6091
6092 if (!(currentFormat == format && currentType == type) && !validReadFormat)
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006093 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006094 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006095 }
6096
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006097 context->readPixels(x, y, width, height, format, type, &bufSize, data);
6098 }
6099 }
6100 catch(std::bad_alloc&)
6101 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006102 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006103 }
6104}
6105
6106void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
6107 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006108{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006109 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006110 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00006111 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006112
6113 try
6114 {
6115 if (width < 0 || height < 0)
6116 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006117 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006118 }
6119
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006120 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006121
6122 if (context)
6123 {
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006124 GLint currentInternalFormat;
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006125 GLenum currentFormat, currentType;
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006126
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006127 // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound,
6128 // and attempting to read back if that's the case is an error. The error will be registered
6129 // by getCurrentReadFormat.
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006130 if (!context->getCurrentReadFormatType(&currentInternalFormat, &currentFormat, &currentType))
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006131 return;
6132
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006133 bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) :
6134 validES3ReadFormatType(currentInternalFormat, format, type);
6135
6136 if (!(currentFormat == format && currentType == type) && !validReadFormat)
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006137 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006138 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006139 }
6140
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006141 context->readPixels(x, y, width, height, format, type, NULL, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006142 }
6143 }
6144 catch(std::bad_alloc&)
6145 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006146 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006147 }
6148}
6149
6150void __stdcall glReleaseShaderCompiler(void)
6151{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006152 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006153
6154 try
6155 {
6156 gl::Shader::releaseCompiler();
6157 }
6158 catch(std::bad_alloc&)
6159 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006160 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006161 }
6162}
6163
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00006164void __stdcall glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006165{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006166 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00006167 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006168
6169 try
6170 {
6171 switch (target)
6172 {
6173 case GL_RENDERBUFFER:
6174 break;
6175 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006176 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006177 }
6178
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006179 if (width < 0 || height < 0 || samples < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006180 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006181 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006182 }
6183
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006184 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006185
6186 if (context)
6187 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006188 if (!gl::IsValidInternalFormat(internalformat, context))
6189 {
6190 return gl::error(GL_INVALID_ENUM);
6191 }
6192
6193 if (!gl::IsColorRenderingSupported(internalformat, context) &&
6194 !gl::IsDepthRenderingSupported(internalformat, context) &&
6195 !gl::IsStencilRenderingSupported(internalformat, context))
6196 {
6197 return gl::error(GL_INVALID_ENUM);
6198 }
6199
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006200 if (width > context->getMaximumRenderbufferDimension() ||
6201 height > context->getMaximumRenderbufferDimension() ||
6202 samples > context->getMaxSupportedSamples())
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00006203 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006204 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00006205 }
6206
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +00006207 GLuint handle = context->getRenderbufferHandle();
6208 if (handle == 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006209 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006210 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006211 }
6212
6213 switch (internalformat)
6214 {
6215 case GL_DEPTH_COMPONENT16:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006216 case GL_RGBA4:
6217 case GL_RGB5_A1:
6218 case GL_RGB565:
daniel@transgaming.com63977542010-08-24 19:21:02 +00006219 case GL_RGB8_OES:
6220 case GL_RGBA8_OES:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006221 case GL_STENCIL_INDEX8:
daniel@transgaming.comcdacc8e2010-07-28 19:20:50 +00006222 case GL_DEPTH24_STENCIL8_OES:
shannon.woods%transgaming.com@gtempaccount.com8dce6512013-04-13 03:42:19 +00006223 break;
6224 case GL_SRGB8_ALPHA8:
6225 case GL_RGB10_A2:
6226 case GL_RG8:
6227 case GL_R8:
6228 if (context->getClientVersion() < 3)
6229 {
6230 return gl::error(GL_INVALID_ENUM);
6231 }
daniel@transgaming.comcdacc8e2010-07-28 19:20:50 +00006232 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006233 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006234 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006235 }
shannon.woods%transgaming.com@gtempaccount.com8dce6512013-04-13 03:42:19 +00006236
6237 context->setRenderbufferStorage(width, height, internalformat, samples);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006238 }
6239 }
6240 catch(std::bad_alloc&)
6241 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006242 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006243 }
6244}
6245
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00006246void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
6247{
6248 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
6249}
6250
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006251void __stdcall glSampleCoverage(GLclampf value, GLboolean invert)
6252{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006253 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006254
6255 try
6256 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006257 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006258
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006259 if (context)
6260 {
daniel@transgaming.coma36f98e2010-05-18 18:51:09 +00006261 context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006262 }
6263 }
6264 catch(std::bad_alloc&)
6265 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006266 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006267 }
6268}
6269
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006270void __stdcall glSetFenceNV(GLuint fence, GLenum condition)
6271{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006272 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006273
6274 try
6275 {
6276 if (condition != GL_ALL_COMPLETED_NV)
6277 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006278 return gl::error(GL_INVALID_ENUM);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006279 }
6280
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006281 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006282
6283 if (context)
6284 {
6285 gl::Fence *fenceObject = context->getFence(fence);
6286
6287 if (fenceObject == NULL)
6288 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006289 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006290 }
6291
6292 fenceObject->setFence(condition);
6293 }
6294 }
6295 catch(std::bad_alloc&)
6296 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006297 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006298 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006299}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006300
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006301void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
6302{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006303 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006304
6305 try
6306 {
6307 if (width < 0 || height < 0)
6308 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006309 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006310 }
6311
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006312 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006313
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006314 if (context)
6315 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006316 context->setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006317 }
6318 }
6319 catch(std::bad_alloc&)
6320 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006321 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006322 }
6323}
6324
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006325void __stdcall glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006326{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006327 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006328 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00006329 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006330
6331 try
6332 {
daniel@transgaming.comd1f667f2010-04-29 03:38:52 +00006333 // No binary shader formats are supported.
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006334 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006335 }
6336 catch(std::bad_alloc&)
6337 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006338 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006339 }
6340}
6341
shannon.woods%transgaming.com@gtempaccount.com5f339332013-04-13 03:29:02 +00006342void __stdcall glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006343{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006344 EVENT("(GLuint shader = %d, GLsizei count = %d, const GLchar** string = 0x%0.8p, const GLint* length = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00006345 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006346
6347 try
6348 {
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006349 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006350 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006351 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006352 }
6353
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006354 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006355
6356 if (context)
6357 {
6358 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006359
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006360 if (!shaderObject)
6361 {
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006362 if (context->getProgram(shader))
6363 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006364 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006365 }
6366 else
6367 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006368 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006369 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006370 }
6371
6372 shaderObject->setSource(count, string, length);
6373 }
6374 }
6375 catch(std::bad_alloc&)
6376 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006377 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006378 }
6379}
6380
6381void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask)
6382{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006383 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006384}
6385
6386void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
6387{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006388 EVENT("(GLenum face = 0x%X, GLenum func = 0x%X, GLint ref = %d, GLuint mask = %d)", face, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006389
6390 try
6391 {
6392 switch (face)
6393 {
6394 case GL_FRONT:
6395 case GL_BACK:
6396 case GL_FRONT_AND_BACK:
6397 break;
6398 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006399 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006400 }
6401
6402 switch (func)
6403 {
6404 case GL_NEVER:
6405 case GL_ALWAYS:
6406 case GL_LESS:
6407 case GL_LEQUAL:
6408 case GL_EQUAL:
6409 case GL_GEQUAL:
6410 case GL_GREATER:
6411 case GL_NOTEQUAL:
6412 break;
6413 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006414 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006415 }
6416
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006417 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006418
6419 if (context)
6420 {
6421 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
6422 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006423 context->setStencilParams(func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006424 }
6425
6426 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
6427 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006428 context->setStencilBackParams(func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006429 }
6430 }
6431 }
6432 catch(std::bad_alloc&)
6433 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006434 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006435 }
6436}
6437
6438void __stdcall glStencilMask(GLuint mask)
6439{
6440 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
6441}
6442
6443void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask)
6444{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006445 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006446
6447 try
6448 {
6449 switch (face)
6450 {
6451 case GL_FRONT:
6452 case GL_BACK:
6453 case GL_FRONT_AND_BACK:
6454 break;
6455 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006456 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006457 }
6458
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006459 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006460
6461 if (context)
6462 {
6463 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
6464 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006465 context->setStencilWritemask(mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006466 }
6467
6468 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
6469 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006470 context->setStencilBackWritemask(mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006471 }
6472 }
6473 }
6474 catch(std::bad_alloc&)
6475 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006476 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006477 }
6478}
6479
6480void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
6481{
6482 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
6483}
6484
6485void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
6486{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006487 EVENT("(GLenum face = 0x%X, GLenum fail = 0x%X, GLenum zfail = 0x%X, GLenum zpas = 0x%Xs)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00006488 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006489
6490 try
6491 {
6492 switch (face)
6493 {
6494 case GL_FRONT:
6495 case GL_BACK:
6496 case GL_FRONT_AND_BACK:
6497 break;
6498 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006499 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006500 }
6501
6502 switch (fail)
6503 {
6504 case GL_ZERO:
6505 case GL_KEEP:
6506 case GL_REPLACE:
6507 case GL_INCR:
6508 case GL_DECR:
6509 case GL_INVERT:
6510 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006511 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006512 break;
6513 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006514 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006515 }
6516
6517 switch (zfail)
6518 {
6519 case GL_ZERO:
6520 case GL_KEEP:
6521 case GL_REPLACE:
6522 case GL_INCR:
6523 case GL_DECR:
6524 case GL_INVERT:
6525 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006526 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006527 break;
6528 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006529 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006530 }
6531
6532 switch (zpass)
6533 {
6534 case GL_ZERO:
6535 case GL_KEEP:
6536 case GL_REPLACE:
6537 case GL_INCR:
6538 case GL_DECR:
6539 case GL_INVERT:
6540 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006541 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006542 break;
6543 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006544 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006545 }
6546
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006547 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006548
6549 if (context)
6550 {
6551 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
6552 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006553 context->setStencilOperations(fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006554 }
6555
6556 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
6557 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006558 context->setStencilBackOperations(fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006559 }
6560 }
6561 }
6562 catch(std::bad_alloc&)
6563 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006564 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006565 }
6566}
6567
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006568GLboolean __stdcall glTestFenceNV(GLuint fence)
6569{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006570 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006571
6572 try
6573 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006574 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006575
6576 if (context)
6577 {
6578 gl::Fence *fenceObject = context->getFence(fence);
6579
6580 if (fenceObject == NULL)
6581 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006582 return gl::error(GL_INVALID_OPERATION, GL_TRUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006583 }
6584
6585 return fenceObject->testFence();
6586 }
6587 }
6588 catch(std::bad_alloc&)
6589 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006590 gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006591 }
6592
6593 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006594}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006595
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006596void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
6597 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006598{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006599 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006600 "GLint border = %d, GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00006601 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006602
6603 try
6604 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006605 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006606
6607 if (context)
6608 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006609 if (context->getClientVersion() < 3 &&
6610 !validateES2TexImageParameters(context, target, level, internalformat, false, false,
6611 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com32b11442011-11-19 02:42:48 +00006612 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006613 return;
6614 }
6615
6616 if (context->getClientVersion() >= 3 &&
6617 !validateES3TexImageParameters(context, target, level, internalformat, false, false,
6618 0, 0, 0, width, height, 1, border, format, type))
6619 {
6620 return;
daniel@transgaming.com32b11442011-11-19 02:42:48 +00006621 }
6622
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006623 switch (target)
6624 {
6625 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006626 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006627 gl::Texture2D *texture = context->getTexture2D();
6628 texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006629 }
6630 break;
6631 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006632 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006633 gl::TextureCubeMap *texture = context->getTextureCubeMap();
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +00006634 texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006635 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006636 break;
6637 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
6638 {
6639 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6640 texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6641 }
6642 break;
6643 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
6644 {
6645 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6646 texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6647 }
6648 break;
6649 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
6650 {
6651 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6652 texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6653 }
6654 break;
6655 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
6656 {
6657 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6658 texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6659 }
6660 break;
6661 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
6662 {
6663 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6664 texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6665 }
6666 break;
6667 default: UNREACHABLE();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006668 }
6669 }
6670 }
6671 catch(std::bad_alloc&)
6672 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006673 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006674 }
6675}
6676
6677void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param)
6678{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006679 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
6680
6681 try
6682 {
6683 gl::Context *context = gl::getNonLostContext();
6684
6685 if (context)
6686 {
6687 gl::Texture *texture;
6688
6689 switch (target)
6690 {
6691 case GL_TEXTURE_2D:
6692 texture = context->getTexture2D();
6693 break;
6694 case GL_TEXTURE_CUBE_MAP:
6695 texture = context->getTextureCubeMap();
6696 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00006697 case GL_TEXTURE_3D:
6698 if (context->getClientVersion() < 3)
6699 {
6700 return gl::error(GL_INVALID_ENUM);
6701 }
6702 texture = context->getTexture3D();
shannon.woods%transgaming.com@gtempaccount.com90dbc442013-04-13 03:46:14 +00006703 case GL_TEXTURE_2D_ARRAY:
6704 if (context->getClientVersion() < 3)
6705 {
6706 return gl::error(GL_INVALID_ENUM);
6707 }
6708 texture = context->getTexture2DArray();
6709 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006710 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006711 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006712 }
6713
6714 switch (pname)
6715 {
6716 case GL_TEXTURE_WRAP_S:
6717 if (!texture->setWrapS((GLenum)param))
6718 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006719 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006720 }
6721 break;
6722 case GL_TEXTURE_WRAP_T:
6723 if (!texture->setWrapT((GLenum)param))
6724 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006725 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006726 }
6727 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00006728 case GL_TEXTURE_WRAP_R:
6729 if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param))
6730 {
6731 return gl::error(GL_INVALID_ENUM);
6732 }
6733 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006734 case GL_TEXTURE_MIN_FILTER:
6735 if (!texture->setMinFilter((GLenum)param))
6736 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006737 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006738 }
6739 break;
6740 case GL_TEXTURE_MAG_FILTER:
6741 if (!texture->setMagFilter((GLenum)param))
6742 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006743 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006744 }
6745 break;
6746 case GL_TEXTURE_USAGE_ANGLE:
6747 if (!texture->setUsage((GLenum)param))
6748 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006749 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006750 }
6751 break;
6752 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
6753 if (!context->supportsTextureFilterAnisotropy())
6754 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006755 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006756 }
6757 if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()))
6758 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006759 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006760 }
6761 break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00006762
6763 case GL_TEXTURE_MIN_LOD:
6764 case GL_TEXTURE_MAX_LOD:
6765 if (context->getClientVersion() < 3)
6766 {
6767 return gl::error(GL_INVALID_ENUM);
6768 }
6769 UNIMPLEMENTED();
6770 break;
6771
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006772 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006773 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006774 }
6775 }
6776 }
6777 catch(std::bad_alloc&)
6778 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006779 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006780 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006781}
6782
6783void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
6784{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006785 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006786}
6787
6788void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param)
6789{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006790 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006791
6792 try
6793 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006794 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006795
6796 if (context)
6797 {
6798 gl::Texture *texture;
6799
6800 switch (target)
6801 {
6802 case GL_TEXTURE_2D:
6803 texture = context->getTexture2D();
6804 break;
6805 case GL_TEXTURE_CUBE_MAP:
6806 texture = context->getTextureCubeMap();
6807 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00006808 case GL_TEXTURE_3D:
6809 if (context->getClientVersion() < 3)
6810 {
6811 return gl::error(GL_INVALID_ENUM);
6812 }
6813 texture = context->getTexture3D();
6814 break;
shannon.woods%transgaming.com@gtempaccount.com90dbc442013-04-13 03:46:14 +00006815 case GL_TEXTURE_2D_ARRAY:
6816 if (context->getClientVersion() < 3)
6817 {
6818 return gl::error(GL_INVALID_ENUM);
6819 }
6820 texture = context->getTexture2DArray();
6821 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006822 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006823 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006824 }
6825
6826 switch (pname)
6827 {
6828 case GL_TEXTURE_WRAP_S:
6829 if (!texture->setWrapS((GLenum)param))
6830 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006831 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006832 }
6833 break;
6834 case GL_TEXTURE_WRAP_T:
6835 if (!texture->setWrapT((GLenum)param))
6836 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006837 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006838 }
6839 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00006840 case GL_TEXTURE_WRAP_R:
6841 if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param))
6842 {
6843 return gl::error(GL_INVALID_ENUM);
6844 }
6845 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006846 case GL_TEXTURE_MIN_FILTER:
6847 if (!texture->setMinFilter((GLenum)param))
6848 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006849 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006850 }
6851 break;
6852 case GL_TEXTURE_MAG_FILTER:
6853 if (!texture->setMagFilter((GLenum)param))
6854 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006855 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006856 }
6857 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00006858 case GL_TEXTURE_USAGE_ANGLE:
6859 if (!texture->setUsage((GLenum)param))
6860 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006861 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00006862 }
6863 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006864 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
6865 if (!context->supportsTextureFilterAnisotropy())
6866 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006867 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006868 }
6869 if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()))
6870 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006871 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006872 }
6873 break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00006874
6875 case GL_TEXTURE_SWIZZLE_R:
6876 case GL_TEXTURE_SWIZZLE_G:
6877 case GL_TEXTURE_SWIZZLE_B:
6878 case GL_TEXTURE_SWIZZLE_A:
6879 case GL_TEXTURE_BASE_LEVEL:
6880 case GL_TEXTURE_MAX_LEVEL:
6881 case GL_TEXTURE_COMPARE_MODE:
6882 case GL_TEXTURE_COMPARE_FUNC:
6883 if (context->getClientVersion() < 3)
6884 {
6885 return gl::error(GL_INVALID_ENUM);
6886 }
6887 UNIMPLEMENTED();
6888 break;
6889
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006890 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006891 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006892 }
6893 }
6894 }
6895 catch(std::bad_alloc&)
6896 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006897 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006898 }
6899}
6900
6901void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
6902{
6903 glTexParameteri(target, pname, *params);
6904}
6905
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00006906void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
6907{
6908 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
6909 target, levels, internalformat, width, height);
6910
6911 try
6912 {
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00006913 gl::Context *context = gl::getNonLostContext();
6914
6915 if (context)
6916 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006917 if (context->getClientVersion() < 3 &&
6918 !validateES2TexStorageParameters(context, target, levels, internalformat, width, height))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006919 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006920 return;
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006921 }
6922
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006923 if (context->getClientVersion() >= 3 &&
6924 !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006925 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006926 return;
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006927 }
6928
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006929 switch (target)
6930 {
6931 case GL_TEXTURE_2D:
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006932 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006933 gl::Texture2D *texture2d = context->getTexture2D();
6934 texture2d->storage(levels, internalformat, width, height);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006935 }
6936 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006937
6938 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
6939 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
6940 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
6941 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
6942 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
6943 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006944 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006945 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
6946 textureCube->storage(levels, internalformat, width);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006947 }
6948 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006949
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006950 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006951 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006952 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00006953 }
6954 }
6955 catch(std::bad_alloc&)
6956 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006957 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00006958 }
6959}
6960
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006961void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
6962 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006963{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006964 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00006965 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006966 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006967 target, level, xoffset, yoffset, width, height, format, type, pixels);
6968
6969 try
6970 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006971 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com00c75962010-03-11 20:36:15 +00006972
6973 if (context)
6974 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006975 if (context->getClientVersion() < 3 &&
6976 !validateES2TexImageParameters(context, target, level, GL_NONE, false, true,
6977 0, 0, width, height, 0, format, type, pixels))
daniel@transgaming.com1d2d3c42012-05-31 01:14:15 +00006978 {
6979 return;
6980 }
6981
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006982 if (context->getClientVersion() >= 3 &&
6983 !validateES3TexImageParameters(context, target, level, GL_NONE, false, true,
6984 0, 0, 0, width, height, 1, 0, format, type))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00006985 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006986 return;
6987 }
6988
6989 switch (target)
6990 {
6991 case GL_TEXTURE_2D:
daniel@transgaming.com00c75962010-03-11 20:36:15 +00006992 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006993 gl::Texture2D *texture = context->getTexture2D();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00006994 texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00006995 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006996 break;
6997
6998 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
6999 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
7000 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
7001 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
7002 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
7003 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007004 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007005 gl::TextureCubeMap *texture = context->getTextureCubeMap();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00007006 texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007007 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007008 break;
7009
7010 default:
7011 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007012 }
7013 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007014 }
7015 catch(std::bad_alloc&)
7016 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007017 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007018 }
7019}
7020
7021void __stdcall glUniform1f(GLint location, GLfloat x)
7022{
7023 glUniform1fv(location, 1, &x);
7024}
7025
7026void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
7027{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007028 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007029
7030 try
7031 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007032 if (count < 0)
7033 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007034 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007035 }
7036
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007037 if (location == -1)
7038 {
7039 return;
7040 }
7041
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007042 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007043
7044 if (context)
7045 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007046 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007047 if (!programBinary)
7048 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007049 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007050 }
7051
7052 if (!programBinary->setUniform1fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007053 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007054 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007055 }
7056 }
7057 }
7058 catch(std::bad_alloc&)
7059 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007060 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007061 }
7062}
7063
7064void __stdcall glUniform1i(GLint location, GLint x)
7065{
7066 glUniform1iv(location, 1, &x);
7067}
7068
7069void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v)
7070{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007071 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007072
7073 try
7074 {
7075 if (count < 0)
7076 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007077 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007078 }
7079
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007080 if (location == -1)
7081 {
7082 return;
7083 }
7084
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007085 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007086
7087 if (context)
7088 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007089 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007090 if (!programBinary)
7091 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007092 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007093 }
7094
7095 if (!programBinary->setUniform1iv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007096 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007097 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007098 }
7099 }
7100 }
7101 catch(std::bad_alloc&)
7102 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007103 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007104 }
7105}
7106
7107void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y)
7108{
7109 GLfloat xy[2] = {x, y};
7110
7111 glUniform2fv(location, 1, (GLfloat*)&xy);
7112}
7113
7114void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
7115{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007116 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007117
7118 try
7119 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007120 if (count < 0)
7121 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007122 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007123 }
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007124
7125 if (location == -1)
7126 {
7127 return;
7128 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007129
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007130 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007131
7132 if (context)
7133 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007134 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007135 if (!programBinary)
7136 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007137 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007138 }
7139
7140 if (!programBinary->setUniform2fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007141 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007142 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007143 }
7144 }
7145 }
7146 catch(std::bad_alloc&)
7147 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007148 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007149 }
7150}
7151
7152void __stdcall glUniform2i(GLint location, GLint x, GLint y)
7153{
7154 GLint xy[4] = {x, y};
7155
7156 glUniform2iv(location, 1, (GLint*)&xy);
7157}
7158
7159void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v)
7160{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007161 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007162
7163 try
7164 {
7165 if (count < 0)
7166 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007167 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007168 }
7169
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007170 if (location == -1)
7171 {
7172 return;
7173 }
7174
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007175 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007176
7177 if (context)
7178 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007179 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007180 if (!programBinary)
7181 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007182 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007183 }
7184
7185 if (!programBinary->setUniform2iv(location, count, v))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007186 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007187 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007188 }
7189 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007190 }
7191 catch(std::bad_alloc&)
7192 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007193 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007194 }
7195}
7196
7197void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
7198{
7199 GLfloat xyz[3] = {x, y, z};
7200
7201 glUniform3fv(location, 1, (GLfloat*)&xyz);
7202}
7203
7204void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
7205{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007206 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007207
7208 try
7209 {
7210 if (count < 0)
7211 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007212 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007213 }
7214
7215 if (location == -1)
7216 {
7217 return;
7218 }
7219
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007220 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007221
7222 if (context)
7223 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007224 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007225 if (!programBinary)
7226 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007227 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007228 }
7229
7230 if (!programBinary->setUniform3fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007231 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007232 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007233 }
7234 }
7235 }
7236 catch(std::bad_alloc&)
7237 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007238 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007239 }
7240}
7241
7242void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z)
7243{
7244 GLint xyz[3] = {x, y, z};
7245
7246 glUniform3iv(location, 1, (GLint*)&xyz);
7247}
7248
7249void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v)
7250{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007251 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007252
7253 try
7254 {
7255 if (count < 0)
7256 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007257 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007258 }
7259
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007260 if (location == -1)
7261 {
7262 return;
7263 }
7264
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007265 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007266
7267 if (context)
7268 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007269 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007270 if (!programBinary)
7271 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007272 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007273 }
7274
7275 if (!programBinary->setUniform3iv(location, count, v))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007276 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007277 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007278 }
7279 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007280 }
7281 catch(std::bad_alloc&)
7282 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007283 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007284 }
7285}
7286
7287void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
7288{
7289 GLfloat xyzw[4] = {x, y, z, w};
7290
7291 glUniform4fv(location, 1, (GLfloat*)&xyzw);
7292}
7293
7294void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
7295{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007296 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007297
7298 try
7299 {
7300 if (count < 0)
7301 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007302 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007303 }
7304
7305 if (location == -1)
7306 {
7307 return;
7308 }
7309
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007310 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007311
7312 if (context)
7313 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007314 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007315 if (!programBinary)
7316 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007317 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007318 }
7319
7320 if (!programBinary->setUniform4fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007321 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007322 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007323 }
7324 }
7325 }
7326 catch(std::bad_alloc&)
7327 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007328 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007329 }
7330}
7331
7332void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
7333{
7334 GLint xyzw[4] = {x, y, z, w};
7335
7336 glUniform4iv(location, 1, (GLint*)&xyzw);
7337}
7338
7339void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v)
7340{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007341 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007342
7343 try
7344 {
7345 if (count < 0)
7346 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007347 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007348 }
7349
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007350 if (location == -1)
7351 {
7352 return;
7353 }
7354
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007355 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007356
7357 if (context)
7358 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007359 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007360 if (!programBinary)
7361 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007362 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007363 }
7364
7365 if (!programBinary->setUniform4iv(location, count, v))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007366 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007367 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007368 }
7369 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007370 }
7371 catch(std::bad_alloc&)
7372 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007373 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007374 }
7375}
7376
7377void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
7378{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007379 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007380 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007381
7382 try
7383 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007384 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007385 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007386 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007387 }
7388
7389 if (location == -1)
7390 {
7391 return;
7392 }
7393
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007394 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007395
7396 if (context)
7397 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007398 if (transpose != GL_FALSE && context->getClientVersion() < 3)
7399 {
7400 return gl::error(GL_INVALID_VALUE);
7401 }
7402
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007403 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007404 if (!programBinary)
7405 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007406 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007407 }
7408
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007409 if (!programBinary->setUniformMatrix2fv(location, count, transpose, value))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007410 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007411 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007412 }
7413 }
7414 }
7415 catch(std::bad_alloc&)
7416 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007417 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007418 }
7419}
7420
7421void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
7422{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007423 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007424 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007425
7426 try
7427 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007428 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007429 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007430 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007431 }
7432
7433 if (location == -1)
7434 {
7435 return;
7436 }
7437
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007438 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007439
7440 if (context)
7441 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007442 if (transpose != GL_FALSE && context->getClientVersion() < 3)
7443 {
7444 return gl::error(GL_INVALID_VALUE);
7445 }
7446
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007447 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007448 if (!programBinary)
7449 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007450 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007451 }
7452
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007453 if (!programBinary->setUniformMatrix3fv(location, count, transpose, value))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007454 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007455 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007456 }
7457 }
7458 }
7459 catch(std::bad_alloc&)
7460 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007461 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007462 }
7463}
7464
7465void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
7466{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007467 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007468 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007469
7470 try
7471 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007472 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007473 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007474 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007475 }
7476
7477 if (location == -1)
7478 {
7479 return;
7480 }
7481
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007482 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007483
7484 if (context)
7485 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007486 if (transpose != GL_FALSE && context->getClientVersion() < 3)
7487 {
7488 return gl::error(GL_INVALID_VALUE);
7489 }
7490
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007491 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007492 if (!programBinary)
7493 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007494 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007495 }
7496
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007497 if (!programBinary->setUniformMatrix4fv(location, count, transpose, value))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007498 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007499 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007500 }
7501 }
7502 }
7503 catch(std::bad_alloc&)
7504 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007505 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007506 }
7507}
7508
7509void __stdcall glUseProgram(GLuint program)
7510{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007511 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007512
7513 try
7514 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007515 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007516
7517 if (context)
7518 {
7519 gl::Program *programObject = context->getProgram(program);
7520
daniel@transgaming.comc8478202010-04-13 19:53:35 +00007521 if (!programObject && program != 0)
7522 {
7523 if (context->getShader(program))
7524 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007525 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comc8478202010-04-13 19:53:35 +00007526 }
7527 else
7528 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007529 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comc8478202010-04-13 19:53:35 +00007530 }
7531 }
7532
daniel@transgaming.com716056c2012-07-24 18:38:59 +00007533 if (program != 0 && !programObject->isLinked())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007534 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007535 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007536 }
7537
7538 context->useProgram(program);
7539 }
7540 }
7541 catch(std::bad_alloc&)
7542 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007543 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007544 }
7545}
7546
7547void __stdcall glValidateProgram(GLuint program)
7548{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007549 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007550
7551 try
7552 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007553 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007554
7555 if (context)
7556 {
7557 gl::Program *programObject = context->getProgram(program);
7558
7559 if (!programObject)
7560 {
7561 if (context->getShader(program))
7562 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007563 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007564 }
7565 else
7566 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007567 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007568 }
7569 }
7570
apatrick@chromium.org253b8d22012-06-22 19:27:21 +00007571 programObject->validate();
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007572 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007573 }
7574 catch(std::bad_alloc&)
7575 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007576 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007577 }
7578}
7579
7580void __stdcall glVertexAttrib1f(GLuint index, GLfloat x)
7581{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007582 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007583
7584 try
7585 {
7586 if (index >= gl::MAX_VERTEX_ATTRIBS)
7587 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007588 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007589 }
7590
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007591 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007592
7593 if (context)
7594 {
7595 GLfloat vals[4] = { x, 0, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007596 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007597 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007598 }
7599 catch(std::bad_alloc&)
7600 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007601 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007602 }
7603}
7604
7605void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values)
7606{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007607 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007608
7609 try
7610 {
7611 if (index >= gl::MAX_VERTEX_ATTRIBS)
7612 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007613 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007614 }
7615
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007616 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007617
7618 if (context)
7619 {
7620 GLfloat vals[4] = { values[0], 0, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007621 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007622 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007623 }
7624 catch(std::bad_alloc&)
7625 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007626 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007627 }
7628}
7629
7630void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
7631{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007632 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007633
7634 try
7635 {
7636 if (index >= gl::MAX_VERTEX_ATTRIBS)
7637 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007638 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007639 }
7640
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007641 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007642
7643 if (context)
7644 {
7645 GLfloat vals[4] = { x, y, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007646 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007647 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007648 }
7649 catch(std::bad_alloc&)
7650 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007651 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007652 }
7653}
7654
7655void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values)
7656{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007657 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007658
7659 try
7660 {
7661 if (index >= gl::MAX_VERTEX_ATTRIBS)
7662 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007663 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007664 }
7665
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007666 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007667
7668 if (context)
7669 {
7670 GLfloat vals[4] = { values[0], values[1], 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007671 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007672 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007673 }
7674 catch(std::bad_alloc&)
7675 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007676 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007677 }
7678}
7679
7680void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
7681{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007682 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", index, x, y, z);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007683
7684 try
7685 {
7686 if (index >= gl::MAX_VERTEX_ATTRIBS)
7687 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007688 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007689 }
7690
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007691 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007692
7693 if (context)
7694 {
7695 GLfloat vals[4] = { x, y, z, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007696 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007697 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007698 }
7699 catch(std::bad_alloc&)
7700 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007701 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007702 }
7703}
7704
7705void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values)
7706{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007707 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007708
7709 try
7710 {
7711 if (index >= gl::MAX_VERTEX_ATTRIBS)
7712 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007713 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007714 }
7715
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007716 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007717
7718 if (context)
7719 {
7720 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007721 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007722 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007723 }
7724 catch(std::bad_alloc&)
7725 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007726 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007727 }
7728}
7729
7730void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
7731{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007732 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f, GLfloat w = %f)", index, x, y, z, w);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007733
7734 try
7735 {
7736 if (index >= gl::MAX_VERTEX_ATTRIBS)
7737 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007738 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007739 }
7740
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007741 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007742
7743 if (context)
7744 {
7745 GLfloat vals[4] = { x, y, z, w };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007746 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007747 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007748 }
7749 catch(std::bad_alloc&)
7750 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007751 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007752 }
7753}
7754
7755void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values)
7756{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007757 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007758
7759 try
7760 {
7761 if (index >= gl::MAX_VERTEX_ATTRIBS)
7762 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007763 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007764 }
7765
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007766 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007767
7768 if (context)
7769 {
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007770 context->setVertexAttribf(index, values);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007771 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007772 }
7773 catch(std::bad_alloc&)
7774 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007775 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007776 }
7777}
7778
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00007779void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
7780{
7781 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
7782
7783 try
7784 {
7785 if (index >= gl::MAX_VERTEX_ATTRIBS)
7786 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007787 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00007788 }
7789
7790 gl::Context *context = gl::getNonLostContext();
7791
7792 if (context)
7793 {
7794 context->setVertexAttribDivisor(index, divisor);
7795 }
7796 }
7797 catch(std::bad_alloc&)
7798 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007799 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00007800 }
7801}
7802
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00007803void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007804{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007805 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007806 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007807 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007808
7809 try
7810 {
7811 if (index >= gl::MAX_VERTEX_ATTRIBS)
7812 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007813 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007814 }
7815
7816 if (size < 1 || size > 4)
7817 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007818 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007819 }
7820
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00007821 gl::Context *context = gl::getNonLostContext();
7822
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007823 switch (type)
7824 {
7825 case GL_BYTE:
7826 case GL_UNSIGNED_BYTE:
7827 case GL_SHORT:
7828 case GL_UNSIGNED_SHORT:
7829 case GL_FIXED:
7830 case GL_FLOAT:
7831 break;
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00007832 case GL_HALF_FLOAT:
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007833 case GL_INT:
7834 case GL_UNSIGNED_INT:
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00007835 case GL_INT_2_10_10_10_REV:
7836 case GL_UNSIGNED_INT_2_10_10_10_REV:
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00007837 if (context && context->getClientVersion() < 3)
7838 {
7839 return gl::error(GL_INVALID_ENUM);
7840 }
7841 else
7842 {
7843 break;
7844 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007845 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007846 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007847 }
7848
7849 if (stride < 0)
7850 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007851 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007852 }
7853
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00007854 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
7855 {
7856 return gl::error(GL_INVALID_OPERATION);
7857 }
7858
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007859 if (context)
7860 {
shannon.woods%transgaming.com@gtempaccount.com8de4e6a2013-04-13 03:37:44 +00007861 context->setVertexAttribState(index, context->getArrayBuffer(), size, type,
7862 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007863 }
7864 }
7865 catch(std::bad_alloc&)
7866 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007867 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007868 }
7869}
7870
7871void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
7872{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007873 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007874
7875 try
7876 {
7877 if (width < 0 || height < 0)
7878 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007879 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007880 }
7881
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007882 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007883
7884 if (context)
7885 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00007886 context->setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007887 }
7888 }
7889 catch(std::bad_alloc&)
7890 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007891 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007892 }
7893}
7894
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007895// OpenGL ES 3.0 functions
7896
7897void __stdcall glReadBuffer(GLenum mode)
7898{
7899 EVENT("(GLenum mode = 0x%X)", mode);
7900
7901 try
7902 {
7903 gl::Context *context = gl::getNonLostContext();
7904
7905 if (context)
7906 {
7907 if (context->getClientVersion() < 3)
7908 {
7909 return gl::error(GL_INVALID_OPERATION);
7910 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007911
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007912 UNIMPLEMENTED();
7913 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007914 }
7915 catch(std::bad_alloc&)
7916 {
7917 return gl::error(GL_OUT_OF_MEMORY);
7918 }
7919}
7920
7921void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
7922{
7923 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
7924 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
7925
7926 try
7927 {
7928 gl::Context *context = gl::getNonLostContext();
7929
7930 if (context)
7931 {
7932 if (context->getClientVersion() < 3)
7933 {
7934 return gl::error(GL_INVALID_OPERATION);
7935 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007936
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007937 UNIMPLEMENTED();
7938 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007939 }
7940 catch(std::bad_alloc&)
7941 {
7942 return gl::error(GL_OUT_OF_MEMORY);
7943 }
7944}
7945
7946void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
7947{
7948 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
7949 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
7950 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
7951 target, level, internalformat, width, height, depth, border, format, type, pixels);
7952
7953 try
7954 {
7955 gl::Context *context = gl::getNonLostContext();
7956
7957 if (context)
7958 {
7959 if (context->getClientVersion() < 3)
7960 {
7961 return gl::error(GL_INVALID_OPERATION);
7962 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007963
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00007964 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00007965 if (!validateES3TexImageParameters(context, target, level, internalformat, false, false,
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00007966 0, 0, 0, width, height, depth, border, format, type))
7967 {
7968 return;
7969 }
7970
7971 switch(target)
7972 {
7973 case GL_TEXTURE_3D:
7974 {
7975 gl::Texture3D *texture = context->getTexture3D();
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +00007976 texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackAlignment(), pixels);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00007977 }
7978 break;
7979
7980 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00007981 {
7982 gl::Texture2DArray *texture = context->getTexture2DArray();
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +00007983 texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackAlignment(), pixels);
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00007984 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00007985 break;
7986
7987 default:
7988 return gl::error(GL_INVALID_ENUM);
7989 }
7990 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007991 }
7992 catch(std::bad_alloc&)
7993 {
7994 return gl::error(GL_OUT_OF_MEMORY);
7995 }
7996}
7997
7998void __stdcall glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
7999{
8000 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
8001 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
8002 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
8003 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
8004
8005 try
8006 {
8007 gl::Context *context = gl::getNonLostContext();
8008
8009 if (context)
8010 {
8011 if (context->getClientVersion() < 3)
8012 {
8013 return gl::error(GL_INVALID_OPERATION);
8014 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008015
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008016 if (!pixels)
8017 {
8018 return gl::error(GL_INVALID_VALUE);
8019 }
8020
8021 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008022 if (!validateES3TexImageParameters(context, target, level, GL_NONE, false, true,
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008023 xoffset, yoffset, zoffset, width, height, depth, 0,
8024 format, type))
8025 {
8026 return;
8027 }
8028
8029 switch(target)
8030 {
8031 case GL_TEXTURE_3D:
8032 {
8033 gl::Texture3D *texture = context->getTexture3D();
8034 texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels);
8035 }
8036 break;
8037
8038 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008039 {
8040 gl::Texture2DArray *texture = context->getTexture2DArray();
8041 texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels);
8042 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008043 break;
8044
8045 default:
8046 return gl::error(GL_INVALID_ENUM);
8047 }
8048 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008049 }
8050 catch(std::bad_alloc&)
8051 {
8052 return gl::error(GL_OUT_OF_MEMORY);
8053 }
8054}
8055
8056void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
8057{
8058 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
8059 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
8060 target, level, xoffset, yoffset, zoffset, x, y, width, height);
8061
8062 try
8063 {
8064 gl::Context *context = gl::getNonLostContext();
8065
8066 if (context)
8067 {
8068 if (context->getClientVersion() < 3)
8069 {
8070 return gl::error(GL_INVALID_OPERATION);
8071 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008072
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008073 if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset,
8074 x, y, width, height, 0))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008075 {
8076 return;
8077 }
8078
8079 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
8080 gl::Texture *texture = NULL;
8081 switch (target)
8082 {
8083 case GL_TEXTURE_3D:
8084 texture = context->getTexture3D();
8085 break;
8086
8087 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008088 texture = context->getTexture2DArray();
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008089 break;
8090
8091 default:
8092 return gl::error(GL_INVALID_ENUM);
8093 }
8094
8095 texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
8096 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008097 }
8098 catch(std::bad_alloc&)
8099 {
8100 return gl::error(GL_OUT_OF_MEMORY);
8101 }
8102}
8103
8104void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
8105{
8106 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
8107 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
8108 "const GLvoid* data = 0x%0.8p)",
8109 target, level, internalformat, width, height, depth, border, imageSize, data);
8110
8111 try
8112 {
8113 gl::Context *context = gl::getNonLostContext();
8114
8115 if (context)
8116 {
8117 if (context->getClientVersion() < 3)
8118 {
8119 return gl::error(GL_INVALID_OPERATION);
8120 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008121
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00008122 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008123 {
8124 return gl::error(GL_INVALID_VALUE);
8125 }
8126
8127 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008128 if (!validateES3TexImageParameters(context, target, level, internalformat, true, false,
8129 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008130 {
8131 return;
8132 }
8133
8134 switch(target)
8135 {
8136 case GL_TEXTURE_3D:
8137 {
8138 gl::Texture3D *texture = context->getTexture3D();
8139 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
8140 }
8141 break;
8142
8143 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008144 {
8145 gl::Texture2DArray *texture = context->getTexture2DArray();
8146 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
8147 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008148 break;
8149
8150 default:
8151 return gl::error(GL_INVALID_ENUM);
8152 }
8153 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008154 }
8155 catch(std::bad_alloc&)
8156 {
8157 return gl::error(GL_OUT_OF_MEMORY);
8158 }
8159}
8160
8161void __stdcall glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
8162{
8163 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
8164 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
8165 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
8166 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
8167
8168 try
8169 {
8170 gl::Context *context = gl::getNonLostContext();
8171
8172 if (context)
8173 {
8174 if (context->getClientVersion() < 3)
8175 {
8176 return gl::error(GL_INVALID_OPERATION);
8177 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008178
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00008179 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008180 {
8181 return gl::error(GL_INVALID_VALUE);
8182 }
8183
8184 if (!data)
8185 {
8186 return gl::error(GL_INVALID_VALUE);
8187 }
8188
8189 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008190 if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true,
8191 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008192 {
8193 return;
8194 }
8195
8196 switch(target)
8197 {
8198 case GL_TEXTURE_3D:
8199 {
8200 gl::Texture3D *texture = context->getTexture3D();
8201 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
8202 format, imageSize, data);
8203 }
8204 break;
8205
8206 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008207 {
8208 gl::Texture2DArray *texture = context->getTexture2DArray();
8209 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
8210 format, imageSize, data);
8211 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008212 break;
8213
8214 default:
8215 return gl::error(GL_INVALID_ENUM);
8216 }
8217 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008218 }
8219 catch(std::bad_alloc&)
8220 {
8221 return gl::error(GL_OUT_OF_MEMORY);
8222 }
8223}
8224
8225void __stdcall glGenQueries(GLsizei n, GLuint* ids)
8226{
8227 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8228
8229 try
8230 {
8231 gl::Context *context = gl::getNonLostContext();
8232
8233 if (context)
8234 {
8235 if (context->getClientVersion() < 3)
8236 {
8237 return gl::error(GL_INVALID_OPERATION);
8238 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008239
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008240 UNIMPLEMENTED();
8241 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008242 }
8243 catch(std::bad_alloc&)
8244 {
8245 return gl::error(GL_OUT_OF_MEMORY);
8246 }
8247}
8248
8249void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids)
8250{
8251 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8252
8253 try
8254 {
8255 gl::Context *context = gl::getNonLostContext();
8256
8257 if (context)
8258 {
8259 if (context->getClientVersion() < 3)
8260 {
8261 return gl::error(GL_INVALID_OPERATION);
8262 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008263
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008264 UNIMPLEMENTED();
8265 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008266 }
8267 catch(std::bad_alloc&)
8268 {
8269 return gl::error(GL_OUT_OF_MEMORY);
8270 }
8271}
8272
8273GLboolean __stdcall glIsQuery(GLuint id)
8274{
8275 EVENT("(GLuint id = %u)", id);
8276
8277 try
8278 {
8279 gl::Context *context = gl::getNonLostContext();
8280
8281 if (context)
8282 {
8283 if (context->getClientVersion() < 3)
8284 {
8285 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8286 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008287
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008288 UNIMPLEMENTED();
8289 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008290 }
8291 catch(std::bad_alloc&)
8292 {
8293 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8294 }
8295
8296 return GL_FALSE;
8297}
8298
8299void __stdcall glBeginQuery(GLenum target, GLuint id)
8300{
8301 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
8302
8303 try
8304 {
8305 gl::Context *context = gl::getNonLostContext();
8306
8307 if (context)
8308 {
8309 if (context->getClientVersion() < 3)
8310 {
8311 return gl::error(GL_INVALID_OPERATION);
8312 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008313
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008314 UNIMPLEMENTED();
8315 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008316 }
8317 catch(std::bad_alloc&)
8318 {
8319 return gl::error(GL_OUT_OF_MEMORY);
8320 }
8321}
8322
8323void __stdcall glEndQuery(GLenum target)
8324{
8325 EVENT("(GLenum target = 0x%X)", target);
8326
8327 try
8328 {
8329 gl::Context *context = gl::getNonLostContext();
8330
8331 if (context)
8332 {
8333 if (context->getClientVersion() < 3)
8334 {
8335 return gl::error(GL_INVALID_OPERATION);
8336 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008337
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008338 UNIMPLEMENTED();
8339 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008340 }
8341 catch(std::bad_alloc&)
8342 {
8343 return gl::error(GL_OUT_OF_MEMORY);
8344 }
8345}
8346
8347void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params)
8348{
8349 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
8350
8351 try
8352 {
8353 gl::Context *context = gl::getNonLostContext();
8354
8355 if (context)
8356 {
8357 if (context->getClientVersion() < 3)
8358 {
8359 return gl::error(GL_INVALID_OPERATION);
8360 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008361
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008362 UNIMPLEMENTED();
8363 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008364 }
8365 catch(std::bad_alloc&)
8366 {
8367 return gl::error(GL_OUT_OF_MEMORY);
8368 }
8369}
8370
8371void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
8372{
8373 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
8374
8375 try
8376 {
8377 gl::Context *context = gl::getNonLostContext();
8378
8379 if (context)
8380 {
8381 if (context->getClientVersion() < 3)
8382 {
8383 return gl::error(GL_INVALID_OPERATION);
8384 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008385
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008386 UNIMPLEMENTED();
8387 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008388 }
8389 catch(std::bad_alloc&)
8390 {
8391 return gl::error(GL_OUT_OF_MEMORY);
8392 }
8393}
8394
8395GLboolean __stdcall glUnmapBuffer(GLenum target)
8396{
8397 EVENT("(GLenum target = 0x%X)", target);
8398
8399 try
8400 {
8401 gl::Context *context = gl::getNonLostContext();
8402
8403 if (context)
8404 {
8405 if (context->getClientVersion() < 3)
8406 {
8407 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8408 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008409
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008410 UNIMPLEMENTED();
8411 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008412 }
8413 catch(std::bad_alloc&)
8414 {
8415 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8416 }
8417
8418 return GL_FALSE;
8419}
8420
8421void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
8422{
8423 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
8424
8425 try
8426 {
8427 gl::Context *context = gl::getNonLostContext();
8428
8429 if (context)
8430 {
8431 if (context->getClientVersion() < 3)
8432 {
8433 return gl::error(GL_INVALID_OPERATION);
8434 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008435
shannonwoods@chromium.org2d2190a2013-05-30 00:17:35 +00008436 UNIMPLEMENTED();
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008437 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008438 }
8439 catch(std::bad_alloc&)
8440 {
8441 return gl::error(GL_OUT_OF_MEMORY);
8442 }
8443}
8444
8445void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs)
8446{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008447 try
8448 {
8449 gl::Context *context = gl::getNonLostContext();
8450
8451 if (context)
8452 {
8453 if (context->getClientVersion() < 3)
8454 {
8455 return gl::error(GL_INVALID_OPERATION);
8456 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008457
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00008458 glDrawBuffersEXT(n, bufs);
8459 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008460 }
8461 catch(std::bad_alloc&)
8462 {
8463 return gl::error(GL_OUT_OF_MEMORY);
8464 }
8465}
8466
8467void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8468{
8469 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8470 location, count, transpose, value);
8471
8472 try
8473 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008474 if (count < 0)
8475 {
8476 return gl::error(GL_INVALID_VALUE);
8477 }
8478
8479 if (location == -1)
8480 {
8481 return;
8482 }
8483
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008484 gl::Context *context = gl::getNonLostContext();
8485
8486 if (context)
8487 {
8488 if (context->getClientVersion() < 3)
8489 {
8490 return gl::error(GL_INVALID_OPERATION);
8491 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008492
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008493 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8494 if (!programBinary)
8495 {
8496 return gl::error(GL_INVALID_OPERATION);
8497 }
8498
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008499 if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008500 {
8501 return gl::error(GL_INVALID_OPERATION);
8502 }
8503 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008504 }
8505 catch(std::bad_alloc&)
8506 {
8507 return gl::error(GL_OUT_OF_MEMORY);
8508 }
8509}
8510
8511void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8512{
8513 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8514 location, count, transpose, value);
8515
8516 try
8517 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008518 if (count < 0)
8519 {
8520 return gl::error(GL_INVALID_VALUE);
8521 }
8522
8523 if (location == -1)
8524 {
8525 return;
8526 }
8527
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008528 gl::Context *context = gl::getNonLostContext();
8529
8530 if (context)
8531 {
8532 if (context->getClientVersion() < 3)
8533 {
8534 return gl::error(GL_INVALID_OPERATION);
8535 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008536
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008537 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8538 if (!programBinary)
8539 {
8540 return gl::error(GL_INVALID_OPERATION);
8541 }
8542
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008543 if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008544 {
8545 return gl::error(GL_INVALID_OPERATION);
8546 }
8547 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008548 }
8549 catch(std::bad_alloc&)
8550 {
8551 return gl::error(GL_OUT_OF_MEMORY);
8552 }
8553}
8554
8555void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8556{
8557 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8558 location, count, transpose, value);
8559
8560 try
8561 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008562 if (count < 0)
8563 {
8564 return gl::error(GL_INVALID_VALUE);
8565 }
8566
8567 if (location == -1)
8568 {
8569 return;
8570 }
8571
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008572 gl::Context *context = gl::getNonLostContext();
8573
8574 if (context)
8575 {
8576 if (context->getClientVersion() < 3)
8577 {
8578 return gl::error(GL_INVALID_OPERATION);
8579 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008580
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008581 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8582 if (!programBinary)
8583 {
8584 return gl::error(GL_INVALID_OPERATION);
8585 }
8586
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008587 if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008588 {
8589 return gl::error(GL_INVALID_OPERATION);
8590 }
8591 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008592 }
8593 catch(std::bad_alloc&)
8594 {
8595 return gl::error(GL_OUT_OF_MEMORY);
8596 }
8597}
8598
8599void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8600{
8601 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8602 location, count, transpose, value);
8603
8604 try
8605 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008606 if (count < 0)
8607 {
8608 return gl::error(GL_INVALID_VALUE);
8609 }
8610
8611 if (location == -1)
8612 {
8613 return;
8614 }
8615
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008616 gl::Context *context = gl::getNonLostContext();
8617
8618 if (context)
8619 {
8620 if (context->getClientVersion() < 3)
8621 {
8622 return gl::error(GL_INVALID_OPERATION);
8623 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008624
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008625 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8626 if (!programBinary)
8627 {
8628 return gl::error(GL_INVALID_OPERATION);
8629 }
8630
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008631 if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008632 {
8633 return gl::error(GL_INVALID_OPERATION);
8634 }
8635 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008636 }
8637 catch(std::bad_alloc&)
8638 {
8639 return gl::error(GL_OUT_OF_MEMORY);
8640 }
8641}
8642
8643void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8644{
8645 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8646 location, count, transpose, value);
8647
8648 try
8649 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008650 if (count < 0)
8651 {
8652 return gl::error(GL_INVALID_VALUE);
8653 }
8654
8655 if (location == -1)
8656 {
8657 return;
8658 }
8659
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008660 gl::Context *context = gl::getNonLostContext();
8661
8662 if (context)
8663 {
8664 if (context->getClientVersion() < 3)
8665 {
8666 return gl::error(GL_INVALID_OPERATION);
8667 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008668
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008669 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8670 if (!programBinary)
8671 {
8672 return gl::error(GL_INVALID_OPERATION);
8673 }
8674
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008675 if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008676 {
8677 return gl::error(GL_INVALID_OPERATION);
8678 }
8679 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008680 }
8681 catch(std::bad_alloc&)
8682 {
8683 return gl::error(GL_OUT_OF_MEMORY);
8684 }
8685}
8686
8687void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8688{
8689 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8690 location, count, transpose, value);
8691
8692 try
8693 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008694 if (count < 0)
8695 {
8696 return gl::error(GL_INVALID_VALUE);
8697 }
8698
8699 if (location == -1)
8700 {
8701 return;
8702 }
8703
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008704 gl::Context *context = gl::getNonLostContext();
8705
8706 if (context)
8707 {
8708 if (context->getClientVersion() < 3)
8709 {
8710 return gl::error(GL_INVALID_OPERATION);
8711 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008712
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008713 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8714 if (!programBinary)
8715 {
8716 return gl::error(GL_INVALID_OPERATION);
8717 }
8718
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008719 if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008720 {
8721 return gl::error(GL_INVALID_OPERATION);
8722 }
8723 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008724 }
8725 catch(std::bad_alloc&)
8726 {
8727 return gl::error(GL_OUT_OF_MEMORY);
8728 }
8729}
8730
8731void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
8732{
8733 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
8734 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
8735 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
8736
8737 try
8738 {
8739 gl::Context *context = gl::getNonLostContext();
8740
8741 if (context)
8742 {
8743 if (context->getClientVersion() < 3)
8744 {
8745 return gl::error(GL_INVALID_OPERATION);
8746 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008747
shannonwoods@chromium.orgee148562013-05-30 00:17:21 +00008748 glBlitFramebufferANGLE(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008749 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008750 }
8751 catch(std::bad_alloc&)
8752 {
8753 return gl::error(GL_OUT_OF_MEMORY);
8754 }
8755}
8756
8757void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
8758{
8759 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
8760 target, samples, internalformat, width, height);
8761
8762 try
8763 {
8764 gl::Context *context = gl::getNonLostContext();
8765
8766 if (context)
8767 {
8768 if (context->getClientVersion() < 3)
8769 {
8770 return gl::error(GL_INVALID_OPERATION);
8771 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008772
shannonwoods@chromium.org2d2190a2013-05-30 00:17:35 +00008773 glRenderbufferStorageMultisampleANGLE(target, samples, internalformat, width, height);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008774 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008775 }
8776 catch(std::bad_alloc&)
8777 {
8778 return gl::error(GL_OUT_OF_MEMORY);
8779 }
8780}
8781
8782void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
8783{
8784 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
8785 target, attachment, texture, level, layer);
8786
8787 try
8788 {
8789 gl::Context *context = gl::getNonLostContext();
8790
8791 if (context)
8792 {
8793 if (context->getClientVersion() < 3)
8794 {
8795 return gl::error(GL_INVALID_OPERATION);
8796 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008797
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008798 UNIMPLEMENTED();
8799 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008800 }
8801 catch(std::bad_alloc&)
8802 {
8803 return gl::error(GL_OUT_OF_MEMORY);
8804 }
8805}
8806
8807GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
8808{
8809 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
8810 target, offset, length, access);
8811
8812 try
8813 {
8814 gl::Context *context = gl::getNonLostContext();
8815
8816 if (context)
8817 {
8818 if (context->getClientVersion() < 3)
8819 {
8820 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
8821 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008822
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008823 UNIMPLEMENTED();
8824 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008825 }
8826 catch(std::bad_alloc&)
8827 {
8828 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL));
8829 }
8830
8831 return NULL;
8832}
8833
8834void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
8835{
8836 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
8837
8838 try
8839 {
8840 gl::Context *context = gl::getNonLostContext();
8841
8842 if (context)
8843 {
8844 if (context->getClientVersion() < 3)
8845 {
8846 return gl::error(GL_INVALID_OPERATION);
8847 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008848
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008849 UNIMPLEMENTED();
8850 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008851 }
8852 catch(std::bad_alloc&)
8853 {
8854 return gl::error(GL_OUT_OF_MEMORY);
8855 }
8856}
8857
8858void __stdcall glBindVertexArray(GLuint array)
8859{
8860 EVENT("(GLuint array = %u)", array);
8861
8862 try
8863 {
8864 gl::Context *context = gl::getNonLostContext();
8865
8866 if (context)
8867 {
8868 if (context->getClientVersion() < 3)
8869 {
8870 return gl::error(GL_INVALID_OPERATION);
8871 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008872
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008873 UNIMPLEMENTED();
8874 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008875 }
8876 catch(std::bad_alloc&)
8877 {
8878 return gl::error(GL_OUT_OF_MEMORY);
8879 }
8880}
8881
8882void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
8883{
8884 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
8885
8886 try
8887 {
8888 gl::Context *context = gl::getNonLostContext();
8889
8890 if (context)
8891 {
8892 if (context->getClientVersion() < 3)
8893 {
8894 return gl::error(GL_INVALID_OPERATION);
8895 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008896
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008897 UNIMPLEMENTED();
8898 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008899 }
8900 catch(std::bad_alloc&)
8901 {
8902 return gl::error(GL_OUT_OF_MEMORY);
8903 }
8904}
8905
8906void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays)
8907{
8908 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
8909
8910 try
8911 {
8912 gl::Context *context = gl::getNonLostContext();
8913
8914 if (context)
8915 {
8916 if (context->getClientVersion() < 3)
8917 {
8918 return gl::error(GL_INVALID_OPERATION);
8919 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008920
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008921 UNIMPLEMENTED();
8922 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008923 }
8924 catch(std::bad_alloc&)
8925 {
8926 return gl::error(GL_OUT_OF_MEMORY);
8927 }
8928}
8929
8930GLboolean __stdcall glIsVertexArray(GLuint array)
8931{
8932 EVENT("(GLuint array = %u)", array);
8933
8934 try
8935 {
8936 gl::Context *context = gl::getNonLostContext();
8937
8938 if (context)
8939 {
8940 if (context->getClientVersion() < 3)
8941 {
8942 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8943 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008944
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008945 UNIMPLEMENTED();
8946 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008947 }
8948 catch(std::bad_alloc&)
8949 {
8950 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8951 }
8952
8953 return GL_FALSE;
8954}
8955
8956void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
8957{
8958 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
8959 target, index, data);
8960
8961 try
8962 {
8963 gl::Context *context = gl::getNonLostContext();
8964
8965 if (context)
8966 {
8967 if (context->getClientVersion() < 3)
8968 {
8969 return gl::error(GL_INVALID_OPERATION);
8970 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008971
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008972 UNIMPLEMENTED();
8973 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008974 }
8975 catch(std::bad_alloc&)
8976 {
8977 return gl::error(GL_OUT_OF_MEMORY);
8978 }
8979}
8980
8981void __stdcall glBeginTransformFeedback(GLenum primitiveMode)
8982{
8983 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
8984
8985 try
8986 {
8987 gl::Context *context = gl::getNonLostContext();
8988
8989 if (context)
8990 {
8991 if (context->getClientVersion() < 3)
8992 {
8993 return gl::error(GL_INVALID_OPERATION);
8994 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008995
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008996 UNIMPLEMENTED();
8997 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008998 }
8999 catch(std::bad_alloc&)
9000 {
9001 return gl::error(GL_OUT_OF_MEMORY);
9002 }
9003}
9004
9005void __stdcall glEndTransformFeedback(void)
9006{
9007 EVENT("(void)");
9008
9009 try
9010 {
9011 gl::Context *context = gl::getNonLostContext();
9012
9013 if (context)
9014 {
9015 if (context->getClientVersion() < 3)
9016 {
9017 return gl::error(GL_INVALID_OPERATION);
9018 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009019
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009020 UNIMPLEMENTED();
9021 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009022 }
9023 catch(std::bad_alloc&)
9024 {
9025 return gl::error(GL_OUT_OF_MEMORY);
9026 }
9027}
9028
9029void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
9030{
9031 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
9032 target, index, buffer, offset, size);
9033
9034 try
9035 {
9036 gl::Context *context = gl::getNonLostContext();
9037
9038 if (context)
9039 {
9040 if (context->getClientVersion() < 3)
9041 {
9042 return gl::error(GL_INVALID_OPERATION);
9043 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009044
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009045 switch (target)
9046 {
9047 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00009048 if (index >= context->getMaxTransformFeedbackBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009049 {
9050 return gl::error(GL_INVALID_VALUE);
9051 }
9052 break;
9053
9054 case GL_UNIFORM_BUFFER:
9055 if (index >= context->getMaximumCombinedUniformBufferBindings())
9056 {
9057 return gl::error(GL_INVALID_VALUE);
9058 }
9059 break;
9060
9061 default:
9062 return gl::error(GL_INVALID_ENUM);
9063 }
9064
shannonwoods@chromium.orge6e00792013-05-30 00:06:07 +00009065 if (buffer != 0 && size <= 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009066 {
9067 return gl::error(GL_INVALID_VALUE);
9068 }
9069
9070 switch (target)
9071 {
9072 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orga26aeaf2013-05-30 00:06:13 +00009073
9074 // size and offset must be a multiple of 4
9075 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
9076 {
9077 return gl::error(GL_INVALID_VALUE);
9078 }
9079
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009080 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
9081 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009082 break;
9083
9084 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.org97c3d502013-05-30 00:04:34 +00009085
9086 // it is an error to bind an offset not a multiple of the alignment
9087 if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0)
9088 {
9089 return gl::error(GL_INVALID_VALUE);
9090 }
9091
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009092 context->bindIndexedUniformBuffer(buffer, index, offset, size);
9093 context->bindGenericUniformBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009094 break;
9095
9096 default:
9097 UNREACHABLE();
9098 }
9099 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009100 }
9101 catch(std::bad_alloc&)
9102 {
9103 return gl::error(GL_OUT_OF_MEMORY);
9104 }
9105}
9106
9107void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
9108{
9109 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
9110 target, index, buffer);
9111
9112 try
9113 {
9114 gl::Context *context = gl::getNonLostContext();
9115
9116 if (context)
9117 {
9118 if (context->getClientVersion() < 3)
9119 {
9120 return gl::error(GL_INVALID_OPERATION);
9121 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009122
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009123 switch (target)
9124 {
9125 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00009126 if (index >= context->getMaxTransformFeedbackBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009127 {
9128 return gl::error(GL_INVALID_VALUE);
9129 }
9130 break;
9131
9132 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00009133 if (index >= context->getMaximumCombinedUniformBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009134 {
9135 return gl::error(GL_INVALID_VALUE);
9136 }
9137 break;
9138
9139 default:
9140 return gl::error(GL_INVALID_ENUM);
9141 }
9142
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009143 switch (target)
9144 {
9145 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.org3eeca1e2013-05-30 00:04:28 +00009146 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009147 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009148 break;
9149
9150 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.org3eeca1e2013-05-30 00:04:28 +00009151 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009152 context->bindGenericUniformBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009153 break;
9154
9155 default:
9156 UNREACHABLE();
9157 }
9158 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009159 }
9160 catch(std::bad_alloc&)
9161 {
9162 return gl::error(GL_OUT_OF_MEMORY);
9163 }
9164}
9165
9166void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
9167{
9168 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
9169 program, count, varyings, bufferMode);
9170
9171 try
9172 {
9173 gl::Context *context = gl::getNonLostContext();
9174
9175 if (context)
9176 {
9177 if (context->getClientVersion() < 3)
9178 {
9179 return gl::error(GL_INVALID_OPERATION);
9180 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009181
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009182 UNIMPLEMENTED();
9183 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009184 }
9185 catch(std::bad_alloc&)
9186 {
9187 return gl::error(GL_OUT_OF_MEMORY);
9188 }
9189}
9190
9191void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
9192{
9193 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
9194 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
9195 program, index, bufSize, length, size, type, name);
9196
9197 try
9198 {
9199 gl::Context *context = gl::getNonLostContext();
9200
9201 if (context)
9202 {
9203 if (context->getClientVersion() < 3)
9204 {
9205 return gl::error(GL_INVALID_OPERATION);
9206 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009207
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009208 UNIMPLEMENTED();
9209 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009210 }
9211 catch(std::bad_alloc&)
9212 {
9213 return gl::error(GL_OUT_OF_MEMORY);
9214 }
9215}
9216
9217void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
9218{
9219 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
9220 index, size, type, stride, pointer);
9221
9222 try
9223 {
9224 gl::Context *context = gl::getNonLostContext();
9225
9226 if (context)
9227 {
9228 if (context->getClientVersion() < 3)
9229 {
9230 return gl::error(GL_INVALID_OPERATION);
9231 }
9232 }
9233
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009234 if (index >= gl::MAX_VERTEX_ATTRIBS)
9235 {
9236 return gl::error(GL_INVALID_VALUE);
9237 }
9238
9239 if (size < 1 || size > 4)
9240 {
9241 return gl::error(GL_INVALID_VALUE);
9242 }
9243
9244 switch (type)
9245 {
9246 case GL_BYTE:
9247 case GL_UNSIGNED_BYTE:
9248 case GL_SHORT:
9249 case GL_UNSIGNED_SHORT:
9250 case GL_INT:
9251 case GL_UNSIGNED_INT:
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00009252 case GL_INT_2_10_10_10_REV:
9253 case GL_UNSIGNED_INT_2_10_10_10_REV:
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009254 break;
9255 default:
9256 return gl::error(GL_INVALID_ENUM);
9257 }
9258
9259 if (stride < 0)
9260 {
9261 return gl::error(GL_INVALID_VALUE);
9262 }
9263
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00009264 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
9265 {
9266 return gl::error(GL_INVALID_OPERATION);
9267 }
9268
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009269 if (context)
9270 {
9271 context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true,
9272 stride, pointer);
9273 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009274 }
9275 catch(std::bad_alloc&)
9276 {
9277 return gl::error(GL_OUT_OF_MEMORY);
9278 }
9279}
9280
9281void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
9282{
9283 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
9284 index, pname, params);
9285
9286 try
9287 {
9288 gl::Context *context = gl::getNonLostContext();
9289
9290 if (context)
9291 {
9292 if (context->getClientVersion() < 3)
9293 {
9294 return gl::error(GL_INVALID_OPERATION);
9295 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009296
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009297 UNIMPLEMENTED();
9298 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009299 }
9300 catch(std::bad_alloc&)
9301 {
9302 return gl::error(GL_OUT_OF_MEMORY);
9303 }
9304}
9305
9306void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
9307{
9308 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
9309 index, pname, params);
9310
9311 try
9312 {
9313 gl::Context *context = gl::getNonLostContext();
9314
9315 if (context)
9316 {
9317 if (context->getClientVersion() < 3)
9318 {
9319 return gl::error(GL_INVALID_OPERATION);
9320 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009321
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009322 UNIMPLEMENTED();
9323 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009324 }
9325 catch(std::bad_alloc&)
9326 {
9327 return gl::error(GL_OUT_OF_MEMORY);
9328 }
9329}
9330
9331void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
9332{
9333 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
9334 index, x, y, z, w);
9335
9336 try
9337 {
9338 gl::Context *context = gl::getNonLostContext();
9339
9340 if (context)
9341 {
9342 if (context->getClientVersion() < 3)
9343 {
9344 return gl::error(GL_INVALID_OPERATION);
9345 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009346
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009347 if (index >= gl::MAX_VERTEX_ATTRIBS)
9348 {
9349 return gl::error(GL_INVALID_VALUE);
9350 }
9351
9352 GLint vals[4] = { x, y, z, w };
9353 context->setVertexAttribi(index, vals);
9354 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009355 }
9356 catch(std::bad_alloc&)
9357 {
9358 return gl::error(GL_OUT_OF_MEMORY);
9359 }
9360}
9361
9362void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
9363{
9364 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
9365 index, x, y, z, w);
9366
9367 try
9368 {
9369 gl::Context *context = gl::getNonLostContext();
9370
9371 if (context)
9372 {
9373 if (context->getClientVersion() < 3)
9374 {
9375 return gl::error(GL_INVALID_OPERATION);
9376 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009377
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009378 if (index >= gl::MAX_VERTEX_ATTRIBS)
9379 {
9380 return gl::error(GL_INVALID_VALUE);
9381 }
9382
9383 GLuint vals[4] = { x, y, z, w };
9384 context->setVertexAttribu(index, vals);
9385 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009386 }
9387 catch(std::bad_alloc&)
9388 {
9389 return gl::error(GL_OUT_OF_MEMORY);
9390 }
9391}
9392
9393void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v)
9394{
9395 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
9396
9397 try
9398 {
9399 gl::Context *context = gl::getNonLostContext();
9400
9401 if (context)
9402 {
9403 if (context->getClientVersion() < 3)
9404 {
9405 return gl::error(GL_INVALID_OPERATION);
9406 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009407
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009408 if (index >= gl::MAX_VERTEX_ATTRIBS)
9409 {
9410 return gl::error(GL_INVALID_VALUE);
9411 }
9412
9413 context->setVertexAttribi(index, v);
9414 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009415 }
9416 catch(std::bad_alloc&)
9417 {
9418 return gl::error(GL_OUT_OF_MEMORY);
9419 }
9420}
9421
9422void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v)
9423{
9424 EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
9425
9426 try
9427 {
9428 gl::Context *context = gl::getNonLostContext();
9429
9430 if (context)
9431 {
9432 if (context->getClientVersion() < 3)
9433 {
9434 return gl::error(GL_INVALID_OPERATION);
9435 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009436
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009437 if (index >= gl::MAX_VERTEX_ATTRIBS)
9438 {
9439 return gl::error(GL_INVALID_VALUE);
9440 }
9441
9442 context->setVertexAttribu(index, v);
9443 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009444 }
9445 catch(std::bad_alloc&)
9446 {
9447 return gl::error(GL_OUT_OF_MEMORY);
9448 }
9449}
9450
9451void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params)
9452{
9453 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
9454 program, location, params);
9455
9456 try
9457 {
9458 gl::Context *context = gl::getNonLostContext();
9459
9460 if (context)
9461 {
9462 if (context->getClientVersion() < 3)
9463 {
9464 return gl::error(GL_INVALID_OPERATION);
9465 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009466
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00009467 if (program == 0)
9468 {
9469 return gl::error(GL_INVALID_VALUE);
9470 }
9471
9472 gl::Program *programObject = context->getProgram(program);
9473
9474 if (!programObject || !programObject->isLinked())
9475 {
9476 return gl::error(GL_INVALID_OPERATION);
9477 }
9478
9479 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
9480 if (!programBinary)
9481 {
9482 return gl::error(GL_INVALID_OPERATION);
9483 }
9484
9485 if (!programBinary->getUniformuiv(location, NULL, params))
9486 {
9487 return gl::error(GL_INVALID_OPERATION);
9488 }
9489 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009490 }
9491 catch(std::bad_alloc&)
9492 {
9493 return gl::error(GL_OUT_OF_MEMORY);
9494 }
9495}
9496
9497GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name)
9498{
9499 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
9500 program, name);
9501
9502 try
9503 {
9504 gl::Context *context = gl::getNonLostContext();
9505
9506 if (context)
9507 {
9508 if (context->getClientVersion() < 3)
9509 {
9510 return gl::error(GL_INVALID_OPERATION, 0);
9511 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009512
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009513 UNIMPLEMENTED();
9514 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009515 }
9516 catch(std::bad_alloc&)
9517 {
9518 return gl::error(GL_OUT_OF_MEMORY, 0);
9519 }
9520
9521 return 0;
9522}
9523
9524void __stdcall glUniform1ui(GLint location, GLuint v0)
9525{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00009526 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009527}
9528
9529void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1)
9530{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00009531 const GLuint xy[] = { v0, v1 };
9532 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009533}
9534
9535void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
9536{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00009537 const GLuint xyz[] = { v0, v1, v2 };
9538 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009539}
9540
9541void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
9542{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00009543 const GLuint xyzw[] = { v0, v1, v2, v3 };
9544 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009545}
9546
9547void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
9548{
9549 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
9550 location, count, value);
9551
9552 try
9553 {
9554 gl::Context *context = gl::getNonLostContext();
9555
9556 if (context)
9557 {
9558 if (context->getClientVersion() < 3)
9559 {
9560 return gl::error(GL_INVALID_OPERATION);
9561 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009562
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00009563 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9564 if (!programBinary)
9565 {
9566 return gl::error(GL_INVALID_OPERATION);
9567 }
9568
9569 if (!programBinary->setUniform1uiv(location, count, value))
9570 {
9571 return gl::error(GL_INVALID_OPERATION);
9572 }
9573 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009574 }
9575 catch(std::bad_alloc&)
9576 {
9577 return gl::error(GL_OUT_OF_MEMORY);
9578 }
9579}
9580
9581void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
9582{
9583 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
9584 location, count, value);
9585
9586 try
9587 {
9588 gl::Context *context = gl::getNonLostContext();
9589
9590 if (context)
9591 {
9592 if (context->getClientVersion() < 3)
9593 {
9594 return gl::error(GL_INVALID_OPERATION);
9595 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009596
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00009597 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9598 if (!programBinary)
9599 {
9600 return gl::error(GL_INVALID_OPERATION);
9601 }
9602
9603 if (!programBinary->setUniform2uiv(location, count, value))
9604 {
9605 return gl::error(GL_INVALID_OPERATION);
9606 }
9607 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009608 }
9609 catch(std::bad_alloc&)
9610 {
9611 return gl::error(GL_OUT_OF_MEMORY);
9612 }
9613}
9614
9615void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
9616{
9617 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
9618 location, count, value);
9619
9620 try
9621 {
9622 gl::Context *context = gl::getNonLostContext();
9623
9624 if (context)
9625 {
9626 if (context->getClientVersion() < 3)
9627 {
9628 return gl::error(GL_INVALID_OPERATION);
9629 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009630
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00009631 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9632 if (!programBinary)
9633 {
9634 return gl::error(GL_INVALID_OPERATION);
9635 }
9636
9637 if (!programBinary->setUniform3uiv(location, count, value))
9638 {
9639 return gl::error(GL_INVALID_OPERATION);
9640 }
9641 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009642 }
9643 catch(std::bad_alloc&)
9644 {
9645 return gl::error(GL_OUT_OF_MEMORY);
9646 }
9647}
9648
9649void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
9650{
9651 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
9652 location, count, value);
9653
9654 try
9655 {
9656 gl::Context *context = gl::getNonLostContext();
9657
9658 if (context)
9659 {
9660 if (context->getClientVersion() < 3)
9661 {
9662 return gl::error(GL_INVALID_OPERATION);
9663 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009664
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00009665 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9666 if (!programBinary)
9667 {
9668 return gl::error(GL_INVALID_OPERATION);
9669 }
9670
9671 if (!programBinary->setUniform4uiv(location, count, value))
9672 {
9673 return gl::error(GL_INVALID_OPERATION);
9674 }
9675 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009676 }
9677 catch(std::bad_alloc&)
9678 {
9679 return gl::error(GL_OUT_OF_MEMORY);
9680 }
9681}
9682
9683void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
9684{
9685 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
9686 buffer, drawbuffer, value);
9687
9688 try
9689 {
9690 gl::Context *context = gl::getNonLostContext();
9691
9692 if (context)
9693 {
9694 if (context->getClientVersion() < 3)
9695 {
9696 return gl::error(GL_INVALID_OPERATION);
9697 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009698
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009699 UNIMPLEMENTED();
9700 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009701 }
9702 catch(std::bad_alloc&)
9703 {
9704 return gl::error(GL_OUT_OF_MEMORY);
9705 }
9706}
9707
9708void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
9709{
9710 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
9711 buffer, drawbuffer, value);
9712
9713 try
9714 {
9715 gl::Context *context = gl::getNonLostContext();
9716
9717 if (context)
9718 {
9719 if (context->getClientVersion() < 3)
9720 {
9721 return gl::error(GL_INVALID_OPERATION);
9722 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009723
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009724 UNIMPLEMENTED();
9725 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009726 }
9727 catch(std::bad_alloc&)
9728 {
9729 return gl::error(GL_OUT_OF_MEMORY);
9730 }
9731}
9732
9733void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
9734{
9735 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
9736 buffer, drawbuffer, value);
9737
9738 try
9739 {
9740 gl::Context *context = gl::getNonLostContext();
9741
9742 if (context)
9743 {
9744 if (context->getClientVersion() < 3)
9745 {
9746 return gl::error(GL_INVALID_OPERATION);
9747 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009748
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009749 UNIMPLEMENTED();
9750 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009751 }
9752 catch(std::bad_alloc&)
9753 {
9754 return gl::error(GL_OUT_OF_MEMORY);
9755 }
9756}
9757
9758void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
9759{
9760 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
9761 buffer, drawbuffer, depth, stencil);
9762
9763 try
9764 {
9765 gl::Context *context = gl::getNonLostContext();
9766
9767 if (context)
9768 {
9769 if (context->getClientVersion() < 3)
9770 {
9771 return gl::error(GL_INVALID_OPERATION);
9772 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009773
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009774 UNIMPLEMENTED();
9775 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009776 }
9777 catch(std::bad_alloc&)
9778 {
9779 return gl::error(GL_OUT_OF_MEMORY);
9780 }
9781}
9782
9783const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index)
9784{
9785 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
9786
9787 try
9788 {
9789 gl::Context *context = gl::getNonLostContext();
9790
9791 if (context)
9792 {
9793 if (context->getClientVersion() < 3)
9794 {
9795 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL));
9796 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009797
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00009798 if (name != GL_EXTENSIONS)
9799 {
9800 return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL));
9801 }
9802
9803 if (index >= context->getNumExtensions())
9804 {
9805 return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL));
9806 }
9807
9808 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index));
9809 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009810 }
9811 catch(std::bad_alloc&)
9812 {
9813 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL));
9814 }
9815
9816 return NULL;
9817}
9818
9819void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
9820{
9821 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
9822 readTarget, writeTarget, readOffset, writeOffset, size);
9823
9824 try
9825 {
9826 gl::Context *context = gl::getNonLostContext();
9827
9828 if (context)
9829 {
9830 if (context->getClientVersion() < 3)
9831 {
9832 return gl::error(GL_INVALID_OPERATION);
9833 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009834
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00009835 gl::Buffer *readBuffer = NULL;
9836 switch (readTarget)
9837 {
9838 case GL_ARRAY_BUFFER:
9839 readBuffer = context->getArrayBuffer();
9840 break;
9841 case GL_COPY_READ_BUFFER:
9842 readBuffer = context->getCopyReadBuffer();
9843 break;
9844 case GL_COPY_WRITE_BUFFER:
9845 readBuffer = context->getCopyWriteBuffer();
9846 break;
9847 case GL_ELEMENT_ARRAY_BUFFER:
9848 readBuffer = context->getElementArrayBuffer();
9849 break;
9850 case GL_PIXEL_PACK_BUFFER:
9851 readBuffer = context->getPixelPackBuffer();
9852 break;
9853 case GL_PIXEL_UNPACK_BUFFER:
9854 readBuffer = context->getPixelUnpackBuffer();
9855 break;
9856 case GL_TRANSFORM_FEEDBACK_BUFFER:
9857 readBuffer = context->getGenericTransformFeedbackBuffer();
9858 break;
9859 case GL_UNIFORM_BUFFER:
9860 readBuffer = context->getGenericUniformBuffer();
9861 break;
9862 default:
9863 return gl::error(GL_INVALID_ENUM);
9864 }
9865
9866 gl::Buffer *writeBuffer = NULL;
9867 switch (writeTarget)
9868 {
9869 case GL_ARRAY_BUFFER:
9870 writeBuffer = context->getArrayBuffer();
9871 break;
9872 case GL_COPY_READ_BUFFER:
9873 writeBuffer = context->getCopyReadBuffer();
9874 break;
9875 case GL_COPY_WRITE_BUFFER:
9876 writeBuffer = context->getCopyWriteBuffer();
9877 break;
9878 case GL_ELEMENT_ARRAY_BUFFER:
9879 writeBuffer = context->getElementArrayBuffer();
9880 break;
9881 case GL_PIXEL_PACK_BUFFER:
9882 writeBuffer = context->getPixelPackBuffer();
9883 break;
9884 case GL_PIXEL_UNPACK_BUFFER:
9885 writeBuffer = context->getPixelUnpackBuffer();
9886 break;
9887 case GL_TRANSFORM_FEEDBACK_BUFFER:
9888 writeBuffer = context->getGenericTransformFeedbackBuffer();
9889 break;
9890 case GL_UNIFORM_BUFFER:
9891 writeBuffer = context->getGenericUniformBuffer();
9892 break;
9893 default:
9894 return gl::error(GL_INVALID_ENUM);
9895 }
9896
9897 if (!readBuffer || !writeBuffer)
9898 {
9899 return gl::error(GL_INVALID_OPERATION);
9900 }
9901
9902 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
9903 static_cast<unsigned int>(readOffset + size) > readBuffer->size() ||
9904 static_cast<unsigned int>(writeOffset + size) > writeBuffer->size())
9905 {
9906 return gl::error(GL_INVALID_VALUE);
9907 }
9908
9909 if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size)
9910 {
9911 return gl::error(GL_INVALID_VALUE);
9912 }
9913
9914 // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION)
9915
shannon.woods%transgaming.com@gtempaccount.comc53376a2013-04-13 03:41:23 +00009916 // if size is zero, the copy is a successful no-op
9917 if (size > 0)
9918 {
9919 writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
9920 }
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00009921 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009922 }
9923 catch(std::bad_alloc&)
9924 {
9925 return gl::error(GL_OUT_OF_MEMORY);
9926 }
9927}
9928
9929void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
9930{
9931 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
9932 program, uniformCount, uniformNames, uniformIndices);
9933
9934 try
9935 {
9936 gl::Context *context = gl::getNonLostContext();
9937
9938 if (context)
9939 {
9940 if (context->getClientVersion() < 3)
9941 {
9942 return gl::error(GL_INVALID_OPERATION);
9943 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009944
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00009945 if (uniformCount < 0)
9946 {
9947 return gl::error(GL_INVALID_VALUE);
9948 }
9949
9950 gl::Program *programObject = context->getProgram(program);
9951
9952 if (!programObject)
9953 {
9954 if (context->getShader(program))
9955 {
9956 return gl::error(GL_INVALID_OPERATION);
9957 }
9958 else
9959 {
9960 return gl::error(GL_INVALID_VALUE);
9961 }
9962 }
9963
9964 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
9965 if (!programObject->isLinked() || !programBinary)
9966 {
9967 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
9968 {
9969 uniformIndices[uniformId] = GL_INVALID_INDEX;
9970 }
9971 }
9972 else
9973 {
9974 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
9975 {
9976 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
9977 }
9978 }
9979 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009980 }
9981 catch(std::bad_alloc&)
9982 {
9983 return gl::error(GL_OUT_OF_MEMORY);
9984 }
9985}
9986
9987void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
9988{
9989 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
9990 program, uniformCount, uniformIndices, pname, params);
9991
9992 try
9993 {
9994 gl::Context *context = gl::getNonLostContext();
9995
9996 if (context)
9997 {
9998 if (context->getClientVersion() < 3)
9999 {
10000 return gl::error(GL_INVALID_OPERATION);
10001 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010002
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +000010003 if (uniformCount < 0)
10004 {
10005 return gl::error(GL_INVALID_VALUE);
10006 }
10007
10008 gl::Program *programObject = context->getProgram(program);
10009
10010 if (!programObject)
10011 {
10012 if (context->getShader(program))
10013 {
10014 return gl::error(GL_INVALID_OPERATION);
10015 }
10016 else
10017 {
10018 return gl::error(GL_INVALID_VALUE);
10019 }
10020 }
10021
10022 switch (pname)
10023 {
10024 case GL_UNIFORM_TYPE:
10025 case GL_UNIFORM_SIZE:
10026 case GL_UNIFORM_NAME_LENGTH:
10027 case GL_UNIFORM_BLOCK_INDEX:
10028 case GL_UNIFORM_OFFSET:
10029 case GL_UNIFORM_ARRAY_STRIDE:
10030 case GL_UNIFORM_MATRIX_STRIDE:
10031 case GL_UNIFORM_IS_ROW_MAJOR:
10032 break;
10033 default:
10034 return gl::error(GL_INVALID_ENUM);
10035 }
10036
10037 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10038
10039 if (!programBinary && uniformCount > 0)
10040 {
10041 return gl::error(GL_INVALID_VALUE);
10042 }
10043
10044 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10045 {
10046 const GLuint index = uniformIndices[uniformId];
10047
10048 if (index >= (GLuint)programBinary->getActiveUniformCount())
10049 {
10050 return gl::error(GL_INVALID_VALUE);
10051 }
10052 }
10053
10054 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10055 {
10056 const GLuint index = uniformIndices[uniformId];
10057 params[uniformId] = programBinary->getActiveUniformi(index, pname);
10058 }
10059 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010060 }
10061 catch(std::bad_alloc&)
10062 {
10063 return gl::error(GL_OUT_OF_MEMORY);
10064 }
10065}
10066
10067GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
10068{
10069 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
10070
10071 try
10072 {
10073 gl::Context *context = gl::getNonLostContext();
10074
10075 if (context)
10076 {
10077 if (context->getClientVersion() < 3)
10078 {
shannonwoods@chromium.org42766252013-05-30 00:07:12 +000010079 return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010080 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010081
shannonwoods@chromium.org42766252013-05-30 00:07:12 +000010082 gl::Program *programObject = context->getProgram(program);
10083
10084 if (!programObject)
10085 {
10086 if (context->getShader(program))
10087 {
10088 return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
10089 }
10090 else
10091 {
10092 return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX);
10093 }
10094 }
10095
10096 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10097 if (!programBinary)
10098 {
10099 return GL_INVALID_INDEX;
10100 }
10101
10102 return programBinary->getUniformBlockIndex(uniformBlockName);
10103 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010104 }
10105 catch(std::bad_alloc&)
10106 {
10107 return gl::error(GL_OUT_OF_MEMORY, 0);
10108 }
10109
10110 return 0;
10111}
10112
10113void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
10114{
10115 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
10116 program, uniformBlockIndex, pname, params);
10117
10118 try
10119 {
10120 gl::Context *context = gl::getNonLostContext();
10121
10122 if (context)
10123 {
10124 if (context->getClientVersion() < 3)
10125 {
10126 return gl::error(GL_INVALID_OPERATION);
10127 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +000010128 gl::Program *programObject = context->getProgram(program);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010129
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +000010130 if (!programObject)
10131 {
10132 if (context->getShader(program))
10133 {
10134 return gl::error(GL_INVALID_OPERATION);
10135 }
10136 else
10137 {
10138 return gl::error(GL_INVALID_VALUE);
10139 }
10140 }
10141
10142 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10143
10144 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
10145 {
10146 return gl::error(GL_INVALID_VALUE);
10147 }
10148
10149 switch (pname)
10150 {
10151 case GL_UNIFORM_BLOCK_BINDING:
10152 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
10153 break;
10154
10155 case GL_UNIFORM_BLOCK_DATA_SIZE:
10156 case GL_UNIFORM_BLOCK_NAME_LENGTH:
10157 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
10158 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
10159 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
10160 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
10161 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
10162 break;
10163
10164 default:
10165 return gl::error(GL_INVALID_ENUM);
10166 }
10167 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010168 }
10169 catch(std::bad_alloc&)
10170 {
10171 return gl::error(GL_OUT_OF_MEMORY);
10172 }
10173}
10174
10175void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
10176{
10177 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
10178 program, uniformBlockIndex, bufSize, length, uniformBlockName);
10179
10180 try
10181 {
10182 gl::Context *context = gl::getNonLostContext();
10183
10184 if (context)
10185 {
10186 if (context->getClientVersion() < 3)
10187 {
10188 return gl::error(GL_INVALID_OPERATION);
10189 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010190
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +000010191 gl::Program *programObject = context->getProgram(program);
10192
10193 if (!programObject)
10194 {
10195 if (context->getShader(program))
10196 {
10197 return gl::error(GL_INVALID_OPERATION);
10198 }
10199 else
10200 {
10201 return gl::error(GL_INVALID_VALUE);
10202 }
10203 }
10204
10205 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10206
10207 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
10208 {
10209 return gl::error(GL_INVALID_VALUE);
10210 }
10211
10212 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
10213 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010214 }
10215 catch(std::bad_alloc&)
10216 {
10217 return gl::error(GL_OUT_OF_MEMORY);
10218 }
10219}
10220
10221void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
10222{
10223 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
10224 program, uniformBlockIndex, uniformBlockBinding);
10225
10226 try
10227 {
10228 gl::Context *context = gl::getNonLostContext();
10229
10230 if (context)
10231 {
10232 if (context->getClientVersion() < 3)
10233 {
10234 return gl::error(GL_INVALID_OPERATION);
10235 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010236
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +000010237 if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings())
10238 {
10239 return gl::error(GL_INVALID_VALUE);
10240 }
10241
10242 gl::Program *programObject = context->getProgram(program);
10243
10244 if (!programObject)
10245 {
10246 if (context->getShader(program))
10247 {
10248 return gl::error(GL_INVALID_OPERATION);
10249 }
10250 else
10251 {
10252 return gl::error(GL_INVALID_VALUE);
10253 }
10254 }
10255
10256 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10257
10258 // if never linked, there won't be any uniform blocks
10259 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
10260 {
10261 return gl::error(GL_INVALID_VALUE);
10262 }
10263
10264 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
10265 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010266 }
10267 catch(std::bad_alloc&)
10268 {
10269 return gl::error(GL_OUT_OF_MEMORY);
10270 }
10271}
10272
10273void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
10274{
10275 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
10276 mode, first, count, instanceCount);
10277
10278 try
10279 {
10280 gl::Context *context = gl::getNonLostContext();
10281
10282 if (context)
10283 {
10284 if (context->getClientVersion() < 3)
10285 {
10286 return gl::error(GL_INVALID_OPERATION);
10287 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010288
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010289 UNIMPLEMENTED();
10290 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010291 }
10292 catch(std::bad_alloc&)
10293 {
10294 return gl::error(GL_OUT_OF_MEMORY);
10295 }
10296}
10297
10298void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
10299{
10300 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
10301 mode, count, type, indices, instanceCount);
10302
10303 try
10304 {
10305 gl::Context *context = gl::getNonLostContext();
10306
10307 if (context)
10308 {
10309 if (context->getClientVersion() < 3)
10310 {
10311 return gl::error(GL_INVALID_OPERATION);
10312 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010313
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010314 UNIMPLEMENTED();
10315 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010316 }
10317 catch(std::bad_alloc&)
10318 {
10319 return gl::error(GL_OUT_OF_MEMORY);
10320 }
10321}
10322
10323GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags)
10324{
10325 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
10326
10327 try
10328 {
10329 gl::Context *context = gl::getNonLostContext();
10330
10331 if (context)
10332 {
10333 if (context->getClientVersion() < 3)
10334 {
10335 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(NULL));
10336 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010337
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010338 UNIMPLEMENTED();
10339 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010340 }
10341 catch(std::bad_alloc&)
10342 {
10343 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL));
10344 }
10345
10346 return NULL;
10347}
10348
10349GLboolean __stdcall glIsSync(GLsync sync)
10350{
10351 EVENT("(GLsync sync = 0x%0.8p)", sync);
10352
10353 try
10354 {
10355 gl::Context *context = gl::getNonLostContext();
10356
10357 if (context)
10358 {
10359 if (context->getClientVersion() < 3)
10360 {
10361 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10362 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010363
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010364 UNIMPLEMENTED();
10365 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010366 }
10367 catch(std::bad_alloc&)
10368 {
10369 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10370 }
10371
10372 return GL_FALSE;
10373}
10374
10375void __stdcall glDeleteSync(GLsync sync)
10376{
10377 EVENT("(GLsync sync = 0x%0.8p)", sync);
10378
10379 try
10380 {
10381 gl::Context *context = gl::getNonLostContext();
10382
10383 if (context)
10384 {
10385 if (context->getClientVersion() < 3)
10386 {
10387 return gl::error(GL_INVALID_OPERATION);
10388 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010389
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010390 UNIMPLEMENTED();
10391 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010392 }
10393 catch(std::bad_alloc&)
10394 {
10395 return gl::error(GL_OUT_OF_MEMORY);
10396 }
10397}
10398
10399GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
10400{
10401 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
10402 sync, flags, timeout);
10403
10404 try
10405 {
10406 gl::Context *context = gl::getNonLostContext();
10407
10408 if (context)
10409 {
10410 if (context->getClientVersion() < 3)
10411 {
10412 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10413 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010414
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010415 UNIMPLEMENTED();
10416 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010417 }
10418 catch(std::bad_alloc&)
10419 {
10420 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10421 }
10422
10423 return GL_FALSE;
10424}
10425
10426void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
10427{
10428 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
10429 sync, flags, timeout);
10430
10431 try
10432 {
10433 gl::Context *context = gl::getNonLostContext();
10434
10435 if (context)
10436 {
10437 if (context->getClientVersion() < 3)
10438 {
10439 return gl::error(GL_INVALID_OPERATION);
10440 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010441
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010442 UNIMPLEMENTED();
10443 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010444 }
10445 catch(std::bad_alloc&)
10446 {
10447 return gl::error(GL_OUT_OF_MEMORY);
10448 }
10449}
10450
10451void __stdcall glGetInteger64v(GLenum pname, GLint64* params)
10452{
10453 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
10454 pname, params);
10455
10456 try
10457 {
10458 gl::Context *context = gl::getNonLostContext();
10459
10460 if (context)
10461 {
10462 if (context->getClientVersion() < 3)
10463 {
10464 return gl::error(GL_INVALID_OPERATION);
10465 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010466
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010467 UNIMPLEMENTED();
10468 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010469 }
10470 catch(std::bad_alloc&)
10471 {
10472 return gl::error(GL_OUT_OF_MEMORY);
10473 }
10474}
10475
10476void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
10477{
10478 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
10479 sync, pname, bufSize, length, values);
10480
10481 try
10482 {
10483 gl::Context *context = gl::getNonLostContext();
10484
10485 if (context)
10486 {
10487 if (context->getClientVersion() < 3)
10488 {
10489 return gl::error(GL_INVALID_OPERATION);
10490 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010491
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010492 UNIMPLEMENTED();
10493 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010494 }
10495 catch(std::bad_alloc&)
10496 {
10497 return gl::error(GL_OUT_OF_MEMORY);
10498 }
10499}
10500
10501void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
10502{
10503 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
10504 target, index, data);
10505
10506 try
10507 {
10508 gl::Context *context = gl::getNonLostContext();
10509
10510 if (context)
10511 {
10512 if (context->getClientVersion() < 3)
10513 {
10514 return gl::error(GL_INVALID_OPERATION);
10515 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010516
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010517 UNIMPLEMENTED();
10518 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010519 }
10520 catch(std::bad_alloc&)
10521 {
10522 return gl::error(GL_OUT_OF_MEMORY);
10523 }
10524}
10525
10526void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
10527{
10528 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
10529 target, pname, params);
10530
10531 try
10532 {
10533 gl::Context *context = gl::getNonLostContext();
10534
10535 if (context)
10536 {
10537 if (context->getClientVersion() < 3)
10538 {
10539 return gl::error(GL_INVALID_OPERATION);
10540 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010541
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010542 UNIMPLEMENTED();
10543 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010544 }
10545 catch(std::bad_alloc&)
10546 {
10547 return gl::error(GL_OUT_OF_MEMORY);
10548 }
10549}
10550
10551void __stdcall glGenSamplers(GLsizei count, GLuint* samplers)
10552{
10553 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
10554
10555 try
10556 {
10557 gl::Context *context = gl::getNonLostContext();
10558
10559 if (context)
10560 {
10561 if (context->getClientVersion() < 3)
10562 {
10563 return gl::error(GL_INVALID_OPERATION);
10564 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010565
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010566 UNIMPLEMENTED();
10567 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010568 }
10569 catch(std::bad_alloc&)
10570 {
10571 return gl::error(GL_OUT_OF_MEMORY);
10572 }
10573}
10574
10575void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers)
10576{
10577 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
10578
10579 try
10580 {
10581 gl::Context *context = gl::getNonLostContext();
10582
10583 if (context)
10584 {
10585 if (context->getClientVersion() < 3)
10586 {
10587 return gl::error(GL_INVALID_OPERATION);
10588 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010589
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010590 UNIMPLEMENTED();
10591 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010592 }
10593 catch(std::bad_alloc&)
10594 {
10595 return gl::error(GL_OUT_OF_MEMORY);
10596 }
10597}
10598
10599GLboolean __stdcall glIsSampler(GLuint sampler)
10600{
10601 EVENT("(GLuint sampler = %u)", sampler);
10602
10603 try
10604 {
10605 gl::Context *context = gl::getNonLostContext();
10606
10607 if (context)
10608 {
10609 if (context->getClientVersion() < 3)
10610 {
10611 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10612 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010613
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010614 UNIMPLEMENTED();
10615 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010616 }
10617 catch(std::bad_alloc&)
10618 {
10619 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10620 }
10621
10622 return GL_FALSE;
10623}
10624
10625void __stdcall glBindSampler(GLuint unit, GLuint sampler)
10626{
10627 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
10628
10629 try
10630 {
10631 gl::Context *context = gl::getNonLostContext();
10632
10633 if (context)
10634 {
10635 if (context->getClientVersion() < 3)
10636 {
10637 return gl::error(GL_INVALID_OPERATION);
10638 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010639
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010640 UNIMPLEMENTED();
10641 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010642 }
10643 catch(std::bad_alloc&)
10644 {
10645 return gl::error(GL_OUT_OF_MEMORY);
10646 }
10647}
10648
10649void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
10650{
10651 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
10652
10653 try
10654 {
10655 gl::Context *context = gl::getNonLostContext();
10656
10657 if (context)
10658 {
10659 if (context->getClientVersion() < 3)
10660 {
10661 return gl::error(GL_INVALID_OPERATION);
10662 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010663
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010664 UNIMPLEMENTED();
10665 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010666 }
10667 catch(std::bad_alloc&)
10668 {
10669 return gl::error(GL_OUT_OF_MEMORY);
10670 }
10671}
10672
10673void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
10674{
10675 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLint* param = 0x%0.8p)",
10676 sampler, pname, param);
10677
10678 try
10679 {
10680 gl::Context *context = gl::getNonLostContext();
10681
10682 if (context)
10683 {
10684 if (context->getClientVersion() < 3)
10685 {
10686 return gl::error(GL_INVALID_OPERATION);
10687 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010688
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010689 UNIMPLEMENTED();
10690 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010691 }
10692 catch(std::bad_alloc&)
10693 {
10694 return gl::error(GL_OUT_OF_MEMORY);
10695 }
10696}
10697
10698void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
10699{
10700 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
10701
10702 try
10703 {
10704 gl::Context *context = gl::getNonLostContext();
10705
10706 if (context)
10707 {
10708 if (context->getClientVersion() < 3)
10709 {
10710 return gl::error(GL_INVALID_OPERATION);
10711 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010712
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010713 UNIMPLEMENTED();
10714 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010715 }
10716 catch(std::bad_alloc&)
10717 {
10718 return gl::error(GL_OUT_OF_MEMORY);
10719 }
10720}
10721
10722void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
10723{
10724 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLfloat* param = 0x%0.8p)", sampler, pname, param);
10725
10726 try
10727 {
10728 gl::Context *context = gl::getNonLostContext();
10729
10730 if (context)
10731 {
10732 if (context->getClientVersion() < 3)
10733 {
10734 return gl::error(GL_INVALID_OPERATION);
10735 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010736
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010737 UNIMPLEMENTED();
10738 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010739 }
10740 catch(std::bad_alloc&)
10741 {
10742 return gl::error(GL_OUT_OF_MEMORY);
10743 }
10744}
10745
10746void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
10747{
10748 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
10749
10750 try
10751 {
10752 gl::Context *context = gl::getNonLostContext();
10753
10754 if (context)
10755 {
10756 if (context->getClientVersion() < 3)
10757 {
10758 return gl::error(GL_INVALID_OPERATION);
10759 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010760
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010761 UNIMPLEMENTED();
10762 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010763 }
10764 catch(std::bad_alloc&)
10765 {
10766 return gl::error(GL_OUT_OF_MEMORY);
10767 }
10768}
10769
10770void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
10771{
10772 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
10773
10774 try
10775 {
10776 gl::Context *context = gl::getNonLostContext();
10777
10778 if (context)
10779 {
10780 if (context->getClientVersion() < 3)
10781 {
10782 return gl::error(GL_INVALID_OPERATION);
10783 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010784
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010785 UNIMPLEMENTED();
10786 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010787 }
10788 catch(std::bad_alloc&)
10789 {
10790 return gl::error(GL_OUT_OF_MEMORY);
10791 }
10792}
10793
10794void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor)
10795{
10796 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
10797
10798 try
10799 {
shannon.woods%transgaming.com@gtempaccount.com8736bd62013-04-13 03:35:41 +000010800 if (index >= gl::MAX_VERTEX_ATTRIBS)
10801 {
10802 return gl::error(GL_INVALID_VALUE);
10803 }
10804
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010805 gl::Context *context = gl::getNonLostContext();
10806
10807 if (context)
10808 {
10809 if (context->getClientVersion() < 3)
10810 {
10811 return gl::error(GL_INVALID_OPERATION);
10812 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010813
shannon.woods%transgaming.com@gtempaccount.com8736bd62013-04-13 03:35:41 +000010814 context->setVertexAttribDivisor(index, divisor);
10815 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010816 }
10817 catch(std::bad_alloc&)
10818 {
10819 return gl::error(GL_OUT_OF_MEMORY);
10820 }
10821}
10822
10823void __stdcall glBindTransformFeedback(GLenum target, GLuint id)
10824{
10825 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
10826
10827 try
10828 {
10829 gl::Context *context = gl::getNonLostContext();
10830
10831 if (context)
10832 {
10833 if (context->getClientVersion() < 3)
10834 {
10835 return gl::error(GL_INVALID_OPERATION);
10836 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010837
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010838 UNIMPLEMENTED();
10839 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010840 }
10841 catch(std::bad_alloc&)
10842 {
10843 return gl::error(GL_OUT_OF_MEMORY);
10844 }
10845}
10846
10847void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
10848{
10849 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
10850
10851 try
10852 {
10853 gl::Context *context = gl::getNonLostContext();
10854
10855 if (context)
10856 {
10857 if (context->getClientVersion() < 3)
10858 {
10859 return gl::error(GL_INVALID_OPERATION);
10860 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010861
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010862 UNIMPLEMENTED();
10863 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010864 }
10865 catch(std::bad_alloc&)
10866 {
10867 return gl::error(GL_OUT_OF_MEMORY);
10868 }
10869}
10870
10871void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids)
10872{
10873 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
10874
10875 try
10876 {
10877 gl::Context *context = gl::getNonLostContext();
10878
10879 if (context)
10880 {
10881 if (context->getClientVersion() < 3)
10882 {
10883 return gl::error(GL_INVALID_OPERATION);
10884 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010885
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010886 UNIMPLEMENTED();
10887 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010888 }
10889 catch(std::bad_alloc&)
10890 {
10891 return gl::error(GL_OUT_OF_MEMORY);
10892 }
10893}
10894
10895GLboolean __stdcall glIsTransformFeedback(GLuint id)
10896{
10897 EVENT("(GLuint id = %u)", id);
10898
10899 try
10900 {
10901 gl::Context *context = gl::getNonLostContext();
10902
10903 if (context)
10904 {
10905 if (context->getClientVersion() < 3)
10906 {
10907 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10908 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010909
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010910 UNIMPLEMENTED();
10911 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010912 }
10913 catch(std::bad_alloc&)
10914 {
10915 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10916 }
10917
10918 return GL_FALSE;
10919}
10920
10921void __stdcall glPauseTransformFeedback(void)
10922{
10923 EVENT("(void)");
10924
10925 try
10926 {
10927 gl::Context *context = gl::getNonLostContext();
10928
10929 if (context)
10930 {
10931 if (context->getClientVersion() < 3)
10932 {
10933 return gl::error(GL_INVALID_OPERATION);
10934 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010935
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010936 UNIMPLEMENTED();
10937 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010938 }
10939 catch(std::bad_alloc&)
10940 {
10941 return gl::error(GL_OUT_OF_MEMORY);
10942 }
10943}
10944
10945void __stdcall glResumeTransformFeedback(void)
10946{
10947 EVENT("(void)");
10948
10949 try
10950 {
10951 gl::Context *context = gl::getNonLostContext();
10952
10953 if (context)
10954 {
10955 if (context->getClientVersion() < 3)
10956 {
10957 return gl::error(GL_INVALID_OPERATION);
10958 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010959
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010960 UNIMPLEMENTED();
10961 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010962 }
10963 catch(std::bad_alloc&)
10964 {
10965 return gl::error(GL_OUT_OF_MEMORY);
10966 }
10967}
10968
10969void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
10970{
10971 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
10972 program, bufSize, length, binaryFormat, binary);
10973
10974 try
10975 {
10976 gl::Context *context = gl::getNonLostContext();
10977
10978 if (context)
10979 {
10980 if (context->getClientVersion() < 3)
10981 {
10982 return gl::error(GL_INVALID_OPERATION);
10983 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010984
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010985 UNIMPLEMENTED();
10986 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010987 }
10988 catch(std::bad_alloc&)
10989 {
10990 return gl::error(GL_OUT_OF_MEMORY);
10991 }
10992}
10993
10994void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
10995{
10996 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
10997 program, binaryFormat, binary, length);
10998
10999 try
11000 {
11001 gl::Context *context = gl::getNonLostContext();
11002
11003 if (context)
11004 {
11005 if (context->getClientVersion() < 3)
11006 {
11007 return gl::error(GL_INVALID_OPERATION);
11008 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011009
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011010 UNIMPLEMENTED();
11011 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011012 }
11013 catch(std::bad_alloc&)
11014 {
11015 return gl::error(GL_OUT_OF_MEMORY);
11016 }
11017}
11018
11019void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value)
11020{
11021 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
11022 program, pname, value);
11023
11024 try
11025 {
11026 gl::Context *context = gl::getNonLostContext();
11027
11028 if (context)
11029 {
11030 if (context->getClientVersion() < 3)
11031 {
11032 return gl::error(GL_INVALID_OPERATION);
11033 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011034
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011035 UNIMPLEMENTED();
11036 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011037 }
11038 catch(std::bad_alloc&)
11039 {
11040 return gl::error(GL_OUT_OF_MEMORY);
11041 }
11042}
11043
11044void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
11045{
11046 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
11047 target, numAttachments, attachments);
11048
11049 try
11050 {
11051 gl::Context *context = gl::getNonLostContext();
11052
11053 if (context)
11054 {
11055 if (context->getClientVersion() < 3)
11056 {
11057 return gl::error(GL_INVALID_OPERATION);
11058 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011059
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +000011060 if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
11061 {
11062 return;
11063 }
11064
11065 int maxDimension = context->getMaximumRenderbufferDimension();
11066 context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension);
11067 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011068 }
11069 catch(std::bad_alloc&)
11070 {
11071 return gl::error(GL_OUT_OF_MEMORY);
11072 }
11073}
11074
11075void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
11076{
11077 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
11078 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
11079 target, numAttachments, attachments, x, y, width, height);
11080
11081 try
11082 {
11083 gl::Context *context = gl::getNonLostContext();
11084
11085 if (context)
11086 {
11087 if (context->getClientVersion() < 3)
11088 {
11089 return gl::error(GL_INVALID_OPERATION);
11090 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011091
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +000011092 if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
11093 {
11094 return;
11095 }
11096
11097 context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height);
11098 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011099 }
11100 catch(std::bad_alloc&)
11101 {
11102 return gl::error(GL_OUT_OF_MEMORY);
11103 }
11104}
11105
11106void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
11107{
11108 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
11109 target, levels, internalformat, width, height);
11110
11111 try
11112 {
11113 gl::Context *context = gl::getNonLostContext();
11114
11115 if (context)
11116 {
11117 if (context->getClientVersion() < 3)
11118 {
11119 return gl::error(GL_INVALID_OPERATION);
11120 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011121
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +000011122 if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
11123 {
11124 return;
11125 }
11126
11127 switch (target)
11128 {
11129 case GL_TEXTURE_2D:
11130 {
11131 gl::Texture2D *texture2d = context->getTexture2D();
11132 texture2d->storage(levels, internalformat, width, height);
11133 }
11134 break;
11135
11136 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
11137 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
11138 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
11139 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
11140 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
11141 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
11142 {
11143 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
11144 textureCube->storage(levels, internalformat, width);
11145 }
11146 break;
11147
11148 default:
11149 return gl::error(GL_INVALID_ENUM);
11150 }
11151 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011152 }
11153 catch(std::bad_alloc&)
11154 {
11155 return gl::error(GL_OUT_OF_MEMORY);
11156 }
11157}
11158
11159void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
11160{
11161 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
11162 "GLsizei height = %d, GLsizei depth = %d)",
11163 target, levels, internalformat, width, height, depth);
11164
11165 try
11166 {
11167 gl::Context *context = gl::getNonLostContext();
11168
11169 if (context)
11170 {
11171 if (context->getClientVersion() < 3)
11172 {
11173 return gl::error(GL_INVALID_OPERATION);
11174 }
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +000011175
11176 if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
11177 {
11178 return;
11179 }
11180
11181 switch (target)
11182 {
11183 case GL_TEXTURE_3D:
11184 {
11185 gl::Texture3D *texture3d = context->getTexture3D();
11186 texture3d->storage(levels, internalformat, width, height, depth);
11187 }
11188 break;
11189
11190 case GL_TEXTURE_2D_ARRAY:
11191 {
11192 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
11193 texture2darray->storage(levels, internalformat, width, height, depth);
11194 }
11195 break;
11196
11197 default:
11198 return gl::error(GL_INVALID_ENUM);
11199 }
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +000011200 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011201 }
11202 catch(std::bad_alloc&)
11203 {
11204 return gl::error(GL_OUT_OF_MEMORY);
11205 }
11206}
11207
11208void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
11209{
11210 EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
11211 "GLint* params = 0x%0.8p)",
11212 target, internalformat, pname, bufSize, params);
11213
11214 try
11215 {
11216 gl::Context *context = gl::getNonLostContext();
11217
11218 if (context)
11219 {
11220 if (context->getClientVersion() < 3)
11221 {
11222 return gl::error(GL_INVALID_OPERATION);
11223 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011224
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011225 UNIMPLEMENTED();
11226 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011227 }
11228 catch(std::bad_alloc&)
11229 {
11230 return gl::error(GL_OUT_OF_MEMORY);
11231 }
11232}
11233
11234// Extension functions
11235
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011236void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
11237 GLbitfield mask, GLenum filter)
11238{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000011239 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011240 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
11241 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
11242 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
11243
11244 try
11245 {
11246 switch (filter)
11247 {
11248 case GL_NEAREST:
11249 break;
11250 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011251 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011252 }
11253
11254 if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0)
11255 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011256 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011257 }
11258
11259 if (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0)
11260 {
11261 ERR("Scaling and flipping in BlitFramebufferANGLE not supported by this implementation");
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011262 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011263 }
11264
daniel@transgaming.com9d788502011-11-09 17:46:55 +000011265 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011266
11267 if (context)
11268 {
11269 if (context->getReadFramebufferHandle() == context->getDrawFramebufferHandle())
11270 {
11271 ERR("Blits with the same source and destination framebuffer are not supported by this implementation.");
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011272 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011273 }
11274
11275 context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask);
11276 }
11277 }
11278 catch(std::bad_alloc&)
11279 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011280 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011281 }
11282}
11283
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +000011284void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
11285 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011286{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000011287 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +000011288 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +000011289 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011290 target, level, internalformat, width, height, depth, border, format, type, pixels);
11291
11292 try
11293 {
11294 UNIMPLEMENTED(); // FIXME
11295 }
11296 catch(std::bad_alloc&)
11297 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011298 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011299 }
11300}
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011301
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011302void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
11303 GLenum *binaryFormat, void *binary)
11304{
apatrick@chromium.org90080e32012-07-09 22:15:33 +000011305 EVENT("(GLenum program = 0x%X, bufSize = %d, length = 0x%0.8p, binaryFormat = 0x%0.8p, binary = 0x%0.8p)",
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011306 program, bufSize, length, binaryFormat, binary);
11307
11308 try
11309 {
11310 gl::Context *context = gl::getNonLostContext();
11311
11312 if (context)
11313 {
11314 gl::Program *programObject = context->getProgram(program);
11315
daniel@transgaming.com716056c2012-07-24 18:38:59 +000011316 if (!programObject || !programObject->isLinked())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011317 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011318 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011319 }
11320
11321 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
11322
11323 if (!programBinary)
11324 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011325 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011326 }
11327
apatrick@chromium.org90080e32012-07-09 22:15:33 +000011328 if (!programBinary->save(binary, bufSize, length))
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011329 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011330 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011331 }
apatrick@chromium.org90080e32012-07-09 22:15:33 +000011332
11333 *binaryFormat = GL_PROGRAM_BINARY_ANGLE;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011334 }
11335 }
11336 catch(std::bad_alloc&)
11337 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011338 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011339 }
11340}
11341
11342void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat,
11343 const void *binary, GLint length)
11344{
11345 EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
11346 program, binaryFormat, binary, length);
11347
11348 try
11349 {
11350 gl::Context *context = gl::getNonLostContext();
11351
11352 if (context)
11353 {
11354 if (binaryFormat != GL_PROGRAM_BINARY_ANGLE)
11355 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011356 return gl::error(GL_INVALID_ENUM);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011357 }
11358
11359 gl::Program *programObject = context->getProgram(program);
11360
11361 if (!programObject)
11362 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011363 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011364 }
11365
daniel@transgaming.com95d29422012-07-24 18:36:10 +000011366 context->setProgramBinary(program, binary, length);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011367 }
11368 }
11369 catch(std::bad_alloc&)
11370 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011371 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011372 }
11373}
11374
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011375void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
11376{
11377 EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
11378
11379 try
11380 {
11381 gl::Context *context = gl::getNonLostContext();
11382
11383 if (context)
11384 {
11385 if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets())
11386 {
11387 return gl::error(GL_INVALID_VALUE);
11388 }
11389
11390 if (context->getDrawFramebufferHandle() == 0)
11391 {
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011392 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011393 {
11394 return gl::error(GL_INVALID_OPERATION);
11395 }
11396
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011397 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011398 {
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011399 return gl::error(GL_INVALID_OPERATION);
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011400 }
11401 }
11402 else
11403 {
11404 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
11405 {
11406 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
11407 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
11408 {
11409 return gl::error(GL_INVALID_OPERATION);
11410 }
11411 }
11412 }
11413
11414 gl::Framebuffer *framebuffer = context->getDrawFramebuffer();
11415
11416 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
11417 {
11418 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
11419 }
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011420
11421 for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++)
11422 {
11423 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
11424 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011425 }
11426 }
11427 catch (std::bad_alloc&)
11428 {
11429 return gl::error(GL_OUT_OF_MEMORY);
11430 }
11431}
11432
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011433__eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname)
11434{
11435 struct Extension
11436 {
11437 const char *name;
11438 __eglMustCastToProperFunctionPointerType address;
11439 };
11440
11441 static const Extension glExtensions[] =
11442 {
11443 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +000011444 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +000011445 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000011446 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
11447 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
11448 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
11449 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
11450 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
11451 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
11452 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +000011453 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +000011454 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +000011455 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
11456 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
11457 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
11458 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000011459 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
11460 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
11461 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
11462 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
11463 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
11464 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
11465 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +000011466 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +000011467 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
11468 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
11469 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011470 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
11471 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011472
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +000011473 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011474 {
11475 if (strcmp(procname, glExtensions[ext].name) == 0)
11476 {
11477 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
11478 }
11479 }
11480
11481 return NULL;
11482}
11483
daniel@transgaming.com17f548c2011-11-09 17:47:02 +000011484// Non-public functions used by EGL
11485
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000011486bool __stdcall glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011487{
11488 EVENT("(egl::Surface* surface = 0x%0.8p)",
11489 surface);
11490
11491 try
11492 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +000011493 gl::Context *context = gl::getNonLostContext();
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011494
11495 if (context)
11496 {
11497 gl::Texture2D *textureObject = context->getTexture2D();
11498
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000011499 if (textureObject->isImmutable())
11500 {
11501 return false;
11502 }
11503
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011504 if (textureObject)
11505 {
11506 textureObject->bindTexImage(surface);
11507 }
11508 }
11509 }
11510 catch(std::bad_alloc&)
11511 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011512 return gl::error(GL_OUT_OF_MEMORY, false);
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011513 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000011514
11515 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011516}
11517
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011518}