blob: 349cb8861ba2f73bd7c6f5a7a2b0ccdd02cb2422 [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"
Jamie Madill57a89722013-07-02 11:57:03 -040024#include "libGLESv2/VertexArray.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000025
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +000026bool validImageSize(const gl::Context *context, GLint level, GLsizei width, GLsizei height, GLsizei depth)
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000027{
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +000028 if (level < 0 || width < 0 || height < 0 || depth < 0)
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000029 {
30 return false;
31 }
32
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +000033 if (context->supportsNonPower2Texture())
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000034 {
35 return true;
36 }
37
38 if (level == 0)
39 {
40 return true;
41 }
42
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +000043 if (gl::isPow2(width) && gl::isPow2(height) && gl::isPow2(depth))
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000044 {
45 return true;
46 }
47
48 return false;
49}
50
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +000051bool validCompressedImageSize(GLsizei width, GLsizei height)
52{
53 if (width != 1 && width != 2 && width % 4 != 0)
54 {
55 return false;
56 }
57
58 if (height != 1 && height != 2 && height % 4 != 0)
59 {
60 return false;
61 }
62
63 return true;
64}
65
daniel@transgaming.com8833dd22012-06-05 19:49:58 +000066// Verify that format/type are one of the combinations from table 3.4.
67bool checkTextureFormatType(GLenum format, GLenum type)
68{
69 // validate <format> by itself (used as secondary key below)
70 switch (format)
71 {
72 case GL_RGBA:
73 case GL_BGRA_EXT:
74 case GL_RGB:
75 case GL_ALPHA:
76 case GL_LUMINANCE:
77 case GL_LUMINANCE_ALPHA:
78 case GL_DEPTH_COMPONENT:
79 case GL_DEPTH_STENCIL_OES:
80 break;
81 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000082 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +000083 }
84
85 // invalid <type> -> sets INVALID_ENUM
86 // invalid <format>+<type> combination -> sets INVALID_OPERATION
87 switch (type)
88 {
89 case GL_UNSIGNED_BYTE:
90 switch (format)
91 {
92 case GL_RGBA:
93 case GL_BGRA_EXT:
94 case GL_RGB:
95 case GL_ALPHA:
96 case GL_LUMINANCE:
97 case GL_LUMINANCE_ALPHA:
98 return true;
99 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000100 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000101 }
102
103 case GL_FLOAT:
104 case GL_HALF_FLOAT_OES:
105 switch (format)
106 {
107 case GL_RGBA:
108 case GL_RGB:
109 case GL_ALPHA:
110 case GL_LUMINANCE:
111 case GL_LUMINANCE_ALPHA:
112 return true;
113 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000114 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000115 }
116
117 case GL_UNSIGNED_SHORT_4_4_4_4:
118 case GL_UNSIGNED_SHORT_5_5_5_1:
119 switch (format)
120 {
121 case GL_RGBA:
122 return true;
123 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000124 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000125 }
126
127 case GL_UNSIGNED_SHORT_5_6_5:
128 switch (format)
129 {
130 case GL_RGB:
131 return true;
132 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000133 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000134 }
135
136 case GL_UNSIGNED_SHORT:
137 case GL_UNSIGNED_INT:
138 switch (format)
139 {
140 case GL_DEPTH_COMPONENT:
141 return true;
142 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000143 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000144 }
145
146 case GL_UNSIGNED_INT_24_8_OES:
147 switch (format)
148 {
149 case GL_DEPTH_STENCIL_OES:
150 return true;
151 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000152 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000153 }
154
155 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000156 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000157 }
158}
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000159
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000160bool validateSubImageParams2D(bool compressed, GLsizei width, GLsizei height,
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000161 GLint xoffset, GLint yoffset, GLint level, GLenum format, GLenum type,
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000162 gl::Texture2D *texture)
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000163{
164 if (!texture)
165 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000166 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000167 }
168
daniel@transgaming.com92f49922012-05-09 15:49:19 +0000169 if (compressed != texture->isCompressed(level))
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000170 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000171 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000172 }
173
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000174 if (format != GL_NONE)
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000175 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000176 GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000177 if (internalformat != texture->getInternalFormat(level))
178 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000179 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000180 }
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000181 }
182
183 if (compressed)
184 {
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000185 if ((width % 4 != 0 && width != texture->getWidth(0)) ||
186 (height % 4 != 0 && height != texture->getHeight(0)))
187 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000188 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000189 }
190 }
191
192 if (xoffset + width > texture->getWidth(level) ||
193 yoffset + height > texture->getHeight(level))
194 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000195 return gl::error(GL_INVALID_VALUE, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000196 }
197
198 return true;
199}
200
201bool validateSubImageParamsCube(bool compressed, GLsizei width, GLsizei height,
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000202 GLint xoffset, GLint yoffset, GLenum target, GLint level, GLenum format, GLenum type,
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000203 gl::TextureCubeMap *texture)
204{
205 if (!texture)
206 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000207 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000208 }
209
daniel@transgaming.com4df88e82012-05-09 15:49:24 +0000210 if (compressed != texture->isCompressed(target, level))
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000211 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000212 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000213 }
214
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000215 if (format != GL_NONE)
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000216 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000217 GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000218 if (internalformat != texture->getInternalFormat(target, level))
219 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000220 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000221 }
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000222 }
223
224 if (compressed)
225 {
daniel@transgaming.com4df88e82012-05-09 15:49:24 +0000226 if ((width % 4 != 0 && width != texture->getWidth(target, 0)) ||
227 (height % 4 != 0 && height != texture->getHeight(target, 0)))
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000228 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000229 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000230 }
231 }
232
daniel@transgaming.com4df88e82012-05-09 15:49:24 +0000233 if (xoffset + width > texture->getWidth(target, level) ||
234 yoffset + height > texture->getHeight(target, level))
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000235 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000236 return gl::error(GL_INVALID_VALUE, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000237 }
238
239 return true;
240}
241
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000242bool validateES2TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage,
243 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
244 GLint border, GLenum format, GLenum type, const GLvoid *pixels)
245{
246 if (!validImageSize(context, level, width, height, 1))
247 {
248 return gl::error(GL_INVALID_VALUE, false);
249 }
250
251 if (isCompressed && !validCompressedImageSize(width, height))
252 {
253 return gl::error(GL_INVALID_OPERATION, false);
254 }
255
256 if (level < 0 || xoffset < 0 ||
257 std::numeric_limits<GLsizei>::max() - xoffset < width ||
258 std::numeric_limits<GLsizei>::max() - yoffset < height)
259 {
260 return gl::error(GL_INVALID_VALUE, false);
261 }
262
263 if (!isSubImage && !isCompressed && internalformat != GLint(format))
264 {
265 return gl::error(GL_INVALID_OPERATION, false);
266 }
267
268 gl::Texture *texture = NULL;
269 bool textureCompressed = false;
270 GLenum textureInternalFormat = GL_NONE;
271 GLint textureLevelWidth = 0;
272 GLint textureLevelHeight = 0;
273 switch (target)
274 {
275 case GL_TEXTURE_2D:
276 {
277 if (width > (context->getMaximum2DTextureDimension() >> level) ||
278 height > (context->getMaximum2DTextureDimension() >> level))
279 {
280 return gl::error(GL_INVALID_VALUE, false);
281 }
282
283 gl::Texture2D *tex2d = context->getTexture2D();
284 if (tex2d)
285 {
286 textureCompressed = tex2d->isCompressed(level);
287 textureInternalFormat = tex2d->getInternalFormat(level);
288 textureLevelWidth = tex2d->getWidth(level);
289 textureLevelHeight = tex2d->getHeight(level);
290 texture = tex2d;
291 }
292
293 if (isSubImage && !validateSubImageParams2D(isCompressed, width, height, xoffset, yoffset,
294 level, format, type, tex2d))
295 {
296 return false;
297 }
298
299 texture = tex2d;
300 }
301 break;
302
303 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
304 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
305 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
306 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
307 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
308 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
309 {
310 if (!isSubImage && width != height)
311 {
312 return gl::error(GL_INVALID_VALUE, false);
313 }
314
315 if (width > (context->getMaximumCubeTextureDimension() >> level) ||
316 height > (context->getMaximumCubeTextureDimension() >> level))
317 {
318 return gl::error(GL_INVALID_VALUE, false);
319 }
320
321 gl::TextureCubeMap *texCube = context->getTextureCubeMap();
322 if (texCube)
323 {
324 textureCompressed = texCube->isCompressed(target, level);
325 textureInternalFormat = texCube->getInternalFormat(target, level);
326 textureLevelWidth = texCube->getWidth(target, level);
327 textureLevelHeight = texCube->getHeight(target, level);
328 texture = texCube;
329 }
330
331 if (isSubImage && !validateSubImageParamsCube(isCompressed, width, height, xoffset, yoffset,
332 target, level, format, type, texCube))
333 {
334 return false;
335 }
336 }
337 break;
338
339 default:
340 return gl::error(GL_INVALID_ENUM, false);
341 }
342
343 if (!texture)
344 {
345 return gl::error(GL_INVALID_OPERATION, false);
346 }
347
348 if (!isSubImage && texture->isImmutable())
349 {
350 return gl::error(GL_INVALID_OPERATION, false);
351 }
352
353 // Verify zero border
354 if (border != 0)
355 {
356 return gl::error(GL_INVALID_VALUE, false);
357 }
358
359 // Verify texture is not requesting more mip levels than are available.
360 if (level > context->getMaximumTextureLevel())
361 {
362 return gl::error(GL_INVALID_VALUE, false);
363 }
364
365 GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat;
366 if (isCompressed)
367 {
368 switch (actualInternalFormat)
369 {
370 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
371 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
372 if (!context->supportsDXT1Textures())
373 {
374 return gl::error(GL_INVALID_ENUM, false);
375 }
376 break;
377 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
378 if (!context->supportsDXT3Textures())
379 {
380 return gl::error(GL_INVALID_ENUM, false);
381 }
382 break;
383 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
384 if (!context->supportsDXT5Textures())
385 {
386 return gl::error(GL_INVALID_ENUM, false);
387 }
388 break;
389 default:
390 return gl::error(GL_INVALID_ENUM, false);
391 }
392 }
393 else
394 {
395 // validate <type> by itself (used as secondary key below)
396 switch (type)
397 {
398 case GL_UNSIGNED_BYTE:
399 case GL_UNSIGNED_SHORT_5_6_5:
400 case GL_UNSIGNED_SHORT_4_4_4_4:
401 case GL_UNSIGNED_SHORT_5_5_5_1:
402 case GL_UNSIGNED_SHORT:
403 case GL_UNSIGNED_INT:
404 case GL_UNSIGNED_INT_24_8_OES:
405 case GL_HALF_FLOAT_OES:
406 case GL_FLOAT:
407 break;
408 default:
409 return gl::error(GL_INVALID_ENUM, false);
410 }
411
412 // validate <format> + <type> combinations
413 // - invalid <format> -> sets INVALID_ENUM
414 // - invalid <format>+<type> combination -> sets INVALID_OPERATION
415 switch (format)
416 {
417 case GL_ALPHA:
418 case GL_LUMINANCE:
419 case GL_LUMINANCE_ALPHA:
420 switch (type)
421 {
422 case GL_UNSIGNED_BYTE:
423 case GL_FLOAT:
424 case GL_HALF_FLOAT_OES:
425 break;
426 default:
427 return gl::error(GL_INVALID_OPERATION, false);
428 }
429 break;
430 case GL_RGB:
431 switch (type)
432 {
433 case GL_UNSIGNED_BYTE:
434 case GL_UNSIGNED_SHORT_5_6_5:
435 case GL_FLOAT:
436 case GL_HALF_FLOAT_OES:
437 break;
438 default:
439 return gl::error(GL_INVALID_OPERATION, false);
440 }
441 break;
442 case GL_RGBA:
443 switch (type)
444 {
445 case GL_UNSIGNED_BYTE:
446 case GL_UNSIGNED_SHORT_4_4_4_4:
447 case GL_UNSIGNED_SHORT_5_5_5_1:
448 case GL_FLOAT:
449 case GL_HALF_FLOAT_OES:
450 break;
451 default:
452 return gl::error(GL_INVALID_OPERATION, false);
453 }
454 break;
455 case GL_BGRA_EXT:
456 switch (type)
457 {
458 case GL_UNSIGNED_BYTE:
459 break;
460 default:
461 return gl::error(GL_INVALID_OPERATION, false);
462 }
463 break;
464 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below
465 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
466 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
467 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
468 break;
469 case GL_DEPTH_COMPONENT:
470 switch (type)
471 {
472 case GL_UNSIGNED_SHORT:
473 case GL_UNSIGNED_INT:
474 break;
475 default:
476 return gl::error(GL_INVALID_OPERATION, false);
477 }
478 break;
479 case GL_DEPTH_STENCIL_OES:
480 switch (type)
481 {
482 case GL_UNSIGNED_INT_24_8_OES:
483 break;
484 default:
485 return gl::error(GL_INVALID_OPERATION, false);
486 }
487 break;
488 default:
489 return gl::error(GL_INVALID_ENUM, false);
490 }
491
492 switch (format)
493 {
494 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
495 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
496 if (context->supportsDXT1Textures())
497 {
498 return gl::error(GL_INVALID_OPERATION, false);
499 }
500 else
501 {
502 return gl::error(GL_INVALID_ENUM, false);
503 }
504 break;
505 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
506 if (context->supportsDXT3Textures())
507 {
508 return gl::error(GL_INVALID_OPERATION, false);
509 }
510 else
511 {
512 return gl::error(GL_INVALID_ENUM, false);
513 }
514 break;
515 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
516 if (context->supportsDXT5Textures())
517 {
518 return gl::error(GL_INVALID_OPERATION, false);
519 }
520 else
521 {
522 return gl::error(GL_INVALID_ENUM, false);
523 }
524 break;
525 case GL_DEPTH_COMPONENT:
526 case GL_DEPTH_STENCIL_OES:
527 if (!context->supportsDepthTextures())
528 {
529 return gl::error(GL_INVALID_VALUE, false);
530 }
531 if (target != GL_TEXTURE_2D)
532 {
533 return gl::error(GL_INVALID_OPERATION, false);
534 }
535 // OES_depth_texture supports loading depth data and multiple levels,
536 // but ANGLE_depth_texture does not
537 if (pixels != NULL || level != 0)
538 {
539 return gl::error(GL_INVALID_OPERATION, false);
540 }
541 break;
542 default:
543 break;
544 }
545
546 if (type == GL_FLOAT)
547 {
548 if (!context->supportsFloat32Textures())
549 {
550 return gl::error(GL_INVALID_ENUM, false);
551 }
552 }
553 else if (type == GL_HALF_FLOAT_OES)
554 {
555 if (!context->supportsFloat16Textures())
556 {
557 return gl::error(GL_INVALID_ENUM, false);
558 }
559 }
560 }
561
562 return true;
563}
564
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +0000565bool validateES3TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage,
566 GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
567 GLint border, GLenum format, GLenum type)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000568{
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000569 // Validate image size
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000570 if (!validImageSize(context, level, width, height, depth))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000571 {
572 return gl::error(GL_INVALID_VALUE, false);
573 }
574
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000575 if (isCompressed && !validCompressedImageSize(width, height))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000576 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000577 return gl::error(GL_INVALID_OPERATION, false);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000578 }
579
580 // Verify zero border
581 if (border != 0)
582 {
583 return gl::error(GL_INVALID_VALUE, false);
584 }
585
586 // Validate dimensions based on Context limits and validate the texture
587 if (level > context->getMaximumTextureLevel())
588 {
589 return gl::error(GL_INVALID_VALUE, false);
590 }
591
592 gl::Texture *texture = NULL;
593 bool textureCompressed = false;
594 GLenum textureInternalFormat = GL_NONE;
595 GLint textureLevelWidth = 0;
596 GLint textureLevelHeight = 0;
597 GLint textureLevelDepth = 0;
598 switch (target)
599 {
600 case GL_TEXTURE_2D:
601 {
602 if (width > (context->getMaximum2DTextureDimension() >> level) ||
603 height > (context->getMaximum2DTextureDimension() >> level))
604 {
605 return gl::error(GL_INVALID_VALUE, false);
606 }
607
608 gl::Texture2D *texture2d = context->getTexture2D();
609 if (texture2d)
610 {
611 textureCompressed = texture2d->isCompressed(level);
612 textureInternalFormat = texture2d->getInternalFormat(level);
613 textureLevelWidth = texture2d->getWidth(level);
614 textureLevelHeight = texture2d->getHeight(level);
615 textureLevelDepth = 1;
616 texture = texture2d;
617 }
618 }
619 break;
620
621 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
622 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
623 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
624 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
625 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
626 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
627 {
shannonwoods@chromium.org92852cf2013-05-30 00:14:12 +0000628 if (!isSubImage && width != height)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000629 {
630 return gl::error(GL_INVALID_VALUE, false);
631 }
632
633 if (width > (context->getMaximumCubeTextureDimension() >> level))
634 {
635 return gl::error(GL_INVALID_VALUE, false);
636 }
637
638 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
639 if (textureCube)
640 {
641 textureCompressed = textureCube->isCompressed(target, level);
642 textureInternalFormat = textureCube->getInternalFormat(target, level);
643 textureLevelWidth = textureCube->getWidth(target, level);
644 textureLevelHeight = textureCube->getHeight(target, level);
645 textureLevelDepth = 1;
646 texture = textureCube;
647 }
648 }
649 break;
650
651 case GL_TEXTURE_3D:
652 {
653 if (width > (context->getMaximum3DTextureDimension() >> level) ||
654 height > (context->getMaximum3DTextureDimension() >> level) ||
655 depth > (context->getMaximum3DTextureDimension() >> level))
656 {
657 return gl::error(GL_INVALID_VALUE, false);
658 }
659
660 gl::Texture3D *texture3d = context->getTexture3D();
661 if (texture3d)
662 {
663 textureCompressed = texture3d->isCompressed(level);
664 textureInternalFormat = texture3d->getInternalFormat(level);
665 textureLevelWidth = texture3d->getWidth(level);
666 textureLevelHeight = texture3d->getHeight(level);
667 textureLevelDepth = texture3d->getDepth(level);
668 texture = texture3d;
669 }
670 }
671 break;
672
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +0000673 case GL_TEXTURE_2D_ARRAY:
674 {
675 if (width > (context->getMaximum2DTextureDimension() >> level) ||
676 height > (context->getMaximum2DTextureDimension() >> level) ||
677 depth > (context->getMaximum2DArrayTextureLayers() >> level))
678 {
679 return gl::error(GL_INVALID_VALUE, false);
680 }
681
682 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
683 if (texture2darray)
684 {
685 textureCompressed = texture2darray->isCompressed(level);
686 textureInternalFormat = texture2darray->getInternalFormat(level);
687 textureLevelWidth = texture2darray->getWidth(level);
688 textureLevelHeight = texture2darray->getHeight(level);
689 textureLevelDepth = texture2darray->getDepth(level);
690 texture = texture2darray;
691 }
692 }
693 break;
694
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000695 default:
696 return gl::error(GL_INVALID_ENUM, false);
697 }
698
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000699 if (!texture)
700 {
701 return gl::error(GL_INVALID_OPERATION, false);
702 }
703
shannonwoods@chromium.orgcf2533c2013-05-30 00:14:18 +0000704 if (texture->isImmutable() && !isSubImage)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000705 {
706 return gl::error(GL_INVALID_OPERATION, false);
707 }
708
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000709 // Validate texture formats
710 GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat;
711 if (isCompressed)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000712 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000713 if (!gl::IsFormatCompressed(actualInternalFormat, context->getClientVersion()))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000714 {
715 return gl::error(GL_INVALID_ENUM, false);
716 }
717
718 if (target == GL_TEXTURE_3D)
719 {
720 return gl::error(GL_INVALID_OPERATION, false);
721 }
722 }
723 else
724 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000725 if (!gl::IsValidInternalFormat(actualInternalFormat, context) ||
726 !gl::IsValidFormat(format, context->getClientVersion()) ||
727 !gl::IsValidType(type, context->getClientVersion()))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000728 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000729 return gl::error(GL_INVALID_ENUM, false);
730 }
731
732 if (!gl::IsValidFormatCombination(actualInternalFormat, format, type, context->getClientVersion()))
733 {
734 return gl::error(GL_INVALID_OPERATION, false);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000735 }
736
737 if ((target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) &&
738 (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL))
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000739 {
740 return gl::error(GL_INVALID_OPERATION, false);
741 }
742 }
743
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000744 // Validate sub image parameters
745 if (isSubImage)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000746 {
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000747 if (isCompressed != textureCompressed)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000748 {
749 return gl::error(GL_INVALID_OPERATION, false);
750 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000751
752 if (format != GL_NONE)
753 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000754 GLenum internalformat = gl::GetSizedInternalFormat(format, type, context->getClientVersion());
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000755 if (internalformat != textureInternalFormat)
756 {
757 return gl::error(GL_INVALID_OPERATION, false);
758 }
759 }
760
761 if (isCompressed)
762 {
763 if ((width % 4 != 0 && width != textureLevelWidth) ||
764 (height % 4 != 0 && height != textureLevelHeight))
765 {
766 return gl::error(GL_INVALID_OPERATION, false);
767 }
768 }
769
770 if (width == 0 || height == 0 || depth == 0)
771 {
772 return false;
773 }
774
775 if (xoffset < 0 || yoffset < 0 || zoffset < 0)
776 {
777 return gl::error(GL_INVALID_VALUE, false);
778 }
779
780 if (std::numeric_limits<GLsizei>::max() - xoffset < width ||
781 std::numeric_limits<GLsizei>::max() - yoffset < height ||
782 std::numeric_limits<GLsizei>::max() - zoffset < depth)
783 {
784 return gl::error(GL_INVALID_VALUE, false);
785 }
786
787 if (xoffset + width > textureLevelWidth ||
788 yoffset + height > textureLevelHeight ||
789 zoffset + depth > textureLevelDepth)
790 {
791 return gl::error(GL_INVALID_VALUE, false);
792 }
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000793 }
794
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000795 return true;
796}
797
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000798
799bool validateES2CopyTexImageParameters(gl::Context* context, GLenum target, GLint level, GLenum internalformat, bool isSubImage,
800 GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height,
801 GLint border)
802{
803 if (!gl::IsInternalTextureTarget(target))
804 {
805 return gl::error(GL_INVALID_ENUM, false);
806 }
807
808 if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0)
809 {
810 return gl::error(GL_INVALID_VALUE, false);
811 }
812
813 if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
814 {
815 return gl::error(GL_INVALID_VALUE, false);
816 }
817
818 if (width == 0 || height == 0)
819 {
820 return false;
821 }
822
823 // Verify zero border
824 if (border != 0)
825 {
826 return gl::error(GL_INVALID_VALUE, false);
827 }
828
829 // Validate dimensions based on Context limits and validate the texture
830 if (level > context->getMaximumTextureLevel())
831 {
832 return gl::error(GL_INVALID_VALUE, false);
833 }
834
835 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
836
837 if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
838 {
839 return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
840 }
841
842 if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0)
843 {
844 return gl::error(GL_INVALID_OPERATION, false);
845 }
846
847 GLenum colorbufferFormat = framebuffer->getReadColorbuffer()->getInternalFormat();
848 gl::Texture *texture = NULL;
849 GLenum textureFormat = GL_RGBA;
850
851 switch (target)
852 {
853 case GL_TEXTURE_2D:
854 {
855 if (width > (context->getMaximum2DTextureDimension() >> level) ||
856 height > (context->getMaximum2DTextureDimension() >> level))
857 {
858 return gl::error(GL_INVALID_VALUE, false);
859 }
860
861 gl::Texture2D *tex2d = context->getTexture2D();
862 if (tex2d)
863 {
864 if (isSubImage && !validateSubImageParams2D(false, width, height, xoffset, yoffset, level, GL_NONE, GL_NONE, tex2d))
865 {
866 return false; // error already registered by validateSubImageParams
867 }
868 texture = tex2d;
869 textureFormat = gl::GetFormat(tex2d->getInternalFormat(level), context->getClientVersion());
870 }
871 }
872 break;
873
874 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
875 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
876 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
877 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
878 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
879 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
880 {
881 if (!isSubImage && width != height)
882 {
883 return gl::error(GL_INVALID_VALUE, false);
884 }
885
886 if (width > (context->getMaximumCubeTextureDimension() >> level) ||
887 height > (context->getMaximumCubeTextureDimension() >> level))
888 {
889 return gl::error(GL_INVALID_VALUE, false);
890 }
891
892 gl::TextureCubeMap *texcube = context->getTextureCubeMap();
893 if (texcube)
894 {
895 if (isSubImage && !validateSubImageParamsCube(false, width, height, xoffset, yoffset, target, level, GL_NONE, GL_NONE, texcube))
896 {
897 return false; // error already registered by validateSubImageParams
898 }
899 texture = texcube;
900 textureFormat = gl::GetFormat(texcube->getInternalFormat(target, level), context->getClientVersion());
901 }
902 }
903 break;
904
905 default:
906 return gl::error(GL_INVALID_ENUM, false);
907 }
908
909 if (!texture)
910 {
911 return gl::error(GL_INVALID_OPERATION, false);
912 }
913
914 if (texture->isImmutable() && !isSubImage)
915 {
916 return gl::error(GL_INVALID_OPERATION, false);
917 }
918
919
920 // [OpenGL ES 2.0.24] table 3.9
921 if (isSubImage)
922 {
923 switch (textureFormat)
924 {
925 case GL_ALPHA:
926 if (colorbufferFormat != GL_ALPHA8_EXT &&
927 colorbufferFormat != GL_RGBA4 &&
928 colorbufferFormat != GL_RGB5_A1 &&
929 colorbufferFormat != GL_RGBA8_OES)
930 {
931 return gl::error(GL_INVALID_OPERATION, false);
932 }
933 break;
934 case GL_LUMINANCE:
935 case GL_RGB:
936 if (colorbufferFormat != GL_RGB565 &&
937 colorbufferFormat != GL_RGB8_OES &&
938 colorbufferFormat != GL_RGBA4 &&
939 colorbufferFormat != GL_RGB5_A1 &&
940 colorbufferFormat != GL_RGBA8_OES)
941 {
942 return gl::error(GL_INVALID_OPERATION, false);
943 }
944 break;
945 case GL_LUMINANCE_ALPHA:
946 case GL_RGBA:
947 if (colorbufferFormat != GL_RGBA4 &&
948 colorbufferFormat != GL_RGB5_A1 &&
949 colorbufferFormat != GL_RGBA8_OES)
950 {
951 return gl::error(GL_INVALID_OPERATION, false);
952 }
953 break;
954 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
955 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
956 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
957 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
958 return gl::error(GL_INVALID_OPERATION, false);
959 case GL_DEPTH_COMPONENT:
960 case GL_DEPTH_STENCIL_OES:
961 return gl::error(GL_INVALID_OPERATION, false);
962 default:
963 return gl::error(GL_INVALID_OPERATION, false);
964 }
965 }
966 else
967 {
968 switch (internalformat)
969 {
970 case GL_ALPHA:
971 if (colorbufferFormat != GL_ALPHA8_EXT &&
972 colorbufferFormat != GL_RGBA4 &&
973 colorbufferFormat != GL_RGB5_A1 &&
974 colorbufferFormat != GL_BGRA8_EXT &&
975 colorbufferFormat != GL_RGBA8_OES)
976 {
977 return gl::error(GL_INVALID_OPERATION, false);
978 }
979 break;
980 case GL_LUMINANCE:
981 case GL_RGB:
982 if (colorbufferFormat != GL_RGB565 &&
983 colorbufferFormat != GL_RGB8_OES &&
984 colorbufferFormat != GL_RGBA4 &&
985 colorbufferFormat != GL_RGB5_A1 &&
986 colorbufferFormat != GL_BGRA8_EXT &&
987 colorbufferFormat != GL_RGBA8_OES)
988 {
989 return gl::error(GL_INVALID_OPERATION, false);
990 }
991 break;
992 case GL_LUMINANCE_ALPHA:
993 case GL_RGBA:
994 if (colorbufferFormat != GL_RGBA4 &&
995 colorbufferFormat != GL_RGB5_A1 &&
996 colorbufferFormat != GL_BGRA8_EXT &&
997 colorbufferFormat != GL_RGBA8_OES)
998 {
999 return gl::error(GL_INVALID_OPERATION, false);
1000 }
1001 break;
1002 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1003 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1004 if (context->supportsDXT1Textures())
1005 {
1006 return gl::error(GL_INVALID_OPERATION, false);
1007 }
1008 else
1009 {
1010 return gl::error(GL_INVALID_ENUM, false);
1011 }
1012 break;
1013 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
1014 if (context->supportsDXT3Textures())
1015 {
1016 return gl::error(GL_INVALID_OPERATION, false);
1017 }
1018 else
1019 {
1020 return gl::error(GL_INVALID_ENUM, false);
1021 }
1022 break;
1023 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
1024 if (context->supportsDXT5Textures())
1025 {
1026 return gl::error(GL_INVALID_OPERATION, false);
1027 }
1028 else
1029 {
1030 return gl::error(GL_INVALID_ENUM, false);
1031 }
1032 break;
1033 case GL_DEPTH_COMPONENT:
1034 case GL_DEPTH_COMPONENT16:
1035 case GL_DEPTH_COMPONENT32_OES:
1036 case GL_DEPTH_STENCIL_OES:
1037 case GL_DEPTH24_STENCIL8_OES:
1038 if (context->supportsDepthTextures())
1039 {
1040 return gl::error(GL_INVALID_OPERATION, false);
1041 }
1042 else
1043 {
1044 return gl::error(GL_INVALID_ENUM, false);
1045 }
1046 default:
1047 return gl::error(GL_INVALID_ENUM, false);
1048 }
1049 }
1050
1051 return true;
1052}
1053
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001054bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLint level, GLenum internalformat,
1055 bool isSubImage, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y,
1056 GLsizei width, GLsizei height, GLint border)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001057{
1058 if (level < 0 || xoffset < 0 || yoffset < 0 || zoffset < 0 || width < 0 || height < 0)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +00001059 {
1060 return gl::error(GL_INVALID_VALUE, false);
1061 }
1062
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001063 if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
1064 {
1065 return gl::error(GL_INVALID_VALUE, false);
1066 }
1067
1068 if (width == 0 || height == 0)
1069 {
1070 return false;
1071 }
1072
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001073 if (border != 0)
1074 {
1075 return gl::error(GL_INVALID_VALUE, false);
1076 }
1077
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001078 if (level > context->getMaximumTextureLevel())
1079 {
1080 return gl::error(GL_INVALID_VALUE, false);
1081 }
1082
1083 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
1084
1085 if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
1086 {
1087 return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
1088 }
1089
1090 if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0)
1091 {
1092 return gl::error(GL_INVALID_OPERATION, false);
1093 }
1094
1095 gl::Renderbuffer *source = framebuffer->getReadColorbuffer();
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001096 GLenum colorbufferInternalFormat = source->getInternalFormat();
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001097 gl::Texture *texture = NULL;
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001098 GLenum textureInternalFormat = GL_NONE;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001099 bool textureCompressed = false;
Geoff Lang0e7c2fd2013-06-12 16:43:52 -04001100 bool textureIsDepth = false;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001101 GLint textureLevelWidth = 0;
1102 GLint textureLevelHeight = 0;
1103 GLint textureLevelDepth = 0;
1104 switch (target)
1105 {
1106 case GL_TEXTURE_2D:
1107 {
1108 gl::Texture2D *texture2d = context->getTexture2D();
1109 if (texture2d)
1110 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001111 textureInternalFormat = texture2d->getInternalFormat(level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001112 textureCompressed = texture2d->isCompressed(level);
Geoff Lang0e7c2fd2013-06-12 16:43:52 -04001113 textureIsDepth = texture2d->isDepth(level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001114 textureLevelWidth = texture2d->getWidth(level);
1115 textureLevelHeight = texture2d->getHeight(level);
1116 textureLevelDepth = 1;
1117 texture = texture2d;
1118 }
1119 }
1120 break;
1121
1122 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1123 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1124 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1125 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1126 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1127 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1128 {
1129 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
1130 if (textureCube)
1131 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001132 textureInternalFormat = textureCube->getInternalFormat(target, level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001133 textureCompressed = textureCube->isCompressed(target, level);
Geoff Lang0e7c2fd2013-06-12 16:43:52 -04001134 textureIsDepth = false;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001135 textureLevelWidth = textureCube->getWidth(target, level);
1136 textureLevelHeight = textureCube->getHeight(target, level);
1137 textureLevelDepth = 1;
1138 texture = textureCube;
1139 }
1140 }
1141 break;
1142
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001143 case GL_TEXTURE_2D_ARRAY:
1144 {
1145 gl::Texture2DArray *texture2dArray = context->getTexture2DArray();
1146 if (texture2dArray)
1147 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001148 textureInternalFormat = texture2dArray->getInternalFormat(level);
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001149 textureCompressed = texture2dArray->isCompressed(level);
Geoff Lang0e7c2fd2013-06-12 16:43:52 -04001150 textureIsDepth = texture2dArray->isDepth(level);
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001151 textureLevelWidth = texture2dArray->getWidth(level);
1152 textureLevelHeight = texture2dArray->getHeight(level);
1153 textureLevelDepth = texture2dArray->getDepth(level);
1154 texture = texture2dArray;
1155 }
1156 }
1157 break;
1158
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001159 case GL_TEXTURE_3D:
1160 {
1161 gl::Texture3D *texture3d = context->getTexture3D();
1162 if (texture3d)
1163 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001164 textureInternalFormat = texture3d->getInternalFormat(level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001165 textureCompressed = texture3d->isCompressed(level);
Geoff Lang0e7c2fd2013-06-12 16:43:52 -04001166 textureIsDepth = texture3d->isDepth(level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001167 textureLevelWidth = texture3d->getWidth(level);
1168 textureLevelHeight = texture3d->getHeight(level);
1169 textureLevelDepth = texture3d->getDepth(level);
1170 texture = texture3d;
1171 }
1172 }
1173 break;
1174
1175 default:
1176 return gl::error(GL_INVALID_ENUM, false);
1177 }
1178
1179 if (!texture)
1180 {
1181 return gl::error(GL_INVALID_OPERATION, false);
1182 }
1183
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001184 if (texture->isImmutable() && !isSubImage)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001185 {
1186 return gl::error(GL_INVALID_OPERATION, false);
1187 }
1188
Geoff Lang0e7c2fd2013-06-12 16:43:52 -04001189 if (textureIsDepth)
1190 {
1191 return gl::error(GL_INVALID_OPERATION, false);
1192 }
1193
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001194 if (textureCompressed)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001195 {
1196 if ((width % 4 != 0 && width != textureLevelWidth) ||
1197 (height % 4 != 0 && height != textureLevelHeight))
1198 {
1199 return gl::error(GL_INVALID_OPERATION, false);
1200 }
1201 }
1202
Geoff Langa4d13322013-06-05 14:57:51 -04001203 if (isSubImage)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001204 {
Geoff Langa4d13322013-06-05 14:57:51 -04001205 if (xoffset + width > textureLevelWidth ||
1206 yoffset + height > textureLevelHeight ||
1207 zoffset >= textureLevelDepth)
1208 {
1209 return gl::error(GL_INVALID_VALUE, false);
1210 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001211
Geoff Langa4d13322013-06-05 14:57:51 -04001212 if (!gl::IsValidCopyTexImageCombination(textureInternalFormat, colorbufferInternalFormat,
1213 context->getClientVersion()))
1214 {
1215 return gl::error(GL_INVALID_OPERATION, false);
1216 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001217 }
1218
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +00001219 return true;
1220}
1221
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00001222bool validateES2TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat,
1223 GLsizei width, GLsizei height)
1224{
1225 if (target != GL_TEXTURE_2D && target != GL_TEXTURE_CUBE_MAP)
1226 {
1227 return gl::error(GL_INVALID_ENUM, false);
1228 }
1229
1230 if (width < 1 || height < 1 || levels < 1)
1231 {
1232 return gl::error(GL_INVALID_VALUE, false);
1233 }
1234
1235 if (target == GL_TEXTURE_CUBE_MAP && width != height)
1236 {
1237 return gl::error(GL_INVALID_VALUE, false);
1238 }
1239
1240 if (levels != 1 && levels != gl::log2(std::max(width, height)) + 1)
1241 {
1242 return gl::error(GL_INVALID_OPERATION, false);
1243 }
1244
1245 GLenum format = gl::GetFormat(internalformat, context->getClientVersion());
1246 GLenum type = gl::GetType(internalformat, context->getClientVersion());
1247
1248 if (format == GL_NONE || type == GL_NONE)
1249 {
1250 return gl::error(GL_INVALID_ENUM, false);
1251 }
1252
1253 switch (target)
1254 {
1255 case GL_TEXTURE_2D:
1256 if (width > context->getMaximum2DTextureDimension() ||
1257 height > context->getMaximum2DTextureDimension())
1258 {
1259 return gl::error(GL_INVALID_VALUE, false);
1260 }
1261 break;
1262 case GL_TEXTURE_CUBE_MAP:
1263 if (width > context->getMaximumCubeTextureDimension() ||
1264 height > context->getMaximumCubeTextureDimension())
1265 {
1266 return gl::error(GL_INVALID_VALUE, false);
1267 }
1268 break;
1269 default:
1270 return gl::error(GL_INVALID_ENUM, false);
1271 }
1272
1273 if (levels != 1 && !context->supportsNonPower2Texture())
1274 {
1275 if (!gl::isPow2(width) || !gl::isPow2(height))
1276 {
1277 return gl::error(GL_INVALID_OPERATION, false);
1278 }
1279 }
1280
1281 switch (internalformat)
1282 {
1283 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1284 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1285 if (!context->supportsDXT1Textures())
1286 {
1287 return gl::error(GL_INVALID_ENUM, false);
1288 }
1289 break;
1290 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
1291 if (!context->supportsDXT3Textures())
1292 {
1293 return gl::error(GL_INVALID_ENUM, false);
1294 }
1295 break;
1296 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
1297 if (!context->supportsDXT5Textures())
1298 {
1299 return gl::error(GL_INVALID_ENUM, false);
1300 }
1301 break;
1302 case GL_RGBA32F_EXT:
1303 case GL_RGB32F_EXT:
1304 case GL_ALPHA32F_EXT:
1305 case GL_LUMINANCE32F_EXT:
1306 case GL_LUMINANCE_ALPHA32F_EXT:
1307 if (!context->supportsFloat32Textures())
1308 {
1309 return gl::error(GL_INVALID_ENUM, false);
1310 }
1311 break;
1312 case GL_RGBA16F_EXT:
1313 case GL_RGB16F_EXT:
1314 case GL_ALPHA16F_EXT:
1315 case GL_LUMINANCE16F_EXT:
1316 case GL_LUMINANCE_ALPHA16F_EXT:
1317 if (!context->supportsFloat16Textures())
1318 {
1319 return gl::error(GL_INVALID_ENUM, false);
1320 }
1321 break;
1322 case GL_DEPTH_COMPONENT16:
1323 case GL_DEPTH_COMPONENT32_OES:
1324 case GL_DEPTH24_STENCIL8_OES:
1325 if (!context->supportsDepthTextures())
1326 {
1327 return gl::error(GL_INVALID_ENUM, false);
1328 }
1329 if (target != GL_TEXTURE_2D)
1330 {
1331 return gl::error(GL_INVALID_OPERATION, false);
1332 }
1333 // ANGLE_depth_texture only supports 1-level textures
1334 if (levels != 1)
1335 {
1336 return gl::error(GL_INVALID_OPERATION, false);
1337 }
1338 break;
1339 default:
1340 break;
1341 }
1342
1343 gl::Texture *texture = NULL;
1344 switch(target)
1345 {
1346 case GL_TEXTURE_2D:
1347 texture = context->getTexture2D();
1348 break;
1349 case GL_TEXTURE_CUBE_MAP:
1350 texture = context->getTextureCubeMap();
1351 break;
1352 default:
1353 UNREACHABLE();
1354 }
1355
1356 if (!texture || texture->id() == 0)
1357 {
1358 return gl::error(GL_INVALID_OPERATION, false);
1359 }
1360
1361 if (texture->isImmutable())
1362 {
1363 return gl::error(GL_INVALID_OPERATION, false);
1364 }
1365
1366 return true;
1367}
1368
1369bool validateES3TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat,
1370 GLsizei width, GLsizei height, GLsizei depth)
1371{
1372 if (width < 1 || height < 1 || depth < 1 || levels < 1)
1373 {
1374 return gl::error(GL_INVALID_VALUE, false);
1375 }
1376
1377 if (levels > gl::log2(std::max(std::max(width, height), depth)) + 1)
1378 {
1379 return gl::error(GL_INVALID_OPERATION, false);
1380 }
1381
1382 gl::Texture *texture = NULL;
1383 switch (target)
1384 {
1385 case GL_TEXTURE_2D:
1386 {
1387 texture = context->getTexture2D();
1388
1389 if (width > (context->getMaximum2DTextureDimension()) ||
1390 height > (context->getMaximum2DTextureDimension()))
1391 {
1392 return gl::error(GL_INVALID_VALUE, false);
1393 }
1394 }
1395 break;
1396
1397 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1398 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1399 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1400 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1401 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1402 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1403 {
1404 texture = context->getTextureCubeMap();
1405
1406 if (width != height)
1407 {
1408 return gl::error(GL_INVALID_VALUE, false);
1409 }
1410
1411 if (width > (context->getMaximumCubeTextureDimension()))
1412 {
1413 return gl::error(GL_INVALID_VALUE, false);
1414 }
1415 }
1416 break;
1417
1418 case GL_TEXTURE_3D:
1419 {
1420 texture = context->getTexture3D();
1421
1422 if (width > (context->getMaximum3DTextureDimension()) ||
1423 height > (context->getMaximum3DTextureDimension()) ||
1424 depth > (context->getMaximum3DTextureDimension()))
1425 {
1426 return gl::error(GL_INVALID_VALUE, false);
1427 }
1428 }
1429 break;
1430
1431 case GL_TEXTURE_2D_ARRAY:
1432 {
1433 texture = context->getTexture2DArray();
1434
1435 if (width > (context->getMaximum2DTextureDimension()) ||
1436 height > (context->getMaximum2DTextureDimension()) ||
1437 depth > (context->getMaximum2DArrayTextureLayers()))
1438 {
1439 return gl::error(GL_INVALID_VALUE, false);
1440 }
1441 }
1442 break;
1443
1444 default:
1445 return gl::error(GL_INVALID_ENUM, false);
1446 }
1447
1448 if (!texture || texture->id() == 0)
1449 {
1450 return gl::error(GL_INVALID_OPERATION, false);
1451 }
1452
1453 if (texture->isImmutable())
1454 {
1455 return gl::error(GL_INVALID_OPERATION, false);
1456 }
1457
1458 if (!gl::IsValidInternalFormat(internalformat, context))
1459 {
1460 return gl::error(GL_INVALID_ENUM, false);
1461 }
1462
1463 if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion()))
1464 {
1465 return gl::error(GL_INVALID_ENUM, false);
1466 }
1467
1468 return true;
1469}
1470
Geoff Lang2e1dcd52013-05-29 10:34:08 -04001471bool validateRenderbufferStorageParameters(const gl::Context *context, GLenum target, GLsizei samples,
1472 GLenum internalformat, GLsizei width, GLsizei height,
1473 bool angleExtension)
1474{
1475 switch (target)
1476 {
1477 case GL_RENDERBUFFER:
1478 break;
1479 default:
1480 return gl::error(GL_INVALID_ENUM, false);
1481 }
1482
1483 if (width < 0 || height < 0 || samples < 0)
1484 {
1485 return gl::error(GL_INVALID_VALUE, false);
1486 }
1487
1488 if (!gl::IsValidInternalFormat(internalformat, context))
1489 {
1490 return gl::error(GL_INVALID_ENUM, false);
1491 }
1492
1493 // ANGLE_framebuffer_multisample does not explicitly state that the internal format must be
1494 // sized but it does state that the format must be in the ES2.0 spec table 4.5 which contains
1495 // only sized internal formats. The ES3 spec (section 4.4.2) does, however, state that the
1496 // internal format must be sized and not an integer format if samples is greater than zero.
1497 if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion()))
1498 {
1499 return gl::error(GL_INVALID_ENUM, false);
1500 }
1501
1502 if (gl::IsIntegerFormat(internalformat, context->getClientVersion()) && samples > 0)
1503 {
1504 return gl::error(GL_INVALID_OPERATION, false);
1505 }
1506
1507 if (!gl::IsColorRenderingSupported(internalformat, context) &&
1508 !gl::IsDepthRenderingSupported(internalformat, context) &&
1509 !gl::IsStencilRenderingSupported(internalformat, context))
1510 {
1511 return gl::error(GL_INVALID_ENUM, false);
1512 }
1513
1514 if (std::max(width, height) > context->getMaximumRenderbufferDimension())
1515 {
1516 return gl::error(GL_INVALID_VALUE, false);
1517 }
1518
1519 // ANGLE_framebuffer_multisample states that the value of samples must be less than or equal
1520 // to MAX_SAMPLES_ANGLE (Context::getMaxSupportedSamples) while the ES3.0 spec (section 4.4.2)
1521 // states that samples must be less than or equal to the maximum samples for the specified
1522 // internal format.
1523 if (angleExtension)
1524 {
1525 if (samples > context->getMaxSupportedSamples())
1526 {
1527 return gl::error(GL_INVALID_VALUE, false);
1528 }
1529 }
1530 else
1531 {
1532 if (samples > context->getMaxSupportedFormatSamples(internalformat))
1533 {
1534 return gl::error(GL_INVALID_VALUE, false);
1535 }
1536 }
1537
1538 GLuint handle = context->getRenderbufferHandle();
1539 if (handle == 0)
1540 {
1541 return gl::error(GL_INVALID_OPERATION, false);
1542 }
1543
1544 return true;
1545}
1546
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00001547// check for combinations of format and type that are valid for ReadPixels
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00001548bool validES2ReadFormatType(GLenum format, GLenum type)
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00001549{
1550 switch (format)
1551 {
1552 case GL_RGBA:
1553 switch (type)
1554 {
1555 case GL_UNSIGNED_BYTE:
1556 break;
1557 default:
1558 return false;
1559 }
1560 break;
1561 case GL_BGRA_EXT:
1562 switch (type)
1563 {
1564 case GL_UNSIGNED_BYTE:
1565 case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
1566 case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
1567 break;
1568 default:
1569 return false;
1570 }
1571 break;
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00001572 default:
1573 return false;
1574 }
1575 return true;
1576}
1577
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00001578bool validES3ReadFormatType(GLenum internalFormat, GLenum format, GLenum type)
1579{
1580 switch (format)
1581 {
1582 case GL_RGBA:
1583 switch (type)
1584 {
1585 case GL_UNSIGNED_BYTE:
1586 break;
1587 case GL_UNSIGNED_INT_2_10_10_10_REV:
1588 if (internalFormat != GL_RGB10_A2)
1589 {
1590 return false;
1591 }
1592 break;
1593 default:
1594 return false;
1595 }
1596 break;
1597 case GL_RGBA_INTEGER:
1598 switch (type)
1599 {
1600 case GL_INT:
Geoff Langd384a942013-06-05 15:00:10 -04001601 if (!gl::IsSignedIntegerFormat(internalFormat, 3))
1602 {
1603 return false;
1604 }
1605 break;
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00001606 case GL_UNSIGNED_INT:
Geoff Langd384a942013-06-05 15:00:10 -04001607 if (!gl::IsUnsignedIntegerFormat(internalFormat, 3))
1608 {
1609 return false;
1610 }
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00001611 break;
1612 default:
1613 return false;
1614 }
1615 break;
1616 case GL_BGRA_EXT:
1617 switch (type)
1618 {
1619 case GL_UNSIGNED_BYTE:
1620 case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
1621 case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
1622 break;
1623 default:
1624 return false;
1625 }
1626 break;
1627 default:
1628 return false;
1629 }
1630 return true;
1631}
1632
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00001633bool validateInvalidateFramebufferParameters(gl::Context *context, GLenum target, GLsizei numAttachments,
1634 const GLenum* attachments)
1635{
1636 bool defaultFramebuffer = false;
1637
1638 switch (target)
1639 {
1640 case GL_DRAW_FRAMEBUFFER:
1641 case GL_FRAMEBUFFER:
1642 defaultFramebuffer = context->getDrawFramebufferHandle() == 0;
1643 break;
1644 case GL_READ_FRAMEBUFFER:
1645 defaultFramebuffer = context->getReadFramebufferHandle() == 0;
1646 break;
1647 default:
1648 return gl::error(GL_INVALID_ENUM, false);
1649 }
1650
1651 for (int i = 0; i < numAttachments; ++i)
1652 {
1653 if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15)
1654 {
1655 if (defaultFramebuffer)
1656 {
1657 return gl::error(GL_INVALID_ENUM, false);
1658 }
1659
1660 if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getMaximumRenderTargets())
1661 {
1662 return gl::error(GL_INVALID_OPERATION, false);
1663 }
1664 }
1665 else
1666 {
1667 switch (attachments[i])
1668 {
1669 case GL_DEPTH_ATTACHMENT:
1670 case GL_STENCIL_ATTACHMENT:
1671 case GL_DEPTH_STENCIL_ATTACHMENT:
1672 if (defaultFramebuffer)
1673 {
1674 return gl::error(GL_INVALID_ENUM, false);
1675 }
1676 break;
1677 case GL_COLOR:
1678 case GL_DEPTH:
1679 case GL_STENCIL:
1680 if (!defaultFramebuffer)
1681 {
1682 return gl::error(GL_INVALID_ENUM, false);
1683 }
1684 break;
1685 default:
1686 return gl::error(GL_INVALID_ENUM, false);
1687 }
1688 }
1689 }
1690
1691 return true;
1692}
1693
Geoff Lang758d5b22013-06-11 11:42:50 -04001694bool validateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
1695 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask,
1696 GLenum filter, bool fromAngleExtension)
1697{
1698 switch (filter)
1699 {
1700 case GL_NEAREST:
1701 break;
1702 case GL_LINEAR:
1703 if (fromAngleExtension)
1704 {
1705 return gl::error(GL_INVALID_ENUM, false);
1706 }
1707 break;
1708 default:
1709 return gl::error(GL_INVALID_ENUM, false);
1710 }
1711
1712 if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0)
1713 {
1714 return gl::error(GL_INVALID_VALUE, false);
1715 }
1716
1717 if (mask == 0)
1718 {
1719 // ES3.0 spec, section 4.3.2 specifies that a mask of zero is valid and no
1720 // buffers are copied.
1721 return false;
1722 }
1723
1724 if (fromAngleExtension && (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0))
1725 {
1726 ERR("Scaling and flipping in BlitFramebufferANGLE not supported by this implementation.");
1727 return gl::error(GL_INVALID_OPERATION, false);
1728 }
1729
1730 // ES3.0 spec, section 4.3.2 states that linear filtering is only available for the
1731 // color buffer, leaving only nearest being unfiltered from above
1732 if ((mask & ~GL_COLOR_BUFFER_BIT) != 0 && filter != GL_NEAREST)
1733 {
1734 return gl::error(GL_INVALID_OPERATION, false);
1735 }
1736
1737 if (context->getReadFramebufferHandle() == context->getDrawFramebufferHandle())
1738 {
1739 if (fromAngleExtension)
1740 {
1741 ERR("Blits with the same source and destination framebuffer are not supported by this "
1742 "implementation.");
1743 }
1744 return gl::error(GL_INVALID_OPERATION, false);
1745 }
1746
1747 gl::Framebuffer *readFramebuffer = context->getReadFramebuffer();
1748 gl::Framebuffer *drawFramebuffer = context->getDrawFramebuffer();
1749 if (!readFramebuffer || readFramebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE ||
1750 !drawFramebuffer || drawFramebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
1751 {
1752 return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
1753 }
1754
1755 if (drawFramebuffer->getSamples() != 0)
1756 {
1757 return gl::error(GL_INVALID_OPERATION, false);
1758 }
1759
1760 gl::Rectangle sourceClippedRect, destClippedRect;
1761 bool partialCopy;
1762 if (!context->clipBlitFramebufferCoordinates(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
1763 &sourceClippedRect, &destClippedRect, &partialCopy))
1764 {
1765 return gl::error(GL_INVALID_OPERATION, false);
1766 }
1767
1768 bool sameBounds = srcX0 == dstX0 && srcY0 == dstY0 && srcX1 == dstX1 && srcY1 == dstY1;
1769
1770 GLuint clientVersion = context->getClientVersion();
1771
1772 if (mask & GL_COLOR_BUFFER_BIT)
1773 {
1774 gl::Renderbuffer *readColorBuffer = readFramebuffer->getReadColorbuffer();
1775 gl::Renderbuffer *drawColorBuffer = drawFramebuffer->getFirstColorbuffer();
1776
1777 if (readColorBuffer && drawColorBuffer)
1778 {
1779 GLint readInternalFormat = readColorBuffer->getActualFormat();
1780 GLint drawInternalFormat = drawColorBuffer->getActualFormat();
1781
1782 for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; i++)
1783 {
1784 if (drawFramebuffer->isEnabledColorAttachment(i))
1785 {
1786 GLint drawbufferAttachmentFormat = drawFramebuffer->getColorbuffer(i)->getActualFormat();
1787
1788 if (gl::IsNormalizedFixedPointFormat(readInternalFormat, clientVersion) &&
1789 !gl::IsNormalizedFixedPointFormat(drawbufferAttachmentFormat, clientVersion))
1790 {
1791 return gl::error(GL_INVALID_OPERATION, false);
1792 }
1793
1794 if (gl::IsUnsignedIntegerFormat(readInternalFormat, clientVersion) &&
1795 !gl::IsUnsignedIntegerFormat(drawbufferAttachmentFormat, clientVersion))
1796 {
1797 return gl::error(GL_INVALID_OPERATION, false);
1798 }
1799
1800 if (gl::IsSignedIntegerFormat(readInternalFormat, clientVersion) &&
1801 !gl::IsSignedIntegerFormat(drawbufferAttachmentFormat, clientVersion))
1802 {
1803 return gl::error(GL_INVALID_OPERATION, false);
1804 }
1805
1806 if (readColorBuffer->getSamples() > 0 && (readInternalFormat != drawbufferAttachmentFormat || !sameBounds))
1807 {
1808 return gl::error(GL_INVALID_OPERATION, false);
1809 }
1810 }
1811 }
1812
1813 if (gl::IsIntegerFormat(readInternalFormat, clientVersion) && filter == GL_LINEAR)
1814 {
1815 return gl::error(GL_INVALID_OPERATION, false);
1816 }
1817
1818 if (fromAngleExtension)
1819 {
1820 const GLenum readColorbufferType = readFramebuffer->getReadColorbufferType();
1821 if (readColorbufferType != GL_TEXTURE_2D && readColorbufferType != GL_RENDERBUFFER)
1822 {
1823 return gl::error(GL_INVALID_OPERATION, false);
1824 }
1825
1826 for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
1827 {
1828 if (drawFramebuffer->isEnabledColorAttachment(colorAttachment))
1829 {
1830 if (drawFramebuffer->getColorbufferType(colorAttachment) != GL_TEXTURE_2D &&
1831 drawFramebuffer->getColorbufferType(colorAttachment) != GL_RENDERBUFFER)
1832 {
1833 return gl::error(GL_INVALID_OPERATION, false);
1834 }
1835
1836 if (drawFramebuffer->getColorbuffer(colorAttachment)->getActualFormat() != readColorBuffer->getActualFormat())
1837 {
1838 return gl::error(GL_INVALID_OPERATION, false);
1839 }
1840 }
1841 }
1842
1843 if (partialCopy && readFramebuffer->getSamples() != 0)
1844 {
1845 return gl::error(GL_INVALID_OPERATION, false);
1846 }
1847 }
1848 }
1849 }
1850
1851 if (mask & GL_DEPTH_BUFFER_BIT)
1852 {
1853 gl::Renderbuffer *readDepthBuffer = readFramebuffer->getDepthbuffer();
1854 gl::Renderbuffer *drawDepthBuffer = drawFramebuffer->getDepthbuffer();
1855
1856 if (readDepthBuffer && drawDepthBuffer)
1857 {
1858 if (readDepthBuffer->getActualFormat() != drawDepthBuffer->getActualFormat())
1859 {
1860 return gl::error(GL_INVALID_OPERATION, false);
1861 }
1862
1863 if (readDepthBuffer->getSamples() > 0 && !sameBounds)
1864 {
1865 return gl::error(GL_INVALID_OPERATION, false);
1866 }
1867
1868 if (fromAngleExtension)
1869 {
1870 if (partialCopy)
1871 {
1872 ERR("Only whole-buffer depth and stencil blits are supported by this implementation.");
1873 return gl::error(GL_INVALID_OPERATION, false); // only whole-buffer copies are permitted
1874 }
1875
1876 if (readDepthBuffer->getSamples() != 0 || drawDepthBuffer->getSamples() != 0)
1877 {
1878 return gl::error(GL_INVALID_OPERATION, false);
1879 }
1880 }
1881 }
1882 }
1883
1884 if (mask & GL_STENCIL_BUFFER_BIT)
1885 {
1886 gl::Renderbuffer *readStencilBuffer = readFramebuffer->getStencilbuffer();
1887 gl::Renderbuffer *drawStencilBuffer = drawFramebuffer->getStencilbuffer();
1888
1889 if (fromAngleExtension && partialCopy)
1890 {
1891 ERR("Only whole-buffer depth and stencil blits are supported by this implementation.");
1892 return gl::error(GL_INVALID_OPERATION, false); // only whole-buffer copies are permitted
1893 }
1894
1895 if (readStencilBuffer && drawStencilBuffer)
1896 {
1897 if (readStencilBuffer->getActualFormat() != drawStencilBuffer->getActualFormat())
1898 {
1899 return gl::error(GL_INVALID_OPERATION, false);
1900 }
1901
1902 if (readStencilBuffer->getSamples() > 0 && !sameBounds)
1903 {
1904 return gl::error(GL_INVALID_OPERATION, false);
1905 }
1906
1907 if (fromAngleExtension)
1908 {
1909 if (partialCopy)
1910 {
1911 ERR("Only whole-buffer depth and stencil blits are supported by this implementation.");
1912 return gl::error(GL_INVALID_OPERATION, false); // only whole-buffer copies are permitted
1913 }
1914
1915 if (readStencilBuffer->getSamples() != 0 || drawStencilBuffer->getSamples() != 0)
1916 {
1917 return gl::error(GL_INVALID_OPERATION, false);
1918 }
1919 }
1920 }
1921 }
1922
1923 return true;
1924}
1925
Jamie Madillaff71502013-07-02 11:57:05 -04001926bool validateGetVertexAttribParameters(GLenum pname, int clientVersion)
1927{
1928 switch (pname)
1929 {
1930 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
1931 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
1932 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
1933 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
1934 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
1935 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
1936 case GL_CURRENT_VERTEX_ATTRIB:
1937 return true;
1938
1939 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
1940 // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses
1941 // the same constant.
1942 META_ASSERT(GL_VERTEX_ATTRIB_ARRAY_DIVISOR == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE);
1943 return true;
1944
Jamie Madill30855b32013-07-02 11:57:06 -04001945 case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
1946 return ((clientVersion >= 3) ? true : gl::error(GL_INVALID_ENUM, false));
1947
Jamie Madillaff71502013-07-02 11:57:05 -04001948 default:
1949 return gl::error(GL_INVALID_ENUM, false);
1950 }
1951}
1952
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001953extern "C"
1954{
1955
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00001956// OpenGL ES 2.0 functions
1957
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001958void __stdcall glActiveTexture(GLenum texture)
1959{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001960 EVENT("(GLenum texture = 0x%X)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001961
1962 try
1963 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001964 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001965
1966 if (context)
1967 {
daniel@transgaming.com3f74c7a2011-05-11 15:36:51 +00001968 if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1)
1969 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001970 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3f74c7a2011-05-11 15:36:51 +00001971 }
1972
daniel@transgaming.com428d1582010-05-04 03:35:25 +00001973 context->setActiveSampler(texture - GL_TEXTURE0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001974 }
1975 }
1976 catch(std::bad_alloc&)
1977 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001978 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001979 }
1980}
1981
1982void __stdcall glAttachShader(GLuint program, GLuint shader)
1983{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001984 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001985
1986 try
1987 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001988 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001989
1990 if (context)
1991 {
1992 gl::Program *programObject = context->getProgram(program);
1993 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00001994
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001995 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001996 {
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001997 if (context->getShader(program))
1998 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001999 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00002000 }
2001 else
2002 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002003 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00002004 }
2005 }
2006
2007 if (!shaderObject)
2008 {
2009 if (context->getProgram(shader))
2010 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002011 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00002012 }
2013 else
2014 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002015 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00002016 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002017 }
2018
2019 if (!programObject->attachShader(shaderObject))
2020 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002021 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002022 }
2023 }
2024 }
2025 catch(std::bad_alloc&)
2026 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002027 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002028 }
2029}
2030
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002031void __stdcall glBeginQueryEXT(GLenum target, GLuint id)
2032{
2033 EVENT("(GLenum target = 0x%X, GLuint %d)", target, id);
2034
2035 try
2036 {
2037 switch (target)
2038 {
2039 case GL_ANY_SAMPLES_PASSED_EXT:
2040 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
2041 break;
2042 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002043 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002044 }
2045
2046 if (id == 0)
2047 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002048 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002049 }
2050
2051 gl::Context *context = gl::getNonLostContext();
2052
2053 if (context)
2054 {
2055 context->beginQuery(target, id);
2056 }
2057 }
2058 catch(std::bad_alloc&)
2059 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002060 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002061 }
2062}
2063
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002064void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002065{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002066 EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002067
2068 try
2069 {
2070 if (index >= gl::MAX_VERTEX_ATTRIBS)
2071 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002072 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002073 }
2074
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002075 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002076
2077 if (context)
2078 {
2079 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00002080
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002081 if (!programObject)
2082 {
daniel@transgaming.com98079832010-04-13 03:26:29 +00002083 if (context->getShader(program))
2084 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002085 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com98079832010-04-13 03:26:29 +00002086 }
2087 else
2088 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002089 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com98079832010-04-13 03:26:29 +00002090 }
2091 }
2092
2093 if (strncmp(name, "gl_", 3) == 0)
2094 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002095 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002096 }
2097
2098 programObject->bindAttributeLocation(index, name);
2099 }
2100 }
2101 catch(std::bad_alloc&)
2102 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002103 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002104 }
2105}
2106
2107void __stdcall glBindBuffer(GLenum target, GLuint buffer)
2108{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002109 EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002110
2111 try
2112 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002113 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002114
2115 if (context)
2116 {
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002117 // Check ES3 specific targets
2118 switch (target)
2119 {
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002120 case GL_COPY_READ_BUFFER:
2121 case GL_COPY_WRITE_BUFFER:
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002122 case GL_PIXEL_PACK_BUFFER:
2123 case GL_PIXEL_UNPACK_BUFFER:
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002124 case GL_UNIFORM_BUFFER:
2125 case GL_TRANSFORM_FEEDBACK_BUFFER:
2126 if (context->getClientVersion() < 3)
2127 {
2128 return gl::error(GL_INVALID_ENUM);
2129 }
2130 }
2131
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002132 switch (target)
2133 {
2134 case GL_ARRAY_BUFFER:
2135 context->bindArrayBuffer(buffer);
2136 return;
2137 case GL_ELEMENT_ARRAY_BUFFER:
2138 context->bindElementArrayBuffer(buffer);
2139 return;
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002140 case GL_COPY_READ_BUFFER:
2141 context->bindCopyReadBuffer(buffer);
2142 return;
2143 case GL_COPY_WRITE_BUFFER:
2144 context->bindCopyWriteBuffer(buffer);
2145 return;
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002146 case GL_PIXEL_PACK_BUFFER:
2147 context->bindPixelPackBuffer(buffer);
2148 return;
2149 case GL_PIXEL_UNPACK_BUFFER:
2150 context->bindPixelUnpackBuffer(buffer);
2151 return;
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002152 case GL_UNIFORM_BUFFER:
2153 context->bindGenericUniformBuffer(buffer);
2154 return;
2155 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.org7a1ebad2013-05-30 00:05:20 +00002156 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002157 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002158 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002159 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002160 }
2161 }
2162 }
2163 catch(std::bad_alloc&)
2164 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002165 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002166 }
2167}
2168
2169void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer)
2170{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002171 EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002172
2173 try
2174 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002175 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002176 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002177 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002178 }
2179
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002180 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002181
2182 if (context)
2183 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002184 if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
2185 {
2186 context->bindReadFramebuffer(framebuffer);
2187 }
2188
2189 if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
2190 {
2191 context->bindDrawFramebuffer(framebuffer);
2192 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002193 }
2194 }
2195 catch(std::bad_alloc&)
2196 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002197 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002198 }
2199}
2200
2201void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer)
2202{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002203 EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002204
2205 try
2206 {
2207 if (target != GL_RENDERBUFFER)
2208 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002209 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002210 }
2211
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002212 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002213
2214 if (context)
2215 {
2216 context->bindRenderbuffer(renderbuffer);
2217 }
2218 }
2219 catch(std::bad_alloc&)
2220 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002221 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002222 }
2223}
2224
2225void __stdcall glBindTexture(GLenum target, GLuint texture)
2226{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002227 EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002228
2229 try
2230 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002231 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002232
2233 if (context)
2234 {
2235 gl::Texture *textureObject = context->getTexture(texture);
2236
2237 if (textureObject && textureObject->getTarget() != target && texture != 0)
2238 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002239 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002240 }
2241
2242 switch (target)
2243 {
2244 case GL_TEXTURE_2D:
2245 context->bindTexture2D(texture);
2246 return;
2247 case GL_TEXTURE_CUBE_MAP:
2248 context->bindTextureCubeMap(texture);
2249 return;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00002250 case GL_TEXTURE_3D:
2251 if (context->getClientVersion() < 3)
2252 {
2253 return gl::error(GL_INVALID_ENUM);
2254 }
2255 context->bindTexture3D(texture);
2256 return;
shannon.woods%transgaming.com@gtempaccount.com90dbc442013-04-13 03:46:14 +00002257 case GL_TEXTURE_2D_ARRAY:
2258 if (context->getClientVersion() < 3)
2259 {
2260 return gl::error(GL_INVALID_ENUM);
2261 }
2262 context->bindTexture2DArray(texture);
2263 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002264 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002265 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002266 }
2267 }
2268 }
2269 catch(std::bad_alloc&)
2270 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002271 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002272 }
2273}
2274
2275void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
2276{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002277 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002278 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002279
2280 try
2281 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002282 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002283
2284 if (context)
2285 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002286 context->setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002287 }
2288 }
2289 catch(std::bad_alloc&)
2290 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002291 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002292 }
2293}
2294
2295void __stdcall glBlendEquation(GLenum mode)
2296{
2297 glBlendEquationSeparate(mode, mode);
2298}
2299
2300void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
2301{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002302 EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002303
2304 try
2305 {
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +00002306 gl::Context *context = gl::getNonLostContext();
2307
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002308 switch (modeRGB)
2309 {
2310 case GL_FUNC_ADD:
2311 case GL_FUNC_SUBTRACT:
2312 case GL_FUNC_REVERSE_SUBTRACT:
2313 break;
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +00002314
2315 case GL_MIN:
2316 case GL_MAX:
2317 if (context && context->getClientVersion() < 3)
2318 {
2319 return gl::error(GL_INVALID_ENUM);
2320 }
2321 break;
2322
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002323 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002324 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002325 }
2326
2327 switch (modeAlpha)
2328 {
2329 case GL_FUNC_ADD:
2330 case GL_FUNC_SUBTRACT:
2331 case GL_FUNC_REVERSE_SUBTRACT:
2332 break;
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +00002333
2334 case GL_MIN:
2335 case GL_MAX:
2336 if (context && context->getClientVersion() < 3)
2337 {
2338 return gl::error(GL_INVALID_ENUM);
2339 }
2340 break;
2341
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002342 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002343 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002344 }
2345
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002346 if (context)
2347 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002348 context->setBlendEquation(modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002349 }
2350 }
2351 catch(std::bad_alloc&)
2352 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002353 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002354 }
2355}
2356
2357void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor)
2358{
2359 glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
2360}
2361
2362void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
2363{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002364 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 +00002365 srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002366
2367 try
2368 {
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +00002369 gl::Context *context = gl::getNonLostContext();
2370
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002371 switch (srcRGB)
2372 {
2373 case GL_ZERO:
2374 case GL_ONE:
2375 case GL_SRC_COLOR:
2376 case GL_ONE_MINUS_SRC_COLOR:
2377 case GL_DST_COLOR:
2378 case GL_ONE_MINUS_DST_COLOR:
2379 case GL_SRC_ALPHA:
2380 case GL_ONE_MINUS_SRC_ALPHA:
2381 case GL_DST_ALPHA:
2382 case GL_ONE_MINUS_DST_ALPHA:
2383 case GL_CONSTANT_COLOR:
2384 case GL_ONE_MINUS_CONSTANT_COLOR:
2385 case GL_CONSTANT_ALPHA:
2386 case GL_ONE_MINUS_CONSTANT_ALPHA:
2387 case GL_SRC_ALPHA_SATURATE:
2388 break;
2389 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002390 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002391 }
2392
2393 switch (dstRGB)
2394 {
2395 case GL_ZERO:
2396 case GL_ONE:
2397 case GL_SRC_COLOR:
2398 case GL_ONE_MINUS_SRC_COLOR:
2399 case GL_DST_COLOR:
2400 case GL_ONE_MINUS_DST_COLOR:
2401 case GL_SRC_ALPHA:
2402 case GL_ONE_MINUS_SRC_ALPHA:
2403 case GL_DST_ALPHA:
2404 case GL_ONE_MINUS_DST_ALPHA:
2405 case GL_CONSTANT_COLOR:
2406 case GL_ONE_MINUS_CONSTANT_COLOR:
2407 case GL_CONSTANT_ALPHA:
2408 case GL_ONE_MINUS_CONSTANT_ALPHA:
2409 break;
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +00002410
2411 case GL_SRC_ALPHA_SATURATE:
2412 if (!context || context->getClientVersion() < 3)
2413 {
2414 return gl::error(GL_INVALID_ENUM);
2415 }
2416 break;
2417
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002418 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002419 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002420 }
2421
2422 switch (srcAlpha)
2423 {
2424 case GL_ZERO:
2425 case GL_ONE:
2426 case GL_SRC_COLOR:
2427 case GL_ONE_MINUS_SRC_COLOR:
2428 case GL_DST_COLOR:
2429 case GL_ONE_MINUS_DST_COLOR:
2430 case GL_SRC_ALPHA:
2431 case GL_ONE_MINUS_SRC_ALPHA:
2432 case GL_DST_ALPHA:
2433 case GL_ONE_MINUS_DST_ALPHA:
2434 case GL_CONSTANT_COLOR:
2435 case GL_ONE_MINUS_CONSTANT_COLOR:
2436 case GL_CONSTANT_ALPHA:
2437 case GL_ONE_MINUS_CONSTANT_ALPHA:
2438 case GL_SRC_ALPHA_SATURATE:
2439 break;
2440 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002441 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002442 }
2443
2444 switch (dstAlpha)
2445 {
2446 case GL_ZERO:
2447 case GL_ONE:
2448 case GL_SRC_COLOR:
2449 case GL_ONE_MINUS_SRC_COLOR:
2450 case GL_DST_COLOR:
2451 case GL_ONE_MINUS_DST_COLOR:
2452 case GL_SRC_ALPHA:
2453 case GL_ONE_MINUS_SRC_ALPHA:
2454 case GL_DST_ALPHA:
2455 case GL_ONE_MINUS_DST_ALPHA:
2456 case GL_CONSTANT_COLOR:
2457 case GL_ONE_MINUS_CONSTANT_COLOR:
2458 case GL_CONSTANT_ALPHA:
2459 case GL_ONE_MINUS_CONSTANT_ALPHA:
2460 break;
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +00002461
2462 case GL_SRC_ALPHA_SATURATE:
2463 if (!context || context->getClientVersion() < 3)
2464 {
2465 return gl::error(GL_INVALID_ENUM);
2466 }
2467 break;
2468
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002469 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002470 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002471 }
2472
daniel@transgaming.comfe453652010-03-16 06:23:28 +00002473 bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
2474 dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
2475
2476 bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
2477 dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
2478
2479 if (constantColorUsed && constantAlphaUsed)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002480 {
daniel@transgaming.comfe453652010-03-16 06:23:28 +00002481 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 +00002482 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002483 }
2484
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002485 if (context)
2486 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002487 context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002488 }
2489 }
2490 catch(std::bad_alloc&)
2491 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002492 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002493 }
2494}
2495
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002496void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002497{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002498 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 +00002499 target, size, data, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002500
2501 try
2502 {
2503 if (size < 0)
2504 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002505 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002506 }
2507
shannon.woods%transgaming.com@gtempaccount.comf2db40b2013-04-13 03:37:09 +00002508 gl::Context *context = gl::getNonLostContext();
2509
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002510 switch (usage)
2511 {
2512 case GL_STREAM_DRAW:
2513 case GL_STATIC_DRAW:
2514 case GL_DYNAMIC_DRAW:
2515 break;
shannon.woods%transgaming.com@gtempaccount.comf2db40b2013-04-13 03:37:09 +00002516
2517 case GL_STREAM_READ:
2518 case GL_STREAM_COPY:
2519 case GL_STATIC_READ:
2520 case GL_STATIC_COPY:
2521 case GL_DYNAMIC_READ:
2522 case GL_DYNAMIC_COPY:
2523 if (context && context->getClientVersion() < 3)
2524 {
2525 return gl::error(GL_INVALID_ENUM);
2526 }
2527 break;
2528
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002529 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002530 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002531 }
2532
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002533 if (context)
2534 {
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002535 // Check ES3 specific targets
2536 switch (target)
2537 {
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002538 case GL_COPY_READ_BUFFER:
2539 case GL_COPY_WRITE_BUFFER:
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002540 case GL_PIXEL_PACK_BUFFER:
2541 case GL_PIXEL_UNPACK_BUFFER:
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002542 case GL_UNIFORM_BUFFER:
2543 case GL_TRANSFORM_FEEDBACK_BUFFER:
2544 if (context->getClientVersion() < 3)
2545 {
2546 return gl::error(GL_INVALID_ENUM);
2547 }
2548 }
2549
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002550 gl::Buffer *buffer;
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00002551
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002552 switch (target)
2553 {
2554 case GL_ARRAY_BUFFER:
2555 buffer = context->getArrayBuffer();
2556 break;
2557 case GL_ELEMENT_ARRAY_BUFFER:
2558 buffer = context->getElementArrayBuffer();
2559 break;
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002560 case GL_COPY_READ_BUFFER:
2561 buffer = context->getCopyReadBuffer();
2562 break;
2563 case GL_COPY_WRITE_BUFFER:
2564 buffer = context->getCopyWriteBuffer();
2565 break;
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002566 case GL_PIXEL_PACK_BUFFER:
2567 buffer = context->getPixelPackBuffer();
2568 break;
2569 case GL_PIXEL_UNPACK_BUFFER:
2570 buffer = context->getPixelUnpackBuffer();
2571 break;
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002572 case GL_TRANSFORM_FEEDBACK_BUFFER:
2573 buffer = context->getGenericTransformFeedbackBuffer();
2574 break;
2575 case GL_UNIFORM_BUFFER:
2576 buffer = context->getGenericUniformBuffer();
2577 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002578 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002579 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002580 }
2581
2582 if (!buffer)
2583 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002584 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002585 }
2586
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002587 buffer->bufferData(data, size, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002588 }
2589 }
2590 catch(std::bad_alloc&)
2591 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002592 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002593 }
2594}
2595
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002596void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002597{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002598 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 +00002599 target, offset, size, data);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002600
2601 try
2602 {
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +00002603 if (size < 0 || offset < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002604 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002605 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002606 }
2607
daniel@transgaming.comd4620a32010-03-21 04:31:28 +00002608 if (data == NULL)
2609 {
2610 return;
2611 }
2612
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002613 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002614
2615 if (context)
2616 {
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002617 // Check ES3 specific targets
2618 switch (target)
2619 {
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002620 case GL_COPY_READ_BUFFER:
2621 case GL_COPY_WRITE_BUFFER:
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002622 case GL_PIXEL_PACK_BUFFER:
2623 case GL_PIXEL_UNPACK_BUFFER:
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002624 case GL_UNIFORM_BUFFER:
2625 case GL_TRANSFORM_FEEDBACK_BUFFER:
2626 if (context->getClientVersion() < 3)
2627 {
2628 return gl::error(GL_INVALID_ENUM);
2629 }
2630 }
2631
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002632 gl::Buffer *buffer;
2633
2634 switch (target)
2635 {
2636 case GL_ARRAY_BUFFER:
2637 buffer = context->getArrayBuffer();
2638 break;
2639 case GL_ELEMENT_ARRAY_BUFFER:
2640 buffer = context->getElementArrayBuffer();
2641 break;
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002642 case GL_COPY_READ_BUFFER:
2643 buffer = context->getCopyReadBuffer();
2644 break;
2645 case GL_COPY_WRITE_BUFFER:
2646 buffer = context->getCopyWriteBuffer();
2647 break;
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002648 case GL_PIXEL_PACK_BUFFER:
2649 buffer = context->getPixelPackBuffer();
2650 break;
2651 case GL_PIXEL_UNPACK_BUFFER:
2652 buffer = context->getPixelUnpackBuffer();
2653 break;
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002654 case GL_TRANSFORM_FEEDBACK_BUFFER:
2655 buffer = context->getGenericTransformFeedbackBuffer();
2656 break;
2657 case GL_UNIFORM_BUFFER:
2658 buffer = context->getGenericUniformBuffer();
2659 break;
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002660 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002661 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002662 }
2663
2664 if (!buffer)
2665 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002666 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002667 }
2668
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +00002669 if ((size_t)size + offset > buffer->size())
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002670 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002671 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002672 }
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +00002673
2674 buffer->bufferSubData(data, size, offset);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002675 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002676 }
2677 catch(std::bad_alloc&)
2678 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002679 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002680 }
2681}
2682
2683GLenum __stdcall glCheckFramebufferStatus(GLenum target)
2684{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002685 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002686
2687 try
2688 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002689 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002690 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002691 return gl::error(GL_INVALID_ENUM, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002692 }
2693
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002694 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002695
2696 if (context)
2697 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002698 gl::Framebuffer *framebuffer = NULL;
2699 if (target == GL_READ_FRAMEBUFFER_ANGLE)
2700 {
2701 framebuffer = context->getReadFramebuffer();
2702 }
2703 else
2704 {
2705 framebuffer = context->getDrawFramebuffer();
2706 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002707
2708 return framebuffer->completeness();
2709 }
2710 }
2711 catch(std::bad_alloc&)
2712 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002713 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002714 }
2715
2716 return 0;
2717}
2718
2719void __stdcall glClear(GLbitfield mask)
2720{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00002721 EVENT("(GLbitfield mask = 0x%X)", mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002722
2723 try
2724 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002725 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002726
2727 if (context)
2728 {
2729 context->clear(mask);
2730 }
2731 }
2732 catch(std::bad_alloc&)
2733 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002734 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002735 }
2736}
2737
2738void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
2739{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002740 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002741 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002742
2743 try
2744 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002745 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002746
2747 if (context)
2748 {
2749 context->setClearColor(red, green, blue, alpha);
2750 }
2751 }
2752 catch(std::bad_alloc&)
2753 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002754 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002755 }
2756}
2757
2758void __stdcall glClearDepthf(GLclampf depth)
2759{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002760 EVENT("(GLclampf depth = %f)", depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002761
2762 try
2763 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002764 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002765
2766 if (context)
2767 {
2768 context->setClearDepth(depth);
2769 }
2770 }
2771 catch(std::bad_alloc&)
2772 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002773 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002774 }
2775}
2776
2777void __stdcall glClearStencil(GLint s)
2778{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002779 EVENT("(GLint s = %d)", s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002780
2781 try
2782 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002783 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002784
2785 if (context)
2786 {
2787 context->setClearStencil(s);
2788 }
2789 }
2790 catch(std::bad_alloc&)
2791 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002792 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002793 }
2794}
2795
2796void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
2797{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00002798 EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002799 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002800
2801 try
2802 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002803 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002804
2805 if (context)
2806 {
daniel@transgaming.coma36f98e2010-05-18 18:51:09 +00002807 context->setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002808 }
2809 }
2810 catch(std::bad_alloc&)
2811 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002812 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002813 }
2814}
2815
2816void __stdcall glCompileShader(GLuint shader)
2817{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002818 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002819
2820 try
2821 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002822 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002823
2824 if (context)
2825 {
2826 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00002827
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002828 if (!shaderObject)
2829 {
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +00002830 if (context->getProgram(shader))
2831 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002832 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +00002833 }
2834 else
2835 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002836 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +00002837 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002838 }
2839
2840 shaderObject->compile();
2841 }
2842 }
2843 catch(std::bad_alloc&)
2844 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002845 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002846 }
2847}
2848
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002849void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
2850 GLint border, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002851{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002852 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002853 "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002854 target, level, internalformat, width, height, border, imageSize, data);
2855
2856 try
2857 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002858 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com01868132010-08-24 19:21:17 +00002859
2860 if (context)
2861 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002862 if (context->getClientVersion() < 3 &&
2863 !validateES2TexImageParameters(context, target, level, internalformat, true, false,
2864 0, 0, width, height, 0, GL_NONE, GL_NONE, data))
2865 {
2866 return;
2867 }
2868
2869 if (context->getClientVersion() >= 3 &&
2870 !validateES3TexImageParameters(context, target, level, internalformat, true, false,
2871 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE))
2872 {
2873 return;
2874 }
2875
2876 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002877 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002878 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002879 }
2880
2881 switch (target)
2882 {
2883 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002884 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002885 gl::Texture2D *texture = context->getTexture2D();
2886 texture->setCompressedImage(level, internalformat, width, height, imageSize, data);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002887 }
2888 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002889
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002890 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2891 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2892 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2893 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2894 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2895 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002896 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002897 gl::TextureCubeMap *texture = context->getTextureCubeMap();
2898 texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002899 }
2900 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002901
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002902 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002903 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002904 }
daniel@transgaming.com01868132010-08-24 19:21:17 +00002905 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002906 }
2907 catch(std::bad_alloc&)
2908 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002909 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002910 }
2911}
2912
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002913void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
2914 GLenum format, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002915{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002916 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002917 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002918 "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002919 target, level, xoffset, yoffset, width, height, format, imageSize, data);
2920
2921 try
2922 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002923 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com01868132010-08-24 19:21:17 +00002924
2925 if (context)
2926 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002927 if (context->getClientVersion() < 3 &&
2928 !validateES2TexImageParameters(context, target, level, GL_NONE, true, true,
2929 xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
2930 {
2931 return;
2932 }
2933
2934 if (context->getClientVersion() >= 3 &&
2935 !validateES3TexImageParameters(context, target, level, GL_NONE, true, true,
2936 xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE))
2937 {
2938 return;
2939 }
2940
2941 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002942 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002943 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002944 }
2945
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002946 switch (target)
daniel@transgaming.com01868132010-08-24 19:21:17 +00002947 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002948 case GL_TEXTURE_2D:
daniel@transgaming.com01868132010-08-24 19:21:17 +00002949 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002950 gl::Texture2D *texture = context->getTexture2D();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00002951 texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
daniel@transgaming.com01868132010-08-24 19:21:17 +00002952 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002953 break;
2954
2955 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2956 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2957 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2958 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2959 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2960 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com01868132010-08-24 19:21:17 +00002961 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002962 gl::TextureCubeMap *texture = context->getTextureCubeMap();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00002963 texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
daniel@transgaming.com01868132010-08-24 19:21:17 +00002964 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002965 break;
2966
2967 default:
2968 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com01868132010-08-24 19:21:17 +00002969 }
2970 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002971 }
2972 catch(std::bad_alloc&)
2973 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002974 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002975 }
2976}
2977
2978void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
2979{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002980 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002981 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002982 target, level, internalformat, x, y, width, height, border);
2983
2984 try
2985 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002986 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002987
2988 if (context)
2989 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002990 if (context->getClientVersion() < 3 &&
2991 !validateES2CopyTexImageParameters(context, target, level, internalformat, false,
2992 0, 0, x, y, width, height, border))
daniel@transgaming.com32b11442011-11-19 02:42:48 +00002993 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002994 return;
daniel@transgaming.com32b11442011-11-19 02:42:48 +00002995 }
2996
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002997 if (context->getClientVersion() >= 3 &&
2998 !validateES3CopyTexImageParameters(context, target, level, internalformat, false,
2999 0, 0, 0, x, y, width, height, border))
3000 {
3001 return;
3002 }
3003
3004 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
3005
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00003006 switch (target)
3007 {
3008 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00003009 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00003010 gl::Texture2D *texture = context->getTexture2D();
3011 texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00003012 }
3013 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00003014
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00003015 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
3016 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
3017 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
3018 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
3019 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
3020 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00003021 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00003022 gl::TextureCubeMap *texture = context->getTextureCubeMap();
3023 texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00003024 }
3025 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00003026
3027 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003028 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00003029 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00003030 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003031 }
3032 catch(std::bad_alloc&)
3033 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003034 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003035 }
3036}
3037
3038void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
3039{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003040 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003041 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003042 target, level, xoffset, yoffset, x, y, width, height);
3043
3044 try
3045 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003046 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00003047
3048 if (context)
3049 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00003050 if (context->getClientVersion() < 3 &&
3051 !validateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
3052 xoffset, yoffset, x, y, width, height, 0))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00003053 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00003054 return;
3055 }
3056
3057 if (context->getClientVersion() >= 3 &&
3058 !validateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
3059 xoffset, yoffset, 0, x, y, width, height, 0))
3060 {
3061 return;
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00003062 }
3063
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003064 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00003065
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00003066 switch (target)
daniel@transgaming.combbc57792010-07-28 19:21:05 +00003067 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00003068 case GL_TEXTURE_2D:
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +00003069 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00003070 gl::Texture2D *texture = context->getTexture2D();
3071 texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00003072 }
3073 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00003074
3075 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
3076 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
3077 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
3078 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
3079 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
3080 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com6452adf2012-10-17 18:22:35 +00003081 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00003082 gl::TextureCubeMap *texture = context->getTextureCubeMap();
3083 texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +00003084 }
3085 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00003086
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00003087 default:
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00003088 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00003089 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00003090 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003091 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00003092
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003093 catch(std::bad_alloc&)
3094 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003095 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003096 }
3097}
3098
3099GLuint __stdcall glCreateProgram(void)
3100{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003101 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003102
3103 try
3104 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003105 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003106
3107 if (context)
3108 {
3109 return context->createProgram();
3110 }
3111 }
3112 catch(std::bad_alloc&)
3113 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003114 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003115 }
3116
3117 return 0;
3118}
3119
3120GLuint __stdcall glCreateShader(GLenum type)
3121{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003122 EVENT("(GLenum type = 0x%X)", type);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003123
3124 try
3125 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003126 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003127
3128 if (context)
3129 {
3130 switch (type)
3131 {
3132 case GL_FRAGMENT_SHADER:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003133 case GL_VERTEX_SHADER:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003134 return context->createShader(type);
3135 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003136 return gl::error(GL_INVALID_ENUM, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003137 }
3138 }
3139 }
3140 catch(std::bad_alloc&)
3141 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003142 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003143 }
3144
3145 return 0;
3146}
3147
3148void __stdcall glCullFace(GLenum mode)
3149{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003150 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003151
3152 try
3153 {
3154 switch (mode)
3155 {
3156 case GL_FRONT:
3157 case GL_BACK:
3158 case GL_FRONT_AND_BACK:
3159 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003160 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003161
3162 if (context)
3163 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003164 context->setCullMode(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003165 }
3166 }
3167 break;
3168 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003169 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003170 }
3171 }
3172 catch(std::bad_alloc&)
3173 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003174 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003175 }
3176}
3177
3178void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers)
3179{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003180 EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003181
3182 try
3183 {
3184 if (n < 0)
3185 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003186 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003187 }
3188
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003189 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003190
3191 if (context)
3192 {
3193 for (int i = 0; i < n; i++)
3194 {
3195 context->deleteBuffer(buffers[i]);
3196 }
3197 }
3198 }
3199 catch(std::bad_alloc&)
3200 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003201 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003202 }
3203}
3204
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003205void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences)
3206{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003207 EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003208
3209 try
3210 {
3211 if (n < 0)
3212 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003213 return gl::error(GL_INVALID_VALUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003214 }
3215
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003216 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003217
3218 if (context)
3219 {
3220 for (int i = 0; i < n; i++)
3221 {
3222 context->deleteFence(fences[i]);
3223 }
3224 }
3225 }
3226 catch(std::bad_alloc&)
3227 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003228 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003229 }
3230}
3231
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003232void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
3233{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003234 EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003235
3236 try
3237 {
3238 if (n < 0)
3239 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003240 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003241 }
3242
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003243 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003244
3245 if (context)
3246 {
3247 for (int i = 0; i < n; i++)
3248 {
3249 if (framebuffers[i] != 0)
3250 {
3251 context->deleteFramebuffer(framebuffers[i]);
3252 }
3253 }
3254 }
3255 }
3256 catch(std::bad_alloc&)
3257 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003258 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003259 }
3260}
3261
3262void __stdcall glDeleteProgram(GLuint program)
3263{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003264 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003265
3266 try
3267 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003268 if (program == 0)
3269 {
3270 return;
3271 }
3272
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003273 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003274
3275 if (context)
3276 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003277 if (!context->getProgram(program))
3278 {
3279 if(context->getShader(program))
3280 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003281 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003282 }
3283 else
3284 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003285 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003286 }
3287 }
3288
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003289 context->deleteProgram(program);
3290 }
3291 }
3292 catch(std::bad_alloc&)
3293 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003294 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003295 }
3296}
3297
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003298void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
3299{
3300 EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
3301
3302 try
3303 {
3304 if (n < 0)
3305 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003306 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003307 }
3308
3309 gl::Context *context = gl::getNonLostContext();
3310
3311 if (context)
3312 {
3313 for (int i = 0; i < n; i++)
3314 {
3315 context->deleteQuery(ids[i]);
3316 }
3317 }
3318 }
3319 catch(std::bad_alloc&)
3320 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003321 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003322 }
3323}
3324
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003325void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
3326{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003327 EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003328
3329 try
3330 {
3331 if (n < 0)
3332 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003333 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003334 }
3335
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003336 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003337
3338 if (context)
3339 {
daniel@transgaming.come2b22122010-03-11 19:22:14 +00003340 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003341 {
3342 context->deleteRenderbuffer(renderbuffers[i]);
3343 }
3344 }
3345 }
3346 catch(std::bad_alloc&)
3347 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003348 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003349 }
3350}
3351
3352void __stdcall glDeleteShader(GLuint shader)
3353{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003354 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003355
3356 try
3357 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003358 if (shader == 0)
3359 {
3360 return;
3361 }
3362
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003363 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003364
3365 if (context)
3366 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003367 if (!context->getShader(shader))
3368 {
3369 if(context->getProgram(shader))
3370 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003371 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003372 }
3373 else
3374 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003375 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003376 }
3377 }
3378
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003379 context->deleteShader(shader);
3380 }
3381 }
3382 catch(std::bad_alloc&)
3383 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003384 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003385 }
3386}
3387
3388void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures)
3389{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003390 EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003391
3392 try
3393 {
3394 if (n < 0)
3395 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003396 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003397 }
3398
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003399 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003400
3401 if (context)
3402 {
3403 for (int i = 0; i < n; i++)
3404 {
3405 if (textures[i] != 0)
3406 {
3407 context->deleteTexture(textures[i]);
3408 }
3409 }
3410 }
3411 }
3412 catch(std::bad_alloc&)
3413 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003414 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003415 }
3416}
3417
3418void __stdcall glDepthFunc(GLenum func)
3419{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003420 EVENT("(GLenum func = 0x%X)", func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003421
3422 try
3423 {
3424 switch (func)
3425 {
3426 case GL_NEVER:
3427 case GL_ALWAYS:
3428 case GL_LESS:
3429 case GL_LEQUAL:
3430 case GL_EQUAL:
3431 case GL_GREATER:
3432 case GL_GEQUAL:
3433 case GL_NOTEQUAL:
3434 break;
3435 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003436 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003437 }
3438
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003439 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003440
3441 if (context)
3442 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003443 context->setDepthFunc(func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003444 }
3445 }
3446 catch(std::bad_alloc&)
3447 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003448 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003449 }
3450}
3451
3452void __stdcall glDepthMask(GLboolean flag)
3453{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00003454 EVENT("(GLboolean flag = %u)", flag);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003455
3456 try
3457 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003458 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003459
3460 if (context)
3461 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003462 context->setDepthMask(flag != GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003463 }
3464 }
3465 catch(std::bad_alloc&)
3466 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003467 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003468 }
3469}
3470
3471void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar)
3472{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003473 EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003474
3475 try
3476 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003477 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003478
3479 if (context)
3480 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003481 context->setDepthRange(zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003482 }
3483 }
3484 catch(std::bad_alloc&)
3485 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003486 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003487 }
3488}
3489
3490void __stdcall glDetachShader(GLuint program, GLuint shader)
3491{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003492 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003493
3494 try
3495 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003496 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003497
3498 if (context)
3499 {
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003500
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003501 gl::Program *programObject = context->getProgram(program);
3502 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003503
3504 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003505 {
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003506 gl::Shader *shaderByProgramHandle;
3507 shaderByProgramHandle = context->getShader(program);
3508 if (!shaderByProgramHandle)
3509 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003510 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003511 }
3512 else
3513 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003514 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003515 }
3516 }
3517
3518 if (!shaderObject)
3519 {
3520 gl::Program *programByShaderHandle = context->getProgram(shader);
3521 if (!programByShaderHandle)
3522 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003523 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003524 }
3525 else
3526 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003527 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003528 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003529 }
3530
3531 if (!programObject->detachShader(shaderObject))
3532 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003533 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003534 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003535 }
3536 }
3537 catch(std::bad_alloc&)
3538 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003539 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003540 }
3541}
3542
3543void __stdcall glDisable(GLenum cap)
3544{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003545 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003546
3547 try
3548 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003549 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003550
3551 if (context)
3552 {
3553 switch (cap)
3554 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003555 case GL_CULL_FACE: context->setCullFace(false); break;
3556 case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break;
3557 case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break;
3558 case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break;
3559 case GL_SCISSOR_TEST: context->setScissorTest(false); break;
3560 case GL_STENCIL_TEST: context->setStencilTest(false); break;
3561 case GL_DEPTH_TEST: context->setDepthTest(false); break;
3562 case GL_BLEND: context->setBlend(false); break;
3563 case GL_DITHER: context->setDither(false); break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00003564
3565 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
3566 case GL_RASTERIZER_DISCARD:
3567 if (context->getClientVersion() < 3)
3568 {
3569 return gl::error(GL_INVALID_ENUM);
3570 }
3571 UNIMPLEMENTED();
3572 break;
3573
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003574 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003575 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003576 }
3577 }
3578 }
3579 catch(std::bad_alloc&)
3580 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003581 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003582 }
3583}
3584
3585void __stdcall glDisableVertexAttribArray(GLuint index)
3586{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003587 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003588
3589 try
3590 {
3591 if (index >= gl::MAX_VERTEX_ATTRIBS)
3592 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003593 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003594 }
3595
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003596 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003597
3598 if (context)
3599 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00003600 context->setEnableVertexAttribArray(index, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003601 }
3602 }
3603 catch(std::bad_alloc&)
3604 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003605 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003606 }
3607}
3608
3609void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count)
3610{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003611 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003612
3613 try
3614 {
3615 if (count < 0 || first < 0)
3616 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003617 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003618 }
3619
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003620 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003621
3622 if (context)
3623 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003624 context->drawArrays(mode, first, count, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003625 }
3626 }
3627 catch(std::bad_alloc&)
3628 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003629 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003630 }
3631}
3632
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003633void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
3634{
3635 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
3636
3637 try
3638 {
3639 if (count < 0 || first < 0 || primcount < 0)
3640 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003641 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003642 }
3643
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003644 if (primcount > 0)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003645 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003646 gl::Context *context = gl::getNonLostContext();
3647
3648 if (context)
3649 {
3650 context->drawArrays(mode, first, count, primcount);
3651 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003652 }
3653 }
3654 catch(std::bad_alloc&)
3655 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003656 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003657 }
3658}
3659
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003660void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003661{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003662 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 +00003663 mode, count, type, indices);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003664
3665 try
3666 {
3667 if (count < 0)
3668 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003669 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003670 }
3671
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003672 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003673
3674 if (context)
3675 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00003676 switch (type)
3677 {
3678 case GL_UNSIGNED_BYTE:
3679 case GL_UNSIGNED_SHORT:
3680 break;
3681 case GL_UNSIGNED_INT:
3682 if (!context->supports32bitIndices())
3683 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003684 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com83921382011-01-08 05:46:00 +00003685 }
3686 break;
3687 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003688 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com83921382011-01-08 05:46:00 +00003689 }
3690
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003691 context->drawElements(mode, count, type, indices, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003692 }
3693 }
3694 catch(std::bad_alloc&)
3695 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003696 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003697 }
3698}
3699
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003700void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
3701{
3702 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
3703 mode, count, type, indices, primcount);
3704
3705 try
3706 {
3707 if (count < 0 || primcount < 0)
3708 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003709 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003710 }
3711
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003712 if (primcount > 0)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003713 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003714 gl::Context *context = gl::getNonLostContext();
3715
3716 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003717 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003718 switch (type)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003719 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003720 case GL_UNSIGNED_BYTE:
3721 case GL_UNSIGNED_SHORT:
3722 break;
3723 case GL_UNSIGNED_INT:
3724 if (!context->supports32bitIndices())
3725 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003726 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003727 }
3728 break;
3729 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003730 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003731 }
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003732
3733 context->drawElements(mode, count, type, indices, primcount);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003734 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003735 }
3736 }
3737 catch(std::bad_alloc&)
3738 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003739 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003740 }
3741}
3742
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003743void __stdcall glEnable(GLenum cap)
3744{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003745 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003746
3747 try
3748 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003749 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003750
3751 if (context)
3752 {
3753 switch (cap)
3754 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003755 case GL_CULL_FACE: context->setCullFace(true); break;
3756 case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break;
3757 case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break;
3758 case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break;
3759 case GL_SCISSOR_TEST: context->setScissorTest(true); break;
3760 case GL_STENCIL_TEST: context->setStencilTest(true); break;
3761 case GL_DEPTH_TEST: context->setDepthTest(true); break;
3762 case GL_BLEND: context->setBlend(true); break;
3763 case GL_DITHER: context->setDither(true); break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003764 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003765 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003766 }
3767 }
3768 }
3769 catch(std::bad_alloc&)
3770 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003771 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003772 }
3773}
3774
3775void __stdcall glEnableVertexAttribArray(GLuint index)
3776{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003777 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003778
3779 try
3780 {
3781 if (index >= gl::MAX_VERTEX_ATTRIBS)
3782 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003783 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003784 }
3785
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003786 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003787
3788 if (context)
3789 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00003790 context->setEnableVertexAttribArray(index, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003791 }
3792 }
3793 catch(std::bad_alloc&)
3794 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003795 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003796 }
3797}
3798
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003799void __stdcall glEndQueryEXT(GLenum target)
3800{
3801 EVENT("GLenum target = 0x%X)", target);
3802
3803 try
3804 {
3805 switch (target)
3806 {
3807 case GL_ANY_SAMPLES_PASSED_EXT:
3808 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
3809 break;
3810 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003811 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003812 }
3813
3814 gl::Context *context = gl::getNonLostContext();
3815
3816 if (context)
3817 {
3818 context->endQuery(target);
3819 }
3820 }
3821 catch(std::bad_alloc&)
3822 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003823 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003824 }
3825}
3826
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003827void __stdcall glFinishFenceNV(GLuint fence)
3828{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003829 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003830
3831 try
3832 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003833 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003834
3835 if (context)
3836 {
3837 gl::Fence* fenceObject = context->getFence(fence);
3838
3839 if (fenceObject == NULL)
3840 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003841 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003842 }
3843
3844 fenceObject->finishFence();
3845 }
3846 }
3847 catch(std::bad_alloc&)
3848 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003849 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003850 }
3851}
3852
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003853void __stdcall glFinish(void)
3854{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003855 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003856
3857 try
3858 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003859 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003860
3861 if (context)
3862 {
daniel@transgaming.com0d86aa72011-10-26 02:35:10 +00003863 context->sync(true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003864 }
3865 }
3866 catch(std::bad_alloc&)
3867 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003868 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003869 }
3870}
3871
3872void __stdcall glFlush(void)
3873{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003874 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003875
3876 try
3877 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003878 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003879
3880 if (context)
3881 {
daniel@transgaming.com0d86aa72011-10-26 02:35:10 +00003882 context->sync(false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003883 }
3884 }
3885 catch(std::bad_alloc&)
3886 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003887 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003888 }
3889}
3890
3891void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
3892{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003893 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003894 "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003895
3896 try
3897 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003898 if ((target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com2fa45512011-10-04 18:43:18 +00003899 || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003900 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003901 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003902 }
3903
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003904 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003905
3906 if (context)
3907 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003908 gl::Framebuffer *framebuffer = NULL;
3909 GLuint framebufferHandle = 0;
3910 if (target == GL_READ_FRAMEBUFFER_ANGLE)
3911 {
3912 framebuffer = context->getReadFramebuffer();
3913 framebufferHandle = context->getReadFramebufferHandle();
3914 }
daniel@transgaming.com2fa45512011-10-04 18:43:18 +00003915 else
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003916 {
3917 framebuffer = context->getDrawFramebuffer();
3918 framebufferHandle = context->getDrawFramebufferHandle();
3919 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003920
daniel@transgaming.com2fa45512011-10-04 18:43:18 +00003921 if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003922 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003923 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003924 }
3925
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003926 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003927 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003928 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
3929
3930 if (colorAttachment >= context->getMaximumRenderTargets())
3931 {
3932 return gl::error(GL_INVALID_VALUE);
3933 }
3934
3935 framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer);
3936 }
3937 else
3938 {
3939 switch (attachment)
3940 {
3941 case GL_DEPTH_ATTACHMENT:
3942 framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer);
3943 break;
3944 case GL_STENCIL_ATTACHMENT:
3945 framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer);
3946 break;
3947 default:
3948 return gl::error(GL_INVALID_ENUM);
3949 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003950 }
3951 }
3952 }
3953 catch(std::bad_alloc&)
3954 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003955 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003956 }
3957}
3958
3959void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
3960{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003961 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003962 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003963
3964 try
3965 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003966 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003967 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003968 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003969 }
3970
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003971 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003972
3973 if (context)
3974 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003975 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
3976 {
3977 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
3978
3979 if (colorAttachment >= context->getMaximumRenderTargets())
3980 {
3981 return gl::error(GL_INVALID_VALUE);
3982 }
3983 }
3984 else
3985 {
3986 switch (attachment)
3987 {
3988 case GL_DEPTH_ATTACHMENT:
3989 case GL_STENCIL_ATTACHMENT:
3990 break;
3991 default:
3992 return gl::error(GL_INVALID_ENUM);
3993 }
3994 }
3995
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003996 if (texture == 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003997 {
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003998 textarget = GL_NONE;
3999 }
4000 else
4001 {
4002 gl::Texture *tex = context->getTexture(texture);
4003
4004 if (tex == NULL)
4005 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004006 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com93a81472010-04-20 18:52:58 +00004007 }
4008
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004009 switch (textarget)
4010 {
4011 case GL_TEXTURE_2D:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004012 {
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00004013 if (tex->getTarget() != GL_TEXTURE_2D)
4014 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004015 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00004016 }
4017 gl::Texture2D *tex2d = static_cast<gl::Texture2D *>(tex);
daniel@transgaming.com92f49922012-05-09 15:49:19 +00004018 if (tex2d->isCompressed(0))
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00004019 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004020 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00004021 }
4022 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004023 }
daniel@transgaming.com93a81472010-04-20 18:52:58 +00004024
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004025 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004026 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004027 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004028 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004029 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004030 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com93a81472010-04-20 18:52:58 +00004031 {
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00004032 if (tex->getTarget() != GL_TEXTURE_CUBE_MAP)
4033 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004034 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00004035 }
4036 gl::TextureCubeMap *texcube = static_cast<gl::TextureCubeMap *>(tex);
daniel@transgaming.com4df88e82012-05-09 15:49:24 +00004037 if (texcube->isCompressed(textarget, level))
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00004038 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004039 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00004040 }
4041 break;
daniel@transgaming.com93a81472010-04-20 18:52:58 +00004042 }
daniel@transgaming.com93a81472010-04-20 18:52:58 +00004043
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004044 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004045 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004046 }
4047
4048 if (level != 0)
4049 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004050 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004051 }
4052 }
4053
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004054 gl::Framebuffer *framebuffer = NULL;
4055 GLuint framebufferHandle = 0;
4056 if (target == GL_READ_FRAMEBUFFER_ANGLE)
4057 {
4058 framebuffer = context->getReadFramebuffer();
4059 framebufferHandle = context->getReadFramebufferHandle();
4060 }
4061 else
4062 {
4063 framebuffer = context->getDrawFramebuffer();
4064 framebufferHandle = context->getDrawFramebufferHandle();
4065 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004066
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004067 if (framebufferHandle == 0 || !framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004068 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004069 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004070 }
4071
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00004072 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00004073 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00004074 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
4075
4076 if (colorAttachment >= context->getMaximumRenderTargets())
4077 {
4078 return gl::error(GL_INVALID_VALUE);
4079 }
4080
4081 framebuffer->setColorbuffer(colorAttachment, textarget, texture);
4082 }
4083 else
4084 {
4085 switch (attachment)
4086 {
4087 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break;
4088 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break;
4089 }
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00004090 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004091 }
4092 }
4093 catch(std::bad_alloc&)
4094 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004095 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004096 }
4097}
4098
4099void __stdcall glFrontFace(GLenum mode)
4100{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004101 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004102
4103 try
4104 {
4105 switch (mode)
4106 {
4107 case GL_CW:
4108 case GL_CCW:
4109 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004110 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004111
4112 if (context)
4113 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004114 context->setFrontFace(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004115 }
4116 }
4117 break;
4118 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004119 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004120 }
4121 }
4122 catch(std::bad_alloc&)
4123 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004124 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004125 }
4126}
4127
4128void __stdcall glGenBuffers(GLsizei n, GLuint* buffers)
4129{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004130 EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004131
4132 try
4133 {
4134 if (n < 0)
4135 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004136 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004137 }
4138
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004139 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004140
4141 if (context)
4142 {
4143 for (int i = 0; i < n; i++)
4144 {
4145 buffers[i] = context->createBuffer();
4146 }
4147 }
4148 }
4149 catch(std::bad_alloc&)
4150 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004151 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004152 }
4153}
4154
4155void __stdcall glGenerateMipmap(GLenum target)
4156{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004157 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004158
4159 try
4160 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004161 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00004162
4163 if (context)
4164 {
Geoff Langae4852a2013-06-05 15:00:34 -04004165 gl::Texture *texture = NULL;
4166 GLint internalFormat = GL_NONE;
4167 bool isCompressed = false;
4168 bool isDepth = false;
4169
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00004170 switch (target)
4171 {
4172 case GL_TEXTURE_2D:
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00004173 {
4174 gl::Texture2D *tex2d = context->getTexture2D();
Geoff Langae4852a2013-06-05 15:00:34 -04004175 if (tex2d)
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00004176 {
Geoff Langae4852a2013-06-05 15:00:34 -04004177 internalFormat = tex2d->getInternalFormat(0);
4178 isCompressed = tex2d->isCompressed(0);
4179 isDepth = tex2d->isDepth(0);
4180 texture = tex2d;
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00004181 }
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00004182 break;
4183 }
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00004184
4185 case GL_TEXTURE_CUBE_MAP:
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00004186 {
4187 gl::TextureCubeMap *texcube = context->getTextureCubeMap();
Geoff Langae4852a2013-06-05 15:00:34 -04004188 if (texcube)
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00004189 {
Geoff Langae4852a2013-06-05 15:00:34 -04004190 internalFormat = texcube->getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0);
4191 isCompressed = texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0);
4192 isDepth = false;
4193 texture = texcube;
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00004194 }
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00004195 break;
4196 }
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00004197
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00004198 case GL_TEXTURE_3D:
4199 {
4200 if (context->getClientVersion() < 3)
4201 {
4202 return gl::error(GL_INVALID_ENUM);
4203 }
4204
4205 gl::Texture3D *tex3D = context->getTexture3D();
Geoff Langae4852a2013-06-05 15:00:34 -04004206 if (tex3D)
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00004207 {
Geoff Langae4852a2013-06-05 15:00:34 -04004208 internalFormat = tex3D->getInternalFormat(0);
4209 isCompressed = tex3D->isCompressed(0);
4210 isDepth = tex3D->isDepth(0);
4211 texture = tex3D;
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00004212 }
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00004213 break;
4214 }
4215
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00004216 case GL_TEXTURE_2D_ARRAY:
4217 {
4218 if (context->getClientVersion() < 3)
4219 {
4220 return gl::error(GL_INVALID_ENUM);
4221 }
4222
4223 gl::Texture2DArray *tex2darr = context->getTexture2DArray();
Geoff Langae4852a2013-06-05 15:00:34 -04004224 if (tex2darr)
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00004225 {
Geoff Langae4852a2013-06-05 15:00:34 -04004226 internalFormat = tex2darr->getInternalFormat(0);
4227 isCompressed = tex2darr->isCompressed(0);
4228 isDepth = tex2darr->isDepth(0);
4229 texture = tex2darr;
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00004230 }
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00004231 break;
4232 }
4233
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00004234 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004235 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00004236 }
Geoff Langae4852a2013-06-05 15:00:34 -04004237
4238 if (!texture)
4239 {
4240 return gl::error(GL_INVALID_OPERATION);
4241 }
4242
4243 // Internally, all texture formats are sized so checking if the format
4244 // is color renderable and filterable will not fail.
4245 if (isDepth || isCompressed ||
4246 !gl::IsColorRenderingSupported(internalFormat, context) ||
4247 !gl::IsTextureFilteringSupported(internalFormat, context))
4248 {
4249 return gl::error(GL_INVALID_OPERATION);
4250 }
4251
4252 texture->generateMipmaps();
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00004253 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004254 }
4255 catch(std::bad_alloc&)
4256 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004257 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004258 }
4259}
4260
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004261void __stdcall glGenFencesNV(GLsizei n, GLuint* fences)
4262{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004263 EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004264
4265 try
4266 {
4267 if (n < 0)
4268 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004269 return gl::error(GL_INVALID_VALUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004270 }
4271
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004272 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004273
4274 if (context)
4275 {
4276 for (int i = 0; i < n; i++)
4277 {
4278 fences[i] = context->createFence();
4279 }
4280 }
4281 }
4282 catch(std::bad_alloc&)
4283 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004284 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004285 }
4286}
4287
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004288void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers)
4289{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004290 EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004291
4292 try
4293 {
4294 if (n < 0)
4295 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004296 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004297 }
4298
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004299 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004300
4301 if (context)
4302 {
4303 for (int i = 0; i < n; i++)
4304 {
4305 framebuffers[i] = context->createFramebuffer();
4306 }
4307 }
4308 }
4309 catch(std::bad_alloc&)
4310 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004311 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004312 }
4313}
4314
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004315void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids)
4316{
4317 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
4318
4319 try
4320 {
4321 if (n < 0)
4322 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004323 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004324 }
4325
4326 gl::Context *context = gl::getNonLostContext();
4327
4328 if (context)
4329 {
4330 for (int i = 0; i < n; i++)
4331 {
4332 ids[i] = context->createQuery();
4333 }
4334 }
4335 }
4336 catch(std::bad_alloc&)
4337 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004338 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004339 }
4340}
4341
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004342void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
4343{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004344 EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004345
4346 try
4347 {
4348 if (n < 0)
4349 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004350 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004351 }
4352
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004353 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004354
4355 if (context)
4356 {
4357 for (int i = 0; i < n; i++)
4358 {
4359 renderbuffers[i] = context->createRenderbuffer();
4360 }
4361 }
4362 }
4363 catch(std::bad_alloc&)
4364 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004365 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004366 }
4367}
4368
4369void __stdcall glGenTextures(GLsizei n, GLuint* textures)
4370{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004371 EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004372
4373 try
4374 {
4375 if (n < 0)
4376 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004377 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004378 }
4379
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004380 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004381
4382 if (context)
4383 {
4384 for (int i = 0; i < n; i++)
4385 {
4386 textures[i] = context->createTexture();
4387 }
4388 }
4389 }
4390 catch(std::bad_alloc&)
4391 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004392 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004393 }
4394}
4395
daniel@transgaming.com85423182010-04-22 13:35:27 +00004396void __stdcall glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004397{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004398 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
daniel@transgaming.com85423182010-04-22 13:35:27 +00004399 "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004400 program, index, bufsize, length, size, type, name);
4401
4402 try
4403 {
4404 if (bufsize < 0)
4405 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004406 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004407 }
4408
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004409 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com85423182010-04-22 13:35:27 +00004410
4411 if (context)
4412 {
4413 gl::Program *programObject = context->getProgram(program);
4414
4415 if (!programObject)
4416 {
4417 if (context->getShader(program))
4418 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004419 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com85423182010-04-22 13:35:27 +00004420 }
4421 else
4422 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004423 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com85423182010-04-22 13:35:27 +00004424 }
4425 }
4426
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004427 if (index >= (GLuint)programObject->getActiveAttributeCount())
daniel@transgaming.com85423182010-04-22 13:35:27 +00004428 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004429 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com85423182010-04-22 13:35:27 +00004430 }
4431
4432 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
4433 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004434 }
4435 catch(std::bad_alloc&)
4436 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004437 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004438 }
4439}
4440
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004441void __stdcall glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004442{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004443 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004444 "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 +00004445 program, index, bufsize, length, size, type, name);
4446
4447 try
4448 {
4449 if (bufsize < 0)
4450 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004451 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004452 }
4453
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004454 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004455
4456 if (context)
4457 {
4458 gl::Program *programObject = context->getProgram(program);
4459
4460 if (!programObject)
4461 {
4462 if (context->getShader(program))
4463 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004464 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004465 }
4466 else
4467 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004468 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004469 }
4470 }
4471
4472 if (index >= (GLuint)programObject->getActiveUniformCount())
4473 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004474 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004475 }
4476
4477 programObject->getActiveUniform(index, bufsize, length, size, type, name);
4478 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004479 }
4480 catch(std::bad_alloc&)
4481 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004482 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004483 }
4484}
4485
4486void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
4487{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004488 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 +00004489 program, maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004490
4491 try
4492 {
4493 if (maxcount < 0)
4494 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004495 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004496 }
4497
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004498 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com6c785212010-03-30 03:36:17 +00004499
4500 if (context)
4501 {
4502 gl::Program *programObject = context->getProgram(program);
4503
4504 if (!programObject)
4505 {
daniel@transgaming.com23953e32010-04-13 19:53:31 +00004506 if (context->getShader(program))
4507 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004508 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com23953e32010-04-13 19:53:31 +00004509 }
4510 else
4511 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004512 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com23953e32010-04-13 19:53:31 +00004513 }
daniel@transgaming.com6c785212010-03-30 03:36:17 +00004514 }
4515
4516 return programObject->getAttachedShaders(maxcount, count, shaders);
4517 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004518 }
4519 catch(std::bad_alloc&)
4520 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004521 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004522 }
4523}
4524
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004525int __stdcall glGetAttribLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004526{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004527 EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004528
4529 try
4530 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004531 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004532
4533 if (context)
4534 {
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004535
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004536 gl::Program *programObject = context->getProgram(program);
4537
4538 if (!programObject)
4539 {
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004540 if (context->getShader(program))
4541 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004542 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004543 }
4544 else
4545 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004546 return gl::error(GL_INVALID_VALUE, -1);
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004547 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004548 }
4549
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00004550 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
daniel@transgaming.com716056c2012-07-24 18:38:59 +00004551 if (!programObject->isLinked() || !programBinary)
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00004552 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004553 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00004554 }
4555
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00004556 return programBinary->getAttributeLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004557 }
4558 }
4559 catch(std::bad_alloc&)
4560 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004561 return gl::error(GL_OUT_OF_MEMORY, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004562 }
4563
4564 return -1;
4565}
4566
4567void __stdcall glGetBooleanv(GLenum pname, GLboolean* params)
4568{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004569 EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004570
4571 try
4572 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004573 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004574
4575 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004576 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004577 if (!(context->getBooleanv(pname, params)))
4578 {
4579 GLenum nativeType;
4580 unsigned int numParams = 0;
4581 if (!context->getQueryParameterInfo(pname, &nativeType, &numParams))
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004582 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004583
4584 if (numParams == 0)
4585 return; // it is known that the pname is valid, but there are no parameters to return
4586
4587 if (nativeType == GL_FLOAT)
4588 {
4589 GLfloat *floatParams = NULL;
4590 floatParams = new GLfloat[numParams];
4591
4592 context->getFloatv(pname, floatParams);
4593
4594 for (unsigned int i = 0; i < numParams; ++i)
4595 {
4596 if (floatParams[i] == 0.0f)
4597 params[i] = GL_FALSE;
4598 else
4599 params[i] = GL_TRUE;
4600 }
4601
4602 delete [] floatParams;
4603 }
4604 else if (nativeType == GL_INT)
4605 {
4606 GLint *intParams = NULL;
4607 intParams = new GLint[numParams];
4608
4609 context->getIntegerv(pname, intParams);
4610
4611 for (unsigned int i = 0; i < numParams; ++i)
4612 {
4613 if (intParams[i] == 0)
4614 params[i] = GL_FALSE;
4615 else
4616 params[i] = GL_TRUE;
4617 }
4618
4619 delete [] intParams;
4620 }
4621 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004622 }
4623 }
4624 catch(std::bad_alloc&)
4625 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004626 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004627 }
4628}
4629
4630void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
4631{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004632 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 +00004633
4634 try
4635 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004636 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004637
4638 if (context)
4639 {
4640 gl::Buffer *buffer;
4641
4642 switch (target)
4643 {
4644 case GL_ARRAY_BUFFER:
4645 buffer = context->getArrayBuffer();
4646 break;
4647 case GL_ELEMENT_ARRAY_BUFFER:
4648 buffer = context->getElementArrayBuffer();
4649 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004650 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004651 }
4652
4653 if (!buffer)
4654 {
4655 // A null buffer means that "0" is bound to the requested buffer target
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004656 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004657 }
4658
4659 switch (pname)
4660 {
4661 case GL_BUFFER_USAGE:
4662 *params = buffer->usage();
4663 break;
4664 case GL_BUFFER_SIZE:
4665 *params = buffer->size();
4666 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004667 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004668 }
4669 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004670 }
4671 catch(std::bad_alloc&)
4672 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004673 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004674 }
4675}
4676
4677GLenum __stdcall glGetError(void)
4678{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004679 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004680
4681 gl::Context *context = gl::getContext();
4682
4683 if (context)
4684 {
daniel@transgaming.com82b28912011-12-12 21:01:35 +00004685 return context->getError();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004686 }
4687
4688 return GL_NO_ERROR;
4689}
4690
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004691void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
4692{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004693 EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004694
4695 try
4696 {
4697
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004698 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004699
4700 if (context)
4701 {
4702 gl::Fence *fenceObject = context->getFence(fence);
4703
4704 if (fenceObject == NULL)
4705 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004706 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004707 }
4708
4709 fenceObject->getFenceiv(pname, params);
4710 }
4711 }
4712 catch(std::bad_alloc&)
4713 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004714 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004715 }
4716}
4717
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004718void __stdcall glGetFloatv(GLenum pname, GLfloat* params)
4719{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004720 EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004721
4722 try
4723 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004724 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004725
4726 if (context)
4727 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004728 if (!(context->getFloatv(pname, params)))
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004729 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004730 GLenum nativeType;
4731 unsigned int numParams = 0;
4732 if (!context->getQueryParameterInfo(pname, &nativeType, &numParams))
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004733 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004734
4735 if (numParams == 0)
4736 return; // it is known that the pname is valid, but that there are no parameters to return.
4737
4738 if (nativeType == GL_BOOL)
4739 {
4740 GLboolean *boolParams = NULL;
4741 boolParams = new GLboolean[numParams];
4742
4743 context->getBooleanv(pname, boolParams);
4744
4745 for (unsigned int i = 0; i < numParams; ++i)
4746 {
4747 if (boolParams[i] == GL_FALSE)
4748 params[i] = 0.0f;
4749 else
4750 params[i] = 1.0f;
4751 }
4752
4753 delete [] boolParams;
4754 }
4755 else if (nativeType == GL_INT)
4756 {
4757 GLint *intParams = NULL;
4758 intParams = new GLint[numParams];
4759
4760 context->getIntegerv(pname, intParams);
4761
4762 for (unsigned int i = 0; i < numParams; ++i)
4763 {
4764 params[i] = (GLfloat)intParams[i];
4765 }
4766
4767 delete [] intParams;
4768 }
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004769 }
4770 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004771 }
4772 catch(std::bad_alloc&)
4773 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004774 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004775 }
4776}
4777
4778void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
4779{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004780 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 +00004781 target, attachment, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004782
4783 try
4784 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004785 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004786
4787 if (context)
4788 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004789 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004790 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004791 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004792 }
4793
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004794 gl::Framebuffer *framebuffer = NULL;
4795 if (target == GL_READ_FRAMEBUFFER_ANGLE)
4796 {
4797 if(context->getReadFramebufferHandle() == 0)
4798 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004799 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004800 }
4801
4802 framebuffer = context->getReadFramebuffer();
4803 }
4804 else
4805 {
4806 if (context->getDrawFramebufferHandle() == 0)
4807 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004808 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004809 }
4810
4811 framebuffer = context->getDrawFramebuffer();
4812 }
4813
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004814 GLenum attachmentType;
4815 GLuint attachmentHandle;
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00004816
4817 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004818 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00004819 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
4820
4821 if (colorAttachment >= context->getMaximumRenderTargets())
4822 {
4823 return gl::error(GL_INVALID_ENUM);
4824 }
4825
4826 attachmentType = framebuffer->getColorbufferType(colorAttachment);
4827 attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment);
4828 }
4829 else
4830 {
4831 switch (attachment)
4832 {
4833 case GL_DEPTH_ATTACHMENT:
4834 attachmentType = framebuffer->getDepthbufferType();
4835 attachmentHandle = framebuffer->getDepthbufferHandle();
4836 break;
4837 case GL_STENCIL_ATTACHMENT:
4838 attachmentType = framebuffer->getStencilbufferType();
4839 attachmentHandle = framebuffer->getStencilbufferHandle();
4840 break;
4841 default: return gl::error(GL_INVALID_ENUM);
4842 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004843 }
4844
4845 GLenum attachmentObjectType; // Type category
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00004846 if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004847 {
4848 attachmentObjectType = attachmentType;
4849 }
apatrick@chromium.org551022e2012-01-23 19:56:54 +00004850 else if (gl::IsInternalTextureTarget(attachmentType))
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004851 {
4852 attachmentObjectType = GL_TEXTURE;
4853 }
apatrick@chromium.orga1d80592012-01-25 21:52:10 +00004854 else
4855 {
4856 UNREACHABLE();
4857 return;
4858 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004859
4860 switch (pname)
4861 {
4862 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
4863 *params = attachmentObjectType;
4864 break;
4865 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
4866 if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE)
4867 {
4868 *params = attachmentHandle;
4869 }
4870 else
4871 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004872 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004873 }
4874 break;
4875 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
4876 if (attachmentObjectType == GL_TEXTURE)
4877 {
4878 *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0
4879 }
4880 else
4881 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004882 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004883 }
4884 break;
4885 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
4886 if (attachmentObjectType == GL_TEXTURE)
4887 {
daniel@transgaming.com19ffc242010-05-04 03:35:21 +00004888 if (gl::IsCubemapTextureTarget(attachmentType))
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004889 {
4890 *params = attachmentType;
4891 }
4892 else
4893 {
4894 *params = 0;
4895 }
4896 }
4897 else
4898 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004899 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004900 }
4901 break;
4902 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004903 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004904 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004905 }
4906 }
4907 catch(std::bad_alloc&)
4908 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004909 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004910 }
4911}
4912
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00004913GLenum __stdcall glGetGraphicsResetStatusEXT(void)
4914{
4915 EVENT("()");
4916
4917 try
4918 {
4919 gl::Context *context = gl::getContext();
4920
4921 if (context)
4922 {
4923 return context->getResetStatus();
4924 }
4925
4926 return GL_NO_ERROR;
4927 }
4928 catch(std::bad_alloc&)
4929 {
4930 return GL_OUT_OF_MEMORY;
4931 }
4932}
4933
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004934void __stdcall glGetIntegerv(GLenum pname, GLint* params)
4935{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004936 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004937
4938 try
4939 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004940 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004941
4942 if (context)
4943 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004944 if (!(context->getIntegerv(pname, params)))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004945 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004946 GLenum nativeType;
4947 unsigned int numParams = 0;
4948 if (!context->getQueryParameterInfo(pname, &nativeType, &numParams))
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004949 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004950
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004951 if (numParams == 0)
4952 return; // it is known that pname is valid, but there are no parameters to return
4953
4954 if (nativeType == GL_BOOL)
4955 {
4956 GLboolean *boolParams = NULL;
4957 boolParams = new GLboolean[numParams];
4958
4959 context->getBooleanv(pname, boolParams);
4960
4961 for (unsigned int i = 0; i < numParams; ++i)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004962 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004963 if (boolParams[i] == GL_FALSE)
4964 params[i] = 0;
4965 else
4966 params[i] = 1;
4967 }
4968
4969 delete [] boolParams;
4970 }
4971 else if (nativeType == GL_FLOAT)
4972 {
4973 GLfloat *floatParams = NULL;
4974 floatParams = new GLfloat[numParams];
4975
4976 context->getFloatv(pname, floatParams);
4977
4978 for (unsigned int i = 0; i < numParams; ++i)
4979 {
daniel@transgaming.comc1641352010-04-26 15:33:36 +00004980 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 +00004981 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004982 params[i] = (GLint)(((GLfloat)(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004983 }
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004984 else
Jamie Madillaf496912013-07-19 16:36:54 -04004985 params[i] = gl::iround<GLint>(floatParams[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004986 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004987
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004988 delete [] floatParams;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004989 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004990 }
4991 }
4992 }
4993 catch(std::bad_alloc&)
4994 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004995 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004996 }
4997}
4998
4999void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params)
5000{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005001 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005002
5003 try
5004 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005005 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005006
5007 if (context)
5008 {
5009 gl::Program *programObject = context->getProgram(program);
5010
5011 if (!programObject)
5012 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005013 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005014 }
5015
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00005016 if (context->getClientVersion() < 3)
5017 {
5018 switch (pname)
5019 {
5020 case GL_ACTIVE_UNIFORM_BLOCKS:
5021 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
5022 return gl::error(GL_INVALID_ENUM);
5023 }
5024 }
5025
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005026 switch (pname)
5027 {
5028 case GL_DELETE_STATUS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005029 *params = programObject->isFlaggedForDeletion();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005030 return;
5031 case GL_LINK_STATUS:
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005032 *params = programObject->isLinked();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005033 return;
5034 case GL_VALIDATE_STATUS:
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00005035 *params = programObject->isValidated();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005036 return;
5037 case GL_INFO_LOG_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005038 *params = programObject->getInfoLogLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005039 return;
5040 case GL_ATTACHED_SHADERS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005041 *params = programObject->getAttachedShadersCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005042 return;
5043 case GL_ACTIVE_ATTRIBUTES:
daniel@transgaming.com85423182010-04-22 13:35:27 +00005044 *params = programObject->getActiveAttributeCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005045 return;
5046 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
daniel@transgaming.com85423182010-04-22 13:35:27 +00005047 *params = programObject->getActiveAttributeMaxLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005048 return;
5049 case GL_ACTIVE_UNIFORMS:
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00005050 *params = programObject->getActiveUniformCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005051 return;
5052 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00005053 *params = programObject->getActiveUniformMaxLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005054 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00005055 case GL_PROGRAM_BINARY_LENGTH_OES:
apatrick@chromium.org90080e32012-07-09 22:15:33 +00005056 *params = programObject->getProgramBinaryLength();
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00005057 return;
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00005058 case GL_ACTIVE_UNIFORM_BLOCKS:
5059 *params = programObject->getActiveUniformBlockCount();
5060 return;
5061 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
5062 *params = programObject->getActiveUniformBlockMaxLength();
5063 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005064 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005065 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005066 }
5067 }
5068 }
5069 catch(std::bad_alloc&)
5070 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005071 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005072 }
5073}
5074
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005075void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005076{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005077 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 +00005078 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005079
5080 try
5081 {
5082 if (bufsize < 0)
5083 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005084 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005085 }
5086
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005087 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005088
5089 if (context)
5090 {
5091 gl::Program *programObject = context->getProgram(program);
5092
5093 if (!programObject)
5094 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005095 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005096 }
5097
5098 programObject->getInfoLog(bufsize, length, infolog);
5099 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005100 }
5101 catch(std::bad_alloc&)
5102 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005103 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005104 }
5105}
5106
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00005107void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
5108{
5109 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
5110
5111 try
5112 {
5113 switch (pname)
5114 {
5115 case GL_CURRENT_QUERY_EXT:
5116 break;
5117 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005118 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00005119 }
5120
5121 gl::Context *context = gl::getNonLostContext();
5122
5123 if (context)
5124 {
5125 params[0] = context->getActiveQuery(target);
5126 }
5127 }
5128 catch(std::bad_alloc&)
5129 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005130 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00005131 }
5132}
5133
5134void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
5135{
5136 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
5137
5138 try
5139 {
5140 switch (pname)
5141 {
5142 case GL_QUERY_RESULT_EXT:
5143 case GL_QUERY_RESULT_AVAILABLE_EXT:
5144 break;
5145 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005146 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00005147 }
5148 gl::Context *context = gl::getNonLostContext();
5149
5150 if (context)
5151 {
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00005152 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
5153
5154 if (!queryObject)
5155 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005156 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00005157 }
5158
5159 if (context->getActiveQuery(queryObject->getType()) == id)
5160 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005161 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00005162 }
5163
5164 switch(pname)
5165 {
5166 case GL_QUERY_RESULT_EXT:
5167 params[0] = queryObject->getResult();
5168 break;
5169 case GL_QUERY_RESULT_AVAILABLE_EXT:
5170 params[0] = queryObject->isResultAvailable();
5171 break;
5172 default:
5173 ASSERT(false);
5174 }
5175 }
5176 }
5177 catch(std::bad_alloc&)
5178 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005179 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00005180 }
5181}
5182
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005183void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
5184{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005185 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 +00005186
5187 try
5188 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005189 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00005190
5191 if (context)
5192 {
5193 if (target != GL_RENDERBUFFER)
5194 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005195 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00005196 }
5197
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005198 if (context->getRenderbufferHandle() == 0)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00005199 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005200 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00005201 }
5202
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005203 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle());
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00005204
5205 switch (pname)
5206 {
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00005207 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
5208 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
5209 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
5210 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
5211 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
5212 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
5213 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
5214 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
5215 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00005216 case GL_RENDERBUFFER_SAMPLES_ANGLE:
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00005217 if (context->getMaxSupportedSamples() != 0)
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00005218 {
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00005219 *params = renderbuffer->getSamples();
5220 }
5221 else
5222 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005223 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00005224 }
5225 break;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00005226 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005227 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00005228 }
5229 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005230 }
5231 catch(std::bad_alloc&)
5232 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005233 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005234 }
5235}
5236
5237void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
5238{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005239 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005240
5241 try
5242 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005243 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005244
5245 if (context)
5246 {
5247 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00005248
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005249 if (!shaderObject)
5250 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005251 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005252 }
5253
5254 switch (pname)
5255 {
5256 case GL_SHADER_TYPE:
5257 *params = shaderObject->getType();
5258 return;
5259 case GL_DELETE_STATUS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005260 *params = shaderObject->isFlaggedForDeletion();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005261 return;
5262 case GL_COMPILE_STATUS:
5263 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
5264 return;
5265 case GL_INFO_LOG_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005266 *params = shaderObject->getInfoLogLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005267 return;
5268 case GL_SHADER_SOURCE_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005269 *params = shaderObject->getSourceLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005270 return;
zmo@google.coma574f782011-10-03 21:45:23 +00005271 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
5272 *params = shaderObject->getTranslatedSourceLength();
5273 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005274 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005275 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005276 }
5277 }
5278 }
5279 catch(std::bad_alloc&)
5280 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005281 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005282 }
5283}
5284
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005285void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005286{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005287 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 +00005288 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005289
5290 try
5291 {
5292 if (bufsize < 0)
5293 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005294 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005295 }
5296
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005297 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005298
5299 if (context)
5300 {
5301 gl::Shader *shaderObject = context->getShader(shader);
5302
5303 if (!shaderObject)
5304 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005305 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005306 }
5307
5308 shaderObject->getInfoLog(bufsize, length, infolog);
5309 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005310 }
5311 catch(std::bad_alloc&)
5312 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005313 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005314 }
5315}
5316
5317void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
5318{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005319 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 +00005320 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005321
5322 try
5323 {
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005324 switch (shadertype)
5325 {
5326 case GL_VERTEX_SHADER:
5327 case GL_FRAGMENT_SHADER:
5328 break;
5329 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005330 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005331 }
5332
5333 switch (precisiontype)
5334 {
5335 case GL_LOW_FLOAT:
5336 case GL_MEDIUM_FLOAT:
5337 case GL_HIGH_FLOAT:
5338 // Assume IEEE 754 precision
5339 range[0] = 127;
5340 range[1] = 127;
daniel@transgaming.comc5c15382010-04-23 18:34:49 +00005341 *precision = 23;
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005342 break;
5343 case GL_LOW_INT:
5344 case GL_MEDIUM_INT:
5345 case GL_HIGH_INT:
5346 // Some (most) hardware only supports single-precision floating-point numbers,
5347 // which can accurately represent integers up to +/-16777216
5348 range[0] = 24;
5349 range[1] = 24;
daniel@transgaming.comc5c15382010-04-23 18:34:49 +00005350 *precision = 0;
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005351 break;
5352 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005353 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005354 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005355 }
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.com4f39fd92010-03-08 20:26:45 +00005359 }
5360}
5361
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005362void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005363{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005364 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 +00005365 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005366
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.com4f39fd92010-03-08 20:26:45 +00005372 }
5373
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005374 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005375
5376 if (context)
5377 {
5378 gl::Shader *shaderObject = context->getShader(shader);
5379
5380 if (!shaderObject)
5381 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005382 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005383 }
5384
5385 shaderObject->getSource(bufsize, length, source);
5386 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005387 }
5388 catch(std::bad_alloc&)
5389 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005390 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005391 }
5392}
5393
zmo@google.coma574f782011-10-03 21:45:23 +00005394void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
5395{
5396 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
5397 shader, bufsize, length, source);
5398
5399 try
5400 {
5401 if (bufsize < 0)
5402 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005403 return gl::error(GL_INVALID_VALUE);
zmo@google.coma574f782011-10-03 21:45:23 +00005404 }
5405
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005406 gl::Context *context = gl::getNonLostContext();
zmo@google.coma574f782011-10-03 21:45:23 +00005407
5408 if (context)
5409 {
5410 gl::Shader *shaderObject = context->getShader(shader);
5411
5412 if (!shaderObject)
5413 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005414 return gl::error(GL_INVALID_OPERATION);
zmo@google.coma574f782011-10-03 21:45:23 +00005415 }
5416
5417 shaderObject->getTranslatedSource(bufsize, length, source);
5418 }
5419 }
5420 catch(std::bad_alloc&)
5421 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005422 return gl::error(GL_OUT_OF_MEMORY);
zmo@google.coma574f782011-10-03 21:45:23 +00005423 }
5424}
5425
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005426const GLubyte* __stdcall glGetString(GLenum name)
5427{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005428 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005429
5430 try
5431 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005432 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00005433
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005434 switch (name)
5435 {
5436 case GL_VENDOR:
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +00005437 return (GLubyte*)"Google Inc.";
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005438 case GL_RENDERER:
daniel@transgaming.comc23ff642011-08-16 20:28:45 +00005439 return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005440 case GL_VERSION:
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00005441 if (context->getClientVersion() == 2)
5442 {
5443 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")";
5444 }
5445 else
5446 {
5447 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")";
5448 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005449 case GL_SHADING_LANGUAGE_VERSION:
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00005450 if (context->getClientVersion() == 2)
5451 {
5452 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")";
5453 }
5454 else
5455 {
5456 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")";
5457 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005458 case GL_EXTENSIONS:
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00005459 return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : "");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005460 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005461 return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005462 }
5463 }
5464 catch(std::bad_alloc&)
5465 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005466 return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005467 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005468}
5469
5470void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
5471{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005472 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 +00005473
5474 try
5475 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005476 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005477
5478 if (context)
5479 {
5480 gl::Texture *texture;
5481
5482 switch (target)
5483 {
5484 case GL_TEXTURE_2D:
5485 texture = context->getTexture2D();
5486 break;
5487 case GL_TEXTURE_CUBE_MAP:
5488 texture = context->getTextureCubeMap();
5489 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00005490 case GL_TEXTURE_3D:
5491 if (context->getClientVersion() < 3)
5492 {
5493 return gl::error(GL_INVALID_ENUM);
5494 }
5495 texture = context->getTexture3D();
5496 break;
shannonwoods@chromium.org0c611d12013-05-30 00:15:05 +00005497 case GL_TEXTURE_2D_ARRAY:
5498 if (context->getClientVersion() < 3)
5499 {
5500 return gl::error(GL_INVALID_ENUM);
5501 }
5502 texture = context->getTexture2DArray();
5503 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005504 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005505 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005506 }
5507
5508 switch (pname)
5509 {
5510 case GL_TEXTURE_MAG_FILTER:
5511 *params = (GLfloat)texture->getMagFilter();
5512 break;
5513 case GL_TEXTURE_MIN_FILTER:
5514 *params = (GLfloat)texture->getMinFilter();
5515 break;
5516 case GL_TEXTURE_WRAP_S:
5517 *params = (GLfloat)texture->getWrapS();
5518 break;
5519 case GL_TEXTURE_WRAP_T:
5520 *params = (GLfloat)texture->getWrapT();
5521 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00005522 case GL_TEXTURE_WRAP_R:
5523 if (context->getClientVersion() < 3)
5524 {
5525 return gl::error(GL_INVALID_ENUM);
5526 }
5527 *params = (GLfloat)texture->getWrapR();
5528 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005529 case GL_TEXTURE_IMMUTABLE_FORMAT:
5530 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
daniel@transgaming.comd30bd0a2011-11-11 04:10:34 +00005531 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
5532 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005533 case GL_TEXTURE_IMMUTABLE_LEVELS:
5534 if (context->getClientVersion() < 3)
5535 {
5536 return gl::error(GL_INVALID_ENUM);
5537 }
5538 *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0);
5539 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00005540 case GL_TEXTURE_USAGE_ANGLE:
5541 *params = (GLfloat)texture->getUsage();
5542 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005543 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
5544 if (!context->supportsTextureFilterAnisotropy())
5545 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005546 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005547 }
5548 *params = (GLfloat)texture->getMaxAnisotropy();
5549 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005550 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005551 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005552 }
5553 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005554 }
5555 catch(std::bad_alloc&)
5556 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005557 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005558 }
5559}
5560
5561void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
5562{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005563 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 +00005564
5565 try
5566 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005567 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005568
5569 if (context)
5570 {
5571 gl::Texture *texture;
5572
5573 switch (target)
5574 {
5575 case GL_TEXTURE_2D:
5576 texture = context->getTexture2D();
5577 break;
5578 case GL_TEXTURE_CUBE_MAP:
5579 texture = context->getTextureCubeMap();
5580 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00005581 case GL_TEXTURE_3D:
5582 if (context->getClientVersion() < 3)
5583 {
5584 return gl::error(GL_INVALID_ENUM);
5585 }
5586 texture = context->getTexture3D();
5587 break;
shannonwoods@chromium.org0c611d12013-05-30 00:15:05 +00005588 case GL_TEXTURE_2D_ARRAY:
5589 if (context->getClientVersion() < 3)
5590 {
5591 return gl::error(GL_INVALID_ENUM);
5592 }
5593 texture = context->getTexture2DArray();
5594 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005595 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005596 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005597 }
5598
5599 switch (pname)
5600 {
5601 case GL_TEXTURE_MAG_FILTER:
5602 *params = texture->getMagFilter();
5603 break;
5604 case GL_TEXTURE_MIN_FILTER:
5605 *params = texture->getMinFilter();
5606 break;
5607 case GL_TEXTURE_WRAP_S:
5608 *params = texture->getWrapS();
5609 break;
5610 case GL_TEXTURE_WRAP_T:
5611 *params = texture->getWrapT();
5612 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00005613 case GL_TEXTURE_WRAP_R:
5614 if (context->getClientVersion() < 3)
5615 {
5616 return gl::error(GL_INVALID_ENUM);
5617 }
5618 *params = texture->getWrapR();
5619 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005620 case GL_TEXTURE_IMMUTABLE_FORMAT:
5621 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
daniel@transgaming.comd30bd0a2011-11-11 04:10:34 +00005622 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
5623 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005624 case GL_TEXTURE_IMMUTABLE_LEVELS:
5625 if (context->getClientVersion() < 3)
5626 {
5627 return gl::error(GL_INVALID_ENUM);
5628 }
5629 *params = texture->isImmutable() ? texture->levelCount() : 0;
5630 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00005631 case GL_TEXTURE_USAGE_ANGLE:
5632 *params = texture->getUsage();
5633 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005634 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
5635 if (!context->supportsTextureFilterAnisotropy())
5636 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005637 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005638 }
5639 *params = (GLint)texture->getMaxAnisotropy();
5640 break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00005641
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005642 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005643 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005644 }
5645 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005646 }
5647 catch(std::bad_alloc&)
5648 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005649 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005650 }
5651}
5652
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005653void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
5654{
5655 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
5656 program, location, bufSize, params);
5657
5658 try
5659 {
5660 if (bufSize < 0)
5661 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005662 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005663 }
5664
5665 gl::Context *context = gl::getNonLostContext();
5666
5667 if (context)
5668 {
5669 if (program == 0)
5670 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005671 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005672 }
5673
5674 gl::Program *programObject = context->getProgram(program);
5675
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005676 if (!programObject || !programObject->isLinked())
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005677 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005678 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005679 }
5680
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005681 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5682 if (!programBinary)
5683 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005684 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005685 }
5686
5687 if (!programBinary->getUniformfv(location, &bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005688 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005689 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005690 }
5691 }
5692 }
5693 catch(std::bad_alloc&)
5694 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005695 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005696 }
5697}
5698
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005699void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params)
5700{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005701 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005702
5703 try
5704 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005705 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005706
5707 if (context)
5708 {
5709 if (program == 0)
5710 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005711 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005712 }
5713
5714 gl::Program *programObject = context->getProgram(program);
5715
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005716 if (!programObject || !programObject->isLinked())
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005717 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005718 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005719 }
5720
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005721 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5722 if (!programBinary)
5723 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005724 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005725 }
5726
5727 if (!programBinary->getUniformfv(location, NULL, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005728 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005729 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005730 }
5731 }
5732 }
5733 catch(std::bad_alloc&)
5734 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005735 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005736 }
5737}
5738
5739void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
5740{
5741 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
5742 program, location, bufSize, params);
5743
5744 try
5745 {
5746 if (bufSize < 0)
5747 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005748 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005749 }
5750
5751 gl::Context *context = gl::getNonLostContext();
5752
5753 if (context)
5754 {
5755 if (program == 0)
5756 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005757 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005758 }
5759
5760 gl::Program *programObject = context->getProgram(program);
5761
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005762 if (!programObject || !programObject->isLinked())
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005763 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005764 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005765 }
5766
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005767 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5768 if (!programBinary)
5769 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005770 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005771 }
5772
5773 if (!programBinary->getUniformiv(location, &bufSize, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005774 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005775 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005776 }
5777 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005778 }
5779 catch(std::bad_alloc&)
5780 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005781 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005782 }
5783}
5784
5785void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params)
5786{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005787 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005788
5789 try
5790 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005791 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005792
5793 if (context)
5794 {
5795 if (program == 0)
5796 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005797 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005798 }
5799
5800 gl::Program *programObject = context->getProgram(program);
5801
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005802 if (!programObject || !programObject->isLinked())
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005803 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005804 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005805 }
5806
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005807 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5808 if (!programBinary)
5809 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005810 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005811 }
5812
5813 if (!programBinary->getUniformiv(location, NULL, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005814 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005815 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005816 }
5817 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005818 }
5819 catch(std::bad_alloc&)
5820 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005821 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005822 }
5823}
5824
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005825int __stdcall glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005826{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005827 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005828
5829 try
5830 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005831 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005832
5833 if (strstr(name, "gl_") == name)
5834 {
5835 return -1;
5836 }
5837
5838 if (context)
5839 {
5840 gl::Program *programObject = context->getProgram(program);
5841
5842 if (!programObject)
5843 {
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00005844 if (context->getShader(program))
5845 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005846 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00005847 }
5848 else
5849 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005850 return gl::error(GL_INVALID_VALUE, -1);
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00005851 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005852 }
5853
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005854 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005855 if (!programObject->isLinked() || !programBinary)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005856 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005857 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005858 }
5859
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005860 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005861 }
5862 }
5863 catch(std::bad_alloc&)
5864 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005865 return gl::error(GL_OUT_OF_MEMORY, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005866 }
5867
5868 return -1;
5869}
5870
5871void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
5872{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005873 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005874
5875 try
5876 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005877 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005878
daniel@transgaming.come0078962010-04-15 20:45:08 +00005879 if (context)
5880 {
5881 if (index >= gl::MAX_VERTEX_ATTRIBS)
5882 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005883 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005884 }
5885
daniel@transgaming.com83921382011-01-08 05:46:00 +00005886 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005887
Jamie Madillaff71502013-07-02 11:57:05 -04005888 if (!validateGetVertexAttribParameters(pname, context->getClientVersion()))
daniel@transgaming.come0078962010-04-15 20:45:08 +00005889 {
Jamie Madillaff71502013-07-02 11:57:05 -04005890 return;
5891 }
5892
5893 if (pname == GL_CURRENT_VERTEX_ATTRIB)
5894 {
5895 const gl::VertexAttribCurrentValueData &currentValueData = context->getVertexAttribCurrentValue(index);
5896 for (int i = 0; i < 4; ++i)
daniel@transgaming.come0078962010-04-15 20:45:08 +00005897 {
Jamie Madillaff71502013-07-02 11:57:05 -04005898 params[i] = currentValueData.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00005899 }
Jamie Madillaff71502013-07-02 11:57:05 -04005900 }
5901 else
5902 {
5903 *params = attribState.querySingleParameter<GLfloat>(pname);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005904 }
5905 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005906 }
5907 catch(std::bad_alloc&)
5908 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005909 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005910 }
5911}
5912
5913void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
5914{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005915 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005916
5917 try
5918 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005919 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005920
daniel@transgaming.come0078962010-04-15 20:45:08 +00005921 if (context)
5922 {
5923 if (index >= gl::MAX_VERTEX_ATTRIBS)
5924 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005925 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005926 }
5927
daniel@transgaming.com83921382011-01-08 05:46:00 +00005928 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005929
Jamie Madillaff71502013-07-02 11:57:05 -04005930 if (!validateGetVertexAttribParameters(pname, context->getClientVersion()))
daniel@transgaming.come0078962010-04-15 20:45:08 +00005931 {
Jamie Madillaff71502013-07-02 11:57:05 -04005932 return;
5933 }
5934
5935 if (pname == GL_CURRENT_VERTEX_ATTRIB)
5936 {
5937 const gl::VertexAttribCurrentValueData &currentValueData = context->getVertexAttribCurrentValue(index);
5938 for (int i = 0; i < 4; ++i)
daniel@transgaming.come0078962010-04-15 20:45:08 +00005939 {
Jamie Madillaff71502013-07-02 11:57:05 -04005940 float currentValue = currentValueData.FloatValues[i];
Jamie Madillaf496912013-07-19 16:36:54 -04005941 params[i] = gl::iround<GLint>(currentValue);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005942 }
Jamie Madillaff71502013-07-02 11:57:05 -04005943 }
5944 else
5945 {
5946 *params = attribState.querySingleParameter<GLint>(pname);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005947 }
5948 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005949 }
5950 catch(std::bad_alloc&)
5951 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005952 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005953 }
5954}
5955
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005956void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005957{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005958 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005959
5960 try
5961 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005962 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005963
daniel@transgaming.come0078962010-04-15 20:45:08 +00005964 if (context)
5965 {
5966 if (index >= gl::MAX_VERTEX_ATTRIBS)
5967 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005968 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005969 }
5970
5971 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
5972 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005973 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005974 }
5975
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005976 *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index));
daniel@transgaming.come0078962010-04-15 20:45:08 +00005977 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005978 }
5979 catch(std::bad_alloc&)
5980 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005981 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005982 }
5983}
5984
5985void __stdcall glHint(GLenum target, GLenum mode)
5986{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005987 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005988
5989 try
5990 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005991 switch (mode)
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005992 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005993 case GL_FASTEST:
5994 case GL_NICEST:
5995 case GL_DONT_CARE:
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005996 break;
5997 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005998 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005999 }
6000
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006001 gl::Context *context = gl::getNonLostContext();
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00006002 switch (target)
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00006003 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00006004 case GL_GENERATE_MIPMAP_HINT:
6005 if (context) context->setGenerateMipmapHint(mode);
6006 break;
6007 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
6008 if (context) context->setFragmentShaderDerivativeHint(mode);
6009 break;
6010 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006011 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00006012 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006013 }
6014 catch(std::bad_alloc&)
6015 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006016 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006017 }
6018}
6019
6020GLboolean __stdcall glIsBuffer(GLuint buffer)
6021{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006022 EVENT("(GLuint buffer = %d)", buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006023
6024 try
6025 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006026 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006027
6028 if (context && buffer)
6029 {
6030 gl::Buffer *bufferObject = context->getBuffer(buffer);
6031
6032 if (bufferObject)
6033 {
6034 return GL_TRUE;
6035 }
6036 }
6037 }
6038 catch(std::bad_alloc&)
6039 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006040 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006041 }
6042
6043 return GL_FALSE;
6044}
6045
6046GLboolean __stdcall glIsEnabled(GLenum cap)
6047{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006048 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006049
6050 try
6051 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006052 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006053
6054 if (context)
6055 {
6056 switch (cap)
6057 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006058 case GL_CULL_FACE: return context->isCullFaceEnabled();
6059 case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled();
6060 case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled();
6061 case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled();
6062 case GL_SCISSOR_TEST: return context->isScissorTestEnabled();
6063 case GL_STENCIL_TEST: return context->isStencilTestEnabled();
6064 case GL_DEPTH_TEST: return context->isDepthTestEnabled();
6065 case GL_BLEND: return context->isBlendEnabled();
6066 case GL_DITHER: return context->isDitherEnabled();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006067 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006068 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006069 }
6070 }
6071 }
6072 catch(std::bad_alloc&)
6073 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006074 return gl::error(GL_OUT_OF_MEMORY, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006075 }
6076
6077 return false;
6078}
6079
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006080GLboolean __stdcall glIsFenceNV(GLuint fence)
6081{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006082 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006083
6084 try
6085 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006086 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006087
6088 if (context)
6089 {
6090 gl::Fence *fenceObject = context->getFence(fence);
6091
6092 if (fenceObject == NULL)
6093 {
6094 return GL_FALSE;
6095 }
6096
6097 return fenceObject->isFence();
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, GL_FALSE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006103 }
6104
6105 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006106}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006107
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006108GLboolean __stdcall glIsFramebuffer(GLuint framebuffer)
6109{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006110 EVENT("(GLuint framebuffer = %d)", framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006111
6112 try
6113 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006114 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006115
6116 if (context && framebuffer)
6117 {
6118 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
6119
6120 if (framebufferObject)
6121 {
6122 return GL_TRUE;
6123 }
6124 }
6125 }
6126 catch(std::bad_alloc&)
6127 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006128 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006129 }
6130
6131 return GL_FALSE;
6132}
6133
6134GLboolean __stdcall glIsProgram(GLuint program)
6135{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006136 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006137
6138 try
6139 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006140 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006141
6142 if (context && program)
6143 {
6144 gl::Program *programObject = context->getProgram(program);
6145
6146 if (programObject)
6147 {
6148 return GL_TRUE;
6149 }
6150 }
6151 }
6152 catch(std::bad_alloc&)
6153 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006154 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006155 }
6156
6157 return GL_FALSE;
6158}
6159
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00006160GLboolean __stdcall glIsQueryEXT(GLuint id)
6161{
6162 EVENT("(GLuint id = %d)", id);
6163
6164 try
6165 {
6166 if (id == 0)
6167 {
6168 return GL_FALSE;
6169 }
6170
6171 gl::Context *context = gl::getNonLostContext();
6172
6173 if (context)
6174 {
6175 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
6176
6177 if (queryObject)
6178 {
6179 return GL_TRUE;
6180 }
6181 }
6182 }
6183 catch(std::bad_alloc&)
6184 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006185 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00006186 }
6187
6188 return GL_FALSE;
6189}
6190
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006191GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer)
6192{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006193 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006194
6195 try
6196 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006197 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006198
6199 if (context && renderbuffer)
6200 {
6201 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
6202
6203 if (renderbufferObject)
6204 {
6205 return GL_TRUE;
6206 }
6207 }
6208 }
6209 catch(std::bad_alloc&)
6210 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006211 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006212 }
6213
6214 return GL_FALSE;
6215}
6216
6217GLboolean __stdcall glIsShader(GLuint shader)
6218{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006219 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006220
6221 try
6222 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006223 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006224
6225 if (context && shader)
6226 {
6227 gl::Shader *shaderObject = context->getShader(shader);
6228
6229 if (shaderObject)
6230 {
6231 return GL_TRUE;
6232 }
6233 }
6234 }
6235 catch(std::bad_alloc&)
6236 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006237 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006238 }
6239
6240 return GL_FALSE;
6241}
6242
6243GLboolean __stdcall glIsTexture(GLuint texture)
6244{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006245 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006246
6247 try
6248 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006249 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006250
6251 if (context && texture)
6252 {
6253 gl::Texture *textureObject = context->getTexture(texture);
6254
6255 if (textureObject)
6256 {
6257 return GL_TRUE;
6258 }
6259 }
6260 }
6261 catch(std::bad_alloc&)
6262 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006263 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006264 }
6265
6266 return GL_FALSE;
6267}
6268
6269void __stdcall glLineWidth(GLfloat width)
6270{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006271 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006272
6273 try
6274 {
6275 if (width <= 0.0f)
6276 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006277 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006278 }
6279
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006280 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00006281
6282 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006283 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006284 context->setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006285 }
6286 }
6287 catch(std::bad_alloc&)
6288 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006289 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006290 }
6291}
6292
6293void __stdcall glLinkProgram(GLuint program)
6294{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006295 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006296
6297 try
6298 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006299 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006300
6301 if (context)
6302 {
6303 gl::Program *programObject = context->getProgram(program);
6304
6305 if (!programObject)
6306 {
daniel@transgaming.com277b7142010-04-13 03:26:44 +00006307 if (context->getShader(program))
6308 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006309 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com277b7142010-04-13 03:26:44 +00006310 }
6311 else
6312 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006313 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com277b7142010-04-13 03:26:44 +00006314 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006315 }
6316
daniel@transgaming.com95d29422012-07-24 18:36:10 +00006317 context->linkProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006318 }
6319 }
6320 catch(std::bad_alloc&)
6321 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006322 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006323 }
6324}
6325
6326void __stdcall glPixelStorei(GLenum pname, GLint param)
6327{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006328 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006329
6330 try
6331 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006332 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006333
6334 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006335 {
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006336 switch (pname)
6337 {
6338 case GL_UNPACK_ALIGNMENT:
6339 if (param != 1 && param != 2 && param != 4 && param != 8)
6340 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006341 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006342 }
6343
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006344 context->setUnpackAlignment(param);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006345 break;
6346
6347 case GL_PACK_ALIGNMENT:
6348 if (param != 1 && param != 2 && param != 4 && param != 8)
6349 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006350 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006351 }
6352
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006353 context->setPackAlignment(param);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006354 break;
6355
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00006356 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
6357 context->setPackReverseRowOrder(param != 0);
6358 break;
6359
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00006360 case GL_UNPACK_IMAGE_HEIGHT:
6361 case GL_UNPACK_SKIP_IMAGES:
6362 case GL_UNPACK_ROW_LENGTH:
6363 case GL_UNPACK_SKIP_ROWS:
6364 case GL_UNPACK_SKIP_PIXELS:
6365 case GL_PACK_ROW_LENGTH:
6366 case GL_PACK_SKIP_ROWS:
6367 case GL_PACK_SKIP_PIXELS:
6368 if (context->getClientVersion() < 3)
6369 {
6370 return gl::error(GL_INVALID_ENUM);
6371 }
6372 UNIMPLEMENTED();
6373 break;
6374
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006375 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006376 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006377 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006378 }
6379 }
6380 catch(std::bad_alloc&)
6381 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006382 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006383 }
6384}
6385
6386void __stdcall glPolygonOffset(GLfloat factor, GLfloat units)
6387{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006388 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006389
6390 try
6391 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006392 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comaede6302010-04-29 03:35:48 +00006393
6394 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006395 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006396 context->setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006397 }
6398 }
6399 catch(std::bad_alloc&)
6400 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006401 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006402 }
6403}
6404
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006405void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
6406 GLenum format, GLenum type, GLsizei bufSize,
6407 GLvoid *data)
6408{
6409 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
6410 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
6411 x, y, width, height, format, type, bufSize, data);
6412
6413 try
6414 {
6415 if (width < 0 || height < 0 || bufSize < 0)
6416 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006417 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006418 }
6419
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006420 gl::Context *context = gl::getNonLostContext();
6421
6422 if (context)
6423 {
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006424 GLint currentInternalFormat;
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006425 GLenum currentFormat, currentType;
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006426
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006427 // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound,
6428 // and attempting to read back if that's the case is an error. The error will be registered
6429 // by getCurrentReadFormat.
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006430 if (!context->getCurrentReadFormatType(&currentInternalFormat, &currentFormat, &currentType))
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006431 return;
6432
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006433 bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) :
6434 validES3ReadFormatType(currentInternalFormat, format, type);
6435
6436 if (!(currentFormat == format && currentType == type) && !validReadFormat)
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006437 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006438 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006439 }
6440
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006441 context->readPixels(x, y, width, height, format, type, &bufSize, data);
6442 }
6443 }
6444 catch(std::bad_alloc&)
6445 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006446 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006447 }
6448}
6449
6450void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
6451 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006452{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006453 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006454 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00006455 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006456
6457 try
6458 {
6459 if (width < 0 || height < 0)
6460 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006461 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006462 }
6463
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006464 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006465
6466 if (context)
6467 {
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006468 GLint currentInternalFormat;
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006469 GLenum currentFormat, currentType;
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006470
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006471 // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound,
6472 // and attempting to read back if that's the case is an error. The error will be registered
6473 // by getCurrentReadFormat.
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006474 if (!context->getCurrentReadFormatType(&currentInternalFormat, &currentFormat, &currentType))
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006475 return;
6476
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006477 bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) :
6478 validES3ReadFormatType(currentInternalFormat, format, type);
6479
6480 if (!(currentFormat == format && currentType == type) && !validReadFormat)
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006481 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006482 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006483 }
6484
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006485 context->readPixels(x, y, width, height, format, type, NULL, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006486 }
6487 }
6488 catch(std::bad_alloc&)
6489 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006490 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006491 }
6492}
6493
6494void __stdcall glReleaseShaderCompiler(void)
6495{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006496 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006497
6498 try
6499 {
6500 gl::Shader::releaseCompiler();
6501 }
6502 catch(std::bad_alloc&)
6503 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006504 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006505 }
6506}
6507
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00006508void __stdcall glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006509{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006510 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 +00006511 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006512
6513 try
6514 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006515 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006516
6517 if (context)
6518 {
Geoff Lang2e1dcd52013-05-29 10:34:08 -04006519 if (!validateRenderbufferStorageParameters(context, target, samples, internalformat,
6520 width, height, true))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006521 {
Geoff Lang2e1dcd52013-05-29 10:34:08 -04006522 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006523 }
shannon.woods%transgaming.com@gtempaccount.com8dce6512013-04-13 03:42:19 +00006524
6525 context->setRenderbufferStorage(width, height, internalformat, samples);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006526 }
6527 }
6528 catch(std::bad_alloc&)
6529 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006530 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006531 }
6532}
6533
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00006534void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
6535{
6536 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
6537}
6538
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006539void __stdcall glSampleCoverage(GLclampf value, GLboolean invert)
6540{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006541 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006542
6543 try
6544 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006545 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006546
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006547 if (context)
6548 {
daniel@transgaming.coma36f98e2010-05-18 18:51:09 +00006549 context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006550 }
6551 }
6552 catch(std::bad_alloc&)
6553 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006554 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006555 }
6556}
6557
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006558void __stdcall glSetFenceNV(GLuint fence, GLenum condition)
6559{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006560 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006561
6562 try
6563 {
6564 if (condition != GL_ALL_COMPLETED_NV)
6565 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006566 return gl::error(GL_INVALID_ENUM);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006567 }
6568
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006569 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006570
6571 if (context)
6572 {
6573 gl::Fence *fenceObject = context->getFence(fence);
6574
6575 if (fenceObject == NULL)
6576 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006577 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006578 }
6579
6580 fenceObject->setFence(condition);
6581 }
6582 }
6583 catch(std::bad_alloc&)
6584 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006585 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006586 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006587}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006588
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006589void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
6590{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006591 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 +00006592
6593 try
6594 {
6595 if (width < 0 || height < 0)
6596 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006597 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006598 }
6599
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006600 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006601
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006602 if (context)
6603 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006604 context->setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006605 }
6606 }
6607 catch(std::bad_alloc&)
6608 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006609 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006610 }
6611}
6612
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006613void __stdcall glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006614{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006615 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006616 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00006617 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006618
6619 try
6620 {
daniel@transgaming.comd1f667f2010-04-29 03:38:52 +00006621 // No binary shader formats are supported.
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006622 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006623 }
6624 catch(std::bad_alloc&)
6625 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006626 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006627 }
6628}
6629
shannon.woods%transgaming.com@gtempaccount.com5f339332013-04-13 03:29:02 +00006630void __stdcall glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006631{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006632 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 +00006633 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006634
6635 try
6636 {
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006637 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006638 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006639 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006640 }
6641
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006642 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006643
6644 if (context)
6645 {
6646 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006647
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006648 if (!shaderObject)
6649 {
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006650 if (context->getProgram(shader))
6651 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006652 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006653 }
6654 else
6655 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006656 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006657 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006658 }
6659
6660 shaderObject->setSource(count, string, length);
6661 }
6662 }
6663 catch(std::bad_alloc&)
6664 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006665 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006666 }
6667}
6668
6669void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask)
6670{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006671 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006672}
6673
6674void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
6675{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006676 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 +00006677
6678 try
6679 {
6680 switch (face)
6681 {
6682 case GL_FRONT:
6683 case GL_BACK:
6684 case GL_FRONT_AND_BACK:
6685 break;
6686 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006687 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006688 }
6689
6690 switch (func)
6691 {
6692 case GL_NEVER:
6693 case GL_ALWAYS:
6694 case GL_LESS:
6695 case GL_LEQUAL:
6696 case GL_EQUAL:
6697 case GL_GEQUAL:
6698 case GL_GREATER:
6699 case GL_NOTEQUAL:
6700 break;
6701 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006702 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006703 }
6704
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006705 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006706
6707 if (context)
6708 {
6709 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
6710 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006711 context->setStencilParams(func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006712 }
6713
6714 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
6715 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006716 context->setStencilBackParams(func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006717 }
6718 }
6719 }
6720 catch(std::bad_alloc&)
6721 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006722 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006723 }
6724}
6725
6726void __stdcall glStencilMask(GLuint mask)
6727{
6728 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
6729}
6730
6731void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask)
6732{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006733 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006734
6735 try
6736 {
6737 switch (face)
6738 {
6739 case GL_FRONT:
6740 case GL_BACK:
6741 case GL_FRONT_AND_BACK:
6742 break;
6743 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006744 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006745 }
6746
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006747 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006748
6749 if (context)
6750 {
6751 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
6752 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006753 context->setStencilWritemask(mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006754 }
6755
6756 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
6757 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006758 context->setStencilBackWritemask(mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006759 }
6760 }
6761 }
6762 catch(std::bad_alloc&)
6763 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006764 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006765 }
6766}
6767
6768void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
6769{
6770 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
6771}
6772
6773void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
6774{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006775 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 +00006776 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006777
6778 try
6779 {
6780 switch (face)
6781 {
6782 case GL_FRONT:
6783 case GL_BACK:
6784 case GL_FRONT_AND_BACK:
6785 break;
6786 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006787 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006788 }
6789
6790 switch (fail)
6791 {
6792 case GL_ZERO:
6793 case GL_KEEP:
6794 case GL_REPLACE:
6795 case GL_INCR:
6796 case GL_DECR:
6797 case GL_INVERT:
6798 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006799 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006800 break;
6801 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006802 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006803 }
6804
6805 switch (zfail)
6806 {
6807 case GL_ZERO:
6808 case GL_KEEP:
6809 case GL_REPLACE:
6810 case GL_INCR:
6811 case GL_DECR:
6812 case GL_INVERT:
6813 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006814 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006815 break;
6816 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006817 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006818 }
6819
6820 switch (zpass)
6821 {
6822 case GL_ZERO:
6823 case GL_KEEP:
6824 case GL_REPLACE:
6825 case GL_INCR:
6826 case GL_DECR:
6827 case GL_INVERT:
6828 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006829 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006830 break;
6831 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006832 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006833 }
6834
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006835 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006836
6837 if (context)
6838 {
6839 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
6840 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006841 context->setStencilOperations(fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006842 }
6843
6844 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
6845 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006846 context->setStencilBackOperations(fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006847 }
6848 }
6849 }
6850 catch(std::bad_alloc&)
6851 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006852 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006853 }
6854}
6855
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006856GLboolean __stdcall glTestFenceNV(GLuint fence)
6857{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006858 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006859
6860 try
6861 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006862 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006863
6864 if (context)
6865 {
6866 gl::Fence *fenceObject = context->getFence(fence);
6867
6868 if (fenceObject == NULL)
6869 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006870 return gl::error(GL_INVALID_OPERATION, GL_TRUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006871 }
6872
6873 return fenceObject->testFence();
6874 }
6875 }
6876 catch(std::bad_alloc&)
6877 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006878 gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006879 }
6880
6881 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006882}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006883
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006884void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
6885 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006886{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006887 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 +00006888 "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 +00006889 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006890
6891 try
6892 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006893 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006894
6895 if (context)
6896 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006897 if (context->getClientVersion() < 3 &&
6898 !validateES2TexImageParameters(context, target, level, internalformat, false, false,
6899 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com32b11442011-11-19 02:42:48 +00006900 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006901 return;
6902 }
6903
6904 if (context->getClientVersion() >= 3 &&
6905 !validateES3TexImageParameters(context, target, level, internalformat, false, false,
6906 0, 0, 0, width, height, 1, border, format, type))
6907 {
6908 return;
daniel@transgaming.com32b11442011-11-19 02:42:48 +00006909 }
6910
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006911 switch (target)
6912 {
6913 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006914 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006915 gl::Texture2D *texture = context->getTexture2D();
6916 texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006917 }
6918 break;
6919 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006920 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006921 gl::TextureCubeMap *texture = context->getTextureCubeMap();
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +00006922 texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006923 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006924 break;
6925 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
6926 {
6927 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6928 texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6929 }
6930 break;
6931 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
6932 {
6933 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6934 texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6935 }
6936 break;
6937 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
6938 {
6939 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6940 texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6941 }
6942 break;
6943 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
6944 {
6945 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6946 texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6947 }
6948 break;
6949 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
6950 {
6951 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6952 texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6953 }
6954 break;
6955 default: UNREACHABLE();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006956 }
6957 }
6958 }
6959 catch(std::bad_alloc&)
6960 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006961 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006962 }
6963}
6964
6965void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param)
6966{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006967 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
6968
6969 try
6970 {
6971 gl::Context *context = gl::getNonLostContext();
6972
6973 if (context)
6974 {
6975 gl::Texture *texture;
6976
6977 switch (target)
6978 {
6979 case GL_TEXTURE_2D:
6980 texture = context->getTexture2D();
6981 break;
6982 case GL_TEXTURE_CUBE_MAP:
6983 texture = context->getTextureCubeMap();
6984 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00006985 case GL_TEXTURE_3D:
6986 if (context->getClientVersion() < 3)
6987 {
6988 return gl::error(GL_INVALID_ENUM);
6989 }
6990 texture = context->getTexture3D();
shannon.woods%transgaming.com@gtempaccount.com90dbc442013-04-13 03:46:14 +00006991 case GL_TEXTURE_2D_ARRAY:
6992 if (context->getClientVersion() < 3)
6993 {
6994 return gl::error(GL_INVALID_ENUM);
6995 }
6996 texture = context->getTexture2DArray();
6997 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006998 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006999 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007000 }
7001
7002 switch (pname)
7003 {
7004 case GL_TEXTURE_WRAP_S:
Jamie Madillaf496912013-07-19 16:36:54 -04007005 if (!texture->setWrapS(gl::uiround<GLenum>(param)))
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007006 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007007 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007008 }
7009 break;
7010 case GL_TEXTURE_WRAP_T:
Jamie Madillaf496912013-07-19 16:36:54 -04007011 if (!texture->setWrapT(gl::uiround<GLenum>(param)))
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007012 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007013 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007014 }
7015 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00007016 case GL_TEXTURE_WRAP_R:
Jamie Madillaf496912013-07-19 16:36:54 -04007017 if (context->getClientVersion() < 3 || !texture->setWrapR(gl::uiround<GLenum>(param)))
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00007018 {
7019 return gl::error(GL_INVALID_ENUM);
7020 }
7021 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007022 case GL_TEXTURE_MIN_FILTER:
Jamie Madillaf496912013-07-19 16:36:54 -04007023 if (!texture->setMinFilter(gl::uiround<GLenum>(param)))
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007024 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007025 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007026 }
7027 break;
7028 case GL_TEXTURE_MAG_FILTER:
Jamie Madillaf496912013-07-19 16:36:54 -04007029 if (!texture->setMagFilter(gl::uiround<GLenum>(param)))
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007030 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007031 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007032 }
7033 break;
7034 case GL_TEXTURE_USAGE_ANGLE:
Jamie Madillaf496912013-07-19 16:36:54 -04007035 if (!texture->setUsage(gl::uiround<GLenum>(param)))
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007036 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007037 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007038 }
7039 break;
7040 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
7041 if (!context->supportsTextureFilterAnisotropy())
7042 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007043 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007044 }
7045 if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()))
7046 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007047 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007048 }
7049 break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00007050
7051 case GL_TEXTURE_MIN_LOD:
7052 case GL_TEXTURE_MAX_LOD:
7053 if (context->getClientVersion() < 3)
7054 {
7055 return gl::error(GL_INVALID_ENUM);
7056 }
7057 UNIMPLEMENTED();
7058 break;
7059
Geoff Langc82fc412013-07-10 14:43:42 -04007060 case GL_TEXTURE_COMPARE_MODE:
7061 if (context->getClientVersion() < 3)
7062 {
7063 return gl::error(GL_INVALID_ENUM);
7064 }
7065 if (!texture->setCompareMode((GLenum)param))
7066 {
7067 return gl::error(GL_INVALID_ENUM);
7068 }
7069 break;
7070
7071 case GL_TEXTURE_COMPARE_FUNC:
7072 if (context->getClientVersion() < 3)
7073 {
7074 return gl::error(GL_INVALID_ENUM);
7075 }
7076 if (!texture->setCompareFunc((GLenum)param))
7077 {
7078 return gl::error(GL_INVALID_ENUM);
7079 }
7080 break;
7081
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007082 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007083 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007084 }
7085 }
7086 }
7087 catch(std::bad_alloc&)
7088 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007089 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007090 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007091}
7092
7093void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
7094{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007095 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007096}
7097
7098void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param)
7099{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007100 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007101
7102 try
7103 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007104 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007105
7106 if (context)
7107 {
7108 gl::Texture *texture;
7109
7110 switch (target)
7111 {
7112 case GL_TEXTURE_2D:
7113 texture = context->getTexture2D();
7114 break;
7115 case GL_TEXTURE_CUBE_MAP:
7116 texture = context->getTextureCubeMap();
7117 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00007118 case GL_TEXTURE_3D:
7119 if (context->getClientVersion() < 3)
7120 {
7121 return gl::error(GL_INVALID_ENUM);
7122 }
7123 texture = context->getTexture3D();
7124 break;
shannon.woods%transgaming.com@gtempaccount.com90dbc442013-04-13 03:46:14 +00007125 case GL_TEXTURE_2D_ARRAY:
7126 if (context->getClientVersion() < 3)
7127 {
7128 return gl::error(GL_INVALID_ENUM);
7129 }
7130 texture = context->getTexture2DArray();
7131 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007132 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007133 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007134 }
7135
7136 switch (pname)
7137 {
7138 case GL_TEXTURE_WRAP_S:
7139 if (!texture->setWrapS((GLenum)param))
7140 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007141 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007142 }
7143 break;
7144 case GL_TEXTURE_WRAP_T:
7145 if (!texture->setWrapT((GLenum)param))
7146 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007147 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007148 }
7149 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00007150 case GL_TEXTURE_WRAP_R:
7151 if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param))
7152 {
7153 return gl::error(GL_INVALID_ENUM);
7154 }
7155 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007156 case GL_TEXTURE_MIN_FILTER:
7157 if (!texture->setMinFilter((GLenum)param))
7158 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007159 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007160 }
7161 break;
7162 case GL_TEXTURE_MAG_FILTER:
7163 if (!texture->setMagFilter((GLenum)param))
7164 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007165 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007166 }
7167 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00007168 case GL_TEXTURE_USAGE_ANGLE:
7169 if (!texture->setUsage((GLenum)param))
7170 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007171 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00007172 }
7173 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007174 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
7175 if (!context->supportsTextureFilterAnisotropy())
7176 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007177 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007178 }
7179 if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()))
7180 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007181 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00007182 }
7183 break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00007184
7185 case GL_TEXTURE_SWIZZLE_R:
7186 case GL_TEXTURE_SWIZZLE_G:
7187 case GL_TEXTURE_SWIZZLE_B:
7188 case GL_TEXTURE_SWIZZLE_A:
7189 case GL_TEXTURE_BASE_LEVEL:
7190 case GL_TEXTURE_MAX_LEVEL:
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00007191 if (context->getClientVersion() < 3)
7192 {
7193 return gl::error(GL_INVALID_ENUM);
7194 }
7195 UNIMPLEMENTED();
7196 break;
7197
Geoff Langc82fc412013-07-10 14:43:42 -04007198 case GL_TEXTURE_COMPARE_MODE:
7199 if (context->getClientVersion() < 3)
7200 {
7201 return gl::error(GL_INVALID_ENUM);
7202 }
7203 if (!texture->setCompareMode((GLenum)param))
7204 {
7205 return gl::error(GL_INVALID_ENUM);
7206 }
7207 break;
7208
7209 case GL_TEXTURE_COMPARE_FUNC:
7210 if (context->getClientVersion() < 3)
7211 {
7212 return gl::error(GL_INVALID_ENUM);
7213 }
7214 if (!texture->setCompareFunc((GLenum)param))
7215 {
7216 return gl::error(GL_INVALID_ENUM);
7217 }
7218 break;
7219
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007220 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007221 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007222 }
7223 }
7224 }
7225 catch(std::bad_alloc&)
7226 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007227 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007228 }
7229}
7230
7231void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
7232{
7233 glTexParameteri(target, pname, *params);
7234}
7235
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00007236void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
7237{
7238 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
7239 target, levels, internalformat, width, height);
7240
7241 try
7242 {
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00007243 gl::Context *context = gl::getNonLostContext();
7244
7245 if (context)
7246 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00007247 if (context->getClientVersion() < 3 &&
7248 !validateES2TexStorageParameters(context, target, levels, internalformat, width, height))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00007249 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00007250 return;
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00007251 }
7252
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00007253 if (context->getClientVersion() >= 3 &&
7254 !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00007255 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00007256 return;
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00007257 }
7258
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00007259 switch (target)
7260 {
7261 case GL_TEXTURE_2D:
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00007262 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00007263 gl::Texture2D *texture2d = context->getTexture2D();
7264 texture2d->storage(levels, internalformat, width, height);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00007265 }
7266 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00007267
7268 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
7269 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
7270 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
7271 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
7272 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
7273 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00007274 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00007275 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
7276 textureCube->storage(levels, internalformat, width);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00007277 }
7278 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00007279
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00007280 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007281 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00007282 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00007283 }
7284 }
7285 catch(std::bad_alloc&)
7286 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007287 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00007288 }
7289}
7290
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00007291void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
7292 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007293{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007294 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007295 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00007296 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007297 target, level, xoffset, yoffset, width, height, format, type, pixels);
7298
7299 try
7300 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007301 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007302
7303 if (context)
7304 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007305 if (context->getClientVersion() < 3 &&
7306 !validateES2TexImageParameters(context, target, level, GL_NONE, false, true,
7307 0, 0, width, height, 0, format, type, pixels))
daniel@transgaming.com1d2d3c42012-05-31 01:14:15 +00007308 {
7309 return;
7310 }
7311
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007312 if (context->getClientVersion() >= 3 &&
7313 !validateES3TexImageParameters(context, target, level, GL_NONE, false, true,
7314 0, 0, 0, width, height, 1, 0, format, type))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007315 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007316 return;
7317 }
7318
7319 switch (target)
7320 {
7321 case GL_TEXTURE_2D:
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007322 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007323 gl::Texture2D *texture = context->getTexture2D();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00007324 texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007325 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007326 break;
7327
7328 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
7329 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
7330 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
7331 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
7332 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
7333 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007334 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007335 gl::TextureCubeMap *texture = context->getTextureCubeMap();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00007336 texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007337 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007338 break;
7339
7340 default:
7341 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007342 }
7343 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007344 }
7345 catch(std::bad_alloc&)
7346 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007347 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007348 }
7349}
7350
7351void __stdcall glUniform1f(GLint location, GLfloat x)
7352{
7353 glUniform1fv(location, 1, &x);
7354}
7355
7356void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
7357{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007358 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007359
7360 try
7361 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007362 if (count < 0)
7363 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007364 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007365 }
7366
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007367 if (location == -1)
7368 {
7369 return;
7370 }
7371
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007372 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007373
7374 if (context)
7375 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007376 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007377 if (!programBinary)
7378 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007379 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007380 }
7381
7382 if (!programBinary->setUniform1fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007383 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007384 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007385 }
7386 }
7387 }
7388 catch(std::bad_alloc&)
7389 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007390 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007391 }
7392}
7393
7394void __stdcall glUniform1i(GLint location, GLint x)
7395{
7396 glUniform1iv(location, 1, &x);
7397}
7398
7399void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v)
7400{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007401 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007402
7403 try
7404 {
7405 if (count < 0)
7406 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007407 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007408 }
7409
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007410 if (location == -1)
7411 {
7412 return;
7413 }
7414
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007415 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007416
7417 if (context)
7418 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007419 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007420 if (!programBinary)
7421 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007422 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007423 }
7424
7425 if (!programBinary->setUniform1iv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007426 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007427 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007428 }
7429 }
7430 }
7431 catch(std::bad_alloc&)
7432 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007433 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007434 }
7435}
7436
7437void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y)
7438{
7439 GLfloat xy[2] = {x, y};
7440
7441 glUniform2fv(location, 1, (GLfloat*)&xy);
7442}
7443
7444void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
7445{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007446 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007447
7448 try
7449 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007450 if (count < 0)
7451 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007452 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007453 }
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007454
7455 if (location == -1)
7456 {
7457 return;
7458 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007459
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007460 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007461
7462 if (context)
7463 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007464 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007465 if (!programBinary)
7466 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007467 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007468 }
7469
7470 if (!programBinary->setUniform2fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007471 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007472 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007473 }
7474 }
7475 }
7476 catch(std::bad_alloc&)
7477 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007478 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007479 }
7480}
7481
7482void __stdcall glUniform2i(GLint location, GLint x, GLint y)
7483{
7484 GLint xy[4] = {x, y};
7485
7486 glUniform2iv(location, 1, (GLint*)&xy);
7487}
7488
7489void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v)
7490{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007491 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007492
7493 try
7494 {
7495 if (count < 0)
7496 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007497 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007498 }
7499
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007500 if (location == -1)
7501 {
7502 return;
7503 }
7504
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007505 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007506
7507 if (context)
7508 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007509 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007510 if (!programBinary)
7511 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007512 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007513 }
7514
7515 if (!programBinary->setUniform2iv(location, count, v))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007516 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007517 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007518 }
7519 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007520 }
7521 catch(std::bad_alloc&)
7522 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007523 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007524 }
7525}
7526
7527void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
7528{
7529 GLfloat xyz[3] = {x, y, z};
7530
7531 glUniform3fv(location, 1, (GLfloat*)&xyz);
7532}
7533
7534void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
7535{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007536 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007537
7538 try
7539 {
7540 if (count < 0)
7541 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007542 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007543 }
7544
7545 if (location == -1)
7546 {
7547 return;
7548 }
7549
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007550 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007551
7552 if (context)
7553 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007554 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007555 if (!programBinary)
7556 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007557 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007558 }
7559
7560 if (!programBinary->setUniform3fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007561 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007562 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007563 }
7564 }
7565 }
7566 catch(std::bad_alloc&)
7567 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007568 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007569 }
7570}
7571
7572void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z)
7573{
7574 GLint xyz[3] = {x, y, z};
7575
7576 glUniform3iv(location, 1, (GLint*)&xyz);
7577}
7578
7579void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v)
7580{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007581 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007582
7583 try
7584 {
7585 if (count < 0)
7586 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007587 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007588 }
7589
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007590 if (location == -1)
7591 {
7592 return;
7593 }
7594
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007595 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007596
7597 if (context)
7598 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007599 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007600 if (!programBinary)
7601 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007602 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007603 }
7604
7605 if (!programBinary->setUniform3iv(location, count, v))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007606 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007607 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007608 }
7609 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007610 }
7611 catch(std::bad_alloc&)
7612 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007613 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007614 }
7615}
7616
7617void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
7618{
7619 GLfloat xyzw[4] = {x, y, z, w};
7620
7621 glUniform4fv(location, 1, (GLfloat*)&xyzw);
7622}
7623
7624void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
7625{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007626 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007627
7628 try
7629 {
7630 if (count < 0)
7631 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007632 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007633 }
7634
7635 if (location == -1)
7636 {
7637 return;
7638 }
7639
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007640 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007641
7642 if (context)
7643 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007644 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007645 if (!programBinary)
7646 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007647 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007648 }
7649
7650 if (!programBinary->setUniform4fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007651 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007652 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007653 }
7654 }
7655 }
7656 catch(std::bad_alloc&)
7657 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007658 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007659 }
7660}
7661
7662void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
7663{
7664 GLint xyzw[4] = {x, y, z, w};
7665
7666 glUniform4iv(location, 1, (GLint*)&xyzw);
7667}
7668
7669void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v)
7670{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007671 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007672
7673 try
7674 {
7675 if (count < 0)
7676 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007677 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007678 }
7679
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007680 if (location == -1)
7681 {
7682 return;
7683 }
7684
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007685 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007686
7687 if (context)
7688 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007689 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007690 if (!programBinary)
7691 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007692 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007693 }
7694
7695 if (!programBinary->setUniform4iv(location, count, v))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007696 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007697 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007698 }
7699 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007700 }
7701 catch(std::bad_alloc&)
7702 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007703 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007704 }
7705}
7706
7707void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
7708{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007709 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007710 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007711
7712 try
7713 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007714 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007715 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007716 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007717 }
7718
7719 if (location == -1)
7720 {
7721 return;
7722 }
7723
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007724 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007725
7726 if (context)
7727 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007728 if (transpose != GL_FALSE && context->getClientVersion() < 3)
7729 {
7730 return gl::error(GL_INVALID_VALUE);
7731 }
7732
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007733 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007734 if (!programBinary)
7735 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007736 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007737 }
7738
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007739 if (!programBinary->setUniformMatrix2fv(location, count, transpose, value))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007740 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007741 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007742 }
7743 }
7744 }
7745 catch(std::bad_alloc&)
7746 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007747 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007748 }
7749}
7750
7751void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
7752{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007753 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007754 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007755
7756 try
7757 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007758 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007759 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007760 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007761 }
7762
7763 if (location == -1)
7764 {
7765 return;
7766 }
7767
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007768 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007769
7770 if (context)
7771 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007772 if (transpose != GL_FALSE && context->getClientVersion() < 3)
7773 {
7774 return gl::error(GL_INVALID_VALUE);
7775 }
7776
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007777 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007778 if (!programBinary)
7779 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007780 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007781 }
7782
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007783 if (!programBinary->setUniformMatrix3fv(location, count, transpose, value))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007784 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007785 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007786 }
7787 }
7788 }
7789 catch(std::bad_alloc&)
7790 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007791 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007792 }
7793}
7794
7795void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
7796{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007797 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007798 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007799
7800 try
7801 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007802 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007803 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007804 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007805 }
7806
7807 if (location == -1)
7808 {
7809 return;
7810 }
7811
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007812 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007813
7814 if (context)
7815 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007816 if (transpose != GL_FALSE && context->getClientVersion() < 3)
7817 {
7818 return gl::error(GL_INVALID_VALUE);
7819 }
7820
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007821 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007822 if (!programBinary)
7823 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007824 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007825 }
7826
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007827 if (!programBinary->setUniformMatrix4fv(location, count, transpose, value))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007828 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007829 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007830 }
7831 }
7832 }
7833 catch(std::bad_alloc&)
7834 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007835 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007836 }
7837}
7838
7839void __stdcall glUseProgram(GLuint program)
7840{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007841 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007842
7843 try
7844 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007845 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007846
7847 if (context)
7848 {
7849 gl::Program *programObject = context->getProgram(program);
7850
daniel@transgaming.comc8478202010-04-13 19:53:35 +00007851 if (!programObject && program != 0)
7852 {
7853 if (context->getShader(program))
7854 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007855 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comc8478202010-04-13 19:53:35 +00007856 }
7857 else
7858 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007859 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comc8478202010-04-13 19:53:35 +00007860 }
7861 }
7862
daniel@transgaming.com716056c2012-07-24 18:38:59 +00007863 if (program != 0 && !programObject->isLinked())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007864 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007865 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007866 }
7867
7868 context->useProgram(program);
7869 }
7870 }
7871 catch(std::bad_alloc&)
7872 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007873 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007874 }
7875}
7876
7877void __stdcall glValidateProgram(GLuint program)
7878{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007879 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007880
7881 try
7882 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007883 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007884
7885 if (context)
7886 {
7887 gl::Program *programObject = context->getProgram(program);
7888
7889 if (!programObject)
7890 {
7891 if (context->getShader(program))
7892 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007893 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007894 }
7895 else
7896 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007897 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007898 }
7899 }
7900
apatrick@chromium.org253b8d22012-06-22 19:27:21 +00007901 programObject->validate();
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007902 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007903 }
7904 catch(std::bad_alloc&)
7905 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007906 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007907 }
7908}
7909
7910void __stdcall glVertexAttrib1f(GLuint index, GLfloat x)
7911{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007912 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007913
7914 try
7915 {
7916 if (index >= gl::MAX_VERTEX_ATTRIBS)
7917 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007918 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007919 }
7920
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007921 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007922
7923 if (context)
7924 {
7925 GLfloat vals[4] = { x, 0, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007926 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007927 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007928 }
7929 catch(std::bad_alloc&)
7930 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007931 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007932 }
7933}
7934
7935void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values)
7936{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007937 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007938
7939 try
7940 {
7941 if (index >= gl::MAX_VERTEX_ATTRIBS)
7942 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007943 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007944 }
7945
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007946 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007947
7948 if (context)
7949 {
7950 GLfloat vals[4] = { values[0], 0, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007951 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007952 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007953 }
7954 catch(std::bad_alloc&)
7955 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007956 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007957 }
7958}
7959
7960void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
7961{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007962 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007963
7964 try
7965 {
7966 if (index >= gl::MAX_VERTEX_ATTRIBS)
7967 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007968 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007969 }
7970
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007971 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007972
7973 if (context)
7974 {
7975 GLfloat vals[4] = { x, y, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007976 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007977 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007978 }
7979 catch(std::bad_alloc&)
7980 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007981 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007982 }
7983}
7984
7985void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values)
7986{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007987 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007988
7989 try
7990 {
7991 if (index >= gl::MAX_VERTEX_ATTRIBS)
7992 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007993 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007994 }
7995
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007996 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007997
7998 if (context)
7999 {
8000 GLfloat vals[4] = { values[0], values[1], 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00008001 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00008002 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008003 }
8004 catch(std::bad_alloc&)
8005 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008006 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008007 }
8008}
8009
8010void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
8011{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008012 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 +00008013
8014 try
8015 {
8016 if (index >= gl::MAX_VERTEX_ATTRIBS)
8017 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008018 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008019 }
8020
daniel@transgaming.com9d788502011-11-09 17:46:55 +00008021 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00008022
8023 if (context)
8024 {
8025 GLfloat vals[4] = { x, y, z, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00008026 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00008027 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008028 }
8029 catch(std::bad_alloc&)
8030 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008031 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008032 }
8033}
8034
8035void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values)
8036{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008037 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008038
8039 try
8040 {
8041 if (index >= gl::MAX_VERTEX_ATTRIBS)
8042 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008043 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008044 }
8045
daniel@transgaming.com9d788502011-11-09 17:46:55 +00008046 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00008047
8048 if (context)
8049 {
8050 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00008051 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00008052 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008053 }
8054 catch(std::bad_alloc&)
8055 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008056 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008057 }
8058}
8059
8060void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
8061{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008062 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 +00008063
8064 try
8065 {
8066 if (index >= gl::MAX_VERTEX_ATTRIBS)
8067 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008068 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008069 }
8070
daniel@transgaming.com9d788502011-11-09 17:46:55 +00008071 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00008072
8073 if (context)
8074 {
8075 GLfloat vals[4] = { x, y, z, w };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00008076 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00008077 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008078 }
8079 catch(std::bad_alloc&)
8080 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008081 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008082 }
8083}
8084
8085void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values)
8086{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008087 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008088
8089 try
8090 {
8091 if (index >= gl::MAX_VERTEX_ATTRIBS)
8092 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008093 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008094 }
8095
daniel@transgaming.com9d788502011-11-09 17:46:55 +00008096 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00008097
8098 if (context)
8099 {
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00008100 context->setVertexAttribf(index, values);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00008101 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008102 }
8103 catch(std::bad_alloc&)
8104 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008105 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008106 }
8107}
8108
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00008109void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
8110{
8111 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
8112
8113 try
8114 {
8115 if (index >= gl::MAX_VERTEX_ATTRIBS)
8116 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008117 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00008118 }
8119
8120 gl::Context *context = gl::getNonLostContext();
8121
8122 if (context)
8123 {
8124 context->setVertexAttribDivisor(index, divisor);
8125 }
8126 }
8127 catch(std::bad_alloc&)
8128 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008129 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00008130 }
8131}
8132
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008133void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008134{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008135 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008136 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00008137 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008138
8139 try
8140 {
8141 if (index >= gl::MAX_VERTEX_ATTRIBS)
8142 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008143 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008144 }
8145
8146 if (size < 1 || size > 4)
8147 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008148 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008149 }
8150
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00008151 gl::Context *context = gl::getNonLostContext();
8152
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008153 switch (type)
8154 {
8155 case GL_BYTE:
8156 case GL_UNSIGNED_BYTE:
8157 case GL_SHORT:
8158 case GL_UNSIGNED_SHORT:
8159 case GL_FIXED:
8160 case GL_FLOAT:
8161 break;
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00008162 case GL_HALF_FLOAT:
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00008163 case GL_INT:
8164 case GL_UNSIGNED_INT:
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00008165 case GL_INT_2_10_10_10_REV:
8166 case GL_UNSIGNED_INT_2_10_10_10_REV:
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00008167 if (context && context->getClientVersion() < 3)
8168 {
8169 return gl::error(GL_INVALID_ENUM);
8170 }
8171 else
8172 {
8173 break;
8174 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008175 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008176 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008177 }
8178
8179 if (stride < 0)
8180 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008181 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008182 }
8183
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00008184 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
8185 {
8186 return gl::error(GL_INVALID_OPERATION);
8187 }
8188
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008189 if (context)
8190 {
Jamie Madilld8db8662013-07-02 11:57:04 -04008191 // [OpenGL ES 3.0.2] Section 2.8 page 24:
8192 // An INVALID_OPERATION error is generated when a non-zero vertex array object
8193 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
8194 // and the pointer argument is not NULL.
8195 if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && ptr != NULL)
8196 {
8197 return gl::error(GL_INVALID_OPERATION);
8198 }
8199
shannon.woods%transgaming.com@gtempaccount.com8de4e6a2013-04-13 03:37:44 +00008200 context->setVertexAttribState(index, context->getArrayBuffer(), size, type,
8201 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008202 }
8203 }
8204 catch(std::bad_alloc&)
8205 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008206 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008207 }
8208}
8209
8210void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
8211{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008212 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 +00008213
8214 try
8215 {
8216 if (width < 0 || height < 0)
8217 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008218 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008219 }
8220
daniel@transgaming.com9d788502011-11-09 17:46:55 +00008221 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008222
8223 if (context)
8224 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00008225 context->setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008226 }
8227 }
8228 catch(std::bad_alloc&)
8229 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00008230 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008231 }
8232}
8233
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008234// OpenGL ES 3.0 functions
8235
8236void __stdcall glReadBuffer(GLenum mode)
8237{
8238 EVENT("(GLenum mode = 0x%X)", mode);
8239
8240 try
8241 {
8242 gl::Context *context = gl::getNonLostContext();
8243
8244 if (context)
8245 {
8246 if (context->getClientVersion() < 3)
8247 {
8248 return gl::error(GL_INVALID_OPERATION);
8249 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008250
Jamie Madill54133512013-06-21 09:33:07 -04008251 // glReadBuffer
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008252 UNIMPLEMENTED();
8253 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008254 }
8255 catch(std::bad_alloc&)
8256 {
8257 return gl::error(GL_OUT_OF_MEMORY);
8258 }
8259}
8260
8261void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
8262{
8263 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
8264 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
8265
8266 try
8267 {
8268 gl::Context *context = gl::getNonLostContext();
8269
8270 if (context)
8271 {
8272 if (context->getClientVersion() < 3)
8273 {
8274 return gl::error(GL_INVALID_OPERATION);
8275 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008276
Jamie Madill54133512013-06-21 09:33:07 -04008277 // glDrawRangeElements
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008278 UNIMPLEMENTED();
8279 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008280 }
8281 catch(std::bad_alloc&)
8282 {
8283 return gl::error(GL_OUT_OF_MEMORY);
8284 }
8285}
8286
8287void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
8288{
8289 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
8290 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
8291 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
8292 target, level, internalformat, width, height, depth, border, format, type, pixels);
8293
8294 try
8295 {
8296 gl::Context *context = gl::getNonLostContext();
8297
8298 if (context)
8299 {
8300 if (context->getClientVersion() < 3)
8301 {
8302 return gl::error(GL_INVALID_OPERATION);
8303 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008304
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008305 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008306 if (!validateES3TexImageParameters(context, target, level, internalformat, false, false,
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008307 0, 0, 0, width, height, depth, border, format, type))
8308 {
8309 return;
8310 }
8311
8312 switch(target)
8313 {
8314 case GL_TEXTURE_3D:
8315 {
8316 gl::Texture3D *texture = context->getTexture3D();
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +00008317 texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackAlignment(), pixels);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008318 }
8319 break;
8320
8321 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008322 {
8323 gl::Texture2DArray *texture = context->getTexture2DArray();
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +00008324 texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackAlignment(), pixels);
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008325 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008326 break;
8327
8328 default:
8329 return gl::error(GL_INVALID_ENUM);
8330 }
8331 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008332 }
8333 catch(std::bad_alloc&)
8334 {
8335 return gl::error(GL_OUT_OF_MEMORY);
8336 }
8337}
8338
8339void __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)
8340{
8341 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
8342 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
8343 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
8344 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
8345
8346 try
8347 {
8348 gl::Context *context = gl::getNonLostContext();
8349
8350 if (context)
8351 {
8352 if (context->getClientVersion() < 3)
8353 {
8354 return gl::error(GL_INVALID_OPERATION);
8355 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008356
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008357 if (!pixels)
8358 {
8359 return gl::error(GL_INVALID_VALUE);
8360 }
8361
8362 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008363 if (!validateES3TexImageParameters(context, target, level, GL_NONE, false, true,
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008364 xoffset, yoffset, zoffset, width, height, depth, 0,
8365 format, type))
8366 {
8367 return;
8368 }
8369
8370 switch(target)
8371 {
8372 case GL_TEXTURE_3D:
8373 {
8374 gl::Texture3D *texture = context->getTexture3D();
8375 texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels);
8376 }
8377 break;
8378
8379 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008380 {
8381 gl::Texture2DArray *texture = context->getTexture2DArray();
8382 texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels);
8383 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008384 break;
8385
8386 default:
8387 return gl::error(GL_INVALID_ENUM);
8388 }
8389 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008390 }
8391 catch(std::bad_alloc&)
8392 {
8393 return gl::error(GL_OUT_OF_MEMORY);
8394 }
8395}
8396
8397void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
8398{
8399 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
8400 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
8401 target, level, xoffset, yoffset, zoffset, x, y, width, height);
8402
8403 try
8404 {
8405 gl::Context *context = gl::getNonLostContext();
8406
8407 if (context)
8408 {
8409 if (context->getClientVersion() < 3)
8410 {
8411 return gl::error(GL_INVALID_OPERATION);
8412 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008413
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008414 if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset,
8415 x, y, width, height, 0))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008416 {
8417 return;
8418 }
8419
8420 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
8421 gl::Texture *texture = NULL;
8422 switch (target)
8423 {
8424 case GL_TEXTURE_3D:
8425 texture = context->getTexture3D();
8426 break;
8427
8428 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008429 texture = context->getTexture2DArray();
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008430 break;
8431
8432 default:
8433 return gl::error(GL_INVALID_ENUM);
8434 }
8435
8436 texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
8437 }
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 glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
8446{
8447 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
8448 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
8449 "const GLvoid* data = 0x%0.8p)",
8450 target, level, internalformat, width, height, depth, border, imageSize, data);
8451
8452 try
8453 {
8454 gl::Context *context = gl::getNonLostContext();
8455
8456 if (context)
8457 {
8458 if (context->getClientVersion() < 3)
8459 {
8460 return gl::error(GL_INVALID_OPERATION);
8461 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008462
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00008463 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 +00008464 {
8465 return gl::error(GL_INVALID_VALUE);
8466 }
8467
8468 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008469 if (!validateES3TexImageParameters(context, target, level, internalformat, true, false,
8470 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008471 {
8472 return;
8473 }
8474
8475 switch(target)
8476 {
8477 case GL_TEXTURE_3D:
8478 {
8479 gl::Texture3D *texture = context->getTexture3D();
8480 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
8481 }
8482 break;
8483
8484 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008485 {
8486 gl::Texture2DArray *texture = context->getTexture2DArray();
8487 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
8488 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008489 break;
8490
8491 default:
8492 return gl::error(GL_INVALID_ENUM);
8493 }
8494 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008495 }
8496 catch(std::bad_alloc&)
8497 {
8498 return gl::error(GL_OUT_OF_MEMORY);
8499 }
8500}
8501
8502void __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)
8503{
8504 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
8505 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
8506 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
8507 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
8508
8509 try
8510 {
8511 gl::Context *context = gl::getNonLostContext();
8512
8513 if (context)
8514 {
8515 if (context->getClientVersion() < 3)
8516 {
8517 return gl::error(GL_INVALID_OPERATION);
8518 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008519
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00008520 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 +00008521 {
8522 return gl::error(GL_INVALID_VALUE);
8523 }
8524
8525 if (!data)
8526 {
8527 return gl::error(GL_INVALID_VALUE);
8528 }
8529
8530 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008531 if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true,
8532 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008533 {
8534 return;
8535 }
8536
8537 switch(target)
8538 {
8539 case GL_TEXTURE_3D:
8540 {
8541 gl::Texture3D *texture = context->getTexture3D();
8542 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
8543 format, imageSize, data);
8544 }
8545 break;
8546
8547 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008548 {
8549 gl::Texture2DArray *texture = context->getTexture2DArray();
8550 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
8551 format, imageSize, data);
8552 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008553 break;
8554
8555 default:
8556 return gl::error(GL_INVALID_ENUM);
8557 }
8558 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008559 }
8560 catch(std::bad_alloc&)
8561 {
8562 return gl::error(GL_OUT_OF_MEMORY);
8563 }
8564}
8565
8566void __stdcall glGenQueries(GLsizei n, GLuint* ids)
8567{
8568 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8569
8570 try
8571 {
8572 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
Jamie Madill54133512013-06-21 09:33:07 -04008581 // glGenQueries
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008582 UNIMPLEMENTED();
8583 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008584 }
8585 catch(std::bad_alloc&)
8586 {
8587 return gl::error(GL_OUT_OF_MEMORY);
8588 }
8589}
8590
8591void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids)
8592{
8593 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8594
8595 try
8596 {
8597 gl::Context *context = gl::getNonLostContext();
8598
8599 if (context)
8600 {
8601 if (context->getClientVersion() < 3)
8602 {
8603 return gl::error(GL_INVALID_OPERATION);
8604 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008605
Jamie Madill54133512013-06-21 09:33:07 -04008606 // glDeleteQueries
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008607 UNIMPLEMENTED();
8608 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008609 }
8610 catch(std::bad_alloc&)
8611 {
8612 return gl::error(GL_OUT_OF_MEMORY);
8613 }
8614}
8615
8616GLboolean __stdcall glIsQuery(GLuint id)
8617{
8618 EVENT("(GLuint id = %u)", id);
8619
8620 try
8621 {
8622 gl::Context *context = gl::getNonLostContext();
8623
8624 if (context)
8625 {
8626 if (context->getClientVersion() < 3)
8627 {
8628 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8629 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008630
Jamie Madill54133512013-06-21 09:33:07 -04008631 // glIsQuery
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008632 UNIMPLEMENTED();
8633 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008634 }
8635 catch(std::bad_alloc&)
8636 {
8637 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8638 }
8639
8640 return GL_FALSE;
8641}
8642
8643void __stdcall glBeginQuery(GLenum target, GLuint id)
8644{
8645 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
8646
8647 try
8648 {
8649 gl::Context *context = gl::getNonLostContext();
8650
8651 if (context)
8652 {
8653 if (context->getClientVersion() < 3)
8654 {
8655 return gl::error(GL_INVALID_OPERATION);
8656 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008657
Jamie Madill54133512013-06-21 09:33:07 -04008658 // glBeginQuery
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008659 UNIMPLEMENTED();
8660 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008661 }
8662 catch(std::bad_alloc&)
8663 {
8664 return gl::error(GL_OUT_OF_MEMORY);
8665 }
8666}
8667
8668void __stdcall glEndQuery(GLenum target)
8669{
8670 EVENT("(GLenum target = 0x%X)", target);
8671
8672 try
8673 {
8674 gl::Context *context = gl::getNonLostContext();
8675
8676 if (context)
8677 {
8678 if (context->getClientVersion() < 3)
8679 {
8680 return gl::error(GL_INVALID_OPERATION);
8681 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008682
Jamie Madill54133512013-06-21 09:33:07 -04008683 // glEndQuery
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008684 UNIMPLEMENTED();
8685 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008686 }
8687 catch(std::bad_alloc&)
8688 {
8689 return gl::error(GL_OUT_OF_MEMORY);
8690 }
8691}
8692
8693void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params)
8694{
8695 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
8696
8697 try
8698 {
8699 gl::Context *context = gl::getNonLostContext();
8700
8701 if (context)
8702 {
8703 if (context->getClientVersion() < 3)
8704 {
8705 return gl::error(GL_INVALID_OPERATION);
8706 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008707
Jamie Madill54133512013-06-21 09:33:07 -04008708 // glGetQueryiv
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008709 UNIMPLEMENTED();
8710 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008711 }
8712 catch(std::bad_alloc&)
8713 {
8714 return gl::error(GL_OUT_OF_MEMORY);
8715 }
8716}
8717
8718void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
8719{
8720 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
8721
8722 try
8723 {
8724 gl::Context *context = gl::getNonLostContext();
8725
8726 if (context)
8727 {
8728 if (context->getClientVersion() < 3)
8729 {
8730 return gl::error(GL_INVALID_OPERATION);
8731 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008732
Jamie Madill54133512013-06-21 09:33:07 -04008733 // glGetQueryObjectuiv
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008734 UNIMPLEMENTED();
8735 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008736 }
8737 catch(std::bad_alloc&)
8738 {
8739 return gl::error(GL_OUT_OF_MEMORY);
8740 }
8741}
8742
8743GLboolean __stdcall glUnmapBuffer(GLenum target)
8744{
8745 EVENT("(GLenum target = 0x%X)", target);
8746
8747 try
8748 {
8749 gl::Context *context = gl::getNonLostContext();
8750
8751 if (context)
8752 {
8753 if (context->getClientVersion() < 3)
8754 {
8755 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8756 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008757
Jamie Madill54133512013-06-21 09:33:07 -04008758 // glUnmapBuffer
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008759 UNIMPLEMENTED();
8760 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008761 }
8762 catch(std::bad_alloc&)
8763 {
8764 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8765 }
8766
8767 return GL_FALSE;
8768}
8769
8770void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
8771{
8772 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
8773
8774 try
8775 {
8776 gl::Context *context = gl::getNonLostContext();
8777
8778 if (context)
8779 {
8780 if (context->getClientVersion() < 3)
8781 {
8782 return gl::error(GL_INVALID_OPERATION);
8783 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008784
Jamie Madill54133512013-06-21 09:33:07 -04008785 // glGetBufferPointerv
shannonwoods@chromium.org2d2190a2013-05-30 00:17:35 +00008786 UNIMPLEMENTED();
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008787 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008788 }
8789 catch(std::bad_alloc&)
8790 {
8791 return gl::error(GL_OUT_OF_MEMORY);
8792 }
8793}
8794
8795void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs)
8796{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008797 try
8798 {
8799 gl::Context *context = gl::getNonLostContext();
8800
8801 if (context)
8802 {
8803 if (context->getClientVersion() < 3)
8804 {
8805 return gl::error(GL_INVALID_OPERATION);
8806 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008807
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00008808 glDrawBuffersEXT(n, bufs);
8809 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008810 }
8811 catch(std::bad_alloc&)
8812 {
8813 return gl::error(GL_OUT_OF_MEMORY);
8814 }
8815}
8816
8817void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8818{
8819 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8820 location, count, transpose, value);
8821
8822 try
8823 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008824 if (count < 0)
8825 {
8826 return gl::error(GL_INVALID_VALUE);
8827 }
8828
8829 if (location == -1)
8830 {
8831 return;
8832 }
8833
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008834 gl::Context *context = gl::getNonLostContext();
8835
8836 if (context)
8837 {
8838 if (context->getClientVersion() < 3)
8839 {
8840 return gl::error(GL_INVALID_OPERATION);
8841 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008842
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008843 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8844 if (!programBinary)
8845 {
8846 return gl::error(GL_INVALID_OPERATION);
8847 }
8848
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008849 if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008850 {
8851 return gl::error(GL_INVALID_OPERATION);
8852 }
8853 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008854 }
8855 catch(std::bad_alloc&)
8856 {
8857 return gl::error(GL_OUT_OF_MEMORY);
8858 }
8859}
8860
8861void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8862{
8863 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8864 location, count, transpose, value);
8865
8866 try
8867 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008868 if (count < 0)
8869 {
8870 return gl::error(GL_INVALID_VALUE);
8871 }
8872
8873 if (location == -1)
8874 {
8875 return;
8876 }
8877
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008878 gl::Context *context = gl::getNonLostContext();
8879
8880 if (context)
8881 {
8882 if (context->getClientVersion() < 3)
8883 {
8884 return gl::error(GL_INVALID_OPERATION);
8885 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008886
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008887 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8888 if (!programBinary)
8889 {
8890 return gl::error(GL_INVALID_OPERATION);
8891 }
8892
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008893 if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008894 {
8895 return gl::error(GL_INVALID_OPERATION);
8896 }
8897 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008898 }
8899 catch(std::bad_alloc&)
8900 {
8901 return gl::error(GL_OUT_OF_MEMORY);
8902 }
8903}
8904
8905void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8906{
8907 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8908 location, count, transpose, value);
8909
8910 try
8911 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008912 if (count < 0)
8913 {
8914 return gl::error(GL_INVALID_VALUE);
8915 }
8916
8917 if (location == -1)
8918 {
8919 return;
8920 }
8921
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008922 gl::Context *context = gl::getNonLostContext();
8923
8924 if (context)
8925 {
8926 if (context->getClientVersion() < 3)
8927 {
8928 return gl::error(GL_INVALID_OPERATION);
8929 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008930
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008931 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8932 if (!programBinary)
8933 {
8934 return gl::error(GL_INVALID_OPERATION);
8935 }
8936
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008937 if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008938 {
8939 return gl::error(GL_INVALID_OPERATION);
8940 }
8941 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008942 }
8943 catch(std::bad_alloc&)
8944 {
8945 return gl::error(GL_OUT_OF_MEMORY);
8946 }
8947}
8948
8949void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8950{
8951 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8952 location, count, transpose, value);
8953
8954 try
8955 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008956 if (count < 0)
8957 {
8958 return gl::error(GL_INVALID_VALUE);
8959 }
8960
8961 if (location == -1)
8962 {
8963 return;
8964 }
8965
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008966 gl::Context *context = gl::getNonLostContext();
8967
8968 if (context)
8969 {
8970 if (context->getClientVersion() < 3)
8971 {
8972 return gl::error(GL_INVALID_OPERATION);
8973 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008974
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008975 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8976 if (!programBinary)
8977 {
8978 return gl::error(GL_INVALID_OPERATION);
8979 }
8980
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008981 if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008982 {
8983 return gl::error(GL_INVALID_OPERATION);
8984 }
8985 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008986 }
8987 catch(std::bad_alloc&)
8988 {
8989 return gl::error(GL_OUT_OF_MEMORY);
8990 }
8991}
8992
8993void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8994{
8995 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8996 location, count, transpose, value);
8997
8998 try
8999 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00009000 if (count < 0)
9001 {
9002 return gl::error(GL_INVALID_VALUE);
9003 }
9004
9005 if (location == -1)
9006 {
9007 return;
9008 }
9009
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009010 gl::Context *context = gl::getNonLostContext();
9011
9012 if (context)
9013 {
9014 if (context->getClientVersion() < 3)
9015 {
9016 return gl::error(GL_INVALID_OPERATION);
9017 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009018
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00009019 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9020 if (!programBinary)
9021 {
9022 return gl::error(GL_INVALID_OPERATION);
9023 }
9024
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00009025 if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00009026 {
9027 return gl::error(GL_INVALID_OPERATION);
9028 }
9029 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009030 }
9031 catch(std::bad_alloc&)
9032 {
9033 return gl::error(GL_OUT_OF_MEMORY);
9034 }
9035}
9036
9037void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
9038{
9039 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
9040 location, count, transpose, value);
9041
9042 try
9043 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00009044 if (count < 0)
9045 {
9046 return gl::error(GL_INVALID_VALUE);
9047 }
9048
9049 if (location == -1)
9050 {
9051 return;
9052 }
9053
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009054 gl::Context *context = gl::getNonLostContext();
9055
9056 if (context)
9057 {
9058 if (context->getClientVersion() < 3)
9059 {
9060 return gl::error(GL_INVALID_OPERATION);
9061 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009062
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00009063 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9064 if (!programBinary)
9065 {
9066 return gl::error(GL_INVALID_OPERATION);
9067 }
9068
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00009069 if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00009070 {
9071 return gl::error(GL_INVALID_OPERATION);
9072 }
9073 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009074 }
9075 catch(std::bad_alloc&)
9076 {
9077 return gl::error(GL_OUT_OF_MEMORY);
9078 }
9079}
9080
9081void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
9082{
9083 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
9084 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
9085 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
9086
9087 try
9088 {
9089 gl::Context *context = gl::getNonLostContext();
9090
9091 if (context)
9092 {
9093 if (context->getClientVersion() < 3)
9094 {
9095 return gl::error(GL_INVALID_OPERATION);
9096 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009097
Geoff Lang758d5b22013-06-11 11:42:50 -04009098 if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
9099 dstX0, dstY0, dstX1, dstY1, mask, filter,
9100 false))
9101 {
9102 return;
9103 }
9104
9105 context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
9106 mask, filter);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009107 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009108 }
9109 catch(std::bad_alloc&)
9110 {
9111 return gl::error(GL_OUT_OF_MEMORY);
9112 }
9113}
9114
9115void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
9116{
9117 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
9118 target, samples, internalformat, width, height);
9119
9120 try
9121 {
9122 gl::Context *context = gl::getNonLostContext();
9123
9124 if (context)
9125 {
9126 if (context->getClientVersion() < 3)
9127 {
9128 return gl::error(GL_INVALID_OPERATION);
9129 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009130
Geoff Lang2e1dcd52013-05-29 10:34:08 -04009131 if (!validateRenderbufferStorageParameters(context, target, samples, internalformat,
9132 width, height, false))
9133 {
9134 return;
9135 }
9136
9137 context->setRenderbufferStorage(width, height, internalformat, samples);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009138 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009139 }
9140 catch(std::bad_alloc&)
9141 {
9142 return gl::error(GL_OUT_OF_MEMORY);
9143 }
9144}
9145
9146void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
9147{
9148 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
9149 target, attachment, texture, level, layer);
9150
9151 try
9152 {
9153 gl::Context *context = gl::getNonLostContext();
9154
9155 if (context)
9156 {
9157 if (context->getClientVersion() < 3)
9158 {
9159 return gl::error(GL_INVALID_OPERATION);
9160 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009161
Jamie Madill54133512013-06-21 09:33:07 -04009162 // glFramebufferTextureLayer
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009163 UNIMPLEMENTED();
9164 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009165 }
9166 catch(std::bad_alloc&)
9167 {
9168 return gl::error(GL_OUT_OF_MEMORY);
9169 }
9170}
9171
9172GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
9173{
9174 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
9175 target, offset, length, access);
9176
9177 try
9178 {
9179 gl::Context *context = gl::getNonLostContext();
9180
9181 if (context)
9182 {
9183 if (context->getClientVersion() < 3)
9184 {
9185 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
9186 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009187
Jamie Madill54133512013-06-21 09:33:07 -04009188 // glMapBufferRange
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009189 UNIMPLEMENTED();
9190 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009191 }
9192 catch(std::bad_alloc&)
9193 {
9194 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL));
9195 }
9196
9197 return NULL;
9198}
9199
9200void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
9201{
9202 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
9203
9204 try
9205 {
9206 gl::Context *context = gl::getNonLostContext();
9207
9208 if (context)
9209 {
9210 if (context->getClientVersion() < 3)
9211 {
9212 return gl::error(GL_INVALID_OPERATION);
9213 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009214
Jamie Madill54133512013-06-21 09:33:07 -04009215 // glFlushMappedBufferRange
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009216 UNIMPLEMENTED();
9217 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009218 }
9219 catch(std::bad_alloc&)
9220 {
9221 return gl::error(GL_OUT_OF_MEMORY);
9222 }
9223}
9224
9225void __stdcall glBindVertexArray(GLuint array)
9226{
9227 EVENT("(GLuint array = %u)", array);
9228
9229 try
9230 {
9231 gl::Context *context = gl::getNonLostContext();
9232
9233 if (context)
9234 {
9235 if (context->getClientVersion() < 3)
9236 {
9237 return gl::error(GL_INVALID_OPERATION);
9238 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009239
Jamie Madilld1028542013-07-02 11:57:04 -04009240 gl::VertexArray *vao = context->getVertexArray(array);
9241
9242 if (!vao)
9243 {
9244 // The default VAO should always exist
9245 ASSERT(array != 0);
9246 return gl::error(GL_INVALID_OPERATION);
9247 }
9248
9249 context->bindVertexArray(array);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009250 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009251 }
9252 catch(std::bad_alloc&)
9253 {
9254 return gl::error(GL_OUT_OF_MEMORY);
9255 }
9256}
9257
9258void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
9259{
9260 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
9261
9262 try
9263 {
9264 gl::Context *context = gl::getNonLostContext();
9265
9266 if (context)
9267 {
9268 if (context->getClientVersion() < 3)
9269 {
9270 return gl::error(GL_INVALID_OPERATION);
9271 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009272
Jamie Madilld1028542013-07-02 11:57:04 -04009273 if (n < 0)
9274 {
9275 return gl::error(GL_INVALID_VALUE);
9276 }
9277
9278 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
9279 {
9280 if (arrays[arrayIndex] != 0)
9281 {
9282 context->deleteVertexArray(arrays[arrayIndex]);
9283 }
9284 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009285 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009286 }
9287 catch(std::bad_alloc&)
9288 {
9289 return gl::error(GL_OUT_OF_MEMORY);
9290 }
9291}
9292
9293void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays)
9294{
9295 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
9296
9297 try
9298 {
9299 gl::Context *context = gl::getNonLostContext();
9300
9301 if (context)
9302 {
9303 if (context->getClientVersion() < 3)
9304 {
9305 return gl::error(GL_INVALID_OPERATION);
9306 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009307
Jamie Madilld1028542013-07-02 11:57:04 -04009308 if (n < 0)
9309 {
9310 return gl::error(GL_INVALID_VALUE);
9311 }
9312
9313 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
9314 {
9315 arrays[arrayIndex] = context->createVertexArray();
9316 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009317 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009318 }
9319 catch(std::bad_alloc&)
9320 {
9321 return gl::error(GL_OUT_OF_MEMORY);
9322 }
9323}
9324
9325GLboolean __stdcall glIsVertexArray(GLuint array)
9326{
9327 EVENT("(GLuint array = %u)", array);
9328
9329 try
9330 {
9331 gl::Context *context = gl::getNonLostContext();
9332
9333 if (context)
9334 {
9335 if (context->getClientVersion() < 3)
9336 {
9337 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
9338 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009339
Jamie Madilld1028542013-07-02 11:57:04 -04009340 if (array == 0)
9341 {
9342 return GL_FALSE;
9343 }
9344
9345 gl::VertexArray *vao = context->getVertexArray(array);
9346
9347 return (vao != NULL ? GL_TRUE : GL_FALSE);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009348 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009349 }
9350 catch(std::bad_alloc&)
9351 {
9352 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
9353 }
9354
9355 return GL_FALSE;
9356}
9357
9358void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
9359{
9360 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
9361 target, index, data);
9362
9363 try
9364 {
9365 gl::Context *context = gl::getNonLostContext();
9366
9367 if (context)
9368 {
9369 if (context->getClientVersion() < 3)
9370 {
9371 return gl::error(GL_INVALID_OPERATION);
9372 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009373
Jamie Madill54133512013-06-21 09:33:07 -04009374 // glGetIntegeri_v
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009375 UNIMPLEMENTED();
9376 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009377 }
9378 catch(std::bad_alloc&)
9379 {
9380 return gl::error(GL_OUT_OF_MEMORY);
9381 }
9382}
9383
9384void __stdcall glBeginTransformFeedback(GLenum primitiveMode)
9385{
9386 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
9387
9388 try
9389 {
9390 gl::Context *context = gl::getNonLostContext();
9391
9392 if (context)
9393 {
9394 if (context->getClientVersion() < 3)
9395 {
9396 return gl::error(GL_INVALID_OPERATION);
9397 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009398
Jamie Madill54133512013-06-21 09:33:07 -04009399 // glBeginTransformFeedback
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009400 UNIMPLEMENTED();
9401 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009402 }
9403 catch(std::bad_alloc&)
9404 {
9405 return gl::error(GL_OUT_OF_MEMORY);
9406 }
9407}
9408
9409void __stdcall glEndTransformFeedback(void)
9410{
9411 EVENT("(void)");
9412
9413 try
9414 {
9415 gl::Context *context = gl::getNonLostContext();
9416
9417 if (context)
9418 {
9419 if (context->getClientVersion() < 3)
9420 {
9421 return gl::error(GL_INVALID_OPERATION);
9422 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009423
Jamie Madill54133512013-06-21 09:33:07 -04009424 // glEndTransformFeedback
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009425 UNIMPLEMENTED();
9426 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009427 }
9428 catch(std::bad_alloc&)
9429 {
9430 return gl::error(GL_OUT_OF_MEMORY);
9431 }
9432}
9433
9434void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
9435{
9436 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
9437 target, index, buffer, offset, size);
9438
9439 try
9440 {
9441 gl::Context *context = gl::getNonLostContext();
9442
9443 if (context)
9444 {
9445 if (context->getClientVersion() < 3)
9446 {
9447 return gl::error(GL_INVALID_OPERATION);
9448 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009449
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009450 switch (target)
9451 {
9452 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00009453 if (index >= context->getMaxTransformFeedbackBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009454 {
9455 return gl::error(GL_INVALID_VALUE);
9456 }
9457 break;
9458
9459 case GL_UNIFORM_BUFFER:
9460 if (index >= context->getMaximumCombinedUniformBufferBindings())
9461 {
9462 return gl::error(GL_INVALID_VALUE);
9463 }
9464 break;
9465
9466 default:
9467 return gl::error(GL_INVALID_ENUM);
9468 }
9469
shannonwoods@chromium.orge6e00792013-05-30 00:06:07 +00009470 if (buffer != 0 && size <= 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009471 {
9472 return gl::error(GL_INVALID_VALUE);
9473 }
9474
9475 switch (target)
9476 {
9477 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orga26aeaf2013-05-30 00:06:13 +00009478
9479 // size and offset must be a multiple of 4
9480 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
9481 {
9482 return gl::error(GL_INVALID_VALUE);
9483 }
9484
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009485 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
9486 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009487 break;
9488
9489 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.org97c3d502013-05-30 00:04:34 +00009490
9491 // it is an error to bind an offset not a multiple of the alignment
9492 if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0)
9493 {
9494 return gl::error(GL_INVALID_VALUE);
9495 }
9496
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009497 context->bindIndexedUniformBuffer(buffer, index, offset, size);
9498 context->bindGenericUniformBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009499 break;
9500
9501 default:
9502 UNREACHABLE();
9503 }
9504 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009505 }
9506 catch(std::bad_alloc&)
9507 {
9508 return gl::error(GL_OUT_OF_MEMORY);
9509 }
9510}
9511
9512void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
9513{
9514 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
9515 target, index, buffer);
9516
9517 try
9518 {
9519 gl::Context *context = gl::getNonLostContext();
9520
9521 if (context)
9522 {
9523 if (context->getClientVersion() < 3)
9524 {
9525 return gl::error(GL_INVALID_OPERATION);
9526 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009527
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009528 switch (target)
9529 {
9530 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00009531 if (index >= context->getMaxTransformFeedbackBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009532 {
9533 return gl::error(GL_INVALID_VALUE);
9534 }
9535 break;
9536
9537 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00009538 if (index >= context->getMaximumCombinedUniformBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009539 {
9540 return gl::error(GL_INVALID_VALUE);
9541 }
9542 break;
9543
9544 default:
9545 return gl::error(GL_INVALID_ENUM);
9546 }
9547
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009548 switch (target)
9549 {
9550 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.org3eeca1e2013-05-30 00:04:28 +00009551 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009552 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009553 break;
9554
9555 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.org3eeca1e2013-05-30 00:04:28 +00009556 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009557 context->bindGenericUniformBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009558 break;
9559
9560 default:
9561 UNREACHABLE();
9562 }
9563 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009564 }
9565 catch(std::bad_alloc&)
9566 {
9567 return gl::error(GL_OUT_OF_MEMORY);
9568 }
9569}
9570
9571void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
9572{
9573 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
9574 program, count, varyings, bufferMode);
9575
9576 try
9577 {
9578 gl::Context *context = gl::getNonLostContext();
9579
9580 if (context)
9581 {
9582 if (context->getClientVersion() < 3)
9583 {
9584 return gl::error(GL_INVALID_OPERATION);
9585 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009586
Jamie Madill54133512013-06-21 09:33:07 -04009587 // glTransformFeedbackVaryings
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009588 UNIMPLEMENTED();
9589 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009590 }
9591 catch(std::bad_alloc&)
9592 {
9593 return gl::error(GL_OUT_OF_MEMORY);
9594 }
9595}
9596
9597void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
9598{
9599 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
9600 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
9601 program, index, bufSize, length, size, type, name);
9602
9603 try
9604 {
9605 gl::Context *context = gl::getNonLostContext();
9606
9607 if (context)
9608 {
9609 if (context->getClientVersion() < 3)
9610 {
9611 return gl::error(GL_INVALID_OPERATION);
9612 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009613
Jamie Madill54133512013-06-21 09:33:07 -04009614 // glGetTransformFeedbackVarying
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009615 UNIMPLEMENTED();
9616 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009617 }
9618 catch(std::bad_alloc&)
9619 {
9620 return gl::error(GL_OUT_OF_MEMORY);
9621 }
9622}
9623
9624void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
9625{
9626 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
9627 index, size, type, stride, pointer);
9628
9629 try
9630 {
9631 gl::Context *context = gl::getNonLostContext();
9632
9633 if (context)
9634 {
9635 if (context->getClientVersion() < 3)
9636 {
9637 return gl::error(GL_INVALID_OPERATION);
9638 }
9639 }
9640
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009641 if (index >= gl::MAX_VERTEX_ATTRIBS)
9642 {
9643 return gl::error(GL_INVALID_VALUE);
9644 }
9645
9646 if (size < 1 || size > 4)
9647 {
9648 return gl::error(GL_INVALID_VALUE);
9649 }
9650
9651 switch (type)
9652 {
9653 case GL_BYTE:
9654 case GL_UNSIGNED_BYTE:
9655 case GL_SHORT:
9656 case GL_UNSIGNED_SHORT:
9657 case GL_INT:
9658 case GL_UNSIGNED_INT:
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00009659 case GL_INT_2_10_10_10_REV:
9660 case GL_UNSIGNED_INT_2_10_10_10_REV:
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009661 break;
9662 default:
9663 return gl::error(GL_INVALID_ENUM);
9664 }
9665
9666 if (stride < 0)
9667 {
9668 return gl::error(GL_INVALID_VALUE);
9669 }
9670
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00009671 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
9672 {
9673 return gl::error(GL_INVALID_OPERATION);
9674 }
9675
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009676 if (context)
9677 {
Jamie Madilld8db8662013-07-02 11:57:04 -04009678 // [OpenGL ES 3.0.2] Section 2.8 page 24:
9679 // An INVALID_OPERATION error is generated when a non-zero vertex array object
9680 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
9681 // and the pointer argument is not NULL.
9682 if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && pointer != NULL)
9683 {
9684 return gl::error(GL_INVALID_OPERATION);
9685 }
9686
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009687 context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true,
9688 stride, pointer);
9689 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009690 }
9691 catch(std::bad_alloc&)
9692 {
9693 return gl::error(GL_OUT_OF_MEMORY);
9694 }
9695}
9696
9697void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
9698{
9699 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
9700 index, pname, params);
9701
9702 try
9703 {
9704 gl::Context *context = gl::getNonLostContext();
9705
9706 if (context)
9707 {
9708 if (context->getClientVersion() < 3)
9709 {
9710 return gl::error(GL_INVALID_OPERATION);
9711 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009712
Jamie Madilla7d05862013-07-02 11:57:06 -04009713 if (index >= gl::MAX_VERTEX_ATTRIBS)
9714 {
9715 return gl::error(GL_INVALID_VALUE);
9716 }
9717
9718 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
9719
9720 if (!validateGetVertexAttribParameters(pname, context->getClientVersion()))
9721 {
9722 return;
9723 }
9724
9725 if (pname == GL_CURRENT_VERTEX_ATTRIB)
9726 {
9727 const gl::VertexAttribCurrentValueData &currentValueData = context->getVertexAttribCurrentValue(index);
9728 for (int i = 0; i < 4; ++i)
9729 {
9730 params[i] = currentValueData.IntValues[i];
9731 }
9732 }
9733 else
9734 {
9735 *params = attribState.querySingleParameter<GLint>(pname);
9736 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009737 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009738 }
9739 catch(std::bad_alloc&)
9740 {
9741 return gl::error(GL_OUT_OF_MEMORY);
9742 }
9743}
9744
9745void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
9746{
9747 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
9748 index, pname, params);
9749
9750 try
9751 {
9752 gl::Context *context = gl::getNonLostContext();
9753
9754 if (context)
9755 {
9756 if (context->getClientVersion() < 3)
9757 {
9758 return gl::error(GL_INVALID_OPERATION);
9759 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009760
Jamie Madilla7d05862013-07-02 11:57:06 -04009761 if (index >= gl::MAX_VERTEX_ATTRIBS)
9762 {
9763 return gl::error(GL_INVALID_VALUE);
9764 }
9765
9766 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
9767
9768 if (!validateGetVertexAttribParameters(pname, context->getClientVersion()))
9769 {
9770 return;
9771 }
9772
9773 if (pname == GL_CURRENT_VERTEX_ATTRIB)
9774 {
9775 const gl::VertexAttribCurrentValueData &currentValueData = context->getVertexAttribCurrentValue(index);
9776 for (int i = 0; i < 4; ++i)
9777 {
9778 params[i] = currentValueData.UnsignedIntValues[i];
9779 }
9780 }
9781 else
9782 {
9783 *params = attribState.querySingleParameter<GLuint>(pname);
9784 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009785 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009786 }
9787 catch(std::bad_alloc&)
9788 {
9789 return gl::error(GL_OUT_OF_MEMORY);
9790 }
9791}
9792
9793void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
9794{
9795 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
9796 index, x, y, z, w);
9797
9798 try
9799 {
9800 gl::Context *context = gl::getNonLostContext();
9801
9802 if (context)
9803 {
9804 if (context->getClientVersion() < 3)
9805 {
9806 return gl::error(GL_INVALID_OPERATION);
9807 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009808
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009809 if (index >= gl::MAX_VERTEX_ATTRIBS)
9810 {
9811 return gl::error(GL_INVALID_VALUE);
9812 }
9813
9814 GLint vals[4] = { x, y, z, w };
9815 context->setVertexAttribi(index, vals);
9816 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009817 }
9818 catch(std::bad_alloc&)
9819 {
9820 return gl::error(GL_OUT_OF_MEMORY);
9821 }
9822}
9823
9824void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
9825{
9826 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
9827 index, x, y, z, w);
9828
9829 try
9830 {
9831 gl::Context *context = gl::getNonLostContext();
9832
9833 if (context)
9834 {
9835 if (context->getClientVersion() < 3)
9836 {
9837 return gl::error(GL_INVALID_OPERATION);
9838 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009839
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009840 if (index >= gl::MAX_VERTEX_ATTRIBS)
9841 {
9842 return gl::error(GL_INVALID_VALUE);
9843 }
9844
9845 GLuint vals[4] = { x, y, z, w };
9846 context->setVertexAttribu(index, vals);
9847 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009848 }
9849 catch(std::bad_alloc&)
9850 {
9851 return gl::error(GL_OUT_OF_MEMORY);
9852 }
9853}
9854
9855void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v)
9856{
9857 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
9858
9859 try
9860 {
9861 gl::Context *context = gl::getNonLostContext();
9862
9863 if (context)
9864 {
9865 if (context->getClientVersion() < 3)
9866 {
9867 return gl::error(GL_INVALID_OPERATION);
9868 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009869
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009870 if (index >= gl::MAX_VERTEX_ATTRIBS)
9871 {
9872 return gl::error(GL_INVALID_VALUE);
9873 }
9874
9875 context->setVertexAttribi(index, v);
9876 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009877 }
9878 catch(std::bad_alloc&)
9879 {
9880 return gl::error(GL_OUT_OF_MEMORY);
9881 }
9882}
9883
9884void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v)
9885{
9886 EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
9887
9888 try
9889 {
9890 gl::Context *context = gl::getNonLostContext();
9891
9892 if (context)
9893 {
9894 if (context->getClientVersion() < 3)
9895 {
9896 return gl::error(GL_INVALID_OPERATION);
9897 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009898
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009899 if (index >= gl::MAX_VERTEX_ATTRIBS)
9900 {
9901 return gl::error(GL_INVALID_VALUE);
9902 }
9903
9904 context->setVertexAttribu(index, v);
9905 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009906 }
9907 catch(std::bad_alloc&)
9908 {
9909 return gl::error(GL_OUT_OF_MEMORY);
9910 }
9911}
9912
9913void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params)
9914{
9915 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
9916 program, location, params);
9917
9918 try
9919 {
9920 gl::Context *context = gl::getNonLostContext();
9921
9922 if (context)
9923 {
9924 if (context->getClientVersion() < 3)
9925 {
9926 return gl::error(GL_INVALID_OPERATION);
9927 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009928
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00009929 if (program == 0)
9930 {
9931 return gl::error(GL_INVALID_VALUE);
9932 }
9933
9934 gl::Program *programObject = context->getProgram(program);
9935
9936 if (!programObject || !programObject->isLinked())
9937 {
9938 return gl::error(GL_INVALID_OPERATION);
9939 }
9940
9941 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
9942 if (!programBinary)
9943 {
9944 return gl::error(GL_INVALID_OPERATION);
9945 }
9946
9947 if (!programBinary->getUniformuiv(location, NULL, params))
9948 {
9949 return gl::error(GL_INVALID_OPERATION);
9950 }
9951 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009952 }
9953 catch(std::bad_alloc&)
9954 {
9955 return gl::error(GL_OUT_OF_MEMORY);
9956 }
9957}
9958
9959GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name)
9960{
9961 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
9962 program, name);
9963
9964 try
9965 {
9966 gl::Context *context = gl::getNonLostContext();
9967
9968 if (context)
9969 {
9970 if (context->getClientVersion() < 3)
9971 {
Jamie Madilld1e78c92013-06-20 11:55:50 -04009972 return gl::error(GL_INVALID_OPERATION, -1);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009973 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009974
Jamie Madilld1e78c92013-06-20 11:55:50 -04009975 if (program == 0)
9976 {
9977 return gl::error(GL_INVALID_VALUE, -1);
9978 }
9979
9980 gl::Program *programObject = context->getProgram(program);
9981
9982 if (!programObject || !programObject->isLinked())
9983 {
9984 return gl::error(GL_INVALID_OPERATION, -1);
9985 }
9986
9987 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
9988 if (!programBinary)
9989 {
9990 return gl::error(GL_INVALID_OPERATION, -1);
9991 }
9992
9993 return programBinary->getFragDataLocation(name);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009994 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009995 }
9996 catch(std::bad_alloc&)
9997 {
9998 return gl::error(GL_OUT_OF_MEMORY, 0);
9999 }
10000
10001 return 0;
10002}
10003
10004void __stdcall glUniform1ui(GLint location, GLuint v0)
10005{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +000010006 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010007}
10008
10009void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1)
10010{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +000010011 const GLuint xy[] = { v0, v1 };
10012 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010013}
10014
10015void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
10016{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +000010017 const GLuint xyz[] = { v0, v1, v2 };
10018 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010019}
10020
10021void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
10022{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +000010023 const GLuint xyzw[] = { v0, v1, v2, v3 };
10024 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010025}
10026
10027void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
10028{
10029 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
10030 location, count, value);
10031
10032 try
10033 {
10034 gl::Context *context = gl::getNonLostContext();
10035
10036 if (context)
10037 {
10038 if (context->getClientVersion() < 3)
10039 {
10040 return gl::error(GL_INVALID_OPERATION);
10041 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010042
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +000010043 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
10044 if (!programBinary)
10045 {
10046 return gl::error(GL_INVALID_OPERATION);
10047 }
10048
10049 if (!programBinary->setUniform1uiv(location, count, value))
10050 {
10051 return gl::error(GL_INVALID_OPERATION);
10052 }
10053 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010054 }
10055 catch(std::bad_alloc&)
10056 {
10057 return gl::error(GL_OUT_OF_MEMORY);
10058 }
10059}
10060
10061void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
10062{
10063 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
10064 location, count, value);
10065
10066 try
10067 {
10068 gl::Context *context = gl::getNonLostContext();
10069
10070 if (context)
10071 {
10072 if (context->getClientVersion() < 3)
10073 {
10074 return gl::error(GL_INVALID_OPERATION);
10075 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010076
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +000010077 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
10078 if (!programBinary)
10079 {
10080 return gl::error(GL_INVALID_OPERATION);
10081 }
10082
10083 if (!programBinary->setUniform2uiv(location, count, value))
10084 {
10085 return gl::error(GL_INVALID_OPERATION);
10086 }
10087 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010088 }
10089 catch(std::bad_alloc&)
10090 {
10091 return gl::error(GL_OUT_OF_MEMORY);
10092 }
10093}
10094
10095void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
10096{
10097 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
10098 location, count, value);
10099
10100 try
10101 {
10102 gl::Context *context = gl::getNonLostContext();
10103
10104 if (context)
10105 {
10106 if (context->getClientVersion() < 3)
10107 {
10108 return gl::error(GL_INVALID_OPERATION);
10109 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010110
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +000010111 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
10112 if (!programBinary)
10113 {
10114 return gl::error(GL_INVALID_OPERATION);
10115 }
10116
10117 if (!programBinary->setUniform3uiv(location, count, value))
10118 {
10119 return gl::error(GL_INVALID_OPERATION);
10120 }
10121 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010122 }
10123 catch(std::bad_alloc&)
10124 {
10125 return gl::error(GL_OUT_OF_MEMORY);
10126 }
10127}
10128
10129void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
10130{
10131 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
10132 location, count, value);
10133
10134 try
10135 {
10136 gl::Context *context = gl::getNonLostContext();
10137
10138 if (context)
10139 {
10140 if (context->getClientVersion() < 3)
10141 {
10142 return gl::error(GL_INVALID_OPERATION);
10143 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010144
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +000010145 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
10146 if (!programBinary)
10147 {
10148 return gl::error(GL_INVALID_OPERATION);
10149 }
10150
10151 if (!programBinary->setUniform4uiv(location, count, value))
10152 {
10153 return gl::error(GL_INVALID_OPERATION);
10154 }
10155 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010156 }
10157 catch(std::bad_alloc&)
10158 {
10159 return gl::error(GL_OUT_OF_MEMORY);
10160 }
10161}
10162
10163void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
10164{
10165 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
10166 buffer, drawbuffer, value);
10167
10168 try
10169 {
10170 gl::Context *context = gl::getNonLostContext();
10171
10172 if (context)
10173 {
10174 if (context->getClientVersion() < 3)
10175 {
10176 return gl::error(GL_INVALID_OPERATION);
10177 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010178
Jamie Madill54133512013-06-21 09:33:07 -040010179 // glClearBufferiv
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010180 UNIMPLEMENTED();
10181 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010182 }
10183 catch(std::bad_alloc&)
10184 {
10185 return gl::error(GL_OUT_OF_MEMORY);
10186 }
10187}
10188
10189void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
10190{
10191 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
10192 buffer, drawbuffer, value);
10193
10194 try
10195 {
10196 gl::Context *context = gl::getNonLostContext();
10197
10198 if (context)
10199 {
10200 if (context->getClientVersion() < 3)
10201 {
10202 return gl::error(GL_INVALID_OPERATION);
10203 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010204
Jamie Madill54133512013-06-21 09:33:07 -040010205 // glClearBufferuiv
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010206 UNIMPLEMENTED();
10207 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010208 }
10209 catch(std::bad_alloc&)
10210 {
10211 return gl::error(GL_OUT_OF_MEMORY);
10212 }
10213}
10214
10215void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
10216{
10217 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
10218 buffer, drawbuffer, value);
10219
10220 try
10221 {
10222 gl::Context *context = gl::getNonLostContext();
10223
10224 if (context)
10225 {
10226 if (context->getClientVersion() < 3)
10227 {
10228 return gl::error(GL_INVALID_OPERATION);
10229 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010230
Jamie Madill54133512013-06-21 09:33:07 -040010231 // glClearBufferfv
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010232 UNIMPLEMENTED();
10233 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010234 }
10235 catch(std::bad_alloc&)
10236 {
10237 return gl::error(GL_OUT_OF_MEMORY);
10238 }
10239}
10240
10241void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
10242{
10243 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
10244 buffer, drawbuffer, depth, stencil);
10245
10246 try
10247 {
10248 gl::Context *context = gl::getNonLostContext();
10249
10250 if (context)
10251 {
10252 if (context->getClientVersion() < 3)
10253 {
10254 return gl::error(GL_INVALID_OPERATION);
10255 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010256
Jamie Madill54133512013-06-21 09:33:07 -040010257 // glClearBufferfi
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010258 UNIMPLEMENTED();
10259 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010260 }
10261 catch(std::bad_alloc&)
10262 {
10263 return gl::error(GL_OUT_OF_MEMORY);
10264 }
10265}
10266
10267const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index)
10268{
10269 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
10270
10271 try
10272 {
10273 gl::Context *context = gl::getNonLostContext();
10274
10275 if (context)
10276 {
10277 if (context->getClientVersion() < 3)
10278 {
10279 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL));
10280 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010281
shannonwoods@chromium.org302df742013-05-30 00:05:54 +000010282 if (name != GL_EXTENSIONS)
10283 {
10284 return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL));
10285 }
10286
10287 if (index >= context->getNumExtensions())
10288 {
10289 return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL));
10290 }
10291
10292 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index));
10293 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010294 }
10295 catch(std::bad_alloc&)
10296 {
10297 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL));
10298 }
10299
10300 return NULL;
10301}
10302
10303void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
10304{
10305 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
10306 readTarget, writeTarget, readOffset, writeOffset, size);
10307
10308 try
10309 {
10310 gl::Context *context = gl::getNonLostContext();
10311
10312 if (context)
10313 {
10314 if (context->getClientVersion() < 3)
10315 {
10316 return gl::error(GL_INVALID_OPERATION);
10317 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010318
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +000010319 gl::Buffer *readBuffer = NULL;
10320 switch (readTarget)
10321 {
10322 case GL_ARRAY_BUFFER:
10323 readBuffer = context->getArrayBuffer();
10324 break;
10325 case GL_COPY_READ_BUFFER:
10326 readBuffer = context->getCopyReadBuffer();
10327 break;
10328 case GL_COPY_WRITE_BUFFER:
10329 readBuffer = context->getCopyWriteBuffer();
10330 break;
10331 case GL_ELEMENT_ARRAY_BUFFER:
10332 readBuffer = context->getElementArrayBuffer();
10333 break;
10334 case GL_PIXEL_PACK_BUFFER:
10335 readBuffer = context->getPixelPackBuffer();
10336 break;
10337 case GL_PIXEL_UNPACK_BUFFER:
10338 readBuffer = context->getPixelUnpackBuffer();
10339 break;
10340 case GL_TRANSFORM_FEEDBACK_BUFFER:
10341 readBuffer = context->getGenericTransformFeedbackBuffer();
10342 break;
10343 case GL_UNIFORM_BUFFER:
10344 readBuffer = context->getGenericUniformBuffer();
10345 break;
10346 default:
10347 return gl::error(GL_INVALID_ENUM);
10348 }
10349
10350 gl::Buffer *writeBuffer = NULL;
10351 switch (writeTarget)
10352 {
10353 case GL_ARRAY_BUFFER:
10354 writeBuffer = context->getArrayBuffer();
10355 break;
10356 case GL_COPY_READ_BUFFER:
10357 writeBuffer = context->getCopyReadBuffer();
10358 break;
10359 case GL_COPY_WRITE_BUFFER:
10360 writeBuffer = context->getCopyWriteBuffer();
10361 break;
10362 case GL_ELEMENT_ARRAY_BUFFER:
10363 writeBuffer = context->getElementArrayBuffer();
10364 break;
10365 case GL_PIXEL_PACK_BUFFER:
10366 writeBuffer = context->getPixelPackBuffer();
10367 break;
10368 case GL_PIXEL_UNPACK_BUFFER:
10369 writeBuffer = context->getPixelUnpackBuffer();
10370 break;
10371 case GL_TRANSFORM_FEEDBACK_BUFFER:
10372 writeBuffer = context->getGenericTransformFeedbackBuffer();
10373 break;
10374 case GL_UNIFORM_BUFFER:
10375 writeBuffer = context->getGenericUniformBuffer();
10376 break;
10377 default:
10378 return gl::error(GL_INVALID_ENUM);
10379 }
10380
10381 if (!readBuffer || !writeBuffer)
10382 {
10383 return gl::error(GL_INVALID_OPERATION);
10384 }
10385
10386 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
10387 static_cast<unsigned int>(readOffset + size) > readBuffer->size() ||
10388 static_cast<unsigned int>(writeOffset + size) > writeBuffer->size())
10389 {
10390 return gl::error(GL_INVALID_VALUE);
10391 }
10392
10393 if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size)
10394 {
10395 return gl::error(GL_INVALID_VALUE);
10396 }
10397
10398 // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION)
10399
shannon.woods%transgaming.com@gtempaccount.comc53376a2013-04-13 03:41:23 +000010400 // if size is zero, the copy is a successful no-op
10401 if (size > 0)
10402 {
10403 writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
10404 }
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +000010405 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010406 }
10407 catch(std::bad_alloc&)
10408 {
10409 return gl::error(GL_OUT_OF_MEMORY);
10410 }
10411}
10412
10413void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
10414{
10415 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
10416 program, uniformCount, uniformNames, uniformIndices);
10417
10418 try
10419 {
10420 gl::Context *context = gl::getNonLostContext();
10421
10422 if (context)
10423 {
10424 if (context->getClientVersion() < 3)
10425 {
10426 return gl::error(GL_INVALID_OPERATION);
10427 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010428
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +000010429 if (uniformCount < 0)
10430 {
10431 return gl::error(GL_INVALID_VALUE);
10432 }
10433
10434 gl::Program *programObject = context->getProgram(program);
10435
10436 if (!programObject)
10437 {
10438 if (context->getShader(program))
10439 {
10440 return gl::error(GL_INVALID_OPERATION);
10441 }
10442 else
10443 {
10444 return gl::error(GL_INVALID_VALUE);
10445 }
10446 }
10447
10448 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10449 if (!programObject->isLinked() || !programBinary)
10450 {
10451 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10452 {
10453 uniformIndices[uniformId] = GL_INVALID_INDEX;
10454 }
10455 }
10456 else
10457 {
10458 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10459 {
10460 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
10461 }
10462 }
10463 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010464 }
10465 catch(std::bad_alloc&)
10466 {
10467 return gl::error(GL_OUT_OF_MEMORY);
10468 }
10469}
10470
10471void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
10472{
10473 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
10474 program, uniformCount, uniformIndices, pname, params);
10475
10476 try
10477 {
10478 gl::Context *context = gl::getNonLostContext();
10479
10480 if (context)
10481 {
10482 if (context->getClientVersion() < 3)
10483 {
10484 return gl::error(GL_INVALID_OPERATION);
10485 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010486
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +000010487 if (uniformCount < 0)
10488 {
10489 return gl::error(GL_INVALID_VALUE);
10490 }
10491
10492 gl::Program *programObject = context->getProgram(program);
10493
10494 if (!programObject)
10495 {
10496 if (context->getShader(program))
10497 {
10498 return gl::error(GL_INVALID_OPERATION);
10499 }
10500 else
10501 {
10502 return gl::error(GL_INVALID_VALUE);
10503 }
10504 }
10505
10506 switch (pname)
10507 {
10508 case GL_UNIFORM_TYPE:
10509 case GL_UNIFORM_SIZE:
10510 case GL_UNIFORM_NAME_LENGTH:
10511 case GL_UNIFORM_BLOCK_INDEX:
10512 case GL_UNIFORM_OFFSET:
10513 case GL_UNIFORM_ARRAY_STRIDE:
10514 case GL_UNIFORM_MATRIX_STRIDE:
10515 case GL_UNIFORM_IS_ROW_MAJOR:
10516 break;
10517 default:
10518 return gl::error(GL_INVALID_ENUM);
10519 }
10520
10521 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10522
10523 if (!programBinary && uniformCount > 0)
10524 {
10525 return gl::error(GL_INVALID_VALUE);
10526 }
10527
10528 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10529 {
10530 const GLuint index = uniformIndices[uniformId];
10531
10532 if (index >= (GLuint)programBinary->getActiveUniformCount())
10533 {
10534 return gl::error(GL_INVALID_VALUE);
10535 }
10536 }
10537
10538 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10539 {
10540 const GLuint index = uniformIndices[uniformId];
10541 params[uniformId] = programBinary->getActiveUniformi(index, pname);
10542 }
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
10551GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
10552{
10553 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
10554
10555 try
10556 {
10557 gl::Context *context = gl::getNonLostContext();
10558
10559 if (context)
10560 {
10561 if (context->getClientVersion() < 3)
10562 {
shannonwoods@chromium.org42766252013-05-30 00:07:12 +000010563 return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010564 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010565
shannonwoods@chromium.org42766252013-05-30 00:07:12 +000010566 gl::Program *programObject = context->getProgram(program);
10567
10568 if (!programObject)
10569 {
10570 if (context->getShader(program))
10571 {
10572 return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
10573 }
10574 else
10575 {
10576 return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX);
10577 }
10578 }
10579
10580 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10581 if (!programBinary)
10582 {
10583 return GL_INVALID_INDEX;
10584 }
10585
10586 return programBinary->getUniformBlockIndex(uniformBlockName);
10587 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010588 }
10589 catch(std::bad_alloc&)
10590 {
10591 return gl::error(GL_OUT_OF_MEMORY, 0);
10592 }
10593
10594 return 0;
10595}
10596
10597void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
10598{
10599 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
10600 program, uniformBlockIndex, pname, params);
10601
10602 try
10603 {
10604 gl::Context *context = gl::getNonLostContext();
10605
10606 if (context)
10607 {
10608 if (context->getClientVersion() < 3)
10609 {
10610 return gl::error(GL_INVALID_OPERATION);
10611 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +000010612 gl::Program *programObject = context->getProgram(program);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010613
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +000010614 if (!programObject)
10615 {
10616 if (context->getShader(program))
10617 {
10618 return gl::error(GL_INVALID_OPERATION);
10619 }
10620 else
10621 {
10622 return gl::error(GL_INVALID_VALUE);
10623 }
10624 }
10625
10626 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10627
10628 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
10629 {
10630 return gl::error(GL_INVALID_VALUE);
10631 }
10632
10633 switch (pname)
10634 {
10635 case GL_UNIFORM_BLOCK_BINDING:
10636 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
10637 break;
10638
10639 case GL_UNIFORM_BLOCK_DATA_SIZE:
10640 case GL_UNIFORM_BLOCK_NAME_LENGTH:
10641 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
10642 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
10643 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
10644 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
10645 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
10646 break;
10647
10648 default:
10649 return gl::error(GL_INVALID_ENUM);
10650 }
10651 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010652 }
10653 catch(std::bad_alloc&)
10654 {
10655 return gl::error(GL_OUT_OF_MEMORY);
10656 }
10657}
10658
10659void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
10660{
10661 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
10662 program, uniformBlockIndex, bufSize, length, uniformBlockName);
10663
10664 try
10665 {
10666 gl::Context *context = gl::getNonLostContext();
10667
10668 if (context)
10669 {
10670 if (context->getClientVersion() < 3)
10671 {
10672 return gl::error(GL_INVALID_OPERATION);
10673 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010674
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +000010675 gl::Program *programObject = context->getProgram(program);
10676
10677 if (!programObject)
10678 {
10679 if (context->getShader(program))
10680 {
10681 return gl::error(GL_INVALID_OPERATION);
10682 }
10683 else
10684 {
10685 return gl::error(GL_INVALID_VALUE);
10686 }
10687 }
10688
10689 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10690
10691 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
10692 {
10693 return gl::error(GL_INVALID_VALUE);
10694 }
10695
10696 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
10697 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010698 }
10699 catch(std::bad_alloc&)
10700 {
10701 return gl::error(GL_OUT_OF_MEMORY);
10702 }
10703}
10704
10705void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
10706{
10707 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
10708 program, uniformBlockIndex, uniformBlockBinding);
10709
10710 try
10711 {
10712 gl::Context *context = gl::getNonLostContext();
10713
10714 if (context)
10715 {
10716 if (context->getClientVersion() < 3)
10717 {
10718 return gl::error(GL_INVALID_OPERATION);
10719 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010720
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +000010721 if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings())
10722 {
10723 return gl::error(GL_INVALID_VALUE);
10724 }
10725
10726 gl::Program *programObject = context->getProgram(program);
10727
10728 if (!programObject)
10729 {
10730 if (context->getShader(program))
10731 {
10732 return gl::error(GL_INVALID_OPERATION);
10733 }
10734 else
10735 {
10736 return gl::error(GL_INVALID_VALUE);
10737 }
10738 }
10739
10740 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10741
10742 // if never linked, there won't be any uniform blocks
10743 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
10744 {
10745 return gl::error(GL_INVALID_VALUE);
10746 }
10747
10748 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
10749 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010750 }
10751 catch(std::bad_alloc&)
10752 {
10753 return gl::error(GL_OUT_OF_MEMORY);
10754 }
10755}
10756
10757void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
10758{
10759 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
10760 mode, first, count, instanceCount);
10761
10762 try
10763 {
10764 gl::Context *context = gl::getNonLostContext();
10765
10766 if (context)
10767 {
10768 if (context->getClientVersion() < 3)
10769 {
10770 return gl::error(GL_INVALID_OPERATION);
10771 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010772
Jamie Madill54133512013-06-21 09:33:07 -040010773 // glDrawArraysInstanced
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010774 UNIMPLEMENTED();
10775 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010776 }
10777 catch(std::bad_alloc&)
10778 {
10779 return gl::error(GL_OUT_OF_MEMORY);
10780 }
10781}
10782
10783void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
10784{
10785 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
10786 mode, count, type, indices, instanceCount);
10787
10788 try
10789 {
10790 gl::Context *context = gl::getNonLostContext();
10791
10792 if (context)
10793 {
10794 if (context->getClientVersion() < 3)
10795 {
10796 return gl::error(GL_INVALID_OPERATION);
10797 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010798
Jamie Madill54133512013-06-21 09:33:07 -040010799 // glDrawElementsInstanced
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010800 UNIMPLEMENTED();
10801 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010802 }
10803 catch(std::bad_alloc&)
10804 {
10805 return gl::error(GL_OUT_OF_MEMORY);
10806 }
10807}
10808
10809GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags)
10810{
10811 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
10812
10813 try
10814 {
10815 gl::Context *context = gl::getNonLostContext();
10816
10817 if (context)
10818 {
10819 if (context->getClientVersion() < 3)
10820 {
10821 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(NULL));
10822 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010823
Jamie Madill54133512013-06-21 09:33:07 -040010824 // glFenceSync
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010825 UNIMPLEMENTED();
10826 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010827 }
10828 catch(std::bad_alloc&)
10829 {
10830 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL));
10831 }
10832
10833 return NULL;
10834}
10835
10836GLboolean __stdcall glIsSync(GLsync sync)
10837{
10838 EVENT("(GLsync sync = 0x%0.8p)", sync);
10839
10840 try
10841 {
10842 gl::Context *context = gl::getNonLostContext();
10843
10844 if (context)
10845 {
10846 if (context->getClientVersion() < 3)
10847 {
10848 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10849 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010850
Jamie Madill54133512013-06-21 09:33:07 -040010851 // glIsSync
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010852 UNIMPLEMENTED();
10853 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010854 }
10855 catch(std::bad_alloc&)
10856 {
10857 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10858 }
10859
10860 return GL_FALSE;
10861}
10862
10863void __stdcall glDeleteSync(GLsync sync)
10864{
10865 EVENT("(GLsync sync = 0x%0.8p)", sync);
10866
10867 try
10868 {
10869 gl::Context *context = gl::getNonLostContext();
10870
10871 if (context)
10872 {
10873 if (context->getClientVersion() < 3)
10874 {
10875 return gl::error(GL_INVALID_OPERATION);
10876 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010877
Jamie Madill54133512013-06-21 09:33:07 -040010878 // glDeleteSync
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010879 UNIMPLEMENTED();
10880 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010881 }
10882 catch(std::bad_alloc&)
10883 {
10884 return gl::error(GL_OUT_OF_MEMORY);
10885 }
10886}
10887
10888GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
10889{
10890 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
10891 sync, flags, timeout);
10892
10893 try
10894 {
10895 gl::Context *context = gl::getNonLostContext();
10896
10897 if (context)
10898 {
10899 if (context->getClientVersion() < 3)
10900 {
10901 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10902 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010903
Jamie Madill54133512013-06-21 09:33:07 -040010904 // glClientWaitSync
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010905 UNIMPLEMENTED();
10906 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010907 }
10908 catch(std::bad_alloc&)
10909 {
10910 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10911 }
10912
10913 return GL_FALSE;
10914}
10915
10916void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
10917{
10918 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
10919 sync, flags, timeout);
10920
10921 try
10922 {
10923 gl::Context *context = gl::getNonLostContext();
10924
10925 if (context)
10926 {
10927 if (context->getClientVersion() < 3)
10928 {
10929 return gl::error(GL_INVALID_OPERATION);
10930 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010931
Jamie Madill54133512013-06-21 09:33:07 -040010932 // glWaitSync
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010933 UNIMPLEMENTED();
10934 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010935 }
10936 catch(std::bad_alloc&)
10937 {
10938 return gl::error(GL_OUT_OF_MEMORY);
10939 }
10940}
10941
10942void __stdcall glGetInteger64v(GLenum pname, GLint64* params)
10943{
10944 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
10945 pname, params);
10946
10947 try
10948 {
10949 gl::Context *context = gl::getNonLostContext();
10950
10951 if (context)
10952 {
10953 if (context->getClientVersion() < 3)
10954 {
10955 return gl::error(GL_INVALID_OPERATION);
10956 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010957
Jamie Madill54133512013-06-21 09:33:07 -040010958 // glGetInteger64v
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010959 UNIMPLEMENTED();
10960 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010961 }
10962 catch(std::bad_alloc&)
10963 {
10964 return gl::error(GL_OUT_OF_MEMORY);
10965 }
10966}
10967
10968void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
10969{
10970 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
10971 sync, pname, bufSize, length, values);
10972
10973 try
10974 {
10975 gl::Context *context = gl::getNonLostContext();
10976
10977 if (context)
10978 {
10979 if (context->getClientVersion() < 3)
10980 {
10981 return gl::error(GL_INVALID_OPERATION);
10982 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010983
Jamie Madill54133512013-06-21 09:33:07 -040010984 // glGetSynciv
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 glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
10995{
10996 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
10997 target, index, data);
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
Jamie Madill54133512013-06-21 09:33:07 -040011010 // glGetInteger64i_v
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011011 UNIMPLEMENTED();
11012 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011013 }
11014 catch(std::bad_alloc&)
11015 {
11016 return gl::error(GL_OUT_OF_MEMORY);
11017 }
11018}
11019
11020void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
11021{
11022 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
11023 target, pname, params);
11024
11025 try
11026 {
11027 gl::Context *context = gl::getNonLostContext();
11028
11029 if (context)
11030 {
11031 if (context->getClientVersion() < 3)
11032 {
11033 return gl::error(GL_INVALID_OPERATION);
11034 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011035
Jamie Madill54133512013-06-21 09:33:07 -040011036 // glGetBufferParameteri64v
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011037 UNIMPLEMENTED();
11038 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011039 }
11040 catch(std::bad_alloc&)
11041 {
11042 return gl::error(GL_OUT_OF_MEMORY);
11043 }
11044}
11045
11046void __stdcall glGenSamplers(GLsizei count, GLuint* samplers)
11047{
11048 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
11049
11050 try
11051 {
11052 gl::Context *context = gl::getNonLostContext();
11053
11054 if (context)
11055 {
11056 if (context->getClientVersion() < 3)
11057 {
11058 return gl::error(GL_INVALID_OPERATION);
11059 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011060
Jamie Madill54133512013-06-21 09:33:07 -040011061 // glGenSamplers
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011062 UNIMPLEMENTED();
11063 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011064 }
11065 catch(std::bad_alloc&)
11066 {
11067 return gl::error(GL_OUT_OF_MEMORY);
11068 }
11069}
11070
11071void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers)
11072{
11073 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
11074
11075 try
11076 {
11077 gl::Context *context = gl::getNonLostContext();
11078
11079 if (context)
11080 {
11081 if (context->getClientVersion() < 3)
11082 {
11083 return gl::error(GL_INVALID_OPERATION);
11084 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011085
Jamie Madill54133512013-06-21 09:33:07 -040011086 // glDeleteSamplers
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011087 UNIMPLEMENTED();
11088 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011089 }
11090 catch(std::bad_alloc&)
11091 {
11092 return gl::error(GL_OUT_OF_MEMORY);
11093 }
11094}
11095
11096GLboolean __stdcall glIsSampler(GLuint sampler)
11097{
11098 EVENT("(GLuint sampler = %u)", sampler);
11099
11100 try
11101 {
11102 gl::Context *context = gl::getNonLostContext();
11103
11104 if (context)
11105 {
11106 if (context->getClientVersion() < 3)
11107 {
11108 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
11109 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011110
Jamie Madill54133512013-06-21 09:33:07 -040011111 // glIsSampler
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011112 UNIMPLEMENTED();
11113 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011114 }
11115 catch(std::bad_alloc&)
11116 {
11117 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
11118 }
11119
11120 return GL_FALSE;
11121}
11122
11123void __stdcall glBindSampler(GLuint unit, GLuint sampler)
11124{
11125 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
11126
11127 try
11128 {
11129 gl::Context *context = gl::getNonLostContext();
11130
11131 if (context)
11132 {
11133 if (context->getClientVersion() < 3)
11134 {
11135 return gl::error(GL_INVALID_OPERATION);
11136 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011137
Jamie Madill54133512013-06-21 09:33:07 -040011138 // glBindSampler
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011139 UNIMPLEMENTED();
11140 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011141 }
11142 catch(std::bad_alloc&)
11143 {
11144 return gl::error(GL_OUT_OF_MEMORY);
11145 }
11146}
11147
11148void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
11149{
11150 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
11151
11152 try
11153 {
11154 gl::Context *context = gl::getNonLostContext();
11155
11156 if (context)
11157 {
11158 if (context->getClientVersion() < 3)
11159 {
11160 return gl::error(GL_INVALID_OPERATION);
11161 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011162
Jamie Madill54133512013-06-21 09:33:07 -040011163 // glSamplerParameteri
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011164 UNIMPLEMENTED();
11165 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011166 }
11167 catch(std::bad_alloc&)
11168 {
11169 return gl::error(GL_OUT_OF_MEMORY);
11170 }
11171}
11172
11173void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
11174{
11175 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLint* param = 0x%0.8p)",
11176 sampler, pname, param);
11177
11178 try
11179 {
11180 gl::Context *context = gl::getNonLostContext();
11181
11182 if (context)
11183 {
11184 if (context->getClientVersion() < 3)
11185 {
11186 return gl::error(GL_INVALID_OPERATION);
11187 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011188
Jamie Madill54133512013-06-21 09:33:07 -040011189 // glSamplerParameteriv
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011190 UNIMPLEMENTED();
11191 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011192 }
11193 catch(std::bad_alloc&)
11194 {
11195 return gl::error(GL_OUT_OF_MEMORY);
11196 }
11197}
11198
11199void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
11200{
11201 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
11202
11203 try
11204 {
11205 gl::Context *context = gl::getNonLostContext();
11206
11207 if (context)
11208 {
11209 if (context->getClientVersion() < 3)
11210 {
11211 return gl::error(GL_INVALID_OPERATION);
11212 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011213
Jamie Madill54133512013-06-21 09:33:07 -040011214 // glSamplerParameterf
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011215 UNIMPLEMENTED();
11216 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011217 }
11218 catch(std::bad_alloc&)
11219 {
11220 return gl::error(GL_OUT_OF_MEMORY);
11221 }
11222}
11223
11224void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
11225{
11226 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLfloat* param = 0x%0.8p)", sampler, pname, param);
11227
11228 try
11229 {
11230 gl::Context *context = gl::getNonLostContext();
11231
11232 if (context)
11233 {
11234 if (context->getClientVersion() < 3)
11235 {
11236 return gl::error(GL_INVALID_OPERATION);
11237 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011238
Jamie Madill54133512013-06-21 09:33:07 -040011239 // glSamplerParameterfv
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011240 UNIMPLEMENTED();
11241 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011242 }
11243 catch(std::bad_alloc&)
11244 {
11245 return gl::error(GL_OUT_OF_MEMORY);
11246 }
11247}
11248
11249void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
11250{
11251 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
11252
11253 try
11254 {
11255 gl::Context *context = gl::getNonLostContext();
11256
11257 if (context)
11258 {
11259 if (context->getClientVersion() < 3)
11260 {
11261 return gl::error(GL_INVALID_OPERATION);
11262 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011263
Jamie Madill54133512013-06-21 09:33:07 -040011264 // glGetSamplerParameteriv
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011265 UNIMPLEMENTED();
11266 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011267 }
11268 catch(std::bad_alloc&)
11269 {
11270 return gl::error(GL_OUT_OF_MEMORY);
11271 }
11272}
11273
11274void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
11275{
11276 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
11277
11278 try
11279 {
11280 gl::Context *context = gl::getNonLostContext();
11281
11282 if (context)
11283 {
11284 if (context->getClientVersion() < 3)
11285 {
11286 return gl::error(GL_INVALID_OPERATION);
11287 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011288
Jamie Madill54133512013-06-21 09:33:07 -040011289 // glGetSamplerParameterfv
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011290 UNIMPLEMENTED();
11291 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011292 }
11293 catch(std::bad_alloc&)
11294 {
11295 return gl::error(GL_OUT_OF_MEMORY);
11296 }
11297}
11298
11299void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor)
11300{
11301 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
11302
11303 try
11304 {
shannon.woods%transgaming.com@gtempaccount.com8736bd62013-04-13 03:35:41 +000011305 if (index >= gl::MAX_VERTEX_ATTRIBS)
11306 {
11307 return gl::error(GL_INVALID_VALUE);
11308 }
11309
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011310 gl::Context *context = gl::getNonLostContext();
11311
11312 if (context)
11313 {
11314 if (context->getClientVersion() < 3)
11315 {
11316 return gl::error(GL_INVALID_OPERATION);
11317 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011318
shannon.woods%transgaming.com@gtempaccount.com8736bd62013-04-13 03:35:41 +000011319 context->setVertexAttribDivisor(index, divisor);
11320 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011321 }
11322 catch(std::bad_alloc&)
11323 {
11324 return gl::error(GL_OUT_OF_MEMORY);
11325 }
11326}
11327
11328void __stdcall glBindTransformFeedback(GLenum target, GLuint id)
11329{
11330 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
11331
11332 try
11333 {
11334 gl::Context *context = gl::getNonLostContext();
11335
11336 if (context)
11337 {
11338 if (context->getClientVersion() < 3)
11339 {
11340 return gl::error(GL_INVALID_OPERATION);
11341 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011342
Jamie Madill54133512013-06-21 09:33:07 -040011343 // glBindTransformFeedback
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011344 UNIMPLEMENTED();
11345 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011346 }
11347 catch(std::bad_alloc&)
11348 {
11349 return gl::error(GL_OUT_OF_MEMORY);
11350 }
11351}
11352
11353void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
11354{
11355 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
11356
11357 try
11358 {
11359 gl::Context *context = gl::getNonLostContext();
11360
11361 if (context)
11362 {
11363 if (context->getClientVersion() < 3)
11364 {
11365 return gl::error(GL_INVALID_OPERATION);
11366 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011367
Jamie Madill54133512013-06-21 09:33:07 -040011368 // glDeleteTransformFeedbacks
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011369 UNIMPLEMENTED();
11370 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011371 }
11372 catch(std::bad_alloc&)
11373 {
11374 return gl::error(GL_OUT_OF_MEMORY);
11375 }
11376}
11377
11378void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids)
11379{
11380 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
11381
11382 try
11383 {
11384 gl::Context *context = gl::getNonLostContext();
11385
11386 if (context)
11387 {
11388 if (context->getClientVersion() < 3)
11389 {
11390 return gl::error(GL_INVALID_OPERATION);
11391 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011392
Jamie Madill54133512013-06-21 09:33:07 -040011393 // glGenTransformFeedbacks
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011394 UNIMPLEMENTED();
11395 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011396 }
11397 catch(std::bad_alloc&)
11398 {
11399 return gl::error(GL_OUT_OF_MEMORY);
11400 }
11401}
11402
11403GLboolean __stdcall glIsTransformFeedback(GLuint id)
11404{
11405 EVENT("(GLuint id = %u)", id);
11406
11407 try
11408 {
11409 gl::Context *context = gl::getNonLostContext();
11410
11411 if (context)
11412 {
11413 if (context->getClientVersion() < 3)
11414 {
11415 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
11416 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011417
Jamie Madill54133512013-06-21 09:33:07 -040011418 // glIsTransformFeedback
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011419 UNIMPLEMENTED();
11420 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011421 }
11422 catch(std::bad_alloc&)
11423 {
11424 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
11425 }
11426
11427 return GL_FALSE;
11428}
11429
11430void __stdcall glPauseTransformFeedback(void)
11431{
11432 EVENT("(void)");
11433
11434 try
11435 {
11436 gl::Context *context = gl::getNonLostContext();
11437
11438 if (context)
11439 {
11440 if (context->getClientVersion() < 3)
11441 {
11442 return gl::error(GL_INVALID_OPERATION);
11443 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011444
Jamie Madill54133512013-06-21 09:33:07 -040011445 // glPauseTransformFeedback
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011446 UNIMPLEMENTED();
11447 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011448 }
11449 catch(std::bad_alloc&)
11450 {
11451 return gl::error(GL_OUT_OF_MEMORY);
11452 }
11453}
11454
11455void __stdcall glResumeTransformFeedback(void)
11456{
11457 EVENT("(void)");
11458
11459 try
11460 {
11461 gl::Context *context = gl::getNonLostContext();
11462
11463 if (context)
11464 {
11465 if (context->getClientVersion() < 3)
11466 {
11467 return gl::error(GL_INVALID_OPERATION);
11468 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011469
Jamie Madill54133512013-06-21 09:33:07 -040011470 // glResumeTransformFeedback
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011471 UNIMPLEMENTED();
11472 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011473 }
11474 catch(std::bad_alloc&)
11475 {
11476 return gl::error(GL_OUT_OF_MEMORY);
11477 }
11478}
11479
11480void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
11481{
11482 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
11483 program, bufSize, length, binaryFormat, binary);
11484
11485 try
11486 {
11487 gl::Context *context = gl::getNonLostContext();
11488
11489 if (context)
11490 {
11491 if (context->getClientVersion() < 3)
11492 {
11493 return gl::error(GL_INVALID_OPERATION);
11494 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011495
Jamie Madill54133512013-06-21 09:33:07 -040011496 // glGetProgramBinary
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011497 UNIMPLEMENTED();
11498 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011499 }
11500 catch(std::bad_alloc&)
11501 {
11502 return gl::error(GL_OUT_OF_MEMORY);
11503 }
11504}
11505
11506void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
11507{
11508 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
11509 program, binaryFormat, binary, length);
11510
11511 try
11512 {
11513 gl::Context *context = gl::getNonLostContext();
11514
11515 if (context)
11516 {
11517 if (context->getClientVersion() < 3)
11518 {
11519 return gl::error(GL_INVALID_OPERATION);
11520 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011521
Jamie Madill54133512013-06-21 09:33:07 -040011522 // glProgramBinary
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011523 UNIMPLEMENTED();
11524 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011525 }
11526 catch(std::bad_alloc&)
11527 {
11528 return gl::error(GL_OUT_OF_MEMORY);
11529 }
11530}
11531
11532void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value)
11533{
11534 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
11535 program, pname, value);
11536
11537 try
11538 {
11539 gl::Context *context = gl::getNonLostContext();
11540
11541 if (context)
11542 {
11543 if (context->getClientVersion() < 3)
11544 {
11545 return gl::error(GL_INVALID_OPERATION);
11546 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011547
Jamie Madill54133512013-06-21 09:33:07 -040011548 // glProgramParameteri
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011549 UNIMPLEMENTED();
11550 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011551 }
11552 catch(std::bad_alloc&)
11553 {
11554 return gl::error(GL_OUT_OF_MEMORY);
11555 }
11556}
11557
11558void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
11559{
11560 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
11561 target, numAttachments, attachments);
11562
11563 try
11564 {
11565 gl::Context *context = gl::getNonLostContext();
11566
11567 if (context)
11568 {
11569 if (context->getClientVersion() < 3)
11570 {
11571 return gl::error(GL_INVALID_OPERATION);
11572 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011573
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +000011574 if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
11575 {
11576 return;
11577 }
11578
11579 int maxDimension = context->getMaximumRenderbufferDimension();
11580 context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension);
11581 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011582 }
11583 catch(std::bad_alloc&)
11584 {
11585 return gl::error(GL_OUT_OF_MEMORY);
11586 }
11587}
11588
11589void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
11590{
11591 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
11592 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
11593 target, numAttachments, attachments, x, y, width, height);
11594
11595 try
11596 {
11597 gl::Context *context = gl::getNonLostContext();
11598
11599 if (context)
11600 {
11601 if (context->getClientVersion() < 3)
11602 {
11603 return gl::error(GL_INVALID_OPERATION);
11604 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011605
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +000011606 if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
11607 {
11608 return;
11609 }
11610
11611 context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height);
11612 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011613 }
11614 catch(std::bad_alloc&)
11615 {
11616 return gl::error(GL_OUT_OF_MEMORY);
11617 }
11618}
11619
11620void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
11621{
11622 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
11623 target, levels, internalformat, width, height);
11624
11625 try
11626 {
11627 gl::Context *context = gl::getNonLostContext();
11628
11629 if (context)
11630 {
11631 if (context->getClientVersion() < 3)
11632 {
11633 return gl::error(GL_INVALID_OPERATION);
11634 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011635
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +000011636 if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
11637 {
11638 return;
11639 }
11640
11641 switch (target)
11642 {
11643 case GL_TEXTURE_2D:
11644 {
11645 gl::Texture2D *texture2d = context->getTexture2D();
11646 texture2d->storage(levels, internalformat, width, height);
11647 }
11648 break;
11649
11650 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
11651 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
11652 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
11653 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
11654 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
11655 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
11656 {
11657 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
11658 textureCube->storage(levels, internalformat, width);
11659 }
11660 break;
11661
11662 default:
11663 return gl::error(GL_INVALID_ENUM);
11664 }
11665 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011666 }
11667 catch(std::bad_alloc&)
11668 {
11669 return gl::error(GL_OUT_OF_MEMORY);
11670 }
11671}
11672
11673void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
11674{
11675 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
11676 "GLsizei height = %d, GLsizei depth = %d)",
11677 target, levels, internalformat, width, height, depth);
11678
11679 try
11680 {
11681 gl::Context *context = gl::getNonLostContext();
11682
11683 if (context)
11684 {
11685 if (context->getClientVersion() < 3)
11686 {
11687 return gl::error(GL_INVALID_OPERATION);
11688 }
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +000011689
11690 if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
11691 {
11692 return;
11693 }
11694
11695 switch (target)
11696 {
11697 case GL_TEXTURE_3D:
11698 {
11699 gl::Texture3D *texture3d = context->getTexture3D();
11700 texture3d->storage(levels, internalformat, width, height, depth);
11701 }
11702 break;
11703
11704 case GL_TEXTURE_2D_ARRAY:
11705 {
11706 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
11707 texture2darray->storage(levels, internalformat, width, height, depth);
11708 }
11709 break;
11710
11711 default:
11712 return gl::error(GL_INVALID_ENUM);
11713 }
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +000011714 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011715 }
11716 catch(std::bad_alloc&)
11717 {
11718 return gl::error(GL_OUT_OF_MEMORY);
11719 }
11720}
11721
11722void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
11723{
11724 EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
11725 "GLint* params = 0x%0.8p)",
11726 target, internalformat, pname, bufSize, params);
11727
11728 try
11729 {
11730 gl::Context *context = gl::getNonLostContext();
11731
11732 if (context)
11733 {
11734 if (context->getClientVersion() < 3)
11735 {
11736 return gl::error(GL_INVALID_OPERATION);
11737 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011738
Shannon Woods809d2502013-07-08 10:32:18 -040011739 if (!gl::IsColorRenderingSupported(internalformat, context) &&
11740 !gl::IsDepthRenderingSupported(internalformat, context) &&
11741 !gl::IsStencilRenderingSupported(internalformat, context))
11742 {
11743 return gl::error(GL_INVALID_ENUM);
11744 }
11745
11746 if (target != GL_RENDERBUFFER)
11747 {
11748 return gl::error(GL_INVALID_ENUM);
11749 }
11750
11751 if (bufSize < 0)
11752 {
11753 return gl::error(GL_INVALID_VALUE);
11754 }
11755
11756 switch (pname)
11757 {
11758 case GL_NUM_SAMPLE_COUNTS:
11759 if (bufSize != 0)
11760 *params = context->getNumSampleCounts(internalformat);
11761 break;
11762 case GL_SAMPLES:
11763 context->getSampleCounts(internalformat, bufSize, params);
11764 break;
11765 default:
11766 return gl::error(GL_INVALID_ENUM);
11767 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011768 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011769 }
11770 catch(std::bad_alloc&)
11771 {
11772 return gl::error(GL_OUT_OF_MEMORY);
11773 }
11774}
11775
11776// Extension functions
11777
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011778void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
11779 GLbitfield mask, GLenum filter)
11780{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000011781 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011782 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
11783 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
11784 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
11785
11786 try
11787 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +000011788 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011789
11790 if (context)
11791 {
Geoff Lang758d5b22013-06-11 11:42:50 -040011792 if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
11793 dstX0, dstY0, dstX1, dstY1, mask, filter,
11794 true))
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011795 {
Geoff Lang758d5b22013-06-11 11:42:50 -040011796 return;
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011797 }
11798
Geoff Lang758d5b22013-06-11 11:42:50 -040011799 context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
11800 mask, filter);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011801 }
11802 }
11803 catch(std::bad_alloc&)
11804 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011805 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011806 }
11807}
11808
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +000011809void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
11810 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011811{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000011812 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +000011813 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +000011814 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011815 target, level, internalformat, width, height, depth, border, format, type, pixels);
11816
11817 try
11818 {
11819 UNIMPLEMENTED(); // FIXME
11820 }
11821 catch(std::bad_alloc&)
11822 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011823 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011824 }
11825}
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011826
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011827void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
11828 GLenum *binaryFormat, void *binary)
11829{
apatrick@chromium.org90080e32012-07-09 22:15:33 +000011830 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 +000011831 program, bufSize, length, binaryFormat, binary);
11832
11833 try
11834 {
11835 gl::Context *context = gl::getNonLostContext();
11836
11837 if (context)
11838 {
11839 gl::Program *programObject = context->getProgram(program);
11840
daniel@transgaming.com716056c2012-07-24 18:38:59 +000011841 if (!programObject || !programObject->isLinked())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011842 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011843 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011844 }
11845
11846 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
11847
11848 if (!programBinary)
11849 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011850 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011851 }
11852
apatrick@chromium.org90080e32012-07-09 22:15:33 +000011853 if (!programBinary->save(binary, bufSize, length))
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011854 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011855 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011856 }
apatrick@chromium.org90080e32012-07-09 22:15:33 +000011857
11858 *binaryFormat = GL_PROGRAM_BINARY_ANGLE;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011859 }
11860 }
11861 catch(std::bad_alloc&)
11862 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011863 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011864 }
11865}
11866
11867void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat,
11868 const void *binary, GLint length)
11869{
11870 EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
11871 program, binaryFormat, binary, length);
11872
11873 try
11874 {
11875 gl::Context *context = gl::getNonLostContext();
11876
11877 if (context)
11878 {
11879 if (binaryFormat != GL_PROGRAM_BINARY_ANGLE)
11880 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011881 return gl::error(GL_INVALID_ENUM);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011882 }
11883
11884 gl::Program *programObject = context->getProgram(program);
11885
11886 if (!programObject)
11887 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011888 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011889 }
11890
daniel@transgaming.com95d29422012-07-24 18:36:10 +000011891 context->setProgramBinary(program, binary, length);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011892 }
11893 }
11894 catch(std::bad_alloc&)
11895 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011896 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011897 }
11898}
11899
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011900void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
11901{
11902 EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
11903
11904 try
11905 {
11906 gl::Context *context = gl::getNonLostContext();
11907
11908 if (context)
11909 {
11910 if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets())
11911 {
11912 return gl::error(GL_INVALID_VALUE);
11913 }
11914
11915 if (context->getDrawFramebufferHandle() == 0)
11916 {
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011917 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011918 {
11919 return gl::error(GL_INVALID_OPERATION);
11920 }
11921
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011922 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011923 {
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011924 return gl::error(GL_INVALID_OPERATION);
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011925 }
11926 }
11927 else
11928 {
11929 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
11930 {
11931 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
11932 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
11933 {
11934 return gl::error(GL_INVALID_OPERATION);
11935 }
11936 }
11937 }
11938
11939 gl::Framebuffer *framebuffer = context->getDrawFramebuffer();
11940
11941 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
11942 {
11943 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
11944 }
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011945
11946 for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++)
11947 {
11948 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
11949 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011950 }
11951 }
11952 catch (std::bad_alloc&)
11953 {
11954 return gl::error(GL_OUT_OF_MEMORY);
11955 }
11956}
11957
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011958__eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname)
11959{
11960 struct Extension
11961 {
11962 const char *name;
11963 __eglMustCastToProperFunctionPointerType address;
11964 };
11965
11966 static const Extension glExtensions[] =
11967 {
11968 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +000011969 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +000011970 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000011971 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
11972 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
11973 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
11974 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
11975 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
11976 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
11977 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +000011978 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +000011979 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +000011980 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
11981 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
11982 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
11983 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000011984 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
11985 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
11986 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
11987 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
11988 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
11989 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
11990 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +000011991 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +000011992 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
11993 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
11994 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011995 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
11996 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011997
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +000011998 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011999 {
12000 if (strcmp(procname, glExtensions[ext].name) == 0)
12001 {
12002 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
12003 }
12004 }
12005
12006 return NULL;
12007}
12008
daniel@transgaming.com17f548c2011-11-09 17:47:02 +000012009// Non-public functions used by EGL
12010
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000012011bool __stdcall glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +000012012{
12013 EVENT("(egl::Surface* surface = 0x%0.8p)",
12014 surface);
12015
12016 try
12017 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +000012018 gl::Context *context = gl::getNonLostContext();
jbauman@chromium.orgae345802011-03-30 22:04:25 +000012019
12020 if (context)
12021 {
12022 gl::Texture2D *textureObject = context->getTexture2D();
12023
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000012024 if (textureObject->isImmutable())
12025 {
12026 return false;
12027 }
12028
jbauman@chromium.orgae345802011-03-30 22:04:25 +000012029 if (textureObject)
12030 {
12031 textureObject->bindTexImage(surface);
12032 }
12033 }
12034 }
12035 catch(std::bad_alloc&)
12036 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000012037 return gl::error(GL_OUT_OF_MEMORY, false);
jbauman@chromium.orgae345802011-03-30 22:04:25 +000012038 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000012039
12040 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +000012041}
12042
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000012043}