blob: d5b5e5bf00a55ac1670737691e0c4a5c1640968c [file] [log] [blame]
shannon.woods@transgaming.combdf2d802013-02-28 23:16:20 +00001#include "precompiled.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002//
shannon.woods%transgaming.com@gtempaccount.com8dce6512013-04-13 03:42:19 +00003// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004// Use of this source code is governed by a BSD-style license that can be
5// found in the LICENSE file.
6//
7
8// libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions.
9
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +000010#include "common/version.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000011
12#include "libGLESv2/main.h"
shannonwoods@chromium.orga2ecfcc2013-05-30 00:11:59 +000013#include "common/utilities.h"
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +000014#include "libGLESv2/formatutils.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000015#include "libGLESv2/Buffer.h"
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000016#include "libGLESv2/Fence.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000017#include "libGLESv2/Framebuffer.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000018#include "libGLESv2/Renderbuffer.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000019#include "libGLESv2/Program.h"
apatrick@chromium.orgea09f9b2012-06-08 00:45:32 +000020#include "libGLESv2/ProgramBinary.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000021#include "libGLESv2/Texture.h"
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000022#include "libGLESv2/Query.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000023#include "libGLESv2/Context.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000024
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +000025bool validImageSize(const gl::Context *context, GLint level, GLsizei width, GLsizei height, GLsizei depth)
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000026{
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +000027 if (level < 0 || width < 0 || height < 0 || depth < 0)
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000028 {
29 return false;
30 }
31
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +000032 if (context->supportsNonPower2Texture())
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000033 {
34 return true;
35 }
36
37 if (level == 0)
38 {
39 return true;
40 }
41
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +000042 if (gl::isPow2(width) && gl::isPow2(height) && gl::isPow2(depth))
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000043 {
44 return true;
45 }
46
47 return false;
48}
49
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +000050bool validCompressedImageSize(GLsizei width, GLsizei height)
51{
52 if (width != 1 && width != 2 && width % 4 != 0)
53 {
54 return false;
55 }
56
57 if (height != 1 && height != 2 && height % 4 != 0)
58 {
59 return false;
60 }
61
62 return true;
63}
64
daniel@transgaming.com8833dd22012-06-05 19:49:58 +000065// Verify that format/type are one of the combinations from table 3.4.
66bool checkTextureFormatType(GLenum format, GLenum type)
67{
68 // validate <format> by itself (used as secondary key below)
69 switch (format)
70 {
71 case GL_RGBA:
72 case GL_BGRA_EXT:
73 case GL_RGB:
74 case GL_ALPHA:
75 case GL_LUMINANCE:
76 case GL_LUMINANCE_ALPHA:
77 case GL_DEPTH_COMPONENT:
78 case GL_DEPTH_STENCIL_OES:
79 break;
80 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000081 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +000082 }
83
84 // invalid <type> -> sets INVALID_ENUM
85 // invalid <format>+<type> combination -> sets INVALID_OPERATION
86 switch (type)
87 {
88 case GL_UNSIGNED_BYTE:
89 switch (format)
90 {
91 case GL_RGBA:
92 case GL_BGRA_EXT:
93 case GL_RGB:
94 case GL_ALPHA:
95 case GL_LUMINANCE:
96 case GL_LUMINANCE_ALPHA:
97 return true;
98 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000099 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000100 }
101
102 case GL_FLOAT:
103 case GL_HALF_FLOAT_OES:
104 switch (format)
105 {
106 case GL_RGBA:
107 case GL_RGB:
108 case GL_ALPHA:
109 case GL_LUMINANCE:
110 case GL_LUMINANCE_ALPHA:
111 return true;
112 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000113 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000114 }
115
116 case GL_UNSIGNED_SHORT_4_4_4_4:
117 case GL_UNSIGNED_SHORT_5_5_5_1:
118 switch (format)
119 {
120 case GL_RGBA:
121 return true;
122 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000123 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000124 }
125
126 case GL_UNSIGNED_SHORT_5_6_5:
127 switch (format)
128 {
129 case GL_RGB:
130 return true;
131 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000132 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000133 }
134
135 case GL_UNSIGNED_SHORT:
136 case GL_UNSIGNED_INT:
137 switch (format)
138 {
139 case GL_DEPTH_COMPONENT:
140 return true;
141 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000142 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000143 }
144
145 case GL_UNSIGNED_INT_24_8_OES:
146 switch (format)
147 {
148 case GL_DEPTH_STENCIL_OES:
149 return true;
150 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000151 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000152 }
153
154 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000155 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000156 }
157}
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000158
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000159bool validateSubImageParams2D(bool compressed, GLsizei width, GLsizei height,
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000160 GLint xoffset, GLint yoffset, GLint level, GLenum format, GLenum type,
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000161 gl::Texture2D *texture)
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000162{
163 if (!texture)
164 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000165 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000166 }
167
daniel@transgaming.com92f49922012-05-09 15:49:19 +0000168 if (compressed != texture->isCompressed(level))
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000169 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000170 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000171 }
172
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000173 if (format != GL_NONE)
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000174 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000175 GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000176 if (internalformat != texture->getInternalFormat(level))
177 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000178 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000179 }
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000180 }
181
182 if (compressed)
183 {
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000184 if ((width % 4 != 0 && width != texture->getWidth(0)) ||
185 (height % 4 != 0 && height != texture->getHeight(0)))
186 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000187 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000188 }
189 }
190
191 if (xoffset + width > texture->getWidth(level) ||
192 yoffset + height > texture->getHeight(level))
193 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000194 return gl::error(GL_INVALID_VALUE, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000195 }
196
197 return true;
198}
199
200bool validateSubImageParamsCube(bool compressed, GLsizei width, GLsizei height,
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000201 GLint xoffset, GLint yoffset, GLenum target, GLint level, GLenum format, GLenum type,
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000202 gl::TextureCubeMap *texture)
203{
204 if (!texture)
205 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000206 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000207 }
208
daniel@transgaming.com4df88e82012-05-09 15:49:24 +0000209 if (compressed != texture->isCompressed(target, level))
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000210 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000211 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000212 }
213
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000214 if (format != GL_NONE)
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000215 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000216 GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000217 if (internalformat != texture->getInternalFormat(target, level))
218 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000219 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000220 }
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000221 }
222
223 if (compressed)
224 {
daniel@transgaming.com4df88e82012-05-09 15:49:24 +0000225 if ((width % 4 != 0 && width != texture->getWidth(target, 0)) ||
226 (height % 4 != 0 && height != texture->getHeight(target, 0)))
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000227 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000228 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000229 }
230 }
231
daniel@transgaming.com4df88e82012-05-09 15:49:24 +0000232 if (xoffset + width > texture->getWidth(target, level) ||
233 yoffset + height > texture->getHeight(target, level))
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000234 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000235 return gl::error(GL_INVALID_VALUE, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000236 }
237
238 return true;
239}
240
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000241bool validateES2TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage,
242 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
243 GLint border, GLenum format, GLenum type, const GLvoid *pixels)
244{
245 if (!validImageSize(context, level, width, height, 1))
246 {
247 return gl::error(GL_INVALID_VALUE, false);
248 }
249
250 if (isCompressed && !validCompressedImageSize(width, height))
251 {
252 return gl::error(GL_INVALID_OPERATION, false);
253 }
254
255 if (level < 0 || xoffset < 0 ||
256 std::numeric_limits<GLsizei>::max() - xoffset < width ||
257 std::numeric_limits<GLsizei>::max() - yoffset < height)
258 {
259 return gl::error(GL_INVALID_VALUE, false);
260 }
261
262 if (!isSubImage && !isCompressed && internalformat != GLint(format))
263 {
264 return gl::error(GL_INVALID_OPERATION, false);
265 }
266
267 gl::Texture *texture = NULL;
268 bool textureCompressed = false;
269 GLenum textureInternalFormat = GL_NONE;
270 GLint textureLevelWidth = 0;
271 GLint textureLevelHeight = 0;
272 switch (target)
273 {
274 case GL_TEXTURE_2D:
275 {
276 if (width > (context->getMaximum2DTextureDimension() >> level) ||
277 height > (context->getMaximum2DTextureDimension() >> level))
278 {
279 return gl::error(GL_INVALID_VALUE, false);
280 }
281
282 gl::Texture2D *tex2d = context->getTexture2D();
283 if (tex2d)
284 {
285 textureCompressed = tex2d->isCompressed(level);
286 textureInternalFormat = tex2d->getInternalFormat(level);
287 textureLevelWidth = tex2d->getWidth(level);
288 textureLevelHeight = tex2d->getHeight(level);
289 texture = tex2d;
290 }
291
292 if (isSubImage && !validateSubImageParams2D(isCompressed, width, height, xoffset, yoffset,
293 level, format, type, tex2d))
294 {
295 return false;
296 }
297
298 texture = tex2d;
299 }
300 break;
301
302 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
303 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
304 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
305 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
306 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
307 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
308 {
309 if (!isSubImage && width != height)
310 {
311 return gl::error(GL_INVALID_VALUE, false);
312 }
313
314 if (width > (context->getMaximumCubeTextureDimension() >> level) ||
315 height > (context->getMaximumCubeTextureDimension() >> level))
316 {
317 return gl::error(GL_INVALID_VALUE, false);
318 }
319
320 gl::TextureCubeMap *texCube = context->getTextureCubeMap();
321 if (texCube)
322 {
323 textureCompressed = texCube->isCompressed(target, level);
324 textureInternalFormat = texCube->getInternalFormat(target, level);
325 textureLevelWidth = texCube->getWidth(target, level);
326 textureLevelHeight = texCube->getHeight(target, level);
327 texture = texCube;
328 }
329
330 if (isSubImage && !validateSubImageParamsCube(isCompressed, width, height, xoffset, yoffset,
331 target, level, format, type, texCube))
332 {
333 return false;
334 }
335 }
336 break;
337
338 default:
339 return gl::error(GL_INVALID_ENUM, false);
340 }
341
342 if (!texture)
343 {
344 return gl::error(GL_INVALID_OPERATION, false);
345 }
346
347 if (!isSubImage && texture->isImmutable())
348 {
349 return gl::error(GL_INVALID_OPERATION, false);
350 }
351
352 // Verify zero border
353 if (border != 0)
354 {
355 return gl::error(GL_INVALID_VALUE, false);
356 }
357
358 // Verify texture is not requesting more mip levels than are available.
359 if (level > context->getMaximumTextureLevel())
360 {
361 return gl::error(GL_INVALID_VALUE, false);
362 }
363
364 GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat;
365 if (isCompressed)
366 {
367 switch (actualInternalFormat)
368 {
369 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
370 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
371 if (!context->supportsDXT1Textures())
372 {
373 return gl::error(GL_INVALID_ENUM, false);
374 }
375 break;
376 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
377 if (!context->supportsDXT3Textures())
378 {
379 return gl::error(GL_INVALID_ENUM, false);
380 }
381 break;
382 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
383 if (!context->supportsDXT5Textures())
384 {
385 return gl::error(GL_INVALID_ENUM, false);
386 }
387 break;
388 default:
389 return gl::error(GL_INVALID_ENUM, false);
390 }
391 }
392 else
393 {
394 // validate <type> by itself (used as secondary key below)
395 switch (type)
396 {
397 case GL_UNSIGNED_BYTE:
398 case GL_UNSIGNED_SHORT_5_6_5:
399 case GL_UNSIGNED_SHORT_4_4_4_4:
400 case GL_UNSIGNED_SHORT_5_5_5_1:
401 case GL_UNSIGNED_SHORT:
402 case GL_UNSIGNED_INT:
403 case GL_UNSIGNED_INT_24_8_OES:
404 case GL_HALF_FLOAT_OES:
405 case GL_FLOAT:
406 break;
407 default:
408 return gl::error(GL_INVALID_ENUM, false);
409 }
410
411 // validate <format> + <type> combinations
412 // - invalid <format> -> sets INVALID_ENUM
413 // - invalid <format>+<type> combination -> sets INVALID_OPERATION
414 switch (format)
415 {
416 case GL_ALPHA:
417 case GL_LUMINANCE:
418 case GL_LUMINANCE_ALPHA:
419 switch (type)
420 {
421 case GL_UNSIGNED_BYTE:
422 case GL_FLOAT:
423 case GL_HALF_FLOAT_OES:
424 break;
425 default:
426 return gl::error(GL_INVALID_OPERATION, false);
427 }
428 break;
429 case GL_RGB:
430 switch (type)
431 {
432 case GL_UNSIGNED_BYTE:
433 case GL_UNSIGNED_SHORT_5_6_5:
434 case GL_FLOAT:
435 case GL_HALF_FLOAT_OES:
436 break;
437 default:
438 return gl::error(GL_INVALID_OPERATION, false);
439 }
440 break;
441 case GL_RGBA:
442 switch (type)
443 {
444 case GL_UNSIGNED_BYTE:
445 case GL_UNSIGNED_SHORT_4_4_4_4:
446 case GL_UNSIGNED_SHORT_5_5_5_1:
447 case GL_FLOAT:
448 case GL_HALF_FLOAT_OES:
449 break;
450 default:
451 return gl::error(GL_INVALID_OPERATION, false);
452 }
453 break;
454 case GL_BGRA_EXT:
455 switch (type)
456 {
457 case GL_UNSIGNED_BYTE:
458 break;
459 default:
460 return gl::error(GL_INVALID_OPERATION, false);
461 }
462 break;
463 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below
464 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
465 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
466 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
467 break;
468 case GL_DEPTH_COMPONENT:
469 switch (type)
470 {
471 case GL_UNSIGNED_SHORT:
472 case GL_UNSIGNED_INT:
473 break;
474 default:
475 return gl::error(GL_INVALID_OPERATION, false);
476 }
477 break;
478 case GL_DEPTH_STENCIL_OES:
479 switch (type)
480 {
481 case GL_UNSIGNED_INT_24_8_OES:
482 break;
483 default:
484 return gl::error(GL_INVALID_OPERATION, false);
485 }
486 break;
487 default:
488 return gl::error(GL_INVALID_ENUM, false);
489 }
490
491 switch (format)
492 {
493 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
494 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
495 if (context->supportsDXT1Textures())
496 {
497 return gl::error(GL_INVALID_OPERATION, false);
498 }
499 else
500 {
501 return gl::error(GL_INVALID_ENUM, false);
502 }
503 break;
504 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
505 if (context->supportsDXT3Textures())
506 {
507 return gl::error(GL_INVALID_OPERATION, false);
508 }
509 else
510 {
511 return gl::error(GL_INVALID_ENUM, false);
512 }
513 break;
514 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
515 if (context->supportsDXT5Textures())
516 {
517 return gl::error(GL_INVALID_OPERATION, false);
518 }
519 else
520 {
521 return gl::error(GL_INVALID_ENUM, false);
522 }
523 break;
524 case GL_DEPTH_COMPONENT:
525 case GL_DEPTH_STENCIL_OES:
526 if (!context->supportsDepthTextures())
527 {
528 return gl::error(GL_INVALID_VALUE, false);
529 }
530 if (target != GL_TEXTURE_2D)
531 {
532 return gl::error(GL_INVALID_OPERATION, false);
533 }
534 // OES_depth_texture supports loading depth data and multiple levels,
535 // but ANGLE_depth_texture does not
536 if (pixels != NULL || level != 0)
537 {
538 return gl::error(GL_INVALID_OPERATION, false);
539 }
540 break;
541 default:
542 break;
543 }
544
545 if (type == GL_FLOAT)
546 {
547 if (!context->supportsFloat32Textures())
548 {
549 return gl::error(GL_INVALID_ENUM, false);
550 }
551 }
552 else if (type == GL_HALF_FLOAT_OES)
553 {
554 if (!context->supportsFloat16Textures())
555 {
556 return gl::error(GL_INVALID_ENUM, false);
557 }
558 }
559 }
560
561 return true;
562}
563
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +0000564bool validateES3TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage,
565 GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
566 GLint border, GLenum format, GLenum type)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000567{
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000568 // Validate image size
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000569 if (!validImageSize(context, level, width, height, depth))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000570 {
571 return gl::error(GL_INVALID_VALUE, false);
572 }
573
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000574 if (isCompressed && !validCompressedImageSize(width, height))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000575 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000576 return gl::error(GL_INVALID_OPERATION, false);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000577 }
578
579 // Verify zero border
580 if (border != 0)
581 {
582 return gl::error(GL_INVALID_VALUE, false);
583 }
584
585 // Validate dimensions based on Context limits and validate the texture
586 if (level > context->getMaximumTextureLevel())
587 {
588 return gl::error(GL_INVALID_VALUE, false);
589 }
590
591 gl::Texture *texture = NULL;
592 bool textureCompressed = false;
593 GLenum textureInternalFormat = GL_NONE;
594 GLint textureLevelWidth = 0;
595 GLint textureLevelHeight = 0;
596 GLint textureLevelDepth = 0;
597 switch (target)
598 {
599 case GL_TEXTURE_2D:
600 {
601 if (width > (context->getMaximum2DTextureDimension() >> level) ||
602 height > (context->getMaximum2DTextureDimension() >> level))
603 {
604 return gl::error(GL_INVALID_VALUE, false);
605 }
606
607 gl::Texture2D *texture2d = context->getTexture2D();
608 if (texture2d)
609 {
610 textureCompressed = texture2d->isCompressed(level);
611 textureInternalFormat = texture2d->getInternalFormat(level);
612 textureLevelWidth = texture2d->getWidth(level);
613 textureLevelHeight = texture2d->getHeight(level);
614 textureLevelDepth = 1;
615 texture = texture2d;
616 }
617 }
618 break;
619
620 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
621 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
622 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
623 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
624 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
625 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
626 {
shannonwoods@chromium.org92852cf2013-05-30 00:14:12 +0000627 if (!isSubImage && width != height)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000628 {
629 return gl::error(GL_INVALID_VALUE, false);
630 }
631
632 if (width > (context->getMaximumCubeTextureDimension() >> level))
633 {
634 return gl::error(GL_INVALID_VALUE, false);
635 }
636
637 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
638 if (textureCube)
639 {
640 textureCompressed = textureCube->isCompressed(target, level);
641 textureInternalFormat = textureCube->getInternalFormat(target, level);
642 textureLevelWidth = textureCube->getWidth(target, level);
643 textureLevelHeight = textureCube->getHeight(target, level);
644 textureLevelDepth = 1;
645 texture = textureCube;
646 }
647 }
648 break;
649
650 case GL_TEXTURE_3D:
651 {
652 if (width > (context->getMaximum3DTextureDimension() >> level) ||
653 height > (context->getMaximum3DTextureDimension() >> level) ||
654 depth > (context->getMaximum3DTextureDimension() >> level))
655 {
656 return gl::error(GL_INVALID_VALUE, false);
657 }
658
659 gl::Texture3D *texture3d = context->getTexture3D();
660 if (texture3d)
661 {
662 textureCompressed = texture3d->isCompressed(level);
663 textureInternalFormat = texture3d->getInternalFormat(level);
664 textureLevelWidth = texture3d->getWidth(level);
665 textureLevelHeight = texture3d->getHeight(level);
666 textureLevelDepth = texture3d->getDepth(level);
667 texture = texture3d;
668 }
669 }
670 break;
671
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +0000672 case GL_TEXTURE_2D_ARRAY:
673 {
674 if (width > (context->getMaximum2DTextureDimension() >> level) ||
675 height > (context->getMaximum2DTextureDimension() >> level) ||
676 depth > (context->getMaximum2DArrayTextureLayers() >> level))
677 {
678 return gl::error(GL_INVALID_VALUE, false);
679 }
680
681 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
682 if (texture2darray)
683 {
684 textureCompressed = texture2darray->isCompressed(level);
685 textureInternalFormat = texture2darray->getInternalFormat(level);
686 textureLevelWidth = texture2darray->getWidth(level);
687 textureLevelHeight = texture2darray->getHeight(level);
688 textureLevelDepth = texture2darray->getDepth(level);
689 texture = texture2darray;
690 }
691 }
692 break;
693
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000694 default:
695 return gl::error(GL_INVALID_ENUM, false);
696 }
697
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000698 if (!texture)
699 {
700 return gl::error(GL_INVALID_OPERATION, false);
701 }
702
shannonwoods@chromium.orgcf2533c2013-05-30 00:14:18 +0000703 if (texture->isImmutable() && !isSubImage)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000704 {
705 return gl::error(GL_INVALID_OPERATION, false);
706 }
707
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000708 // Validate texture formats
709 GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat;
710 if (isCompressed)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000711 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000712 if (!gl::IsFormatCompressed(actualInternalFormat, context->getClientVersion()))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000713 {
714 return gl::error(GL_INVALID_ENUM, false);
715 }
716
717 if (target == GL_TEXTURE_3D)
718 {
719 return gl::error(GL_INVALID_OPERATION, false);
720 }
721 }
722 else
723 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000724 if (!gl::IsValidInternalFormat(actualInternalFormat, context) ||
725 !gl::IsValidFormat(format, context->getClientVersion()) ||
726 !gl::IsValidType(type, context->getClientVersion()))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000727 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000728 return gl::error(GL_INVALID_ENUM, false);
729 }
730
731 if (!gl::IsValidFormatCombination(actualInternalFormat, format, type, context->getClientVersion()))
732 {
733 return gl::error(GL_INVALID_OPERATION, false);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000734 }
735
736 if ((target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) &&
737 (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL))
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000738 {
739 return gl::error(GL_INVALID_OPERATION, false);
740 }
741 }
742
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000743 // Validate sub image parameters
744 if (isSubImage)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000745 {
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000746 if (isCompressed != textureCompressed)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000747 {
748 return gl::error(GL_INVALID_OPERATION, false);
749 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000750
751 if (format != GL_NONE)
752 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000753 GLenum internalformat = gl::GetSizedInternalFormat(format, type, context->getClientVersion());
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000754 if (internalformat != textureInternalFormat)
755 {
756 return gl::error(GL_INVALID_OPERATION, false);
757 }
758 }
759
760 if (isCompressed)
761 {
762 if ((width % 4 != 0 && width != textureLevelWidth) ||
763 (height % 4 != 0 && height != textureLevelHeight))
764 {
765 return gl::error(GL_INVALID_OPERATION, false);
766 }
767 }
768
769 if (width == 0 || height == 0 || depth == 0)
770 {
771 return false;
772 }
773
774 if (xoffset < 0 || yoffset < 0 || zoffset < 0)
775 {
776 return gl::error(GL_INVALID_VALUE, false);
777 }
778
779 if (std::numeric_limits<GLsizei>::max() - xoffset < width ||
780 std::numeric_limits<GLsizei>::max() - yoffset < height ||
781 std::numeric_limits<GLsizei>::max() - zoffset < depth)
782 {
783 return gl::error(GL_INVALID_VALUE, false);
784 }
785
786 if (xoffset + width > textureLevelWidth ||
787 yoffset + height > textureLevelHeight ||
788 zoffset + depth > textureLevelDepth)
789 {
790 return gl::error(GL_INVALID_VALUE, false);
791 }
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000792 }
793
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000794 return true;
795}
796
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000797
798bool validateES2CopyTexImageParameters(gl::Context* context, GLenum target, GLint level, GLenum internalformat, bool isSubImage,
799 GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height,
800 GLint border)
801{
802 if (!gl::IsInternalTextureTarget(target))
803 {
804 return gl::error(GL_INVALID_ENUM, false);
805 }
806
807 if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0)
808 {
809 return gl::error(GL_INVALID_VALUE, false);
810 }
811
812 if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
813 {
814 return gl::error(GL_INVALID_VALUE, false);
815 }
816
817 if (width == 0 || height == 0)
818 {
819 return false;
820 }
821
822 // Verify zero border
823 if (border != 0)
824 {
825 return gl::error(GL_INVALID_VALUE, false);
826 }
827
828 // Validate dimensions based on Context limits and validate the texture
829 if (level > context->getMaximumTextureLevel())
830 {
831 return gl::error(GL_INVALID_VALUE, false);
832 }
833
834 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
835
836 if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
837 {
838 return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
839 }
840
841 if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0)
842 {
843 return gl::error(GL_INVALID_OPERATION, false);
844 }
845
846 GLenum colorbufferFormat = framebuffer->getReadColorbuffer()->getInternalFormat();
847 gl::Texture *texture = NULL;
848 GLenum textureFormat = GL_RGBA;
849
850 switch (target)
851 {
852 case GL_TEXTURE_2D:
853 {
854 if (width > (context->getMaximum2DTextureDimension() >> level) ||
855 height > (context->getMaximum2DTextureDimension() >> level))
856 {
857 return gl::error(GL_INVALID_VALUE, false);
858 }
859
860 gl::Texture2D *tex2d = context->getTexture2D();
861 if (tex2d)
862 {
863 if (isSubImage && !validateSubImageParams2D(false, width, height, xoffset, yoffset, level, GL_NONE, GL_NONE, tex2d))
864 {
865 return false; // error already registered by validateSubImageParams
866 }
867 texture = tex2d;
868 textureFormat = gl::GetFormat(tex2d->getInternalFormat(level), context->getClientVersion());
869 }
870 }
871 break;
872
873 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
874 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
875 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
876 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
877 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
878 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
879 {
880 if (!isSubImage && width != height)
881 {
882 return gl::error(GL_INVALID_VALUE, false);
883 }
884
885 if (width > (context->getMaximumCubeTextureDimension() >> level) ||
886 height > (context->getMaximumCubeTextureDimension() >> level))
887 {
888 return gl::error(GL_INVALID_VALUE, false);
889 }
890
891 gl::TextureCubeMap *texcube = context->getTextureCubeMap();
892 if (texcube)
893 {
894 if (isSubImage && !validateSubImageParamsCube(false, width, height, xoffset, yoffset, target, level, GL_NONE, GL_NONE, texcube))
895 {
896 return false; // error already registered by validateSubImageParams
897 }
898 texture = texcube;
899 textureFormat = gl::GetFormat(texcube->getInternalFormat(target, level), context->getClientVersion());
900 }
901 }
902 break;
903
904 default:
905 return gl::error(GL_INVALID_ENUM, false);
906 }
907
908 if (!texture)
909 {
910 return gl::error(GL_INVALID_OPERATION, false);
911 }
912
913 if (texture->isImmutable() && !isSubImage)
914 {
915 return gl::error(GL_INVALID_OPERATION, false);
916 }
917
918
919 // [OpenGL ES 2.0.24] table 3.9
920 if (isSubImage)
921 {
922 switch (textureFormat)
923 {
924 case GL_ALPHA:
925 if (colorbufferFormat != GL_ALPHA8_EXT &&
926 colorbufferFormat != GL_RGBA4 &&
927 colorbufferFormat != GL_RGB5_A1 &&
928 colorbufferFormat != GL_RGBA8_OES)
929 {
930 return gl::error(GL_INVALID_OPERATION, false);
931 }
932 break;
933 case GL_LUMINANCE:
934 case GL_RGB:
935 if (colorbufferFormat != GL_RGB565 &&
936 colorbufferFormat != GL_RGB8_OES &&
937 colorbufferFormat != GL_RGBA4 &&
938 colorbufferFormat != GL_RGB5_A1 &&
939 colorbufferFormat != GL_RGBA8_OES)
940 {
941 return gl::error(GL_INVALID_OPERATION, false);
942 }
943 break;
944 case GL_LUMINANCE_ALPHA:
945 case GL_RGBA:
946 if (colorbufferFormat != GL_RGBA4 &&
947 colorbufferFormat != GL_RGB5_A1 &&
948 colorbufferFormat != GL_RGBA8_OES)
949 {
950 return gl::error(GL_INVALID_OPERATION, false);
951 }
952 break;
953 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
954 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
955 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
956 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
957 return gl::error(GL_INVALID_OPERATION, false);
958 case GL_DEPTH_COMPONENT:
959 case GL_DEPTH_STENCIL_OES:
960 return gl::error(GL_INVALID_OPERATION, false);
961 default:
962 return gl::error(GL_INVALID_OPERATION, false);
963 }
964 }
965 else
966 {
967 switch (internalformat)
968 {
969 case GL_ALPHA:
970 if (colorbufferFormat != GL_ALPHA8_EXT &&
971 colorbufferFormat != GL_RGBA4 &&
972 colorbufferFormat != GL_RGB5_A1 &&
973 colorbufferFormat != GL_BGRA8_EXT &&
974 colorbufferFormat != GL_RGBA8_OES)
975 {
976 return gl::error(GL_INVALID_OPERATION, false);
977 }
978 break;
979 case GL_LUMINANCE:
980 case GL_RGB:
981 if (colorbufferFormat != GL_RGB565 &&
982 colorbufferFormat != GL_RGB8_OES &&
983 colorbufferFormat != GL_RGBA4 &&
984 colorbufferFormat != GL_RGB5_A1 &&
985 colorbufferFormat != GL_BGRA8_EXT &&
986 colorbufferFormat != GL_RGBA8_OES)
987 {
988 return gl::error(GL_INVALID_OPERATION, false);
989 }
990 break;
991 case GL_LUMINANCE_ALPHA:
992 case GL_RGBA:
993 if (colorbufferFormat != GL_RGBA4 &&
994 colorbufferFormat != GL_RGB5_A1 &&
995 colorbufferFormat != GL_BGRA8_EXT &&
996 colorbufferFormat != GL_RGBA8_OES)
997 {
998 return gl::error(GL_INVALID_OPERATION, false);
999 }
1000 break;
1001 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1002 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1003 if (context->supportsDXT1Textures())
1004 {
1005 return gl::error(GL_INVALID_OPERATION, false);
1006 }
1007 else
1008 {
1009 return gl::error(GL_INVALID_ENUM, false);
1010 }
1011 break;
1012 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
1013 if (context->supportsDXT3Textures())
1014 {
1015 return gl::error(GL_INVALID_OPERATION, false);
1016 }
1017 else
1018 {
1019 return gl::error(GL_INVALID_ENUM, false);
1020 }
1021 break;
1022 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
1023 if (context->supportsDXT5Textures())
1024 {
1025 return gl::error(GL_INVALID_OPERATION, false);
1026 }
1027 else
1028 {
1029 return gl::error(GL_INVALID_ENUM, false);
1030 }
1031 break;
1032 case GL_DEPTH_COMPONENT:
1033 case GL_DEPTH_COMPONENT16:
1034 case GL_DEPTH_COMPONENT32_OES:
1035 case GL_DEPTH_STENCIL_OES:
1036 case GL_DEPTH24_STENCIL8_OES:
1037 if (context->supportsDepthTextures())
1038 {
1039 return gl::error(GL_INVALID_OPERATION, false);
1040 }
1041 else
1042 {
1043 return gl::error(GL_INVALID_ENUM, false);
1044 }
1045 default:
1046 return gl::error(GL_INVALID_ENUM, false);
1047 }
1048 }
1049
1050 return true;
1051}
1052
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001053bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLint level, GLenum internalformat,
1054 bool isSubImage, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y,
1055 GLsizei width, GLsizei height, GLint border)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001056{
1057 if (level < 0 || xoffset < 0 || yoffset < 0 || zoffset < 0 || width < 0 || height < 0)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +00001058 {
1059 return gl::error(GL_INVALID_VALUE, false);
1060 }
1061
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001062 if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
1063 {
1064 return gl::error(GL_INVALID_VALUE, false);
1065 }
1066
1067 if (width == 0 || height == 0)
1068 {
1069 return false;
1070 }
1071
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001072 if (border != 0)
1073 {
1074 return gl::error(GL_INVALID_VALUE, false);
1075 }
1076
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001077 if (level > context->getMaximumTextureLevel())
1078 {
1079 return gl::error(GL_INVALID_VALUE, false);
1080 }
1081
1082 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
1083
1084 if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
1085 {
1086 return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
1087 }
1088
1089 if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0)
1090 {
1091 return gl::error(GL_INVALID_OPERATION, false);
1092 }
1093
1094 gl::Renderbuffer *source = framebuffer->getReadColorbuffer();
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001095 GLenum colorbufferInternalFormat = source->getInternalFormat();
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001096 gl::Texture *texture = NULL;
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001097 GLenum textureInternalFormat = GL_NONE;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001098 bool textureCompressed = false;
1099 GLint textureLevelWidth = 0;
1100 GLint textureLevelHeight = 0;
1101 GLint textureLevelDepth = 0;
1102 switch (target)
1103 {
1104 case GL_TEXTURE_2D:
1105 {
1106 gl::Texture2D *texture2d = context->getTexture2D();
1107 if (texture2d)
1108 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001109 textureInternalFormat = texture2d->getInternalFormat(level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001110 textureCompressed = texture2d->isCompressed(level);
1111 textureLevelWidth = texture2d->getWidth(level);
1112 textureLevelHeight = texture2d->getHeight(level);
1113 textureLevelDepth = 1;
1114 texture = texture2d;
1115 }
1116 }
1117 break;
1118
1119 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1120 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1121 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1122 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1123 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1124 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1125 {
1126 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
1127 if (textureCube)
1128 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001129 textureInternalFormat = textureCube->getInternalFormat(target, level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001130 textureCompressed = textureCube->isCompressed(target, level);
1131 textureLevelWidth = textureCube->getWidth(target, level);
1132 textureLevelHeight = textureCube->getHeight(target, level);
1133 textureLevelDepth = 1;
1134 texture = textureCube;
1135 }
1136 }
1137 break;
1138
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001139 case GL_TEXTURE_2D_ARRAY:
1140 {
1141 gl::Texture2DArray *texture2dArray = context->getTexture2DArray();
1142 if (texture2dArray)
1143 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001144 textureInternalFormat = texture2dArray->getInternalFormat(level);
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001145 textureCompressed = texture2dArray->isCompressed(level);
1146 textureLevelWidth = texture2dArray->getWidth(level);
1147 textureLevelHeight = texture2dArray->getHeight(level);
1148 textureLevelDepth = texture2dArray->getDepth(level);
1149 texture = texture2dArray;
1150 }
1151 }
1152 break;
1153
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001154 case GL_TEXTURE_3D:
1155 {
1156 gl::Texture3D *texture3d = context->getTexture3D();
1157 if (texture3d)
1158 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001159 textureInternalFormat = texture3d->getInternalFormat(level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001160 textureCompressed = texture3d->isCompressed(level);
1161 textureLevelWidth = texture3d->getWidth(level);
1162 textureLevelHeight = texture3d->getHeight(level);
1163 textureLevelDepth = texture3d->getDepth(level);
1164 texture = texture3d;
1165 }
1166 }
1167 break;
1168
1169 default:
1170 return gl::error(GL_INVALID_ENUM, false);
1171 }
1172
1173 if (!texture)
1174 {
1175 return gl::error(GL_INVALID_OPERATION, false);
1176 }
1177
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001178 if (texture->isImmutable() && !isSubImage)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001179 {
1180 return gl::error(GL_INVALID_OPERATION, false);
1181 }
1182
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001183 if (textureCompressed)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001184 {
1185 if ((width % 4 != 0 && width != textureLevelWidth) ||
1186 (height % 4 != 0 && height != textureLevelHeight))
1187 {
1188 return gl::error(GL_INVALID_OPERATION, false);
1189 }
1190 }
1191
Geoff Langa4d13322013-06-05 14:57:51 -04001192 if (isSubImage)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001193 {
Geoff Langa4d13322013-06-05 14:57:51 -04001194 if (xoffset + width > textureLevelWidth ||
1195 yoffset + height > textureLevelHeight ||
1196 zoffset >= textureLevelDepth)
1197 {
1198 return gl::error(GL_INVALID_VALUE, false);
1199 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001200
Geoff Langa4d13322013-06-05 14:57:51 -04001201 if (!gl::IsValidCopyTexImageCombination(textureInternalFormat, colorbufferInternalFormat,
1202 context->getClientVersion()))
1203 {
1204 return gl::error(GL_INVALID_OPERATION, false);
1205 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001206 }
1207
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +00001208 return true;
1209}
1210
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00001211bool validateES2TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat,
1212 GLsizei width, GLsizei height)
1213{
1214 if (target != GL_TEXTURE_2D && target != GL_TEXTURE_CUBE_MAP)
1215 {
1216 return gl::error(GL_INVALID_ENUM, false);
1217 }
1218
1219 if (width < 1 || height < 1 || levels < 1)
1220 {
1221 return gl::error(GL_INVALID_VALUE, false);
1222 }
1223
1224 if (target == GL_TEXTURE_CUBE_MAP && width != height)
1225 {
1226 return gl::error(GL_INVALID_VALUE, false);
1227 }
1228
1229 if (levels != 1 && levels != gl::log2(std::max(width, height)) + 1)
1230 {
1231 return gl::error(GL_INVALID_OPERATION, false);
1232 }
1233
1234 GLenum format = gl::GetFormat(internalformat, context->getClientVersion());
1235 GLenum type = gl::GetType(internalformat, context->getClientVersion());
1236
1237 if (format == GL_NONE || type == GL_NONE)
1238 {
1239 return gl::error(GL_INVALID_ENUM, false);
1240 }
1241
1242 switch (target)
1243 {
1244 case GL_TEXTURE_2D:
1245 if (width > context->getMaximum2DTextureDimension() ||
1246 height > context->getMaximum2DTextureDimension())
1247 {
1248 return gl::error(GL_INVALID_VALUE, false);
1249 }
1250 break;
1251 case GL_TEXTURE_CUBE_MAP:
1252 if (width > context->getMaximumCubeTextureDimension() ||
1253 height > context->getMaximumCubeTextureDimension())
1254 {
1255 return gl::error(GL_INVALID_VALUE, false);
1256 }
1257 break;
1258 default:
1259 return gl::error(GL_INVALID_ENUM, false);
1260 }
1261
1262 if (levels != 1 && !context->supportsNonPower2Texture())
1263 {
1264 if (!gl::isPow2(width) || !gl::isPow2(height))
1265 {
1266 return gl::error(GL_INVALID_OPERATION, false);
1267 }
1268 }
1269
1270 switch (internalformat)
1271 {
1272 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1273 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1274 if (!context->supportsDXT1Textures())
1275 {
1276 return gl::error(GL_INVALID_ENUM, false);
1277 }
1278 break;
1279 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
1280 if (!context->supportsDXT3Textures())
1281 {
1282 return gl::error(GL_INVALID_ENUM, false);
1283 }
1284 break;
1285 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
1286 if (!context->supportsDXT5Textures())
1287 {
1288 return gl::error(GL_INVALID_ENUM, false);
1289 }
1290 break;
1291 case GL_RGBA32F_EXT:
1292 case GL_RGB32F_EXT:
1293 case GL_ALPHA32F_EXT:
1294 case GL_LUMINANCE32F_EXT:
1295 case GL_LUMINANCE_ALPHA32F_EXT:
1296 if (!context->supportsFloat32Textures())
1297 {
1298 return gl::error(GL_INVALID_ENUM, false);
1299 }
1300 break;
1301 case GL_RGBA16F_EXT:
1302 case GL_RGB16F_EXT:
1303 case GL_ALPHA16F_EXT:
1304 case GL_LUMINANCE16F_EXT:
1305 case GL_LUMINANCE_ALPHA16F_EXT:
1306 if (!context->supportsFloat16Textures())
1307 {
1308 return gl::error(GL_INVALID_ENUM, false);
1309 }
1310 break;
1311 case GL_DEPTH_COMPONENT16:
1312 case GL_DEPTH_COMPONENT32_OES:
1313 case GL_DEPTH24_STENCIL8_OES:
1314 if (!context->supportsDepthTextures())
1315 {
1316 return gl::error(GL_INVALID_ENUM, false);
1317 }
1318 if (target != GL_TEXTURE_2D)
1319 {
1320 return gl::error(GL_INVALID_OPERATION, false);
1321 }
1322 // ANGLE_depth_texture only supports 1-level textures
1323 if (levels != 1)
1324 {
1325 return gl::error(GL_INVALID_OPERATION, false);
1326 }
1327 break;
1328 default:
1329 break;
1330 }
1331
1332 gl::Texture *texture = NULL;
1333 switch(target)
1334 {
1335 case GL_TEXTURE_2D:
1336 texture = context->getTexture2D();
1337 break;
1338 case GL_TEXTURE_CUBE_MAP:
1339 texture = context->getTextureCubeMap();
1340 break;
1341 default:
1342 UNREACHABLE();
1343 }
1344
1345 if (!texture || texture->id() == 0)
1346 {
1347 return gl::error(GL_INVALID_OPERATION, false);
1348 }
1349
1350 if (texture->isImmutable())
1351 {
1352 return gl::error(GL_INVALID_OPERATION, false);
1353 }
1354
1355 return true;
1356}
1357
1358bool validateES3TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat,
1359 GLsizei width, GLsizei height, GLsizei depth)
1360{
1361 if (width < 1 || height < 1 || depth < 1 || levels < 1)
1362 {
1363 return gl::error(GL_INVALID_VALUE, false);
1364 }
1365
1366 if (levels > gl::log2(std::max(std::max(width, height), depth)) + 1)
1367 {
1368 return gl::error(GL_INVALID_OPERATION, false);
1369 }
1370
1371 gl::Texture *texture = NULL;
1372 switch (target)
1373 {
1374 case GL_TEXTURE_2D:
1375 {
1376 texture = context->getTexture2D();
1377
1378 if (width > (context->getMaximum2DTextureDimension()) ||
1379 height > (context->getMaximum2DTextureDimension()))
1380 {
1381 return gl::error(GL_INVALID_VALUE, false);
1382 }
1383 }
1384 break;
1385
1386 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1387 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1388 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1389 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1390 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1391 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1392 {
1393 texture = context->getTextureCubeMap();
1394
1395 if (width != height)
1396 {
1397 return gl::error(GL_INVALID_VALUE, false);
1398 }
1399
1400 if (width > (context->getMaximumCubeTextureDimension()))
1401 {
1402 return gl::error(GL_INVALID_VALUE, false);
1403 }
1404 }
1405 break;
1406
1407 case GL_TEXTURE_3D:
1408 {
1409 texture = context->getTexture3D();
1410
1411 if (width > (context->getMaximum3DTextureDimension()) ||
1412 height > (context->getMaximum3DTextureDimension()) ||
1413 depth > (context->getMaximum3DTextureDimension()))
1414 {
1415 return gl::error(GL_INVALID_VALUE, false);
1416 }
1417 }
1418 break;
1419
1420 case GL_TEXTURE_2D_ARRAY:
1421 {
1422 texture = context->getTexture2DArray();
1423
1424 if (width > (context->getMaximum2DTextureDimension()) ||
1425 height > (context->getMaximum2DTextureDimension()) ||
1426 depth > (context->getMaximum2DArrayTextureLayers()))
1427 {
1428 return gl::error(GL_INVALID_VALUE, false);
1429 }
1430 }
1431 break;
1432
1433 default:
1434 return gl::error(GL_INVALID_ENUM, false);
1435 }
1436
1437 if (!texture || texture->id() == 0)
1438 {
1439 return gl::error(GL_INVALID_OPERATION, false);
1440 }
1441
1442 if (texture->isImmutable())
1443 {
1444 return gl::error(GL_INVALID_OPERATION, false);
1445 }
1446
1447 if (!gl::IsValidInternalFormat(internalformat, context))
1448 {
1449 return gl::error(GL_INVALID_ENUM, false);
1450 }
1451
1452 if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion()))
1453 {
1454 return gl::error(GL_INVALID_ENUM, false);
1455 }
1456
1457 return true;
1458}
1459
Geoff Lang2e1dcd52013-05-29 10:34:08 -04001460bool validateRenderbufferStorageParameters(const gl::Context *context, GLenum target, GLsizei samples,
1461 GLenum internalformat, GLsizei width, GLsizei height,
1462 bool angleExtension)
1463{
1464 switch (target)
1465 {
1466 case GL_RENDERBUFFER:
1467 break;
1468 default:
1469 return gl::error(GL_INVALID_ENUM, false);
1470 }
1471
1472 if (width < 0 || height < 0 || samples < 0)
1473 {
1474 return gl::error(GL_INVALID_VALUE, false);
1475 }
1476
1477 if (!gl::IsValidInternalFormat(internalformat, context))
1478 {
1479 return gl::error(GL_INVALID_ENUM, false);
1480 }
1481
1482 // ANGLE_framebuffer_multisample does not explicitly state that the internal format must be
1483 // sized but it does state that the format must be in the ES2.0 spec table 4.5 which contains
1484 // only sized internal formats. The ES3 spec (section 4.4.2) does, however, state that the
1485 // internal format must be sized and not an integer format if samples is greater than zero.
1486 if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion()))
1487 {
1488 return gl::error(GL_INVALID_ENUM, false);
1489 }
1490
1491 if (gl::IsIntegerFormat(internalformat, context->getClientVersion()) && samples > 0)
1492 {
1493 return gl::error(GL_INVALID_OPERATION, false);
1494 }
1495
1496 if (!gl::IsColorRenderingSupported(internalformat, context) &&
1497 !gl::IsDepthRenderingSupported(internalformat, context) &&
1498 !gl::IsStencilRenderingSupported(internalformat, context))
1499 {
1500 return gl::error(GL_INVALID_ENUM, false);
1501 }
1502
1503 if (std::max(width, height) > context->getMaximumRenderbufferDimension())
1504 {
1505 return gl::error(GL_INVALID_VALUE, false);
1506 }
1507
1508 // ANGLE_framebuffer_multisample states that the value of samples must be less than or equal
1509 // to MAX_SAMPLES_ANGLE (Context::getMaxSupportedSamples) while the ES3.0 spec (section 4.4.2)
1510 // states that samples must be less than or equal to the maximum samples for the specified
1511 // internal format.
1512 if (angleExtension)
1513 {
1514 if (samples > context->getMaxSupportedSamples())
1515 {
1516 return gl::error(GL_INVALID_VALUE, false);
1517 }
1518 }
1519 else
1520 {
1521 if (samples > context->getMaxSupportedFormatSamples(internalformat))
1522 {
1523 return gl::error(GL_INVALID_VALUE, false);
1524 }
1525 }
1526
1527 GLuint handle = context->getRenderbufferHandle();
1528 if (handle == 0)
1529 {
1530 return gl::error(GL_INVALID_OPERATION, false);
1531 }
1532
1533 return true;
1534}
1535
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00001536// check for combinations of format and type that are valid for ReadPixels
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00001537bool validES2ReadFormatType(GLenum format, GLenum type)
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00001538{
1539 switch (format)
1540 {
1541 case GL_RGBA:
1542 switch (type)
1543 {
1544 case GL_UNSIGNED_BYTE:
1545 break;
1546 default:
1547 return false;
1548 }
1549 break;
1550 case GL_BGRA_EXT:
1551 switch (type)
1552 {
1553 case GL_UNSIGNED_BYTE:
1554 case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
1555 case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
1556 break;
1557 default:
1558 return false;
1559 }
1560 break;
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00001561 default:
1562 return false;
1563 }
1564 return true;
1565}
1566
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00001567bool validES3ReadFormatType(GLenum internalFormat, GLenum format, GLenum type)
1568{
1569 switch (format)
1570 {
1571 case GL_RGBA:
1572 switch (type)
1573 {
1574 case GL_UNSIGNED_BYTE:
1575 break;
1576 case GL_UNSIGNED_INT_2_10_10_10_REV:
1577 if (internalFormat != GL_RGB10_A2)
1578 {
1579 return false;
1580 }
1581 break;
1582 default:
1583 return false;
1584 }
1585 break;
1586 case GL_RGBA_INTEGER:
1587 switch (type)
1588 {
1589 case GL_INT:
Geoff Langd384a942013-06-05 15:00:10 -04001590 if (!gl::IsSignedIntegerFormat(internalFormat, 3))
1591 {
1592 return false;
1593 }
1594 break;
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00001595 case GL_UNSIGNED_INT:
Geoff Langd384a942013-06-05 15:00:10 -04001596 if (!gl::IsUnsignedIntegerFormat(internalFormat, 3))
1597 {
1598 return false;
1599 }
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00001600 break;
1601 default:
1602 return false;
1603 }
1604 break;
1605 case GL_BGRA_EXT:
1606 switch (type)
1607 {
1608 case GL_UNSIGNED_BYTE:
1609 case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
1610 case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
1611 break;
1612 default:
1613 return false;
1614 }
1615 break;
1616 default:
1617 return false;
1618 }
1619 return true;
1620}
1621
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00001622bool validateInvalidateFramebufferParameters(gl::Context *context, GLenum target, GLsizei numAttachments,
1623 const GLenum* attachments)
1624{
1625 bool defaultFramebuffer = false;
1626
1627 switch (target)
1628 {
1629 case GL_DRAW_FRAMEBUFFER:
1630 case GL_FRAMEBUFFER:
1631 defaultFramebuffer = context->getDrawFramebufferHandle() == 0;
1632 break;
1633 case GL_READ_FRAMEBUFFER:
1634 defaultFramebuffer = context->getReadFramebufferHandle() == 0;
1635 break;
1636 default:
1637 return gl::error(GL_INVALID_ENUM, false);
1638 }
1639
1640 for (int i = 0; i < numAttachments; ++i)
1641 {
1642 if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15)
1643 {
1644 if (defaultFramebuffer)
1645 {
1646 return gl::error(GL_INVALID_ENUM, false);
1647 }
1648
1649 if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getMaximumRenderTargets())
1650 {
1651 return gl::error(GL_INVALID_OPERATION, false);
1652 }
1653 }
1654 else
1655 {
1656 switch (attachments[i])
1657 {
1658 case GL_DEPTH_ATTACHMENT:
1659 case GL_STENCIL_ATTACHMENT:
1660 case GL_DEPTH_STENCIL_ATTACHMENT:
1661 if (defaultFramebuffer)
1662 {
1663 return gl::error(GL_INVALID_ENUM, false);
1664 }
1665 break;
1666 case GL_COLOR:
1667 case GL_DEPTH:
1668 case GL_STENCIL:
1669 if (!defaultFramebuffer)
1670 {
1671 return gl::error(GL_INVALID_ENUM, false);
1672 }
1673 break;
1674 default:
1675 return gl::error(GL_INVALID_ENUM, false);
1676 }
1677 }
1678 }
1679
1680 return true;
1681}
1682
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001683extern "C"
1684{
1685
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00001686// OpenGL ES 2.0 functions
1687
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001688void __stdcall glActiveTexture(GLenum texture)
1689{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001690 EVENT("(GLenum texture = 0x%X)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001691
1692 try
1693 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001694 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001695
1696 if (context)
1697 {
daniel@transgaming.com3f74c7a2011-05-11 15:36:51 +00001698 if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1)
1699 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001700 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3f74c7a2011-05-11 15:36:51 +00001701 }
1702
daniel@transgaming.com428d1582010-05-04 03:35:25 +00001703 context->setActiveSampler(texture - GL_TEXTURE0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001704 }
1705 }
1706 catch(std::bad_alloc&)
1707 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001708 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001709 }
1710}
1711
1712void __stdcall glAttachShader(GLuint program, GLuint shader)
1713{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001714 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001715
1716 try
1717 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001718 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001719
1720 if (context)
1721 {
1722 gl::Program *programObject = context->getProgram(program);
1723 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00001724
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001725 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001726 {
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001727 if (context->getShader(program))
1728 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001729 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001730 }
1731 else
1732 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001733 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001734 }
1735 }
1736
1737 if (!shaderObject)
1738 {
1739 if (context->getProgram(shader))
1740 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001741 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001742 }
1743 else
1744 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001745 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001746 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001747 }
1748
1749 if (!programObject->attachShader(shaderObject))
1750 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001751 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001752 }
1753 }
1754 }
1755 catch(std::bad_alloc&)
1756 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001757 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001758 }
1759}
1760
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001761void __stdcall glBeginQueryEXT(GLenum target, GLuint id)
1762{
1763 EVENT("(GLenum target = 0x%X, GLuint %d)", target, id);
1764
1765 try
1766 {
1767 switch (target)
1768 {
1769 case GL_ANY_SAMPLES_PASSED_EXT:
1770 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
1771 break;
1772 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001773 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001774 }
1775
1776 if (id == 0)
1777 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001778 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001779 }
1780
1781 gl::Context *context = gl::getNonLostContext();
1782
1783 if (context)
1784 {
1785 context->beginQuery(target, id);
1786 }
1787 }
1788 catch(std::bad_alloc&)
1789 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001790 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001791 }
1792}
1793
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001794void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001795{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001796 EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001797
1798 try
1799 {
1800 if (index >= gl::MAX_VERTEX_ATTRIBS)
1801 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001802 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001803 }
1804
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001805 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001806
1807 if (context)
1808 {
1809 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00001810
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001811 if (!programObject)
1812 {
daniel@transgaming.com98079832010-04-13 03:26:29 +00001813 if (context->getShader(program))
1814 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001815 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com98079832010-04-13 03:26:29 +00001816 }
1817 else
1818 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001819 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com98079832010-04-13 03:26:29 +00001820 }
1821 }
1822
1823 if (strncmp(name, "gl_", 3) == 0)
1824 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001825 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001826 }
1827
1828 programObject->bindAttributeLocation(index, name);
1829 }
1830 }
1831 catch(std::bad_alloc&)
1832 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001833 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001834 }
1835}
1836
1837void __stdcall glBindBuffer(GLenum target, GLuint buffer)
1838{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001839 EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001840
1841 try
1842 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001843 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001844
1845 if (context)
1846 {
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00001847 // Check ES3 specific targets
1848 switch (target)
1849 {
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00001850 case GL_COPY_READ_BUFFER:
1851 case GL_COPY_WRITE_BUFFER:
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00001852 case GL_PIXEL_PACK_BUFFER:
1853 case GL_PIXEL_UNPACK_BUFFER:
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00001854 case GL_UNIFORM_BUFFER:
1855 case GL_TRANSFORM_FEEDBACK_BUFFER:
1856 if (context->getClientVersion() < 3)
1857 {
1858 return gl::error(GL_INVALID_ENUM);
1859 }
1860 }
1861
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001862 switch (target)
1863 {
1864 case GL_ARRAY_BUFFER:
1865 context->bindArrayBuffer(buffer);
1866 return;
1867 case GL_ELEMENT_ARRAY_BUFFER:
1868 context->bindElementArrayBuffer(buffer);
1869 return;
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00001870 case GL_COPY_READ_BUFFER:
1871 context->bindCopyReadBuffer(buffer);
1872 return;
1873 case GL_COPY_WRITE_BUFFER:
1874 context->bindCopyWriteBuffer(buffer);
1875 return;
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00001876 case GL_PIXEL_PACK_BUFFER:
1877 context->bindPixelPackBuffer(buffer);
1878 return;
1879 case GL_PIXEL_UNPACK_BUFFER:
1880 context->bindPixelUnpackBuffer(buffer);
1881 return;
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00001882 case GL_UNIFORM_BUFFER:
1883 context->bindGenericUniformBuffer(buffer);
1884 return;
1885 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.org7a1ebad2013-05-30 00:05:20 +00001886 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00001887 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001888 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001889 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001890 }
1891 }
1892 }
1893 catch(std::bad_alloc&)
1894 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001895 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001896 }
1897}
1898
1899void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer)
1900{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001901 EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001902
1903 try
1904 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00001905 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001906 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001907 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001908 }
1909
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001910 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001911
1912 if (context)
1913 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00001914 if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
1915 {
1916 context->bindReadFramebuffer(framebuffer);
1917 }
1918
1919 if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
1920 {
1921 context->bindDrawFramebuffer(framebuffer);
1922 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001923 }
1924 }
1925 catch(std::bad_alloc&)
1926 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001927 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001928 }
1929}
1930
1931void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer)
1932{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001933 EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001934
1935 try
1936 {
1937 if (target != GL_RENDERBUFFER)
1938 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001939 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001940 }
1941
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001942 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001943
1944 if (context)
1945 {
1946 context->bindRenderbuffer(renderbuffer);
1947 }
1948 }
1949 catch(std::bad_alloc&)
1950 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001951 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001952 }
1953}
1954
1955void __stdcall glBindTexture(GLenum target, GLuint texture)
1956{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001957 EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001958
1959 try
1960 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001961 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001962
1963 if (context)
1964 {
1965 gl::Texture *textureObject = context->getTexture(texture);
1966
1967 if (textureObject && textureObject->getTarget() != target && texture != 0)
1968 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001969 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001970 }
1971
1972 switch (target)
1973 {
1974 case GL_TEXTURE_2D:
1975 context->bindTexture2D(texture);
1976 return;
1977 case GL_TEXTURE_CUBE_MAP:
1978 context->bindTextureCubeMap(texture);
1979 return;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00001980 case GL_TEXTURE_3D:
1981 if (context->getClientVersion() < 3)
1982 {
1983 return gl::error(GL_INVALID_ENUM);
1984 }
1985 context->bindTexture3D(texture);
1986 return;
shannon.woods%transgaming.com@gtempaccount.com90dbc442013-04-13 03:46:14 +00001987 case GL_TEXTURE_2D_ARRAY:
1988 if (context->getClientVersion() < 3)
1989 {
1990 return gl::error(GL_INVALID_ENUM);
1991 }
1992 context->bindTexture2DArray(texture);
1993 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001994 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001995 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001996 }
1997 }
1998 }
1999 catch(std::bad_alloc&)
2000 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002001 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002002 }
2003}
2004
2005void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
2006{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002007 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002008 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002009
2010 try
2011 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002012 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002013
2014 if (context)
2015 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002016 context->setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002017 }
2018 }
2019 catch(std::bad_alloc&)
2020 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002021 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002022 }
2023}
2024
2025void __stdcall glBlendEquation(GLenum mode)
2026{
2027 glBlendEquationSeparate(mode, mode);
2028}
2029
2030void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
2031{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002032 EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002033
2034 try
2035 {
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +00002036 gl::Context *context = gl::getNonLostContext();
2037
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002038 switch (modeRGB)
2039 {
2040 case GL_FUNC_ADD:
2041 case GL_FUNC_SUBTRACT:
2042 case GL_FUNC_REVERSE_SUBTRACT:
2043 break;
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +00002044
2045 case GL_MIN:
2046 case GL_MAX:
2047 if (context && context->getClientVersion() < 3)
2048 {
2049 return gl::error(GL_INVALID_ENUM);
2050 }
2051 break;
2052
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002053 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002054 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002055 }
2056
2057 switch (modeAlpha)
2058 {
2059 case GL_FUNC_ADD:
2060 case GL_FUNC_SUBTRACT:
2061 case GL_FUNC_REVERSE_SUBTRACT:
2062 break;
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +00002063
2064 case GL_MIN:
2065 case GL_MAX:
2066 if (context && context->getClientVersion() < 3)
2067 {
2068 return gl::error(GL_INVALID_ENUM);
2069 }
2070 break;
2071
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002072 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002073 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002074 }
2075
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002076 if (context)
2077 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002078 context->setBlendEquation(modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002079 }
2080 }
2081 catch(std::bad_alloc&)
2082 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002083 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002084 }
2085}
2086
2087void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor)
2088{
2089 glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
2090}
2091
2092void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
2093{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002094 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 +00002095 srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002096
2097 try
2098 {
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +00002099 gl::Context *context = gl::getNonLostContext();
2100
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002101 switch (srcRGB)
2102 {
2103 case GL_ZERO:
2104 case GL_ONE:
2105 case GL_SRC_COLOR:
2106 case GL_ONE_MINUS_SRC_COLOR:
2107 case GL_DST_COLOR:
2108 case GL_ONE_MINUS_DST_COLOR:
2109 case GL_SRC_ALPHA:
2110 case GL_ONE_MINUS_SRC_ALPHA:
2111 case GL_DST_ALPHA:
2112 case GL_ONE_MINUS_DST_ALPHA:
2113 case GL_CONSTANT_COLOR:
2114 case GL_ONE_MINUS_CONSTANT_COLOR:
2115 case GL_CONSTANT_ALPHA:
2116 case GL_ONE_MINUS_CONSTANT_ALPHA:
2117 case GL_SRC_ALPHA_SATURATE:
2118 break;
2119 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002120 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002121 }
2122
2123 switch (dstRGB)
2124 {
2125 case GL_ZERO:
2126 case GL_ONE:
2127 case GL_SRC_COLOR:
2128 case GL_ONE_MINUS_SRC_COLOR:
2129 case GL_DST_COLOR:
2130 case GL_ONE_MINUS_DST_COLOR:
2131 case GL_SRC_ALPHA:
2132 case GL_ONE_MINUS_SRC_ALPHA:
2133 case GL_DST_ALPHA:
2134 case GL_ONE_MINUS_DST_ALPHA:
2135 case GL_CONSTANT_COLOR:
2136 case GL_ONE_MINUS_CONSTANT_COLOR:
2137 case GL_CONSTANT_ALPHA:
2138 case GL_ONE_MINUS_CONSTANT_ALPHA:
2139 break;
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +00002140
2141 case GL_SRC_ALPHA_SATURATE:
2142 if (!context || context->getClientVersion() < 3)
2143 {
2144 return gl::error(GL_INVALID_ENUM);
2145 }
2146 break;
2147
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002148 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002149 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002150 }
2151
2152 switch (srcAlpha)
2153 {
2154 case GL_ZERO:
2155 case GL_ONE:
2156 case GL_SRC_COLOR:
2157 case GL_ONE_MINUS_SRC_COLOR:
2158 case GL_DST_COLOR:
2159 case GL_ONE_MINUS_DST_COLOR:
2160 case GL_SRC_ALPHA:
2161 case GL_ONE_MINUS_SRC_ALPHA:
2162 case GL_DST_ALPHA:
2163 case GL_ONE_MINUS_DST_ALPHA:
2164 case GL_CONSTANT_COLOR:
2165 case GL_ONE_MINUS_CONSTANT_COLOR:
2166 case GL_CONSTANT_ALPHA:
2167 case GL_ONE_MINUS_CONSTANT_ALPHA:
2168 case GL_SRC_ALPHA_SATURATE:
2169 break;
2170 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002171 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002172 }
2173
2174 switch (dstAlpha)
2175 {
2176 case GL_ZERO:
2177 case GL_ONE:
2178 case GL_SRC_COLOR:
2179 case GL_ONE_MINUS_SRC_COLOR:
2180 case GL_DST_COLOR:
2181 case GL_ONE_MINUS_DST_COLOR:
2182 case GL_SRC_ALPHA:
2183 case GL_ONE_MINUS_SRC_ALPHA:
2184 case GL_DST_ALPHA:
2185 case GL_ONE_MINUS_DST_ALPHA:
2186 case GL_CONSTANT_COLOR:
2187 case GL_ONE_MINUS_CONSTANT_COLOR:
2188 case GL_CONSTANT_ALPHA:
2189 case GL_ONE_MINUS_CONSTANT_ALPHA:
2190 break;
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +00002191
2192 case GL_SRC_ALPHA_SATURATE:
2193 if (!context || context->getClientVersion() < 3)
2194 {
2195 return gl::error(GL_INVALID_ENUM);
2196 }
2197 break;
2198
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002199 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002200 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002201 }
2202
daniel@transgaming.comfe453652010-03-16 06:23:28 +00002203 bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
2204 dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
2205
2206 bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
2207 dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
2208
2209 if (constantColorUsed && constantAlphaUsed)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002210 {
daniel@transgaming.comfe453652010-03-16 06:23:28 +00002211 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 +00002212 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002213 }
2214
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002215 if (context)
2216 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002217 context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002218 }
2219 }
2220 catch(std::bad_alloc&)
2221 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002222 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002223 }
2224}
2225
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002226void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002227{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002228 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 +00002229 target, size, data, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002230
2231 try
2232 {
2233 if (size < 0)
2234 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002235 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002236 }
2237
shannon.woods%transgaming.com@gtempaccount.comf2db40b2013-04-13 03:37:09 +00002238 gl::Context *context = gl::getNonLostContext();
2239
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002240 switch (usage)
2241 {
2242 case GL_STREAM_DRAW:
2243 case GL_STATIC_DRAW:
2244 case GL_DYNAMIC_DRAW:
2245 break;
shannon.woods%transgaming.com@gtempaccount.comf2db40b2013-04-13 03:37:09 +00002246
2247 case GL_STREAM_READ:
2248 case GL_STREAM_COPY:
2249 case GL_STATIC_READ:
2250 case GL_STATIC_COPY:
2251 case GL_DYNAMIC_READ:
2252 case GL_DYNAMIC_COPY:
2253 if (context && context->getClientVersion() < 3)
2254 {
2255 return gl::error(GL_INVALID_ENUM);
2256 }
2257 break;
2258
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002259 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002260 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002261 }
2262
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002263 if (context)
2264 {
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002265 // Check ES3 specific targets
2266 switch (target)
2267 {
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002268 case GL_COPY_READ_BUFFER:
2269 case GL_COPY_WRITE_BUFFER:
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002270 case GL_PIXEL_PACK_BUFFER:
2271 case GL_PIXEL_UNPACK_BUFFER:
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002272 case GL_UNIFORM_BUFFER:
2273 case GL_TRANSFORM_FEEDBACK_BUFFER:
2274 if (context->getClientVersion() < 3)
2275 {
2276 return gl::error(GL_INVALID_ENUM);
2277 }
2278 }
2279
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002280 gl::Buffer *buffer;
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00002281
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002282 switch (target)
2283 {
2284 case GL_ARRAY_BUFFER:
2285 buffer = context->getArrayBuffer();
2286 break;
2287 case GL_ELEMENT_ARRAY_BUFFER:
2288 buffer = context->getElementArrayBuffer();
2289 break;
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002290 case GL_COPY_READ_BUFFER:
2291 buffer = context->getCopyReadBuffer();
2292 break;
2293 case GL_COPY_WRITE_BUFFER:
2294 buffer = context->getCopyWriteBuffer();
2295 break;
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002296 case GL_PIXEL_PACK_BUFFER:
2297 buffer = context->getPixelPackBuffer();
2298 break;
2299 case GL_PIXEL_UNPACK_BUFFER:
2300 buffer = context->getPixelUnpackBuffer();
2301 break;
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002302 case GL_TRANSFORM_FEEDBACK_BUFFER:
2303 buffer = context->getGenericTransformFeedbackBuffer();
2304 break;
2305 case GL_UNIFORM_BUFFER:
2306 buffer = context->getGenericUniformBuffer();
2307 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002308 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002309 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002310 }
2311
2312 if (!buffer)
2313 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002314 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002315 }
2316
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002317 buffer->bufferData(data, size, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002318 }
2319 }
2320 catch(std::bad_alloc&)
2321 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002322 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002323 }
2324}
2325
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002326void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002327{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002328 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 +00002329 target, offset, size, data);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002330
2331 try
2332 {
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +00002333 if (size < 0 || offset < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002334 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002335 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002336 }
2337
daniel@transgaming.comd4620a32010-03-21 04:31:28 +00002338 if (data == NULL)
2339 {
2340 return;
2341 }
2342
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002343 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002344
2345 if (context)
2346 {
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002347 // Check ES3 specific targets
2348 switch (target)
2349 {
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002350 case GL_COPY_READ_BUFFER:
2351 case GL_COPY_WRITE_BUFFER:
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002352 case GL_PIXEL_PACK_BUFFER:
2353 case GL_PIXEL_UNPACK_BUFFER:
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002354 case GL_UNIFORM_BUFFER:
2355 case GL_TRANSFORM_FEEDBACK_BUFFER:
2356 if (context->getClientVersion() < 3)
2357 {
2358 return gl::error(GL_INVALID_ENUM);
2359 }
2360 }
2361
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002362 gl::Buffer *buffer;
2363
2364 switch (target)
2365 {
2366 case GL_ARRAY_BUFFER:
2367 buffer = context->getArrayBuffer();
2368 break;
2369 case GL_ELEMENT_ARRAY_BUFFER:
2370 buffer = context->getElementArrayBuffer();
2371 break;
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002372 case GL_COPY_READ_BUFFER:
2373 buffer = context->getCopyReadBuffer();
2374 break;
2375 case GL_COPY_WRITE_BUFFER:
2376 buffer = context->getCopyWriteBuffer();
2377 break;
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002378 case GL_PIXEL_PACK_BUFFER:
2379 buffer = context->getPixelPackBuffer();
2380 break;
2381 case GL_PIXEL_UNPACK_BUFFER:
2382 buffer = context->getPixelUnpackBuffer();
2383 break;
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002384 case GL_TRANSFORM_FEEDBACK_BUFFER:
2385 buffer = context->getGenericTransformFeedbackBuffer();
2386 break;
2387 case GL_UNIFORM_BUFFER:
2388 buffer = context->getGenericUniformBuffer();
2389 break;
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002390 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002391 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002392 }
2393
2394 if (!buffer)
2395 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002396 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002397 }
2398
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +00002399 if ((size_t)size + offset > buffer->size())
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002400 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002401 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002402 }
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +00002403
2404 buffer->bufferSubData(data, size, offset);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002405 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002406 }
2407 catch(std::bad_alloc&)
2408 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002409 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002410 }
2411}
2412
2413GLenum __stdcall glCheckFramebufferStatus(GLenum target)
2414{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002415 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002416
2417 try
2418 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002419 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002420 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002421 return gl::error(GL_INVALID_ENUM, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002422 }
2423
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002424 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002425
2426 if (context)
2427 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002428 gl::Framebuffer *framebuffer = NULL;
2429 if (target == GL_READ_FRAMEBUFFER_ANGLE)
2430 {
2431 framebuffer = context->getReadFramebuffer();
2432 }
2433 else
2434 {
2435 framebuffer = context->getDrawFramebuffer();
2436 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002437
2438 return framebuffer->completeness();
2439 }
2440 }
2441 catch(std::bad_alloc&)
2442 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002443 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002444 }
2445
2446 return 0;
2447}
2448
2449void __stdcall glClear(GLbitfield mask)
2450{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00002451 EVENT("(GLbitfield mask = 0x%X)", mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002452
2453 try
2454 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002455 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002456
2457 if (context)
2458 {
2459 context->clear(mask);
2460 }
2461 }
2462 catch(std::bad_alloc&)
2463 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002464 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002465 }
2466}
2467
2468void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
2469{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002470 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002471 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002472
2473 try
2474 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002475 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002476
2477 if (context)
2478 {
2479 context->setClearColor(red, green, blue, alpha);
2480 }
2481 }
2482 catch(std::bad_alloc&)
2483 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002484 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002485 }
2486}
2487
2488void __stdcall glClearDepthf(GLclampf depth)
2489{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002490 EVENT("(GLclampf depth = %f)", depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002491
2492 try
2493 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002494 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002495
2496 if (context)
2497 {
2498 context->setClearDepth(depth);
2499 }
2500 }
2501 catch(std::bad_alloc&)
2502 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002503 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002504 }
2505}
2506
2507void __stdcall glClearStencil(GLint s)
2508{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002509 EVENT("(GLint s = %d)", s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002510
2511 try
2512 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002513 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002514
2515 if (context)
2516 {
2517 context->setClearStencil(s);
2518 }
2519 }
2520 catch(std::bad_alloc&)
2521 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002522 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002523 }
2524}
2525
2526void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
2527{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00002528 EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002529 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002530
2531 try
2532 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002533 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002534
2535 if (context)
2536 {
daniel@transgaming.coma36f98e2010-05-18 18:51:09 +00002537 context->setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002538 }
2539 }
2540 catch(std::bad_alloc&)
2541 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002542 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002543 }
2544}
2545
2546void __stdcall glCompileShader(GLuint shader)
2547{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002548 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002549
2550 try
2551 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002552 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002553
2554 if (context)
2555 {
2556 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00002557
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002558 if (!shaderObject)
2559 {
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +00002560 if (context->getProgram(shader))
2561 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002562 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +00002563 }
2564 else
2565 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002566 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +00002567 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002568 }
2569
2570 shaderObject->compile();
2571 }
2572 }
2573 catch(std::bad_alloc&)
2574 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002575 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002576 }
2577}
2578
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002579void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
2580 GLint border, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002581{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002582 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002583 "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002584 target, level, internalformat, width, height, border, imageSize, data);
2585
2586 try
2587 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002588 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com01868132010-08-24 19:21:17 +00002589
2590 if (context)
2591 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002592 if (context->getClientVersion() < 3 &&
2593 !validateES2TexImageParameters(context, target, level, internalformat, true, false,
2594 0, 0, width, height, 0, GL_NONE, GL_NONE, data))
2595 {
2596 return;
2597 }
2598
2599 if (context->getClientVersion() >= 3 &&
2600 !validateES3TexImageParameters(context, target, level, internalformat, true, false,
2601 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE))
2602 {
2603 return;
2604 }
2605
2606 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002607 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002608 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002609 }
2610
2611 switch (target)
2612 {
2613 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002614 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002615 gl::Texture2D *texture = context->getTexture2D();
2616 texture->setCompressedImage(level, internalformat, width, height, imageSize, data);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002617 }
2618 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002619
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002620 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2621 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2622 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2623 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2624 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2625 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002626 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002627 gl::TextureCubeMap *texture = context->getTextureCubeMap();
2628 texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002629 }
2630 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002631
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002632 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002633 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002634 }
daniel@transgaming.com01868132010-08-24 19:21:17 +00002635 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002636 }
2637 catch(std::bad_alloc&)
2638 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002639 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002640 }
2641}
2642
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002643void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
2644 GLenum format, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002645{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002646 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002647 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002648 "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002649 target, level, xoffset, yoffset, width, height, format, imageSize, data);
2650
2651 try
2652 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002653 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com01868132010-08-24 19:21:17 +00002654
2655 if (context)
2656 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002657 if (context->getClientVersion() < 3 &&
2658 !validateES2TexImageParameters(context, target, level, GL_NONE, true, true,
2659 xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
2660 {
2661 return;
2662 }
2663
2664 if (context->getClientVersion() >= 3 &&
2665 !validateES3TexImageParameters(context, target, level, GL_NONE, true, true,
2666 xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE))
2667 {
2668 return;
2669 }
2670
2671 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002672 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002673 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002674 }
2675
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002676 switch (target)
daniel@transgaming.com01868132010-08-24 19:21:17 +00002677 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002678 case GL_TEXTURE_2D:
daniel@transgaming.com01868132010-08-24 19:21:17 +00002679 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002680 gl::Texture2D *texture = context->getTexture2D();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00002681 texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
daniel@transgaming.com01868132010-08-24 19:21:17 +00002682 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002683 break;
2684
2685 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2686 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2687 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2688 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2689 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2690 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com01868132010-08-24 19:21:17 +00002691 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002692 gl::TextureCubeMap *texture = context->getTextureCubeMap();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00002693 texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
daniel@transgaming.com01868132010-08-24 19:21:17 +00002694 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002695 break;
2696
2697 default:
2698 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com01868132010-08-24 19:21:17 +00002699 }
2700 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002701 }
2702 catch(std::bad_alloc&)
2703 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002704 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002705 }
2706}
2707
2708void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
2709{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002710 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002711 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002712 target, level, internalformat, x, y, width, height, border);
2713
2714 try
2715 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002716 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002717
2718 if (context)
2719 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002720 if (context->getClientVersion() < 3 &&
2721 !validateES2CopyTexImageParameters(context, target, level, internalformat, false,
2722 0, 0, x, y, width, height, border))
daniel@transgaming.com32b11442011-11-19 02:42:48 +00002723 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002724 return;
daniel@transgaming.com32b11442011-11-19 02:42:48 +00002725 }
2726
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002727 if (context->getClientVersion() >= 3 &&
2728 !validateES3CopyTexImageParameters(context, target, level, internalformat, false,
2729 0, 0, 0, x, y, width, height, border))
2730 {
2731 return;
2732 }
2733
2734 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
2735
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002736 switch (target)
2737 {
2738 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002739 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002740 gl::Texture2D *texture = context->getTexture2D();
2741 texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002742 }
2743 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002744
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002745 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2746 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2747 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2748 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2749 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2750 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002751 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002752 gl::TextureCubeMap *texture = context->getTextureCubeMap();
2753 texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002754 }
2755 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002756
2757 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002758 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002759 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002760 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002761 }
2762 catch(std::bad_alloc&)
2763 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002764 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002765 }
2766}
2767
2768void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
2769{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002770 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002771 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002772 target, level, xoffset, yoffset, x, y, width, height);
2773
2774 try
2775 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002776 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002777
2778 if (context)
2779 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002780 if (context->getClientVersion() < 3 &&
2781 !validateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
2782 xoffset, yoffset, x, y, width, height, 0))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002783 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002784 return;
2785 }
2786
2787 if (context->getClientVersion() >= 3 &&
2788 !validateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
2789 xoffset, yoffset, 0, x, y, width, height, 0))
2790 {
2791 return;
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002792 }
2793
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002794 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00002795
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002796 switch (target)
daniel@transgaming.combbc57792010-07-28 19:21:05 +00002797 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002798 case GL_TEXTURE_2D:
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +00002799 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002800 gl::Texture2D *texture = context->getTexture2D();
2801 texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00002802 }
2803 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002804
2805 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2806 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2807 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2808 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2809 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2810 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com6452adf2012-10-17 18:22:35 +00002811 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002812 gl::TextureCubeMap *texture = context->getTextureCubeMap();
2813 texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +00002814 }
2815 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002816
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00002817 default:
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002818 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00002819 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002820 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002821 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002822
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002823 catch(std::bad_alloc&)
2824 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002825 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002826 }
2827}
2828
2829GLuint __stdcall glCreateProgram(void)
2830{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002831 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002832
2833 try
2834 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002835 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002836
2837 if (context)
2838 {
2839 return context->createProgram();
2840 }
2841 }
2842 catch(std::bad_alloc&)
2843 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002844 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002845 }
2846
2847 return 0;
2848}
2849
2850GLuint __stdcall glCreateShader(GLenum type)
2851{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002852 EVENT("(GLenum type = 0x%X)", type);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002853
2854 try
2855 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002856 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002857
2858 if (context)
2859 {
2860 switch (type)
2861 {
2862 case GL_FRAGMENT_SHADER:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00002863 case GL_VERTEX_SHADER:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002864 return context->createShader(type);
2865 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002866 return gl::error(GL_INVALID_ENUM, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002867 }
2868 }
2869 }
2870 catch(std::bad_alloc&)
2871 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002872 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002873 }
2874
2875 return 0;
2876}
2877
2878void __stdcall glCullFace(GLenum mode)
2879{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002880 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002881
2882 try
2883 {
2884 switch (mode)
2885 {
2886 case GL_FRONT:
2887 case GL_BACK:
2888 case GL_FRONT_AND_BACK:
2889 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002890 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002891
2892 if (context)
2893 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002894 context->setCullMode(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002895 }
2896 }
2897 break;
2898 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002899 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002900 }
2901 }
2902 catch(std::bad_alloc&)
2903 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002904 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002905 }
2906}
2907
2908void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers)
2909{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002910 EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002911
2912 try
2913 {
2914 if (n < 0)
2915 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002916 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002917 }
2918
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002919 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002920
2921 if (context)
2922 {
2923 for (int i = 0; i < n; i++)
2924 {
2925 context->deleteBuffer(buffers[i]);
2926 }
2927 }
2928 }
2929 catch(std::bad_alloc&)
2930 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002931 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002932 }
2933}
2934
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002935void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences)
2936{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002937 EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002938
2939 try
2940 {
2941 if (n < 0)
2942 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002943 return gl::error(GL_INVALID_VALUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002944 }
2945
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002946 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002947
2948 if (context)
2949 {
2950 for (int i = 0; i < n; i++)
2951 {
2952 context->deleteFence(fences[i]);
2953 }
2954 }
2955 }
2956 catch(std::bad_alloc&)
2957 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002958 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002959 }
2960}
2961
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002962void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
2963{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002964 EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002965
2966 try
2967 {
2968 if (n < 0)
2969 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002970 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002971 }
2972
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002973 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002974
2975 if (context)
2976 {
2977 for (int i = 0; i < n; i++)
2978 {
2979 if (framebuffers[i] != 0)
2980 {
2981 context->deleteFramebuffer(framebuffers[i]);
2982 }
2983 }
2984 }
2985 }
2986 catch(std::bad_alloc&)
2987 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002988 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002989 }
2990}
2991
2992void __stdcall glDeleteProgram(GLuint program)
2993{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002994 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002995
2996 try
2997 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00002998 if (program == 0)
2999 {
3000 return;
3001 }
3002
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003003 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003004
3005 if (context)
3006 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003007 if (!context->getProgram(program))
3008 {
3009 if(context->getShader(program))
3010 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003011 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003012 }
3013 else
3014 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003015 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003016 }
3017 }
3018
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003019 context->deleteProgram(program);
3020 }
3021 }
3022 catch(std::bad_alloc&)
3023 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003024 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003025 }
3026}
3027
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003028void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
3029{
3030 EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
3031
3032 try
3033 {
3034 if (n < 0)
3035 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003036 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003037 }
3038
3039 gl::Context *context = gl::getNonLostContext();
3040
3041 if (context)
3042 {
3043 for (int i = 0; i < n; i++)
3044 {
3045 context->deleteQuery(ids[i]);
3046 }
3047 }
3048 }
3049 catch(std::bad_alloc&)
3050 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003051 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003052 }
3053}
3054
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003055void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
3056{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003057 EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003058
3059 try
3060 {
3061 if (n < 0)
3062 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003063 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003064 }
3065
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003066 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003067
3068 if (context)
3069 {
daniel@transgaming.come2b22122010-03-11 19:22:14 +00003070 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003071 {
3072 context->deleteRenderbuffer(renderbuffers[i]);
3073 }
3074 }
3075 }
3076 catch(std::bad_alloc&)
3077 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003078 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003079 }
3080}
3081
3082void __stdcall glDeleteShader(GLuint shader)
3083{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003084 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003085
3086 try
3087 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003088 if (shader == 0)
3089 {
3090 return;
3091 }
3092
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003093 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003094
3095 if (context)
3096 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003097 if (!context->getShader(shader))
3098 {
3099 if(context->getProgram(shader))
3100 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003101 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003102 }
3103 else
3104 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003105 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003106 }
3107 }
3108
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003109 context->deleteShader(shader);
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);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003115 }
3116}
3117
3118void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures)
3119{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003120 EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003121
3122 try
3123 {
3124 if (n < 0)
3125 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003126 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003127 }
3128
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003129 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003130
3131 if (context)
3132 {
3133 for (int i = 0; i < n; i++)
3134 {
3135 if (textures[i] != 0)
3136 {
3137 context->deleteTexture(textures[i]);
3138 }
3139 }
3140 }
3141 }
3142 catch(std::bad_alloc&)
3143 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003144 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003145 }
3146}
3147
3148void __stdcall glDepthFunc(GLenum func)
3149{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003150 EVENT("(GLenum func = 0x%X)", func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003151
3152 try
3153 {
3154 switch (func)
3155 {
3156 case GL_NEVER:
3157 case GL_ALWAYS:
3158 case GL_LESS:
3159 case GL_LEQUAL:
3160 case GL_EQUAL:
3161 case GL_GREATER:
3162 case GL_GEQUAL:
3163 case GL_NOTEQUAL:
3164 break;
3165 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003166 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003167 }
3168
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003169 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003170
3171 if (context)
3172 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003173 context->setDepthFunc(func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003174 }
3175 }
3176 catch(std::bad_alloc&)
3177 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003178 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003179 }
3180}
3181
3182void __stdcall glDepthMask(GLboolean flag)
3183{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00003184 EVENT("(GLboolean flag = %u)", flag);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003185
3186 try
3187 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003188 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003189
3190 if (context)
3191 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003192 context->setDepthMask(flag != GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003193 }
3194 }
3195 catch(std::bad_alloc&)
3196 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003197 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003198 }
3199}
3200
3201void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar)
3202{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003203 EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003204
3205 try
3206 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003207 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003208
3209 if (context)
3210 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003211 context->setDepthRange(zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003212 }
3213 }
3214 catch(std::bad_alloc&)
3215 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003216 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003217 }
3218}
3219
3220void __stdcall glDetachShader(GLuint program, GLuint shader)
3221{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003222 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003223
3224 try
3225 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003226 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003227
3228 if (context)
3229 {
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003230
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003231 gl::Program *programObject = context->getProgram(program);
3232 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003233
3234 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003235 {
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003236 gl::Shader *shaderByProgramHandle;
3237 shaderByProgramHandle = context->getShader(program);
3238 if (!shaderByProgramHandle)
3239 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003240 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003241 }
3242 else
3243 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003244 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003245 }
3246 }
3247
3248 if (!shaderObject)
3249 {
3250 gl::Program *programByShaderHandle = context->getProgram(shader);
3251 if (!programByShaderHandle)
3252 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003253 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003254 }
3255 else
3256 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003257 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003258 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003259 }
3260
3261 if (!programObject->detachShader(shaderObject))
3262 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003263 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003264 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003265 }
3266 }
3267 catch(std::bad_alloc&)
3268 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003269 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003270 }
3271}
3272
3273void __stdcall glDisable(GLenum cap)
3274{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003275 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003276
3277 try
3278 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003279 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003280
3281 if (context)
3282 {
3283 switch (cap)
3284 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003285 case GL_CULL_FACE: context->setCullFace(false); break;
3286 case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break;
3287 case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break;
3288 case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break;
3289 case GL_SCISSOR_TEST: context->setScissorTest(false); break;
3290 case GL_STENCIL_TEST: context->setStencilTest(false); break;
3291 case GL_DEPTH_TEST: context->setDepthTest(false); break;
3292 case GL_BLEND: context->setBlend(false); break;
3293 case GL_DITHER: context->setDither(false); break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00003294
3295 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
3296 case GL_RASTERIZER_DISCARD:
3297 if (context->getClientVersion() < 3)
3298 {
3299 return gl::error(GL_INVALID_ENUM);
3300 }
3301 UNIMPLEMENTED();
3302 break;
3303
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003304 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003305 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003306 }
3307 }
3308 }
3309 catch(std::bad_alloc&)
3310 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003311 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003312 }
3313}
3314
3315void __stdcall glDisableVertexAttribArray(GLuint index)
3316{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003317 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003318
3319 try
3320 {
3321 if (index >= gl::MAX_VERTEX_ATTRIBS)
3322 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003323 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003324 }
3325
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003326 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003327
3328 if (context)
3329 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00003330 context->setEnableVertexAttribArray(index, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003331 }
3332 }
3333 catch(std::bad_alloc&)
3334 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003335 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003336 }
3337}
3338
3339void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count)
3340{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003341 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003342
3343 try
3344 {
3345 if (count < 0 || first < 0)
3346 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003347 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003348 }
3349
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003350 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003351
3352 if (context)
3353 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003354 context->drawArrays(mode, first, count, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003355 }
3356 }
3357 catch(std::bad_alloc&)
3358 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003359 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003360 }
3361}
3362
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003363void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
3364{
3365 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
3366
3367 try
3368 {
3369 if (count < 0 || first < 0 || primcount < 0)
3370 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003371 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003372 }
3373
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003374 if (primcount > 0)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003375 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003376 gl::Context *context = gl::getNonLostContext();
3377
3378 if (context)
3379 {
3380 context->drawArrays(mode, first, count, primcount);
3381 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003382 }
3383 }
3384 catch(std::bad_alloc&)
3385 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003386 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003387 }
3388}
3389
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003390void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003391{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003392 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 +00003393 mode, count, type, indices);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003394
3395 try
3396 {
3397 if (count < 0)
3398 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003399 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003400 }
3401
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003402 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003403
3404 if (context)
3405 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00003406 switch (type)
3407 {
3408 case GL_UNSIGNED_BYTE:
3409 case GL_UNSIGNED_SHORT:
3410 break;
3411 case GL_UNSIGNED_INT:
3412 if (!context->supports32bitIndices())
3413 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003414 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com83921382011-01-08 05:46:00 +00003415 }
3416 break;
3417 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003418 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com83921382011-01-08 05:46:00 +00003419 }
3420
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003421 context->drawElements(mode, count, type, indices, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003422 }
3423 }
3424 catch(std::bad_alloc&)
3425 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003426 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003427 }
3428}
3429
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003430void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
3431{
3432 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
3433 mode, count, type, indices, primcount);
3434
3435 try
3436 {
3437 if (count < 0 || primcount < 0)
3438 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003439 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003440 }
3441
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003442 if (primcount > 0)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003443 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003444 gl::Context *context = gl::getNonLostContext();
3445
3446 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003447 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003448 switch (type)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003449 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003450 case GL_UNSIGNED_BYTE:
3451 case GL_UNSIGNED_SHORT:
3452 break;
3453 case GL_UNSIGNED_INT:
3454 if (!context->supports32bitIndices())
3455 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003456 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003457 }
3458 break;
3459 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003460 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003461 }
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003462
3463 context->drawElements(mode, count, type, indices, primcount);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003464 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003465 }
3466 }
3467 catch(std::bad_alloc&)
3468 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003469 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003470 }
3471}
3472
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003473void __stdcall glEnable(GLenum cap)
3474{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003475 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003476
3477 try
3478 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003479 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003480
3481 if (context)
3482 {
3483 switch (cap)
3484 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003485 case GL_CULL_FACE: context->setCullFace(true); break;
3486 case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break;
3487 case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break;
3488 case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break;
3489 case GL_SCISSOR_TEST: context->setScissorTest(true); break;
3490 case GL_STENCIL_TEST: context->setStencilTest(true); break;
3491 case GL_DEPTH_TEST: context->setDepthTest(true); break;
3492 case GL_BLEND: context->setBlend(true); break;
3493 case GL_DITHER: context->setDither(true); break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003494 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003495 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003496 }
3497 }
3498 }
3499 catch(std::bad_alloc&)
3500 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003501 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003502 }
3503}
3504
3505void __stdcall glEnableVertexAttribArray(GLuint index)
3506{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003507 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003508
3509 try
3510 {
3511 if (index >= gl::MAX_VERTEX_ATTRIBS)
3512 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003513 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003514 }
3515
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003516 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003517
3518 if (context)
3519 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00003520 context->setEnableVertexAttribArray(index, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003521 }
3522 }
3523 catch(std::bad_alloc&)
3524 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003525 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003526 }
3527}
3528
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003529void __stdcall glEndQueryEXT(GLenum target)
3530{
3531 EVENT("GLenum target = 0x%X)", target);
3532
3533 try
3534 {
3535 switch (target)
3536 {
3537 case GL_ANY_SAMPLES_PASSED_EXT:
3538 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
3539 break;
3540 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003541 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003542 }
3543
3544 gl::Context *context = gl::getNonLostContext();
3545
3546 if (context)
3547 {
3548 context->endQuery(target);
3549 }
3550 }
3551 catch(std::bad_alloc&)
3552 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003553 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003554 }
3555}
3556
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003557void __stdcall glFinishFenceNV(GLuint fence)
3558{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003559 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003560
3561 try
3562 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003563 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003564
3565 if (context)
3566 {
3567 gl::Fence* fenceObject = context->getFence(fence);
3568
3569 if (fenceObject == NULL)
3570 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003571 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003572 }
3573
3574 fenceObject->finishFence();
3575 }
3576 }
3577 catch(std::bad_alloc&)
3578 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003579 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003580 }
3581}
3582
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003583void __stdcall glFinish(void)
3584{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003585 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003586
3587 try
3588 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003589 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003590
3591 if (context)
3592 {
daniel@transgaming.com0d86aa72011-10-26 02:35:10 +00003593 context->sync(true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003594 }
3595 }
3596 catch(std::bad_alloc&)
3597 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003598 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003599 }
3600}
3601
3602void __stdcall glFlush(void)
3603{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003604 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003605
3606 try
3607 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003608 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003609
3610 if (context)
3611 {
daniel@transgaming.com0d86aa72011-10-26 02:35:10 +00003612 context->sync(false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003613 }
3614 }
3615 catch(std::bad_alloc&)
3616 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003617 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003618 }
3619}
3620
3621void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
3622{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003623 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003624 "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003625
3626 try
3627 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003628 if ((target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com2fa45512011-10-04 18:43:18 +00003629 || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003630 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003631 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003632 }
3633
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003634 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003635
3636 if (context)
3637 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003638 gl::Framebuffer *framebuffer = NULL;
3639 GLuint framebufferHandle = 0;
3640 if (target == GL_READ_FRAMEBUFFER_ANGLE)
3641 {
3642 framebuffer = context->getReadFramebuffer();
3643 framebufferHandle = context->getReadFramebufferHandle();
3644 }
daniel@transgaming.com2fa45512011-10-04 18:43:18 +00003645 else
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003646 {
3647 framebuffer = context->getDrawFramebuffer();
3648 framebufferHandle = context->getDrawFramebufferHandle();
3649 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003650
daniel@transgaming.com2fa45512011-10-04 18:43:18 +00003651 if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003652 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003653 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003654 }
3655
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003656 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003657 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003658 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
3659
3660 if (colorAttachment >= context->getMaximumRenderTargets())
3661 {
3662 return gl::error(GL_INVALID_VALUE);
3663 }
3664
3665 framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer);
3666 }
3667 else
3668 {
3669 switch (attachment)
3670 {
3671 case GL_DEPTH_ATTACHMENT:
3672 framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer);
3673 break;
3674 case GL_STENCIL_ATTACHMENT:
3675 framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer);
3676 break;
3677 default:
3678 return gl::error(GL_INVALID_ENUM);
3679 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003680 }
3681 }
3682 }
3683 catch(std::bad_alloc&)
3684 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003685 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003686 }
3687}
3688
3689void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
3690{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003691 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003692 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003693
3694 try
3695 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003696 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003697 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003698 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003699 }
3700
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003701 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003702
3703 if (context)
3704 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003705 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
3706 {
3707 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
3708
3709 if (colorAttachment >= context->getMaximumRenderTargets())
3710 {
3711 return gl::error(GL_INVALID_VALUE);
3712 }
3713 }
3714 else
3715 {
3716 switch (attachment)
3717 {
3718 case GL_DEPTH_ATTACHMENT:
3719 case GL_STENCIL_ATTACHMENT:
3720 break;
3721 default:
3722 return gl::error(GL_INVALID_ENUM);
3723 }
3724 }
3725
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003726 if (texture == 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003727 {
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003728 textarget = GL_NONE;
3729 }
3730 else
3731 {
3732 gl::Texture *tex = context->getTexture(texture);
3733
3734 if (tex == NULL)
3735 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003736 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003737 }
3738
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003739 switch (textarget)
3740 {
3741 case GL_TEXTURE_2D:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003742 {
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003743 if (tex->getTarget() != GL_TEXTURE_2D)
3744 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003745 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003746 }
3747 gl::Texture2D *tex2d = static_cast<gl::Texture2D *>(tex);
daniel@transgaming.com92f49922012-05-09 15:49:19 +00003748 if (tex2d->isCompressed(0))
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003749 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003750 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003751 }
3752 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003753 }
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003754
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003755 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003756 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003757 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003758 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003759 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003760 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003761 {
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003762 if (tex->getTarget() != GL_TEXTURE_CUBE_MAP)
3763 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003764 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003765 }
3766 gl::TextureCubeMap *texcube = static_cast<gl::TextureCubeMap *>(tex);
daniel@transgaming.com4df88e82012-05-09 15:49:24 +00003767 if (texcube->isCompressed(textarget, level))
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003768 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003769 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003770 }
3771 break;
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003772 }
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003773
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003774 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003775 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003776 }
3777
3778 if (level != 0)
3779 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003780 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003781 }
3782 }
3783
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003784 gl::Framebuffer *framebuffer = NULL;
3785 GLuint framebufferHandle = 0;
3786 if (target == GL_READ_FRAMEBUFFER_ANGLE)
3787 {
3788 framebuffer = context->getReadFramebuffer();
3789 framebufferHandle = context->getReadFramebufferHandle();
3790 }
3791 else
3792 {
3793 framebuffer = context->getDrawFramebuffer();
3794 framebufferHandle = context->getDrawFramebufferHandle();
3795 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003796
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003797 if (framebufferHandle == 0 || !framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003798 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003799 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003800 }
3801
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003802 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00003803 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003804 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
3805
3806 if (colorAttachment >= context->getMaximumRenderTargets())
3807 {
3808 return gl::error(GL_INVALID_VALUE);
3809 }
3810
3811 framebuffer->setColorbuffer(colorAttachment, textarget, texture);
3812 }
3813 else
3814 {
3815 switch (attachment)
3816 {
3817 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break;
3818 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break;
3819 }
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00003820 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003821 }
3822 }
3823 catch(std::bad_alloc&)
3824 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003825 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003826 }
3827}
3828
3829void __stdcall glFrontFace(GLenum mode)
3830{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003831 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003832
3833 try
3834 {
3835 switch (mode)
3836 {
3837 case GL_CW:
3838 case GL_CCW:
3839 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003840 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003841
3842 if (context)
3843 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003844 context->setFrontFace(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003845 }
3846 }
3847 break;
3848 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003849 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003850 }
3851 }
3852 catch(std::bad_alloc&)
3853 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003854 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003855 }
3856}
3857
3858void __stdcall glGenBuffers(GLsizei n, GLuint* buffers)
3859{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003860 EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003861
3862 try
3863 {
3864 if (n < 0)
3865 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003866 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003867 }
3868
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003869 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003870
3871 if (context)
3872 {
3873 for (int i = 0; i < n; i++)
3874 {
3875 buffers[i] = context->createBuffer();
3876 }
3877 }
3878 }
3879 catch(std::bad_alloc&)
3880 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003881 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003882 }
3883}
3884
3885void __stdcall glGenerateMipmap(GLenum target)
3886{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003887 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003888
3889 try
3890 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003891 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003892
3893 if (context)
3894 {
Geoff Langae4852a2013-06-05 15:00:34 -04003895 gl::Texture *texture = NULL;
3896 GLint internalFormat = GL_NONE;
3897 bool isCompressed = false;
3898 bool isDepth = false;
3899
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003900 switch (target)
3901 {
3902 case GL_TEXTURE_2D:
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003903 {
3904 gl::Texture2D *tex2d = context->getTexture2D();
Geoff Langae4852a2013-06-05 15:00:34 -04003905 if (tex2d)
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003906 {
Geoff Langae4852a2013-06-05 15:00:34 -04003907 internalFormat = tex2d->getInternalFormat(0);
3908 isCompressed = tex2d->isCompressed(0);
3909 isDepth = tex2d->isDepth(0);
3910 texture = tex2d;
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003911 }
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003912 break;
3913 }
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003914
3915 case GL_TEXTURE_CUBE_MAP:
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003916 {
3917 gl::TextureCubeMap *texcube = context->getTextureCubeMap();
Geoff Langae4852a2013-06-05 15:00:34 -04003918 if (texcube)
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003919 {
Geoff Langae4852a2013-06-05 15:00:34 -04003920 internalFormat = texcube->getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0);
3921 isCompressed = texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0);
3922 isDepth = false;
3923 texture = texcube;
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003924 }
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003925 break;
3926 }
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003927
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00003928 case GL_TEXTURE_3D:
3929 {
3930 if (context->getClientVersion() < 3)
3931 {
3932 return gl::error(GL_INVALID_ENUM);
3933 }
3934
3935 gl::Texture3D *tex3D = context->getTexture3D();
Geoff Langae4852a2013-06-05 15:00:34 -04003936 if (tex3D)
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00003937 {
Geoff Langae4852a2013-06-05 15:00:34 -04003938 internalFormat = tex3D->getInternalFormat(0);
3939 isCompressed = tex3D->isCompressed(0);
3940 isDepth = tex3D->isDepth(0);
3941 texture = tex3D;
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00003942 }
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00003943 break;
3944 }
3945
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00003946 case GL_TEXTURE_2D_ARRAY:
3947 {
3948 if (context->getClientVersion() < 3)
3949 {
3950 return gl::error(GL_INVALID_ENUM);
3951 }
3952
3953 gl::Texture2DArray *tex2darr = context->getTexture2DArray();
Geoff Langae4852a2013-06-05 15:00:34 -04003954 if (tex2darr)
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00003955 {
Geoff Langae4852a2013-06-05 15:00:34 -04003956 internalFormat = tex2darr->getInternalFormat(0);
3957 isCompressed = tex2darr->isCompressed(0);
3958 isDepth = tex2darr->isDepth(0);
3959 texture = tex2darr;
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00003960 }
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00003961 break;
3962 }
3963
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003964 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003965 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003966 }
Geoff Langae4852a2013-06-05 15:00:34 -04003967
3968 if (!texture)
3969 {
3970 return gl::error(GL_INVALID_OPERATION);
3971 }
3972
3973 // Internally, all texture formats are sized so checking if the format
3974 // is color renderable and filterable will not fail.
3975 if (isDepth || isCompressed ||
3976 !gl::IsColorRenderingSupported(internalFormat, context) ||
3977 !gl::IsTextureFilteringSupported(internalFormat, context))
3978 {
3979 return gl::error(GL_INVALID_OPERATION);
3980 }
3981
3982 texture->generateMipmaps();
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003983 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003984 }
3985 catch(std::bad_alloc&)
3986 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003987 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003988 }
3989}
3990
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003991void __stdcall glGenFencesNV(GLsizei n, GLuint* fences)
3992{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003993 EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003994
3995 try
3996 {
3997 if (n < 0)
3998 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003999 return gl::error(GL_INVALID_VALUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004000 }
4001
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004002 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004003
4004 if (context)
4005 {
4006 for (int i = 0; i < n; i++)
4007 {
4008 fences[i] = context->createFence();
4009 }
4010 }
4011 }
4012 catch(std::bad_alloc&)
4013 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004014 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004015 }
4016}
4017
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004018void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers)
4019{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004020 EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004021
4022 try
4023 {
4024 if (n < 0)
4025 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004026 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004027 }
4028
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004029 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004030
4031 if (context)
4032 {
4033 for (int i = 0; i < n; i++)
4034 {
4035 framebuffers[i] = context->createFramebuffer();
4036 }
4037 }
4038 }
4039 catch(std::bad_alloc&)
4040 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004041 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004042 }
4043}
4044
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004045void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids)
4046{
4047 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
4048
4049 try
4050 {
4051 if (n < 0)
4052 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004053 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004054 }
4055
4056 gl::Context *context = gl::getNonLostContext();
4057
4058 if (context)
4059 {
4060 for (int i = 0; i < n; i++)
4061 {
4062 ids[i] = context->createQuery();
4063 }
4064 }
4065 }
4066 catch(std::bad_alloc&)
4067 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004068 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004069 }
4070}
4071
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004072void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
4073{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004074 EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004075
4076 try
4077 {
4078 if (n < 0)
4079 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004080 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004081 }
4082
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004083 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004084
4085 if (context)
4086 {
4087 for (int i = 0; i < n; i++)
4088 {
4089 renderbuffers[i] = context->createRenderbuffer();
4090 }
4091 }
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 glGenTextures(GLsizei n, GLuint* textures)
4100{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004101 EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004102
4103 try
4104 {
4105 if (n < 0)
4106 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004107 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004108 }
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 {
4114 for (int i = 0; i < n; i++)
4115 {
4116 textures[i] = context->createTexture();
4117 }
4118 }
4119 }
4120 catch(std::bad_alloc&)
4121 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004122 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004123 }
4124}
4125
daniel@transgaming.com85423182010-04-22 13:35:27 +00004126void __stdcall glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004127{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004128 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
daniel@transgaming.com85423182010-04-22 13:35:27 +00004129 "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004130 program, index, bufsize, length, size, type, name);
4131
4132 try
4133 {
4134 if (bufsize < 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.com85423182010-04-22 13:35:27 +00004140
4141 if (context)
4142 {
4143 gl::Program *programObject = context->getProgram(program);
4144
4145 if (!programObject)
4146 {
4147 if (context->getShader(program))
4148 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004149 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com85423182010-04-22 13:35:27 +00004150 }
4151 else
4152 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004153 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com85423182010-04-22 13:35:27 +00004154 }
4155 }
4156
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004157 if (index >= (GLuint)programObject->getActiveAttributeCount())
daniel@transgaming.com85423182010-04-22 13:35:27 +00004158 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004159 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com85423182010-04-22 13:35:27 +00004160 }
4161
4162 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
4163 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004164 }
4165 catch(std::bad_alloc&)
4166 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004167 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004168 }
4169}
4170
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004171void __stdcall glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004172{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004173 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004174 "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 +00004175 program, index, bufsize, length, size, type, name);
4176
4177 try
4178 {
4179 if (bufsize < 0)
4180 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004181 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004182 }
4183
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004184 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004185
4186 if (context)
4187 {
4188 gl::Program *programObject = context->getProgram(program);
4189
4190 if (!programObject)
4191 {
4192 if (context->getShader(program))
4193 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004194 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004195 }
4196 else
4197 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004198 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004199 }
4200 }
4201
4202 if (index >= (GLuint)programObject->getActiveUniformCount())
4203 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004204 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004205 }
4206
4207 programObject->getActiveUniform(index, bufsize, length, size, type, name);
4208 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004209 }
4210 catch(std::bad_alloc&)
4211 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004212 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004213 }
4214}
4215
4216void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
4217{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004218 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 +00004219 program, maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004220
4221 try
4222 {
4223 if (maxcount < 0)
4224 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004225 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004226 }
4227
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004228 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com6c785212010-03-30 03:36:17 +00004229
4230 if (context)
4231 {
4232 gl::Program *programObject = context->getProgram(program);
4233
4234 if (!programObject)
4235 {
daniel@transgaming.com23953e32010-04-13 19:53:31 +00004236 if (context->getShader(program))
4237 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004238 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com23953e32010-04-13 19:53:31 +00004239 }
4240 else
4241 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004242 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com23953e32010-04-13 19:53:31 +00004243 }
daniel@transgaming.com6c785212010-03-30 03:36:17 +00004244 }
4245
4246 return programObject->getAttachedShaders(maxcount, count, shaders);
4247 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004248 }
4249 catch(std::bad_alloc&)
4250 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004251 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004252 }
4253}
4254
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004255int __stdcall glGetAttribLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004256{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004257 EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004258
4259 try
4260 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004261 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004262
4263 if (context)
4264 {
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004265
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004266 gl::Program *programObject = context->getProgram(program);
4267
4268 if (!programObject)
4269 {
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004270 if (context->getShader(program))
4271 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004272 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004273 }
4274 else
4275 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004276 return gl::error(GL_INVALID_VALUE, -1);
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004277 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004278 }
4279
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00004280 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
daniel@transgaming.com716056c2012-07-24 18:38:59 +00004281 if (!programObject->isLinked() || !programBinary)
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00004282 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004283 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00004284 }
4285
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00004286 return programBinary->getAttributeLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004287 }
4288 }
4289 catch(std::bad_alloc&)
4290 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004291 return gl::error(GL_OUT_OF_MEMORY, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004292 }
4293
4294 return -1;
4295}
4296
4297void __stdcall glGetBooleanv(GLenum pname, GLboolean* params)
4298{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004299 EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004300
4301 try
4302 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004303 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004304
4305 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004306 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004307 if (!(context->getBooleanv(pname, params)))
4308 {
4309 GLenum nativeType;
4310 unsigned int numParams = 0;
4311 if (!context->getQueryParameterInfo(pname, &nativeType, &numParams))
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004312 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004313
4314 if (numParams == 0)
4315 return; // it is known that the pname is valid, but there are no parameters to return
4316
4317 if (nativeType == GL_FLOAT)
4318 {
4319 GLfloat *floatParams = NULL;
4320 floatParams = new GLfloat[numParams];
4321
4322 context->getFloatv(pname, floatParams);
4323
4324 for (unsigned int i = 0; i < numParams; ++i)
4325 {
4326 if (floatParams[i] == 0.0f)
4327 params[i] = GL_FALSE;
4328 else
4329 params[i] = GL_TRUE;
4330 }
4331
4332 delete [] floatParams;
4333 }
4334 else if (nativeType == GL_INT)
4335 {
4336 GLint *intParams = NULL;
4337 intParams = new GLint[numParams];
4338
4339 context->getIntegerv(pname, intParams);
4340
4341 for (unsigned int i = 0; i < numParams; ++i)
4342 {
4343 if (intParams[i] == 0)
4344 params[i] = GL_FALSE;
4345 else
4346 params[i] = GL_TRUE;
4347 }
4348
4349 delete [] intParams;
4350 }
4351 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004352 }
4353 }
4354 catch(std::bad_alloc&)
4355 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004356 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004357 }
4358}
4359
4360void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
4361{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004362 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 +00004363
4364 try
4365 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004366 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004367
4368 if (context)
4369 {
4370 gl::Buffer *buffer;
4371
4372 switch (target)
4373 {
4374 case GL_ARRAY_BUFFER:
4375 buffer = context->getArrayBuffer();
4376 break;
4377 case GL_ELEMENT_ARRAY_BUFFER:
4378 buffer = context->getElementArrayBuffer();
4379 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004380 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004381 }
4382
4383 if (!buffer)
4384 {
4385 // A null buffer means that "0" is bound to the requested buffer target
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004386 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004387 }
4388
4389 switch (pname)
4390 {
4391 case GL_BUFFER_USAGE:
4392 *params = buffer->usage();
4393 break;
4394 case GL_BUFFER_SIZE:
4395 *params = buffer->size();
4396 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004397 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004398 }
4399 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004400 }
4401 catch(std::bad_alloc&)
4402 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004403 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004404 }
4405}
4406
4407GLenum __stdcall glGetError(void)
4408{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004409 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004410
4411 gl::Context *context = gl::getContext();
4412
4413 if (context)
4414 {
daniel@transgaming.com82b28912011-12-12 21:01:35 +00004415 return context->getError();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004416 }
4417
4418 return GL_NO_ERROR;
4419}
4420
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004421void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
4422{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004423 EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004424
4425 try
4426 {
4427
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004428 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004429
4430 if (context)
4431 {
4432 gl::Fence *fenceObject = context->getFence(fence);
4433
4434 if (fenceObject == NULL)
4435 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004436 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004437 }
4438
4439 fenceObject->getFenceiv(pname, params);
4440 }
4441 }
4442 catch(std::bad_alloc&)
4443 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004444 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004445 }
4446}
4447
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004448void __stdcall glGetFloatv(GLenum pname, GLfloat* params)
4449{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004450 EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004451
4452 try
4453 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004454 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004455
4456 if (context)
4457 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004458 if (!(context->getFloatv(pname, params)))
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004459 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004460 GLenum nativeType;
4461 unsigned int numParams = 0;
4462 if (!context->getQueryParameterInfo(pname, &nativeType, &numParams))
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004463 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004464
4465 if (numParams == 0)
4466 return; // it is known that the pname is valid, but that there are no parameters to return.
4467
4468 if (nativeType == GL_BOOL)
4469 {
4470 GLboolean *boolParams = NULL;
4471 boolParams = new GLboolean[numParams];
4472
4473 context->getBooleanv(pname, boolParams);
4474
4475 for (unsigned int i = 0; i < numParams; ++i)
4476 {
4477 if (boolParams[i] == GL_FALSE)
4478 params[i] = 0.0f;
4479 else
4480 params[i] = 1.0f;
4481 }
4482
4483 delete [] boolParams;
4484 }
4485 else if (nativeType == GL_INT)
4486 {
4487 GLint *intParams = NULL;
4488 intParams = new GLint[numParams];
4489
4490 context->getIntegerv(pname, intParams);
4491
4492 for (unsigned int i = 0; i < numParams; ++i)
4493 {
4494 params[i] = (GLfloat)intParams[i];
4495 }
4496
4497 delete [] intParams;
4498 }
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004499 }
4500 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004501 }
4502 catch(std::bad_alloc&)
4503 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004504 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004505 }
4506}
4507
4508void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
4509{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004510 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 +00004511 target, attachment, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004512
4513 try
4514 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004515 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004516
4517 if (context)
4518 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004519 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004520 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004521 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004522 }
4523
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004524 gl::Framebuffer *framebuffer = NULL;
4525 if (target == GL_READ_FRAMEBUFFER_ANGLE)
4526 {
4527 if(context->getReadFramebufferHandle() == 0)
4528 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004529 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004530 }
4531
4532 framebuffer = context->getReadFramebuffer();
4533 }
4534 else
4535 {
4536 if (context->getDrawFramebufferHandle() == 0)
4537 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004538 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004539 }
4540
4541 framebuffer = context->getDrawFramebuffer();
4542 }
4543
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004544 GLenum attachmentType;
4545 GLuint attachmentHandle;
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00004546
4547 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004548 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00004549 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
4550
4551 if (colorAttachment >= context->getMaximumRenderTargets())
4552 {
4553 return gl::error(GL_INVALID_ENUM);
4554 }
4555
4556 attachmentType = framebuffer->getColorbufferType(colorAttachment);
4557 attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment);
4558 }
4559 else
4560 {
4561 switch (attachment)
4562 {
4563 case GL_DEPTH_ATTACHMENT:
4564 attachmentType = framebuffer->getDepthbufferType();
4565 attachmentHandle = framebuffer->getDepthbufferHandle();
4566 break;
4567 case GL_STENCIL_ATTACHMENT:
4568 attachmentType = framebuffer->getStencilbufferType();
4569 attachmentHandle = framebuffer->getStencilbufferHandle();
4570 break;
4571 default: return gl::error(GL_INVALID_ENUM);
4572 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004573 }
4574
4575 GLenum attachmentObjectType; // Type category
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00004576 if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004577 {
4578 attachmentObjectType = attachmentType;
4579 }
apatrick@chromium.org551022e2012-01-23 19:56:54 +00004580 else if (gl::IsInternalTextureTarget(attachmentType))
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004581 {
4582 attachmentObjectType = GL_TEXTURE;
4583 }
apatrick@chromium.orga1d80592012-01-25 21:52:10 +00004584 else
4585 {
4586 UNREACHABLE();
4587 return;
4588 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004589
4590 switch (pname)
4591 {
4592 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
4593 *params = attachmentObjectType;
4594 break;
4595 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
4596 if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE)
4597 {
4598 *params = attachmentHandle;
4599 }
4600 else
4601 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004602 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004603 }
4604 break;
4605 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
4606 if (attachmentObjectType == GL_TEXTURE)
4607 {
4608 *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0
4609 }
4610 else
4611 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004612 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004613 }
4614 break;
4615 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
4616 if (attachmentObjectType == GL_TEXTURE)
4617 {
daniel@transgaming.com19ffc242010-05-04 03:35:21 +00004618 if (gl::IsCubemapTextureTarget(attachmentType))
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004619 {
4620 *params = attachmentType;
4621 }
4622 else
4623 {
4624 *params = 0;
4625 }
4626 }
4627 else
4628 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004629 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004630 }
4631 break;
4632 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004633 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004634 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004635 }
4636 }
4637 catch(std::bad_alloc&)
4638 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004639 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004640 }
4641}
4642
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00004643GLenum __stdcall glGetGraphicsResetStatusEXT(void)
4644{
4645 EVENT("()");
4646
4647 try
4648 {
4649 gl::Context *context = gl::getContext();
4650
4651 if (context)
4652 {
4653 return context->getResetStatus();
4654 }
4655
4656 return GL_NO_ERROR;
4657 }
4658 catch(std::bad_alloc&)
4659 {
4660 return GL_OUT_OF_MEMORY;
4661 }
4662}
4663
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004664void __stdcall glGetIntegerv(GLenum pname, GLint* params)
4665{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004666 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004667
4668 try
4669 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004670 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004671
4672 if (context)
4673 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004674 if (!(context->getIntegerv(pname, params)))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004675 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004676 GLenum nativeType;
4677 unsigned int numParams = 0;
4678 if (!context->getQueryParameterInfo(pname, &nativeType, &numParams))
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004679 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004680
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004681 if (numParams == 0)
4682 return; // it is known that pname is valid, but there are no parameters to return
4683
4684 if (nativeType == GL_BOOL)
4685 {
4686 GLboolean *boolParams = NULL;
4687 boolParams = new GLboolean[numParams];
4688
4689 context->getBooleanv(pname, boolParams);
4690
4691 for (unsigned int i = 0; i < numParams; ++i)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004692 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004693 if (boolParams[i] == GL_FALSE)
4694 params[i] = 0;
4695 else
4696 params[i] = 1;
4697 }
4698
4699 delete [] boolParams;
4700 }
4701 else if (nativeType == GL_FLOAT)
4702 {
4703 GLfloat *floatParams = NULL;
4704 floatParams = new GLfloat[numParams];
4705
4706 context->getFloatv(pname, floatParams);
4707
4708 for (unsigned int i = 0; i < numParams; ++i)
4709 {
daniel@transgaming.comc1641352010-04-26 15:33:36 +00004710 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 +00004711 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004712 params[i] = (GLint)(((GLfloat)(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004713 }
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004714 else
4715 params[i] = (GLint)(floatParams[i] > 0.0f ? floor(floatParams[i] + 0.5) : ceil(floatParams[i] - 0.5));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004716 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004717
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004718 delete [] floatParams;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004719 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004720 }
4721 }
4722 }
4723 catch(std::bad_alloc&)
4724 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004725 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004726 }
4727}
4728
4729void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params)
4730{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004731 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004732
4733 try
4734 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004735 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004736
4737 if (context)
4738 {
4739 gl::Program *programObject = context->getProgram(program);
4740
4741 if (!programObject)
4742 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004743 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004744 }
4745
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00004746 if (context->getClientVersion() < 3)
4747 {
4748 switch (pname)
4749 {
4750 case GL_ACTIVE_UNIFORM_BLOCKS:
4751 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
4752 return gl::error(GL_INVALID_ENUM);
4753 }
4754 }
4755
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004756 switch (pname)
4757 {
4758 case GL_DELETE_STATUS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004759 *params = programObject->isFlaggedForDeletion();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004760 return;
4761 case GL_LINK_STATUS:
daniel@transgaming.com716056c2012-07-24 18:38:59 +00004762 *params = programObject->isLinked();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004763 return;
4764 case GL_VALIDATE_STATUS:
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004765 *params = programObject->isValidated();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004766 return;
4767 case GL_INFO_LOG_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004768 *params = programObject->getInfoLogLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004769 return;
4770 case GL_ATTACHED_SHADERS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004771 *params = programObject->getAttachedShadersCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004772 return;
4773 case GL_ACTIVE_ATTRIBUTES:
daniel@transgaming.com85423182010-04-22 13:35:27 +00004774 *params = programObject->getActiveAttributeCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004775 return;
4776 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
daniel@transgaming.com85423182010-04-22 13:35:27 +00004777 *params = programObject->getActiveAttributeMaxLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004778 return;
4779 case GL_ACTIVE_UNIFORMS:
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004780 *params = programObject->getActiveUniformCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004781 return;
4782 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004783 *params = programObject->getActiveUniformMaxLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004784 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00004785 case GL_PROGRAM_BINARY_LENGTH_OES:
apatrick@chromium.org90080e32012-07-09 22:15:33 +00004786 *params = programObject->getProgramBinaryLength();
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00004787 return;
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00004788 case GL_ACTIVE_UNIFORM_BLOCKS:
4789 *params = programObject->getActiveUniformBlockCount();
4790 return;
4791 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
4792 *params = programObject->getActiveUniformBlockMaxLength();
4793 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004794 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004795 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004796 }
4797 }
4798 }
4799 catch(std::bad_alloc&)
4800 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004801 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004802 }
4803}
4804
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004805void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004806{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004807 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 +00004808 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004809
4810 try
4811 {
4812 if (bufsize < 0)
4813 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004814 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004815 }
4816
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004817 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004818
4819 if (context)
4820 {
4821 gl::Program *programObject = context->getProgram(program);
4822
4823 if (!programObject)
4824 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004825 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004826 }
4827
4828 programObject->getInfoLog(bufsize, length, infolog);
4829 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004830 }
4831 catch(std::bad_alloc&)
4832 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004833 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004834 }
4835}
4836
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004837void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
4838{
4839 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
4840
4841 try
4842 {
4843 switch (pname)
4844 {
4845 case GL_CURRENT_QUERY_EXT:
4846 break;
4847 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004848 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004849 }
4850
4851 gl::Context *context = gl::getNonLostContext();
4852
4853 if (context)
4854 {
4855 params[0] = context->getActiveQuery(target);
4856 }
4857 }
4858 catch(std::bad_alloc&)
4859 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004860 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004861 }
4862}
4863
4864void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
4865{
4866 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
4867
4868 try
4869 {
4870 switch (pname)
4871 {
4872 case GL_QUERY_RESULT_EXT:
4873 case GL_QUERY_RESULT_AVAILABLE_EXT:
4874 break;
4875 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004876 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004877 }
4878 gl::Context *context = gl::getNonLostContext();
4879
4880 if (context)
4881 {
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004882 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
4883
4884 if (!queryObject)
4885 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004886 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004887 }
4888
4889 if (context->getActiveQuery(queryObject->getType()) == id)
4890 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004891 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004892 }
4893
4894 switch(pname)
4895 {
4896 case GL_QUERY_RESULT_EXT:
4897 params[0] = queryObject->getResult();
4898 break;
4899 case GL_QUERY_RESULT_AVAILABLE_EXT:
4900 params[0] = queryObject->isResultAvailable();
4901 break;
4902 default:
4903 ASSERT(false);
4904 }
4905 }
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.com86bdb822012-01-20 18:24:39 +00004910 }
4911}
4912
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004913void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
4914{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004915 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 +00004916
4917 try
4918 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004919 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004920
4921 if (context)
4922 {
4923 if (target != GL_RENDERBUFFER)
4924 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004925 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004926 }
4927
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004928 if (context->getRenderbufferHandle() == 0)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004929 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004930 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004931 }
4932
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004933 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle());
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004934
4935 switch (pname)
4936 {
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00004937 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
4938 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
4939 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
4940 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
4941 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
4942 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
4943 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
4944 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
4945 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00004946 case GL_RENDERBUFFER_SAMPLES_ANGLE:
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00004947 if (context->getMaxSupportedSamples() != 0)
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00004948 {
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00004949 *params = renderbuffer->getSamples();
4950 }
4951 else
4952 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004953 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00004954 }
4955 break;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004956 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004957 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004958 }
4959 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004960 }
4961 catch(std::bad_alloc&)
4962 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004963 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004964 }
4965}
4966
4967void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
4968{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004969 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004970
4971 try
4972 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004973 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004974
4975 if (context)
4976 {
4977 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004978
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004979 if (!shaderObject)
4980 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004981 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004982 }
4983
4984 switch (pname)
4985 {
4986 case GL_SHADER_TYPE:
4987 *params = shaderObject->getType();
4988 return;
4989 case GL_DELETE_STATUS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004990 *params = shaderObject->isFlaggedForDeletion();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004991 return;
4992 case GL_COMPILE_STATUS:
4993 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
4994 return;
4995 case GL_INFO_LOG_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004996 *params = shaderObject->getInfoLogLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004997 return;
4998 case GL_SHADER_SOURCE_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004999 *params = shaderObject->getSourceLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005000 return;
zmo@google.coma574f782011-10-03 21:45:23 +00005001 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
5002 *params = shaderObject->getTranslatedSourceLength();
5003 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005004 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005005 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005006 }
5007 }
5008 }
5009 catch(std::bad_alloc&)
5010 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005011 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005012 }
5013}
5014
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005015void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005016{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005017 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 +00005018 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005019
5020 try
5021 {
5022 if (bufsize < 0)
5023 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005024 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005025 }
5026
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005027 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005028
5029 if (context)
5030 {
5031 gl::Shader *shaderObject = context->getShader(shader);
5032
5033 if (!shaderObject)
5034 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005035 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005036 }
5037
5038 shaderObject->getInfoLog(bufsize, length, infolog);
5039 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005040 }
5041 catch(std::bad_alloc&)
5042 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005043 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005044 }
5045}
5046
5047void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
5048{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005049 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 +00005050 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005051
5052 try
5053 {
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005054 switch (shadertype)
5055 {
5056 case GL_VERTEX_SHADER:
5057 case GL_FRAGMENT_SHADER:
5058 break;
5059 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005060 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005061 }
5062
5063 switch (precisiontype)
5064 {
5065 case GL_LOW_FLOAT:
5066 case GL_MEDIUM_FLOAT:
5067 case GL_HIGH_FLOAT:
5068 // Assume IEEE 754 precision
5069 range[0] = 127;
5070 range[1] = 127;
daniel@transgaming.comc5c15382010-04-23 18:34:49 +00005071 *precision = 23;
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005072 break;
5073 case GL_LOW_INT:
5074 case GL_MEDIUM_INT:
5075 case GL_HIGH_INT:
5076 // Some (most) hardware only supports single-precision floating-point numbers,
5077 // which can accurately represent integers up to +/-16777216
5078 range[0] = 24;
5079 range[1] = 24;
daniel@transgaming.comc5c15382010-04-23 18:34:49 +00005080 *precision = 0;
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005081 break;
5082 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005083 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005084 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005085 }
5086 catch(std::bad_alloc&)
5087 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005088 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005089 }
5090}
5091
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005092void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005093{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005094 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 +00005095 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005096
5097 try
5098 {
5099 if (bufsize < 0)
5100 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005101 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005102 }
5103
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005104 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005105
5106 if (context)
5107 {
5108 gl::Shader *shaderObject = context->getShader(shader);
5109
5110 if (!shaderObject)
5111 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005112 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005113 }
5114
5115 shaderObject->getSource(bufsize, length, source);
5116 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005117 }
5118 catch(std::bad_alloc&)
5119 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005120 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005121 }
5122}
5123
zmo@google.coma574f782011-10-03 21:45:23 +00005124void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
5125{
5126 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
5127 shader, bufsize, length, source);
5128
5129 try
5130 {
5131 if (bufsize < 0)
5132 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005133 return gl::error(GL_INVALID_VALUE);
zmo@google.coma574f782011-10-03 21:45:23 +00005134 }
5135
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005136 gl::Context *context = gl::getNonLostContext();
zmo@google.coma574f782011-10-03 21:45:23 +00005137
5138 if (context)
5139 {
5140 gl::Shader *shaderObject = context->getShader(shader);
5141
5142 if (!shaderObject)
5143 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005144 return gl::error(GL_INVALID_OPERATION);
zmo@google.coma574f782011-10-03 21:45:23 +00005145 }
5146
5147 shaderObject->getTranslatedSource(bufsize, length, source);
5148 }
5149 }
5150 catch(std::bad_alloc&)
5151 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005152 return gl::error(GL_OUT_OF_MEMORY);
zmo@google.coma574f782011-10-03 21:45:23 +00005153 }
5154}
5155
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005156const GLubyte* __stdcall glGetString(GLenum name)
5157{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005158 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005159
5160 try
5161 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005162 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00005163
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005164 switch (name)
5165 {
5166 case GL_VENDOR:
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +00005167 return (GLubyte*)"Google Inc.";
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005168 case GL_RENDERER:
daniel@transgaming.comc23ff642011-08-16 20:28:45 +00005169 return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005170 case GL_VERSION:
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00005171 if (context->getClientVersion() == 2)
5172 {
5173 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")";
5174 }
5175 else
5176 {
5177 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")";
5178 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005179 case GL_SHADING_LANGUAGE_VERSION:
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00005180 if (context->getClientVersion() == 2)
5181 {
5182 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")";
5183 }
5184 else
5185 {
5186 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")";
5187 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005188 case GL_EXTENSIONS:
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00005189 return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : "");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005190 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005191 return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005192 }
5193 }
5194 catch(std::bad_alloc&)
5195 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005196 return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005197 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005198}
5199
5200void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
5201{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005202 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 +00005203
5204 try
5205 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005206 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005207
5208 if (context)
5209 {
5210 gl::Texture *texture;
5211
5212 switch (target)
5213 {
5214 case GL_TEXTURE_2D:
5215 texture = context->getTexture2D();
5216 break;
5217 case GL_TEXTURE_CUBE_MAP:
5218 texture = context->getTextureCubeMap();
5219 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00005220 case GL_TEXTURE_3D:
5221 if (context->getClientVersion() < 3)
5222 {
5223 return gl::error(GL_INVALID_ENUM);
5224 }
5225 texture = context->getTexture3D();
5226 break;
shannonwoods@chromium.org0c611d12013-05-30 00:15:05 +00005227 case GL_TEXTURE_2D_ARRAY:
5228 if (context->getClientVersion() < 3)
5229 {
5230 return gl::error(GL_INVALID_ENUM);
5231 }
5232 texture = context->getTexture2DArray();
5233 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005234 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005235 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005236 }
5237
5238 switch (pname)
5239 {
5240 case GL_TEXTURE_MAG_FILTER:
5241 *params = (GLfloat)texture->getMagFilter();
5242 break;
5243 case GL_TEXTURE_MIN_FILTER:
5244 *params = (GLfloat)texture->getMinFilter();
5245 break;
5246 case GL_TEXTURE_WRAP_S:
5247 *params = (GLfloat)texture->getWrapS();
5248 break;
5249 case GL_TEXTURE_WRAP_T:
5250 *params = (GLfloat)texture->getWrapT();
5251 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00005252 case GL_TEXTURE_WRAP_R:
5253 if (context->getClientVersion() < 3)
5254 {
5255 return gl::error(GL_INVALID_ENUM);
5256 }
5257 *params = (GLfloat)texture->getWrapR();
5258 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005259 case GL_TEXTURE_IMMUTABLE_FORMAT:
5260 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
daniel@transgaming.comd30bd0a2011-11-11 04:10:34 +00005261 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
5262 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005263 case GL_TEXTURE_IMMUTABLE_LEVELS:
5264 if (context->getClientVersion() < 3)
5265 {
5266 return gl::error(GL_INVALID_ENUM);
5267 }
5268 *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0);
5269 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00005270 case GL_TEXTURE_USAGE_ANGLE:
5271 *params = (GLfloat)texture->getUsage();
5272 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005273 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
5274 if (!context->supportsTextureFilterAnisotropy())
5275 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005276 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005277 }
5278 *params = (GLfloat)texture->getMaxAnisotropy();
5279 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005280 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005281 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005282 }
5283 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005284 }
5285 catch(std::bad_alloc&)
5286 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005287 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005288 }
5289}
5290
5291void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
5292{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005293 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 +00005294
5295 try
5296 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005297 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005298
5299 if (context)
5300 {
5301 gl::Texture *texture;
5302
5303 switch (target)
5304 {
5305 case GL_TEXTURE_2D:
5306 texture = context->getTexture2D();
5307 break;
5308 case GL_TEXTURE_CUBE_MAP:
5309 texture = context->getTextureCubeMap();
5310 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00005311 case GL_TEXTURE_3D:
5312 if (context->getClientVersion() < 3)
5313 {
5314 return gl::error(GL_INVALID_ENUM);
5315 }
5316 texture = context->getTexture3D();
5317 break;
shannonwoods@chromium.org0c611d12013-05-30 00:15:05 +00005318 case GL_TEXTURE_2D_ARRAY:
5319 if (context->getClientVersion() < 3)
5320 {
5321 return gl::error(GL_INVALID_ENUM);
5322 }
5323 texture = context->getTexture2DArray();
5324 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005325 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005326 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005327 }
5328
5329 switch (pname)
5330 {
5331 case GL_TEXTURE_MAG_FILTER:
5332 *params = texture->getMagFilter();
5333 break;
5334 case GL_TEXTURE_MIN_FILTER:
5335 *params = texture->getMinFilter();
5336 break;
5337 case GL_TEXTURE_WRAP_S:
5338 *params = texture->getWrapS();
5339 break;
5340 case GL_TEXTURE_WRAP_T:
5341 *params = texture->getWrapT();
5342 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00005343 case GL_TEXTURE_WRAP_R:
5344 if (context->getClientVersion() < 3)
5345 {
5346 return gl::error(GL_INVALID_ENUM);
5347 }
5348 *params = texture->getWrapR();
5349 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005350 case GL_TEXTURE_IMMUTABLE_FORMAT:
5351 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
daniel@transgaming.comd30bd0a2011-11-11 04:10:34 +00005352 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
5353 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005354 case GL_TEXTURE_IMMUTABLE_LEVELS:
5355 if (context->getClientVersion() < 3)
5356 {
5357 return gl::error(GL_INVALID_ENUM);
5358 }
5359 *params = texture->isImmutable() ? texture->levelCount() : 0;
5360 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00005361 case GL_TEXTURE_USAGE_ANGLE:
5362 *params = texture->getUsage();
5363 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005364 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
5365 if (!context->supportsTextureFilterAnisotropy())
5366 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005367 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005368 }
5369 *params = (GLint)texture->getMaxAnisotropy();
5370 break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00005371
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005372 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005373 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005374 }
5375 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005376 }
5377 catch(std::bad_alloc&)
5378 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005379 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005380 }
5381}
5382
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005383void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
5384{
5385 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
5386 program, location, bufSize, params);
5387
5388 try
5389 {
5390 if (bufSize < 0)
5391 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005392 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005393 }
5394
5395 gl::Context *context = gl::getNonLostContext();
5396
5397 if (context)
5398 {
5399 if (program == 0)
5400 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005401 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005402 }
5403
5404 gl::Program *programObject = context->getProgram(program);
5405
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005406 if (!programObject || !programObject->isLinked())
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005407 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005408 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005409 }
5410
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005411 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5412 if (!programBinary)
5413 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005414 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005415 }
5416
5417 if (!programBinary->getUniformfv(location, &bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005418 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005419 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005420 }
5421 }
5422 }
5423 catch(std::bad_alloc&)
5424 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005425 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005426 }
5427}
5428
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005429void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params)
5430{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005431 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005432
5433 try
5434 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005435 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005436
5437 if (context)
5438 {
5439 if (program == 0)
5440 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005441 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005442 }
5443
5444 gl::Program *programObject = context->getProgram(program);
5445
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005446 if (!programObject || !programObject->isLinked())
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005447 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005448 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005449 }
5450
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005451 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5452 if (!programBinary)
5453 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005454 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005455 }
5456
5457 if (!programBinary->getUniformfv(location, NULL, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005458 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005459 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005460 }
5461 }
5462 }
5463 catch(std::bad_alloc&)
5464 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005465 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005466 }
5467}
5468
5469void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
5470{
5471 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
5472 program, location, bufSize, params);
5473
5474 try
5475 {
5476 if (bufSize < 0)
5477 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005478 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005479 }
5480
5481 gl::Context *context = gl::getNonLostContext();
5482
5483 if (context)
5484 {
5485 if (program == 0)
5486 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005487 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005488 }
5489
5490 gl::Program *programObject = context->getProgram(program);
5491
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005492 if (!programObject || !programObject->isLinked())
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005493 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005494 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005495 }
5496
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005497 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5498 if (!programBinary)
5499 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005500 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005501 }
5502
5503 if (!programBinary->getUniformiv(location, &bufSize, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005504 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005505 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005506 }
5507 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005508 }
5509 catch(std::bad_alloc&)
5510 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005511 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005512 }
5513}
5514
5515void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params)
5516{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005517 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005518
5519 try
5520 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005521 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005522
5523 if (context)
5524 {
5525 if (program == 0)
5526 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005527 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005528 }
5529
5530 gl::Program *programObject = context->getProgram(program);
5531
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005532 if (!programObject || !programObject->isLinked())
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005533 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005534 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005535 }
5536
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005537 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5538 if (!programBinary)
5539 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005540 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005541 }
5542
5543 if (!programBinary->getUniformiv(location, NULL, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005544 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005545 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005546 }
5547 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005548 }
5549 catch(std::bad_alloc&)
5550 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005551 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005552 }
5553}
5554
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005555int __stdcall glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005556{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005557 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005558
5559 try
5560 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005561 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005562
5563 if (strstr(name, "gl_") == name)
5564 {
5565 return -1;
5566 }
5567
5568 if (context)
5569 {
5570 gl::Program *programObject = context->getProgram(program);
5571
5572 if (!programObject)
5573 {
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00005574 if (context->getShader(program))
5575 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005576 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00005577 }
5578 else
5579 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005580 return gl::error(GL_INVALID_VALUE, -1);
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00005581 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005582 }
5583
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005584 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005585 if (!programObject->isLinked() || !programBinary)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005586 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005587 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005588 }
5589
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005590 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005591 }
5592 }
5593 catch(std::bad_alloc&)
5594 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005595 return gl::error(GL_OUT_OF_MEMORY, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005596 }
5597
5598 return -1;
5599}
5600
5601void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
5602{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005603 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005604
5605 try
5606 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005607 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005608
daniel@transgaming.come0078962010-04-15 20:45:08 +00005609 if (context)
5610 {
5611 if (index >= gl::MAX_VERTEX_ATTRIBS)
5612 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005613 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005614 }
5615
daniel@transgaming.com83921382011-01-08 05:46:00 +00005616 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005617
daniel@transgaming.come0078962010-04-15 20:45:08 +00005618 switch (pname)
5619 {
5620 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
daniel@transgaming.com83921382011-01-08 05:46:00 +00005621 *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005622 break;
5623 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005624 *params = (GLfloat)attribState.mSize;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005625 break;
5626 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005627 *params = (GLfloat)attribState.mStride;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005628 break;
5629 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005630 *params = (GLfloat)attribState.mType;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005631 break;
5632 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005633 *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005634 break;
5635 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +00005636 *params = (GLfloat)attribState.mBoundBuffer.id();
daniel@transgaming.come0078962010-04-15 20:45:08 +00005637 break;
5638 case GL_CURRENT_VERTEX_ATTRIB:
5639 for (int i = 0; i < 4; ++i)
5640 {
shannon.woods%transgaming.com@gtempaccount.com3026dc72013-04-13 03:37:27 +00005641 params[i] = attribState.mCurrentValue.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00005642 }
5643 break;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00005644 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
5645 // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses
5646 // the same constant.
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005647 *params = (GLfloat)attribState.mDivisor;
5648 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005649 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005650 }
5651 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005652 }
5653 catch(std::bad_alloc&)
5654 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005655 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005656 }
5657}
5658
5659void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
5660{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005661 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005662
5663 try
5664 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005665 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005666
daniel@transgaming.come0078962010-04-15 20:45:08 +00005667 if (context)
5668 {
5669 if (index >= gl::MAX_VERTEX_ATTRIBS)
5670 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005671 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005672 }
5673
daniel@transgaming.com83921382011-01-08 05:46:00 +00005674 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005675
daniel@transgaming.come0078962010-04-15 20:45:08 +00005676 switch (pname)
5677 {
5678 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
daniel@transgaming.com83921382011-01-08 05:46:00 +00005679 *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005680 break;
5681 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005682 *params = attribState.mSize;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005683 break;
5684 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005685 *params = attribState.mStride;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005686 break;
5687 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005688 *params = attribState.mType;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005689 break;
5690 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005691 *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005692 break;
5693 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +00005694 *params = attribState.mBoundBuffer.id();
daniel@transgaming.come0078962010-04-15 20:45:08 +00005695 break;
5696 case GL_CURRENT_VERTEX_ATTRIB:
5697 for (int i = 0; i < 4; ++i)
5698 {
shannon.woods%transgaming.com@gtempaccount.com3026dc72013-04-13 03:37:27 +00005699 float currentValue = attribState.mCurrentValue.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00005700 params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f));
5701 }
5702 break;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00005703 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
5704 // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses
5705 // the same constant.
5706 META_ASSERT(GL_VERTEX_ATTRIB_ARRAY_DIVISOR == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005707 *params = (GLint)attribState.mDivisor;
5708 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005709 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005710 }
5711 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005712 }
5713 catch(std::bad_alloc&)
5714 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005715 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005716 }
5717}
5718
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005719void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005720{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005721 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005722
5723 try
5724 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005725 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005726
daniel@transgaming.come0078962010-04-15 20:45:08 +00005727 if (context)
5728 {
5729 if (index >= gl::MAX_VERTEX_ATTRIBS)
5730 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005731 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005732 }
5733
5734 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
5735 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005736 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005737 }
5738
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005739 *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index));
daniel@transgaming.come0078962010-04-15 20:45:08 +00005740 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005741 }
5742 catch(std::bad_alloc&)
5743 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005744 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005745 }
5746}
5747
5748void __stdcall glHint(GLenum target, GLenum mode)
5749{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005750 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005751
5752 try
5753 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005754 switch (mode)
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005755 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005756 case GL_FASTEST:
5757 case GL_NICEST:
5758 case GL_DONT_CARE:
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005759 break;
5760 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005761 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005762 }
5763
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005764 gl::Context *context = gl::getNonLostContext();
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005765 switch (target)
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005766 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005767 case GL_GENERATE_MIPMAP_HINT:
5768 if (context) context->setGenerateMipmapHint(mode);
5769 break;
5770 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
5771 if (context) context->setFragmentShaderDerivativeHint(mode);
5772 break;
5773 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005774 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005775 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005776 }
5777 catch(std::bad_alloc&)
5778 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005779 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005780 }
5781}
5782
5783GLboolean __stdcall glIsBuffer(GLuint buffer)
5784{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005785 EVENT("(GLuint buffer = %d)", buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005786
5787 try
5788 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005789 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005790
5791 if (context && buffer)
5792 {
5793 gl::Buffer *bufferObject = context->getBuffer(buffer);
5794
5795 if (bufferObject)
5796 {
5797 return GL_TRUE;
5798 }
5799 }
5800 }
5801 catch(std::bad_alloc&)
5802 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005803 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005804 }
5805
5806 return GL_FALSE;
5807}
5808
5809GLboolean __stdcall glIsEnabled(GLenum cap)
5810{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005811 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005812
5813 try
5814 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005815 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005816
5817 if (context)
5818 {
5819 switch (cap)
5820 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005821 case GL_CULL_FACE: return context->isCullFaceEnabled();
5822 case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled();
5823 case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled();
5824 case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled();
5825 case GL_SCISSOR_TEST: return context->isScissorTestEnabled();
5826 case GL_STENCIL_TEST: return context->isStencilTestEnabled();
5827 case GL_DEPTH_TEST: return context->isDepthTestEnabled();
5828 case GL_BLEND: return context->isBlendEnabled();
5829 case GL_DITHER: return context->isDitherEnabled();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005830 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005831 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005832 }
5833 }
5834 }
5835 catch(std::bad_alloc&)
5836 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005837 return gl::error(GL_OUT_OF_MEMORY, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005838 }
5839
5840 return false;
5841}
5842
daniel@transgaming.comfe208882010-09-01 15:47:57 +00005843GLboolean __stdcall glIsFenceNV(GLuint fence)
5844{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005845 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00005846
5847 try
5848 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005849 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00005850
5851 if (context)
5852 {
5853 gl::Fence *fenceObject = context->getFence(fence);
5854
5855 if (fenceObject == NULL)
5856 {
5857 return GL_FALSE;
5858 }
5859
5860 return fenceObject->isFence();
5861 }
5862 }
5863 catch(std::bad_alloc&)
5864 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005865 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00005866 }
5867
5868 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00005869}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00005870
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005871GLboolean __stdcall glIsFramebuffer(GLuint framebuffer)
5872{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005873 EVENT("(GLuint framebuffer = %d)", framebuffer);
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
5879 if (context && framebuffer)
5880 {
5881 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
5882
5883 if (framebufferObject)
5884 {
5885 return GL_TRUE;
5886 }
5887 }
5888 }
5889 catch(std::bad_alloc&)
5890 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005891 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005892 }
5893
5894 return GL_FALSE;
5895}
5896
5897GLboolean __stdcall glIsProgram(GLuint program)
5898{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005899 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005900
5901 try
5902 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005903 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005904
5905 if (context && program)
5906 {
5907 gl::Program *programObject = context->getProgram(program);
5908
5909 if (programObject)
5910 {
5911 return GL_TRUE;
5912 }
5913 }
5914 }
5915 catch(std::bad_alloc&)
5916 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005917 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005918 }
5919
5920 return GL_FALSE;
5921}
5922
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00005923GLboolean __stdcall glIsQueryEXT(GLuint id)
5924{
5925 EVENT("(GLuint id = %d)", id);
5926
5927 try
5928 {
5929 if (id == 0)
5930 {
5931 return GL_FALSE;
5932 }
5933
5934 gl::Context *context = gl::getNonLostContext();
5935
5936 if (context)
5937 {
5938 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
5939
5940 if (queryObject)
5941 {
5942 return GL_TRUE;
5943 }
5944 }
5945 }
5946 catch(std::bad_alloc&)
5947 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005948 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00005949 }
5950
5951 return GL_FALSE;
5952}
5953
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005954GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer)
5955{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005956 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005957
5958 try
5959 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005960 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005961
5962 if (context && renderbuffer)
5963 {
5964 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
5965
5966 if (renderbufferObject)
5967 {
5968 return GL_TRUE;
5969 }
5970 }
5971 }
5972 catch(std::bad_alloc&)
5973 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005974 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005975 }
5976
5977 return GL_FALSE;
5978}
5979
5980GLboolean __stdcall glIsShader(GLuint shader)
5981{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005982 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005983
5984 try
5985 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005986 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005987
5988 if (context && shader)
5989 {
5990 gl::Shader *shaderObject = context->getShader(shader);
5991
5992 if (shaderObject)
5993 {
5994 return GL_TRUE;
5995 }
5996 }
5997 }
5998 catch(std::bad_alloc&)
5999 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006000 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006001 }
6002
6003 return GL_FALSE;
6004}
6005
6006GLboolean __stdcall glIsTexture(GLuint texture)
6007{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006008 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006009
6010 try
6011 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006012 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006013
6014 if (context && texture)
6015 {
6016 gl::Texture *textureObject = context->getTexture(texture);
6017
6018 if (textureObject)
6019 {
6020 return GL_TRUE;
6021 }
6022 }
6023 }
6024 catch(std::bad_alloc&)
6025 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006026 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006027 }
6028
6029 return GL_FALSE;
6030}
6031
6032void __stdcall glLineWidth(GLfloat width)
6033{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006034 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006035
6036 try
6037 {
6038 if (width <= 0.0f)
6039 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006040 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006041 }
6042
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006043 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00006044
6045 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006046 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006047 context->setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006048 }
6049 }
6050 catch(std::bad_alloc&)
6051 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006052 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006053 }
6054}
6055
6056void __stdcall glLinkProgram(GLuint program)
6057{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006058 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006059
6060 try
6061 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006062 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006063
6064 if (context)
6065 {
6066 gl::Program *programObject = context->getProgram(program);
6067
6068 if (!programObject)
6069 {
daniel@transgaming.com277b7142010-04-13 03:26:44 +00006070 if (context->getShader(program))
6071 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006072 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com277b7142010-04-13 03:26:44 +00006073 }
6074 else
6075 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006076 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com277b7142010-04-13 03:26:44 +00006077 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006078 }
6079
daniel@transgaming.com95d29422012-07-24 18:36:10 +00006080 context->linkProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006081 }
6082 }
6083 catch(std::bad_alloc&)
6084 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006085 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006086 }
6087}
6088
6089void __stdcall glPixelStorei(GLenum pname, GLint param)
6090{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006091 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006092
6093 try
6094 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006095 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006096
6097 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006098 {
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006099 switch (pname)
6100 {
6101 case GL_UNPACK_ALIGNMENT:
6102 if (param != 1 && param != 2 && param != 4 && param != 8)
6103 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006104 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006105 }
6106
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006107 context->setUnpackAlignment(param);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006108 break;
6109
6110 case GL_PACK_ALIGNMENT:
6111 if (param != 1 && param != 2 && param != 4 && param != 8)
6112 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006113 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006114 }
6115
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006116 context->setPackAlignment(param);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006117 break;
6118
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00006119 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
6120 context->setPackReverseRowOrder(param != 0);
6121 break;
6122
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00006123 case GL_UNPACK_IMAGE_HEIGHT:
6124 case GL_UNPACK_SKIP_IMAGES:
6125 case GL_UNPACK_ROW_LENGTH:
6126 case GL_UNPACK_SKIP_ROWS:
6127 case GL_UNPACK_SKIP_PIXELS:
6128 case GL_PACK_ROW_LENGTH:
6129 case GL_PACK_SKIP_ROWS:
6130 case GL_PACK_SKIP_PIXELS:
6131 if (context->getClientVersion() < 3)
6132 {
6133 return gl::error(GL_INVALID_ENUM);
6134 }
6135 UNIMPLEMENTED();
6136 break;
6137
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006138 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006139 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006140 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006141 }
6142 }
6143 catch(std::bad_alloc&)
6144 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006145 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006146 }
6147}
6148
6149void __stdcall glPolygonOffset(GLfloat factor, GLfloat units)
6150{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006151 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006152
6153 try
6154 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006155 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comaede6302010-04-29 03:35:48 +00006156
6157 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006158 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006159 context->setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006160 }
6161 }
6162 catch(std::bad_alloc&)
6163 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006164 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006165 }
6166}
6167
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006168void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
6169 GLenum format, GLenum type, GLsizei bufSize,
6170 GLvoid *data)
6171{
6172 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
6173 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
6174 x, y, width, height, format, type, bufSize, data);
6175
6176 try
6177 {
6178 if (width < 0 || height < 0 || bufSize < 0)
6179 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006180 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006181 }
6182
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006183 gl::Context *context = gl::getNonLostContext();
6184
6185 if (context)
6186 {
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006187 GLint currentInternalFormat;
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006188 GLenum currentFormat, currentType;
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006189
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006190 // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound,
6191 // and attempting to read back if that's the case is an error. The error will be registered
6192 // by getCurrentReadFormat.
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006193 if (!context->getCurrentReadFormatType(&currentInternalFormat, &currentFormat, &currentType))
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006194 return;
6195
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006196 bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) :
6197 validES3ReadFormatType(currentInternalFormat, format, type);
6198
6199 if (!(currentFormat == format && currentType == type) && !validReadFormat)
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006200 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006201 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006202 }
6203
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006204 context->readPixels(x, y, width, height, format, type, &bufSize, data);
6205 }
6206 }
6207 catch(std::bad_alloc&)
6208 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006209 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006210 }
6211}
6212
6213void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
6214 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006215{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006216 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006217 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00006218 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006219
6220 try
6221 {
6222 if (width < 0 || height < 0)
6223 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006224 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006225 }
6226
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006227 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006228
6229 if (context)
6230 {
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006231 GLint currentInternalFormat;
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006232 GLenum currentFormat, currentType;
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006233
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006234 // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound,
6235 // and attempting to read back if that's the case is an error. The error will be registered
6236 // by getCurrentReadFormat.
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006237 if (!context->getCurrentReadFormatType(&currentInternalFormat, &currentFormat, &currentType))
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006238 return;
6239
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006240 bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) :
6241 validES3ReadFormatType(currentInternalFormat, format, type);
6242
6243 if (!(currentFormat == format && currentType == type) && !validReadFormat)
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006244 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006245 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006246 }
6247
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006248 context->readPixels(x, y, width, height, format, type, NULL, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006249 }
6250 }
6251 catch(std::bad_alloc&)
6252 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006253 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006254 }
6255}
6256
6257void __stdcall glReleaseShaderCompiler(void)
6258{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006259 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006260
6261 try
6262 {
6263 gl::Shader::releaseCompiler();
6264 }
6265 catch(std::bad_alloc&)
6266 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006267 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006268 }
6269}
6270
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00006271void __stdcall glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006272{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006273 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 +00006274 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006275
6276 try
6277 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006278 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006279
6280 if (context)
6281 {
Geoff Lang2e1dcd52013-05-29 10:34:08 -04006282 if (!validateRenderbufferStorageParameters(context, target, samples, internalformat,
6283 width, height, true))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006284 {
Geoff Lang2e1dcd52013-05-29 10:34:08 -04006285 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006286 }
shannon.woods%transgaming.com@gtempaccount.com8dce6512013-04-13 03:42:19 +00006287
6288 context->setRenderbufferStorage(width, height, internalformat, samples);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006289 }
6290 }
6291 catch(std::bad_alloc&)
6292 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006293 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006294 }
6295}
6296
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00006297void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
6298{
6299 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
6300}
6301
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006302void __stdcall glSampleCoverage(GLclampf value, GLboolean invert)
6303{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006304 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006305
6306 try
6307 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006308 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006309
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006310 if (context)
6311 {
daniel@transgaming.coma36f98e2010-05-18 18:51:09 +00006312 context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006313 }
6314 }
6315 catch(std::bad_alloc&)
6316 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006317 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006318 }
6319}
6320
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006321void __stdcall glSetFenceNV(GLuint fence, GLenum condition)
6322{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006323 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006324
6325 try
6326 {
6327 if (condition != GL_ALL_COMPLETED_NV)
6328 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006329 return gl::error(GL_INVALID_ENUM);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006330 }
6331
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006332 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006333
6334 if (context)
6335 {
6336 gl::Fence *fenceObject = context->getFence(fence);
6337
6338 if (fenceObject == NULL)
6339 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006340 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006341 }
6342
6343 fenceObject->setFence(condition);
6344 }
6345 }
6346 catch(std::bad_alloc&)
6347 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006348 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006349 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006350}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006351
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006352void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
6353{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006354 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 +00006355
6356 try
6357 {
6358 if (width < 0 || height < 0)
6359 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006360 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006361 }
6362
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006363 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006364
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006365 if (context)
6366 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006367 context->setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006368 }
6369 }
6370 catch(std::bad_alloc&)
6371 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006372 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006373 }
6374}
6375
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006376void __stdcall glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006377{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006378 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006379 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00006380 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006381
6382 try
6383 {
daniel@transgaming.comd1f667f2010-04-29 03:38:52 +00006384 // No binary shader formats are supported.
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006385 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006386 }
6387 catch(std::bad_alloc&)
6388 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006389 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006390 }
6391}
6392
shannon.woods%transgaming.com@gtempaccount.com5f339332013-04-13 03:29:02 +00006393void __stdcall glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006394{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006395 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 +00006396 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006397
6398 try
6399 {
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006400 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006401 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006402 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006403 }
6404
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006405 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006406
6407 if (context)
6408 {
6409 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006410
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006411 if (!shaderObject)
6412 {
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006413 if (context->getProgram(shader))
6414 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006415 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006416 }
6417 else
6418 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006419 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006420 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006421 }
6422
6423 shaderObject->setSource(count, string, length);
6424 }
6425 }
6426 catch(std::bad_alloc&)
6427 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006428 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006429 }
6430}
6431
6432void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask)
6433{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006434 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006435}
6436
6437void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
6438{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006439 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 +00006440
6441 try
6442 {
6443 switch (face)
6444 {
6445 case GL_FRONT:
6446 case GL_BACK:
6447 case GL_FRONT_AND_BACK:
6448 break;
6449 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006450 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006451 }
6452
6453 switch (func)
6454 {
6455 case GL_NEVER:
6456 case GL_ALWAYS:
6457 case GL_LESS:
6458 case GL_LEQUAL:
6459 case GL_EQUAL:
6460 case GL_GEQUAL:
6461 case GL_GREATER:
6462 case GL_NOTEQUAL:
6463 break;
6464 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006465 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006466 }
6467
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006468 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006469
6470 if (context)
6471 {
6472 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
6473 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006474 context->setStencilParams(func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006475 }
6476
6477 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
6478 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006479 context->setStencilBackParams(func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006480 }
6481 }
6482 }
6483 catch(std::bad_alloc&)
6484 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006485 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006486 }
6487}
6488
6489void __stdcall glStencilMask(GLuint mask)
6490{
6491 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
6492}
6493
6494void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask)
6495{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006496 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006497
6498 try
6499 {
6500 switch (face)
6501 {
6502 case GL_FRONT:
6503 case GL_BACK:
6504 case GL_FRONT_AND_BACK:
6505 break;
6506 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006507 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006508 }
6509
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006510 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006511
6512 if (context)
6513 {
6514 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
6515 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006516 context->setStencilWritemask(mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006517 }
6518
6519 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
6520 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006521 context->setStencilBackWritemask(mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006522 }
6523 }
6524 }
6525 catch(std::bad_alloc&)
6526 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006527 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006528 }
6529}
6530
6531void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
6532{
6533 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
6534}
6535
6536void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
6537{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006538 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 +00006539 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006540
6541 try
6542 {
6543 switch (face)
6544 {
6545 case GL_FRONT:
6546 case GL_BACK:
6547 case GL_FRONT_AND_BACK:
6548 break;
6549 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006550 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006551 }
6552
6553 switch (fail)
6554 {
6555 case GL_ZERO:
6556 case GL_KEEP:
6557 case GL_REPLACE:
6558 case GL_INCR:
6559 case GL_DECR:
6560 case GL_INVERT:
6561 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006562 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006563 break;
6564 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006565 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006566 }
6567
6568 switch (zfail)
6569 {
6570 case GL_ZERO:
6571 case GL_KEEP:
6572 case GL_REPLACE:
6573 case GL_INCR:
6574 case GL_DECR:
6575 case GL_INVERT:
6576 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006577 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006578 break;
6579 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006580 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006581 }
6582
6583 switch (zpass)
6584 {
6585 case GL_ZERO:
6586 case GL_KEEP:
6587 case GL_REPLACE:
6588 case GL_INCR:
6589 case GL_DECR:
6590 case GL_INVERT:
6591 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006592 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006593 break;
6594 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006595 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006596 }
6597
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006598 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006599
6600 if (context)
6601 {
6602 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
6603 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006604 context->setStencilOperations(fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006605 }
6606
6607 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
6608 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006609 context->setStencilBackOperations(fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006610 }
6611 }
6612 }
6613 catch(std::bad_alloc&)
6614 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006615 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006616 }
6617}
6618
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006619GLboolean __stdcall glTestFenceNV(GLuint fence)
6620{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006621 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006622
6623 try
6624 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006625 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006626
6627 if (context)
6628 {
6629 gl::Fence *fenceObject = context->getFence(fence);
6630
6631 if (fenceObject == NULL)
6632 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006633 return gl::error(GL_INVALID_OPERATION, GL_TRUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006634 }
6635
6636 return fenceObject->testFence();
6637 }
6638 }
6639 catch(std::bad_alloc&)
6640 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006641 gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006642 }
6643
6644 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006645}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006646
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006647void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
6648 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006649{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006650 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 +00006651 "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 +00006652 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006653
6654 try
6655 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006656 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006657
6658 if (context)
6659 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006660 if (context->getClientVersion() < 3 &&
6661 !validateES2TexImageParameters(context, target, level, internalformat, false, false,
6662 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com32b11442011-11-19 02:42:48 +00006663 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006664 return;
6665 }
6666
6667 if (context->getClientVersion() >= 3 &&
6668 !validateES3TexImageParameters(context, target, level, internalformat, false, false,
6669 0, 0, 0, width, height, 1, border, format, type))
6670 {
6671 return;
daniel@transgaming.com32b11442011-11-19 02:42:48 +00006672 }
6673
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006674 switch (target)
6675 {
6676 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006677 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006678 gl::Texture2D *texture = context->getTexture2D();
6679 texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006680 }
6681 break;
6682 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006683 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006684 gl::TextureCubeMap *texture = context->getTextureCubeMap();
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +00006685 texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006686 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006687 break;
6688 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
6689 {
6690 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6691 texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6692 }
6693 break;
6694 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
6695 {
6696 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6697 texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6698 }
6699 break;
6700 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
6701 {
6702 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6703 texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6704 }
6705 break;
6706 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
6707 {
6708 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6709 texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6710 }
6711 break;
6712 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
6713 {
6714 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6715 texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6716 }
6717 break;
6718 default: UNREACHABLE();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006719 }
6720 }
6721 }
6722 catch(std::bad_alloc&)
6723 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006724 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006725 }
6726}
6727
6728void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param)
6729{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006730 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
6731
6732 try
6733 {
6734 gl::Context *context = gl::getNonLostContext();
6735
6736 if (context)
6737 {
6738 gl::Texture *texture;
6739
6740 switch (target)
6741 {
6742 case GL_TEXTURE_2D:
6743 texture = context->getTexture2D();
6744 break;
6745 case GL_TEXTURE_CUBE_MAP:
6746 texture = context->getTextureCubeMap();
6747 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00006748 case GL_TEXTURE_3D:
6749 if (context->getClientVersion() < 3)
6750 {
6751 return gl::error(GL_INVALID_ENUM);
6752 }
6753 texture = context->getTexture3D();
shannon.woods%transgaming.com@gtempaccount.com90dbc442013-04-13 03:46:14 +00006754 case GL_TEXTURE_2D_ARRAY:
6755 if (context->getClientVersion() < 3)
6756 {
6757 return gl::error(GL_INVALID_ENUM);
6758 }
6759 texture = context->getTexture2DArray();
6760 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006761 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006762 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006763 }
6764
6765 switch (pname)
6766 {
6767 case GL_TEXTURE_WRAP_S:
6768 if (!texture->setWrapS((GLenum)param))
6769 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006770 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006771 }
6772 break;
6773 case GL_TEXTURE_WRAP_T:
6774 if (!texture->setWrapT((GLenum)param))
6775 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006776 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006777 }
6778 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00006779 case GL_TEXTURE_WRAP_R:
6780 if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param))
6781 {
6782 return gl::error(GL_INVALID_ENUM);
6783 }
6784 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006785 case GL_TEXTURE_MIN_FILTER:
6786 if (!texture->setMinFilter((GLenum)param))
6787 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006788 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006789 }
6790 break;
6791 case GL_TEXTURE_MAG_FILTER:
6792 if (!texture->setMagFilter((GLenum)param))
6793 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006794 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006795 }
6796 break;
6797 case GL_TEXTURE_USAGE_ANGLE:
6798 if (!texture->setUsage((GLenum)param))
6799 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006800 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006801 }
6802 break;
6803 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
6804 if (!context->supportsTextureFilterAnisotropy())
6805 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006806 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006807 }
6808 if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()))
6809 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006810 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006811 }
6812 break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00006813
6814 case GL_TEXTURE_MIN_LOD:
6815 case GL_TEXTURE_MAX_LOD:
6816 if (context->getClientVersion() < 3)
6817 {
6818 return gl::error(GL_INVALID_ENUM);
6819 }
6820 UNIMPLEMENTED();
6821 break;
6822
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006823 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006824 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006825 }
6826 }
6827 }
6828 catch(std::bad_alloc&)
6829 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006830 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006831 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006832}
6833
6834void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
6835{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006836 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006837}
6838
6839void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param)
6840{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006841 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006842
6843 try
6844 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006845 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006846
6847 if (context)
6848 {
6849 gl::Texture *texture;
6850
6851 switch (target)
6852 {
6853 case GL_TEXTURE_2D:
6854 texture = context->getTexture2D();
6855 break;
6856 case GL_TEXTURE_CUBE_MAP:
6857 texture = context->getTextureCubeMap();
6858 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00006859 case GL_TEXTURE_3D:
6860 if (context->getClientVersion() < 3)
6861 {
6862 return gl::error(GL_INVALID_ENUM);
6863 }
6864 texture = context->getTexture3D();
6865 break;
shannon.woods%transgaming.com@gtempaccount.com90dbc442013-04-13 03:46:14 +00006866 case GL_TEXTURE_2D_ARRAY:
6867 if (context->getClientVersion() < 3)
6868 {
6869 return gl::error(GL_INVALID_ENUM);
6870 }
6871 texture = context->getTexture2DArray();
6872 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006873 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006874 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006875 }
6876
6877 switch (pname)
6878 {
6879 case GL_TEXTURE_WRAP_S:
6880 if (!texture->setWrapS((GLenum)param))
6881 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006882 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006883 }
6884 break;
6885 case GL_TEXTURE_WRAP_T:
6886 if (!texture->setWrapT((GLenum)param))
6887 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006888 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006889 }
6890 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00006891 case GL_TEXTURE_WRAP_R:
6892 if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param))
6893 {
6894 return gl::error(GL_INVALID_ENUM);
6895 }
6896 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006897 case GL_TEXTURE_MIN_FILTER:
6898 if (!texture->setMinFilter((GLenum)param))
6899 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006900 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006901 }
6902 break;
6903 case GL_TEXTURE_MAG_FILTER:
6904 if (!texture->setMagFilter((GLenum)param))
6905 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006906 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006907 }
6908 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00006909 case GL_TEXTURE_USAGE_ANGLE:
6910 if (!texture->setUsage((GLenum)param))
6911 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006912 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00006913 }
6914 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006915 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
6916 if (!context->supportsTextureFilterAnisotropy())
6917 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006918 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006919 }
6920 if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()))
6921 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006922 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006923 }
6924 break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00006925
6926 case GL_TEXTURE_SWIZZLE_R:
6927 case GL_TEXTURE_SWIZZLE_G:
6928 case GL_TEXTURE_SWIZZLE_B:
6929 case GL_TEXTURE_SWIZZLE_A:
6930 case GL_TEXTURE_BASE_LEVEL:
6931 case GL_TEXTURE_MAX_LEVEL:
6932 case GL_TEXTURE_COMPARE_MODE:
6933 case GL_TEXTURE_COMPARE_FUNC:
6934 if (context->getClientVersion() < 3)
6935 {
6936 return gl::error(GL_INVALID_ENUM);
6937 }
6938 UNIMPLEMENTED();
6939 break;
6940
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006941 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006942 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006943 }
6944 }
6945 }
6946 catch(std::bad_alloc&)
6947 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006948 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006949 }
6950}
6951
6952void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
6953{
6954 glTexParameteri(target, pname, *params);
6955}
6956
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00006957void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
6958{
6959 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
6960 target, levels, internalformat, width, height);
6961
6962 try
6963 {
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00006964 gl::Context *context = gl::getNonLostContext();
6965
6966 if (context)
6967 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006968 if (context->getClientVersion() < 3 &&
6969 !validateES2TexStorageParameters(context, target, levels, internalformat, width, height))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006970 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006971 return;
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006972 }
6973
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006974 if (context->getClientVersion() >= 3 &&
6975 !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006976 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006977 return;
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006978 }
6979
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006980 switch (target)
6981 {
6982 case GL_TEXTURE_2D:
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006983 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006984 gl::Texture2D *texture2d = context->getTexture2D();
6985 texture2d->storage(levels, internalformat, width, height);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006986 }
6987 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006988
6989 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
6990 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
6991 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
6992 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
6993 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
6994 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006995 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006996 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
6997 textureCube->storage(levels, internalformat, width);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006998 }
6999 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00007000
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00007001 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007002 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00007003 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00007004 }
7005 }
7006 catch(std::bad_alloc&)
7007 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007008 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00007009 }
7010}
7011
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00007012void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
7013 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007014{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007015 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007016 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00007017 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007018 target, level, xoffset, yoffset, width, height, format, type, pixels);
7019
7020 try
7021 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007022 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007023
7024 if (context)
7025 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007026 if (context->getClientVersion() < 3 &&
7027 !validateES2TexImageParameters(context, target, level, GL_NONE, false, true,
7028 0, 0, width, height, 0, format, type, pixels))
daniel@transgaming.com1d2d3c42012-05-31 01:14:15 +00007029 {
7030 return;
7031 }
7032
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007033 if (context->getClientVersion() >= 3 &&
7034 !validateES3TexImageParameters(context, target, level, GL_NONE, false, true,
7035 0, 0, 0, width, height, 1, 0, format, type))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007036 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007037 return;
7038 }
7039
7040 switch (target)
7041 {
7042 case GL_TEXTURE_2D:
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007043 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007044 gl::Texture2D *texture = context->getTexture2D();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00007045 texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007046 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007047 break;
7048
7049 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
7050 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
7051 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
7052 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
7053 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
7054 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007055 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007056 gl::TextureCubeMap *texture = context->getTextureCubeMap();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00007057 texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007058 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007059 break;
7060
7061 default:
7062 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007063 }
7064 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007065 }
7066 catch(std::bad_alloc&)
7067 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007068 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007069 }
7070}
7071
7072void __stdcall glUniform1f(GLint location, GLfloat x)
7073{
7074 glUniform1fv(location, 1, &x);
7075}
7076
7077void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
7078{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007079 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007080
7081 try
7082 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007083 if (count < 0)
7084 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007085 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007086 }
7087
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007088 if (location == -1)
7089 {
7090 return;
7091 }
7092
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007093 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007094
7095 if (context)
7096 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007097 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007098 if (!programBinary)
7099 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007100 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007101 }
7102
7103 if (!programBinary->setUniform1fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007104 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007105 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007106 }
7107 }
7108 }
7109 catch(std::bad_alloc&)
7110 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007111 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007112 }
7113}
7114
7115void __stdcall glUniform1i(GLint location, GLint x)
7116{
7117 glUniform1iv(location, 1, &x);
7118}
7119
7120void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v)
7121{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007122 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007123
7124 try
7125 {
7126 if (count < 0)
7127 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007128 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007129 }
7130
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007131 if (location == -1)
7132 {
7133 return;
7134 }
7135
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007136 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007137
7138 if (context)
7139 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007140 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007141 if (!programBinary)
7142 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007143 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007144 }
7145
7146 if (!programBinary->setUniform1iv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007147 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007148 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007149 }
7150 }
7151 }
7152 catch(std::bad_alloc&)
7153 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007154 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007155 }
7156}
7157
7158void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y)
7159{
7160 GLfloat xy[2] = {x, y};
7161
7162 glUniform2fv(location, 1, (GLfloat*)&xy);
7163}
7164
7165void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
7166{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007167 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007168
7169 try
7170 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007171 if (count < 0)
7172 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007173 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007174 }
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007175
7176 if (location == -1)
7177 {
7178 return;
7179 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007180
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007181 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007182
7183 if (context)
7184 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007185 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007186 if (!programBinary)
7187 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007188 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007189 }
7190
7191 if (!programBinary->setUniform2fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007192 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007193 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007194 }
7195 }
7196 }
7197 catch(std::bad_alloc&)
7198 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007199 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007200 }
7201}
7202
7203void __stdcall glUniform2i(GLint location, GLint x, GLint y)
7204{
7205 GLint xy[4] = {x, y};
7206
7207 glUniform2iv(location, 1, (GLint*)&xy);
7208}
7209
7210void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v)
7211{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007212 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007213
7214 try
7215 {
7216 if (count < 0)
7217 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007218 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007219 }
7220
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007221 if (location == -1)
7222 {
7223 return;
7224 }
7225
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007226 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007227
7228 if (context)
7229 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007230 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007231 if (!programBinary)
7232 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007233 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007234 }
7235
7236 if (!programBinary->setUniform2iv(location, count, v))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007237 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007238 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007239 }
7240 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007241 }
7242 catch(std::bad_alloc&)
7243 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007244 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007245 }
7246}
7247
7248void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
7249{
7250 GLfloat xyz[3] = {x, y, z};
7251
7252 glUniform3fv(location, 1, (GLfloat*)&xyz);
7253}
7254
7255void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
7256{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007257 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007258
7259 try
7260 {
7261 if (count < 0)
7262 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007263 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007264 }
7265
7266 if (location == -1)
7267 {
7268 return;
7269 }
7270
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007271 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007272
7273 if (context)
7274 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007275 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007276 if (!programBinary)
7277 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007278 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007279 }
7280
7281 if (!programBinary->setUniform3fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007282 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007283 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007284 }
7285 }
7286 }
7287 catch(std::bad_alloc&)
7288 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007289 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007290 }
7291}
7292
7293void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z)
7294{
7295 GLint xyz[3] = {x, y, z};
7296
7297 glUniform3iv(location, 1, (GLint*)&xyz);
7298}
7299
7300void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v)
7301{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007302 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007303
7304 try
7305 {
7306 if (count < 0)
7307 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007308 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007309 }
7310
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007311 if (location == -1)
7312 {
7313 return;
7314 }
7315
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007316 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007317
7318 if (context)
7319 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007320 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007321 if (!programBinary)
7322 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007323 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007324 }
7325
7326 if (!programBinary->setUniform3iv(location, count, v))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007327 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007328 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007329 }
7330 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007331 }
7332 catch(std::bad_alloc&)
7333 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007334 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007335 }
7336}
7337
7338void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
7339{
7340 GLfloat xyzw[4] = {x, y, z, w};
7341
7342 glUniform4fv(location, 1, (GLfloat*)&xyzw);
7343}
7344
7345void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
7346{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007347 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007348
7349 try
7350 {
7351 if (count < 0)
7352 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007353 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007354 }
7355
7356 if (location == -1)
7357 {
7358 return;
7359 }
7360
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007361 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007362
7363 if (context)
7364 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007365 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007366 if (!programBinary)
7367 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007368 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007369 }
7370
7371 if (!programBinary->setUniform4fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007372 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007373 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007374 }
7375 }
7376 }
7377 catch(std::bad_alloc&)
7378 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007379 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007380 }
7381}
7382
7383void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
7384{
7385 GLint xyzw[4] = {x, y, z, w};
7386
7387 glUniform4iv(location, 1, (GLint*)&xyzw);
7388}
7389
7390void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v)
7391{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007392 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007393
7394 try
7395 {
7396 if (count < 0)
7397 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007398 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007399 }
7400
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007401 if (location == -1)
7402 {
7403 return;
7404 }
7405
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007406 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007407
7408 if (context)
7409 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007410 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007411 if (!programBinary)
7412 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007413 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007414 }
7415
7416 if (!programBinary->setUniform4iv(location, count, v))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007417 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007418 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007419 }
7420 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007421 }
7422 catch(std::bad_alloc&)
7423 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007424 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007425 }
7426}
7427
7428void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
7429{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007430 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007431 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007432
7433 try
7434 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007435 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007436 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007437 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007438 }
7439
7440 if (location == -1)
7441 {
7442 return;
7443 }
7444
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007445 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007446
7447 if (context)
7448 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007449 if (transpose != GL_FALSE && context->getClientVersion() < 3)
7450 {
7451 return gl::error(GL_INVALID_VALUE);
7452 }
7453
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007454 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007455 if (!programBinary)
7456 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007457 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007458 }
7459
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007460 if (!programBinary->setUniformMatrix2fv(location, count, transpose, value))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007461 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007462 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007463 }
7464 }
7465 }
7466 catch(std::bad_alloc&)
7467 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007468 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007469 }
7470}
7471
7472void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
7473{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007474 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007475 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007476
7477 try
7478 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007479 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007480 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007481 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007482 }
7483
7484 if (location == -1)
7485 {
7486 return;
7487 }
7488
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007489 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007490
7491 if (context)
7492 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007493 if (transpose != GL_FALSE && context->getClientVersion() < 3)
7494 {
7495 return gl::error(GL_INVALID_VALUE);
7496 }
7497
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007498 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007499 if (!programBinary)
7500 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007501 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007502 }
7503
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007504 if (!programBinary->setUniformMatrix3fv(location, count, transpose, value))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007505 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007506 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007507 }
7508 }
7509 }
7510 catch(std::bad_alloc&)
7511 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007512 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007513 }
7514}
7515
7516void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
7517{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007518 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007519 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007520
7521 try
7522 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007523 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007524 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007525 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007526 }
7527
7528 if (location == -1)
7529 {
7530 return;
7531 }
7532
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007533 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007534
7535 if (context)
7536 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007537 if (transpose != GL_FALSE && context->getClientVersion() < 3)
7538 {
7539 return gl::error(GL_INVALID_VALUE);
7540 }
7541
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007542 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007543 if (!programBinary)
7544 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007545 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007546 }
7547
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007548 if (!programBinary->setUniformMatrix4fv(location, count, transpose, value))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007549 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007550 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007551 }
7552 }
7553 }
7554 catch(std::bad_alloc&)
7555 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007556 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007557 }
7558}
7559
7560void __stdcall glUseProgram(GLuint program)
7561{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007562 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007563
7564 try
7565 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007566 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007567
7568 if (context)
7569 {
7570 gl::Program *programObject = context->getProgram(program);
7571
daniel@transgaming.comc8478202010-04-13 19:53:35 +00007572 if (!programObject && program != 0)
7573 {
7574 if (context->getShader(program))
7575 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007576 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comc8478202010-04-13 19:53:35 +00007577 }
7578 else
7579 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007580 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comc8478202010-04-13 19:53:35 +00007581 }
7582 }
7583
daniel@transgaming.com716056c2012-07-24 18:38:59 +00007584 if (program != 0 && !programObject->isLinked())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007585 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007586 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007587 }
7588
7589 context->useProgram(program);
7590 }
7591 }
7592 catch(std::bad_alloc&)
7593 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007594 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007595 }
7596}
7597
7598void __stdcall glValidateProgram(GLuint program)
7599{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007600 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007601
7602 try
7603 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007604 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007605
7606 if (context)
7607 {
7608 gl::Program *programObject = context->getProgram(program);
7609
7610 if (!programObject)
7611 {
7612 if (context->getShader(program))
7613 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007614 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007615 }
7616 else
7617 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007618 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007619 }
7620 }
7621
apatrick@chromium.org253b8d22012-06-22 19:27:21 +00007622 programObject->validate();
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007623 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007624 }
7625 catch(std::bad_alloc&)
7626 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007627 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007628 }
7629}
7630
7631void __stdcall glVertexAttrib1f(GLuint index, GLfloat x)
7632{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007633 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007634
7635 try
7636 {
7637 if (index >= gl::MAX_VERTEX_ATTRIBS)
7638 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007639 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007640 }
7641
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007642 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007643
7644 if (context)
7645 {
7646 GLfloat vals[4] = { x, 0, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007647 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007648 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007649 }
7650 catch(std::bad_alloc&)
7651 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007652 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007653 }
7654}
7655
7656void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values)
7657{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007658 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007659
7660 try
7661 {
7662 if (index >= gl::MAX_VERTEX_ATTRIBS)
7663 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007664 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007665 }
7666
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007667 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007668
7669 if (context)
7670 {
7671 GLfloat vals[4] = { values[0], 0, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007672 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007673 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007674 }
7675 catch(std::bad_alloc&)
7676 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007677 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007678 }
7679}
7680
7681void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
7682{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007683 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007684
7685 try
7686 {
7687 if (index >= gl::MAX_VERTEX_ATTRIBS)
7688 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007689 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007690 }
7691
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007692 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007693
7694 if (context)
7695 {
7696 GLfloat vals[4] = { x, y, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007697 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007698 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007699 }
7700 catch(std::bad_alloc&)
7701 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007702 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007703 }
7704}
7705
7706void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values)
7707{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007708 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007709
7710 try
7711 {
7712 if (index >= gl::MAX_VERTEX_ATTRIBS)
7713 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007714 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007715 }
7716
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007717 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007718
7719 if (context)
7720 {
7721 GLfloat vals[4] = { values[0], values[1], 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007722 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007723 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007724 }
7725 catch(std::bad_alloc&)
7726 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007727 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007728 }
7729}
7730
7731void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
7732{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007733 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 +00007734
7735 try
7736 {
7737 if (index >= gl::MAX_VERTEX_ATTRIBS)
7738 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007739 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007740 }
7741
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007742 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007743
7744 if (context)
7745 {
7746 GLfloat vals[4] = { x, y, z, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007747 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007748 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007749 }
7750 catch(std::bad_alloc&)
7751 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007752 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007753 }
7754}
7755
7756void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values)
7757{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007758 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007759
7760 try
7761 {
7762 if (index >= gl::MAX_VERTEX_ATTRIBS)
7763 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007764 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007765 }
7766
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007767 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007768
7769 if (context)
7770 {
7771 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007772 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007773 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007774 }
7775 catch(std::bad_alloc&)
7776 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007777 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007778 }
7779}
7780
7781void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
7782{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007783 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 +00007784
7785 try
7786 {
7787 if (index >= gl::MAX_VERTEX_ATTRIBS)
7788 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007789 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007790 }
7791
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007792 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007793
7794 if (context)
7795 {
7796 GLfloat vals[4] = { x, y, z, w };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007797 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007798 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007799 }
7800 catch(std::bad_alloc&)
7801 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007802 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007803 }
7804}
7805
7806void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values)
7807{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007808 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007809
7810 try
7811 {
7812 if (index >= gl::MAX_VERTEX_ATTRIBS)
7813 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007814 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007815 }
7816
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007817 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007818
7819 if (context)
7820 {
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007821 context->setVertexAttribf(index, values);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007822 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007823 }
7824 catch(std::bad_alloc&)
7825 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007826 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007827 }
7828}
7829
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00007830void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
7831{
7832 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
7833
7834 try
7835 {
7836 if (index >= gl::MAX_VERTEX_ATTRIBS)
7837 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007838 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00007839 }
7840
7841 gl::Context *context = gl::getNonLostContext();
7842
7843 if (context)
7844 {
7845 context->setVertexAttribDivisor(index, divisor);
7846 }
7847 }
7848 catch(std::bad_alloc&)
7849 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007850 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00007851 }
7852}
7853
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00007854void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007855{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007856 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007857 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007858 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007859
7860 try
7861 {
7862 if (index >= gl::MAX_VERTEX_ATTRIBS)
7863 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007864 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007865 }
7866
7867 if (size < 1 || size > 4)
7868 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007869 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007870 }
7871
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00007872 gl::Context *context = gl::getNonLostContext();
7873
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007874 switch (type)
7875 {
7876 case GL_BYTE:
7877 case GL_UNSIGNED_BYTE:
7878 case GL_SHORT:
7879 case GL_UNSIGNED_SHORT:
7880 case GL_FIXED:
7881 case GL_FLOAT:
7882 break;
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00007883 case GL_HALF_FLOAT:
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007884 case GL_INT:
7885 case GL_UNSIGNED_INT:
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00007886 case GL_INT_2_10_10_10_REV:
7887 case GL_UNSIGNED_INT_2_10_10_10_REV:
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00007888 if (context && context->getClientVersion() < 3)
7889 {
7890 return gl::error(GL_INVALID_ENUM);
7891 }
7892 else
7893 {
7894 break;
7895 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007896 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007897 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007898 }
7899
7900 if (stride < 0)
7901 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007902 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007903 }
7904
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00007905 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
7906 {
7907 return gl::error(GL_INVALID_OPERATION);
7908 }
7909
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007910 if (context)
7911 {
shannon.woods%transgaming.com@gtempaccount.com8de4e6a2013-04-13 03:37:44 +00007912 context->setVertexAttribState(index, context->getArrayBuffer(), size, type,
7913 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007914 }
7915 }
7916 catch(std::bad_alloc&)
7917 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007918 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007919 }
7920}
7921
7922void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
7923{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007924 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 +00007925
7926 try
7927 {
7928 if (width < 0 || height < 0)
7929 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007930 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007931 }
7932
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007933 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007934
7935 if (context)
7936 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00007937 context->setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007938 }
7939 }
7940 catch(std::bad_alloc&)
7941 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007942 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007943 }
7944}
7945
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007946// OpenGL ES 3.0 functions
7947
7948void __stdcall glReadBuffer(GLenum mode)
7949{
7950 EVENT("(GLenum mode = 0x%X)", mode);
7951
7952 try
7953 {
7954 gl::Context *context = gl::getNonLostContext();
7955
7956 if (context)
7957 {
7958 if (context->getClientVersion() < 3)
7959 {
7960 return gl::error(GL_INVALID_OPERATION);
7961 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007962
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007963 UNIMPLEMENTED();
7964 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007965 }
7966 catch(std::bad_alloc&)
7967 {
7968 return gl::error(GL_OUT_OF_MEMORY);
7969 }
7970}
7971
7972void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
7973{
7974 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
7975 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
7976
7977 try
7978 {
7979 gl::Context *context = gl::getNonLostContext();
7980
7981 if (context)
7982 {
7983 if (context->getClientVersion() < 3)
7984 {
7985 return gl::error(GL_INVALID_OPERATION);
7986 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007987
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007988 UNIMPLEMENTED();
7989 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007990 }
7991 catch(std::bad_alloc&)
7992 {
7993 return gl::error(GL_OUT_OF_MEMORY);
7994 }
7995}
7996
7997void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
7998{
7999 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
8000 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
8001 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
8002 target, level, internalformat, width, height, depth, border, format, type, pixels);
8003
8004 try
8005 {
8006 gl::Context *context = gl::getNonLostContext();
8007
8008 if (context)
8009 {
8010 if (context->getClientVersion() < 3)
8011 {
8012 return gl::error(GL_INVALID_OPERATION);
8013 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008014
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008015 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008016 if (!validateES3TexImageParameters(context, target, level, internalformat, false, false,
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008017 0, 0, 0, width, height, depth, border, format, type))
8018 {
8019 return;
8020 }
8021
8022 switch(target)
8023 {
8024 case GL_TEXTURE_3D:
8025 {
8026 gl::Texture3D *texture = context->getTexture3D();
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +00008027 texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackAlignment(), pixels);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008028 }
8029 break;
8030
8031 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008032 {
8033 gl::Texture2DArray *texture = context->getTexture2DArray();
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +00008034 texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackAlignment(), pixels);
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008035 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008036 break;
8037
8038 default:
8039 return gl::error(GL_INVALID_ENUM);
8040 }
8041 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008042 }
8043 catch(std::bad_alloc&)
8044 {
8045 return gl::error(GL_OUT_OF_MEMORY);
8046 }
8047}
8048
8049void __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)
8050{
8051 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
8052 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
8053 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
8054 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
8055
8056 try
8057 {
8058 gl::Context *context = gl::getNonLostContext();
8059
8060 if (context)
8061 {
8062 if (context->getClientVersion() < 3)
8063 {
8064 return gl::error(GL_INVALID_OPERATION);
8065 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008066
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008067 if (!pixels)
8068 {
8069 return gl::error(GL_INVALID_VALUE);
8070 }
8071
8072 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008073 if (!validateES3TexImageParameters(context, target, level, GL_NONE, false, true,
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008074 xoffset, yoffset, zoffset, width, height, depth, 0,
8075 format, type))
8076 {
8077 return;
8078 }
8079
8080 switch(target)
8081 {
8082 case GL_TEXTURE_3D:
8083 {
8084 gl::Texture3D *texture = context->getTexture3D();
8085 texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels);
8086 }
8087 break;
8088
8089 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008090 {
8091 gl::Texture2DArray *texture = context->getTexture2DArray();
8092 texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels);
8093 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008094 break;
8095
8096 default:
8097 return gl::error(GL_INVALID_ENUM);
8098 }
8099 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008100 }
8101 catch(std::bad_alloc&)
8102 {
8103 return gl::error(GL_OUT_OF_MEMORY);
8104 }
8105}
8106
8107void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
8108{
8109 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
8110 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
8111 target, level, xoffset, yoffset, zoffset, x, y, width, height);
8112
8113 try
8114 {
8115 gl::Context *context = gl::getNonLostContext();
8116
8117 if (context)
8118 {
8119 if (context->getClientVersion() < 3)
8120 {
8121 return gl::error(GL_INVALID_OPERATION);
8122 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008123
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008124 if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset,
8125 x, y, width, height, 0))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008126 {
8127 return;
8128 }
8129
8130 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
8131 gl::Texture *texture = NULL;
8132 switch (target)
8133 {
8134 case GL_TEXTURE_3D:
8135 texture = context->getTexture3D();
8136 break;
8137
8138 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008139 texture = context->getTexture2DArray();
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008140 break;
8141
8142 default:
8143 return gl::error(GL_INVALID_ENUM);
8144 }
8145
8146 texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
8147 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008148 }
8149 catch(std::bad_alloc&)
8150 {
8151 return gl::error(GL_OUT_OF_MEMORY);
8152 }
8153}
8154
8155void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
8156{
8157 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
8158 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
8159 "const GLvoid* data = 0x%0.8p)",
8160 target, level, internalformat, width, height, depth, border, imageSize, data);
8161
8162 try
8163 {
8164 gl::Context *context = gl::getNonLostContext();
8165
8166 if (context)
8167 {
8168 if (context->getClientVersion() < 3)
8169 {
8170 return gl::error(GL_INVALID_OPERATION);
8171 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008172
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00008173 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 +00008174 {
8175 return gl::error(GL_INVALID_VALUE);
8176 }
8177
8178 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008179 if (!validateES3TexImageParameters(context, target, level, internalformat, true, false,
8180 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008181 {
8182 return;
8183 }
8184
8185 switch(target)
8186 {
8187 case GL_TEXTURE_3D:
8188 {
8189 gl::Texture3D *texture = context->getTexture3D();
8190 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
8191 }
8192 break;
8193
8194 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008195 {
8196 gl::Texture2DArray *texture = context->getTexture2DArray();
8197 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
8198 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008199 break;
8200
8201 default:
8202 return gl::error(GL_INVALID_ENUM);
8203 }
8204 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008205 }
8206 catch(std::bad_alloc&)
8207 {
8208 return gl::error(GL_OUT_OF_MEMORY);
8209 }
8210}
8211
8212void __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)
8213{
8214 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
8215 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
8216 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
8217 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
8218
8219 try
8220 {
8221 gl::Context *context = gl::getNonLostContext();
8222
8223 if (context)
8224 {
8225 if (context->getClientVersion() < 3)
8226 {
8227 return gl::error(GL_INVALID_OPERATION);
8228 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008229
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00008230 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 +00008231 {
8232 return gl::error(GL_INVALID_VALUE);
8233 }
8234
8235 if (!data)
8236 {
8237 return gl::error(GL_INVALID_VALUE);
8238 }
8239
8240 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008241 if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true,
8242 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008243 {
8244 return;
8245 }
8246
8247 switch(target)
8248 {
8249 case GL_TEXTURE_3D:
8250 {
8251 gl::Texture3D *texture = context->getTexture3D();
8252 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
8253 format, imageSize, data);
8254 }
8255 break;
8256
8257 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008258 {
8259 gl::Texture2DArray *texture = context->getTexture2DArray();
8260 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
8261 format, imageSize, data);
8262 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008263 break;
8264
8265 default:
8266 return gl::error(GL_INVALID_ENUM);
8267 }
8268 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008269 }
8270 catch(std::bad_alloc&)
8271 {
8272 return gl::error(GL_OUT_OF_MEMORY);
8273 }
8274}
8275
8276void __stdcall glGenQueries(GLsizei n, GLuint* ids)
8277{
8278 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8279
8280 try
8281 {
8282 gl::Context *context = gl::getNonLostContext();
8283
8284 if (context)
8285 {
8286 if (context->getClientVersion() < 3)
8287 {
8288 return gl::error(GL_INVALID_OPERATION);
8289 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008290
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008291 UNIMPLEMENTED();
8292 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008293 }
8294 catch(std::bad_alloc&)
8295 {
8296 return gl::error(GL_OUT_OF_MEMORY);
8297 }
8298}
8299
8300void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids)
8301{
8302 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8303
8304 try
8305 {
8306 gl::Context *context = gl::getNonLostContext();
8307
8308 if (context)
8309 {
8310 if (context->getClientVersion() < 3)
8311 {
8312 return gl::error(GL_INVALID_OPERATION);
8313 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008314
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008315 UNIMPLEMENTED();
8316 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008317 }
8318 catch(std::bad_alloc&)
8319 {
8320 return gl::error(GL_OUT_OF_MEMORY);
8321 }
8322}
8323
8324GLboolean __stdcall glIsQuery(GLuint id)
8325{
8326 EVENT("(GLuint id = %u)", id);
8327
8328 try
8329 {
8330 gl::Context *context = gl::getNonLostContext();
8331
8332 if (context)
8333 {
8334 if (context->getClientVersion() < 3)
8335 {
8336 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8337 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008338
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008339 UNIMPLEMENTED();
8340 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008341 }
8342 catch(std::bad_alloc&)
8343 {
8344 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8345 }
8346
8347 return GL_FALSE;
8348}
8349
8350void __stdcall glBeginQuery(GLenum target, GLuint id)
8351{
8352 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
8353
8354 try
8355 {
8356 gl::Context *context = gl::getNonLostContext();
8357
8358 if (context)
8359 {
8360 if (context->getClientVersion() < 3)
8361 {
8362 return gl::error(GL_INVALID_OPERATION);
8363 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008364
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008365 UNIMPLEMENTED();
8366 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008367 }
8368 catch(std::bad_alloc&)
8369 {
8370 return gl::error(GL_OUT_OF_MEMORY);
8371 }
8372}
8373
8374void __stdcall glEndQuery(GLenum target)
8375{
8376 EVENT("(GLenum target = 0x%X)", target);
8377
8378 try
8379 {
8380 gl::Context *context = gl::getNonLostContext();
8381
8382 if (context)
8383 {
8384 if (context->getClientVersion() < 3)
8385 {
8386 return gl::error(GL_INVALID_OPERATION);
8387 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008388
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008389 UNIMPLEMENTED();
8390 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008391 }
8392 catch(std::bad_alloc&)
8393 {
8394 return gl::error(GL_OUT_OF_MEMORY);
8395 }
8396}
8397
8398void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params)
8399{
8400 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
8401
8402 try
8403 {
8404 gl::Context *context = gl::getNonLostContext();
8405
8406 if (context)
8407 {
8408 if (context->getClientVersion() < 3)
8409 {
8410 return gl::error(GL_INVALID_OPERATION);
8411 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008412
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008413 UNIMPLEMENTED();
8414 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008415 }
8416 catch(std::bad_alloc&)
8417 {
8418 return gl::error(GL_OUT_OF_MEMORY);
8419 }
8420}
8421
8422void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
8423{
8424 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
8425
8426 try
8427 {
8428 gl::Context *context = gl::getNonLostContext();
8429
8430 if (context)
8431 {
8432 if (context->getClientVersion() < 3)
8433 {
8434 return gl::error(GL_INVALID_OPERATION);
8435 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008436
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008437 UNIMPLEMENTED();
8438 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008439 }
8440 catch(std::bad_alloc&)
8441 {
8442 return gl::error(GL_OUT_OF_MEMORY);
8443 }
8444}
8445
8446GLboolean __stdcall glUnmapBuffer(GLenum target)
8447{
8448 EVENT("(GLenum target = 0x%X)", target);
8449
8450 try
8451 {
8452 gl::Context *context = gl::getNonLostContext();
8453
8454 if (context)
8455 {
8456 if (context->getClientVersion() < 3)
8457 {
8458 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8459 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008460
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008461 UNIMPLEMENTED();
8462 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008463 }
8464 catch(std::bad_alloc&)
8465 {
8466 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8467 }
8468
8469 return GL_FALSE;
8470}
8471
8472void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
8473{
8474 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
8475
8476 try
8477 {
8478 gl::Context *context = gl::getNonLostContext();
8479
8480 if (context)
8481 {
8482 if (context->getClientVersion() < 3)
8483 {
8484 return gl::error(GL_INVALID_OPERATION);
8485 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008486
shannonwoods@chromium.org2d2190a2013-05-30 00:17:35 +00008487 UNIMPLEMENTED();
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008488 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008489 }
8490 catch(std::bad_alloc&)
8491 {
8492 return gl::error(GL_OUT_OF_MEMORY);
8493 }
8494}
8495
8496void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs)
8497{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008498 try
8499 {
8500 gl::Context *context = gl::getNonLostContext();
8501
8502 if (context)
8503 {
8504 if (context->getClientVersion() < 3)
8505 {
8506 return gl::error(GL_INVALID_OPERATION);
8507 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008508
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00008509 glDrawBuffersEXT(n, bufs);
8510 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008511 }
8512 catch(std::bad_alloc&)
8513 {
8514 return gl::error(GL_OUT_OF_MEMORY);
8515 }
8516}
8517
8518void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8519{
8520 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8521 location, count, transpose, value);
8522
8523 try
8524 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008525 if (count < 0)
8526 {
8527 return gl::error(GL_INVALID_VALUE);
8528 }
8529
8530 if (location == -1)
8531 {
8532 return;
8533 }
8534
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008535 gl::Context *context = gl::getNonLostContext();
8536
8537 if (context)
8538 {
8539 if (context->getClientVersion() < 3)
8540 {
8541 return gl::error(GL_INVALID_OPERATION);
8542 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008543
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008544 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8545 if (!programBinary)
8546 {
8547 return gl::error(GL_INVALID_OPERATION);
8548 }
8549
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008550 if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008551 {
8552 return gl::error(GL_INVALID_OPERATION);
8553 }
8554 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008555 }
8556 catch(std::bad_alloc&)
8557 {
8558 return gl::error(GL_OUT_OF_MEMORY);
8559 }
8560}
8561
8562void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8563{
8564 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8565 location, count, transpose, value);
8566
8567 try
8568 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008569 if (count < 0)
8570 {
8571 return gl::error(GL_INVALID_VALUE);
8572 }
8573
8574 if (location == -1)
8575 {
8576 return;
8577 }
8578
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008579 gl::Context *context = gl::getNonLostContext();
8580
8581 if (context)
8582 {
8583 if (context->getClientVersion() < 3)
8584 {
8585 return gl::error(GL_INVALID_OPERATION);
8586 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008587
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008588 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8589 if (!programBinary)
8590 {
8591 return gl::error(GL_INVALID_OPERATION);
8592 }
8593
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008594 if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008595 {
8596 return gl::error(GL_INVALID_OPERATION);
8597 }
8598 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008599 }
8600 catch(std::bad_alloc&)
8601 {
8602 return gl::error(GL_OUT_OF_MEMORY);
8603 }
8604}
8605
8606void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8607{
8608 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8609 location, count, transpose, value);
8610
8611 try
8612 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008613 if (count < 0)
8614 {
8615 return gl::error(GL_INVALID_VALUE);
8616 }
8617
8618 if (location == -1)
8619 {
8620 return;
8621 }
8622
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008623 gl::Context *context = gl::getNonLostContext();
8624
8625 if (context)
8626 {
8627 if (context->getClientVersion() < 3)
8628 {
8629 return gl::error(GL_INVALID_OPERATION);
8630 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008631
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008632 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8633 if (!programBinary)
8634 {
8635 return gl::error(GL_INVALID_OPERATION);
8636 }
8637
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008638 if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008639 {
8640 return gl::error(GL_INVALID_OPERATION);
8641 }
8642 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008643 }
8644 catch(std::bad_alloc&)
8645 {
8646 return gl::error(GL_OUT_OF_MEMORY);
8647 }
8648}
8649
8650void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8651{
8652 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8653 location, count, transpose, value);
8654
8655 try
8656 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008657 if (count < 0)
8658 {
8659 return gl::error(GL_INVALID_VALUE);
8660 }
8661
8662 if (location == -1)
8663 {
8664 return;
8665 }
8666
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008667 gl::Context *context = gl::getNonLostContext();
8668
8669 if (context)
8670 {
8671 if (context->getClientVersion() < 3)
8672 {
8673 return gl::error(GL_INVALID_OPERATION);
8674 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008675
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008676 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8677 if (!programBinary)
8678 {
8679 return gl::error(GL_INVALID_OPERATION);
8680 }
8681
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008682 if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008683 {
8684 return gl::error(GL_INVALID_OPERATION);
8685 }
8686 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008687 }
8688 catch(std::bad_alloc&)
8689 {
8690 return gl::error(GL_OUT_OF_MEMORY);
8691 }
8692}
8693
8694void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8695{
8696 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8697 location, count, transpose, value);
8698
8699 try
8700 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008701 if (count < 0)
8702 {
8703 return gl::error(GL_INVALID_VALUE);
8704 }
8705
8706 if (location == -1)
8707 {
8708 return;
8709 }
8710
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008711 gl::Context *context = gl::getNonLostContext();
8712
8713 if (context)
8714 {
8715 if (context->getClientVersion() < 3)
8716 {
8717 return gl::error(GL_INVALID_OPERATION);
8718 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008719
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008720 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8721 if (!programBinary)
8722 {
8723 return gl::error(GL_INVALID_OPERATION);
8724 }
8725
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008726 if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008727 {
8728 return gl::error(GL_INVALID_OPERATION);
8729 }
8730 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008731 }
8732 catch(std::bad_alloc&)
8733 {
8734 return gl::error(GL_OUT_OF_MEMORY);
8735 }
8736}
8737
8738void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8739{
8740 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8741 location, count, transpose, value);
8742
8743 try
8744 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008745 if (count < 0)
8746 {
8747 return gl::error(GL_INVALID_VALUE);
8748 }
8749
8750 if (location == -1)
8751 {
8752 return;
8753 }
8754
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008755 gl::Context *context = gl::getNonLostContext();
8756
8757 if (context)
8758 {
8759 if (context->getClientVersion() < 3)
8760 {
8761 return gl::error(GL_INVALID_OPERATION);
8762 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008763
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008764 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8765 if (!programBinary)
8766 {
8767 return gl::error(GL_INVALID_OPERATION);
8768 }
8769
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008770 if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008771 {
8772 return gl::error(GL_INVALID_OPERATION);
8773 }
8774 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008775 }
8776 catch(std::bad_alloc&)
8777 {
8778 return gl::error(GL_OUT_OF_MEMORY);
8779 }
8780}
8781
8782void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
8783{
8784 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
8785 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
8786 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
8787
8788 try
8789 {
8790 gl::Context *context = gl::getNonLostContext();
8791
8792 if (context)
8793 {
8794 if (context->getClientVersion() < 3)
8795 {
8796 return gl::error(GL_INVALID_OPERATION);
8797 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008798
shannonwoods@chromium.orgee148562013-05-30 00:17:21 +00008799 glBlitFramebufferANGLE(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008800 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008801 }
8802 catch(std::bad_alloc&)
8803 {
8804 return gl::error(GL_OUT_OF_MEMORY);
8805 }
8806}
8807
8808void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
8809{
8810 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
8811 target, samples, internalformat, width, height);
8812
8813 try
8814 {
8815 gl::Context *context = gl::getNonLostContext();
8816
8817 if (context)
8818 {
8819 if (context->getClientVersion() < 3)
8820 {
8821 return gl::error(GL_INVALID_OPERATION);
8822 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008823
Geoff Lang2e1dcd52013-05-29 10:34:08 -04008824 if (!validateRenderbufferStorageParameters(context, target, samples, internalformat,
8825 width, height, false))
8826 {
8827 return;
8828 }
8829
8830 context->setRenderbufferStorage(width, height, internalformat, samples);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008831 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008832 }
8833 catch(std::bad_alloc&)
8834 {
8835 return gl::error(GL_OUT_OF_MEMORY);
8836 }
8837}
8838
8839void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
8840{
8841 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
8842 target, attachment, texture, level, layer);
8843
8844 try
8845 {
8846 gl::Context *context = gl::getNonLostContext();
8847
8848 if (context)
8849 {
8850 if (context->getClientVersion() < 3)
8851 {
8852 return gl::error(GL_INVALID_OPERATION);
8853 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008854
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008855 UNIMPLEMENTED();
8856 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008857 }
8858 catch(std::bad_alloc&)
8859 {
8860 return gl::error(GL_OUT_OF_MEMORY);
8861 }
8862}
8863
8864GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
8865{
8866 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
8867 target, offset, length, access);
8868
8869 try
8870 {
8871 gl::Context *context = gl::getNonLostContext();
8872
8873 if (context)
8874 {
8875 if (context->getClientVersion() < 3)
8876 {
8877 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
8878 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008879
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008880 UNIMPLEMENTED();
8881 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008882 }
8883 catch(std::bad_alloc&)
8884 {
8885 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL));
8886 }
8887
8888 return NULL;
8889}
8890
8891void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
8892{
8893 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
8894
8895 try
8896 {
8897 gl::Context *context = gl::getNonLostContext();
8898
8899 if (context)
8900 {
8901 if (context->getClientVersion() < 3)
8902 {
8903 return gl::error(GL_INVALID_OPERATION);
8904 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008905
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008906 UNIMPLEMENTED();
8907 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008908 }
8909 catch(std::bad_alloc&)
8910 {
8911 return gl::error(GL_OUT_OF_MEMORY);
8912 }
8913}
8914
8915void __stdcall glBindVertexArray(GLuint array)
8916{
8917 EVENT("(GLuint array = %u)", array);
8918
8919 try
8920 {
8921 gl::Context *context = gl::getNonLostContext();
8922
8923 if (context)
8924 {
8925 if (context->getClientVersion() < 3)
8926 {
8927 return gl::error(GL_INVALID_OPERATION);
8928 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008929
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008930 UNIMPLEMENTED();
8931 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008932 }
8933 catch(std::bad_alloc&)
8934 {
8935 return gl::error(GL_OUT_OF_MEMORY);
8936 }
8937}
8938
8939void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
8940{
8941 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
8942
8943 try
8944 {
8945 gl::Context *context = gl::getNonLostContext();
8946
8947 if (context)
8948 {
8949 if (context->getClientVersion() < 3)
8950 {
8951 return gl::error(GL_INVALID_OPERATION);
8952 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008953
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008954 UNIMPLEMENTED();
8955 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008956 }
8957 catch(std::bad_alloc&)
8958 {
8959 return gl::error(GL_OUT_OF_MEMORY);
8960 }
8961}
8962
8963void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays)
8964{
8965 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
8966
8967 try
8968 {
8969 gl::Context *context = gl::getNonLostContext();
8970
8971 if (context)
8972 {
8973 if (context->getClientVersion() < 3)
8974 {
8975 return gl::error(GL_INVALID_OPERATION);
8976 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008977
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008978 UNIMPLEMENTED();
8979 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008980 }
8981 catch(std::bad_alloc&)
8982 {
8983 return gl::error(GL_OUT_OF_MEMORY);
8984 }
8985}
8986
8987GLboolean __stdcall glIsVertexArray(GLuint array)
8988{
8989 EVENT("(GLuint array = %u)", array);
8990
8991 try
8992 {
8993 gl::Context *context = gl::getNonLostContext();
8994
8995 if (context)
8996 {
8997 if (context->getClientVersion() < 3)
8998 {
8999 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
9000 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009001
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009002 UNIMPLEMENTED();
9003 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009004 }
9005 catch(std::bad_alloc&)
9006 {
9007 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
9008 }
9009
9010 return GL_FALSE;
9011}
9012
9013void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
9014{
9015 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
9016 target, index, data);
9017
9018 try
9019 {
9020 gl::Context *context = gl::getNonLostContext();
9021
9022 if (context)
9023 {
9024 if (context->getClientVersion() < 3)
9025 {
9026 return gl::error(GL_INVALID_OPERATION);
9027 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009028
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009029 UNIMPLEMENTED();
9030 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009031 }
9032 catch(std::bad_alloc&)
9033 {
9034 return gl::error(GL_OUT_OF_MEMORY);
9035 }
9036}
9037
9038void __stdcall glBeginTransformFeedback(GLenum primitiveMode)
9039{
9040 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
9041
9042 try
9043 {
9044 gl::Context *context = gl::getNonLostContext();
9045
9046 if (context)
9047 {
9048 if (context->getClientVersion() < 3)
9049 {
9050 return gl::error(GL_INVALID_OPERATION);
9051 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009052
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009053 UNIMPLEMENTED();
9054 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009055 }
9056 catch(std::bad_alloc&)
9057 {
9058 return gl::error(GL_OUT_OF_MEMORY);
9059 }
9060}
9061
9062void __stdcall glEndTransformFeedback(void)
9063{
9064 EVENT("(void)");
9065
9066 try
9067 {
9068 gl::Context *context = gl::getNonLostContext();
9069
9070 if (context)
9071 {
9072 if (context->getClientVersion() < 3)
9073 {
9074 return gl::error(GL_INVALID_OPERATION);
9075 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009076
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009077 UNIMPLEMENTED();
9078 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009079 }
9080 catch(std::bad_alloc&)
9081 {
9082 return gl::error(GL_OUT_OF_MEMORY);
9083 }
9084}
9085
9086void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
9087{
9088 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
9089 target, index, buffer, offset, size);
9090
9091 try
9092 {
9093 gl::Context *context = gl::getNonLostContext();
9094
9095 if (context)
9096 {
9097 if (context->getClientVersion() < 3)
9098 {
9099 return gl::error(GL_INVALID_OPERATION);
9100 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009101
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009102 switch (target)
9103 {
9104 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00009105 if (index >= context->getMaxTransformFeedbackBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009106 {
9107 return gl::error(GL_INVALID_VALUE);
9108 }
9109 break;
9110
9111 case GL_UNIFORM_BUFFER:
9112 if (index >= context->getMaximumCombinedUniformBufferBindings())
9113 {
9114 return gl::error(GL_INVALID_VALUE);
9115 }
9116 break;
9117
9118 default:
9119 return gl::error(GL_INVALID_ENUM);
9120 }
9121
shannonwoods@chromium.orge6e00792013-05-30 00:06:07 +00009122 if (buffer != 0 && size <= 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009123 {
9124 return gl::error(GL_INVALID_VALUE);
9125 }
9126
9127 switch (target)
9128 {
9129 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orga26aeaf2013-05-30 00:06:13 +00009130
9131 // size and offset must be a multiple of 4
9132 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
9133 {
9134 return gl::error(GL_INVALID_VALUE);
9135 }
9136
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009137 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
9138 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009139 break;
9140
9141 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.org97c3d502013-05-30 00:04:34 +00009142
9143 // it is an error to bind an offset not a multiple of the alignment
9144 if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0)
9145 {
9146 return gl::error(GL_INVALID_VALUE);
9147 }
9148
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009149 context->bindIndexedUniformBuffer(buffer, index, offset, size);
9150 context->bindGenericUniformBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009151 break;
9152
9153 default:
9154 UNREACHABLE();
9155 }
9156 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009157 }
9158 catch(std::bad_alloc&)
9159 {
9160 return gl::error(GL_OUT_OF_MEMORY);
9161 }
9162}
9163
9164void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
9165{
9166 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
9167 target, index, buffer);
9168
9169 try
9170 {
9171 gl::Context *context = gl::getNonLostContext();
9172
9173 if (context)
9174 {
9175 if (context->getClientVersion() < 3)
9176 {
9177 return gl::error(GL_INVALID_OPERATION);
9178 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009179
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009180 switch (target)
9181 {
9182 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00009183 if (index >= context->getMaxTransformFeedbackBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009184 {
9185 return gl::error(GL_INVALID_VALUE);
9186 }
9187 break;
9188
9189 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00009190 if (index >= context->getMaximumCombinedUniformBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009191 {
9192 return gl::error(GL_INVALID_VALUE);
9193 }
9194 break;
9195
9196 default:
9197 return gl::error(GL_INVALID_ENUM);
9198 }
9199
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009200 switch (target)
9201 {
9202 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.org3eeca1e2013-05-30 00:04:28 +00009203 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009204 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009205 break;
9206
9207 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.org3eeca1e2013-05-30 00:04:28 +00009208 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009209 context->bindGenericUniformBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009210 break;
9211
9212 default:
9213 UNREACHABLE();
9214 }
9215 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009216 }
9217 catch(std::bad_alloc&)
9218 {
9219 return gl::error(GL_OUT_OF_MEMORY);
9220 }
9221}
9222
9223void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
9224{
9225 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
9226 program, count, varyings, bufferMode);
9227
9228 try
9229 {
9230 gl::Context *context = gl::getNonLostContext();
9231
9232 if (context)
9233 {
9234 if (context->getClientVersion() < 3)
9235 {
9236 return gl::error(GL_INVALID_OPERATION);
9237 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009238
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009239 UNIMPLEMENTED();
9240 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009241 }
9242 catch(std::bad_alloc&)
9243 {
9244 return gl::error(GL_OUT_OF_MEMORY);
9245 }
9246}
9247
9248void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
9249{
9250 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
9251 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
9252 program, index, bufSize, length, size, type, name);
9253
9254 try
9255 {
9256 gl::Context *context = gl::getNonLostContext();
9257
9258 if (context)
9259 {
9260 if (context->getClientVersion() < 3)
9261 {
9262 return gl::error(GL_INVALID_OPERATION);
9263 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009264
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009265 UNIMPLEMENTED();
9266 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009267 }
9268 catch(std::bad_alloc&)
9269 {
9270 return gl::error(GL_OUT_OF_MEMORY);
9271 }
9272}
9273
9274void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
9275{
9276 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
9277 index, size, type, stride, pointer);
9278
9279 try
9280 {
9281 gl::Context *context = gl::getNonLostContext();
9282
9283 if (context)
9284 {
9285 if (context->getClientVersion() < 3)
9286 {
9287 return gl::error(GL_INVALID_OPERATION);
9288 }
9289 }
9290
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009291 if (index >= gl::MAX_VERTEX_ATTRIBS)
9292 {
9293 return gl::error(GL_INVALID_VALUE);
9294 }
9295
9296 if (size < 1 || size > 4)
9297 {
9298 return gl::error(GL_INVALID_VALUE);
9299 }
9300
9301 switch (type)
9302 {
9303 case GL_BYTE:
9304 case GL_UNSIGNED_BYTE:
9305 case GL_SHORT:
9306 case GL_UNSIGNED_SHORT:
9307 case GL_INT:
9308 case GL_UNSIGNED_INT:
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00009309 case GL_INT_2_10_10_10_REV:
9310 case GL_UNSIGNED_INT_2_10_10_10_REV:
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009311 break;
9312 default:
9313 return gl::error(GL_INVALID_ENUM);
9314 }
9315
9316 if (stride < 0)
9317 {
9318 return gl::error(GL_INVALID_VALUE);
9319 }
9320
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00009321 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
9322 {
9323 return gl::error(GL_INVALID_OPERATION);
9324 }
9325
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009326 if (context)
9327 {
9328 context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true,
9329 stride, pointer);
9330 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009331 }
9332 catch(std::bad_alloc&)
9333 {
9334 return gl::error(GL_OUT_OF_MEMORY);
9335 }
9336}
9337
9338void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
9339{
9340 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
9341 index, pname, params);
9342
9343 try
9344 {
9345 gl::Context *context = gl::getNonLostContext();
9346
9347 if (context)
9348 {
9349 if (context->getClientVersion() < 3)
9350 {
9351 return gl::error(GL_INVALID_OPERATION);
9352 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009353
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009354 UNIMPLEMENTED();
9355 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009356 }
9357 catch(std::bad_alloc&)
9358 {
9359 return gl::error(GL_OUT_OF_MEMORY);
9360 }
9361}
9362
9363void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
9364{
9365 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
9366 index, pname, params);
9367
9368 try
9369 {
9370 gl::Context *context = gl::getNonLostContext();
9371
9372 if (context)
9373 {
9374 if (context->getClientVersion() < 3)
9375 {
9376 return gl::error(GL_INVALID_OPERATION);
9377 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009378
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009379 UNIMPLEMENTED();
9380 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009381 }
9382 catch(std::bad_alloc&)
9383 {
9384 return gl::error(GL_OUT_OF_MEMORY);
9385 }
9386}
9387
9388void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
9389{
9390 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
9391 index, x, y, z, w);
9392
9393 try
9394 {
9395 gl::Context *context = gl::getNonLostContext();
9396
9397 if (context)
9398 {
9399 if (context->getClientVersion() < 3)
9400 {
9401 return gl::error(GL_INVALID_OPERATION);
9402 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009403
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009404 if (index >= gl::MAX_VERTEX_ATTRIBS)
9405 {
9406 return gl::error(GL_INVALID_VALUE);
9407 }
9408
9409 GLint vals[4] = { x, y, z, w };
9410 context->setVertexAttribi(index, vals);
9411 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009412 }
9413 catch(std::bad_alloc&)
9414 {
9415 return gl::error(GL_OUT_OF_MEMORY);
9416 }
9417}
9418
9419void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
9420{
9421 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
9422 index, x, y, z, w);
9423
9424 try
9425 {
9426 gl::Context *context = gl::getNonLostContext();
9427
9428 if (context)
9429 {
9430 if (context->getClientVersion() < 3)
9431 {
9432 return gl::error(GL_INVALID_OPERATION);
9433 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009434
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009435 if (index >= gl::MAX_VERTEX_ATTRIBS)
9436 {
9437 return gl::error(GL_INVALID_VALUE);
9438 }
9439
9440 GLuint vals[4] = { x, y, z, w };
9441 context->setVertexAttribu(index, vals);
9442 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009443 }
9444 catch(std::bad_alloc&)
9445 {
9446 return gl::error(GL_OUT_OF_MEMORY);
9447 }
9448}
9449
9450void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v)
9451{
9452 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
9453
9454 try
9455 {
9456 gl::Context *context = gl::getNonLostContext();
9457
9458 if (context)
9459 {
9460 if (context->getClientVersion() < 3)
9461 {
9462 return gl::error(GL_INVALID_OPERATION);
9463 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009464
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009465 if (index >= gl::MAX_VERTEX_ATTRIBS)
9466 {
9467 return gl::error(GL_INVALID_VALUE);
9468 }
9469
9470 context->setVertexAttribi(index, v);
9471 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009472 }
9473 catch(std::bad_alloc&)
9474 {
9475 return gl::error(GL_OUT_OF_MEMORY);
9476 }
9477}
9478
9479void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v)
9480{
9481 EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
9482
9483 try
9484 {
9485 gl::Context *context = gl::getNonLostContext();
9486
9487 if (context)
9488 {
9489 if (context->getClientVersion() < 3)
9490 {
9491 return gl::error(GL_INVALID_OPERATION);
9492 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009493
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009494 if (index >= gl::MAX_VERTEX_ATTRIBS)
9495 {
9496 return gl::error(GL_INVALID_VALUE);
9497 }
9498
9499 context->setVertexAttribu(index, v);
9500 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009501 }
9502 catch(std::bad_alloc&)
9503 {
9504 return gl::error(GL_OUT_OF_MEMORY);
9505 }
9506}
9507
9508void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params)
9509{
9510 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
9511 program, location, params);
9512
9513 try
9514 {
9515 gl::Context *context = gl::getNonLostContext();
9516
9517 if (context)
9518 {
9519 if (context->getClientVersion() < 3)
9520 {
9521 return gl::error(GL_INVALID_OPERATION);
9522 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009523
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00009524 if (program == 0)
9525 {
9526 return gl::error(GL_INVALID_VALUE);
9527 }
9528
9529 gl::Program *programObject = context->getProgram(program);
9530
9531 if (!programObject || !programObject->isLinked())
9532 {
9533 return gl::error(GL_INVALID_OPERATION);
9534 }
9535
9536 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
9537 if (!programBinary)
9538 {
9539 return gl::error(GL_INVALID_OPERATION);
9540 }
9541
9542 if (!programBinary->getUniformuiv(location, NULL, params))
9543 {
9544 return gl::error(GL_INVALID_OPERATION);
9545 }
9546 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009547 }
9548 catch(std::bad_alloc&)
9549 {
9550 return gl::error(GL_OUT_OF_MEMORY);
9551 }
9552}
9553
9554GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name)
9555{
9556 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
9557 program, name);
9558
9559 try
9560 {
9561 gl::Context *context = gl::getNonLostContext();
9562
9563 if (context)
9564 {
9565 if (context->getClientVersion() < 3)
9566 {
9567 return gl::error(GL_INVALID_OPERATION, 0);
9568 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009569
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009570 UNIMPLEMENTED();
9571 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009572 }
9573 catch(std::bad_alloc&)
9574 {
9575 return gl::error(GL_OUT_OF_MEMORY, 0);
9576 }
9577
9578 return 0;
9579}
9580
9581void __stdcall glUniform1ui(GLint location, GLuint v0)
9582{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00009583 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009584}
9585
9586void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1)
9587{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00009588 const GLuint xy[] = { v0, v1 };
9589 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009590}
9591
9592void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
9593{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00009594 const GLuint xyz[] = { v0, v1, v2 };
9595 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009596}
9597
9598void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
9599{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00009600 const GLuint xyzw[] = { v0, v1, v2, v3 };
9601 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009602}
9603
9604void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
9605{
9606 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
9607 location, count, value);
9608
9609 try
9610 {
9611 gl::Context *context = gl::getNonLostContext();
9612
9613 if (context)
9614 {
9615 if (context->getClientVersion() < 3)
9616 {
9617 return gl::error(GL_INVALID_OPERATION);
9618 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009619
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00009620 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9621 if (!programBinary)
9622 {
9623 return gl::error(GL_INVALID_OPERATION);
9624 }
9625
9626 if (!programBinary->setUniform1uiv(location, count, value))
9627 {
9628 return gl::error(GL_INVALID_OPERATION);
9629 }
9630 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009631 }
9632 catch(std::bad_alloc&)
9633 {
9634 return gl::error(GL_OUT_OF_MEMORY);
9635 }
9636}
9637
9638void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
9639{
9640 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
9641 location, count, value);
9642
9643 try
9644 {
9645 gl::Context *context = gl::getNonLostContext();
9646
9647 if (context)
9648 {
9649 if (context->getClientVersion() < 3)
9650 {
9651 return gl::error(GL_INVALID_OPERATION);
9652 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009653
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00009654 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9655 if (!programBinary)
9656 {
9657 return gl::error(GL_INVALID_OPERATION);
9658 }
9659
9660 if (!programBinary->setUniform2uiv(location, count, value))
9661 {
9662 return gl::error(GL_INVALID_OPERATION);
9663 }
9664 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009665 }
9666 catch(std::bad_alloc&)
9667 {
9668 return gl::error(GL_OUT_OF_MEMORY);
9669 }
9670}
9671
9672void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
9673{
9674 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
9675 location, count, value);
9676
9677 try
9678 {
9679 gl::Context *context = gl::getNonLostContext();
9680
9681 if (context)
9682 {
9683 if (context->getClientVersion() < 3)
9684 {
9685 return gl::error(GL_INVALID_OPERATION);
9686 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009687
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00009688 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9689 if (!programBinary)
9690 {
9691 return gl::error(GL_INVALID_OPERATION);
9692 }
9693
9694 if (!programBinary->setUniform3uiv(location, count, value))
9695 {
9696 return gl::error(GL_INVALID_OPERATION);
9697 }
9698 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009699 }
9700 catch(std::bad_alloc&)
9701 {
9702 return gl::error(GL_OUT_OF_MEMORY);
9703 }
9704}
9705
9706void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
9707{
9708 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
9709 location, count, value);
9710
9711 try
9712 {
9713 gl::Context *context = gl::getNonLostContext();
9714
9715 if (context)
9716 {
9717 if (context->getClientVersion() < 3)
9718 {
9719 return gl::error(GL_INVALID_OPERATION);
9720 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009721
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00009722 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9723 if (!programBinary)
9724 {
9725 return gl::error(GL_INVALID_OPERATION);
9726 }
9727
9728 if (!programBinary->setUniform4uiv(location, count, value))
9729 {
9730 return gl::error(GL_INVALID_OPERATION);
9731 }
9732 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009733 }
9734 catch(std::bad_alloc&)
9735 {
9736 return gl::error(GL_OUT_OF_MEMORY);
9737 }
9738}
9739
9740void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
9741{
9742 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
9743 buffer, drawbuffer, value);
9744
9745 try
9746 {
9747 gl::Context *context = gl::getNonLostContext();
9748
9749 if (context)
9750 {
9751 if (context->getClientVersion() < 3)
9752 {
9753 return gl::error(GL_INVALID_OPERATION);
9754 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009755
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009756 UNIMPLEMENTED();
9757 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009758 }
9759 catch(std::bad_alloc&)
9760 {
9761 return gl::error(GL_OUT_OF_MEMORY);
9762 }
9763}
9764
9765void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
9766{
9767 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
9768 buffer, drawbuffer, value);
9769
9770 try
9771 {
9772 gl::Context *context = gl::getNonLostContext();
9773
9774 if (context)
9775 {
9776 if (context->getClientVersion() < 3)
9777 {
9778 return gl::error(GL_INVALID_OPERATION);
9779 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009780
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009781 UNIMPLEMENTED();
9782 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009783 }
9784 catch(std::bad_alloc&)
9785 {
9786 return gl::error(GL_OUT_OF_MEMORY);
9787 }
9788}
9789
9790void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
9791{
9792 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
9793 buffer, drawbuffer, value);
9794
9795 try
9796 {
9797 gl::Context *context = gl::getNonLostContext();
9798
9799 if (context)
9800 {
9801 if (context->getClientVersion() < 3)
9802 {
9803 return gl::error(GL_INVALID_OPERATION);
9804 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009805
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009806 UNIMPLEMENTED();
9807 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009808 }
9809 catch(std::bad_alloc&)
9810 {
9811 return gl::error(GL_OUT_OF_MEMORY);
9812 }
9813}
9814
9815void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
9816{
9817 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
9818 buffer, drawbuffer, depth, stencil);
9819
9820 try
9821 {
9822 gl::Context *context = gl::getNonLostContext();
9823
9824 if (context)
9825 {
9826 if (context->getClientVersion() < 3)
9827 {
9828 return gl::error(GL_INVALID_OPERATION);
9829 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009830
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009831 UNIMPLEMENTED();
9832 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009833 }
9834 catch(std::bad_alloc&)
9835 {
9836 return gl::error(GL_OUT_OF_MEMORY);
9837 }
9838}
9839
9840const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index)
9841{
9842 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
9843
9844 try
9845 {
9846 gl::Context *context = gl::getNonLostContext();
9847
9848 if (context)
9849 {
9850 if (context->getClientVersion() < 3)
9851 {
9852 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL));
9853 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009854
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00009855 if (name != GL_EXTENSIONS)
9856 {
9857 return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL));
9858 }
9859
9860 if (index >= context->getNumExtensions())
9861 {
9862 return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL));
9863 }
9864
9865 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index));
9866 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009867 }
9868 catch(std::bad_alloc&)
9869 {
9870 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL));
9871 }
9872
9873 return NULL;
9874}
9875
9876void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
9877{
9878 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
9879 readTarget, writeTarget, readOffset, writeOffset, size);
9880
9881 try
9882 {
9883 gl::Context *context = gl::getNonLostContext();
9884
9885 if (context)
9886 {
9887 if (context->getClientVersion() < 3)
9888 {
9889 return gl::error(GL_INVALID_OPERATION);
9890 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009891
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00009892 gl::Buffer *readBuffer = NULL;
9893 switch (readTarget)
9894 {
9895 case GL_ARRAY_BUFFER:
9896 readBuffer = context->getArrayBuffer();
9897 break;
9898 case GL_COPY_READ_BUFFER:
9899 readBuffer = context->getCopyReadBuffer();
9900 break;
9901 case GL_COPY_WRITE_BUFFER:
9902 readBuffer = context->getCopyWriteBuffer();
9903 break;
9904 case GL_ELEMENT_ARRAY_BUFFER:
9905 readBuffer = context->getElementArrayBuffer();
9906 break;
9907 case GL_PIXEL_PACK_BUFFER:
9908 readBuffer = context->getPixelPackBuffer();
9909 break;
9910 case GL_PIXEL_UNPACK_BUFFER:
9911 readBuffer = context->getPixelUnpackBuffer();
9912 break;
9913 case GL_TRANSFORM_FEEDBACK_BUFFER:
9914 readBuffer = context->getGenericTransformFeedbackBuffer();
9915 break;
9916 case GL_UNIFORM_BUFFER:
9917 readBuffer = context->getGenericUniformBuffer();
9918 break;
9919 default:
9920 return gl::error(GL_INVALID_ENUM);
9921 }
9922
9923 gl::Buffer *writeBuffer = NULL;
9924 switch (writeTarget)
9925 {
9926 case GL_ARRAY_BUFFER:
9927 writeBuffer = context->getArrayBuffer();
9928 break;
9929 case GL_COPY_READ_BUFFER:
9930 writeBuffer = context->getCopyReadBuffer();
9931 break;
9932 case GL_COPY_WRITE_BUFFER:
9933 writeBuffer = context->getCopyWriteBuffer();
9934 break;
9935 case GL_ELEMENT_ARRAY_BUFFER:
9936 writeBuffer = context->getElementArrayBuffer();
9937 break;
9938 case GL_PIXEL_PACK_BUFFER:
9939 writeBuffer = context->getPixelPackBuffer();
9940 break;
9941 case GL_PIXEL_UNPACK_BUFFER:
9942 writeBuffer = context->getPixelUnpackBuffer();
9943 break;
9944 case GL_TRANSFORM_FEEDBACK_BUFFER:
9945 writeBuffer = context->getGenericTransformFeedbackBuffer();
9946 break;
9947 case GL_UNIFORM_BUFFER:
9948 writeBuffer = context->getGenericUniformBuffer();
9949 break;
9950 default:
9951 return gl::error(GL_INVALID_ENUM);
9952 }
9953
9954 if (!readBuffer || !writeBuffer)
9955 {
9956 return gl::error(GL_INVALID_OPERATION);
9957 }
9958
9959 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
9960 static_cast<unsigned int>(readOffset + size) > readBuffer->size() ||
9961 static_cast<unsigned int>(writeOffset + size) > writeBuffer->size())
9962 {
9963 return gl::error(GL_INVALID_VALUE);
9964 }
9965
9966 if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size)
9967 {
9968 return gl::error(GL_INVALID_VALUE);
9969 }
9970
9971 // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION)
9972
shannon.woods%transgaming.com@gtempaccount.comc53376a2013-04-13 03:41:23 +00009973 // if size is zero, the copy is a successful no-op
9974 if (size > 0)
9975 {
9976 writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
9977 }
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00009978 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009979 }
9980 catch(std::bad_alloc&)
9981 {
9982 return gl::error(GL_OUT_OF_MEMORY);
9983 }
9984}
9985
9986void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
9987{
9988 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
9989 program, uniformCount, uniformNames, uniformIndices);
9990
9991 try
9992 {
9993 gl::Context *context = gl::getNonLostContext();
9994
9995 if (context)
9996 {
9997 if (context->getClientVersion() < 3)
9998 {
9999 return gl::error(GL_INVALID_OPERATION);
10000 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010001
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +000010002 if (uniformCount < 0)
10003 {
10004 return gl::error(GL_INVALID_VALUE);
10005 }
10006
10007 gl::Program *programObject = context->getProgram(program);
10008
10009 if (!programObject)
10010 {
10011 if (context->getShader(program))
10012 {
10013 return gl::error(GL_INVALID_OPERATION);
10014 }
10015 else
10016 {
10017 return gl::error(GL_INVALID_VALUE);
10018 }
10019 }
10020
10021 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10022 if (!programObject->isLinked() || !programBinary)
10023 {
10024 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10025 {
10026 uniformIndices[uniformId] = GL_INVALID_INDEX;
10027 }
10028 }
10029 else
10030 {
10031 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10032 {
10033 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
10034 }
10035 }
10036 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010037 }
10038 catch(std::bad_alloc&)
10039 {
10040 return gl::error(GL_OUT_OF_MEMORY);
10041 }
10042}
10043
10044void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
10045{
10046 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
10047 program, uniformCount, uniformIndices, pname, params);
10048
10049 try
10050 {
10051 gl::Context *context = gl::getNonLostContext();
10052
10053 if (context)
10054 {
10055 if (context->getClientVersion() < 3)
10056 {
10057 return gl::error(GL_INVALID_OPERATION);
10058 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010059
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +000010060 if (uniformCount < 0)
10061 {
10062 return gl::error(GL_INVALID_VALUE);
10063 }
10064
10065 gl::Program *programObject = context->getProgram(program);
10066
10067 if (!programObject)
10068 {
10069 if (context->getShader(program))
10070 {
10071 return gl::error(GL_INVALID_OPERATION);
10072 }
10073 else
10074 {
10075 return gl::error(GL_INVALID_VALUE);
10076 }
10077 }
10078
10079 switch (pname)
10080 {
10081 case GL_UNIFORM_TYPE:
10082 case GL_UNIFORM_SIZE:
10083 case GL_UNIFORM_NAME_LENGTH:
10084 case GL_UNIFORM_BLOCK_INDEX:
10085 case GL_UNIFORM_OFFSET:
10086 case GL_UNIFORM_ARRAY_STRIDE:
10087 case GL_UNIFORM_MATRIX_STRIDE:
10088 case GL_UNIFORM_IS_ROW_MAJOR:
10089 break;
10090 default:
10091 return gl::error(GL_INVALID_ENUM);
10092 }
10093
10094 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10095
10096 if (!programBinary && uniformCount > 0)
10097 {
10098 return gl::error(GL_INVALID_VALUE);
10099 }
10100
10101 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10102 {
10103 const GLuint index = uniformIndices[uniformId];
10104
10105 if (index >= (GLuint)programBinary->getActiveUniformCount())
10106 {
10107 return gl::error(GL_INVALID_VALUE);
10108 }
10109 }
10110
10111 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10112 {
10113 const GLuint index = uniformIndices[uniformId];
10114 params[uniformId] = programBinary->getActiveUniformi(index, pname);
10115 }
10116 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010117 }
10118 catch(std::bad_alloc&)
10119 {
10120 return gl::error(GL_OUT_OF_MEMORY);
10121 }
10122}
10123
10124GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
10125{
10126 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
10127
10128 try
10129 {
10130 gl::Context *context = gl::getNonLostContext();
10131
10132 if (context)
10133 {
10134 if (context->getClientVersion() < 3)
10135 {
shannonwoods@chromium.org42766252013-05-30 00:07:12 +000010136 return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010137 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010138
shannonwoods@chromium.org42766252013-05-30 00:07:12 +000010139 gl::Program *programObject = context->getProgram(program);
10140
10141 if (!programObject)
10142 {
10143 if (context->getShader(program))
10144 {
10145 return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
10146 }
10147 else
10148 {
10149 return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX);
10150 }
10151 }
10152
10153 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10154 if (!programBinary)
10155 {
10156 return GL_INVALID_INDEX;
10157 }
10158
10159 return programBinary->getUniformBlockIndex(uniformBlockName);
10160 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010161 }
10162 catch(std::bad_alloc&)
10163 {
10164 return gl::error(GL_OUT_OF_MEMORY, 0);
10165 }
10166
10167 return 0;
10168}
10169
10170void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
10171{
10172 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
10173 program, uniformBlockIndex, pname, params);
10174
10175 try
10176 {
10177 gl::Context *context = gl::getNonLostContext();
10178
10179 if (context)
10180 {
10181 if (context->getClientVersion() < 3)
10182 {
10183 return gl::error(GL_INVALID_OPERATION);
10184 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +000010185 gl::Program *programObject = context->getProgram(program);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010186
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +000010187 if (!programObject)
10188 {
10189 if (context->getShader(program))
10190 {
10191 return gl::error(GL_INVALID_OPERATION);
10192 }
10193 else
10194 {
10195 return gl::error(GL_INVALID_VALUE);
10196 }
10197 }
10198
10199 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10200
10201 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
10202 {
10203 return gl::error(GL_INVALID_VALUE);
10204 }
10205
10206 switch (pname)
10207 {
10208 case GL_UNIFORM_BLOCK_BINDING:
10209 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
10210 break;
10211
10212 case GL_UNIFORM_BLOCK_DATA_SIZE:
10213 case GL_UNIFORM_BLOCK_NAME_LENGTH:
10214 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
10215 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
10216 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
10217 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
10218 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
10219 break;
10220
10221 default:
10222 return gl::error(GL_INVALID_ENUM);
10223 }
10224 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010225 }
10226 catch(std::bad_alloc&)
10227 {
10228 return gl::error(GL_OUT_OF_MEMORY);
10229 }
10230}
10231
10232void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
10233{
10234 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
10235 program, uniformBlockIndex, bufSize, length, uniformBlockName);
10236
10237 try
10238 {
10239 gl::Context *context = gl::getNonLostContext();
10240
10241 if (context)
10242 {
10243 if (context->getClientVersion() < 3)
10244 {
10245 return gl::error(GL_INVALID_OPERATION);
10246 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010247
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +000010248 gl::Program *programObject = context->getProgram(program);
10249
10250 if (!programObject)
10251 {
10252 if (context->getShader(program))
10253 {
10254 return gl::error(GL_INVALID_OPERATION);
10255 }
10256 else
10257 {
10258 return gl::error(GL_INVALID_VALUE);
10259 }
10260 }
10261
10262 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10263
10264 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
10265 {
10266 return gl::error(GL_INVALID_VALUE);
10267 }
10268
10269 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
10270 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010271 }
10272 catch(std::bad_alloc&)
10273 {
10274 return gl::error(GL_OUT_OF_MEMORY);
10275 }
10276}
10277
10278void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
10279{
10280 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
10281 program, uniformBlockIndex, uniformBlockBinding);
10282
10283 try
10284 {
10285 gl::Context *context = gl::getNonLostContext();
10286
10287 if (context)
10288 {
10289 if (context->getClientVersion() < 3)
10290 {
10291 return gl::error(GL_INVALID_OPERATION);
10292 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010293
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +000010294 if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings())
10295 {
10296 return gl::error(GL_INVALID_VALUE);
10297 }
10298
10299 gl::Program *programObject = context->getProgram(program);
10300
10301 if (!programObject)
10302 {
10303 if (context->getShader(program))
10304 {
10305 return gl::error(GL_INVALID_OPERATION);
10306 }
10307 else
10308 {
10309 return gl::error(GL_INVALID_VALUE);
10310 }
10311 }
10312
10313 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10314
10315 // if never linked, there won't be any uniform blocks
10316 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
10317 {
10318 return gl::error(GL_INVALID_VALUE);
10319 }
10320
10321 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
10322 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010323 }
10324 catch(std::bad_alloc&)
10325 {
10326 return gl::error(GL_OUT_OF_MEMORY);
10327 }
10328}
10329
10330void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
10331{
10332 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
10333 mode, first, count, instanceCount);
10334
10335 try
10336 {
10337 gl::Context *context = gl::getNonLostContext();
10338
10339 if (context)
10340 {
10341 if (context->getClientVersion() < 3)
10342 {
10343 return gl::error(GL_INVALID_OPERATION);
10344 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010345
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010346 UNIMPLEMENTED();
10347 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010348 }
10349 catch(std::bad_alloc&)
10350 {
10351 return gl::error(GL_OUT_OF_MEMORY);
10352 }
10353}
10354
10355void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
10356{
10357 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
10358 mode, count, type, indices, instanceCount);
10359
10360 try
10361 {
10362 gl::Context *context = gl::getNonLostContext();
10363
10364 if (context)
10365 {
10366 if (context->getClientVersion() < 3)
10367 {
10368 return gl::error(GL_INVALID_OPERATION);
10369 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010370
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010371 UNIMPLEMENTED();
10372 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010373 }
10374 catch(std::bad_alloc&)
10375 {
10376 return gl::error(GL_OUT_OF_MEMORY);
10377 }
10378}
10379
10380GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags)
10381{
10382 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
10383
10384 try
10385 {
10386 gl::Context *context = gl::getNonLostContext();
10387
10388 if (context)
10389 {
10390 if (context->getClientVersion() < 3)
10391 {
10392 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(NULL));
10393 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010394
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010395 UNIMPLEMENTED();
10396 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010397 }
10398 catch(std::bad_alloc&)
10399 {
10400 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL));
10401 }
10402
10403 return NULL;
10404}
10405
10406GLboolean __stdcall glIsSync(GLsync sync)
10407{
10408 EVENT("(GLsync sync = 0x%0.8p)", sync);
10409
10410 try
10411 {
10412 gl::Context *context = gl::getNonLostContext();
10413
10414 if (context)
10415 {
10416 if (context->getClientVersion() < 3)
10417 {
10418 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10419 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010420
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010421 UNIMPLEMENTED();
10422 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010423 }
10424 catch(std::bad_alloc&)
10425 {
10426 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10427 }
10428
10429 return GL_FALSE;
10430}
10431
10432void __stdcall glDeleteSync(GLsync sync)
10433{
10434 EVENT("(GLsync sync = 0x%0.8p)", sync);
10435
10436 try
10437 {
10438 gl::Context *context = gl::getNonLostContext();
10439
10440 if (context)
10441 {
10442 if (context->getClientVersion() < 3)
10443 {
10444 return gl::error(GL_INVALID_OPERATION);
10445 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010446
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010447 UNIMPLEMENTED();
10448 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010449 }
10450 catch(std::bad_alloc&)
10451 {
10452 return gl::error(GL_OUT_OF_MEMORY);
10453 }
10454}
10455
10456GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
10457{
10458 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
10459 sync, flags, timeout);
10460
10461 try
10462 {
10463 gl::Context *context = gl::getNonLostContext();
10464
10465 if (context)
10466 {
10467 if (context->getClientVersion() < 3)
10468 {
10469 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10470 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010471
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010472 UNIMPLEMENTED();
10473 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010474 }
10475 catch(std::bad_alloc&)
10476 {
10477 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10478 }
10479
10480 return GL_FALSE;
10481}
10482
10483void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
10484{
10485 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
10486 sync, flags, timeout);
10487
10488 try
10489 {
10490 gl::Context *context = gl::getNonLostContext();
10491
10492 if (context)
10493 {
10494 if (context->getClientVersion() < 3)
10495 {
10496 return gl::error(GL_INVALID_OPERATION);
10497 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010498
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010499 UNIMPLEMENTED();
10500 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010501 }
10502 catch(std::bad_alloc&)
10503 {
10504 return gl::error(GL_OUT_OF_MEMORY);
10505 }
10506}
10507
10508void __stdcall glGetInteger64v(GLenum pname, GLint64* params)
10509{
10510 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
10511 pname, params);
10512
10513 try
10514 {
10515 gl::Context *context = gl::getNonLostContext();
10516
10517 if (context)
10518 {
10519 if (context->getClientVersion() < 3)
10520 {
10521 return gl::error(GL_INVALID_OPERATION);
10522 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010523
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010524 UNIMPLEMENTED();
10525 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010526 }
10527 catch(std::bad_alloc&)
10528 {
10529 return gl::error(GL_OUT_OF_MEMORY);
10530 }
10531}
10532
10533void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
10534{
10535 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
10536 sync, pname, bufSize, length, values);
10537
10538 try
10539 {
10540 gl::Context *context = gl::getNonLostContext();
10541
10542 if (context)
10543 {
10544 if (context->getClientVersion() < 3)
10545 {
10546 return gl::error(GL_INVALID_OPERATION);
10547 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010548
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010549 UNIMPLEMENTED();
10550 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010551 }
10552 catch(std::bad_alloc&)
10553 {
10554 return gl::error(GL_OUT_OF_MEMORY);
10555 }
10556}
10557
10558void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
10559{
10560 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
10561 target, index, data);
10562
10563 try
10564 {
10565 gl::Context *context = gl::getNonLostContext();
10566
10567 if (context)
10568 {
10569 if (context->getClientVersion() < 3)
10570 {
10571 return gl::error(GL_INVALID_OPERATION);
10572 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010573
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010574 UNIMPLEMENTED();
10575 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010576 }
10577 catch(std::bad_alloc&)
10578 {
10579 return gl::error(GL_OUT_OF_MEMORY);
10580 }
10581}
10582
10583void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
10584{
10585 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
10586 target, pname, params);
10587
10588 try
10589 {
10590 gl::Context *context = gl::getNonLostContext();
10591
10592 if (context)
10593 {
10594 if (context->getClientVersion() < 3)
10595 {
10596 return gl::error(GL_INVALID_OPERATION);
10597 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010598
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010599 UNIMPLEMENTED();
10600 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010601 }
10602 catch(std::bad_alloc&)
10603 {
10604 return gl::error(GL_OUT_OF_MEMORY);
10605 }
10606}
10607
10608void __stdcall glGenSamplers(GLsizei count, GLuint* samplers)
10609{
10610 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
10611
10612 try
10613 {
10614 gl::Context *context = gl::getNonLostContext();
10615
10616 if (context)
10617 {
10618 if (context->getClientVersion() < 3)
10619 {
10620 return gl::error(GL_INVALID_OPERATION);
10621 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010622
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010623 UNIMPLEMENTED();
10624 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010625 }
10626 catch(std::bad_alloc&)
10627 {
10628 return gl::error(GL_OUT_OF_MEMORY);
10629 }
10630}
10631
10632void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers)
10633{
10634 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
10635
10636 try
10637 {
10638 gl::Context *context = gl::getNonLostContext();
10639
10640 if (context)
10641 {
10642 if (context->getClientVersion() < 3)
10643 {
10644 return gl::error(GL_INVALID_OPERATION);
10645 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010646
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010647 UNIMPLEMENTED();
10648 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010649 }
10650 catch(std::bad_alloc&)
10651 {
10652 return gl::error(GL_OUT_OF_MEMORY);
10653 }
10654}
10655
10656GLboolean __stdcall glIsSampler(GLuint sampler)
10657{
10658 EVENT("(GLuint sampler = %u)", sampler);
10659
10660 try
10661 {
10662 gl::Context *context = gl::getNonLostContext();
10663
10664 if (context)
10665 {
10666 if (context->getClientVersion() < 3)
10667 {
10668 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10669 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010670
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010671 UNIMPLEMENTED();
10672 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010673 }
10674 catch(std::bad_alloc&)
10675 {
10676 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10677 }
10678
10679 return GL_FALSE;
10680}
10681
10682void __stdcall glBindSampler(GLuint unit, GLuint sampler)
10683{
10684 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
10685
10686 try
10687 {
10688 gl::Context *context = gl::getNonLostContext();
10689
10690 if (context)
10691 {
10692 if (context->getClientVersion() < 3)
10693 {
10694 return gl::error(GL_INVALID_OPERATION);
10695 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010696
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010697 UNIMPLEMENTED();
10698 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010699 }
10700 catch(std::bad_alloc&)
10701 {
10702 return gl::error(GL_OUT_OF_MEMORY);
10703 }
10704}
10705
10706void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
10707{
10708 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
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.org705fc2f2013-05-30 00:17:14 +000010721 UNIMPLEMENTED();
10722 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010723 }
10724 catch(std::bad_alloc&)
10725 {
10726 return gl::error(GL_OUT_OF_MEMORY);
10727 }
10728}
10729
10730void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
10731{
10732 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLint* param = 0x%0.8p)",
10733 sampler, pname, param);
10734
10735 try
10736 {
10737 gl::Context *context = gl::getNonLostContext();
10738
10739 if (context)
10740 {
10741 if (context->getClientVersion() < 3)
10742 {
10743 return gl::error(GL_INVALID_OPERATION);
10744 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010745
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010746 UNIMPLEMENTED();
10747 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010748 }
10749 catch(std::bad_alloc&)
10750 {
10751 return gl::error(GL_OUT_OF_MEMORY);
10752 }
10753}
10754
10755void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
10756{
10757 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
10758
10759 try
10760 {
10761 gl::Context *context = gl::getNonLostContext();
10762
10763 if (context)
10764 {
10765 if (context->getClientVersion() < 3)
10766 {
10767 return gl::error(GL_INVALID_OPERATION);
10768 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010769
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010770 UNIMPLEMENTED();
10771 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010772 }
10773 catch(std::bad_alloc&)
10774 {
10775 return gl::error(GL_OUT_OF_MEMORY);
10776 }
10777}
10778
10779void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
10780{
10781 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLfloat* param = 0x%0.8p)", sampler, pname, param);
10782
10783 try
10784 {
10785 gl::Context *context = gl::getNonLostContext();
10786
10787 if (context)
10788 {
10789 if (context->getClientVersion() < 3)
10790 {
10791 return gl::error(GL_INVALID_OPERATION);
10792 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010793
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010794 UNIMPLEMENTED();
10795 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010796 }
10797 catch(std::bad_alloc&)
10798 {
10799 return gl::error(GL_OUT_OF_MEMORY);
10800 }
10801}
10802
10803void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
10804{
10805 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
10806
10807 try
10808 {
10809 gl::Context *context = gl::getNonLostContext();
10810
10811 if (context)
10812 {
10813 if (context->getClientVersion() < 3)
10814 {
10815 return gl::error(GL_INVALID_OPERATION);
10816 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010817
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010818 UNIMPLEMENTED();
10819 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010820 }
10821 catch(std::bad_alloc&)
10822 {
10823 return gl::error(GL_OUT_OF_MEMORY);
10824 }
10825}
10826
10827void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
10828{
10829 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
10830
10831 try
10832 {
10833 gl::Context *context = gl::getNonLostContext();
10834
10835 if (context)
10836 {
10837 if (context->getClientVersion() < 3)
10838 {
10839 return gl::error(GL_INVALID_OPERATION);
10840 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010841
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010842 UNIMPLEMENTED();
10843 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010844 }
10845 catch(std::bad_alloc&)
10846 {
10847 return gl::error(GL_OUT_OF_MEMORY);
10848 }
10849}
10850
10851void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor)
10852{
10853 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
10854
10855 try
10856 {
shannon.woods%transgaming.com@gtempaccount.com8736bd62013-04-13 03:35:41 +000010857 if (index >= gl::MAX_VERTEX_ATTRIBS)
10858 {
10859 return gl::error(GL_INVALID_VALUE);
10860 }
10861
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010862 gl::Context *context = gl::getNonLostContext();
10863
10864 if (context)
10865 {
10866 if (context->getClientVersion() < 3)
10867 {
10868 return gl::error(GL_INVALID_OPERATION);
10869 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010870
shannon.woods%transgaming.com@gtempaccount.com8736bd62013-04-13 03:35:41 +000010871 context->setVertexAttribDivisor(index, divisor);
10872 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010873 }
10874 catch(std::bad_alloc&)
10875 {
10876 return gl::error(GL_OUT_OF_MEMORY);
10877 }
10878}
10879
10880void __stdcall glBindTransformFeedback(GLenum target, GLuint id)
10881{
10882 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
10883
10884 try
10885 {
10886 gl::Context *context = gl::getNonLostContext();
10887
10888 if (context)
10889 {
10890 if (context->getClientVersion() < 3)
10891 {
10892 return gl::error(GL_INVALID_OPERATION);
10893 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010894
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010895 UNIMPLEMENTED();
10896 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010897 }
10898 catch(std::bad_alloc&)
10899 {
10900 return gl::error(GL_OUT_OF_MEMORY);
10901 }
10902}
10903
10904void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
10905{
10906 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
10907
10908 try
10909 {
10910 gl::Context *context = gl::getNonLostContext();
10911
10912 if (context)
10913 {
10914 if (context->getClientVersion() < 3)
10915 {
10916 return gl::error(GL_INVALID_OPERATION);
10917 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010918
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010919 UNIMPLEMENTED();
10920 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010921 }
10922 catch(std::bad_alloc&)
10923 {
10924 return gl::error(GL_OUT_OF_MEMORY);
10925 }
10926}
10927
10928void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids)
10929{
10930 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
10931
10932 try
10933 {
10934 gl::Context *context = gl::getNonLostContext();
10935
10936 if (context)
10937 {
10938 if (context->getClientVersion() < 3)
10939 {
10940 return gl::error(GL_INVALID_OPERATION);
10941 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010942
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010943 UNIMPLEMENTED();
10944 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010945 }
10946 catch(std::bad_alloc&)
10947 {
10948 return gl::error(GL_OUT_OF_MEMORY);
10949 }
10950}
10951
10952GLboolean __stdcall glIsTransformFeedback(GLuint id)
10953{
10954 EVENT("(GLuint id = %u)", id);
10955
10956 try
10957 {
10958 gl::Context *context = gl::getNonLostContext();
10959
10960 if (context)
10961 {
10962 if (context->getClientVersion() < 3)
10963 {
10964 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10965 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010966
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010967 UNIMPLEMENTED();
10968 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010969 }
10970 catch(std::bad_alloc&)
10971 {
10972 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10973 }
10974
10975 return GL_FALSE;
10976}
10977
10978void __stdcall glPauseTransformFeedback(void)
10979{
10980 EVENT("(void)");
10981
10982 try
10983 {
10984 gl::Context *context = gl::getNonLostContext();
10985
10986 if (context)
10987 {
10988 if (context->getClientVersion() < 3)
10989 {
10990 return gl::error(GL_INVALID_OPERATION);
10991 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010992
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010993 UNIMPLEMENTED();
10994 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010995 }
10996 catch(std::bad_alloc&)
10997 {
10998 return gl::error(GL_OUT_OF_MEMORY);
10999 }
11000}
11001
11002void __stdcall glResumeTransformFeedback(void)
11003{
11004 EVENT("(void)");
11005
11006 try
11007 {
11008 gl::Context *context = gl::getNonLostContext();
11009
11010 if (context)
11011 {
11012 if (context->getClientVersion() < 3)
11013 {
11014 return gl::error(GL_INVALID_OPERATION);
11015 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011016
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011017 UNIMPLEMENTED();
11018 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011019 }
11020 catch(std::bad_alloc&)
11021 {
11022 return gl::error(GL_OUT_OF_MEMORY);
11023 }
11024}
11025
11026void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
11027{
11028 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
11029 program, bufSize, length, binaryFormat, binary);
11030
11031 try
11032 {
11033 gl::Context *context = gl::getNonLostContext();
11034
11035 if (context)
11036 {
11037 if (context->getClientVersion() < 3)
11038 {
11039 return gl::error(GL_INVALID_OPERATION);
11040 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011041
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011042 UNIMPLEMENTED();
11043 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011044 }
11045 catch(std::bad_alloc&)
11046 {
11047 return gl::error(GL_OUT_OF_MEMORY);
11048 }
11049}
11050
11051void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
11052{
11053 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
11054 program, binaryFormat, binary, length);
11055
11056 try
11057 {
11058 gl::Context *context = gl::getNonLostContext();
11059
11060 if (context)
11061 {
11062 if (context->getClientVersion() < 3)
11063 {
11064 return gl::error(GL_INVALID_OPERATION);
11065 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011066
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011067 UNIMPLEMENTED();
11068 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011069 }
11070 catch(std::bad_alloc&)
11071 {
11072 return gl::error(GL_OUT_OF_MEMORY);
11073 }
11074}
11075
11076void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value)
11077{
11078 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
11079 program, pname, value);
11080
11081 try
11082 {
11083 gl::Context *context = gl::getNonLostContext();
11084
11085 if (context)
11086 {
11087 if (context->getClientVersion() < 3)
11088 {
11089 return gl::error(GL_INVALID_OPERATION);
11090 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011091
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011092 UNIMPLEMENTED();
11093 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011094 }
11095 catch(std::bad_alloc&)
11096 {
11097 return gl::error(GL_OUT_OF_MEMORY);
11098 }
11099}
11100
11101void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
11102{
11103 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
11104 target, numAttachments, attachments);
11105
11106 try
11107 {
11108 gl::Context *context = gl::getNonLostContext();
11109
11110 if (context)
11111 {
11112 if (context->getClientVersion() < 3)
11113 {
11114 return gl::error(GL_INVALID_OPERATION);
11115 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011116
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +000011117 if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
11118 {
11119 return;
11120 }
11121
11122 int maxDimension = context->getMaximumRenderbufferDimension();
11123 context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension);
11124 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011125 }
11126 catch(std::bad_alloc&)
11127 {
11128 return gl::error(GL_OUT_OF_MEMORY);
11129 }
11130}
11131
11132void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
11133{
11134 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
11135 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
11136 target, numAttachments, attachments, x, y, width, height);
11137
11138 try
11139 {
11140 gl::Context *context = gl::getNonLostContext();
11141
11142 if (context)
11143 {
11144 if (context->getClientVersion() < 3)
11145 {
11146 return gl::error(GL_INVALID_OPERATION);
11147 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011148
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +000011149 if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
11150 {
11151 return;
11152 }
11153
11154 context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height);
11155 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011156 }
11157 catch(std::bad_alloc&)
11158 {
11159 return gl::error(GL_OUT_OF_MEMORY);
11160 }
11161}
11162
11163void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
11164{
11165 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
11166 target, levels, internalformat, width, height);
11167
11168 try
11169 {
11170 gl::Context *context = gl::getNonLostContext();
11171
11172 if (context)
11173 {
11174 if (context->getClientVersion() < 3)
11175 {
11176 return gl::error(GL_INVALID_OPERATION);
11177 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011178
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +000011179 if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
11180 {
11181 return;
11182 }
11183
11184 switch (target)
11185 {
11186 case GL_TEXTURE_2D:
11187 {
11188 gl::Texture2D *texture2d = context->getTexture2D();
11189 texture2d->storage(levels, internalformat, width, height);
11190 }
11191 break;
11192
11193 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
11194 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
11195 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
11196 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
11197 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
11198 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
11199 {
11200 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
11201 textureCube->storage(levels, internalformat, width);
11202 }
11203 break;
11204
11205 default:
11206 return gl::error(GL_INVALID_ENUM);
11207 }
11208 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011209 }
11210 catch(std::bad_alloc&)
11211 {
11212 return gl::error(GL_OUT_OF_MEMORY);
11213 }
11214}
11215
11216void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
11217{
11218 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
11219 "GLsizei height = %d, GLsizei depth = %d)",
11220 target, levels, internalformat, width, height, depth);
11221
11222 try
11223 {
11224 gl::Context *context = gl::getNonLostContext();
11225
11226 if (context)
11227 {
11228 if (context->getClientVersion() < 3)
11229 {
11230 return gl::error(GL_INVALID_OPERATION);
11231 }
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +000011232
11233 if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
11234 {
11235 return;
11236 }
11237
11238 switch (target)
11239 {
11240 case GL_TEXTURE_3D:
11241 {
11242 gl::Texture3D *texture3d = context->getTexture3D();
11243 texture3d->storage(levels, internalformat, width, height, depth);
11244 }
11245 break;
11246
11247 case GL_TEXTURE_2D_ARRAY:
11248 {
11249 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
11250 texture2darray->storage(levels, internalformat, width, height, depth);
11251 }
11252 break;
11253
11254 default:
11255 return gl::error(GL_INVALID_ENUM);
11256 }
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +000011257 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011258 }
11259 catch(std::bad_alloc&)
11260 {
11261 return gl::error(GL_OUT_OF_MEMORY);
11262 }
11263}
11264
11265void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
11266{
11267 EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
11268 "GLint* params = 0x%0.8p)",
11269 target, internalformat, pname, bufSize, params);
11270
11271 try
11272 {
11273 gl::Context *context = gl::getNonLostContext();
11274
11275 if (context)
11276 {
11277 if (context->getClientVersion() < 3)
11278 {
11279 return gl::error(GL_INVALID_OPERATION);
11280 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011281
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011282 UNIMPLEMENTED();
11283 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011284 }
11285 catch(std::bad_alloc&)
11286 {
11287 return gl::error(GL_OUT_OF_MEMORY);
11288 }
11289}
11290
11291// Extension functions
11292
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011293void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
11294 GLbitfield mask, GLenum filter)
11295{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000011296 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011297 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
11298 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
11299 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
11300
11301 try
11302 {
11303 switch (filter)
11304 {
11305 case GL_NEAREST:
11306 break;
11307 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011308 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011309 }
11310
11311 if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0)
11312 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011313 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011314 }
11315
11316 if (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0)
11317 {
11318 ERR("Scaling and flipping in BlitFramebufferANGLE not supported by this implementation");
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011319 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011320 }
11321
daniel@transgaming.com9d788502011-11-09 17:46:55 +000011322 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011323
11324 if (context)
11325 {
11326 if (context->getReadFramebufferHandle() == context->getDrawFramebufferHandle())
11327 {
11328 ERR("Blits with the same source and destination framebuffer are not supported by this implementation.");
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011329 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011330 }
11331
11332 context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask);
11333 }
11334 }
11335 catch(std::bad_alloc&)
11336 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011337 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011338 }
11339}
11340
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +000011341void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
11342 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011343{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000011344 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +000011345 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +000011346 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011347 target, level, internalformat, width, height, depth, border, format, type, pixels);
11348
11349 try
11350 {
11351 UNIMPLEMENTED(); // FIXME
11352 }
11353 catch(std::bad_alloc&)
11354 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011355 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011356 }
11357}
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011358
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011359void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
11360 GLenum *binaryFormat, void *binary)
11361{
apatrick@chromium.org90080e32012-07-09 22:15:33 +000011362 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 +000011363 program, bufSize, length, binaryFormat, binary);
11364
11365 try
11366 {
11367 gl::Context *context = gl::getNonLostContext();
11368
11369 if (context)
11370 {
11371 gl::Program *programObject = context->getProgram(program);
11372
daniel@transgaming.com716056c2012-07-24 18:38:59 +000011373 if (!programObject || !programObject->isLinked())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011374 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011375 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011376 }
11377
11378 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
11379
11380 if (!programBinary)
11381 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011382 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011383 }
11384
apatrick@chromium.org90080e32012-07-09 22:15:33 +000011385 if (!programBinary->save(binary, bufSize, length))
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011386 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011387 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011388 }
apatrick@chromium.org90080e32012-07-09 22:15:33 +000011389
11390 *binaryFormat = GL_PROGRAM_BINARY_ANGLE;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011391 }
11392 }
11393 catch(std::bad_alloc&)
11394 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011395 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011396 }
11397}
11398
11399void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat,
11400 const void *binary, GLint length)
11401{
11402 EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
11403 program, binaryFormat, binary, length);
11404
11405 try
11406 {
11407 gl::Context *context = gl::getNonLostContext();
11408
11409 if (context)
11410 {
11411 if (binaryFormat != GL_PROGRAM_BINARY_ANGLE)
11412 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011413 return gl::error(GL_INVALID_ENUM);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011414 }
11415
11416 gl::Program *programObject = context->getProgram(program);
11417
11418 if (!programObject)
11419 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011420 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011421 }
11422
daniel@transgaming.com95d29422012-07-24 18:36:10 +000011423 context->setProgramBinary(program, binary, length);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011424 }
11425 }
11426 catch(std::bad_alloc&)
11427 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011428 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011429 }
11430}
11431
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011432void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
11433{
11434 EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
11435
11436 try
11437 {
11438 gl::Context *context = gl::getNonLostContext();
11439
11440 if (context)
11441 {
11442 if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets())
11443 {
11444 return gl::error(GL_INVALID_VALUE);
11445 }
11446
11447 if (context->getDrawFramebufferHandle() == 0)
11448 {
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011449 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011450 {
11451 return gl::error(GL_INVALID_OPERATION);
11452 }
11453
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011454 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011455 {
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011456 return gl::error(GL_INVALID_OPERATION);
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011457 }
11458 }
11459 else
11460 {
11461 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
11462 {
11463 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
11464 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
11465 {
11466 return gl::error(GL_INVALID_OPERATION);
11467 }
11468 }
11469 }
11470
11471 gl::Framebuffer *framebuffer = context->getDrawFramebuffer();
11472
11473 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
11474 {
11475 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
11476 }
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011477
11478 for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++)
11479 {
11480 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
11481 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011482 }
11483 }
11484 catch (std::bad_alloc&)
11485 {
11486 return gl::error(GL_OUT_OF_MEMORY);
11487 }
11488}
11489
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011490__eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname)
11491{
11492 struct Extension
11493 {
11494 const char *name;
11495 __eglMustCastToProperFunctionPointerType address;
11496 };
11497
11498 static const Extension glExtensions[] =
11499 {
11500 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +000011501 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +000011502 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000011503 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
11504 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
11505 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
11506 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
11507 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
11508 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
11509 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +000011510 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +000011511 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +000011512 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
11513 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
11514 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
11515 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000011516 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
11517 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
11518 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
11519 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
11520 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
11521 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
11522 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +000011523 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +000011524 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
11525 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
11526 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011527 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
11528 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011529
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +000011530 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011531 {
11532 if (strcmp(procname, glExtensions[ext].name) == 0)
11533 {
11534 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
11535 }
11536 }
11537
11538 return NULL;
11539}
11540
daniel@transgaming.com17f548c2011-11-09 17:47:02 +000011541// Non-public functions used by EGL
11542
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000011543bool __stdcall glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011544{
11545 EVENT("(egl::Surface* surface = 0x%0.8p)",
11546 surface);
11547
11548 try
11549 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +000011550 gl::Context *context = gl::getNonLostContext();
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011551
11552 if (context)
11553 {
11554 gl::Texture2D *textureObject = context->getTexture2D();
11555
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000011556 if (textureObject->isImmutable())
11557 {
11558 return false;
11559 }
11560
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011561 if (textureObject)
11562 {
11563 textureObject->bindTexImage(surface);
11564 }
11565 }
11566 }
11567 catch(std::bad_alloc&)
11568 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011569 return gl::error(GL_OUT_OF_MEMORY, false);
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011570 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000011571
11572 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011573}
11574
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011575}