blob: 7d0b154bc7154a8f128bed9b7171f37fa8b29a48 [file] [log] [blame]
shannon.woods@transgaming.combdf2d802013-02-28 23:16:20 +00001#include "precompiled.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002//
shannon.woods%transgaming.com@gtempaccount.com8dce6512013-04-13 03:42:19 +00003// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004// Use of this source code is governed by a BSD-style license that can be
5// found in the LICENSE file.
6//
7
8// libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions.
9
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +000010#include "common/version.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000011
12#include "libGLESv2/main.h"
shannonwoods@chromium.orga2ecfcc2013-05-30 00:11:59 +000013#include "common/utilities.h"
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +000014#include "libGLESv2/formatutils.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000015#include "libGLESv2/Buffer.h"
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000016#include "libGLESv2/Fence.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000017#include "libGLESv2/Framebuffer.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000018#include "libGLESv2/Renderbuffer.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000019#include "libGLESv2/Program.h"
apatrick@chromium.orgea09f9b2012-06-08 00:45:32 +000020#include "libGLESv2/ProgramBinary.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000021#include "libGLESv2/Texture.h"
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000022#include "libGLESv2/Query.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000023#include "libGLESv2/Context.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000024
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +000025bool validImageSize(const gl::Context *context, GLint level, GLsizei width, GLsizei height, GLsizei depth)
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000026{
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +000027 if (level < 0 || width < 0 || height < 0 || depth < 0)
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000028 {
29 return false;
30 }
31
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +000032 if (context->supportsNonPower2Texture())
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000033 {
34 return true;
35 }
36
37 if (level == 0)
38 {
39 return true;
40 }
41
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +000042 if (gl::isPow2(width) && gl::isPow2(height) && gl::isPow2(depth))
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000043 {
44 return true;
45 }
46
47 return false;
48}
49
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +000050bool validCompressedImageSize(GLsizei width, GLsizei height)
51{
52 if (width != 1 && width != 2 && width % 4 != 0)
53 {
54 return false;
55 }
56
57 if (height != 1 && height != 2 && height % 4 != 0)
58 {
59 return false;
60 }
61
62 return true;
63}
64
daniel@transgaming.com8833dd22012-06-05 19:49:58 +000065// Verify that format/type are one of the combinations from table 3.4.
66bool checkTextureFormatType(GLenum format, GLenum type)
67{
68 // validate <format> by itself (used as secondary key below)
69 switch (format)
70 {
71 case GL_RGBA:
72 case GL_BGRA_EXT:
73 case GL_RGB:
74 case GL_ALPHA:
75 case GL_LUMINANCE:
76 case GL_LUMINANCE_ALPHA:
77 case GL_DEPTH_COMPONENT:
78 case GL_DEPTH_STENCIL_OES:
79 break;
80 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000081 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +000082 }
83
84 // invalid <type> -> sets INVALID_ENUM
85 // invalid <format>+<type> combination -> sets INVALID_OPERATION
86 switch (type)
87 {
88 case GL_UNSIGNED_BYTE:
89 switch (format)
90 {
91 case GL_RGBA:
92 case GL_BGRA_EXT:
93 case GL_RGB:
94 case GL_ALPHA:
95 case GL_LUMINANCE:
96 case GL_LUMINANCE_ALPHA:
97 return true;
98 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000099 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000100 }
101
102 case GL_FLOAT:
103 case GL_HALF_FLOAT_OES:
104 switch (format)
105 {
106 case GL_RGBA:
107 case GL_RGB:
108 case GL_ALPHA:
109 case GL_LUMINANCE:
110 case GL_LUMINANCE_ALPHA:
111 return true;
112 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000113 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000114 }
115
116 case GL_UNSIGNED_SHORT_4_4_4_4:
117 case GL_UNSIGNED_SHORT_5_5_5_1:
118 switch (format)
119 {
120 case GL_RGBA:
121 return true;
122 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000123 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000124 }
125
126 case GL_UNSIGNED_SHORT_5_6_5:
127 switch (format)
128 {
129 case GL_RGB:
130 return true;
131 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000132 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000133 }
134
135 case GL_UNSIGNED_SHORT:
136 case GL_UNSIGNED_INT:
137 switch (format)
138 {
139 case GL_DEPTH_COMPONENT:
140 return true;
141 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000142 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000143 }
144
145 case GL_UNSIGNED_INT_24_8_OES:
146 switch (format)
147 {
148 case GL_DEPTH_STENCIL_OES:
149 return true;
150 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000151 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000152 }
153
154 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000155 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000156 }
157}
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000158
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000159bool validateSubImageParams2D(bool compressed, GLsizei width, GLsizei height,
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000160 GLint xoffset, GLint yoffset, GLint level, GLenum format, GLenum type,
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000161 gl::Texture2D *texture)
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000162{
163 if (!texture)
164 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000165 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000166 }
167
daniel@transgaming.com92f49922012-05-09 15:49:19 +0000168 if (compressed != texture->isCompressed(level))
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000169 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000170 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000171 }
172
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000173 if (format != GL_NONE)
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000174 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000175 GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000176 if (internalformat != texture->getInternalFormat(level))
177 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000178 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000179 }
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000180 }
181
182 if (compressed)
183 {
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000184 if ((width % 4 != 0 && width != texture->getWidth(0)) ||
185 (height % 4 != 0 && height != texture->getHeight(0)))
186 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000187 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000188 }
189 }
190
191 if (xoffset + width > texture->getWidth(level) ||
192 yoffset + height > texture->getHeight(level))
193 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000194 return gl::error(GL_INVALID_VALUE, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000195 }
196
197 return true;
198}
199
200bool validateSubImageParamsCube(bool compressed, GLsizei width, GLsizei height,
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000201 GLint xoffset, GLint yoffset, GLenum target, GLint level, GLenum format, GLenum type,
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000202 gl::TextureCubeMap *texture)
203{
204 if (!texture)
205 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000206 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000207 }
208
daniel@transgaming.com4df88e82012-05-09 15:49:24 +0000209 if (compressed != texture->isCompressed(target, level))
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000210 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000211 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000212 }
213
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000214 if (format != GL_NONE)
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000215 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000216 GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000217 if (internalformat != texture->getInternalFormat(target, level))
218 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000219 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000220 }
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000221 }
222
223 if (compressed)
224 {
daniel@transgaming.com4df88e82012-05-09 15:49:24 +0000225 if ((width % 4 != 0 && width != texture->getWidth(target, 0)) ||
226 (height % 4 != 0 && height != texture->getHeight(target, 0)))
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000227 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000228 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000229 }
230 }
231
daniel@transgaming.com4df88e82012-05-09 15:49:24 +0000232 if (xoffset + width > texture->getWidth(target, level) ||
233 yoffset + height > texture->getHeight(target, level))
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000234 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000235 return gl::error(GL_INVALID_VALUE, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000236 }
237
238 return true;
239}
240
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000241bool validateES2TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage,
242 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
243 GLint border, GLenum format, GLenum type, const GLvoid *pixels)
244{
245 if (!validImageSize(context, level, width, height, 1))
246 {
247 return gl::error(GL_INVALID_VALUE, false);
248 }
249
250 if (isCompressed && !validCompressedImageSize(width, height))
251 {
252 return gl::error(GL_INVALID_OPERATION, false);
253 }
254
255 if (level < 0 || xoffset < 0 ||
256 std::numeric_limits<GLsizei>::max() - xoffset < width ||
257 std::numeric_limits<GLsizei>::max() - yoffset < height)
258 {
259 return gl::error(GL_INVALID_VALUE, false);
260 }
261
262 if (!isSubImage && !isCompressed && internalformat != GLint(format))
263 {
264 return gl::error(GL_INVALID_OPERATION, false);
265 }
266
267 gl::Texture *texture = NULL;
268 bool textureCompressed = false;
269 GLenum textureInternalFormat = GL_NONE;
270 GLint textureLevelWidth = 0;
271 GLint textureLevelHeight = 0;
272 switch (target)
273 {
274 case GL_TEXTURE_2D:
275 {
276 if (width > (context->getMaximum2DTextureDimension() >> level) ||
277 height > (context->getMaximum2DTextureDimension() >> level))
278 {
279 return gl::error(GL_INVALID_VALUE, false);
280 }
281
282 gl::Texture2D *tex2d = context->getTexture2D();
283 if (tex2d)
284 {
285 textureCompressed = tex2d->isCompressed(level);
286 textureInternalFormat = tex2d->getInternalFormat(level);
287 textureLevelWidth = tex2d->getWidth(level);
288 textureLevelHeight = tex2d->getHeight(level);
289 texture = tex2d;
290 }
291
292 if (isSubImage && !validateSubImageParams2D(isCompressed, width, height, xoffset, yoffset,
293 level, format, type, tex2d))
294 {
295 return false;
296 }
297
298 texture = tex2d;
299 }
300 break;
301
302 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
303 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
304 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
305 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
306 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
307 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
308 {
309 if (!isSubImage && width != height)
310 {
311 return gl::error(GL_INVALID_VALUE, false);
312 }
313
314 if (width > (context->getMaximumCubeTextureDimension() >> level) ||
315 height > (context->getMaximumCubeTextureDimension() >> level))
316 {
317 return gl::error(GL_INVALID_VALUE, false);
318 }
319
320 gl::TextureCubeMap *texCube = context->getTextureCubeMap();
321 if (texCube)
322 {
323 textureCompressed = texCube->isCompressed(target, level);
324 textureInternalFormat = texCube->getInternalFormat(target, level);
325 textureLevelWidth = texCube->getWidth(target, level);
326 textureLevelHeight = texCube->getHeight(target, level);
327 texture = texCube;
328 }
329
330 if (isSubImage && !validateSubImageParamsCube(isCompressed, width, height, xoffset, yoffset,
331 target, level, format, type, texCube))
332 {
333 return false;
334 }
335 }
336 break;
337
338 default:
339 return gl::error(GL_INVALID_ENUM, false);
340 }
341
342 if (!texture)
343 {
344 return gl::error(GL_INVALID_OPERATION, false);
345 }
346
347 if (!isSubImage && texture->isImmutable())
348 {
349 return gl::error(GL_INVALID_OPERATION, false);
350 }
351
352 // Verify zero border
353 if (border != 0)
354 {
355 return gl::error(GL_INVALID_VALUE, false);
356 }
357
358 // Verify texture is not requesting more mip levels than are available.
359 if (level > context->getMaximumTextureLevel())
360 {
361 return gl::error(GL_INVALID_VALUE, false);
362 }
363
364 GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat;
365 if (isCompressed)
366 {
367 switch (actualInternalFormat)
368 {
369 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
370 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
371 if (!context->supportsDXT1Textures())
372 {
373 return gl::error(GL_INVALID_ENUM, false);
374 }
375 break;
376 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
377 if (!context->supportsDXT3Textures())
378 {
379 return gl::error(GL_INVALID_ENUM, false);
380 }
381 break;
382 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
383 if (!context->supportsDXT5Textures())
384 {
385 return gl::error(GL_INVALID_ENUM, false);
386 }
387 break;
388 default:
389 return gl::error(GL_INVALID_ENUM, false);
390 }
391 }
392 else
393 {
394 // validate <type> by itself (used as secondary key below)
395 switch (type)
396 {
397 case GL_UNSIGNED_BYTE:
398 case GL_UNSIGNED_SHORT_5_6_5:
399 case GL_UNSIGNED_SHORT_4_4_4_4:
400 case GL_UNSIGNED_SHORT_5_5_5_1:
401 case GL_UNSIGNED_SHORT:
402 case GL_UNSIGNED_INT:
403 case GL_UNSIGNED_INT_24_8_OES:
404 case GL_HALF_FLOAT_OES:
405 case GL_FLOAT:
406 break;
407 default:
408 return gl::error(GL_INVALID_ENUM, false);
409 }
410
411 // validate <format> + <type> combinations
412 // - invalid <format> -> sets INVALID_ENUM
413 // - invalid <format>+<type> combination -> sets INVALID_OPERATION
414 switch (format)
415 {
416 case GL_ALPHA:
417 case GL_LUMINANCE:
418 case GL_LUMINANCE_ALPHA:
419 switch (type)
420 {
421 case GL_UNSIGNED_BYTE:
422 case GL_FLOAT:
423 case GL_HALF_FLOAT_OES:
424 break;
425 default:
426 return gl::error(GL_INVALID_OPERATION, false);
427 }
428 break;
429 case GL_RGB:
430 switch (type)
431 {
432 case GL_UNSIGNED_BYTE:
433 case GL_UNSIGNED_SHORT_5_6_5:
434 case GL_FLOAT:
435 case GL_HALF_FLOAT_OES:
436 break;
437 default:
438 return gl::error(GL_INVALID_OPERATION, false);
439 }
440 break;
441 case GL_RGBA:
442 switch (type)
443 {
444 case GL_UNSIGNED_BYTE:
445 case GL_UNSIGNED_SHORT_4_4_4_4:
446 case GL_UNSIGNED_SHORT_5_5_5_1:
447 case GL_FLOAT:
448 case GL_HALF_FLOAT_OES:
449 break;
450 default:
451 return gl::error(GL_INVALID_OPERATION, false);
452 }
453 break;
454 case GL_BGRA_EXT:
455 switch (type)
456 {
457 case GL_UNSIGNED_BYTE:
458 break;
459 default:
460 return gl::error(GL_INVALID_OPERATION, false);
461 }
462 break;
463 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below
464 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
465 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
466 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
467 break;
468 case GL_DEPTH_COMPONENT:
469 switch (type)
470 {
471 case GL_UNSIGNED_SHORT:
472 case GL_UNSIGNED_INT:
473 break;
474 default:
475 return gl::error(GL_INVALID_OPERATION, false);
476 }
477 break;
478 case GL_DEPTH_STENCIL_OES:
479 switch (type)
480 {
481 case GL_UNSIGNED_INT_24_8_OES:
482 break;
483 default:
484 return gl::error(GL_INVALID_OPERATION, false);
485 }
486 break;
487 default:
488 return gl::error(GL_INVALID_ENUM, false);
489 }
490
491 switch (format)
492 {
493 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
494 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
495 if (context->supportsDXT1Textures())
496 {
497 return gl::error(GL_INVALID_OPERATION, false);
498 }
499 else
500 {
501 return gl::error(GL_INVALID_ENUM, false);
502 }
503 break;
504 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
505 if (context->supportsDXT3Textures())
506 {
507 return gl::error(GL_INVALID_OPERATION, false);
508 }
509 else
510 {
511 return gl::error(GL_INVALID_ENUM, false);
512 }
513 break;
514 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
515 if (context->supportsDXT5Textures())
516 {
517 return gl::error(GL_INVALID_OPERATION, false);
518 }
519 else
520 {
521 return gl::error(GL_INVALID_ENUM, false);
522 }
523 break;
524 case GL_DEPTH_COMPONENT:
525 case GL_DEPTH_STENCIL_OES:
526 if (!context->supportsDepthTextures())
527 {
528 return gl::error(GL_INVALID_VALUE, false);
529 }
530 if (target != GL_TEXTURE_2D)
531 {
532 return gl::error(GL_INVALID_OPERATION, false);
533 }
534 // OES_depth_texture supports loading depth data and multiple levels,
535 // but ANGLE_depth_texture does not
536 if (pixels != NULL || level != 0)
537 {
538 return gl::error(GL_INVALID_OPERATION, false);
539 }
540 break;
541 default:
542 break;
543 }
544
545 if (type == GL_FLOAT)
546 {
547 if (!context->supportsFloat32Textures())
548 {
549 return gl::error(GL_INVALID_ENUM, false);
550 }
551 }
552 else if (type == GL_HALF_FLOAT_OES)
553 {
554 if (!context->supportsFloat16Textures())
555 {
556 return gl::error(GL_INVALID_ENUM, false);
557 }
558 }
559 }
560
561 return true;
562}
563
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +0000564bool validateES3TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage,
565 GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
566 GLint border, GLenum format, GLenum type)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000567{
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000568 // Validate image size
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000569 if (!validImageSize(context, level, width, height, depth))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000570 {
571 return gl::error(GL_INVALID_VALUE, false);
572 }
573
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000574 if (isCompressed && !validCompressedImageSize(width, height))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000575 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000576 return gl::error(GL_INVALID_OPERATION, false);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000577 }
578
579 // Verify zero border
580 if (border != 0)
581 {
582 return gl::error(GL_INVALID_VALUE, false);
583 }
584
585 // Validate dimensions based on Context limits and validate the texture
586 if (level > context->getMaximumTextureLevel())
587 {
588 return gl::error(GL_INVALID_VALUE, false);
589 }
590
591 gl::Texture *texture = NULL;
592 bool textureCompressed = false;
593 GLenum textureInternalFormat = GL_NONE;
594 GLint textureLevelWidth = 0;
595 GLint textureLevelHeight = 0;
596 GLint textureLevelDepth = 0;
597 switch (target)
598 {
599 case GL_TEXTURE_2D:
600 {
601 if (width > (context->getMaximum2DTextureDimension() >> level) ||
602 height > (context->getMaximum2DTextureDimension() >> level))
603 {
604 return gl::error(GL_INVALID_VALUE, false);
605 }
606
607 gl::Texture2D *texture2d = context->getTexture2D();
608 if (texture2d)
609 {
610 textureCompressed = texture2d->isCompressed(level);
611 textureInternalFormat = texture2d->getInternalFormat(level);
612 textureLevelWidth = texture2d->getWidth(level);
613 textureLevelHeight = texture2d->getHeight(level);
614 textureLevelDepth = 1;
615 texture = texture2d;
616 }
617 }
618 break;
619
620 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
621 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
622 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
623 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
624 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
625 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
626 {
shannonwoods@chromium.org92852cf2013-05-30 00:14:12 +0000627 if (!isSubImage && width != height)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000628 {
629 return gl::error(GL_INVALID_VALUE, false);
630 }
631
632 if (width > (context->getMaximumCubeTextureDimension() >> level))
633 {
634 return gl::error(GL_INVALID_VALUE, false);
635 }
636
637 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
638 if (textureCube)
639 {
640 textureCompressed = textureCube->isCompressed(target, level);
641 textureInternalFormat = textureCube->getInternalFormat(target, level);
642 textureLevelWidth = textureCube->getWidth(target, level);
643 textureLevelHeight = textureCube->getHeight(target, level);
644 textureLevelDepth = 1;
645 texture = textureCube;
646 }
647 }
648 break;
649
650 case GL_TEXTURE_3D:
651 {
652 if (width > (context->getMaximum3DTextureDimension() >> level) ||
653 height > (context->getMaximum3DTextureDimension() >> level) ||
654 depth > (context->getMaximum3DTextureDimension() >> level))
655 {
656 return gl::error(GL_INVALID_VALUE, false);
657 }
658
659 gl::Texture3D *texture3d = context->getTexture3D();
660 if (texture3d)
661 {
662 textureCompressed = texture3d->isCompressed(level);
663 textureInternalFormat = texture3d->getInternalFormat(level);
664 textureLevelWidth = texture3d->getWidth(level);
665 textureLevelHeight = texture3d->getHeight(level);
666 textureLevelDepth = texture3d->getDepth(level);
667 texture = texture3d;
668 }
669 }
670 break;
671
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +0000672 case GL_TEXTURE_2D_ARRAY:
673 {
674 if (width > (context->getMaximum2DTextureDimension() >> level) ||
675 height > (context->getMaximum2DTextureDimension() >> level) ||
676 depth > (context->getMaximum2DArrayTextureLayers() >> level))
677 {
678 return gl::error(GL_INVALID_VALUE, false);
679 }
680
681 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
682 if (texture2darray)
683 {
684 textureCompressed = texture2darray->isCompressed(level);
685 textureInternalFormat = texture2darray->getInternalFormat(level);
686 textureLevelWidth = texture2darray->getWidth(level);
687 textureLevelHeight = texture2darray->getHeight(level);
688 textureLevelDepth = texture2darray->getDepth(level);
689 texture = texture2darray;
690 }
691 }
692 break;
693
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000694 default:
695 return gl::error(GL_INVALID_ENUM, false);
696 }
697
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000698 if (!texture)
699 {
700 return gl::error(GL_INVALID_OPERATION, false);
701 }
702
shannonwoods@chromium.orgcf2533c2013-05-30 00:14:18 +0000703 if (texture->isImmutable() && !isSubImage)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000704 {
705 return gl::error(GL_INVALID_OPERATION, false);
706 }
707
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000708 // Validate texture formats
709 GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat;
710 if (isCompressed)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000711 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000712 if (!gl::IsFormatCompressed(actualInternalFormat, context->getClientVersion()))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000713 {
714 return gl::error(GL_INVALID_ENUM, false);
715 }
716
717 if (target == GL_TEXTURE_3D)
718 {
719 return gl::error(GL_INVALID_OPERATION, false);
720 }
721 }
722 else
723 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000724 if (!gl::IsValidInternalFormat(actualInternalFormat, context) ||
725 !gl::IsValidFormat(format, context->getClientVersion()) ||
726 !gl::IsValidType(type, context->getClientVersion()))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000727 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000728 return gl::error(GL_INVALID_ENUM, false);
729 }
730
731 if (!gl::IsValidFormatCombination(actualInternalFormat, format, type, context->getClientVersion()))
732 {
733 return gl::error(GL_INVALID_OPERATION, false);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000734 }
735
736 if ((target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) &&
737 (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL))
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000738 {
739 return gl::error(GL_INVALID_OPERATION, false);
740 }
741 }
742
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000743 // Validate sub image parameters
744 if (isSubImage)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000745 {
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000746 if (isCompressed != textureCompressed)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000747 {
748 return gl::error(GL_INVALID_OPERATION, false);
749 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000750
751 if (format != GL_NONE)
752 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000753 GLenum internalformat = gl::GetSizedInternalFormat(format, type, context->getClientVersion());
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000754 if (internalformat != textureInternalFormat)
755 {
756 return gl::error(GL_INVALID_OPERATION, false);
757 }
758 }
759
760 if (isCompressed)
761 {
762 if ((width % 4 != 0 && width != textureLevelWidth) ||
763 (height % 4 != 0 && height != textureLevelHeight))
764 {
765 return gl::error(GL_INVALID_OPERATION, false);
766 }
767 }
768
769 if (width == 0 || height == 0 || depth == 0)
770 {
771 return false;
772 }
773
774 if (xoffset < 0 || yoffset < 0 || zoffset < 0)
775 {
776 return gl::error(GL_INVALID_VALUE, false);
777 }
778
779 if (std::numeric_limits<GLsizei>::max() - xoffset < width ||
780 std::numeric_limits<GLsizei>::max() - yoffset < height ||
781 std::numeric_limits<GLsizei>::max() - zoffset < depth)
782 {
783 return gl::error(GL_INVALID_VALUE, false);
784 }
785
786 if (xoffset + width > textureLevelWidth ||
787 yoffset + height > textureLevelHeight ||
788 zoffset + depth > textureLevelDepth)
789 {
790 return gl::error(GL_INVALID_VALUE, false);
791 }
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000792 }
793
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000794 return true;
795}
796
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000797
798bool validateES2CopyTexImageParameters(gl::Context* context, GLenum target, GLint level, GLenum internalformat, bool isSubImage,
799 GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height,
800 GLint border)
801{
802 if (!gl::IsInternalTextureTarget(target))
803 {
804 return gl::error(GL_INVALID_ENUM, false);
805 }
806
807 if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0)
808 {
809 return gl::error(GL_INVALID_VALUE, false);
810 }
811
812 if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
813 {
814 return gl::error(GL_INVALID_VALUE, false);
815 }
816
817 if (width == 0 || height == 0)
818 {
819 return false;
820 }
821
822 // Verify zero border
823 if (border != 0)
824 {
825 return gl::error(GL_INVALID_VALUE, false);
826 }
827
828 // Validate dimensions based on Context limits and validate the texture
829 if (level > context->getMaximumTextureLevel())
830 {
831 return gl::error(GL_INVALID_VALUE, false);
832 }
833
834 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
835
836 if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
837 {
838 return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
839 }
840
841 if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0)
842 {
843 return gl::error(GL_INVALID_OPERATION, false);
844 }
845
846 GLenum colorbufferFormat = framebuffer->getReadColorbuffer()->getInternalFormat();
847 gl::Texture *texture = NULL;
848 GLenum textureFormat = GL_RGBA;
849
850 switch (target)
851 {
852 case GL_TEXTURE_2D:
853 {
854 if (width > (context->getMaximum2DTextureDimension() >> level) ||
855 height > (context->getMaximum2DTextureDimension() >> level))
856 {
857 return gl::error(GL_INVALID_VALUE, false);
858 }
859
860 gl::Texture2D *tex2d = context->getTexture2D();
861 if (tex2d)
862 {
863 if (isSubImage && !validateSubImageParams2D(false, width, height, xoffset, yoffset, level, GL_NONE, GL_NONE, tex2d))
864 {
865 return false; // error already registered by validateSubImageParams
866 }
867 texture = tex2d;
868 textureFormat = gl::GetFormat(tex2d->getInternalFormat(level), context->getClientVersion());
869 }
870 }
871 break;
872
873 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
874 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
875 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
876 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
877 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
878 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
879 {
880 if (!isSubImage && width != height)
881 {
882 return gl::error(GL_INVALID_VALUE, false);
883 }
884
885 if (width > (context->getMaximumCubeTextureDimension() >> level) ||
886 height > (context->getMaximumCubeTextureDimension() >> level))
887 {
888 return gl::error(GL_INVALID_VALUE, false);
889 }
890
891 gl::TextureCubeMap *texcube = context->getTextureCubeMap();
892 if (texcube)
893 {
894 if (isSubImage && !validateSubImageParamsCube(false, width, height, xoffset, yoffset, target, level, GL_NONE, GL_NONE, texcube))
895 {
896 return false; // error already registered by validateSubImageParams
897 }
898 texture = texcube;
899 textureFormat = gl::GetFormat(texcube->getInternalFormat(target, level), context->getClientVersion());
900 }
901 }
902 break;
903
904 default:
905 return gl::error(GL_INVALID_ENUM, false);
906 }
907
908 if (!texture)
909 {
910 return gl::error(GL_INVALID_OPERATION, false);
911 }
912
913 if (texture->isImmutable() && !isSubImage)
914 {
915 return gl::error(GL_INVALID_OPERATION, false);
916 }
917
918
919 // [OpenGL ES 2.0.24] table 3.9
920 if (isSubImage)
921 {
922 switch (textureFormat)
923 {
924 case GL_ALPHA:
925 if (colorbufferFormat != GL_ALPHA8_EXT &&
926 colorbufferFormat != GL_RGBA4 &&
927 colorbufferFormat != GL_RGB5_A1 &&
928 colorbufferFormat != GL_RGBA8_OES)
929 {
930 return gl::error(GL_INVALID_OPERATION, false);
931 }
932 break;
933 case GL_LUMINANCE:
934 case GL_RGB:
935 if (colorbufferFormat != GL_RGB565 &&
936 colorbufferFormat != GL_RGB8_OES &&
937 colorbufferFormat != GL_RGBA4 &&
938 colorbufferFormat != GL_RGB5_A1 &&
939 colorbufferFormat != GL_RGBA8_OES)
940 {
941 return gl::error(GL_INVALID_OPERATION, false);
942 }
943 break;
944 case GL_LUMINANCE_ALPHA:
945 case GL_RGBA:
946 if (colorbufferFormat != GL_RGBA4 &&
947 colorbufferFormat != GL_RGB5_A1 &&
948 colorbufferFormat != GL_RGBA8_OES)
949 {
950 return gl::error(GL_INVALID_OPERATION, false);
951 }
952 break;
953 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
954 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
955 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
956 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
957 return gl::error(GL_INVALID_OPERATION, false);
958 case GL_DEPTH_COMPONENT:
959 case GL_DEPTH_STENCIL_OES:
960 return gl::error(GL_INVALID_OPERATION, false);
961 default:
962 return gl::error(GL_INVALID_OPERATION, false);
963 }
964 }
965 else
966 {
967 switch (internalformat)
968 {
969 case GL_ALPHA:
970 if (colorbufferFormat != GL_ALPHA8_EXT &&
971 colorbufferFormat != GL_RGBA4 &&
972 colorbufferFormat != GL_RGB5_A1 &&
973 colorbufferFormat != GL_BGRA8_EXT &&
974 colorbufferFormat != GL_RGBA8_OES)
975 {
976 return gl::error(GL_INVALID_OPERATION, false);
977 }
978 break;
979 case GL_LUMINANCE:
980 case GL_RGB:
981 if (colorbufferFormat != GL_RGB565 &&
982 colorbufferFormat != GL_RGB8_OES &&
983 colorbufferFormat != GL_RGBA4 &&
984 colorbufferFormat != GL_RGB5_A1 &&
985 colorbufferFormat != GL_BGRA8_EXT &&
986 colorbufferFormat != GL_RGBA8_OES)
987 {
988 return gl::error(GL_INVALID_OPERATION, false);
989 }
990 break;
991 case GL_LUMINANCE_ALPHA:
992 case GL_RGBA:
993 if (colorbufferFormat != GL_RGBA4 &&
994 colorbufferFormat != GL_RGB5_A1 &&
995 colorbufferFormat != GL_BGRA8_EXT &&
996 colorbufferFormat != GL_RGBA8_OES)
997 {
998 return gl::error(GL_INVALID_OPERATION, false);
999 }
1000 break;
1001 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1002 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1003 if (context->supportsDXT1Textures())
1004 {
1005 return gl::error(GL_INVALID_OPERATION, false);
1006 }
1007 else
1008 {
1009 return gl::error(GL_INVALID_ENUM, false);
1010 }
1011 break;
1012 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
1013 if (context->supportsDXT3Textures())
1014 {
1015 return gl::error(GL_INVALID_OPERATION, false);
1016 }
1017 else
1018 {
1019 return gl::error(GL_INVALID_ENUM, false);
1020 }
1021 break;
1022 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
1023 if (context->supportsDXT5Textures())
1024 {
1025 return gl::error(GL_INVALID_OPERATION, false);
1026 }
1027 else
1028 {
1029 return gl::error(GL_INVALID_ENUM, false);
1030 }
1031 break;
1032 case GL_DEPTH_COMPONENT:
1033 case GL_DEPTH_COMPONENT16:
1034 case GL_DEPTH_COMPONENT32_OES:
1035 case GL_DEPTH_STENCIL_OES:
1036 case GL_DEPTH24_STENCIL8_OES:
1037 if (context->supportsDepthTextures())
1038 {
1039 return gl::error(GL_INVALID_OPERATION, false);
1040 }
1041 else
1042 {
1043 return gl::error(GL_INVALID_ENUM, false);
1044 }
1045 default:
1046 return gl::error(GL_INVALID_ENUM, false);
1047 }
1048 }
1049
1050 return true;
1051}
1052
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001053bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLint level, GLenum internalformat,
1054 bool isSubImage, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y,
1055 GLsizei width, GLsizei height, GLint border)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001056{
1057 if (level < 0 || xoffset < 0 || yoffset < 0 || zoffset < 0 || width < 0 || height < 0)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +00001058 {
1059 return gl::error(GL_INVALID_VALUE, false);
1060 }
1061
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001062 if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
1063 {
1064 return gl::error(GL_INVALID_VALUE, false);
1065 }
1066
1067 if (width == 0 || height == 0)
1068 {
1069 return false;
1070 }
1071
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001072 if (border != 0)
1073 {
1074 return gl::error(GL_INVALID_VALUE, false);
1075 }
1076
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001077 if (level > context->getMaximumTextureLevel())
1078 {
1079 return gl::error(GL_INVALID_VALUE, false);
1080 }
1081
1082 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
1083
1084 if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
1085 {
1086 return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
1087 }
1088
1089 if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0)
1090 {
1091 return gl::error(GL_INVALID_OPERATION, false);
1092 }
1093
1094 gl::Renderbuffer *source = framebuffer->getReadColorbuffer();
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001095 GLenum colorbufferInternalFormat = source->getInternalFormat();
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001096 gl::Texture *texture = NULL;
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001097 GLenum textureInternalFormat = GL_NONE;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001098 bool textureCompressed = false;
1099 GLint textureLevelWidth = 0;
1100 GLint textureLevelHeight = 0;
1101 GLint textureLevelDepth = 0;
1102 switch (target)
1103 {
1104 case GL_TEXTURE_2D:
1105 {
1106 gl::Texture2D *texture2d = context->getTexture2D();
1107 if (texture2d)
1108 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001109 textureInternalFormat = texture2d->getInternalFormat(level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001110 textureCompressed = texture2d->isCompressed(level);
1111 textureLevelWidth = texture2d->getWidth(level);
1112 textureLevelHeight = texture2d->getHeight(level);
1113 textureLevelDepth = 1;
1114 texture = texture2d;
1115 }
1116 }
1117 break;
1118
1119 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1120 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1121 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1122 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1123 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1124 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1125 {
1126 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
1127 if (textureCube)
1128 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001129 textureInternalFormat = textureCube->getInternalFormat(target, level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001130 textureCompressed = textureCube->isCompressed(target, level);
1131 textureLevelWidth = textureCube->getWidth(target, level);
1132 textureLevelHeight = textureCube->getHeight(target, level);
1133 textureLevelDepth = 1;
1134 texture = textureCube;
1135 }
1136 }
1137 break;
1138
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001139 case GL_TEXTURE_2D_ARRAY:
1140 {
1141 gl::Texture2DArray *texture2dArray = context->getTexture2DArray();
1142 if (texture2dArray)
1143 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001144 textureInternalFormat = texture2dArray->getInternalFormat(level);
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001145 textureCompressed = texture2dArray->isCompressed(level);
1146 textureLevelWidth = texture2dArray->getWidth(level);
1147 textureLevelHeight = texture2dArray->getHeight(level);
1148 textureLevelDepth = texture2dArray->getDepth(level);
1149 texture = texture2dArray;
1150 }
1151 }
1152 break;
1153
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001154 case GL_TEXTURE_3D:
1155 {
1156 gl::Texture3D *texture3d = context->getTexture3D();
1157 if (texture3d)
1158 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001159 textureInternalFormat = texture3d->getInternalFormat(level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001160 textureCompressed = texture3d->isCompressed(level);
1161 textureLevelWidth = texture3d->getWidth(level);
1162 textureLevelHeight = texture3d->getHeight(level);
1163 textureLevelDepth = texture3d->getDepth(level);
1164 texture = texture3d;
1165 }
1166 }
1167 break;
1168
1169 default:
1170 return gl::error(GL_INVALID_ENUM, false);
1171 }
1172
1173 if (!texture)
1174 {
1175 return gl::error(GL_INVALID_OPERATION, false);
1176 }
1177
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001178 if (texture->isImmutable() && !isSubImage)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001179 {
1180 return gl::error(GL_INVALID_OPERATION, false);
1181 }
1182
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001183 if (textureCompressed)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001184 {
1185 if ((width % 4 != 0 && width != textureLevelWidth) ||
1186 (height % 4 != 0 && height != textureLevelHeight))
1187 {
1188 return gl::error(GL_INVALID_OPERATION, false);
1189 }
1190 }
1191
1192 if (xoffset + width > textureLevelWidth ||
1193 yoffset + height > textureLevelHeight ||
1194 zoffset >= textureLevelDepth)
1195 {
1196 return gl::error(GL_INVALID_VALUE, false);
1197 }
1198
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001199 if (!gl::IsValidCopyTexImageCombination(textureInternalFormat, colorbufferInternalFormat,
1200 context->getClientVersion()))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001201 {
1202 return gl::error(GL_INVALID_OPERATION, false);
1203 }
1204
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +00001205 return true;
1206}
1207
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00001208bool validateES2TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat,
1209 GLsizei width, GLsizei height)
1210{
1211 if (target != GL_TEXTURE_2D && target != GL_TEXTURE_CUBE_MAP)
1212 {
1213 return gl::error(GL_INVALID_ENUM, false);
1214 }
1215
1216 if (width < 1 || height < 1 || levels < 1)
1217 {
1218 return gl::error(GL_INVALID_VALUE, false);
1219 }
1220
1221 if (target == GL_TEXTURE_CUBE_MAP && width != height)
1222 {
1223 return gl::error(GL_INVALID_VALUE, false);
1224 }
1225
1226 if (levels != 1 && levels != gl::log2(std::max(width, height)) + 1)
1227 {
1228 return gl::error(GL_INVALID_OPERATION, false);
1229 }
1230
1231 GLenum format = gl::GetFormat(internalformat, context->getClientVersion());
1232 GLenum type = gl::GetType(internalformat, context->getClientVersion());
1233
1234 if (format == GL_NONE || type == GL_NONE)
1235 {
1236 return gl::error(GL_INVALID_ENUM, false);
1237 }
1238
1239 switch (target)
1240 {
1241 case GL_TEXTURE_2D:
1242 if (width > context->getMaximum2DTextureDimension() ||
1243 height > context->getMaximum2DTextureDimension())
1244 {
1245 return gl::error(GL_INVALID_VALUE, false);
1246 }
1247 break;
1248 case GL_TEXTURE_CUBE_MAP:
1249 if (width > context->getMaximumCubeTextureDimension() ||
1250 height > context->getMaximumCubeTextureDimension())
1251 {
1252 return gl::error(GL_INVALID_VALUE, false);
1253 }
1254 break;
1255 default:
1256 return gl::error(GL_INVALID_ENUM, false);
1257 }
1258
1259 if (levels != 1 && !context->supportsNonPower2Texture())
1260 {
1261 if (!gl::isPow2(width) || !gl::isPow2(height))
1262 {
1263 return gl::error(GL_INVALID_OPERATION, false);
1264 }
1265 }
1266
1267 switch (internalformat)
1268 {
1269 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1270 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1271 if (!context->supportsDXT1Textures())
1272 {
1273 return gl::error(GL_INVALID_ENUM, false);
1274 }
1275 break;
1276 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
1277 if (!context->supportsDXT3Textures())
1278 {
1279 return gl::error(GL_INVALID_ENUM, false);
1280 }
1281 break;
1282 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
1283 if (!context->supportsDXT5Textures())
1284 {
1285 return gl::error(GL_INVALID_ENUM, false);
1286 }
1287 break;
1288 case GL_RGBA32F_EXT:
1289 case GL_RGB32F_EXT:
1290 case GL_ALPHA32F_EXT:
1291 case GL_LUMINANCE32F_EXT:
1292 case GL_LUMINANCE_ALPHA32F_EXT:
1293 if (!context->supportsFloat32Textures())
1294 {
1295 return gl::error(GL_INVALID_ENUM, false);
1296 }
1297 break;
1298 case GL_RGBA16F_EXT:
1299 case GL_RGB16F_EXT:
1300 case GL_ALPHA16F_EXT:
1301 case GL_LUMINANCE16F_EXT:
1302 case GL_LUMINANCE_ALPHA16F_EXT:
1303 if (!context->supportsFloat16Textures())
1304 {
1305 return gl::error(GL_INVALID_ENUM, false);
1306 }
1307 break;
1308 case GL_DEPTH_COMPONENT16:
1309 case GL_DEPTH_COMPONENT32_OES:
1310 case GL_DEPTH24_STENCIL8_OES:
1311 if (!context->supportsDepthTextures())
1312 {
1313 return gl::error(GL_INVALID_ENUM, false);
1314 }
1315 if (target != GL_TEXTURE_2D)
1316 {
1317 return gl::error(GL_INVALID_OPERATION, false);
1318 }
1319 // ANGLE_depth_texture only supports 1-level textures
1320 if (levels != 1)
1321 {
1322 return gl::error(GL_INVALID_OPERATION, false);
1323 }
1324 break;
1325 default:
1326 break;
1327 }
1328
1329 gl::Texture *texture = NULL;
1330 switch(target)
1331 {
1332 case GL_TEXTURE_2D:
1333 texture = context->getTexture2D();
1334 break;
1335 case GL_TEXTURE_CUBE_MAP:
1336 texture = context->getTextureCubeMap();
1337 break;
1338 default:
1339 UNREACHABLE();
1340 }
1341
1342 if (!texture || texture->id() == 0)
1343 {
1344 return gl::error(GL_INVALID_OPERATION, false);
1345 }
1346
1347 if (texture->isImmutable())
1348 {
1349 return gl::error(GL_INVALID_OPERATION, false);
1350 }
1351
1352 return true;
1353}
1354
1355bool validateES3TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat,
1356 GLsizei width, GLsizei height, GLsizei depth)
1357{
1358 if (width < 1 || height < 1 || depth < 1 || levels < 1)
1359 {
1360 return gl::error(GL_INVALID_VALUE, false);
1361 }
1362
1363 if (levels > gl::log2(std::max(std::max(width, height), depth)) + 1)
1364 {
1365 return gl::error(GL_INVALID_OPERATION, false);
1366 }
1367
1368 gl::Texture *texture = NULL;
1369 switch (target)
1370 {
1371 case GL_TEXTURE_2D:
1372 {
1373 texture = context->getTexture2D();
1374
1375 if (width > (context->getMaximum2DTextureDimension()) ||
1376 height > (context->getMaximum2DTextureDimension()))
1377 {
1378 return gl::error(GL_INVALID_VALUE, false);
1379 }
1380 }
1381 break;
1382
1383 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1384 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1385 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1386 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1387 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1388 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1389 {
1390 texture = context->getTextureCubeMap();
1391
1392 if (width != height)
1393 {
1394 return gl::error(GL_INVALID_VALUE, false);
1395 }
1396
1397 if (width > (context->getMaximumCubeTextureDimension()))
1398 {
1399 return gl::error(GL_INVALID_VALUE, false);
1400 }
1401 }
1402 break;
1403
1404 case GL_TEXTURE_3D:
1405 {
1406 texture = context->getTexture3D();
1407
1408 if (width > (context->getMaximum3DTextureDimension()) ||
1409 height > (context->getMaximum3DTextureDimension()) ||
1410 depth > (context->getMaximum3DTextureDimension()))
1411 {
1412 return gl::error(GL_INVALID_VALUE, false);
1413 }
1414 }
1415 break;
1416
1417 case GL_TEXTURE_2D_ARRAY:
1418 {
1419 texture = context->getTexture2DArray();
1420
1421 if (width > (context->getMaximum2DTextureDimension()) ||
1422 height > (context->getMaximum2DTextureDimension()) ||
1423 depth > (context->getMaximum2DArrayTextureLayers()))
1424 {
1425 return gl::error(GL_INVALID_VALUE, false);
1426 }
1427 }
1428 break;
1429
1430 default:
1431 return gl::error(GL_INVALID_ENUM, false);
1432 }
1433
1434 if (!texture || texture->id() == 0)
1435 {
1436 return gl::error(GL_INVALID_OPERATION, false);
1437 }
1438
1439 if (texture->isImmutable())
1440 {
1441 return gl::error(GL_INVALID_OPERATION, false);
1442 }
1443
1444 if (!gl::IsValidInternalFormat(internalformat, context))
1445 {
1446 return gl::error(GL_INVALID_ENUM, false);
1447 }
1448
1449 if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion()))
1450 {
1451 return gl::error(GL_INVALID_ENUM, false);
1452 }
1453
1454 return true;
1455}
1456
Geoff Lang2e1dcd52013-05-29 10:34:08 -04001457bool validateRenderbufferStorageParameters(const gl::Context *context, GLenum target, GLsizei samples,
1458 GLenum internalformat, GLsizei width, GLsizei height,
1459 bool angleExtension)
1460{
1461 switch (target)
1462 {
1463 case GL_RENDERBUFFER:
1464 break;
1465 default:
1466 return gl::error(GL_INVALID_ENUM, false);
1467 }
1468
1469 if (width < 0 || height < 0 || samples < 0)
1470 {
1471 return gl::error(GL_INVALID_VALUE, false);
1472 }
1473
1474 if (!gl::IsValidInternalFormat(internalformat, context))
1475 {
1476 return gl::error(GL_INVALID_ENUM, false);
1477 }
1478
1479 // ANGLE_framebuffer_multisample does not explicitly state that the internal format must be
1480 // sized but it does state that the format must be in the ES2.0 spec table 4.5 which contains
1481 // only sized internal formats. The ES3 spec (section 4.4.2) does, however, state that the
1482 // internal format must be sized and not an integer format if samples is greater than zero.
1483 if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion()))
1484 {
1485 return gl::error(GL_INVALID_ENUM, false);
1486 }
1487
1488 if (gl::IsIntegerFormat(internalformat, context->getClientVersion()) && samples > 0)
1489 {
1490 return gl::error(GL_INVALID_OPERATION, false);
1491 }
1492
1493 if (!gl::IsColorRenderingSupported(internalformat, context) &&
1494 !gl::IsDepthRenderingSupported(internalformat, context) &&
1495 !gl::IsStencilRenderingSupported(internalformat, context))
1496 {
1497 return gl::error(GL_INVALID_ENUM, false);
1498 }
1499
1500 if (std::max(width, height) > context->getMaximumRenderbufferDimension())
1501 {
1502 return gl::error(GL_INVALID_VALUE, false);
1503 }
1504
1505 // ANGLE_framebuffer_multisample states that the value of samples must be less than or equal
1506 // to MAX_SAMPLES_ANGLE (Context::getMaxSupportedSamples) while the ES3.0 spec (section 4.4.2)
1507 // states that samples must be less than or equal to the maximum samples for the specified
1508 // internal format.
1509 if (angleExtension)
1510 {
1511 if (samples > context->getMaxSupportedSamples())
1512 {
1513 return gl::error(GL_INVALID_VALUE, false);
1514 }
1515 }
1516 else
1517 {
1518 if (samples > context->getMaxSupportedFormatSamples(internalformat))
1519 {
1520 return gl::error(GL_INVALID_VALUE, false);
1521 }
1522 }
1523
1524 GLuint handle = context->getRenderbufferHandle();
1525 if (handle == 0)
1526 {
1527 return gl::error(GL_INVALID_OPERATION, false);
1528 }
1529
1530 return true;
1531}
1532
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00001533// check for combinations of format and type that are valid for ReadPixels
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00001534bool validES2ReadFormatType(GLenum format, GLenum type)
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00001535{
1536 switch (format)
1537 {
1538 case GL_RGBA:
1539 switch (type)
1540 {
1541 case GL_UNSIGNED_BYTE:
1542 break;
1543 default:
1544 return false;
1545 }
1546 break;
1547 case GL_BGRA_EXT:
1548 switch (type)
1549 {
1550 case GL_UNSIGNED_BYTE:
1551 case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
1552 case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
1553 break;
1554 default:
1555 return false;
1556 }
1557 break;
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00001558 default:
1559 return false;
1560 }
1561 return true;
1562}
1563
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00001564bool validES3ReadFormatType(GLenum internalFormat, GLenum format, GLenum type)
1565{
1566 switch (format)
1567 {
1568 case GL_RGBA:
1569 switch (type)
1570 {
1571 case GL_UNSIGNED_BYTE:
1572 break;
1573 case GL_UNSIGNED_INT_2_10_10_10_REV:
1574 if (internalFormat != GL_RGB10_A2)
1575 {
1576 return false;
1577 }
1578 break;
1579 default:
1580 return false;
1581 }
1582 break;
1583 case GL_RGBA_INTEGER:
1584 switch (type)
1585 {
1586 case GL_INT:
1587 case GL_UNSIGNED_INT:
1588 break;
1589 default:
1590 return false;
1591 }
1592 break;
1593 case GL_BGRA_EXT:
1594 switch (type)
1595 {
1596 case GL_UNSIGNED_BYTE:
1597 case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
1598 case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
1599 break;
1600 default:
1601 return false;
1602 }
1603 break;
1604 default:
1605 return false;
1606 }
1607 return true;
1608}
1609
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00001610bool validateInvalidateFramebufferParameters(gl::Context *context, GLenum target, GLsizei numAttachments,
1611 const GLenum* attachments)
1612{
1613 bool defaultFramebuffer = false;
1614
1615 switch (target)
1616 {
1617 case GL_DRAW_FRAMEBUFFER:
1618 case GL_FRAMEBUFFER:
1619 defaultFramebuffer = context->getDrawFramebufferHandle() == 0;
1620 break;
1621 case GL_READ_FRAMEBUFFER:
1622 defaultFramebuffer = context->getReadFramebufferHandle() == 0;
1623 break;
1624 default:
1625 return gl::error(GL_INVALID_ENUM, false);
1626 }
1627
1628 for (int i = 0; i < numAttachments; ++i)
1629 {
1630 if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15)
1631 {
1632 if (defaultFramebuffer)
1633 {
1634 return gl::error(GL_INVALID_ENUM, false);
1635 }
1636
1637 if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getMaximumRenderTargets())
1638 {
1639 return gl::error(GL_INVALID_OPERATION, false);
1640 }
1641 }
1642 else
1643 {
1644 switch (attachments[i])
1645 {
1646 case GL_DEPTH_ATTACHMENT:
1647 case GL_STENCIL_ATTACHMENT:
1648 case GL_DEPTH_STENCIL_ATTACHMENT:
1649 if (defaultFramebuffer)
1650 {
1651 return gl::error(GL_INVALID_ENUM, false);
1652 }
1653 break;
1654 case GL_COLOR:
1655 case GL_DEPTH:
1656 case GL_STENCIL:
1657 if (!defaultFramebuffer)
1658 {
1659 return gl::error(GL_INVALID_ENUM, false);
1660 }
1661 break;
1662 default:
1663 return gl::error(GL_INVALID_ENUM, false);
1664 }
1665 }
1666 }
1667
1668 return true;
1669}
1670
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001671extern "C"
1672{
1673
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00001674// OpenGL ES 2.0 functions
1675
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001676void __stdcall glActiveTexture(GLenum texture)
1677{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001678 EVENT("(GLenum texture = 0x%X)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001679
1680 try
1681 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001682 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001683
1684 if (context)
1685 {
daniel@transgaming.com3f74c7a2011-05-11 15:36:51 +00001686 if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1)
1687 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001688 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3f74c7a2011-05-11 15:36:51 +00001689 }
1690
daniel@transgaming.com428d1582010-05-04 03:35:25 +00001691 context->setActiveSampler(texture - GL_TEXTURE0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001692 }
1693 }
1694 catch(std::bad_alloc&)
1695 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001696 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001697 }
1698}
1699
1700void __stdcall glAttachShader(GLuint program, GLuint shader)
1701{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001702 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001703
1704 try
1705 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001706 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001707
1708 if (context)
1709 {
1710 gl::Program *programObject = context->getProgram(program);
1711 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00001712
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001713 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001714 {
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001715 if (context->getShader(program))
1716 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001717 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001718 }
1719 else
1720 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001721 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001722 }
1723 }
1724
1725 if (!shaderObject)
1726 {
1727 if (context->getProgram(shader))
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 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001735 }
1736
1737 if (!programObject->attachShader(shaderObject))
1738 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001739 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001740 }
1741 }
1742 }
1743 catch(std::bad_alloc&)
1744 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001745 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001746 }
1747}
1748
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001749void __stdcall glBeginQueryEXT(GLenum target, GLuint id)
1750{
1751 EVENT("(GLenum target = 0x%X, GLuint %d)", target, id);
1752
1753 try
1754 {
1755 switch (target)
1756 {
1757 case GL_ANY_SAMPLES_PASSED_EXT:
1758 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
1759 break;
1760 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001761 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001762 }
1763
1764 if (id == 0)
1765 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001766 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001767 }
1768
1769 gl::Context *context = gl::getNonLostContext();
1770
1771 if (context)
1772 {
1773 context->beginQuery(target, id);
1774 }
1775 }
1776 catch(std::bad_alloc&)
1777 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001778 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001779 }
1780}
1781
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001782void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001783{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001784 EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001785
1786 try
1787 {
1788 if (index >= gl::MAX_VERTEX_ATTRIBS)
1789 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001790 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001791 }
1792
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001793 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001794
1795 if (context)
1796 {
1797 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00001798
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001799 if (!programObject)
1800 {
daniel@transgaming.com98079832010-04-13 03:26:29 +00001801 if (context->getShader(program))
1802 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001803 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com98079832010-04-13 03:26:29 +00001804 }
1805 else
1806 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001807 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com98079832010-04-13 03:26:29 +00001808 }
1809 }
1810
1811 if (strncmp(name, "gl_", 3) == 0)
1812 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001813 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001814 }
1815
1816 programObject->bindAttributeLocation(index, name);
1817 }
1818 }
1819 catch(std::bad_alloc&)
1820 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001821 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001822 }
1823}
1824
1825void __stdcall glBindBuffer(GLenum target, GLuint buffer)
1826{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001827 EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001828
1829 try
1830 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001831 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001832
1833 if (context)
1834 {
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00001835 // Check ES3 specific targets
1836 switch (target)
1837 {
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00001838 case GL_COPY_READ_BUFFER:
1839 case GL_COPY_WRITE_BUFFER:
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00001840 case GL_PIXEL_PACK_BUFFER:
1841 case GL_PIXEL_UNPACK_BUFFER:
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00001842 case GL_UNIFORM_BUFFER:
1843 case GL_TRANSFORM_FEEDBACK_BUFFER:
1844 if (context->getClientVersion() < 3)
1845 {
1846 return gl::error(GL_INVALID_ENUM);
1847 }
1848 }
1849
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001850 switch (target)
1851 {
1852 case GL_ARRAY_BUFFER:
1853 context->bindArrayBuffer(buffer);
1854 return;
1855 case GL_ELEMENT_ARRAY_BUFFER:
1856 context->bindElementArrayBuffer(buffer);
1857 return;
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00001858 case GL_COPY_READ_BUFFER:
1859 context->bindCopyReadBuffer(buffer);
1860 return;
1861 case GL_COPY_WRITE_BUFFER:
1862 context->bindCopyWriteBuffer(buffer);
1863 return;
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00001864 case GL_PIXEL_PACK_BUFFER:
1865 context->bindPixelPackBuffer(buffer);
1866 return;
1867 case GL_PIXEL_UNPACK_BUFFER:
1868 context->bindPixelUnpackBuffer(buffer);
1869 return;
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00001870 case GL_UNIFORM_BUFFER:
1871 context->bindGenericUniformBuffer(buffer);
1872 return;
1873 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.org7a1ebad2013-05-30 00:05:20 +00001874 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00001875 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001876 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001877 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001878 }
1879 }
1880 }
1881 catch(std::bad_alloc&)
1882 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001883 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001884 }
1885}
1886
1887void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer)
1888{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001889 EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001890
1891 try
1892 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00001893 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001894 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001895 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001896 }
1897
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001898 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001899
1900 if (context)
1901 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00001902 if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
1903 {
1904 context->bindReadFramebuffer(framebuffer);
1905 }
1906
1907 if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
1908 {
1909 context->bindDrawFramebuffer(framebuffer);
1910 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001911 }
1912 }
1913 catch(std::bad_alloc&)
1914 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001915 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001916 }
1917}
1918
1919void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer)
1920{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001921 EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001922
1923 try
1924 {
1925 if (target != GL_RENDERBUFFER)
1926 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001927 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001928 }
1929
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001930 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001931
1932 if (context)
1933 {
1934 context->bindRenderbuffer(renderbuffer);
1935 }
1936 }
1937 catch(std::bad_alloc&)
1938 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001939 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001940 }
1941}
1942
1943void __stdcall glBindTexture(GLenum target, GLuint texture)
1944{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001945 EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001946
1947 try
1948 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001949 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001950
1951 if (context)
1952 {
1953 gl::Texture *textureObject = context->getTexture(texture);
1954
1955 if (textureObject && textureObject->getTarget() != target && texture != 0)
1956 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001957 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001958 }
1959
1960 switch (target)
1961 {
1962 case GL_TEXTURE_2D:
1963 context->bindTexture2D(texture);
1964 return;
1965 case GL_TEXTURE_CUBE_MAP:
1966 context->bindTextureCubeMap(texture);
1967 return;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00001968 case GL_TEXTURE_3D:
1969 if (context->getClientVersion() < 3)
1970 {
1971 return gl::error(GL_INVALID_ENUM);
1972 }
1973 context->bindTexture3D(texture);
1974 return;
shannon.woods%transgaming.com@gtempaccount.com90dbc442013-04-13 03:46:14 +00001975 case GL_TEXTURE_2D_ARRAY:
1976 if (context->getClientVersion() < 3)
1977 {
1978 return gl::error(GL_INVALID_ENUM);
1979 }
1980 context->bindTexture2DArray(texture);
1981 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001982 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001983 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001984 }
1985 }
1986 }
1987 catch(std::bad_alloc&)
1988 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001989 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001990 }
1991}
1992
1993void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
1994{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001995 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001996 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001997
1998 try
1999 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002000 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002001
2002 if (context)
2003 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002004 context->setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002005 }
2006 }
2007 catch(std::bad_alloc&)
2008 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002009 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002010 }
2011}
2012
2013void __stdcall glBlendEquation(GLenum mode)
2014{
2015 glBlendEquationSeparate(mode, mode);
2016}
2017
2018void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
2019{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002020 EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002021
2022 try
2023 {
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +00002024 gl::Context *context = gl::getNonLostContext();
2025
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002026 switch (modeRGB)
2027 {
2028 case GL_FUNC_ADD:
2029 case GL_FUNC_SUBTRACT:
2030 case GL_FUNC_REVERSE_SUBTRACT:
2031 break;
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +00002032
2033 case GL_MIN:
2034 case GL_MAX:
2035 if (context && context->getClientVersion() < 3)
2036 {
2037 return gl::error(GL_INVALID_ENUM);
2038 }
2039 break;
2040
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002041 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002042 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002043 }
2044
2045 switch (modeAlpha)
2046 {
2047 case GL_FUNC_ADD:
2048 case GL_FUNC_SUBTRACT:
2049 case GL_FUNC_REVERSE_SUBTRACT:
2050 break;
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +00002051
2052 case GL_MIN:
2053 case GL_MAX:
2054 if (context && context->getClientVersion() < 3)
2055 {
2056 return gl::error(GL_INVALID_ENUM);
2057 }
2058 break;
2059
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002060 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002061 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002062 }
2063
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002064 if (context)
2065 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002066 context->setBlendEquation(modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002067 }
2068 }
2069 catch(std::bad_alloc&)
2070 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002071 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002072 }
2073}
2074
2075void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor)
2076{
2077 glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
2078}
2079
2080void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
2081{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002082 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 +00002083 srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002084
2085 try
2086 {
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +00002087 gl::Context *context = gl::getNonLostContext();
2088
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002089 switch (srcRGB)
2090 {
2091 case GL_ZERO:
2092 case GL_ONE:
2093 case GL_SRC_COLOR:
2094 case GL_ONE_MINUS_SRC_COLOR:
2095 case GL_DST_COLOR:
2096 case GL_ONE_MINUS_DST_COLOR:
2097 case GL_SRC_ALPHA:
2098 case GL_ONE_MINUS_SRC_ALPHA:
2099 case GL_DST_ALPHA:
2100 case GL_ONE_MINUS_DST_ALPHA:
2101 case GL_CONSTANT_COLOR:
2102 case GL_ONE_MINUS_CONSTANT_COLOR:
2103 case GL_CONSTANT_ALPHA:
2104 case GL_ONE_MINUS_CONSTANT_ALPHA:
2105 case GL_SRC_ALPHA_SATURATE:
2106 break;
2107 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002108 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002109 }
2110
2111 switch (dstRGB)
2112 {
2113 case GL_ZERO:
2114 case GL_ONE:
2115 case GL_SRC_COLOR:
2116 case GL_ONE_MINUS_SRC_COLOR:
2117 case GL_DST_COLOR:
2118 case GL_ONE_MINUS_DST_COLOR:
2119 case GL_SRC_ALPHA:
2120 case GL_ONE_MINUS_SRC_ALPHA:
2121 case GL_DST_ALPHA:
2122 case GL_ONE_MINUS_DST_ALPHA:
2123 case GL_CONSTANT_COLOR:
2124 case GL_ONE_MINUS_CONSTANT_COLOR:
2125 case GL_CONSTANT_ALPHA:
2126 case GL_ONE_MINUS_CONSTANT_ALPHA:
2127 break;
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +00002128
2129 case GL_SRC_ALPHA_SATURATE:
2130 if (!context || context->getClientVersion() < 3)
2131 {
2132 return gl::error(GL_INVALID_ENUM);
2133 }
2134 break;
2135
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002136 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002137 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002138 }
2139
2140 switch (srcAlpha)
2141 {
2142 case GL_ZERO:
2143 case GL_ONE:
2144 case GL_SRC_COLOR:
2145 case GL_ONE_MINUS_SRC_COLOR:
2146 case GL_DST_COLOR:
2147 case GL_ONE_MINUS_DST_COLOR:
2148 case GL_SRC_ALPHA:
2149 case GL_ONE_MINUS_SRC_ALPHA:
2150 case GL_DST_ALPHA:
2151 case GL_ONE_MINUS_DST_ALPHA:
2152 case GL_CONSTANT_COLOR:
2153 case GL_ONE_MINUS_CONSTANT_COLOR:
2154 case GL_CONSTANT_ALPHA:
2155 case GL_ONE_MINUS_CONSTANT_ALPHA:
2156 case GL_SRC_ALPHA_SATURATE:
2157 break;
2158 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002159 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002160 }
2161
2162 switch (dstAlpha)
2163 {
2164 case GL_ZERO:
2165 case GL_ONE:
2166 case GL_SRC_COLOR:
2167 case GL_ONE_MINUS_SRC_COLOR:
2168 case GL_DST_COLOR:
2169 case GL_ONE_MINUS_DST_COLOR:
2170 case GL_SRC_ALPHA:
2171 case GL_ONE_MINUS_SRC_ALPHA:
2172 case GL_DST_ALPHA:
2173 case GL_ONE_MINUS_DST_ALPHA:
2174 case GL_CONSTANT_COLOR:
2175 case GL_ONE_MINUS_CONSTANT_COLOR:
2176 case GL_CONSTANT_ALPHA:
2177 case GL_ONE_MINUS_CONSTANT_ALPHA:
2178 break;
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +00002179
2180 case GL_SRC_ALPHA_SATURATE:
2181 if (!context || context->getClientVersion() < 3)
2182 {
2183 return gl::error(GL_INVALID_ENUM);
2184 }
2185 break;
2186
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002187 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002188 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002189 }
2190
daniel@transgaming.comfe453652010-03-16 06:23:28 +00002191 bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
2192 dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
2193
2194 bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
2195 dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
2196
2197 if (constantColorUsed && constantAlphaUsed)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002198 {
daniel@transgaming.comfe453652010-03-16 06:23:28 +00002199 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 +00002200 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002201 }
2202
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002203 if (context)
2204 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002205 context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002206 }
2207 }
2208 catch(std::bad_alloc&)
2209 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002210 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002211 }
2212}
2213
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002214void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002215{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002216 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 +00002217 target, size, data, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002218
2219 try
2220 {
2221 if (size < 0)
2222 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002223 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002224 }
2225
shannon.woods%transgaming.com@gtempaccount.comf2db40b2013-04-13 03:37:09 +00002226 gl::Context *context = gl::getNonLostContext();
2227
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002228 switch (usage)
2229 {
2230 case GL_STREAM_DRAW:
2231 case GL_STATIC_DRAW:
2232 case GL_DYNAMIC_DRAW:
2233 break;
shannon.woods%transgaming.com@gtempaccount.comf2db40b2013-04-13 03:37:09 +00002234
2235 case GL_STREAM_READ:
2236 case GL_STREAM_COPY:
2237 case GL_STATIC_READ:
2238 case GL_STATIC_COPY:
2239 case GL_DYNAMIC_READ:
2240 case GL_DYNAMIC_COPY:
2241 if (context && context->getClientVersion() < 3)
2242 {
2243 return gl::error(GL_INVALID_ENUM);
2244 }
2245 break;
2246
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002247 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002248 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002249 }
2250
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002251 if (context)
2252 {
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002253 // Check ES3 specific targets
2254 switch (target)
2255 {
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002256 case GL_COPY_READ_BUFFER:
2257 case GL_COPY_WRITE_BUFFER:
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002258 case GL_PIXEL_PACK_BUFFER:
2259 case GL_PIXEL_UNPACK_BUFFER:
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002260 case GL_UNIFORM_BUFFER:
2261 case GL_TRANSFORM_FEEDBACK_BUFFER:
2262 if (context->getClientVersion() < 3)
2263 {
2264 return gl::error(GL_INVALID_ENUM);
2265 }
2266 }
2267
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002268 gl::Buffer *buffer;
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00002269
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002270 switch (target)
2271 {
2272 case GL_ARRAY_BUFFER:
2273 buffer = context->getArrayBuffer();
2274 break;
2275 case GL_ELEMENT_ARRAY_BUFFER:
2276 buffer = context->getElementArrayBuffer();
2277 break;
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002278 case GL_COPY_READ_BUFFER:
2279 buffer = context->getCopyReadBuffer();
2280 break;
2281 case GL_COPY_WRITE_BUFFER:
2282 buffer = context->getCopyWriteBuffer();
2283 break;
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002284 case GL_PIXEL_PACK_BUFFER:
2285 buffer = context->getPixelPackBuffer();
2286 break;
2287 case GL_PIXEL_UNPACK_BUFFER:
2288 buffer = context->getPixelUnpackBuffer();
2289 break;
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002290 case GL_TRANSFORM_FEEDBACK_BUFFER:
2291 buffer = context->getGenericTransformFeedbackBuffer();
2292 break;
2293 case GL_UNIFORM_BUFFER:
2294 buffer = context->getGenericUniformBuffer();
2295 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002296 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002297 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002298 }
2299
2300 if (!buffer)
2301 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002302 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002303 }
2304
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002305 buffer->bufferData(data, size, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002306 }
2307 }
2308 catch(std::bad_alloc&)
2309 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002310 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002311 }
2312}
2313
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002314void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002315{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002316 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 +00002317 target, offset, size, data);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002318
2319 try
2320 {
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +00002321 if (size < 0 || offset < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002322 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002323 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002324 }
2325
daniel@transgaming.comd4620a32010-03-21 04:31:28 +00002326 if (data == NULL)
2327 {
2328 return;
2329 }
2330
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002331 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002332
2333 if (context)
2334 {
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002335 // Check ES3 specific targets
2336 switch (target)
2337 {
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002338 case GL_COPY_READ_BUFFER:
2339 case GL_COPY_WRITE_BUFFER:
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002340 case GL_PIXEL_PACK_BUFFER:
2341 case GL_PIXEL_UNPACK_BUFFER:
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002342 case GL_UNIFORM_BUFFER:
2343 case GL_TRANSFORM_FEEDBACK_BUFFER:
2344 if (context->getClientVersion() < 3)
2345 {
2346 return gl::error(GL_INVALID_ENUM);
2347 }
2348 }
2349
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002350 gl::Buffer *buffer;
2351
2352 switch (target)
2353 {
2354 case GL_ARRAY_BUFFER:
2355 buffer = context->getArrayBuffer();
2356 break;
2357 case GL_ELEMENT_ARRAY_BUFFER:
2358 buffer = context->getElementArrayBuffer();
2359 break;
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002360 case GL_COPY_READ_BUFFER:
2361 buffer = context->getCopyReadBuffer();
2362 break;
2363 case GL_COPY_WRITE_BUFFER:
2364 buffer = context->getCopyWriteBuffer();
2365 break;
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002366 case GL_PIXEL_PACK_BUFFER:
2367 buffer = context->getPixelPackBuffer();
2368 break;
2369 case GL_PIXEL_UNPACK_BUFFER:
2370 buffer = context->getPixelUnpackBuffer();
2371 break;
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002372 case GL_TRANSFORM_FEEDBACK_BUFFER:
2373 buffer = context->getGenericTransformFeedbackBuffer();
2374 break;
2375 case GL_UNIFORM_BUFFER:
2376 buffer = context->getGenericUniformBuffer();
2377 break;
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002378 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002379 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002380 }
2381
2382 if (!buffer)
2383 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002384 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002385 }
2386
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +00002387 if ((size_t)size + offset > buffer->size())
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002388 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002389 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002390 }
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +00002391
2392 buffer->bufferSubData(data, size, offset);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002393 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002394 }
2395 catch(std::bad_alloc&)
2396 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002397 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002398 }
2399}
2400
2401GLenum __stdcall glCheckFramebufferStatus(GLenum target)
2402{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002403 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002404
2405 try
2406 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002407 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002408 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002409 return gl::error(GL_INVALID_ENUM, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002410 }
2411
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002412 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002413
2414 if (context)
2415 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002416 gl::Framebuffer *framebuffer = NULL;
2417 if (target == GL_READ_FRAMEBUFFER_ANGLE)
2418 {
2419 framebuffer = context->getReadFramebuffer();
2420 }
2421 else
2422 {
2423 framebuffer = context->getDrawFramebuffer();
2424 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002425
2426 return framebuffer->completeness();
2427 }
2428 }
2429 catch(std::bad_alloc&)
2430 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002431 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002432 }
2433
2434 return 0;
2435}
2436
2437void __stdcall glClear(GLbitfield mask)
2438{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00002439 EVENT("(GLbitfield mask = 0x%X)", mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002440
2441 try
2442 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002443 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002444
2445 if (context)
2446 {
2447 context->clear(mask);
2448 }
2449 }
2450 catch(std::bad_alloc&)
2451 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002452 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002453 }
2454}
2455
2456void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
2457{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002458 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002459 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002460
2461 try
2462 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002463 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002464
2465 if (context)
2466 {
2467 context->setClearColor(red, green, blue, alpha);
2468 }
2469 }
2470 catch(std::bad_alloc&)
2471 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002472 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002473 }
2474}
2475
2476void __stdcall glClearDepthf(GLclampf depth)
2477{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002478 EVENT("(GLclampf depth = %f)", depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002479
2480 try
2481 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002482 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002483
2484 if (context)
2485 {
2486 context->setClearDepth(depth);
2487 }
2488 }
2489 catch(std::bad_alloc&)
2490 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002491 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002492 }
2493}
2494
2495void __stdcall glClearStencil(GLint s)
2496{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002497 EVENT("(GLint s = %d)", s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002498
2499 try
2500 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002501 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002502
2503 if (context)
2504 {
2505 context->setClearStencil(s);
2506 }
2507 }
2508 catch(std::bad_alloc&)
2509 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002510 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002511 }
2512}
2513
2514void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
2515{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00002516 EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002517 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002518
2519 try
2520 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002521 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002522
2523 if (context)
2524 {
daniel@transgaming.coma36f98e2010-05-18 18:51:09 +00002525 context->setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002526 }
2527 }
2528 catch(std::bad_alloc&)
2529 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002530 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002531 }
2532}
2533
2534void __stdcall glCompileShader(GLuint shader)
2535{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002536 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002537
2538 try
2539 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002540 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002541
2542 if (context)
2543 {
2544 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00002545
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002546 if (!shaderObject)
2547 {
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +00002548 if (context->getProgram(shader))
2549 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002550 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +00002551 }
2552 else
2553 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002554 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +00002555 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002556 }
2557
2558 shaderObject->compile();
2559 }
2560 }
2561 catch(std::bad_alloc&)
2562 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002563 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002564 }
2565}
2566
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002567void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
2568 GLint border, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002569{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002570 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002571 "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002572 target, level, internalformat, width, height, border, imageSize, data);
2573
2574 try
2575 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002576 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com01868132010-08-24 19:21:17 +00002577
2578 if (context)
2579 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002580 if (context->getClientVersion() < 3 &&
2581 !validateES2TexImageParameters(context, target, level, internalformat, true, false,
2582 0, 0, width, height, 0, GL_NONE, GL_NONE, data))
2583 {
2584 return;
2585 }
2586
2587 if (context->getClientVersion() >= 3 &&
2588 !validateES3TexImageParameters(context, target, level, internalformat, true, false,
2589 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE))
2590 {
2591 return;
2592 }
2593
2594 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002595 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002596 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002597 }
2598
2599 switch (target)
2600 {
2601 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002602 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002603 gl::Texture2D *texture = context->getTexture2D();
2604 texture->setCompressedImage(level, internalformat, width, height, imageSize, data);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002605 }
2606 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002607
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002608 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2609 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2610 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2611 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2612 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2613 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002614 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002615 gl::TextureCubeMap *texture = context->getTextureCubeMap();
2616 texture->setCompressedImage(target, 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 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002621 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002622 }
daniel@transgaming.com01868132010-08-24 19:21:17 +00002623 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002624 }
2625 catch(std::bad_alloc&)
2626 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002627 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002628 }
2629}
2630
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002631void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
2632 GLenum format, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002633{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002634 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002635 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002636 "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002637 target, level, xoffset, yoffset, width, height, format, imageSize, data);
2638
2639 try
2640 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002641 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com01868132010-08-24 19:21:17 +00002642
2643 if (context)
2644 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002645 if (context->getClientVersion() < 3 &&
2646 !validateES2TexImageParameters(context, target, level, GL_NONE, true, true,
2647 xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
2648 {
2649 return;
2650 }
2651
2652 if (context->getClientVersion() >= 3 &&
2653 !validateES3TexImageParameters(context, target, level, GL_NONE, true, true,
2654 xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE))
2655 {
2656 return;
2657 }
2658
2659 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002660 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002661 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002662 }
2663
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002664 switch (target)
daniel@transgaming.com01868132010-08-24 19:21:17 +00002665 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002666 case GL_TEXTURE_2D:
daniel@transgaming.com01868132010-08-24 19:21:17 +00002667 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002668 gl::Texture2D *texture = context->getTexture2D();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00002669 texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
daniel@transgaming.com01868132010-08-24 19:21:17 +00002670 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002671 break;
2672
2673 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2674 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2675 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2676 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2677 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2678 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com01868132010-08-24 19:21:17 +00002679 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002680 gl::TextureCubeMap *texture = context->getTextureCubeMap();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00002681 texture->subImageCompressed(target, 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 default:
2686 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com01868132010-08-24 19:21:17 +00002687 }
2688 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002689 }
2690 catch(std::bad_alloc&)
2691 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002692 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002693 }
2694}
2695
2696void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
2697{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002698 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002699 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002700 target, level, internalformat, x, y, width, height, border);
2701
2702 try
2703 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002704 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002705
2706 if (context)
2707 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002708 if (context->getClientVersion() < 3 &&
2709 !validateES2CopyTexImageParameters(context, target, level, internalformat, false,
2710 0, 0, x, y, width, height, border))
daniel@transgaming.com32b11442011-11-19 02:42:48 +00002711 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002712 return;
daniel@transgaming.com32b11442011-11-19 02:42:48 +00002713 }
2714
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002715 if (context->getClientVersion() >= 3 &&
2716 !validateES3CopyTexImageParameters(context, target, level, internalformat, false,
2717 0, 0, 0, x, y, width, height, border))
2718 {
2719 return;
2720 }
2721
2722 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
2723
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002724 switch (target)
2725 {
2726 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002727 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002728 gl::Texture2D *texture = context->getTexture2D();
2729 texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002730 }
2731 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002732
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002733 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2734 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2735 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2736 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2737 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2738 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002739 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002740 gl::TextureCubeMap *texture = context->getTextureCubeMap();
2741 texture->copyImage(target, 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
2745 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002746 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002747 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002748 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002749 }
2750 catch(std::bad_alloc&)
2751 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002752 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002753 }
2754}
2755
2756void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
2757{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002758 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002759 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002760 target, level, xoffset, yoffset, x, y, width, height);
2761
2762 try
2763 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002764 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002765
2766 if (context)
2767 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002768 if (context->getClientVersion() < 3 &&
2769 !validateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
2770 xoffset, yoffset, x, y, width, height, 0))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002771 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002772 return;
2773 }
2774
2775 if (context->getClientVersion() >= 3 &&
2776 !validateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
2777 xoffset, yoffset, 0, x, y, width, height, 0))
2778 {
2779 return;
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002780 }
2781
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002782 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00002783
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002784 switch (target)
daniel@transgaming.combbc57792010-07-28 19:21:05 +00002785 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002786 case GL_TEXTURE_2D:
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +00002787 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002788 gl::Texture2D *texture = context->getTexture2D();
2789 texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00002790 }
2791 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002792
2793 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2794 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2795 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2796 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2797 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2798 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com6452adf2012-10-17 18:22:35 +00002799 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002800 gl::TextureCubeMap *texture = context->getTextureCubeMap();
2801 texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +00002802 }
2803 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002804
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00002805 default:
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002806 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00002807 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002808 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002809 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002810
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002811 catch(std::bad_alloc&)
2812 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002813 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002814 }
2815}
2816
2817GLuint __stdcall glCreateProgram(void)
2818{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002819 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002820
2821 try
2822 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002823 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002824
2825 if (context)
2826 {
2827 return context->createProgram();
2828 }
2829 }
2830 catch(std::bad_alloc&)
2831 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002832 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002833 }
2834
2835 return 0;
2836}
2837
2838GLuint __stdcall glCreateShader(GLenum type)
2839{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002840 EVENT("(GLenum type = 0x%X)", type);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002841
2842 try
2843 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002844 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002845
2846 if (context)
2847 {
2848 switch (type)
2849 {
2850 case GL_FRAGMENT_SHADER:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00002851 case GL_VERTEX_SHADER:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002852 return context->createShader(type);
2853 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002854 return gl::error(GL_INVALID_ENUM, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002855 }
2856 }
2857 }
2858 catch(std::bad_alloc&)
2859 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002860 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002861 }
2862
2863 return 0;
2864}
2865
2866void __stdcall glCullFace(GLenum mode)
2867{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002868 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002869
2870 try
2871 {
2872 switch (mode)
2873 {
2874 case GL_FRONT:
2875 case GL_BACK:
2876 case GL_FRONT_AND_BACK:
2877 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002878 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002879
2880 if (context)
2881 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002882 context->setCullMode(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002883 }
2884 }
2885 break;
2886 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002887 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002888 }
2889 }
2890 catch(std::bad_alloc&)
2891 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002892 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002893 }
2894}
2895
2896void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers)
2897{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002898 EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002899
2900 try
2901 {
2902 if (n < 0)
2903 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002904 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002905 }
2906
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002907 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002908
2909 if (context)
2910 {
2911 for (int i = 0; i < n; i++)
2912 {
2913 context->deleteBuffer(buffers[i]);
2914 }
2915 }
2916 }
2917 catch(std::bad_alloc&)
2918 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002919 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002920 }
2921}
2922
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002923void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences)
2924{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002925 EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002926
2927 try
2928 {
2929 if (n < 0)
2930 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002931 return gl::error(GL_INVALID_VALUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002932 }
2933
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002934 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002935
2936 if (context)
2937 {
2938 for (int i = 0; i < n; i++)
2939 {
2940 context->deleteFence(fences[i]);
2941 }
2942 }
2943 }
2944 catch(std::bad_alloc&)
2945 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002946 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002947 }
2948}
2949
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002950void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
2951{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002952 EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002953
2954 try
2955 {
2956 if (n < 0)
2957 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002958 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002959 }
2960
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002961 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002962
2963 if (context)
2964 {
2965 for (int i = 0; i < n; i++)
2966 {
2967 if (framebuffers[i] != 0)
2968 {
2969 context->deleteFramebuffer(framebuffers[i]);
2970 }
2971 }
2972 }
2973 }
2974 catch(std::bad_alloc&)
2975 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002976 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002977 }
2978}
2979
2980void __stdcall glDeleteProgram(GLuint program)
2981{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002982 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002983
2984 try
2985 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00002986 if (program == 0)
2987 {
2988 return;
2989 }
2990
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002991 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002992
2993 if (context)
2994 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00002995 if (!context->getProgram(program))
2996 {
2997 if(context->getShader(program))
2998 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002999 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003000 }
3001 else
3002 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003003 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003004 }
3005 }
3006
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003007 context->deleteProgram(program);
3008 }
3009 }
3010 catch(std::bad_alloc&)
3011 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003012 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003013 }
3014}
3015
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003016void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
3017{
3018 EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
3019
3020 try
3021 {
3022 if (n < 0)
3023 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003024 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003025 }
3026
3027 gl::Context *context = gl::getNonLostContext();
3028
3029 if (context)
3030 {
3031 for (int i = 0; i < n; i++)
3032 {
3033 context->deleteQuery(ids[i]);
3034 }
3035 }
3036 }
3037 catch(std::bad_alloc&)
3038 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003039 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003040 }
3041}
3042
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003043void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
3044{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003045 EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003046
3047 try
3048 {
3049 if (n < 0)
3050 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003051 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003052 }
3053
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003054 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003055
3056 if (context)
3057 {
daniel@transgaming.come2b22122010-03-11 19:22:14 +00003058 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003059 {
3060 context->deleteRenderbuffer(renderbuffers[i]);
3061 }
3062 }
3063 }
3064 catch(std::bad_alloc&)
3065 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003066 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003067 }
3068}
3069
3070void __stdcall glDeleteShader(GLuint shader)
3071{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003072 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003073
3074 try
3075 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003076 if (shader == 0)
3077 {
3078 return;
3079 }
3080
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003081 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003082
3083 if (context)
3084 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003085 if (!context->getShader(shader))
3086 {
3087 if(context->getProgram(shader))
3088 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003089 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003090 }
3091 else
3092 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003093 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003094 }
3095 }
3096
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003097 context->deleteShader(shader);
3098 }
3099 }
3100 catch(std::bad_alloc&)
3101 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003102 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003103 }
3104}
3105
3106void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures)
3107{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003108 EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003109
3110 try
3111 {
3112 if (n < 0)
3113 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003114 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003115 }
3116
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003117 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003118
3119 if (context)
3120 {
3121 for (int i = 0; i < n; i++)
3122 {
3123 if (textures[i] != 0)
3124 {
3125 context->deleteTexture(textures[i]);
3126 }
3127 }
3128 }
3129 }
3130 catch(std::bad_alloc&)
3131 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003132 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003133 }
3134}
3135
3136void __stdcall glDepthFunc(GLenum func)
3137{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003138 EVENT("(GLenum func = 0x%X)", func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003139
3140 try
3141 {
3142 switch (func)
3143 {
3144 case GL_NEVER:
3145 case GL_ALWAYS:
3146 case GL_LESS:
3147 case GL_LEQUAL:
3148 case GL_EQUAL:
3149 case GL_GREATER:
3150 case GL_GEQUAL:
3151 case GL_NOTEQUAL:
3152 break;
3153 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003154 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003155 }
3156
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003157 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003158
3159 if (context)
3160 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003161 context->setDepthFunc(func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003162 }
3163 }
3164 catch(std::bad_alloc&)
3165 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003166 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003167 }
3168}
3169
3170void __stdcall glDepthMask(GLboolean flag)
3171{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00003172 EVENT("(GLboolean flag = %u)", flag);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003173
3174 try
3175 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003176 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003177
3178 if (context)
3179 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003180 context->setDepthMask(flag != GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003181 }
3182 }
3183 catch(std::bad_alloc&)
3184 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003185 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003186 }
3187}
3188
3189void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar)
3190{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003191 EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003192
3193 try
3194 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003195 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003196
3197 if (context)
3198 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003199 context->setDepthRange(zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003200 }
3201 }
3202 catch(std::bad_alloc&)
3203 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003204 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003205 }
3206}
3207
3208void __stdcall glDetachShader(GLuint program, GLuint shader)
3209{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003210 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003211
3212 try
3213 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003214 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003215
3216 if (context)
3217 {
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003218
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003219 gl::Program *programObject = context->getProgram(program);
3220 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003221
3222 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003223 {
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003224 gl::Shader *shaderByProgramHandle;
3225 shaderByProgramHandle = context->getShader(program);
3226 if (!shaderByProgramHandle)
3227 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003228 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003229 }
3230 else
3231 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003232 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003233 }
3234 }
3235
3236 if (!shaderObject)
3237 {
3238 gl::Program *programByShaderHandle = context->getProgram(shader);
3239 if (!programByShaderHandle)
3240 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003241 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003242 }
3243 else
3244 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003245 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003246 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003247 }
3248
3249 if (!programObject->detachShader(shaderObject))
3250 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003251 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003252 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003253 }
3254 }
3255 catch(std::bad_alloc&)
3256 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003257 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003258 }
3259}
3260
3261void __stdcall glDisable(GLenum cap)
3262{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003263 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003264
3265 try
3266 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003267 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003268
3269 if (context)
3270 {
3271 switch (cap)
3272 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003273 case GL_CULL_FACE: context->setCullFace(false); break;
3274 case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break;
3275 case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break;
3276 case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break;
3277 case GL_SCISSOR_TEST: context->setScissorTest(false); break;
3278 case GL_STENCIL_TEST: context->setStencilTest(false); break;
3279 case GL_DEPTH_TEST: context->setDepthTest(false); break;
3280 case GL_BLEND: context->setBlend(false); break;
3281 case GL_DITHER: context->setDither(false); break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00003282
3283 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
3284 case GL_RASTERIZER_DISCARD:
3285 if (context->getClientVersion() < 3)
3286 {
3287 return gl::error(GL_INVALID_ENUM);
3288 }
3289 UNIMPLEMENTED();
3290 break;
3291
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003292 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003293 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003294 }
3295 }
3296 }
3297 catch(std::bad_alloc&)
3298 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003299 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003300 }
3301}
3302
3303void __stdcall glDisableVertexAttribArray(GLuint index)
3304{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003305 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003306
3307 try
3308 {
3309 if (index >= gl::MAX_VERTEX_ATTRIBS)
3310 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003311 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003312 }
3313
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003314 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003315
3316 if (context)
3317 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00003318 context->setEnableVertexAttribArray(index, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003319 }
3320 }
3321 catch(std::bad_alloc&)
3322 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003323 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003324 }
3325}
3326
3327void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count)
3328{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003329 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003330
3331 try
3332 {
3333 if (count < 0 || first < 0)
3334 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003335 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003336 }
3337
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003338 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003339
3340 if (context)
3341 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003342 context->drawArrays(mode, first, count, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003343 }
3344 }
3345 catch(std::bad_alloc&)
3346 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003347 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003348 }
3349}
3350
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003351void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
3352{
3353 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
3354
3355 try
3356 {
3357 if (count < 0 || first < 0 || primcount < 0)
3358 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003359 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003360 }
3361
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003362 if (primcount > 0)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003363 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003364 gl::Context *context = gl::getNonLostContext();
3365
3366 if (context)
3367 {
3368 context->drawArrays(mode, first, count, primcount);
3369 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003370 }
3371 }
3372 catch(std::bad_alloc&)
3373 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003374 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003375 }
3376}
3377
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003378void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003379{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003380 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 +00003381 mode, count, type, indices);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003382
3383 try
3384 {
3385 if (count < 0)
3386 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003387 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003388 }
3389
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003390 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003391
3392 if (context)
3393 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00003394 switch (type)
3395 {
3396 case GL_UNSIGNED_BYTE:
3397 case GL_UNSIGNED_SHORT:
3398 break;
3399 case GL_UNSIGNED_INT:
3400 if (!context->supports32bitIndices())
3401 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003402 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com83921382011-01-08 05:46:00 +00003403 }
3404 break;
3405 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003406 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com83921382011-01-08 05:46:00 +00003407 }
3408
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003409 context->drawElements(mode, count, type, indices, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003410 }
3411 }
3412 catch(std::bad_alloc&)
3413 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003414 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003415 }
3416}
3417
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003418void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
3419{
3420 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
3421 mode, count, type, indices, primcount);
3422
3423 try
3424 {
3425 if (count < 0 || primcount < 0)
3426 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003427 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003428 }
3429
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003430 if (primcount > 0)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003431 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003432 gl::Context *context = gl::getNonLostContext();
3433
3434 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003435 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003436 switch (type)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003437 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003438 case GL_UNSIGNED_BYTE:
3439 case GL_UNSIGNED_SHORT:
3440 break;
3441 case GL_UNSIGNED_INT:
3442 if (!context->supports32bitIndices())
3443 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003444 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003445 }
3446 break;
3447 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003448 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003449 }
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003450
3451 context->drawElements(mode, count, type, indices, primcount);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003452 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003453 }
3454 }
3455 catch(std::bad_alloc&)
3456 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003457 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003458 }
3459}
3460
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003461void __stdcall glEnable(GLenum cap)
3462{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003463 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003464
3465 try
3466 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003467 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003468
3469 if (context)
3470 {
3471 switch (cap)
3472 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003473 case GL_CULL_FACE: context->setCullFace(true); break;
3474 case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break;
3475 case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break;
3476 case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break;
3477 case GL_SCISSOR_TEST: context->setScissorTest(true); break;
3478 case GL_STENCIL_TEST: context->setStencilTest(true); break;
3479 case GL_DEPTH_TEST: context->setDepthTest(true); break;
3480 case GL_BLEND: context->setBlend(true); break;
3481 case GL_DITHER: context->setDither(true); break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003482 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003483 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003484 }
3485 }
3486 }
3487 catch(std::bad_alloc&)
3488 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003489 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003490 }
3491}
3492
3493void __stdcall glEnableVertexAttribArray(GLuint index)
3494{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003495 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003496
3497 try
3498 {
3499 if (index >= gl::MAX_VERTEX_ATTRIBS)
3500 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003501 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003502 }
3503
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003504 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003505
3506 if (context)
3507 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00003508 context->setEnableVertexAttribArray(index, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003509 }
3510 }
3511 catch(std::bad_alloc&)
3512 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003513 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003514 }
3515}
3516
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003517void __stdcall glEndQueryEXT(GLenum target)
3518{
3519 EVENT("GLenum target = 0x%X)", target);
3520
3521 try
3522 {
3523 switch (target)
3524 {
3525 case GL_ANY_SAMPLES_PASSED_EXT:
3526 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
3527 break;
3528 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003529 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003530 }
3531
3532 gl::Context *context = gl::getNonLostContext();
3533
3534 if (context)
3535 {
3536 context->endQuery(target);
3537 }
3538 }
3539 catch(std::bad_alloc&)
3540 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003541 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003542 }
3543}
3544
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003545void __stdcall glFinishFenceNV(GLuint fence)
3546{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003547 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003548
3549 try
3550 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003551 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003552
3553 if (context)
3554 {
3555 gl::Fence* fenceObject = context->getFence(fence);
3556
3557 if (fenceObject == NULL)
3558 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003559 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003560 }
3561
3562 fenceObject->finishFence();
3563 }
3564 }
3565 catch(std::bad_alloc&)
3566 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003567 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003568 }
3569}
3570
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003571void __stdcall glFinish(void)
3572{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003573 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003574
3575 try
3576 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003577 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003578
3579 if (context)
3580 {
daniel@transgaming.com0d86aa72011-10-26 02:35:10 +00003581 context->sync(true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003582 }
3583 }
3584 catch(std::bad_alloc&)
3585 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003586 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003587 }
3588}
3589
3590void __stdcall glFlush(void)
3591{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003592 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003593
3594 try
3595 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003596 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003597
3598 if (context)
3599 {
daniel@transgaming.com0d86aa72011-10-26 02:35:10 +00003600 context->sync(false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003601 }
3602 }
3603 catch(std::bad_alloc&)
3604 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003605 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003606 }
3607}
3608
3609void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
3610{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003611 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003612 "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003613
3614 try
3615 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003616 if ((target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com2fa45512011-10-04 18:43:18 +00003617 || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003618 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003619 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003620 }
3621
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003622 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003623
3624 if (context)
3625 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003626 gl::Framebuffer *framebuffer = NULL;
3627 GLuint framebufferHandle = 0;
3628 if (target == GL_READ_FRAMEBUFFER_ANGLE)
3629 {
3630 framebuffer = context->getReadFramebuffer();
3631 framebufferHandle = context->getReadFramebufferHandle();
3632 }
daniel@transgaming.com2fa45512011-10-04 18:43:18 +00003633 else
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003634 {
3635 framebuffer = context->getDrawFramebuffer();
3636 framebufferHandle = context->getDrawFramebufferHandle();
3637 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003638
daniel@transgaming.com2fa45512011-10-04 18:43:18 +00003639 if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003640 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003641 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003642 }
3643
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003644 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003645 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003646 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
3647
3648 if (colorAttachment >= context->getMaximumRenderTargets())
3649 {
3650 return gl::error(GL_INVALID_VALUE);
3651 }
3652
3653 framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer);
3654 }
3655 else
3656 {
3657 switch (attachment)
3658 {
3659 case GL_DEPTH_ATTACHMENT:
3660 framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer);
3661 break;
3662 case GL_STENCIL_ATTACHMENT:
3663 framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer);
3664 break;
3665 default:
3666 return gl::error(GL_INVALID_ENUM);
3667 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003668 }
3669 }
3670 }
3671 catch(std::bad_alloc&)
3672 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003673 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003674 }
3675}
3676
3677void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
3678{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003679 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003680 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003681
3682 try
3683 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003684 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003685 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003686 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003687 }
3688
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003689 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003690
3691 if (context)
3692 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003693 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
3694 {
3695 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
3696
3697 if (colorAttachment >= context->getMaximumRenderTargets())
3698 {
3699 return gl::error(GL_INVALID_VALUE);
3700 }
3701 }
3702 else
3703 {
3704 switch (attachment)
3705 {
3706 case GL_DEPTH_ATTACHMENT:
3707 case GL_STENCIL_ATTACHMENT:
3708 break;
3709 default:
3710 return gl::error(GL_INVALID_ENUM);
3711 }
3712 }
3713
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003714 if (texture == 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003715 {
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003716 textarget = GL_NONE;
3717 }
3718 else
3719 {
3720 gl::Texture *tex = context->getTexture(texture);
3721
3722 if (tex == NULL)
3723 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003724 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003725 }
3726
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003727 switch (textarget)
3728 {
3729 case GL_TEXTURE_2D:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003730 {
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003731 if (tex->getTarget() != GL_TEXTURE_2D)
3732 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003733 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003734 }
3735 gl::Texture2D *tex2d = static_cast<gl::Texture2D *>(tex);
daniel@transgaming.com92f49922012-05-09 15:49:19 +00003736 if (tex2d->isCompressed(0))
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003737 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003738 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003739 }
3740 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003741 }
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003742
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003743 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003744 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003745 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003746 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003747 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003748 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003749 {
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003750 if (tex->getTarget() != GL_TEXTURE_CUBE_MAP)
3751 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003752 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003753 }
3754 gl::TextureCubeMap *texcube = static_cast<gl::TextureCubeMap *>(tex);
daniel@transgaming.com4df88e82012-05-09 15:49:24 +00003755 if (texcube->isCompressed(textarget, level))
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003756 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003757 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003758 }
3759 break;
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003760 }
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003761
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003762 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003763 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003764 }
3765
3766 if (level != 0)
3767 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003768 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003769 }
3770 }
3771
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003772 gl::Framebuffer *framebuffer = NULL;
3773 GLuint framebufferHandle = 0;
3774 if (target == GL_READ_FRAMEBUFFER_ANGLE)
3775 {
3776 framebuffer = context->getReadFramebuffer();
3777 framebufferHandle = context->getReadFramebufferHandle();
3778 }
3779 else
3780 {
3781 framebuffer = context->getDrawFramebuffer();
3782 framebufferHandle = context->getDrawFramebufferHandle();
3783 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003784
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003785 if (framebufferHandle == 0 || !framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003786 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003787 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003788 }
3789
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003790 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00003791 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003792 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
3793
3794 if (colorAttachment >= context->getMaximumRenderTargets())
3795 {
3796 return gl::error(GL_INVALID_VALUE);
3797 }
3798
3799 framebuffer->setColorbuffer(colorAttachment, textarget, texture);
3800 }
3801 else
3802 {
3803 switch (attachment)
3804 {
3805 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break;
3806 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break;
3807 }
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00003808 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003809 }
3810 }
3811 catch(std::bad_alloc&)
3812 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003813 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003814 }
3815}
3816
3817void __stdcall glFrontFace(GLenum mode)
3818{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003819 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003820
3821 try
3822 {
3823 switch (mode)
3824 {
3825 case GL_CW:
3826 case GL_CCW:
3827 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003828 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003829
3830 if (context)
3831 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003832 context->setFrontFace(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003833 }
3834 }
3835 break;
3836 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003837 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003838 }
3839 }
3840 catch(std::bad_alloc&)
3841 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003842 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003843 }
3844}
3845
3846void __stdcall glGenBuffers(GLsizei n, GLuint* buffers)
3847{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003848 EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003849
3850 try
3851 {
3852 if (n < 0)
3853 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003854 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003855 }
3856
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003857 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003858
3859 if (context)
3860 {
3861 for (int i = 0; i < n; i++)
3862 {
3863 buffers[i] = context->createBuffer();
3864 }
3865 }
3866 }
3867 catch(std::bad_alloc&)
3868 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003869 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003870 }
3871}
3872
3873void __stdcall glGenerateMipmap(GLenum target)
3874{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003875 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003876
3877 try
3878 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003879 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003880
3881 if (context)
3882 {
Geoff Langae4852a2013-06-05 15:00:34 -04003883 gl::Texture *texture = NULL;
3884 GLint internalFormat = GL_NONE;
3885 bool isCompressed = false;
3886 bool isDepth = false;
3887
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003888 switch (target)
3889 {
3890 case GL_TEXTURE_2D:
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003891 {
3892 gl::Texture2D *tex2d = context->getTexture2D();
Geoff Langae4852a2013-06-05 15:00:34 -04003893 if (tex2d)
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003894 {
Geoff Langae4852a2013-06-05 15:00:34 -04003895 internalFormat = tex2d->getInternalFormat(0);
3896 isCompressed = tex2d->isCompressed(0);
3897 isDepth = tex2d->isDepth(0);
3898 texture = tex2d;
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003899 }
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003900 break;
3901 }
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003902
3903 case GL_TEXTURE_CUBE_MAP:
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003904 {
3905 gl::TextureCubeMap *texcube = context->getTextureCubeMap();
Geoff Langae4852a2013-06-05 15:00:34 -04003906 if (texcube)
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003907 {
Geoff Langae4852a2013-06-05 15:00:34 -04003908 internalFormat = texcube->getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0);
3909 isCompressed = texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0);
3910 isDepth = false;
3911 texture = texcube;
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003912 }
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003913 break;
3914 }
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003915
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00003916 case GL_TEXTURE_3D:
3917 {
3918 if (context->getClientVersion() < 3)
3919 {
3920 return gl::error(GL_INVALID_ENUM);
3921 }
3922
3923 gl::Texture3D *tex3D = context->getTexture3D();
Geoff Langae4852a2013-06-05 15:00:34 -04003924 if (tex3D)
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00003925 {
Geoff Langae4852a2013-06-05 15:00:34 -04003926 internalFormat = tex3D->getInternalFormat(0);
3927 isCompressed = tex3D->isCompressed(0);
3928 isDepth = tex3D->isDepth(0);
3929 texture = tex3D;
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00003930 }
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00003931 break;
3932 }
3933
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00003934 case GL_TEXTURE_2D_ARRAY:
3935 {
3936 if (context->getClientVersion() < 3)
3937 {
3938 return gl::error(GL_INVALID_ENUM);
3939 }
3940
3941 gl::Texture2DArray *tex2darr = context->getTexture2DArray();
Geoff Langae4852a2013-06-05 15:00:34 -04003942 if (tex2darr)
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00003943 {
Geoff Langae4852a2013-06-05 15:00:34 -04003944 internalFormat = tex2darr->getInternalFormat(0);
3945 isCompressed = tex2darr->isCompressed(0);
3946 isDepth = tex2darr->isDepth(0);
3947 texture = tex2darr;
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00003948 }
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00003949 break;
3950 }
3951
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003952 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003953 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003954 }
Geoff Langae4852a2013-06-05 15:00:34 -04003955
3956 if (!texture)
3957 {
3958 return gl::error(GL_INVALID_OPERATION);
3959 }
3960
3961 // Internally, all texture formats are sized so checking if the format
3962 // is color renderable and filterable will not fail.
3963 if (isDepth || isCompressed ||
3964 !gl::IsColorRenderingSupported(internalFormat, context) ||
3965 !gl::IsTextureFilteringSupported(internalFormat, context))
3966 {
3967 return gl::error(GL_INVALID_OPERATION);
3968 }
3969
3970 texture->generateMipmaps();
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003971 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003972 }
3973 catch(std::bad_alloc&)
3974 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003975 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003976 }
3977}
3978
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003979void __stdcall glGenFencesNV(GLsizei n, GLuint* fences)
3980{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003981 EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003982
3983 try
3984 {
3985 if (n < 0)
3986 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003987 return gl::error(GL_INVALID_VALUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003988 }
3989
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003990 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003991
3992 if (context)
3993 {
3994 for (int i = 0; i < n; i++)
3995 {
3996 fences[i] = context->createFence();
3997 }
3998 }
3999 }
4000 catch(std::bad_alloc&)
4001 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004002 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004003 }
4004}
4005
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004006void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers)
4007{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004008 EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004009
4010 try
4011 {
4012 if (n < 0)
4013 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004014 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004015 }
4016
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004017 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004018
4019 if (context)
4020 {
4021 for (int i = 0; i < n; i++)
4022 {
4023 framebuffers[i] = context->createFramebuffer();
4024 }
4025 }
4026 }
4027 catch(std::bad_alloc&)
4028 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004029 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004030 }
4031}
4032
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004033void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids)
4034{
4035 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
4036
4037 try
4038 {
4039 if (n < 0)
4040 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004041 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004042 }
4043
4044 gl::Context *context = gl::getNonLostContext();
4045
4046 if (context)
4047 {
4048 for (int i = 0; i < n; i++)
4049 {
4050 ids[i] = context->createQuery();
4051 }
4052 }
4053 }
4054 catch(std::bad_alloc&)
4055 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004056 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004057 }
4058}
4059
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004060void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
4061{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004062 EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004063
4064 try
4065 {
4066 if (n < 0)
4067 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004068 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004069 }
4070
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004071 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004072
4073 if (context)
4074 {
4075 for (int i = 0; i < n; i++)
4076 {
4077 renderbuffers[i] = context->createRenderbuffer();
4078 }
4079 }
4080 }
4081 catch(std::bad_alloc&)
4082 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004083 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004084 }
4085}
4086
4087void __stdcall glGenTextures(GLsizei n, GLuint* textures)
4088{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004089 EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004090
4091 try
4092 {
4093 if (n < 0)
4094 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004095 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004096 }
4097
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004098 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004099
4100 if (context)
4101 {
4102 for (int i = 0; i < n; i++)
4103 {
4104 textures[i] = context->createTexture();
4105 }
4106 }
4107 }
4108 catch(std::bad_alloc&)
4109 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004110 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004111 }
4112}
4113
daniel@transgaming.com85423182010-04-22 13:35:27 +00004114void __stdcall glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004115{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004116 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
daniel@transgaming.com85423182010-04-22 13:35:27 +00004117 "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004118 program, index, bufsize, length, size, type, name);
4119
4120 try
4121 {
4122 if (bufsize < 0)
4123 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004124 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004125 }
4126
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004127 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com85423182010-04-22 13:35:27 +00004128
4129 if (context)
4130 {
4131 gl::Program *programObject = context->getProgram(program);
4132
4133 if (!programObject)
4134 {
4135 if (context->getShader(program))
4136 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004137 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com85423182010-04-22 13:35:27 +00004138 }
4139 else
4140 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004141 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com85423182010-04-22 13:35:27 +00004142 }
4143 }
4144
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004145 if (index >= (GLuint)programObject->getActiveAttributeCount())
daniel@transgaming.com85423182010-04-22 13:35:27 +00004146 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004147 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com85423182010-04-22 13:35:27 +00004148 }
4149
4150 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
4151 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004152 }
4153 catch(std::bad_alloc&)
4154 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004155 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004156 }
4157}
4158
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004159void __stdcall glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004160{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004161 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004162 "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 +00004163 program, index, bufsize, length, size, type, name);
4164
4165 try
4166 {
4167 if (bufsize < 0)
4168 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004169 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004170 }
4171
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004172 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004173
4174 if (context)
4175 {
4176 gl::Program *programObject = context->getProgram(program);
4177
4178 if (!programObject)
4179 {
4180 if (context->getShader(program))
4181 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004182 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004183 }
4184 else
4185 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004186 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004187 }
4188 }
4189
4190 if (index >= (GLuint)programObject->getActiveUniformCount())
4191 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004192 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004193 }
4194
4195 programObject->getActiveUniform(index, bufsize, length, size, type, name);
4196 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004197 }
4198 catch(std::bad_alloc&)
4199 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004200 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004201 }
4202}
4203
4204void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
4205{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004206 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 +00004207 program, maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004208
4209 try
4210 {
4211 if (maxcount < 0)
4212 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004213 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004214 }
4215
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004216 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com6c785212010-03-30 03:36:17 +00004217
4218 if (context)
4219 {
4220 gl::Program *programObject = context->getProgram(program);
4221
4222 if (!programObject)
4223 {
daniel@transgaming.com23953e32010-04-13 19:53:31 +00004224 if (context->getShader(program))
4225 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004226 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com23953e32010-04-13 19:53:31 +00004227 }
4228 else
4229 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004230 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com23953e32010-04-13 19:53:31 +00004231 }
daniel@transgaming.com6c785212010-03-30 03:36:17 +00004232 }
4233
4234 return programObject->getAttachedShaders(maxcount, count, shaders);
4235 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004236 }
4237 catch(std::bad_alloc&)
4238 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004239 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004240 }
4241}
4242
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004243int __stdcall glGetAttribLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004244{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004245 EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004246
4247 try
4248 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004249 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004250
4251 if (context)
4252 {
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004253
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004254 gl::Program *programObject = context->getProgram(program);
4255
4256 if (!programObject)
4257 {
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004258 if (context->getShader(program))
4259 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004260 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004261 }
4262 else
4263 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004264 return gl::error(GL_INVALID_VALUE, -1);
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004265 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004266 }
4267
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00004268 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
daniel@transgaming.com716056c2012-07-24 18:38:59 +00004269 if (!programObject->isLinked() || !programBinary)
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00004270 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004271 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00004272 }
4273
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00004274 return programBinary->getAttributeLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004275 }
4276 }
4277 catch(std::bad_alloc&)
4278 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004279 return gl::error(GL_OUT_OF_MEMORY, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004280 }
4281
4282 return -1;
4283}
4284
4285void __stdcall glGetBooleanv(GLenum pname, GLboolean* params)
4286{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004287 EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004288
4289 try
4290 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004291 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004292
4293 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004294 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004295 if (!(context->getBooleanv(pname, params)))
4296 {
4297 GLenum nativeType;
4298 unsigned int numParams = 0;
4299 if (!context->getQueryParameterInfo(pname, &nativeType, &numParams))
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004300 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004301
4302 if (numParams == 0)
4303 return; // it is known that the pname is valid, but there are no parameters to return
4304
4305 if (nativeType == GL_FLOAT)
4306 {
4307 GLfloat *floatParams = NULL;
4308 floatParams = new GLfloat[numParams];
4309
4310 context->getFloatv(pname, floatParams);
4311
4312 for (unsigned int i = 0; i < numParams; ++i)
4313 {
4314 if (floatParams[i] == 0.0f)
4315 params[i] = GL_FALSE;
4316 else
4317 params[i] = GL_TRUE;
4318 }
4319
4320 delete [] floatParams;
4321 }
4322 else if (nativeType == GL_INT)
4323 {
4324 GLint *intParams = NULL;
4325 intParams = new GLint[numParams];
4326
4327 context->getIntegerv(pname, intParams);
4328
4329 for (unsigned int i = 0; i < numParams; ++i)
4330 {
4331 if (intParams[i] == 0)
4332 params[i] = GL_FALSE;
4333 else
4334 params[i] = GL_TRUE;
4335 }
4336
4337 delete [] intParams;
4338 }
4339 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004340 }
4341 }
4342 catch(std::bad_alloc&)
4343 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004344 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004345 }
4346}
4347
4348void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
4349{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004350 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 +00004351
4352 try
4353 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004354 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004355
4356 if (context)
4357 {
4358 gl::Buffer *buffer;
4359
4360 switch (target)
4361 {
4362 case GL_ARRAY_BUFFER:
4363 buffer = context->getArrayBuffer();
4364 break;
4365 case GL_ELEMENT_ARRAY_BUFFER:
4366 buffer = context->getElementArrayBuffer();
4367 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004368 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004369 }
4370
4371 if (!buffer)
4372 {
4373 // A null buffer means that "0" is bound to the requested buffer target
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004374 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004375 }
4376
4377 switch (pname)
4378 {
4379 case GL_BUFFER_USAGE:
4380 *params = buffer->usage();
4381 break;
4382 case GL_BUFFER_SIZE:
4383 *params = buffer->size();
4384 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004385 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004386 }
4387 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004388 }
4389 catch(std::bad_alloc&)
4390 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004391 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004392 }
4393}
4394
4395GLenum __stdcall glGetError(void)
4396{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004397 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004398
4399 gl::Context *context = gl::getContext();
4400
4401 if (context)
4402 {
daniel@transgaming.com82b28912011-12-12 21:01:35 +00004403 return context->getError();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004404 }
4405
4406 return GL_NO_ERROR;
4407}
4408
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004409void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
4410{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004411 EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004412
4413 try
4414 {
4415
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004416 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004417
4418 if (context)
4419 {
4420 gl::Fence *fenceObject = context->getFence(fence);
4421
4422 if (fenceObject == NULL)
4423 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004424 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004425 }
4426
4427 fenceObject->getFenceiv(pname, params);
4428 }
4429 }
4430 catch(std::bad_alloc&)
4431 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004432 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004433 }
4434}
4435
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004436void __stdcall glGetFloatv(GLenum pname, GLfloat* params)
4437{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004438 EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004439
4440 try
4441 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004442 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004443
4444 if (context)
4445 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004446 if (!(context->getFloatv(pname, params)))
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004447 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004448 GLenum nativeType;
4449 unsigned int numParams = 0;
4450 if (!context->getQueryParameterInfo(pname, &nativeType, &numParams))
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004451 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004452
4453 if (numParams == 0)
4454 return; // it is known that the pname is valid, but that there are no parameters to return.
4455
4456 if (nativeType == GL_BOOL)
4457 {
4458 GLboolean *boolParams = NULL;
4459 boolParams = new GLboolean[numParams];
4460
4461 context->getBooleanv(pname, boolParams);
4462
4463 for (unsigned int i = 0; i < numParams; ++i)
4464 {
4465 if (boolParams[i] == GL_FALSE)
4466 params[i] = 0.0f;
4467 else
4468 params[i] = 1.0f;
4469 }
4470
4471 delete [] boolParams;
4472 }
4473 else if (nativeType == GL_INT)
4474 {
4475 GLint *intParams = NULL;
4476 intParams = new GLint[numParams];
4477
4478 context->getIntegerv(pname, intParams);
4479
4480 for (unsigned int i = 0; i < numParams; ++i)
4481 {
4482 params[i] = (GLfloat)intParams[i];
4483 }
4484
4485 delete [] intParams;
4486 }
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004487 }
4488 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004489 }
4490 catch(std::bad_alloc&)
4491 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004492 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004493 }
4494}
4495
4496void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
4497{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004498 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 +00004499 target, attachment, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004500
4501 try
4502 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004503 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004504
4505 if (context)
4506 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004507 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004508 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004509 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004510 }
4511
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004512 gl::Framebuffer *framebuffer = NULL;
4513 if (target == GL_READ_FRAMEBUFFER_ANGLE)
4514 {
4515 if(context->getReadFramebufferHandle() == 0)
4516 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004517 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004518 }
4519
4520 framebuffer = context->getReadFramebuffer();
4521 }
4522 else
4523 {
4524 if (context->getDrawFramebufferHandle() == 0)
4525 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004526 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004527 }
4528
4529 framebuffer = context->getDrawFramebuffer();
4530 }
4531
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004532 GLenum attachmentType;
4533 GLuint attachmentHandle;
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00004534
4535 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004536 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00004537 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
4538
4539 if (colorAttachment >= context->getMaximumRenderTargets())
4540 {
4541 return gl::error(GL_INVALID_ENUM);
4542 }
4543
4544 attachmentType = framebuffer->getColorbufferType(colorAttachment);
4545 attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment);
4546 }
4547 else
4548 {
4549 switch (attachment)
4550 {
4551 case GL_DEPTH_ATTACHMENT:
4552 attachmentType = framebuffer->getDepthbufferType();
4553 attachmentHandle = framebuffer->getDepthbufferHandle();
4554 break;
4555 case GL_STENCIL_ATTACHMENT:
4556 attachmentType = framebuffer->getStencilbufferType();
4557 attachmentHandle = framebuffer->getStencilbufferHandle();
4558 break;
4559 default: return gl::error(GL_INVALID_ENUM);
4560 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004561 }
4562
4563 GLenum attachmentObjectType; // Type category
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00004564 if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004565 {
4566 attachmentObjectType = attachmentType;
4567 }
apatrick@chromium.org551022e2012-01-23 19:56:54 +00004568 else if (gl::IsInternalTextureTarget(attachmentType))
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004569 {
4570 attachmentObjectType = GL_TEXTURE;
4571 }
apatrick@chromium.orga1d80592012-01-25 21:52:10 +00004572 else
4573 {
4574 UNREACHABLE();
4575 return;
4576 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004577
4578 switch (pname)
4579 {
4580 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
4581 *params = attachmentObjectType;
4582 break;
4583 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
4584 if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE)
4585 {
4586 *params = attachmentHandle;
4587 }
4588 else
4589 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004590 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004591 }
4592 break;
4593 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
4594 if (attachmentObjectType == GL_TEXTURE)
4595 {
4596 *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0
4597 }
4598 else
4599 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004600 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004601 }
4602 break;
4603 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
4604 if (attachmentObjectType == GL_TEXTURE)
4605 {
daniel@transgaming.com19ffc242010-05-04 03:35:21 +00004606 if (gl::IsCubemapTextureTarget(attachmentType))
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004607 {
4608 *params = attachmentType;
4609 }
4610 else
4611 {
4612 *params = 0;
4613 }
4614 }
4615 else
4616 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004617 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004618 }
4619 break;
4620 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004621 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004622 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004623 }
4624 }
4625 catch(std::bad_alloc&)
4626 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004627 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004628 }
4629}
4630
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00004631GLenum __stdcall glGetGraphicsResetStatusEXT(void)
4632{
4633 EVENT("()");
4634
4635 try
4636 {
4637 gl::Context *context = gl::getContext();
4638
4639 if (context)
4640 {
4641 return context->getResetStatus();
4642 }
4643
4644 return GL_NO_ERROR;
4645 }
4646 catch(std::bad_alloc&)
4647 {
4648 return GL_OUT_OF_MEMORY;
4649 }
4650}
4651
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004652void __stdcall glGetIntegerv(GLenum pname, GLint* params)
4653{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004654 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004655
4656 try
4657 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004658 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004659
4660 if (context)
4661 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004662 if (!(context->getIntegerv(pname, params)))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004663 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004664 GLenum nativeType;
4665 unsigned int numParams = 0;
4666 if (!context->getQueryParameterInfo(pname, &nativeType, &numParams))
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004667 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004668
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004669 if (numParams == 0)
4670 return; // it is known that pname is valid, but there are no parameters to return
4671
4672 if (nativeType == GL_BOOL)
4673 {
4674 GLboolean *boolParams = NULL;
4675 boolParams = new GLboolean[numParams];
4676
4677 context->getBooleanv(pname, boolParams);
4678
4679 for (unsigned int i = 0; i < numParams; ++i)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004680 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004681 if (boolParams[i] == GL_FALSE)
4682 params[i] = 0;
4683 else
4684 params[i] = 1;
4685 }
4686
4687 delete [] boolParams;
4688 }
4689 else if (nativeType == GL_FLOAT)
4690 {
4691 GLfloat *floatParams = NULL;
4692 floatParams = new GLfloat[numParams];
4693
4694 context->getFloatv(pname, floatParams);
4695
4696 for (unsigned int i = 0; i < numParams; ++i)
4697 {
daniel@transgaming.comc1641352010-04-26 15:33:36 +00004698 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 +00004699 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004700 params[i] = (GLint)(((GLfloat)(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004701 }
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004702 else
4703 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 +00004704 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004705
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004706 delete [] floatParams;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004707 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004708 }
4709 }
4710 }
4711 catch(std::bad_alloc&)
4712 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004713 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004714 }
4715}
4716
4717void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params)
4718{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004719 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004720
4721 try
4722 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004723 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004724
4725 if (context)
4726 {
4727 gl::Program *programObject = context->getProgram(program);
4728
4729 if (!programObject)
4730 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004731 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004732 }
4733
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00004734 if (context->getClientVersion() < 3)
4735 {
4736 switch (pname)
4737 {
4738 case GL_ACTIVE_UNIFORM_BLOCKS:
4739 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
4740 return gl::error(GL_INVALID_ENUM);
4741 }
4742 }
4743
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004744 switch (pname)
4745 {
4746 case GL_DELETE_STATUS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004747 *params = programObject->isFlaggedForDeletion();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004748 return;
4749 case GL_LINK_STATUS:
daniel@transgaming.com716056c2012-07-24 18:38:59 +00004750 *params = programObject->isLinked();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004751 return;
4752 case GL_VALIDATE_STATUS:
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004753 *params = programObject->isValidated();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004754 return;
4755 case GL_INFO_LOG_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004756 *params = programObject->getInfoLogLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004757 return;
4758 case GL_ATTACHED_SHADERS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004759 *params = programObject->getAttachedShadersCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004760 return;
4761 case GL_ACTIVE_ATTRIBUTES:
daniel@transgaming.com85423182010-04-22 13:35:27 +00004762 *params = programObject->getActiveAttributeCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004763 return;
4764 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
daniel@transgaming.com85423182010-04-22 13:35:27 +00004765 *params = programObject->getActiveAttributeMaxLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004766 return;
4767 case GL_ACTIVE_UNIFORMS:
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004768 *params = programObject->getActiveUniformCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004769 return;
4770 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004771 *params = programObject->getActiveUniformMaxLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004772 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00004773 case GL_PROGRAM_BINARY_LENGTH_OES:
apatrick@chromium.org90080e32012-07-09 22:15:33 +00004774 *params = programObject->getProgramBinaryLength();
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00004775 return;
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00004776 case GL_ACTIVE_UNIFORM_BLOCKS:
4777 *params = programObject->getActiveUniformBlockCount();
4778 return;
4779 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
4780 *params = programObject->getActiveUniformBlockMaxLength();
4781 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004782 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004783 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004784 }
4785 }
4786 }
4787 catch(std::bad_alloc&)
4788 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004789 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004790 }
4791}
4792
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004793void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004794{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004795 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 +00004796 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004797
4798 try
4799 {
4800 if (bufsize < 0)
4801 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004802 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004803 }
4804
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004805 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004806
4807 if (context)
4808 {
4809 gl::Program *programObject = context->getProgram(program);
4810
4811 if (!programObject)
4812 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004813 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004814 }
4815
4816 programObject->getInfoLog(bufsize, length, infolog);
4817 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004818 }
4819 catch(std::bad_alloc&)
4820 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004821 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004822 }
4823}
4824
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004825void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
4826{
4827 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
4828
4829 try
4830 {
4831 switch (pname)
4832 {
4833 case GL_CURRENT_QUERY_EXT:
4834 break;
4835 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004836 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004837 }
4838
4839 gl::Context *context = gl::getNonLostContext();
4840
4841 if (context)
4842 {
4843 params[0] = context->getActiveQuery(target);
4844 }
4845 }
4846 catch(std::bad_alloc&)
4847 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004848 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004849 }
4850}
4851
4852void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
4853{
4854 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
4855
4856 try
4857 {
4858 switch (pname)
4859 {
4860 case GL_QUERY_RESULT_EXT:
4861 case GL_QUERY_RESULT_AVAILABLE_EXT:
4862 break;
4863 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004864 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004865 }
4866 gl::Context *context = gl::getNonLostContext();
4867
4868 if (context)
4869 {
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004870 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
4871
4872 if (!queryObject)
4873 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004874 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004875 }
4876
4877 if (context->getActiveQuery(queryObject->getType()) == id)
4878 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004879 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004880 }
4881
4882 switch(pname)
4883 {
4884 case GL_QUERY_RESULT_EXT:
4885 params[0] = queryObject->getResult();
4886 break;
4887 case GL_QUERY_RESULT_AVAILABLE_EXT:
4888 params[0] = queryObject->isResultAvailable();
4889 break;
4890 default:
4891 ASSERT(false);
4892 }
4893 }
4894 }
4895 catch(std::bad_alloc&)
4896 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004897 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004898 }
4899}
4900
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004901void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
4902{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004903 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 +00004904
4905 try
4906 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004907 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004908
4909 if (context)
4910 {
4911 if (target != GL_RENDERBUFFER)
4912 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004913 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004914 }
4915
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004916 if (context->getRenderbufferHandle() == 0)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004917 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004918 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004919 }
4920
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004921 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle());
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004922
4923 switch (pname)
4924 {
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00004925 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
4926 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
4927 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
4928 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
4929 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
4930 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
4931 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
4932 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
4933 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00004934 case GL_RENDERBUFFER_SAMPLES_ANGLE:
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00004935 if (context->getMaxSupportedSamples() != 0)
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00004936 {
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00004937 *params = renderbuffer->getSamples();
4938 }
4939 else
4940 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004941 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00004942 }
4943 break;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004944 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004945 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004946 }
4947 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004948 }
4949 catch(std::bad_alloc&)
4950 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004951 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004952 }
4953}
4954
4955void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
4956{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004957 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004958
4959 try
4960 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004961 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004962
4963 if (context)
4964 {
4965 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004966
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004967 if (!shaderObject)
4968 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004969 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004970 }
4971
4972 switch (pname)
4973 {
4974 case GL_SHADER_TYPE:
4975 *params = shaderObject->getType();
4976 return;
4977 case GL_DELETE_STATUS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004978 *params = shaderObject->isFlaggedForDeletion();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004979 return;
4980 case GL_COMPILE_STATUS:
4981 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
4982 return;
4983 case GL_INFO_LOG_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004984 *params = shaderObject->getInfoLogLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004985 return;
4986 case GL_SHADER_SOURCE_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004987 *params = shaderObject->getSourceLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004988 return;
zmo@google.coma574f782011-10-03 21:45:23 +00004989 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
4990 *params = shaderObject->getTranslatedSourceLength();
4991 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004992 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004993 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004994 }
4995 }
4996 }
4997 catch(std::bad_alloc&)
4998 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004999 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005000 }
5001}
5002
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005003void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005004{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005005 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 +00005006 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005007
5008 try
5009 {
5010 if (bufsize < 0)
5011 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005012 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005013 }
5014
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005015 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005016
5017 if (context)
5018 {
5019 gl::Shader *shaderObject = context->getShader(shader);
5020
5021 if (!shaderObject)
5022 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005023 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005024 }
5025
5026 shaderObject->getInfoLog(bufsize, length, infolog);
5027 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005028 }
5029 catch(std::bad_alloc&)
5030 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005031 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005032 }
5033}
5034
5035void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
5036{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005037 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 +00005038 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005039
5040 try
5041 {
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005042 switch (shadertype)
5043 {
5044 case GL_VERTEX_SHADER:
5045 case GL_FRAGMENT_SHADER:
5046 break;
5047 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005048 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005049 }
5050
5051 switch (precisiontype)
5052 {
5053 case GL_LOW_FLOAT:
5054 case GL_MEDIUM_FLOAT:
5055 case GL_HIGH_FLOAT:
5056 // Assume IEEE 754 precision
5057 range[0] = 127;
5058 range[1] = 127;
daniel@transgaming.comc5c15382010-04-23 18:34:49 +00005059 *precision = 23;
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005060 break;
5061 case GL_LOW_INT:
5062 case GL_MEDIUM_INT:
5063 case GL_HIGH_INT:
5064 // Some (most) hardware only supports single-precision floating-point numbers,
5065 // which can accurately represent integers up to +/-16777216
5066 range[0] = 24;
5067 range[1] = 24;
daniel@transgaming.comc5c15382010-04-23 18:34:49 +00005068 *precision = 0;
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005069 break;
5070 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005071 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005072 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005073 }
5074 catch(std::bad_alloc&)
5075 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005076 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005077 }
5078}
5079
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005080void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005081{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005082 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 +00005083 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005084
5085 try
5086 {
5087 if (bufsize < 0)
5088 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005089 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005090 }
5091
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005092 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005093
5094 if (context)
5095 {
5096 gl::Shader *shaderObject = context->getShader(shader);
5097
5098 if (!shaderObject)
5099 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005100 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005101 }
5102
5103 shaderObject->getSource(bufsize, length, source);
5104 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005105 }
5106 catch(std::bad_alloc&)
5107 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005108 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005109 }
5110}
5111
zmo@google.coma574f782011-10-03 21:45:23 +00005112void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
5113{
5114 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
5115 shader, bufsize, length, source);
5116
5117 try
5118 {
5119 if (bufsize < 0)
5120 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005121 return gl::error(GL_INVALID_VALUE);
zmo@google.coma574f782011-10-03 21:45:23 +00005122 }
5123
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005124 gl::Context *context = gl::getNonLostContext();
zmo@google.coma574f782011-10-03 21:45:23 +00005125
5126 if (context)
5127 {
5128 gl::Shader *shaderObject = context->getShader(shader);
5129
5130 if (!shaderObject)
5131 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005132 return gl::error(GL_INVALID_OPERATION);
zmo@google.coma574f782011-10-03 21:45:23 +00005133 }
5134
5135 shaderObject->getTranslatedSource(bufsize, length, source);
5136 }
5137 }
5138 catch(std::bad_alloc&)
5139 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005140 return gl::error(GL_OUT_OF_MEMORY);
zmo@google.coma574f782011-10-03 21:45:23 +00005141 }
5142}
5143
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005144const GLubyte* __stdcall glGetString(GLenum name)
5145{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005146 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005147
5148 try
5149 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005150 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00005151
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005152 switch (name)
5153 {
5154 case GL_VENDOR:
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +00005155 return (GLubyte*)"Google Inc.";
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005156 case GL_RENDERER:
daniel@transgaming.comc23ff642011-08-16 20:28:45 +00005157 return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005158 case GL_VERSION:
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00005159 if (context->getClientVersion() == 2)
5160 {
5161 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")";
5162 }
5163 else
5164 {
5165 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")";
5166 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005167 case GL_SHADING_LANGUAGE_VERSION:
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00005168 if (context->getClientVersion() == 2)
5169 {
5170 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")";
5171 }
5172 else
5173 {
5174 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")";
5175 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005176 case GL_EXTENSIONS:
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00005177 return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : "");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005178 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005179 return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005180 }
5181 }
5182 catch(std::bad_alloc&)
5183 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005184 return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005185 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005186}
5187
5188void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
5189{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005190 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 +00005191
5192 try
5193 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005194 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005195
5196 if (context)
5197 {
5198 gl::Texture *texture;
5199
5200 switch (target)
5201 {
5202 case GL_TEXTURE_2D:
5203 texture = context->getTexture2D();
5204 break;
5205 case GL_TEXTURE_CUBE_MAP:
5206 texture = context->getTextureCubeMap();
5207 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00005208 case GL_TEXTURE_3D:
5209 if (context->getClientVersion() < 3)
5210 {
5211 return gl::error(GL_INVALID_ENUM);
5212 }
5213 texture = context->getTexture3D();
5214 break;
shannonwoods@chromium.org0c611d12013-05-30 00:15:05 +00005215 case GL_TEXTURE_2D_ARRAY:
5216 if (context->getClientVersion() < 3)
5217 {
5218 return gl::error(GL_INVALID_ENUM);
5219 }
5220 texture = context->getTexture2DArray();
5221 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005222 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005223 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005224 }
5225
5226 switch (pname)
5227 {
5228 case GL_TEXTURE_MAG_FILTER:
5229 *params = (GLfloat)texture->getMagFilter();
5230 break;
5231 case GL_TEXTURE_MIN_FILTER:
5232 *params = (GLfloat)texture->getMinFilter();
5233 break;
5234 case GL_TEXTURE_WRAP_S:
5235 *params = (GLfloat)texture->getWrapS();
5236 break;
5237 case GL_TEXTURE_WRAP_T:
5238 *params = (GLfloat)texture->getWrapT();
5239 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00005240 case GL_TEXTURE_WRAP_R:
5241 if (context->getClientVersion() < 3)
5242 {
5243 return gl::error(GL_INVALID_ENUM);
5244 }
5245 *params = (GLfloat)texture->getWrapR();
5246 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005247 case GL_TEXTURE_IMMUTABLE_FORMAT:
5248 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
daniel@transgaming.comd30bd0a2011-11-11 04:10:34 +00005249 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
5250 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005251 case GL_TEXTURE_IMMUTABLE_LEVELS:
5252 if (context->getClientVersion() < 3)
5253 {
5254 return gl::error(GL_INVALID_ENUM);
5255 }
5256 *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0);
5257 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00005258 case GL_TEXTURE_USAGE_ANGLE:
5259 *params = (GLfloat)texture->getUsage();
5260 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005261 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
5262 if (!context->supportsTextureFilterAnisotropy())
5263 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005264 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005265 }
5266 *params = (GLfloat)texture->getMaxAnisotropy();
5267 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005268 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005269 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005270 }
5271 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005272 }
5273 catch(std::bad_alloc&)
5274 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005275 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005276 }
5277}
5278
5279void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
5280{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005281 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 +00005282
5283 try
5284 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005285 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005286
5287 if (context)
5288 {
5289 gl::Texture *texture;
5290
5291 switch (target)
5292 {
5293 case GL_TEXTURE_2D:
5294 texture = context->getTexture2D();
5295 break;
5296 case GL_TEXTURE_CUBE_MAP:
5297 texture = context->getTextureCubeMap();
5298 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00005299 case GL_TEXTURE_3D:
5300 if (context->getClientVersion() < 3)
5301 {
5302 return gl::error(GL_INVALID_ENUM);
5303 }
5304 texture = context->getTexture3D();
5305 break;
shannonwoods@chromium.org0c611d12013-05-30 00:15:05 +00005306 case GL_TEXTURE_2D_ARRAY:
5307 if (context->getClientVersion() < 3)
5308 {
5309 return gl::error(GL_INVALID_ENUM);
5310 }
5311 texture = context->getTexture2DArray();
5312 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005313 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005314 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005315 }
5316
5317 switch (pname)
5318 {
5319 case GL_TEXTURE_MAG_FILTER:
5320 *params = texture->getMagFilter();
5321 break;
5322 case GL_TEXTURE_MIN_FILTER:
5323 *params = texture->getMinFilter();
5324 break;
5325 case GL_TEXTURE_WRAP_S:
5326 *params = texture->getWrapS();
5327 break;
5328 case GL_TEXTURE_WRAP_T:
5329 *params = texture->getWrapT();
5330 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00005331 case GL_TEXTURE_WRAP_R:
5332 if (context->getClientVersion() < 3)
5333 {
5334 return gl::error(GL_INVALID_ENUM);
5335 }
5336 *params = texture->getWrapR();
5337 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005338 case GL_TEXTURE_IMMUTABLE_FORMAT:
5339 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
daniel@transgaming.comd30bd0a2011-11-11 04:10:34 +00005340 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
5341 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005342 case GL_TEXTURE_IMMUTABLE_LEVELS:
5343 if (context->getClientVersion() < 3)
5344 {
5345 return gl::error(GL_INVALID_ENUM);
5346 }
5347 *params = texture->isImmutable() ? texture->levelCount() : 0;
5348 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00005349 case GL_TEXTURE_USAGE_ANGLE:
5350 *params = texture->getUsage();
5351 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005352 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
5353 if (!context->supportsTextureFilterAnisotropy())
5354 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005355 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005356 }
5357 *params = (GLint)texture->getMaxAnisotropy();
5358 break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00005359
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005360 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005361 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005362 }
5363 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005364 }
5365 catch(std::bad_alloc&)
5366 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005367 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005368 }
5369}
5370
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005371void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
5372{
5373 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
5374 program, location, bufSize, params);
5375
5376 try
5377 {
5378 if (bufSize < 0)
5379 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005380 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005381 }
5382
5383 gl::Context *context = gl::getNonLostContext();
5384
5385 if (context)
5386 {
5387 if (program == 0)
5388 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005389 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005390 }
5391
5392 gl::Program *programObject = context->getProgram(program);
5393
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005394 if (!programObject || !programObject->isLinked())
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005395 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005396 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005397 }
5398
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005399 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5400 if (!programBinary)
5401 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005402 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005403 }
5404
5405 if (!programBinary->getUniformfv(location, &bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005406 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005407 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005408 }
5409 }
5410 }
5411 catch(std::bad_alloc&)
5412 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005413 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005414 }
5415}
5416
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005417void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params)
5418{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005419 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005420
5421 try
5422 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005423 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005424
5425 if (context)
5426 {
5427 if (program == 0)
5428 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005429 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005430 }
5431
5432 gl::Program *programObject = context->getProgram(program);
5433
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005434 if (!programObject || !programObject->isLinked())
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005435 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005436 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005437 }
5438
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005439 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5440 if (!programBinary)
5441 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005442 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005443 }
5444
5445 if (!programBinary->getUniformfv(location, NULL, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005446 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005447 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005448 }
5449 }
5450 }
5451 catch(std::bad_alloc&)
5452 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005453 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005454 }
5455}
5456
5457void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
5458{
5459 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
5460 program, location, bufSize, params);
5461
5462 try
5463 {
5464 if (bufSize < 0)
5465 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005466 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005467 }
5468
5469 gl::Context *context = gl::getNonLostContext();
5470
5471 if (context)
5472 {
5473 if (program == 0)
5474 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005475 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005476 }
5477
5478 gl::Program *programObject = context->getProgram(program);
5479
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005480 if (!programObject || !programObject->isLinked())
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005481 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005482 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005483 }
5484
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005485 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5486 if (!programBinary)
5487 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005488 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005489 }
5490
5491 if (!programBinary->getUniformiv(location, &bufSize, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005492 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005493 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005494 }
5495 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005496 }
5497 catch(std::bad_alloc&)
5498 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005499 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005500 }
5501}
5502
5503void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params)
5504{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005505 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005506
5507 try
5508 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005509 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005510
5511 if (context)
5512 {
5513 if (program == 0)
5514 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005515 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005516 }
5517
5518 gl::Program *programObject = context->getProgram(program);
5519
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005520 if (!programObject || !programObject->isLinked())
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005521 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005522 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005523 }
5524
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005525 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5526 if (!programBinary)
5527 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005528 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005529 }
5530
5531 if (!programBinary->getUniformiv(location, NULL, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005532 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005533 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005534 }
5535 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005536 }
5537 catch(std::bad_alloc&)
5538 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005539 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005540 }
5541}
5542
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005543int __stdcall glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005544{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005545 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005546
5547 try
5548 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005549 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005550
5551 if (strstr(name, "gl_") == name)
5552 {
5553 return -1;
5554 }
5555
5556 if (context)
5557 {
5558 gl::Program *programObject = context->getProgram(program);
5559
5560 if (!programObject)
5561 {
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00005562 if (context->getShader(program))
5563 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005564 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00005565 }
5566 else
5567 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005568 return gl::error(GL_INVALID_VALUE, -1);
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00005569 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005570 }
5571
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005572 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005573 if (!programObject->isLinked() || !programBinary)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005574 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005575 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005576 }
5577
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005578 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005579 }
5580 }
5581 catch(std::bad_alloc&)
5582 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005583 return gl::error(GL_OUT_OF_MEMORY, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005584 }
5585
5586 return -1;
5587}
5588
5589void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
5590{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005591 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005592
5593 try
5594 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005595 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005596
daniel@transgaming.come0078962010-04-15 20:45:08 +00005597 if (context)
5598 {
5599 if (index >= gl::MAX_VERTEX_ATTRIBS)
5600 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005601 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005602 }
5603
daniel@transgaming.com83921382011-01-08 05:46:00 +00005604 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005605
daniel@transgaming.come0078962010-04-15 20:45:08 +00005606 switch (pname)
5607 {
5608 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
daniel@transgaming.com83921382011-01-08 05:46:00 +00005609 *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005610 break;
5611 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005612 *params = (GLfloat)attribState.mSize;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005613 break;
5614 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005615 *params = (GLfloat)attribState.mStride;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005616 break;
5617 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005618 *params = (GLfloat)attribState.mType;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005619 break;
5620 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005621 *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005622 break;
5623 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +00005624 *params = (GLfloat)attribState.mBoundBuffer.id();
daniel@transgaming.come0078962010-04-15 20:45:08 +00005625 break;
5626 case GL_CURRENT_VERTEX_ATTRIB:
5627 for (int i = 0; i < 4; ++i)
5628 {
shannon.woods%transgaming.com@gtempaccount.com3026dc72013-04-13 03:37:27 +00005629 params[i] = attribState.mCurrentValue.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00005630 }
5631 break;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00005632 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
5633 // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses
5634 // the same constant.
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005635 *params = (GLfloat)attribState.mDivisor;
5636 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005637 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005638 }
5639 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005640 }
5641 catch(std::bad_alloc&)
5642 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005643 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005644 }
5645}
5646
5647void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
5648{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005649 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005650
5651 try
5652 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005653 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005654
daniel@transgaming.come0078962010-04-15 20:45:08 +00005655 if (context)
5656 {
5657 if (index >= gl::MAX_VERTEX_ATTRIBS)
5658 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005659 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005660 }
5661
daniel@transgaming.com83921382011-01-08 05:46:00 +00005662 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005663
daniel@transgaming.come0078962010-04-15 20:45:08 +00005664 switch (pname)
5665 {
5666 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
daniel@transgaming.com83921382011-01-08 05:46:00 +00005667 *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005668 break;
5669 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005670 *params = attribState.mSize;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005671 break;
5672 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005673 *params = attribState.mStride;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005674 break;
5675 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005676 *params = attribState.mType;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005677 break;
5678 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005679 *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005680 break;
5681 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +00005682 *params = attribState.mBoundBuffer.id();
daniel@transgaming.come0078962010-04-15 20:45:08 +00005683 break;
5684 case GL_CURRENT_VERTEX_ATTRIB:
5685 for (int i = 0; i < 4; ++i)
5686 {
shannon.woods%transgaming.com@gtempaccount.com3026dc72013-04-13 03:37:27 +00005687 float currentValue = attribState.mCurrentValue.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00005688 params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f));
5689 }
5690 break;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00005691 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
5692 // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses
5693 // the same constant.
5694 META_ASSERT(GL_VERTEX_ATTRIB_ARRAY_DIVISOR == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005695 *params = (GLint)attribState.mDivisor;
5696 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005697 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005698 }
5699 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005700 }
5701 catch(std::bad_alloc&)
5702 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005703 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005704 }
5705}
5706
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005707void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005708{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005709 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005710
5711 try
5712 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005713 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005714
daniel@transgaming.come0078962010-04-15 20:45:08 +00005715 if (context)
5716 {
5717 if (index >= gl::MAX_VERTEX_ATTRIBS)
5718 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005719 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005720 }
5721
5722 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
5723 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005724 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005725 }
5726
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005727 *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index));
daniel@transgaming.come0078962010-04-15 20:45:08 +00005728 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005729 }
5730 catch(std::bad_alloc&)
5731 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005732 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005733 }
5734}
5735
5736void __stdcall glHint(GLenum target, GLenum mode)
5737{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005738 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005739
5740 try
5741 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005742 switch (mode)
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005743 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005744 case GL_FASTEST:
5745 case GL_NICEST:
5746 case GL_DONT_CARE:
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005747 break;
5748 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005749 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005750 }
5751
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005752 gl::Context *context = gl::getNonLostContext();
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005753 switch (target)
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005754 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005755 case GL_GENERATE_MIPMAP_HINT:
5756 if (context) context->setGenerateMipmapHint(mode);
5757 break;
5758 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
5759 if (context) context->setFragmentShaderDerivativeHint(mode);
5760 break;
5761 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005762 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005763 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005764 }
5765 catch(std::bad_alloc&)
5766 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005767 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005768 }
5769}
5770
5771GLboolean __stdcall glIsBuffer(GLuint buffer)
5772{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005773 EVENT("(GLuint buffer = %d)", buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005774
5775 try
5776 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005777 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005778
5779 if (context && buffer)
5780 {
5781 gl::Buffer *bufferObject = context->getBuffer(buffer);
5782
5783 if (bufferObject)
5784 {
5785 return GL_TRUE;
5786 }
5787 }
5788 }
5789 catch(std::bad_alloc&)
5790 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005791 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005792 }
5793
5794 return GL_FALSE;
5795}
5796
5797GLboolean __stdcall glIsEnabled(GLenum cap)
5798{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005799 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005800
5801 try
5802 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005803 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005804
5805 if (context)
5806 {
5807 switch (cap)
5808 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005809 case GL_CULL_FACE: return context->isCullFaceEnabled();
5810 case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled();
5811 case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled();
5812 case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled();
5813 case GL_SCISSOR_TEST: return context->isScissorTestEnabled();
5814 case GL_STENCIL_TEST: return context->isStencilTestEnabled();
5815 case GL_DEPTH_TEST: return context->isDepthTestEnabled();
5816 case GL_BLEND: return context->isBlendEnabled();
5817 case GL_DITHER: return context->isDitherEnabled();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005818 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005819 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005820 }
5821 }
5822 }
5823 catch(std::bad_alloc&)
5824 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005825 return gl::error(GL_OUT_OF_MEMORY, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005826 }
5827
5828 return false;
5829}
5830
daniel@transgaming.comfe208882010-09-01 15:47:57 +00005831GLboolean __stdcall glIsFenceNV(GLuint fence)
5832{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005833 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00005834
5835 try
5836 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005837 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00005838
5839 if (context)
5840 {
5841 gl::Fence *fenceObject = context->getFence(fence);
5842
5843 if (fenceObject == NULL)
5844 {
5845 return GL_FALSE;
5846 }
5847
5848 return fenceObject->isFence();
5849 }
5850 }
5851 catch(std::bad_alloc&)
5852 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005853 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00005854 }
5855
5856 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00005857}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00005858
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005859GLboolean __stdcall glIsFramebuffer(GLuint framebuffer)
5860{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005861 EVENT("(GLuint framebuffer = %d)", framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005862
5863 try
5864 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005865 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005866
5867 if (context && framebuffer)
5868 {
5869 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
5870
5871 if (framebufferObject)
5872 {
5873 return GL_TRUE;
5874 }
5875 }
5876 }
5877 catch(std::bad_alloc&)
5878 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005879 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005880 }
5881
5882 return GL_FALSE;
5883}
5884
5885GLboolean __stdcall glIsProgram(GLuint program)
5886{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005887 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005888
5889 try
5890 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005891 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005892
5893 if (context && program)
5894 {
5895 gl::Program *programObject = context->getProgram(program);
5896
5897 if (programObject)
5898 {
5899 return GL_TRUE;
5900 }
5901 }
5902 }
5903 catch(std::bad_alloc&)
5904 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005905 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005906 }
5907
5908 return GL_FALSE;
5909}
5910
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00005911GLboolean __stdcall glIsQueryEXT(GLuint id)
5912{
5913 EVENT("(GLuint id = %d)", id);
5914
5915 try
5916 {
5917 if (id == 0)
5918 {
5919 return GL_FALSE;
5920 }
5921
5922 gl::Context *context = gl::getNonLostContext();
5923
5924 if (context)
5925 {
5926 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
5927
5928 if (queryObject)
5929 {
5930 return GL_TRUE;
5931 }
5932 }
5933 }
5934 catch(std::bad_alloc&)
5935 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005936 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00005937 }
5938
5939 return GL_FALSE;
5940}
5941
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005942GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer)
5943{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005944 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005945
5946 try
5947 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005948 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005949
5950 if (context && renderbuffer)
5951 {
5952 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
5953
5954 if (renderbufferObject)
5955 {
5956 return GL_TRUE;
5957 }
5958 }
5959 }
5960 catch(std::bad_alloc&)
5961 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005962 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005963 }
5964
5965 return GL_FALSE;
5966}
5967
5968GLboolean __stdcall glIsShader(GLuint shader)
5969{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005970 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005971
5972 try
5973 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005974 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005975
5976 if (context && shader)
5977 {
5978 gl::Shader *shaderObject = context->getShader(shader);
5979
5980 if (shaderObject)
5981 {
5982 return GL_TRUE;
5983 }
5984 }
5985 }
5986 catch(std::bad_alloc&)
5987 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005988 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005989 }
5990
5991 return GL_FALSE;
5992}
5993
5994GLboolean __stdcall glIsTexture(GLuint texture)
5995{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005996 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005997
5998 try
5999 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006000 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006001
6002 if (context && texture)
6003 {
6004 gl::Texture *textureObject = context->getTexture(texture);
6005
6006 if (textureObject)
6007 {
6008 return GL_TRUE;
6009 }
6010 }
6011 }
6012 catch(std::bad_alloc&)
6013 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006014 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006015 }
6016
6017 return GL_FALSE;
6018}
6019
6020void __stdcall glLineWidth(GLfloat width)
6021{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006022 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006023
6024 try
6025 {
6026 if (width <= 0.0f)
6027 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006028 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006029 }
6030
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006031 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00006032
6033 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006034 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006035 context->setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006036 }
6037 }
6038 catch(std::bad_alloc&)
6039 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006040 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006041 }
6042}
6043
6044void __stdcall glLinkProgram(GLuint program)
6045{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006046 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006047
6048 try
6049 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006050 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006051
6052 if (context)
6053 {
6054 gl::Program *programObject = context->getProgram(program);
6055
6056 if (!programObject)
6057 {
daniel@transgaming.com277b7142010-04-13 03:26:44 +00006058 if (context->getShader(program))
6059 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006060 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com277b7142010-04-13 03:26:44 +00006061 }
6062 else
6063 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006064 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com277b7142010-04-13 03:26:44 +00006065 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006066 }
6067
daniel@transgaming.com95d29422012-07-24 18:36:10 +00006068 context->linkProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006069 }
6070 }
6071 catch(std::bad_alloc&)
6072 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006073 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006074 }
6075}
6076
6077void __stdcall glPixelStorei(GLenum pname, GLint param)
6078{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006079 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006080
6081 try
6082 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006083 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006084
6085 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006086 {
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006087 switch (pname)
6088 {
6089 case GL_UNPACK_ALIGNMENT:
6090 if (param != 1 && param != 2 && param != 4 && param != 8)
6091 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006092 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006093 }
6094
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006095 context->setUnpackAlignment(param);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006096 break;
6097
6098 case GL_PACK_ALIGNMENT:
6099 if (param != 1 && param != 2 && param != 4 && param != 8)
6100 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006101 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006102 }
6103
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006104 context->setPackAlignment(param);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006105 break;
6106
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00006107 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
6108 context->setPackReverseRowOrder(param != 0);
6109 break;
6110
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00006111 case GL_UNPACK_IMAGE_HEIGHT:
6112 case GL_UNPACK_SKIP_IMAGES:
6113 case GL_UNPACK_ROW_LENGTH:
6114 case GL_UNPACK_SKIP_ROWS:
6115 case GL_UNPACK_SKIP_PIXELS:
6116 case GL_PACK_ROW_LENGTH:
6117 case GL_PACK_SKIP_ROWS:
6118 case GL_PACK_SKIP_PIXELS:
6119 if (context->getClientVersion() < 3)
6120 {
6121 return gl::error(GL_INVALID_ENUM);
6122 }
6123 UNIMPLEMENTED();
6124 break;
6125
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006126 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006127 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006128 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006129 }
6130 }
6131 catch(std::bad_alloc&)
6132 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006133 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006134 }
6135}
6136
6137void __stdcall glPolygonOffset(GLfloat factor, GLfloat units)
6138{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006139 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006140
6141 try
6142 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006143 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comaede6302010-04-29 03:35:48 +00006144
6145 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006146 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006147 context->setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006148 }
6149 }
6150 catch(std::bad_alloc&)
6151 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006152 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006153 }
6154}
6155
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006156void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
6157 GLenum format, GLenum type, GLsizei bufSize,
6158 GLvoid *data)
6159{
6160 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
6161 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
6162 x, y, width, height, format, type, bufSize, data);
6163
6164 try
6165 {
6166 if (width < 0 || height < 0 || bufSize < 0)
6167 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006168 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006169 }
6170
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006171 gl::Context *context = gl::getNonLostContext();
6172
6173 if (context)
6174 {
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006175 GLint currentInternalFormat;
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006176 GLenum currentFormat, currentType;
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006177
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006178 // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound,
6179 // and attempting to read back if that's the case is an error. The error will be registered
6180 // by getCurrentReadFormat.
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006181 if (!context->getCurrentReadFormatType(&currentInternalFormat, &currentFormat, &currentType))
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006182 return;
6183
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006184 bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) :
6185 validES3ReadFormatType(currentInternalFormat, format, type);
6186
6187 if (!(currentFormat == format && currentType == type) && !validReadFormat)
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006188 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006189 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006190 }
6191
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006192 context->readPixels(x, y, width, height, format, type, &bufSize, data);
6193 }
6194 }
6195 catch(std::bad_alloc&)
6196 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006197 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006198 }
6199}
6200
6201void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
6202 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006203{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006204 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006205 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00006206 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006207
6208 try
6209 {
6210 if (width < 0 || height < 0)
6211 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006212 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006213 }
6214
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006215 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006216
6217 if (context)
6218 {
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006219 GLint currentInternalFormat;
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006220 GLenum currentFormat, currentType;
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006221
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006222 // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound,
6223 // and attempting to read back if that's the case is an error. The error will be registered
6224 // by getCurrentReadFormat.
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006225 if (!context->getCurrentReadFormatType(&currentInternalFormat, &currentFormat, &currentType))
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006226 return;
6227
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006228 bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) :
6229 validES3ReadFormatType(currentInternalFormat, format, type);
6230
6231 if (!(currentFormat == format && currentType == type) && !validReadFormat)
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006232 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006233 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006234 }
6235
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006236 context->readPixels(x, y, width, height, format, type, NULL, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006237 }
6238 }
6239 catch(std::bad_alloc&)
6240 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006241 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006242 }
6243}
6244
6245void __stdcall glReleaseShaderCompiler(void)
6246{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006247 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006248
6249 try
6250 {
6251 gl::Shader::releaseCompiler();
6252 }
6253 catch(std::bad_alloc&)
6254 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006255 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006256 }
6257}
6258
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00006259void __stdcall glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006260{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006261 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 +00006262 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006263
6264 try
6265 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006266 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006267
6268 if (context)
6269 {
Geoff Lang2e1dcd52013-05-29 10:34:08 -04006270 if (!validateRenderbufferStorageParameters(context, target, samples, internalformat,
6271 width, height, true))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006272 {
Geoff Lang2e1dcd52013-05-29 10:34:08 -04006273 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006274 }
shannon.woods%transgaming.com@gtempaccount.com8dce6512013-04-13 03:42:19 +00006275
6276 context->setRenderbufferStorage(width, height, internalformat, samples);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006277 }
6278 }
6279 catch(std::bad_alloc&)
6280 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006281 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006282 }
6283}
6284
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00006285void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
6286{
6287 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
6288}
6289
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006290void __stdcall glSampleCoverage(GLclampf value, GLboolean invert)
6291{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006292 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006293
6294 try
6295 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006296 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006297
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006298 if (context)
6299 {
daniel@transgaming.coma36f98e2010-05-18 18:51:09 +00006300 context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006301 }
6302 }
6303 catch(std::bad_alloc&)
6304 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006305 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006306 }
6307}
6308
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006309void __stdcall glSetFenceNV(GLuint fence, GLenum condition)
6310{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006311 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006312
6313 try
6314 {
6315 if (condition != GL_ALL_COMPLETED_NV)
6316 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006317 return gl::error(GL_INVALID_ENUM);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006318 }
6319
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006320 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006321
6322 if (context)
6323 {
6324 gl::Fence *fenceObject = context->getFence(fence);
6325
6326 if (fenceObject == NULL)
6327 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006328 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006329 }
6330
6331 fenceObject->setFence(condition);
6332 }
6333 }
6334 catch(std::bad_alloc&)
6335 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006336 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006337 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006338}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006339
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006340void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
6341{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006342 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 +00006343
6344 try
6345 {
6346 if (width < 0 || height < 0)
6347 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006348 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006349 }
6350
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006351 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006352
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006353 if (context)
6354 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006355 context->setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006356 }
6357 }
6358 catch(std::bad_alloc&)
6359 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006360 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006361 }
6362}
6363
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006364void __stdcall glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006365{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006366 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006367 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00006368 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006369
6370 try
6371 {
daniel@transgaming.comd1f667f2010-04-29 03:38:52 +00006372 // No binary shader formats are supported.
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006373 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006374 }
6375 catch(std::bad_alloc&)
6376 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006377 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006378 }
6379}
6380
shannon.woods%transgaming.com@gtempaccount.com5f339332013-04-13 03:29:02 +00006381void __stdcall glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006382{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006383 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 +00006384 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006385
6386 try
6387 {
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006388 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006389 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006390 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006391 }
6392
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006393 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006394
6395 if (context)
6396 {
6397 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006398
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006399 if (!shaderObject)
6400 {
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006401 if (context->getProgram(shader))
6402 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006403 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006404 }
6405 else
6406 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006407 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006408 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006409 }
6410
6411 shaderObject->setSource(count, string, length);
6412 }
6413 }
6414 catch(std::bad_alloc&)
6415 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006416 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006417 }
6418}
6419
6420void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask)
6421{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006422 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006423}
6424
6425void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
6426{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006427 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 +00006428
6429 try
6430 {
6431 switch (face)
6432 {
6433 case GL_FRONT:
6434 case GL_BACK:
6435 case GL_FRONT_AND_BACK:
6436 break;
6437 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006438 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006439 }
6440
6441 switch (func)
6442 {
6443 case GL_NEVER:
6444 case GL_ALWAYS:
6445 case GL_LESS:
6446 case GL_LEQUAL:
6447 case GL_EQUAL:
6448 case GL_GEQUAL:
6449 case GL_GREATER:
6450 case GL_NOTEQUAL:
6451 break;
6452 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006453 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006454 }
6455
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006456 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006457
6458 if (context)
6459 {
6460 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
6461 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006462 context->setStencilParams(func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006463 }
6464
6465 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
6466 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006467 context->setStencilBackParams(func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006468 }
6469 }
6470 }
6471 catch(std::bad_alloc&)
6472 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006473 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006474 }
6475}
6476
6477void __stdcall glStencilMask(GLuint mask)
6478{
6479 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
6480}
6481
6482void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask)
6483{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006484 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006485
6486 try
6487 {
6488 switch (face)
6489 {
6490 case GL_FRONT:
6491 case GL_BACK:
6492 case GL_FRONT_AND_BACK:
6493 break;
6494 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006495 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006496 }
6497
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006498 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006499
6500 if (context)
6501 {
6502 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
6503 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006504 context->setStencilWritemask(mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006505 }
6506
6507 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
6508 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006509 context->setStencilBackWritemask(mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006510 }
6511 }
6512 }
6513 catch(std::bad_alloc&)
6514 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006515 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006516 }
6517}
6518
6519void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
6520{
6521 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
6522}
6523
6524void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
6525{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006526 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 +00006527 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006528
6529 try
6530 {
6531 switch (face)
6532 {
6533 case GL_FRONT:
6534 case GL_BACK:
6535 case GL_FRONT_AND_BACK:
6536 break;
6537 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006538 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006539 }
6540
6541 switch (fail)
6542 {
6543 case GL_ZERO:
6544 case GL_KEEP:
6545 case GL_REPLACE:
6546 case GL_INCR:
6547 case GL_DECR:
6548 case GL_INVERT:
6549 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006550 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006551 break;
6552 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006553 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006554 }
6555
6556 switch (zfail)
6557 {
6558 case GL_ZERO:
6559 case GL_KEEP:
6560 case GL_REPLACE:
6561 case GL_INCR:
6562 case GL_DECR:
6563 case GL_INVERT:
6564 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006565 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006566 break;
6567 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006568 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006569 }
6570
6571 switch (zpass)
6572 {
6573 case GL_ZERO:
6574 case GL_KEEP:
6575 case GL_REPLACE:
6576 case GL_INCR:
6577 case GL_DECR:
6578 case GL_INVERT:
6579 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006580 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006581 break;
6582 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006583 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006584 }
6585
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006586 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006587
6588 if (context)
6589 {
6590 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
6591 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006592 context->setStencilOperations(fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006593 }
6594
6595 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
6596 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006597 context->setStencilBackOperations(fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006598 }
6599 }
6600 }
6601 catch(std::bad_alloc&)
6602 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006603 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006604 }
6605}
6606
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006607GLboolean __stdcall glTestFenceNV(GLuint fence)
6608{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006609 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006610
6611 try
6612 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006613 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006614
6615 if (context)
6616 {
6617 gl::Fence *fenceObject = context->getFence(fence);
6618
6619 if (fenceObject == NULL)
6620 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006621 return gl::error(GL_INVALID_OPERATION, GL_TRUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006622 }
6623
6624 return fenceObject->testFence();
6625 }
6626 }
6627 catch(std::bad_alloc&)
6628 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006629 gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006630 }
6631
6632 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006633}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006634
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006635void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
6636 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006637{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006638 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 +00006639 "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 +00006640 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006641
6642 try
6643 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006644 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006645
6646 if (context)
6647 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006648 if (context->getClientVersion() < 3 &&
6649 !validateES2TexImageParameters(context, target, level, internalformat, false, false,
6650 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com32b11442011-11-19 02:42:48 +00006651 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006652 return;
6653 }
6654
6655 if (context->getClientVersion() >= 3 &&
6656 !validateES3TexImageParameters(context, target, level, internalformat, false, false,
6657 0, 0, 0, width, height, 1, border, format, type))
6658 {
6659 return;
daniel@transgaming.com32b11442011-11-19 02:42:48 +00006660 }
6661
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006662 switch (target)
6663 {
6664 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006665 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006666 gl::Texture2D *texture = context->getTexture2D();
6667 texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006668 }
6669 break;
6670 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006671 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006672 gl::TextureCubeMap *texture = context->getTextureCubeMap();
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +00006673 texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006674 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006675 break;
6676 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
6677 {
6678 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6679 texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6680 }
6681 break;
6682 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
6683 {
6684 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6685 texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6686 }
6687 break;
6688 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
6689 {
6690 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6691 texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6692 }
6693 break;
6694 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
6695 {
6696 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6697 texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6698 }
6699 break;
6700 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
6701 {
6702 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6703 texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6704 }
6705 break;
6706 default: UNREACHABLE();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006707 }
6708 }
6709 }
6710 catch(std::bad_alloc&)
6711 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006712 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006713 }
6714}
6715
6716void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param)
6717{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006718 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
6719
6720 try
6721 {
6722 gl::Context *context = gl::getNonLostContext();
6723
6724 if (context)
6725 {
6726 gl::Texture *texture;
6727
6728 switch (target)
6729 {
6730 case GL_TEXTURE_2D:
6731 texture = context->getTexture2D();
6732 break;
6733 case GL_TEXTURE_CUBE_MAP:
6734 texture = context->getTextureCubeMap();
6735 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00006736 case GL_TEXTURE_3D:
6737 if (context->getClientVersion() < 3)
6738 {
6739 return gl::error(GL_INVALID_ENUM);
6740 }
6741 texture = context->getTexture3D();
shannon.woods%transgaming.com@gtempaccount.com90dbc442013-04-13 03:46:14 +00006742 case GL_TEXTURE_2D_ARRAY:
6743 if (context->getClientVersion() < 3)
6744 {
6745 return gl::error(GL_INVALID_ENUM);
6746 }
6747 texture = context->getTexture2DArray();
6748 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006749 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006750 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006751 }
6752
6753 switch (pname)
6754 {
6755 case GL_TEXTURE_WRAP_S:
6756 if (!texture->setWrapS((GLenum)param))
6757 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006758 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006759 }
6760 break;
6761 case GL_TEXTURE_WRAP_T:
6762 if (!texture->setWrapT((GLenum)param))
6763 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006764 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006765 }
6766 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00006767 case GL_TEXTURE_WRAP_R:
6768 if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param))
6769 {
6770 return gl::error(GL_INVALID_ENUM);
6771 }
6772 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006773 case GL_TEXTURE_MIN_FILTER:
6774 if (!texture->setMinFilter((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;
6779 case GL_TEXTURE_MAG_FILTER:
6780 if (!texture->setMagFilter((GLenum)param))
6781 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006782 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006783 }
6784 break;
6785 case GL_TEXTURE_USAGE_ANGLE:
6786 if (!texture->setUsage((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_MAX_ANISOTROPY_EXT:
6792 if (!context->supportsTextureFilterAnisotropy())
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 if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()))
6797 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006798 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006799 }
6800 break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00006801
6802 case GL_TEXTURE_MIN_LOD:
6803 case GL_TEXTURE_MAX_LOD:
6804 if (context->getClientVersion() < 3)
6805 {
6806 return gl::error(GL_INVALID_ENUM);
6807 }
6808 UNIMPLEMENTED();
6809 break;
6810
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006811 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006812 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006813 }
6814 }
6815 }
6816 catch(std::bad_alloc&)
6817 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006818 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006819 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006820}
6821
6822void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
6823{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006824 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006825}
6826
6827void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param)
6828{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006829 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006830
6831 try
6832 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006833 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006834
6835 if (context)
6836 {
6837 gl::Texture *texture;
6838
6839 switch (target)
6840 {
6841 case GL_TEXTURE_2D:
6842 texture = context->getTexture2D();
6843 break;
6844 case GL_TEXTURE_CUBE_MAP:
6845 texture = context->getTextureCubeMap();
6846 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00006847 case GL_TEXTURE_3D:
6848 if (context->getClientVersion() < 3)
6849 {
6850 return gl::error(GL_INVALID_ENUM);
6851 }
6852 texture = context->getTexture3D();
6853 break;
shannon.woods%transgaming.com@gtempaccount.com90dbc442013-04-13 03:46:14 +00006854 case GL_TEXTURE_2D_ARRAY:
6855 if (context->getClientVersion() < 3)
6856 {
6857 return gl::error(GL_INVALID_ENUM);
6858 }
6859 texture = context->getTexture2DArray();
6860 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006861 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006862 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006863 }
6864
6865 switch (pname)
6866 {
6867 case GL_TEXTURE_WRAP_S:
6868 if (!texture->setWrapS((GLenum)param))
6869 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006870 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006871 }
6872 break;
6873 case GL_TEXTURE_WRAP_T:
6874 if (!texture->setWrapT((GLenum)param))
6875 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006876 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006877 }
6878 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00006879 case GL_TEXTURE_WRAP_R:
6880 if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param))
6881 {
6882 return gl::error(GL_INVALID_ENUM);
6883 }
6884 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006885 case GL_TEXTURE_MIN_FILTER:
6886 if (!texture->setMinFilter((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;
6891 case GL_TEXTURE_MAG_FILTER:
6892 if (!texture->setMagFilter((GLenum)param))
6893 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006894 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006895 }
6896 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00006897 case GL_TEXTURE_USAGE_ANGLE:
6898 if (!texture->setUsage((GLenum)param))
6899 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006900 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00006901 }
6902 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006903 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
6904 if (!context->supportsTextureFilterAnisotropy())
6905 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006906 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006907 }
6908 if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()))
6909 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006910 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006911 }
6912 break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00006913
6914 case GL_TEXTURE_SWIZZLE_R:
6915 case GL_TEXTURE_SWIZZLE_G:
6916 case GL_TEXTURE_SWIZZLE_B:
6917 case GL_TEXTURE_SWIZZLE_A:
6918 case GL_TEXTURE_BASE_LEVEL:
6919 case GL_TEXTURE_MAX_LEVEL:
6920 case GL_TEXTURE_COMPARE_MODE:
6921 case GL_TEXTURE_COMPARE_FUNC:
6922 if (context->getClientVersion() < 3)
6923 {
6924 return gl::error(GL_INVALID_ENUM);
6925 }
6926 UNIMPLEMENTED();
6927 break;
6928
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006929 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006930 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006931 }
6932 }
6933 }
6934 catch(std::bad_alloc&)
6935 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006936 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006937 }
6938}
6939
6940void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
6941{
6942 glTexParameteri(target, pname, *params);
6943}
6944
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00006945void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
6946{
6947 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
6948 target, levels, internalformat, width, height);
6949
6950 try
6951 {
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00006952 gl::Context *context = gl::getNonLostContext();
6953
6954 if (context)
6955 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006956 if (context->getClientVersion() < 3 &&
6957 !validateES2TexStorageParameters(context, target, levels, internalformat, width, height))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006958 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006959 return;
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006960 }
6961
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006962 if (context->getClientVersion() >= 3 &&
6963 !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006964 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006965 return;
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006966 }
6967
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006968 switch (target)
6969 {
6970 case GL_TEXTURE_2D:
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006971 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006972 gl::Texture2D *texture2d = context->getTexture2D();
6973 texture2d->storage(levels, internalformat, width, height);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006974 }
6975 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006976
6977 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
6978 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
6979 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
6980 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
6981 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
6982 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006983 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006984 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
6985 textureCube->storage(levels, internalformat, width);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006986 }
6987 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006988
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006989 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006990 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006991 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00006992 }
6993 }
6994 catch(std::bad_alloc&)
6995 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006996 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00006997 }
6998}
6999
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00007000void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
7001 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007002{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007003 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007004 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00007005 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007006 target, level, xoffset, yoffset, width, height, format, type, pixels);
7007
7008 try
7009 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007010 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007011
7012 if (context)
7013 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007014 if (context->getClientVersion() < 3 &&
7015 !validateES2TexImageParameters(context, target, level, GL_NONE, false, true,
7016 0, 0, width, height, 0, format, type, pixels))
daniel@transgaming.com1d2d3c42012-05-31 01:14:15 +00007017 {
7018 return;
7019 }
7020
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007021 if (context->getClientVersion() >= 3 &&
7022 !validateES3TexImageParameters(context, target, level, GL_NONE, false, true,
7023 0, 0, 0, width, height, 1, 0, format, type))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007024 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007025 return;
7026 }
7027
7028 switch (target)
7029 {
7030 case GL_TEXTURE_2D:
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007031 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007032 gl::Texture2D *texture = context->getTexture2D();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00007033 texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007034 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007035 break;
7036
7037 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
7038 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
7039 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
7040 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
7041 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
7042 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007043 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007044 gl::TextureCubeMap *texture = context->getTextureCubeMap();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00007045 texture->subImage(target, 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 default:
7050 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007051 }
7052 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007053 }
7054 catch(std::bad_alloc&)
7055 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007056 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007057 }
7058}
7059
7060void __stdcall glUniform1f(GLint location, GLfloat x)
7061{
7062 glUniform1fv(location, 1, &x);
7063}
7064
7065void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
7066{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007067 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007068
7069 try
7070 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007071 if (count < 0)
7072 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007073 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007074 }
7075
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007076 if (location == -1)
7077 {
7078 return;
7079 }
7080
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007081 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007082
7083 if (context)
7084 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007085 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007086 if (!programBinary)
7087 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007088 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007089 }
7090
7091 if (!programBinary->setUniform1fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007092 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007093 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007094 }
7095 }
7096 }
7097 catch(std::bad_alloc&)
7098 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007099 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007100 }
7101}
7102
7103void __stdcall glUniform1i(GLint location, GLint x)
7104{
7105 glUniform1iv(location, 1, &x);
7106}
7107
7108void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v)
7109{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007110 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007111
7112 try
7113 {
7114 if (count < 0)
7115 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007116 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007117 }
7118
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007119 if (location == -1)
7120 {
7121 return;
7122 }
7123
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007124 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007125
7126 if (context)
7127 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007128 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007129 if (!programBinary)
7130 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007131 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007132 }
7133
7134 if (!programBinary->setUniform1iv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007135 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007136 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007137 }
7138 }
7139 }
7140 catch(std::bad_alloc&)
7141 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007142 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007143 }
7144}
7145
7146void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y)
7147{
7148 GLfloat xy[2] = {x, y};
7149
7150 glUniform2fv(location, 1, (GLfloat*)&xy);
7151}
7152
7153void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
7154{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007155 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007156
7157 try
7158 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007159 if (count < 0)
7160 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007161 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007162 }
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007163
7164 if (location == -1)
7165 {
7166 return;
7167 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007168
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007169 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007170
7171 if (context)
7172 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007173 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007174 if (!programBinary)
7175 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007176 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007177 }
7178
7179 if (!programBinary->setUniform2fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007180 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007181 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007182 }
7183 }
7184 }
7185 catch(std::bad_alloc&)
7186 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007187 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007188 }
7189}
7190
7191void __stdcall glUniform2i(GLint location, GLint x, GLint y)
7192{
7193 GLint xy[4] = {x, y};
7194
7195 glUniform2iv(location, 1, (GLint*)&xy);
7196}
7197
7198void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v)
7199{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007200 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007201
7202 try
7203 {
7204 if (count < 0)
7205 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007206 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007207 }
7208
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007209 if (location == -1)
7210 {
7211 return;
7212 }
7213
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007214 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007215
7216 if (context)
7217 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007218 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007219 if (!programBinary)
7220 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007221 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007222 }
7223
7224 if (!programBinary->setUniform2iv(location, count, v))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007225 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007226 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007227 }
7228 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007229 }
7230 catch(std::bad_alloc&)
7231 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007232 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007233 }
7234}
7235
7236void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
7237{
7238 GLfloat xyz[3] = {x, y, z};
7239
7240 glUniform3fv(location, 1, (GLfloat*)&xyz);
7241}
7242
7243void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
7244{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007245 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007246
7247 try
7248 {
7249 if (count < 0)
7250 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007251 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007252 }
7253
7254 if (location == -1)
7255 {
7256 return;
7257 }
7258
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007259 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007260
7261 if (context)
7262 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007263 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007264 if (!programBinary)
7265 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007266 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007267 }
7268
7269 if (!programBinary->setUniform3fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007270 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007271 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007272 }
7273 }
7274 }
7275 catch(std::bad_alloc&)
7276 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007277 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007278 }
7279}
7280
7281void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z)
7282{
7283 GLint xyz[3] = {x, y, z};
7284
7285 glUniform3iv(location, 1, (GLint*)&xyz);
7286}
7287
7288void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v)
7289{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007290 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007291
7292 try
7293 {
7294 if (count < 0)
7295 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007296 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007297 }
7298
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007299 if (location == -1)
7300 {
7301 return;
7302 }
7303
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007304 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007305
7306 if (context)
7307 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007308 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007309 if (!programBinary)
7310 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007311 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007312 }
7313
7314 if (!programBinary->setUniform3iv(location, count, v))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007315 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007316 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007317 }
7318 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007319 }
7320 catch(std::bad_alloc&)
7321 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007322 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007323 }
7324}
7325
7326void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
7327{
7328 GLfloat xyzw[4] = {x, y, z, w};
7329
7330 glUniform4fv(location, 1, (GLfloat*)&xyzw);
7331}
7332
7333void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
7334{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007335 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007336
7337 try
7338 {
7339 if (count < 0)
7340 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007341 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007342 }
7343
7344 if (location == -1)
7345 {
7346 return;
7347 }
7348
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007349 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007350
7351 if (context)
7352 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007353 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007354 if (!programBinary)
7355 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007356 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007357 }
7358
7359 if (!programBinary->setUniform4fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007360 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007361 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007362 }
7363 }
7364 }
7365 catch(std::bad_alloc&)
7366 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007367 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007368 }
7369}
7370
7371void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
7372{
7373 GLint xyzw[4] = {x, y, z, w};
7374
7375 glUniform4iv(location, 1, (GLint*)&xyzw);
7376}
7377
7378void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v)
7379{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007380 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007381
7382 try
7383 {
7384 if (count < 0)
7385 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007386 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007387 }
7388
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007389 if (location == -1)
7390 {
7391 return;
7392 }
7393
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007394 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007395
7396 if (context)
7397 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007398 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007399 if (!programBinary)
7400 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007401 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007402 }
7403
7404 if (!programBinary->setUniform4iv(location, count, v))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007405 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007406 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007407 }
7408 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007409 }
7410 catch(std::bad_alloc&)
7411 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007412 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007413 }
7414}
7415
7416void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
7417{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007418 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007419 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007420
7421 try
7422 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007423 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007424 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007425 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007426 }
7427
7428 if (location == -1)
7429 {
7430 return;
7431 }
7432
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007433 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007434
7435 if (context)
7436 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007437 if (transpose != GL_FALSE && context->getClientVersion() < 3)
7438 {
7439 return gl::error(GL_INVALID_VALUE);
7440 }
7441
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007442 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007443 if (!programBinary)
7444 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007445 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007446 }
7447
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007448 if (!programBinary->setUniformMatrix2fv(location, count, transpose, value))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007449 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007450 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007451 }
7452 }
7453 }
7454 catch(std::bad_alloc&)
7455 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007456 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007457 }
7458}
7459
7460void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
7461{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007462 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007463 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007464
7465 try
7466 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007467 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007468 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007469 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007470 }
7471
7472 if (location == -1)
7473 {
7474 return;
7475 }
7476
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007477 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007478
7479 if (context)
7480 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007481 if (transpose != GL_FALSE && context->getClientVersion() < 3)
7482 {
7483 return gl::error(GL_INVALID_VALUE);
7484 }
7485
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007486 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007487 if (!programBinary)
7488 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007489 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007490 }
7491
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007492 if (!programBinary->setUniformMatrix3fv(location, count, transpose, value))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007493 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007494 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007495 }
7496 }
7497 }
7498 catch(std::bad_alloc&)
7499 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007500 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007501 }
7502}
7503
7504void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
7505{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007506 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007507 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007508
7509 try
7510 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007511 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007512 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007513 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007514 }
7515
7516 if (location == -1)
7517 {
7518 return;
7519 }
7520
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007521 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007522
7523 if (context)
7524 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007525 if (transpose != GL_FALSE && context->getClientVersion() < 3)
7526 {
7527 return gl::error(GL_INVALID_VALUE);
7528 }
7529
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007530 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007531 if (!programBinary)
7532 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007533 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007534 }
7535
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007536 if (!programBinary->setUniformMatrix4fv(location, count, transpose, value))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007537 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007538 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007539 }
7540 }
7541 }
7542 catch(std::bad_alloc&)
7543 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007544 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007545 }
7546}
7547
7548void __stdcall glUseProgram(GLuint program)
7549{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007550 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007551
7552 try
7553 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007554 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007555
7556 if (context)
7557 {
7558 gl::Program *programObject = context->getProgram(program);
7559
daniel@transgaming.comc8478202010-04-13 19:53:35 +00007560 if (!programObject && program != 0)
7561 {
7562 if (context->getShader(program))
7563 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007564 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comc8478202010-04-13 19:53:35 +00007565 }
7566 else
7567 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007568 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comc8478202010-04-13 19:53:35 +00007569 }
7570 }
7571
daniel@transgaming.com716056c2012-07-24 18:38:59 +00007572 if (program != 0 && !programObject->isLinked())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007573 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007574 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007575 }
7576
7577 context->useProgram(program);
7578 }
7579 }
7580 catch(std::bad_alloc&)
7581 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007582 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007583 }
7584}
7585
7586void __stdcall glValidateProgram(GLuint program)
7587{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007588 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007589
7590 try
7591 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007592 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007593
7594 if (context)
7595 {
7596 gl::Program *programObject = context->getProgram(program);
7597
7598 if (!programObject)
7599 {
7600 if (context->getShader(program))
7601 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007602 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007603 }
7604 else
7605 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007606 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007607 }
7608 }
7609
apatrick@chromium.org253b8d22012-06-22 19:27:21 +00007610 programObject->validate();
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007611 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007612 }
7613 catch(std::bad_alloc&)
7614 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007615 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007616 }
7617}
7618
7619void __stdcall glVertexAttrib1f(GLuint index, GLfloat x)
7620{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007621 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007622
7623 try
7624 {
7625 if (index >= gl::MAX_VERTEX_ATTRIBS)
7626 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007627 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007628 }
7629
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007630 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007631
7632 if (context)
7633 {
7634 GLfloat vals[4] = { x, 0, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007635 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007636 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007637 }
7638 catch(std::bad_alloc&)
7639 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007640 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007641 }
7642}
7643
7644void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values)
7645{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007646 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007647
7648 try
7649 {
7650 if (index >= gl::MAX_VERTEX_ATTRIBS)
7651 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007652 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007653 }
7654
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007655 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007656
7657 if (context)
7658 {
7659 GLfloat vals[4] = { values[0], 0, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007660 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007661 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007662 }
7663 catch(std::bad_alloc&)
7664 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007665 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007666 }
7667}
7668
7669void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
7670{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007671 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007672
7673 try
7674 {
7675 if (index >= gl::MAX_VERTEX_ATTRIBS)
7676 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007677 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007678 }
7679
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007680 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007681
7682 if (context)
7683 {
7684 GLfloat vals[4] = { x, y, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007685 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007686 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007687 }
7688 catch(std::bad_alloc&)
7689 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007690 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007691 }
7692}
7693
7694void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values)
7695{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007696 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007697
7698 try
7699 {
7700 if (index >= gl::MAX_VERTEX_ATTRIBS)
7701 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007702 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007703 }
7704
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007705 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007706
7707 if (context)
7708 {
7709 GLfloat vals[4] = { values[0], values[1], 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007710 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007711 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007712 }
7713 catch(std::bad_alloc&)
7714 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007715 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007716 }
7717}
7718
7719void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
7720{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007721 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 +00007722
7723 try
7724 {
7725 if (index >= gl::MAX_VERTEX_ATTRIBS)
7726 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007727 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007728 }
7729
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007730 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007731
7732 if (context)
7733 {
7734 GLfloat vals[4] = { x, y, z, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007735 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007736 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007737 }
7738 catch(std::bad_alloc&)
7739 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007740 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007741 }
7742}
7743
7744void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values)
7745{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007746 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007747
7748 try
7749 {
7750 if (index >= gl::MAX_VERTEX_ATTRIBS)
7751 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007752 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007753 }
7754
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007755 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007756
7757 if (context)
7758 {
7759 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007760 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007761 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007762 }
7763 catch(std::bad_alloc&)
7764 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007765 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007766 }
7767}
7768
7769void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
7770{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007771 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 +00007772
7773 try
7774 {
7775 if (index >= gl::MAX_VERTEX_ATTRIBS)
7776 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007777 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007778 }
7779
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007780 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007781
7782 if (context)
7783 {
7784 GLfloat vals[4] = { x, y, z, w };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007785 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007786 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007787 }
7788 catch(std::bad_alloc&)
7789 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007790 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007791 }
7792}
7793
7794void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values)
7795{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007796 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007797
7798 try
7799 {
7800 if (index >= gl::MAX_VERTEX_ATTRIBS)
7801 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007802 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007803 }
7804
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007805 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007806
7807 if (context)
7808 {
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007809 context->setVertexAttribf(index, values);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007810 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007811 }
7812 catch(std::bad_alloc&)
7813 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007814 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007815 }
7816}
7817
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00007818void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
7819{
7820 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
7821
7822 try
7823 {
7824 if (index >= gl::MAX_VERTEX_ATTRIBS)
7825 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007826 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00007827 }
7828
7829 gl::Context *context = gl::getNonLostContext();
7830
7831 if (context)
7832 {
7833 context->setVertexAttribDivisor(index, divisor);
7834 }
7835 }
7836 catch(std::bad_alloc&)
7837 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007838 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00007839 }
7840}
7841
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00007842void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007843{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007844 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007845 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007846 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007847
7848 try
7849 {
7850 if (index >= gl::MAX_VERTEX_ATTRIBS)
7851 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007852 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007853 }
7854
7855 if (size < 1 || size > 4)
7856 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007857 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007858 }
7859
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00007860 gl::Context *context = gl::getNonLostContext();
7861
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007862 switch (type)
7863 {
7864 case GL_BYTE:
7865 case GL_UNSIGNED_BYTE:
7866 case GL_SHORT:
7867 case GL_UNSIGNED_SHORT:
7868 case GL_FIXED:
7869 case GL_FLOAT:
7870 break;
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00007871 case GL_HALF_FLOAT:
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007872 case GL_INT:
7873 case GL_UNSIGNED_INT:
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00007874 case GL_INT_2_10_10_10_REV:
7875 case GL_UNSIGNED_INT_2_10_10_10_REV:
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00007876 if (context && context->getClientVersion() < 3)
7877 {
7878 return gl::error(GL_INVALID_ENUM);
7879 }
7880 else
7881 {
7882 break;
7883 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007884 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007885 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007886 }
7887
7888 if (stride < 0)
7889 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007890 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007891 }
7892
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00007893 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
7894 {
7895 return gl::error(GL_INVALID_OPERATION);
7896 }
7897
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007898 if (context)
7899 {
shannon.woods%transgaming.com@gtempaccount.com8de4e6a2013-04-13 03:37:44 +00007900 context->setVertexAttribState(index, context->getArrayBuffer(), size, type,
7901 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007902 }
7903 }
7904 catch(std::bad_alloc&)
7905 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007906 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007907 }
7908}
7909
7910void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
7911{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007912 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 +00007913
7914 try
7915 {
7916 if (width < 0 || height < 0)
7917 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007918 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007919 }
7920
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007921 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007922
7923 if (context)
7924 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00007925 context->setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007926 }
7927 }
7928 catch(std::bad_alloc&)
7929 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007930 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007931 }
7932}
7933
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007934// OpenGL ES 3.0 functions
7935
7936void __stdcall glReadBuffer(GLenum mode)
7937{
7938 EVENT("(GLenum mode = 0x%X)", mode);
7939
7940 try
7941 {
7942 gl::Context *context = gl::getNonLostContext();
7943
7944 if (context)
7945 {
7946 if (context->getClientVersion() < 3)
7947 {
7948 return gl::error(GL_INVALID_OPERATION);
7949 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007950
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007951 UNIMPLEMENTED();
7952 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007953 }
7954 catch(std::bad_alloc&)
7955 {
7956 return gl::error(GL_OUT_OF_MEMORY);
7957 }
7958}
7959
7960void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
7961{
7962 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
7963 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
7964
7965 try
7966 {
7967 gl::Context *context = gl::getNonLostContext();
7968
7969 if (context)
7970 {
7971 if (context->getClientVersion() < 3)
7972 {
7973 return gl::error(GL_INVALID_OPERATION);
7974 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007975
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007976 UNIMPLEMENTED();
7977 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007978 }
7979 catch(std::bad_alloc&)
7980 {
7981 return gl::error(GL_OUT_OF_MEMORY);
7982 }
7983}
7984
7985void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
7986{
7987 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
7988 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
7989 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
7990 target, level, internalformat, width, height, depth, border, format, type, pixels);
7991
7992 try
7993 {
7994 gl::Context *context = gl::getNonLostContext();
7995
7996 if (context)
7997 {
7998 if (context->getClientVersion() < 3)
7999 {
8000 return gl::error(GL_INVALID_OPERATION);
8001 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008002
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008003 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008004 if (!validateES3TexImageParameters(context, target, level, internalformat, false, false,
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008005 0, 0, 0, width, height, depth, border, format, type))
8006 {
8007 return;
8008 }
8009
8010 switch(target)
8011 {
8012 case GL_TEXTURE_3D:
8013 {
8014 gl::Texture3D *texture = context->getTexture3D();
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +00008015 texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackAlignment(), pixels);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008016 }
8017 break;
8018
8019 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008020 {
8021 gl::Texture2DArray *texture = context->getTexture2DArray();
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +00008022 texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackAlignment(), pixels);
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008023 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008024 break;
8025
8026 default:
8027 return gl::error(GL_INVALID_ENUM);
8028 }
8029 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008030 }
8031 catch(std::bad_alloc&)
8032 {
8033 return gl::error(GL_OUT_OF_MEMORY);
8034 }
8035}
8036
8037void __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)
8038{
8039 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
8040 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
8041 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
8042 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
8043
8044 try
8045 {
8046 gl::Context *context = gl::getNonLostContext();
8047
8048 if (context)
8049 {
8050 if (context->getClientVersion() < 3)
8051 {
8052 return gl::error(GL_INVALID_OPERATION);
8053 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008054
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008055 if (!pixels)
8056 {
8057 return gl::error(GL_INVALID_VALUE);
8058 }
8059
8060 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008061 if (!validateES3TexImageParameters(context, target, level, GL_NONE, false, true,
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008062 xoffset, yoffset, zoffset, width, height, depth, 0,
8063 format, type))
8064 {
8065 return;
8066 }
8067
8068 switch(target)
8069 {
8070 case GL_TEXTURE_3D:
8071 {
8072 gl::Texture3D *texture = context->getTexture3D();
8073 texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels);
8074 }
8075 break;
8076
8077 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008078 {
8079 gl::Texture2DArray *texture = context->getTexture2DArray();
8080 texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels);
8081 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008082 break;
8083
8084 default:
8085 return gl::error(GL_INVALID_ENUM);
8086 }
8087 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008088 }
8089 catch(std::bad_alloc&)
8090 {
8091 return gl::error(GL_OUT_OF_MEMORY);
8092 }
8093}
8094
8095void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
8096{
8097 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
8098 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
8099 target, level, xoffset, yoffset, zoffset, x, y, width, height);
8100
8101 try
8102 {
8103 gl::Context *context = gl::getNonLostContext();
8104
8105 if (context)
8106 {
8107 if (context->getClientVersion() < 3)
8108 {
8109 return gl::error(GL_INVALID_OPERATION);
8110 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008111
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008112 if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset,
8113 x, y, width, height, 0))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008114 {
8115 return;
8116 }
8117
8118 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
8119 gl::Texture *texture = NULL;
8120 switch (target)
8121 {
8122 case GL_TEXTURE_3D:
8123 texture = context->getTexture3D();
8124 break;
8125
8126 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008127 texture = context->getTexture2DArray();
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008128 break;
8129
8130 default:
8131 return gl::error(GL_INVALID_ENUM);
8132 }
8133
8134 texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
8135 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008136 }
8137 catch(std::bad_alloc&)
8138 {
8139 return gl::error(GL_OUT_OF_MEMORY);
8140 }
8141}
8142
8143void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
8144{
8145 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
8146 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
8147 "const GLvoid* data = 0x%0.8p)",
8148 target, level, internalformat, width, height, depth, border, imageSize, data);
8149
8150 try
8151 {
8152 gl::Context *context = gl::getNonLostContext();
8153
8154 if (context)
8155 {
8156 if (context->getClientVersion() < 3)
8157 {
8158 return gl::error(GL_INVALID_OPERATION);
8159 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008160
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00008161 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 +00008162 {
8163 return gl::error(GL_INVALID_VALUE);
8164 }
8165
8166 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008167 if (!validateES3TexImageParameters(context, target, level, internalformat, true, false,
8168 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008169 {
8170 return;
8171 }
8172
8173 switch(target)
8174 {
8175 case GL_TEXTURE_3D:
8176 {
8177 gl::Texture3D *texture = context->getTexture3D();
8178 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
8179 }
8180 break;
8181
8182 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008183 {
8184 gl::Texture2DArray *texture = context->getTexture2DArray();
8185 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
8186 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008187 break;
8188
8189 default:
8190 return gl::error(GL_INVALID_ENUM);
8191 }
8192 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008193 }
8194 catch(std::bad_alloc&)
8195 {
8196 return gl::error(GL_OUT_OF_MEMORY);
8197 }
8198}
8199
8200void __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)
8201{
8202 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
8203 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
8204 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
8205 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
8206
8207 try
8208 {
8209 gl::Context *context = gl::getNonLostContext();
8210
8211 if (context)
8212 {
8213 if (context->getClientVersion() < 3)
8214 {
8215 return gl::error(GL_INVALID_OPERATION);
8216 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008217
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00008218 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 +00008219 {
8220 return gl::error(GL_INVALID_VALUE);
8221 }
8222
8223 if (!data)
8224 {
8225 return gl::error(GL_INVALID_VALUE);
8226 }
8227
8228 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008229 if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true,
8230 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008231 {
8232 return;
8233 }
8234
8235 switch(target)
8236 {
8237 case GL_TEXTURE_3D:
8238 {
8239 gl::Texture3D *texture = context->getTexture3D();
8240 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
8241 format, imageSize, data);
8242 }
8243 break;
8244
8245 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008246 {
8247 gl::Texture2DArray *texture = context->getTexture2DArray();
8248 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
8249 format, imageSize, data);
8250 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008251 break;
8252
8253 default:
8254 return gl::error(GL_INVALID_ENUM);
8255 }
8256 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008257 }
8258 catch(std::bad_alloc&)
8259 {
8260 return gl::error(GL_OUT_OF_MEMORY);
8261 }
8262}
8263
8264void __stdcall glGenQueries(GLsizei n, GLuint* ids)
8265{
8266 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8267
8268 try
8269 {
8270 gl::Context *context = gl::getNonLostContext();
8271
8272 if (context)
8273 {
8274 if (context->getClientVersion() < 3)
8275 {
8276 return gl::error(GL_INVALID_OPERATION);
8277 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008278
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008279 UNIMPLEMENTED();
8280 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008281 }
8282 catch(std::bad_alloc&)
8283 {
8284 return gl::error(GL_OUT_OF_MEMORY);
8285 }
8286}
8287
8288void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids)
8289{
8290 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8291
8292 try
8293 {
8294 gl::Context *context = gl::getNonLostContext();
8295
8296 if (context)
8297 {
8298 if (context->getClientVersion() < 3)
8299 {
8300 return gl::error(GL_INVALID_OPERATION);
8301 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008302
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008303 UNIMPLEMENTED();
8304 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008305 }
8306 catch(std::bad_alloc&)
8307 {
8308 return gl::error(GL_OUT_OF_MEMORY);
8309 }
8310}
8311
8312GLboolean __stdcall glIsQuery(GLuint id)
8313{
8314 EVENT("(GLuint id = %u)", id);
8315
8316 try
8317 {
8318 gl::Context *context = gl::getNonLostContext();
8319
8320 if (context)
8321 {
8322 if (context->getClientVersion() < 3)
8323 {
8324 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8325 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008326
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008327 UNIMPLEMENTED();
8328 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008329 }
8330 catch(std::bad_alloc&)
8331 {
8332 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8333 }
8334
8335 return GL_FALSE;
8336}
8337
8338void __stdcall glBeginQuery(GLenum target, GLuint id)
8339{
8340 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
8341
8342 try
8343 {
8344 gl::Context *context = gl::getNonLostContext();
8345
8346 if (context)
8347 {
8348 if (context->getClientVersion() < 3)
8349 {
8350 return gl::error(GL_INVALID_OPERATION);
8351 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008352
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008353 UNIMPLEMENTED();
8354 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008355 }
8356 catch(std::bad_alloc&)
8357 {
8358 return gl::error(GL_OUT_OF_MEMORY);
8359 }
8360}
8361
8362void __stdcall glEndQuery(GLenum target)
8363{
8364 EVENT("(GLenum target = 0x%X)", target);
8365
8366 try
8367 {
8368 gl::Context *context = gl::getNonLostContext();
8369
8370 if (context)
8371 {
8372 if (context->getClientVersion() < 3)
8373 {
8374 return gl::error(GL_INVALID_OPERATION);
8375 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008376
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008377 UNIMPLEMENTED();
8378 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008379 }
8380 catch(std::bad_alloc&)
8381 {
8382 return gl::error(GL_OUT_OF_MEMORY);
8383 }
8384}
8385
8386void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params)
8387{
8388 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
8389
8390 try
8391 {
8392 gl::Context *context = gl::getNonLostContext();
8393
8394 if (context)
8395 {
8396 if (context->getClientVersion() < 3)
8397 {
8398 return gl::error(GL_INVALID_OPERATION);
8399 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008400
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008401 UNIMPLEMENTED();
8402 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008403 }
8404 catch(std::bad_alloc&)
8405 {
8406 return gl::error(GL_OUT_OF_MEMORY);
8407 }
8408}
8409
8410void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
8411{
8412 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
8413
8414 try
8415 {
8416 gl::Context *context = gl::getNonLostContext();
8417
8418 if (context)
8419 {
8420 if (context->getClientVersion() < 3)
8421 {
8422 return gl::error(GL_INVALID_OPERATION);
8423 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008424
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008425 UNIMPLEMENTED();
8426 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008427 }
8428 catch(std::bad_alloc&)
8429 {
8430 return gl::error(GL_OUT_OF_MEMORY);
8431 }
8432}
8433
8434GLboolean __stdcall glUnmapBuffer(GLenum target)
8435{
8436 EVENT("(GLenum target = 0x%X)", target);
8437
8438 try
8439 {
8440 gl::Context *context = gl::getNonLostContext();
8441
8442 if (context)
8443 {
8444 if (context->getClientVersion() < 3)
8445 {
8446 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8447 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008448
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008449 UNIMPLEMENTED();
8450 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008451 }
8452 catch(std::bad_alloc&)
8453 {
8454 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8455 }
8456
8457 return GL_FALSE;
8458}
8459
8460void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
8461{
8462 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
8463
8464 try
8465 {
8466 gl::Context *context = gl::getNonLostContext();
8467
8468 if (context)
8469 {
8470 if (context->getClientVersion() < 3)
8471 {
8472 return gl::error(GL_INVALID_OPERATION);
8473 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008474
shannonwoods@chromium.org2d2190a2013-05-30 00:17:35 +00008475 UNIMPLEMENTED();
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008476 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008477 }
8478 catch(std::bad_alloc&)
8479 {
8480 return gl::error(GL_OUT_OF_MEMORY);
8481 }
8482}
8483
8484void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs)
8485{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008486 try
8487 {
8488 gl::Context *context = gl::getNonLostContext();
8489
8490 if (context)
8491 {
8492 if (context->getClientVersion() < 3)
8493 {
8494 return gl::error(GL_INVALID_OPERATION);
8495 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008496
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00008497 glDrawBuffersEXT(n, bufs);
8498 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008499 }
8500 catch(std::bad_alloc&)
8501 {
8502 return gl::error(GL_OUT_OF_MEMORY);
8503 }
8504}
8505
8506void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8507{
8508 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8509 location, count, transpose, value);
8510
8511 try
8512 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008513 if (count < 0)
8514 {
8515 return gl::error(GL_INVALID_VALUE);
8516 }
8517
8518 if (location == -1)
8519 {
8520 return;
8521 }
8522
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008523 gl::Context *context = gl::getNonLostContext();
8524
8525 if (context)
8526 {
8527 if (context->getClientVersion() < 3)
8528 {
8529 return gl::error(GL_INVALID_OPERATION);
8530 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008531
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008532 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8533 if (!programBinary)
8534 {
8535 return gl::error(GL_INVALID_OPERATION);
8536 }
8537
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008538 if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008539 {
8540 return gl::error(GL_INVALID_OPERATION);
8541 }
8542 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008543 }
8544 catch(std::bad_alloc&)
8545 {
8546 return gl::error(GL_OUT_OF_MEMORY);
8547 }
8548}
8549
8550void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8551{
8552 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8553 location, count, transpose, value);
8554
8555 try
8556 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008557 if (count < 0)
8558 {
8559 return gl::error(GL_INVALID_VALUE);
8560 }
8561
8562 if (location == -1)
8563 {
8564 return;
8565 }
8566
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008567 gl::Context *context = gl::getNonLostContext();
8568
8569 if (context)
8570 {
8571 if (context->getClientVersion() < 3)
8572 {
8573 return gl::error(GL_INVALID_OPERATION);
8574 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008575
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008576 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8577 if (!programBinary)
8578 {
8579 return gl::error(GL_INVALID_OPERATION);
8580 }
8581
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008582 if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008583 {
8584 return gl::error(GL_INVALID_OPERATION);
8585 }
8586 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008587 }
8588 catch(std::bad_alloc&)
8589 {
8590 return gl::error(GL_OUT_OF_MEMORY);
8591 }
8592}
8593
8594void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8595{
8596 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8597 location, count, transpose, value);
8598
8599 try
8600 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008601 if (count < 0)
8602 {
8603 return gl::error(GL_INVALID_VALUE);
8604 }
8605
8606 if (location == -1)
8607 {
8608 return;
8609 }
8610
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008611 gl::Context *context = gl::getNonLostContext();
8612
8613 if (context)
8614 {
8615 if (context->getClientVersion() < 3)
8616 {
8617 return gl::error(GL_INVALID_OPERATION);
8618 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008619
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008620 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8621 if (!programBinary)
8622 {
8623 return gl::error(GL_INVALID_OPERATION);
8624 }
8625
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008626 if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008627 {
8628 return gl::error(GL_INVALID_OPERATION);
8629 }
8630 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008631 }
8632 catch(std::bad_alloc&)
8633 {
8634 return gl::error(GL_OUT_OF_MEMORY);
8635 }
8636}
8637
8638void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8639{
8640 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8641 location, count, transpose, value);
8642
8643 try
8644 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008645 if (count < 0)
8646 {
8647 return gl::error(GL_INVALID_VALUE);
8648 }
8649
8650 if (location == -1)
8651 {
8652 return;
8653 }
8654
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008655 gl::Context *context = gl::getNonLostContext();
8656
8657 if (context)
8658 {
8659 if (context->getClientVersion() < 3)
8660 {
8661 return gl::error(GL_INVALID_OPERATION);
8662 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008663
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008664 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8665 if (!programBinary)
8666 {
8667 return gl::error(GL_INVALID_OPERATION);
8668 }
8669
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008670 if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008671 {
8672 return gl::error(GL_INVALID_OPERATION);
8673 }
8674 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008675 }
8676 catch(std::bad_alloc&)
8677 {
8678 return gl::error(GL_OUT_OF_MEMORY);
8679 }
8680}
8681
8682void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8683{
8684 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8685 location, count, transpose, value);
8686
8687 try
8688 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008689 if (count < 0)
8690 {
8691 return gl::error(GL_INVALID_VALUE);
8692 }
8693
8694 if (location == -1)
8695 {
8696 return;
8697 }
8698
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008699 gl::Context *context = gl::getNonLostContext();
8700
8701 if (context)
8702 {
8703 if (context->getClientVersion() < 3)
8704 {
8705 return gl::error(GL_INVALID_OPERATION);
8706 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008707
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008708 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8709 if (!programBinary)
8710 {
8711 return gl::error(GL_INVALID_OPERATION);
8712 }
8713
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008714 if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008715 {
8716 return gl::error(GL_INVALID_OPERATION);
8717 }
8718 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008719 }
8720 catch(std::bad_alloc&)
8721 {
8722 return gl::error(GL_OUT_OF_MEMORY);
8723 }
8724}
8725
8726void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8727{
8728 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8729 location, count, transpose, value);
8730
8731 try
8732 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008733 if (count < 0)
8734 {
8735 return gl::error(GL_INVALID_VALUE);
8736 }
8737
8738 if (location == -1)
8739 {
8740 return;
8741 }
8742
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008743 gl::Context *context = gl::getNonLostContext();
8744
8745 if (context)
8746 {
8747 if (context->getClientVersion() < 3)
8748 {
8749 return gl::error(GL_INVALID_OPERATION);
8750 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008751
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008752 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8753 if (!programBinary)
8754 {
8755 return gl::error(GL_INVALID_OPERATION);
8756 }
8757
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008758 if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008759 {
8760 return gl::error(GL_INVALID_OPERATION);
8761 }
8762 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008763 }
8764 catch(std::bad_alloc&)
8765 {
8766 return gl::error(GL_OUT_OF_MEMORY);
8767 }
8768}
8769
8770void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
8771{
8772 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
8773 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
8774 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
8775
8776 try
8777 {
8778 gl::Context *context = gl::getNonLostContext();
8779
8780 if (context)
8781 {
8782 if (context->getClientVersion() < 3)
8783 {
8784 return gl::error(GL_INVALID_OPERATION);
8785 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008786
shannonwoods@chromium.orgee148562013-05-30 00:17:21 +00008787 glBlitFramebufferANGLE(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008788 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008789 }
8790 catch(std::bad_alloc&)
8791 {
8792 return gl::error(GL_OUT_OF_MEMORY);
8793 }
8794}
8795
8796void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
8797{
8798 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
8799 target, samples, internalformat, width, height);
8800
8801 try
8802 {
8803 gl::Context *context = gl::getNonLostContext();
8804
8805 if (context)
8806 {
8807 if (context->getClientVersion() < 3)
8808 {
8809 return gl::error(GL_INVALID_OPERATION);
8810 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008811
Geoff Lang2e1dcd52013-05-29 10:34:08 -04008812 if (!validateRenderbufferStorageParameters(context, target, samples, internalformat,
8813 width, height, false))
8814 {
8815 return;
8816 }
8817
8818 context->setRenderbufferStorage(width, height, internalformat, samples);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008819 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008820 }
8821 catch(std::bad_alloc&)
8822 {
8823 return gl::error(GL_OUT_OF_MEMORY);
8824 }
8825}
8826
8827void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
8828{
8829 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
8830 target, attachment, texture, level, layer);
8831
8832 try
8833 {
8834 gl::Context *context = gl::getNonLostContext();
8835
8836 if (context)
8837 {
8838 if (context->getClientVersion() < 3)
8839 {
8840 return gl::error(GL_INVALID_OPERATION);
8841 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008842
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008843 UNIMPLEMENTED();
8844 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008845 }
8846 catch(std::bad_alloc&)
8847 {
8848 return gl::error(GL_OUT_OF_MEMORY);
8849 }
8850}
8851
8852GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
8853{
8854 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
8855 target, offset, length, access);
8856
8857 try
8858 {
8859 gl::Context *context = gl::getNonLostContext();
8860
8861 if (context)
8862 {
8863 if (context->getClientVersion() < 3)
8864 {
8865 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
8866 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008867
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008868 UNIMPLEMENTED();
8869 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008870 }
8871 catch(std::bad_alloc&)
8872 {
8873 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL));
8874 }
8875
8876 return NULL;
8877}
8878
8879void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
8880{
8881 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
8882
8883 try
8884 {
8885 gl::Context *context = gl::getNonLostContext();
8886
8887 if (context)
8888 {
8889 if (context->getClientVersion() < 3)
8890 {
8891 return gl::error(GL_INVALID_OPERATION);
8892 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008893
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008894 UNIMPLEMENTED();
8895 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008896 }
8897 catch(std::bad_alloc&)
8898 {
8899 return gl::error(GL_OUT_OF_MEMORY);
8900 }
8901}
8902
8903void __stdcall glBindVertexArray(GLuint array)
8904{
8905 EVENT("(GLuint array = %u)", array);
8906
8907 try
8908 {
8909 gl::Context *context = gl::getNonLostContext();
8910
8911 if (context)
8912 {
8913 if (context->getClientVersion() < 3)
8914 {
8915 return gl::error(GL_INVALID_OPERATION);
8916 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008917
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008918 UNIMPLEMENTED();
8919 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008920 }
8921 catch(std::bad_alloc&)
8922 {
8923 return gl::error(GL_OUT_OF_MEMORY);
8924 }
8925}
8926
8927void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
8928{
8929 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
8930
8931 try
8932 {
8933 gl::Context *context = gl::getNonLostContext();
8934
8935 if (context)
8936 {
8937 if (context->getClientVersion() < 3)
8938 {
8939 return gl::error(GL_INVALID_OPERATION);
8940 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008941
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008942 UNIMPLEMENTED();
8943 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008944 }
8945 catch(std::bad_alloc&)
8946 {
8947 return gl::error(GL_OUT_OF_MEMORY);
8948 }
8949}
8950
8951void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays)
8952{
8953 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
8954
8955 try
8956 {
8957 gl::Context *context = gl::getNonLostContext();
8958
8959 if (context)
8960 {
8961 if (context->getClientVersion() < 3)
8962 {
8963 return gl::error(GL_INVALID_OPERATION);
8964 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008965
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008966 UNIMPLEMENTED();
8967 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008968 }
8969 catch(std::bad_alloc&)
8970 {
8971 return gl::error(GL_OUT_OF_MEMORY);
8972 }
8973}
8974
8975GLboolean __stdcall glIsVertexArray(GLuint array)
8976{
8977 EVENT("(GLuint array = %u)", array);
8978
8979 try
8980 {
8981 gl::Context *context = gl::getNonLostContext();
8982
8983 if (context)
8984 {
8985 if (context->getClientVersion() < 3)
8986 {
8987 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8988 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008989
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008990 UNIMPLEMENTED();
8991 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008992 }
8993 catch(std::bad_alloc&)
8994 {
8995 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8996 }
8997
8998 return GL_FALSE;
8999}
9000
9001void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
9002{
9003 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
9004 target, index, data);
9005
9006 try
9007 {
9008 gl::Context *context = gl::getNonLostContext();
9009
9010 if (context)
9011 {
9012 if (context->getClientVersion() < 3)
9013 {
9014 return gl::error(GL_INVALID_OPERATION);
9015 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009016
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009017 UNIMPLEMENTED();
9018 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009019 }
9020 catch(std::bad_alloc&)
9021 {
9022 return gl::error(GL_OUT_OF_MEMORY);
9023 }
9024}
9025
9026void __stdcall glBeginTransformFeedback(GLenum primitiveMode)
9027{
9028 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
9029
9030 try
9031 {
9032 gl::Context *context = gl::getNonLostContext();
9033
9034 if (context)
9035 {
9036 if (context->getClientVersion() < 3)
9037 {
9038 return gl::error(GL_INVALID_OPERATION);
9039 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009040
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009041 UNIMPLEMENTED();
9042 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009043 }
9044 catch(std::bad_alloc&)
9045 {
9046 return gl::error(GL_OUT_OF_MEMORY);
9047 }
9048}
9049
9050void __stdcall glEndTransformFeedback(void)
9051{
9052 EVENT("(void)");
9053
9054 try
9055 {
9056 gl::Context *context = gl::getNonLostContext();
9057
9058 if (context)
9059 {
9060 if (context->getClientVersion() < 3)
9061 {
9062 return gl::error(GL_INVALID_OPERATION);
9063 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009064
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009065 UNIMPLEMENTED();
9066 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009067 }
9068 catch(std::bad_alloc&)
9069 {
9070 return gl::error(GL_OUT_OF_MEMORY);
9071 }
9072}
9073
9074void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
9075{
9076 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
9077 target, index, buffer, offset, size);
9078
9079 try
9080 {
9081 gl::Context *context = gl::getNonLostContext();
9082
9083 if (context)
9084 {
9085 if (context->getClientVersion() < 3)
9086 {
9087 return gl::error(GL_INVALID_OPERATION);
9088 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009089
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009090 switch (target)
9091 {
9092 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00009093 if (index >= context->getMaxTransformFeedbackBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009094 {
9095 return gl::error(GL_INVALID_VALUE);
9096 }
9097 break;
9098
9099 case GL_UNIFORM_BUFFER:
9100 if (index >= context->getMaximumCombinedUniformBufferBindings())
9101 {
9102 return gl::error(GL_INVALID_VALUE);
9103 }
9104 break;
9105
9106 default:
9107 return gl::error(GL_INVALID_ENUM);
9108 }
9109
shannonwoods@chromium.orge6e00792013-05-30 00:06:07 +00009110 if (buffer != 0 && size <= 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009111 {
9112 return gl::error(GL_INVALID_VALUE);
9113 }
9114
9115 switch (target)
9116 {
9117 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orga26aeaf2013-05-30 00:06:13 +00009118
9119 // size and offset must be a multiple of 4
9120 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
9121 {
9122 return gl::error(GL_INVALID_VALUE);
9123 }
9124
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009125 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
9126 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009127 break;
9128
9129 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.org97c3d502013-05-30 00:04:34 +00009130
9131 // it is an error to bind an offset not a multiple of the alignment
9132 if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0)
9133 {
9134 return gl::error(GL_INVALID_VALUE);
9135 }
9136
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009137 context->bindIndexedUniformBuffer(buffer, index, offset, size);
9138 context->bindGenericUniformBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009139 break;
9140
9141 default:
9142 UNREACHABLE();
9143 }
9144 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009145 }
9146 catch(std::bad_alloc&)
9147 {
9148 return gl::error(GL_OUT_OF_MEMORY);
9149 }
9150}
9151
9152void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
9153{
9154 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
9155 target, index, buffer);
9156
9157 try
9158 {
9159 gl::Context *context = gl::getNonLostContext();
9160
9161 if (context)
9162 {
9163 if (context->getClientVersion() < 3)
9164 {
9165 return gl::error(GL_INVALID_OPERATION);
9166 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009167
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009168 switch (target)
9169 {
9170 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00009171 if (index >= context->getMaxTransformFeedbackBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009172 {
9173 return gl::error(GL_INVALID_VALUE);
9174 }
9175 break;
9176
9177 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00009178 if (index >= context->getMaximumCombinedUniformBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009179 {
9180 return gl::error(GL_INVALID_VALUE);
9181 }
9182 break;
9183
9184 default:
9185 return gl::error(GL_INVALID_ENUM);
9186 }
9187
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009188 switch (target)
9189 {
9190 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.org3eeca1e2013-05-30 00:04:28 +00009191 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009192 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009193 break;
9194
9195 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.org3eeca1e2013-05-30 00:04:28 +00009196 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009197 context->bindGenericUniformBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009198 break;
9199
9200 default:
9201 UNREACHABLE();
9202 }
9203 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009204 }
9205 catch(std::bad_alloc&)
9206 {
9207 return gl::error(GL_OUT_OF_MEMORY);
9208 }
9209}
9210
9211void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
9212{
9213 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
9214 program, count, varyings, bufferMode);
9215
9216 try
9217 {
9218 gl::Context *context = gl::getNonLostContext();
9219
9220 if (context)
9221 {
9222 if (context->getClientVersion() < 3)
9223 {
9224 return gl::error(GL_INVALID_OPERATION);
9225 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009226
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009227 UNIMPLEMENTED();
9228 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009229 }
9230 catch(std::bad_alloc&)
9231 {
9232 return gl::error(GL_OUT_OF_MEMORY);
9233 }
9234}
9235
9236void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
9237{
9238 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
9239 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
9240 program, index, bufSize, length, size, type, name);
9241
9242 try
9243 {
9244 gl::Context *context = gl::getNonLostContext();
9245
9246 if (context)
9247 {
9248 if (context->getClientVersion() < 3)
9249 {
9250 return gl::error(GL_INVALID_OPERATION);
9251 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009252
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009253 UNIMPLEMENTED();
9254 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009255 }
9256 catch(std::bad_alloc&)
9257 {
9258 return gl::error(GL_OUT_OF_MEMORY);
9259 }
9260}
9261
9262void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
9263{
9264 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
9265 index, size, type, stride, pointer);
9266
9267 try
9268 {
9269 gl::Context *context = gl::getNonLostContext();
9270
9271 if (context)
9272 {
9273 if (context->getClientVersion() < 3)
9274 {
9275 return gl::error(GL_INVALID_OPERATION);
9276 }
9277 }
9278
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009279 if (index >= gl::MAX_VERTEX_ATTRIBS)
9280 {
9281 return gl::error(GL_INVALID_VALUE);
9282 }
9283
9284 if (size < 1 || size > 4)
9285 {
9286 return gl::error(GL_INVALID_VALUE);
9287 }
9288
9289 switch (type)
9290 {
9291 case GL_BYTE:
9292 case GL_UNSIGNED_BYTE:
9293 case GL_SHORT:
9294 case GL_UNSIGNED_SHORT:
9295 case GL_INT:
9296 case GL_UNSIGNED_INT:
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00009297 case GL_INT_2_10_10_10_REV:
9298 case GL_UNSIGNED_INT_2_10_10_10_REV:
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009299 break;
9300 default:
9301 return gl::error(GL_INVALID_ENUM);
9302 }
9303
9304 if (stride < 0)
9305 {
9306 return gl::error(GL_INVALID_VALUE);
9307 }
9308
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00009309 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
9310 {
9311 return gl::error(GL_INVALID_OPERATION);
9312 }
9313
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009314 if (context)
9315 {
9316 context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true,
9317 stride, pointer);
9318 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009319 }
9320 catch(std::bad_alloc&)
9321 {
9322 return gl::error(GL_OUT_OF_MEMORY);
9323 }
9324}
9325
9326void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
9327{
9328 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
9329 index, pname, params);
9330
9331 try
9332 {
9333 gl::Context *context = gl::getNonLostContext();
9334
9335 if (context)
9336 {
9337 if (context->getClientVersion() < 3)
9338 {
9339 return gl::error(GL_INVALID_OPERATION);
9340 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009341
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009342 UNIMPLEMENTED();
9343 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009344 }
9345 catch(std::bad_alloc&)
9346 {
9347 return gl::error(GL_OUT_OF_MEMORY);
9348 }
9349}
9350
9351void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
9352{
9353 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
9354 index, pname, params);
9355
9356 try
9357 {
9358 gl::Context *context = gl::getNonLostContext();
9359
9360 if (context)
9361 {
9362 if (context->getClientVersion() < 3)
9363 {
9364 return gl::error(GL_INVALID_OPERATION);
9365 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009366
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009367 UNIMPLEMENTED();
9368 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009369 }
9370 catch(std::bad_alloc&)
9371 {
9372 return gl::error(GL_OUT_OF_MEMORY);
9373 }
9374}
9375
9376void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
9377{
9378 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
9379 index, x, y, z, w);
9380
9381 try
9382 {
9383 gl::Context *context = gl::getNonLostContext();
9384
9385 if (context)
9386 {
9387 if (context->getClientVersion() < 3)
9388 {
9389 return gl::error(GL_INVALID_OPERATION);
9390 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009391
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009392 if (index >= gl::MAX_VERTEX_ATTRIBS)
9393 {
9394 return gl::error(GL_INVALID_VALUE);
9395 }
9396
9397 GLint vals[4] = { x, y, z, w };
9398 context->setVertexAttribi(index, vals);
9399 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009400 }
9401 catch(std::bad_alloc&)
9402 {
9403 return gl::error(GL_OUT_OF_MEMORY);
9404 }
9405}
9406
9407void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
9408{
9409 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
9410 index, x, y, z, w);
9411
9412 try
9413 {
9414 gl::Context *context = gl::getNonLostContext();
9415
9416 if (context)
9417 {
9418 if (context->getClientVersion() < 3)
9419 {
9420 return gl::error(GL_INVALID_OPERATION);
9421 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009422
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009423 if (index >= gl::MAX_VERTEX_ATTRIBS)
9424 {
9425 return gl::error(GL_INVALID_VALUE);
9426 }
9427
9428 GLuint vals[4] = { x, y, z, w };
9429 context->setVertexAttribu(index, vals);
9430 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009431 }
9432 catch(std::bad_alloc&)
9433 {
9434 return gl::error(GL_OUT_OF_MEMORY);
9435 }
9436}
9437
9438void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v)
9439{
9440 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
9441
9442 try
9443 {
9444 gl::Context *context = gl::getNonLostContext();
9445
9446 if (context)
9447 {
9448 if (context->getClientVersion() < 3)
9449 {
9450 return gl::error(GL_INVALID_OPERATION);
9451 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009452
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009453 if (index >= gl::MAX_VERTEX_ATTRIBS)
9454 {
9455 return gl::error(GL_INVALID_VALUE);
9456 }
9457
9458 context->setVertexAttribi(index, v);
9459 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009460 }
9461 catch(std::bad_alloc&)
9462 {
9463 return gl::error(GL_OUT_OF_MEMORY);
9464 }
9465}
9466
9467void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v)
9468{
9469 EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
9470
9471 try
9472 {
9473 gl::Context *context = gl::getNonLostContext();
9474
9475 if (context)
9476 {
9477 if (context->getClientVersion() < 3)
9478 {
9479 return gl::error(GL_INVALID_OPERATION);
9480 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009481
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009482 if (index >= gl::MAX_VERTEX_ATTRIBS)
9483 {
9484 return gl::error(GL_INVALID_VALUE);
9485 }
9486
9487 context->setVertexAttribu(index, v);
9488 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009489 }
9490 catch(std::bad_alloc&)
9491 {
9492 return gl::error(GL_OUT_OF_MEMORY);
9493 }
9494}
9495
9496void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params)
9497{
9498 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
9499 program, location, params);
9500
9501 try
9502 {
9503 gl::Context *context = gl::getNonLostContext();
9504
9505 if (context)
9506 {
9507 if (context->getClientVersion() < 3)
9508 {
9509 return gl::error(GL_INVALID_OPERATION);
9510 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009511
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00009512 if (program == 0)
9513 {
9514 return gl::error(GL_INVALID_VALUE);
9515 }
9516
9517 gl::Program *programObject = context->getProgram(program);
9518
9519 if (!programObject || !programObject->isLinked())
9520 {
9521 return gl::error(GL_INVALID_OPERATION);
9522 }
9523
9524 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
9525 if (!programBinary)
9526 {
9527 return gl::error(GL_INVALID_OPERATION);
9528 }
9529
9530 if (!programBinary->getUniformuiv(location, NULL, params))
9531 {
9532 return gl::error(GL_INVALID_OPERATION);
9533 }
9534 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009535 }
9536 catch(std::bad_alloc&)
9537 {
9538 return gl::error(GL_OUT_OF_MEMORY);
9539 }
9540}
9541
9542GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name)
9543{
9544 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
9545 program, name);
9546
9547 try
9548 {
9549 gl::Context *context = gl::getNonLostContext();
9550
9551 if (context)
9552 {
9553 if (context->getClientVersion() < 3)
9554 {
9555 return gl::error(GL_INVALID_OPERATION, 0);
9556 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009557
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009558 UNIMPLEMENTED();
9559 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009560 }
9561 catch(std::bad_alloc&)
9562 {
9563 return gl::error(GL_OUT_OF_MEMORY, 0);
9564 }
9565
9566 return 0;
9567}
9568
9569void __stdcall glUniform1ui(GLint location, GLuint v0)
9570{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00009571 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009572}
9573
9574void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1)
9575{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00009576 const GLuint xy[] = { v0, v1 };
9577 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009578}
9579
9580void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
9581{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00009582 const GLuint xyz[] = { v0, v1, v2 };
9583 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009584}
9585
9586void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
9587{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00009588 const GLuint xyzw[] = { v0, v1, v2, v3 };
9589 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009590}
9591
9592void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
9593{
9594 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
9595 location, count, value);
9596
9597 try
9598 {
9599 gl::Context *context = gl::getNonLostContext();
9600
9601 if (context)
9602 {
9603 if (context->getClientVersion() < 3)
9604 {
9605 return gl::error(GL_INVALID_OPERATION);
9606 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009607
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00009608 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9609 if (!programBinary)
9610 {
9611 return gl::error(GL_INVALID_OPERATION);
9612 }
9613
9614 if (!programBinary->setUniform1uiv(location, count, value))
9615 {
9616 return gl::error(GL_INVALID_OPERATION);
9617 }
9618 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009619 }
9620 catch(std::bad_alloc&)
9621 {
9622 return gl::error(GL_OUT_OF_MEMORY);
9623 }
9624}
9625
9626void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
9627{
9628 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
9629 location, count, value);
9630
9631 try
9632 {
9633 gl::Context *context = gl::getNonLostContext();
9634
9635 if (context)
9636 {
9637 if (context->getClientVersion() < 3)
9638 {
9639 return gl::error(GL_INVALID_OPERATION);
9640 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009641
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00009642 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9643 if (!programBinary)
9644 {
9645 return gl::error(GL_INVALID_OPERATION);
9646 }
9647
9648 if (!programBinary->setUniform2uiv(location, count, value))
9649 {
9650 return gl::error(GL_INVALID_OPERATION);
9651 }
9652 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009653 }
9654 catch(std::bad_alloc&)
9655 {
9656 return gl::error(GL_OUT_OF_MEMORY);
9657 }
9658}
9659
9660void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
9661{
9662 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
9663 location, count, value);
9664
9665 try
9666 {
9667 gl::Context *context = gl::getNonLostContext();
9668
9669 if (context)
9670 {
9671 if (context->getClientVersion() < 3)
9672 {
9673 return gl::error(GL_INVALID_OPERATION);
9674 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009675
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00009676 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9677 if (!programBinary)
9678 {
9679 return gl::error(GL_INVALID_OPERATION);
9680 }
9681
9682 if (!programBinary->setUniform3uiv(location, count, value))
9683 {
9684 return gl::error(GL_INVALID_OPERATION);
9685 }
9686 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009687 }
9688 catch(std::bad_alloc&)
9689 {
9690 return gl::error(GL_OUT_OF_MEMORY);
9691 }
9692}
9693
9694void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
9695{
9696 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
9697 location, count, value);
9698
9699 try
9700 {
9701 gl::Context *context = gl::getNonLostContext();
9702
9703 if (context)
9704 {
9705 if (context->getClientVersion() < 3)
9706 {
9707 return gl::error(GL_INVALID_OPERATION);
9708 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009709
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00009710 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9711 if (!programBinary)
9712 {
9713 return gl::error(GL_INVALID_OPERATION);
9714 }
9715
9716 if (!programBinary->setUniform4uiv(location, count, value))
9717 {
9718 return gl::error(GL_INVALID_OPERATION);
9719 }
9720 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009721 }
9722 catch(std::bad_alloc&)
9723 {
9724 return gl::error(GL_OUT_OF_MEMORY);
9725 }
9726}
9727
9728void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
9729{
9730 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
9731 buffer, drawbuffer, value);
9732
9733 try
9734 {
9735 gl::Context *context = gl::getNonLostContext();
9736
9737 if (context)
9738 {
9739 if (context->getClientVersion() < 3)
9740 {
9741 return gl::error(GL_INVALID_OPERATION);
9742 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009743
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009744 UNIMPLEMENTED();
9745 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009746 }
9747 catch(std::bad_alloc&)
9748 {
9749 return gl::error(GL_OUT_OF_MEMORY);
9750 }
9751}
9752
9753void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
9754{
9755 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
9756 buffer, drawbuffer, value);
9757
9758 try
9759 {
9760 gl::Context *context = gl::getNonLostContext();
9761
9762 if (context)
9763 {
9764 if (context->getClientVersion() < 3)
9765 {
9766 return gl::error(GL_INVALID_OPERATION);
9767 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009768
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009769 UNIMPLEMENTED();
9770 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009771 }
9772 catch(std::bad_alloc&)
9773 {
9774 return gl::error(GL_OUT_OF_MEMORY);
9775 }
9776}
9777
9778void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
9779{
9780 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
9781 buffer, drawbuffer, value);
9782
9783 try
9784 {
9785 gl::Context *context = gl::getNonLostContext();
9786
9787 if (context)
9788 {
9789 if (context->getClientVersion() < 3)
9790 {
9791 return gl::error(GL_INVALID_OPERATION);
9792 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009793
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009794 UNIMPLEMENTED();
9795 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009796 }
9797 catch(std::bad_alloc&)
9798 {
9799 return gl::error(GL_OUT_OF_MEMORY);
9800 }
9801}
9802
9803void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
9804{
9805 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
9806 buffer, drawbuffer, depth, stencil);
9807
9808 try
9809 {
9810 gl::Context *context = gl::getNonLostContext();
9811
9812 if (context)
9813 {
9814 if (context->getClientVersion() < 3)
9815 {
9816 return gl::error(GL_INVALID_OPERATION);
9817 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009818
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009819 UNIMPLEMENTED();
9820 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009821 }
9822 catch(std::bad_alloc&)
9823 {
9824 return gl::error(GL_OUT_OF_MEMORY);
9825 }
9826}
9827
9828const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index)
9829{
9830 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
9831
9832 try
9833 {
9834 gl::Context *context = gl::getNonLostContext();
9835
9836 if (context)
9837 {
9838 if (context->getClientVersion() < 3)
9839 {
9840 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL));
9841 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009842
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00009843 if (name != GL_EXTENSIONS)
9844 {
9845 return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL));
9846 }
9847
9848 if (index >= context->getNumExtensions())
9849 {
9850 return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL));
9851 }
9852
9853 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index));
9854 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009855 }
9856 catch(std::bad_alloc&)
9857 {
9858 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL));
9859 }
9860
9861 return NULL;
9862}
9863
9864void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
9865{
9866 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
9867 readTarget, writeTarget, readOffset, writeOffset, size);
9868
9869 try
9870 {
9871 gl::Context *context = gl::getNonLostContext();
9872
9873 if (context)
9874 {
9875 if (context->getClientVersion() < 3)
9876 {
9877 return gl::error(GL_INVALID_OPERATION);
9878 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009879
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00009880 gl::Buffer *readBuffer = NULL;
9881 switch (readTarget)
9882 {
9883 case GL_ARRAY_BUFFER:
9884 readBuffer = context->getArrayBuffer();
9885 break;
9886 case GL_COPY_READ_BUFFER:
9887 readBuffer = context->getCopyReadBuffer();
9888 break;
9889 case GL_COPY_WRITE_BUFFER:
9890 readBuffer = context->getCopyWriteBuffer();
9891 break;
9892 case GL_ELEMENT_ARRAY_BUFFER:
9893 readBuffer = context->getElementArrayBuffer();
9894 break;
9895 case GL_PIXEL_PACK_BUFFER:
9896 readBuffer = context->getPixelPackBuffer();
9897 break;
9898 case GL_PIXEL_UNPACK_BUFFER:
9899 readBuffer = context->getPixelUnpackBuffer();
9900 break;
9901 case GL_TRANSFORM_FEEDBACK_BUFFER:
9902 readBuffer = context->getGenericTransformFeedbackBuffer();
9903 break;
9904 case GL_UNIFORM_BUFFER:
9905 readBuffer = context->getGenericUniformBuffer();
9906 break;
9907 default:
9908 return gl::error(GL_INVALID_ENUM);
9909 }
9910
9911 gl::Buffer *writeBuffer = NULL;
9912 switch (writeTarget)
9913 {
9914 case GL_ARRAY_BUFFER:
9915 writeBuffer = context->getArrayBuffer();
9916 break;
9917 case GL_COPY_READ_BUFFER:
9918 writeBuffer = context->getCopyReadBuffer();
9919 break;
9920 case GL_COPY_WRITE_BUFFER:
9921 writeBuffer = context->getCopyWriteBuffer();
9922 break;
9923 case GL_ELEMENT_ARRAY_BUFFER:
9924 writeBuffer = context->getElementArrayBuffer();
9925 break;
9926 case GL_PIXEL_PACK_BUFFER:
9927 writeBuffer = context->getPixelPackBuffer();
9928 break;
9929 case GL_PIXEL_UNPACK_BUFFER:
9930 writeBuffer = context->getPixelUnpackBuffer();
9931 break;
9932 case GL_TRANSFORM_FEEDBACK_BUFFER:
9933 writeBuffer = context->getGenericTransformFeedbackBuffer();
9934 break;
9935 case GL_UNIFORM_BUFFER:
9936 writeBuffer = context->getGenericUniformBuffer();
9937 break;
9938 default:
9939 return gl::error(GL_INVALID_ENUM);
9940 }
9941
9942 if (!readBuffer || !writeBuffer)
9943 {
9944 return gl::error(GL_INVALID_OPERATION);
9945 }
9946
9947 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
9948 static_cast<unsigned int>(readOffset + size) > readBuffer->size() ||
9949 static_cast<unsigned int>(writeOffset + size) > writeBuffer->size())
9950 {
9951 return gl::error(GL_INVALID_VALUE);
9952 }
9953
9954 if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size)
9955 {
9956 return gl::error(GL_INVALID_VALUE);
9957 }
9958
9959 // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION)
9960
shannon.woods%transgaming.com@gtempaccount.comc53376a2013-04-13 03:41:23 +00009961 // if size is zero, the copy is a successful no-op
9962 if (size > 0)
9963 {
9964 writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
9965 }
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00009966 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009967 }
9968 catch(std::bad_alloc&)
9969 {
9970 return gl::error(GL_OUT_OF_MEMORY);
9971 }
9972}
9973
9974void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
9975{
9976 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
9977 program, uniformCount, uniformNames, uniformIndices);
9978
9979 try
9980 {
9981 gl::Context *context = gl::getNonLostContext();
9982
9983 if (context)
9984 {
9985 if (context->getClientVersion() < 3)
9986 {
9987 return gl::error(GL_INVALID_OPERATION);
9988 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009989
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00009990 if (uniformCount < 0)
9991 {
9992 return gl::error(GL_INVALID_VALUE);
9993 }
9994
9995 gl::Program *programObject = context->getProgram(program);
9996
9997 if (!programObject)
9998 {
9999 if (context->getShader(program))
10000 {
10001 return gl::error(GL_INVALID_OPERATION);
10002 }
10003 else
10004 {
10005 return gl::error(GL_INVALID_VALUE);
10006 }
10007 }
10008
10009 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10010 if (!programObject->isLinked() || !programBinary)
10011 {
10012 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10013 {
10014 uniformIndices[uniformId] = GL_INVALID_INDEX;
10015 }
10016 }
10017 else
10018 {
10019 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10020 {
10021 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
10022 }
10023 }
10024 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010025 }
10026 catch(std::bad_alloc&)
10027 {
10028 return gl::error(GL_OUT_OF_MEMORY);
10029 }
10030}
10031
10032void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
10033{
10034 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
10035 program, uniformCount, uniformIndices, pname, params);
10036
10037 try
10038 {
10039 gl::Context *context = gl::getNonLostContext();
10040
10041 if (context)
10042 {
10043 if (context->getClientVersion() < 3)
10044 {
10045 return gl::error(GL_INVALID_OPERATION);
10046 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010047
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +000010048 if (uniformCount < 0)
10049 {
10050 return gl::error(GL_INVALID_VALUE);
10051 }
10052
10053 gl::Program *programObject = context->getProgram(program);
10054
10055 if (!programObject)
10056 {
10057 if (context->getShader(program))
10058 {
10059 return gl::error(GL_INVALID_OPERATION);
10060 }
10061 else
10062 {
10063 return gl::error(GL_INVALID_VALUE);
10064 }
10065 }
10066
10067 switch (pname)
10068 {
10069 case GL_UNIFORM_TYPE:
10070 case GL_UNIFORM_SIZE:
10071 case GL_UNIFORM_NAME_LENGTH:
10072 case GL_UNIFORM_BLOCK_INDEX:
10073 case GL_UNIFORM_OFFSET:
10074 case GL_UNIFORM_ARRAY_STRIDE:
10075 case GL_UNIFORM_MATRIX_STRIDE:
10076 case GL_UNIFORM_IS_ROW_MAJOR:
10077 break;
10078 default:
10079 return gl::error(GL_INVALID_ENUM);
10080 }
10081
10082 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10083
10084 if (!programBinary && uniformCount > 0)
10085 {
10086 return gl::error(GL_INVALID_VALUE);
10087 }
10088
10089 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10090 {
10091 const GLuint index = uniformIndices[uniformId];
10092
10093 if (index >= (GLuint)programBinary->getActiveUniformCount())
10094 {
10095 return gl::error(GL_INVALID_VALUE);
10096 }
10097 }
10098
10099 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10100 {
10101 const GLuint index = uniformIndices[uniformId];
10102 params[uniformId] = programBinary->getActiveUniformi(index, pname);
10103 }
10104 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010105 }
10106 catch(std::bad_alloc&)
10107 {
10108 return gl::error(GL_OUT_OF_MEMORY);
10109 }
10110}
10111
10112GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
10113{
10114 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
10115
10116 try
10117 {
10118 gl::Context *context = gl::getNonLostContext();
10119
10120 if (context)
10121 {
10122 if (context->getClientVersion() < 3)
10123 {
shannonwoods@chromium.org42766252013-05-30 00:07:12 +000010124 return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010125 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010126
shannonwoods@chromium.org42766252013-05-30 00:07:12 +000010127 gl::Program *programObject = context->getProgram(program);
10128
10129 if (!programObject)
10130 {
10131 if (context->getShader(program))
10132 {
10133 return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
10134 }
10135 else
10136 {
10137 return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX);
10138 }
10139 }
10140
10141 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10142 if (!programBinary)
10143 {
10144 return GL_INVALID_INDEX;
10145 }
10146
10147 return programBinary->getUniformBlockIndex(uniformBlockName);
10148 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010149 }
10150 catch(std::bad_alloc&)
10151 {
10152 return gl::error(GL_OUT_OF_MEMORY, 0);
10153 }
10154
10155 return 0;
10156}
10157
10158void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
10159{
10160 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
10161 program, uniformBlockIndex, pname, params);
10162
10163 try
10164 {
10165 gl::Context *context = gl::getNonLostContext();
10166
10167 if (context)
10168 {
10169 if (context->getClientVersion() < 3)
10170 {
10171 return gl::error(GL_INVALID_OPERATION);
10172 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +000010173 gl::Program *programObject = context->getProgram(program);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010174
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +000010175 if (!programObject)
10176 {
10177 if (context->getShader(program))
10178 {
10179 return gl::error(GL_INVALID_OPERATION);
10180 }
10181 else
10182 {
10183 return gl::error(GL_INVALID_VALUE);
10184 }
10185 }
10186
10187 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10188
10189 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
10190 {
10191 return gl::error(GL_INVALID_VALUE);
10192 }
10193
10194 switch (pname)
10195 {
10196 case GL_UNIFORM_BLOCK_BINDING:
10197 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
10198 break;
10199
10200 case GL_UNIFORM_BLOCK_DATA_SIZE:
10201 case GL_UNIFORM_BLOCK_NAME_LENGTH:
10202 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
10203 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
10204 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
10205 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
10206 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
10207 break;
10208
10209 default:
10210 return gl::error(GL_INVALID_ENUM);
10211 }
10212 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010213 }
10214 catch(std::bad_alloc&)
10215 {
10216 return gl::error(GL_OUT_OF_MEMORY);
10217 }
10218}
10219
10220void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
10221{
10222 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
10223 program, uniformBlockIndex, bufSize, length, uniformBlockName);
10224
10225 try
10226 {
10227 gl::Context *context = gl::getNonLostContext();
10228
10229 if (context)
10230 {
10231 if (context->getClientVersion() < 3)
10232 {
10233 return gl::error(GL_INVALID_OPERATION);
10234 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010235
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +000010236 gl::Program *programObject = context->getProgram(program);
10237
10238 if (!programObject)
10239 {
10240 if (context->getShader(program))
10241 {
10242 return gl::error(GL_INVALID_OPERATION);
10243 }
10244 else
10245 {
10246 return gl::error(GL_INVALID_VALUE);
10247 }
10248 }
10249
10250 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10251
10252 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
10253 {
10254 return gl::error(GL_INVALID_VALUE);
10255 }
10256
10257 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
10258 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010259 }
10260 catch(std::bad_alloc&)
10261 {
10262 return gl::error(GL_OUT_OF_MEMORY);
10263 }
10264}
10265
10266void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
10267{
10268 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
10269 program, uniformBlockIndex, uniformBlockBinding);
10270
10271 try
10272 {
10273 gl::Context *context = gl::getNonLostContext();
10274
10275 if (context)
10276 {
10277 if (context->getClientVersion() < 3)
10278 {
10279 return gl::error(GL_INVALID_OPERATION);
10280 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010281
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +000010282 if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings())
10283 {
10284 return gl::error(GL_INVALID_VALUE);
10285 }
10286
10287 gl::Program *programObject = context->getProgram(program);
10288
10289 if (!programObject)
10290 {
10291 if (context->getShader(program))
10292 {
10293 return gl::error(GL_INVALID_OPERATION);
10294 }
10295 else
10296 {
10297 return gl::error(GL_INVALID_VALUE);
10298 }
10299 }
10300
10301 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10302
10303 // if never linked, there won't be any uniform blocks
10304 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
10305 {
10306 return gl::error(GL_INVALID_VALUE);
10307 }
10308
10309 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
10310 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010311 }
10312 catch(std::bad_alloc&)
10313 {
10314 return gl::error(GL_OUT_OF_MEMORY);
10315 }
10316}
10317
10318void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
10319{
10320 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
10321 mode, first, count, instanceCount);
10322
10323 try
10324 {
10325 gl::Context *context = gl::getNonLostContext();
10326
10327 if (context)
10328 {
10329 if (context->getClientVersion() < 3)
10330 {
10331 return gl::error(GL_INVALID_OPERATION);
10332 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010333
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010334 UNIMPLEMENTED();
10335 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010336 }
10337 catch(std::bad_alloc&)
10338 {
10339 return gl::error(GL_OUT_OF_MEMORY);
10340 }
10341}
10342
10343void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
10344{
10345 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
10346 mode, count, type, indices, instanceCount);
10347
10348 try
10349 {
10350 gl::Context *context = gl::getNonLostContext();
10351
10352 if (context)
10353 {
10354 if (context->getClientVersion() < 3)
10355 {
10356 return gl::error(GL_INVALID_OPERATION);
10357 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010358
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010359 UNIMPLEMENTED();
10360 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010361 }
10362 catch(std::bad_alloc&)
10363 {
10364 return gl::error(GL_OUT_OF_MEMORY);
10365 }
10366}
10367
10368GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags)
10369{
10370 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
10371
10372 try
10373 {
10374 gl::Context *context = gl::getNonLostContext();
10375
10376 if (context)
10377 {
10378 if (context->getClientVersion() < 3)
10379 {
10380 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(NULL));
10381 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010382
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010383 UNIMPLEMENTED();
10384 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010385 }
10386 catch(std::bad_alloc&)
10387 {
10388 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL));
10389 }
10390
10391 return NULL;
10392}
10393
10394GLboolean __stdcall glIsSync(GLsync sync)
10395{
10396 EVENT("(GLsync sync = 0x%0.8p)", sync);
10397
10398 try
10399 {
10400 gl::Context *context = gl::getNonLostContext();
10401
10402 if (context)
10403 {
10404 if (context->getClientVersion() < 3)
10405 {
10406 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10407 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010408
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010409 UNIMPLEMENTED();
10410 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010411 }
10412 catch(std::bad_alloc&)
10413 {
10414 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10415 }
10416
10417 return GL_FALSE;
10418}
10419
10420void __stdcall glDeleteSync(GLsync sync)
10421{
10422 EVENT("(GLsync sync = 0x%0.8p)", sync);
10423
10424 try
10425 {
10426 gl::Context *context = gl::getNonLostContext();
10427
10428 if (context)
10429 {
10430 if (context->getClientVersion() < 3)
10431 {
10432 return gl::error(GL_INVALID_OPERATION);
10433 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010434
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010435 UNIMPLEMENTED();
10436 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010437 }
10438 catch(std::bad_alloc&)
10439 {
10440 return gl::error(GL_OUT_OF_MEMORY);
10441 }
10442}
10443
10444GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
10445{
10446 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
10447 sync, flags, timeout);
10448
10449 try
10450 {
10451 gl::Context *context = gl::getNonLostContext();
10452
10453 if (context)
10454 {
10455 if (context->getClientVersion() < 3)
10456 {
10457 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10458 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010459
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010460 UNIMPLEMENTED();
10461 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010462 }
10463 catch(std::bad_alloc&)
10464 {
10465 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10466 }
10467
10468 return GL_FALSE;
10469}
10470
10471void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
10472{
10473 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
10474 sync, flags, timeout);
10475
10476 try
10477 {
10478 gl::Context *context = gl::getNonLostContext();
10479
10480 if (context)
10481 {
10482 if (context->getClientVersion() < 3)
10483 {
10484 return gl::error(GL_INVALID_OPERATION);
10485 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010486
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010487 UNIMPLEMENTED();
10488 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010489 }
10490 catch(std::bad_alloc&)
10491 {
10492 return gl::error(GL_OUT_OF_MEMORY);
10493 }
10494}
10495
10496void __stdcall glGetInteger64v(GLenum pname, GLint64* params)
10497{
10498 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
10499 pname, params);
10500
10501 try
10502 {
10503 gl::Context *context = gl::getNonLostContext();
10504
10505 if (context)
10506 {
10507 if (context->getClientVersion() < 3)
10508 {
10509 return gl::error(GL_INVALID_OPERATION);
10510 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010511
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010512 UNIMPLEMENTED();
10513 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010514 }
10515 catch(std::bad_alloc&)
10516 {
10517 return gl::error(GL_OUT_OF_MEMORY);
10518 }
10519}
10520
10521void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
10522{
10523 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
10524 sync, pname, bufSize, length, values);
10525
10526 try
10527 {
10528 gl::Context *context = gl::getNonLostContext();
10529
10530 if (context)
10531 {
10532 if (context->getClientVersion() < 3)
10533 {
10534 return gl::error(GL_INVALID_OPERATION);
10535 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010536
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010537 UNIMPLEMENTED();
10538 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010539 }
10540 catch(std::bad_alloc&)
10541 {
10542 return gl::error(GL_OUT_OF_MEMORY);
10543 }
10544}
10545
10546void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
10547{
10548 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
10549 target, index, data);
10550
10551 try
10552 {
10553 gl::Context *context = gl::getNonLostContext();
10554
10555 if (context)
10556 {
10557 if (context->getClientVersion() < 3)
10558 {
10559 return gl::error(GL_INVALID_OPERATION);
10560 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010561
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010562 UNIMPLEMENTED();
10563 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010564 }
10565 catch(std::bad_alloc&)
10566 {
10567 return gl::error(GL_OUT_OF_MEMORY);
10568 }
10569}
10570
10571void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
10572{
10573 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
10574 target, pname, params);
10575
10576 try
10577 {
10578 gl::Context *context = gl::getNonLostContext();
10579
10580 if (context)
10581 {
10582 if (context->getClientVersion() < 3)
10583 {
10584 return gl::error(GL_INVALID_OPERATION);
10585 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010586
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010587 UNIMPLEMENTED();
10588 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010589 }
10590 catch(std::bad_alloc&)
10591 {
10592 return gl::error(GL_OUT_OF_MEMORY);
10593 }
10594}
10595
10596void __stdcall glGenSamplers(GLsizei count, GLuint* samplers)
10597{
10598 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
10599
10600 try
10601 {
10602 gl::Context *context = gl::getNonLostContext();
10603
10604 if (context)
10605 {
10606 if (context->getClientVersion() < 3)
10607 {
10608 return gl::error(GL_INVALID_OPERATION);
10609 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010610
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010611 UNIMPLEMENTED();
10612 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010613 }
10614 catch(std::bad_alloc&)
10615 {
10616 return gl::error(GL_OUT_OF_MEMORY);
10617 }
10618}
10619
10620void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers)
10621{
10622 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
10623
10624 try
10625 {
10626 gl::Context *context = gl::getNonLostContext();
10627
10628 if (context)
10629 {
10630 if (context->getClientVersion() < 3)
10631 {
10632 return gl::error(GL_INVALID_OPERATION);
10633 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010634
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010635 UNIMPLEMENTED();
10636 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010637 }
10638 catch(std::bad_alloc&)
10639 {
10640 return gl::error(GL_OUT_OF_MEMORY);
10641 }
10642}
10643
10644GLboolean __stdcall glIsSampler(GLuint sampler)
10645{
10646 EVENT("(GLuint sampler = %u)", sampler);
10647
10648 try
10649 {
10650 gl::Context *context = gl::getNonLostContext();
10651
10652 if (context)
10653 {
10654 if (context->getClientVersion() < 3)
10655 {
10656 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10657 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010658
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010659 UNIMPLEMENTED();
10660 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010661 }
10662 catch(std::bad_alloc&)
10663 {
10664 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10665 }
10666
10667 return GL_FALSE;
10668}
10669
10670void __stdcall glBindSampler(GLuint unit, GLuint sampler)
10671{
10672 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
10673
10674 try
10675 {
10676 gl::Context *context = gl::getNonLostContext();
10677
10678 if (context)
10679 {
10680 if (context->getClientVersion() < 3)
10681 {
10682 return gl::error(GL_INVALID_OPERATION);
10683 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010684
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010685 UNIMPLEMENTED();
10686 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010687 }
10688 catch(std::bad_alloc&)
10689 {
10690 return gl::error(GL_OUT_OF_MEMORY);
10691 }
10692}
10693
10694void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
10695{
10696 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
10697
10698 try
10699 {
10700 gl::Context *context = gl::getNonLostContext();
10701
10702 if (context)
10703 {
10704 if (context->getClientVersion() < 3)
10705 {
10706 return gl::error(GL_INVALID_OPERATION);
10707 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010708
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010709 UNIMPLEMENTED();
10710 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010711 }
10712 catch(std::bad_alloc&)
10713 {
10714 return gl::error(GL_OUT_OF_MEMORY);
10715 }
10716}
10717
10718void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
10719{
10720 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLint* param = 0x%0.8p)",
10721 sampler, pname, param);
10722
10723 try
10724 {
10725 gl::Context *context = gl::getNonLostContext();
10726
10727 if (context)
10728 {
10729 if (context->getClientVersion() < 3)
10730 {
10731 return gl::error(GL_INVALID_OPERATION);
10732 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010733
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010734 UNIMPLEMENTED();
10735 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010736 }
10737 catch(std::bad_alloc&)
10738 {
10739 return gl::error(GL_OUT_OF_MEMORY);
10740 }
10741}
10742
10743void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
10744{
10745 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
10746
10747 try
10748 {
10749 gl::Context *context = gl::getNonLostContext();
10750
10751 if (context)
10752 {
10753 if (context->getClientVersion() < 3)
10754 {
10755 return gl::error(GL_INVALID_OPERATION);
10756 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010757
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010758 UNIMPLEMENTED();
10759 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010760 }
10761 catch(std::bad_alloc&)
10762 {
10763 return gl::error(GL_OUT_OF_MEMORY);
10764 }
10765}
10766
10767void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
10768{
10769 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLfloat* param = 0x%0.8p)", sampler, pname, param);
10770
10771 try
10772 {
10773 gl::Context *context = gl::getNonLostContext();
10774
10775 if (context)
10776 {
10777 if (context->getClientVersion() < 3)
10778 {
10779 return gl::error(GL_INVALID_OPERATION);
10780 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010781
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010782 UNIMPLEMENTED();
10783 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010784 }
10785 catch(std::bad_alloc&)
10786 {
10787 return gl::error(GL_OUT_OF_MEMORY);
10788 }
10789}
10790
10791void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
10792{
10793 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
10794
10795 try
10796 {
10797 gl::Context *context = gl::getNonLostContext();
10798
10799 if (context)
10800 {
10801 if (context->getClientVersion() < 3)
10802 {
10803 return gl::error(GL_INVALID_OPERATION);
10804 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010805
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010806 UNIMPLEMENTED();
10807 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010808 }
10809 catch(std::bad_alloc&)
10810 {
10811 return gl::error(GL_OUT_OF_MEMORY);
10812 }
10813}
10814
10815void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
10816{
10817 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
10818
10819 try
10820 {
10821 gl::Context *context = gl::getNonLostContext();
10822
10823 if (context)
10824 {
10825 if (context->getClientVersion() < 3)
10826 {
10827 return gl::error(GL_INVALID_OPERATION);
10828 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010829
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010830 UNIMPLEMENTED();
10831 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010832 }
10833 catch(std::bad_alloc&)
10834 {
10835 return gl::error(GL_OUT_OF_MEMORY);
10836 }
10837}
10838
10839void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor)
10840{
10841 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
10842
10843 try
10844 {
shannon.woods%transgaming.com@gtempaccount.com8736bd62013-04-13 03:35:41 +000010845 if (index >= gl::MAX_VERTEX_ATTRIBS)
10846 {
10847 return gl::error(GL_INVALID_VALUE);
10848 }
10849
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010850 gl::Context *context = gl::getNonLostContext();
10851
10852 if (context)
10853 {
10854 if (context->getClientVersion() < 3)
10855 {
10856 return gl::error(GL_INVALID_OPERATION);
10857 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010858
shannon.woods%transgaming.com@gtempaccount.com8736bd62013-04-13 03:35:41 +000010859 context->setVertexAttribDivisor(index, divisor);
10860 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010861 }
10862 catch(std::bad_alloc&)
10863 {
10864 return gl::error(GL_OUT_OF_MEMORY);
10865 }
10866}
10867
10868void __stdcall glBindTransformFeedback(GLenum target, GLuint id)
10869{
10870 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
10871
10872 try
10873 {
10874 gl::Context *context = gl::getNonLostContext();
10875
10876 if (context)
10877 {
10878 if (context->getClientVersion() < 3)
10879 {
10880 return gl::error(GL_INVALID_OPERATION);
10881 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010882
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010883 UNIMPLEMENTED();
10884 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010885 }
10886 catch(std::bad_alloc&)
10887 {
10888 return gl::error(GL_OUT_OF_MEMORY);
10889 }
10890}
10891
10892void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
10893{
10894 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
10895
10896 try
10897 {
10898 gl::Context *context = gl::getNonLostContext();
10899
10900 if (context)
10901 {
10902 if (context->getClientVersion() < 3)
10903 {
10904 return gl::error(GL_INVALID_OPERATION);
10905 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010906
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010907 UNIMPLEMENTED();
10908 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010909 }
10910 catch(std::bad_alloc&)
10911 {
10912 return gl::error(GL_OUT_OF_MEMORY);
10913 }
10914}
10915
10916void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids)
10917{
10918 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
10919
10920 try
10921 {
10922 gl::Context *context = gl::getNonLostContext();
10923
10924 if (context)
10925 {
10926 if (context->getClientVersion() < 3)
10927 {
10928 return gl::error(GL_INVALID_OPERATION);
10929 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010930
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010931 UNIMPLEMENTED();
10932 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010933 }
10934 catch(std::bad_alloc&)
10935 {
10936 return gl::error(GL_OUT_OF_MEMORY);
10937 }
10938}
10939
10940GLboolean __stdcall glIsTransformFeedback(GLuint id)
10941{
10942 EVENT("(GLuint id = %u)", id);
10943
10944 try
10945 {
10946 gl::Context *context = gl::getNonLostContext();
10947
10948 if (context)
10949 {
10950 if (context->getClientVersion() < 3)
10951 {
10952 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10953 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010954
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010955 UNIMPLEMENTED();
10956 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010957 }
10958 catch(std::bad_alloc&)
10959 {
10960 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10961 }
10962
10963 return GL_FALSE;
10964}
10965
10966void __stdcall glPauseTransformFeedback(void)
10967{
10968 EVENT("(void)");
10969
10970 try
10971 {
10972 gl::Context *context = gl::getNonLostContext();
10973
10974 if (context)
10975 {
10976 if (context->getClientVersion() < 3)
10977 {
10978 return gl::error(GL_INVALID_OPERATION);
10979 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010980
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010981 UNIMPLEMENTED();
10982 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010983 }
10984 catch(std::bad_alloc&)
10985 {
10986 return gl::error(GL_OUT_OF_MEMORY);
10987 }
10988}
10989
10990void __stdcall glResumeTransformFeedback(void)
10991{
10992 EVENT("(void)");
10993
10994 try
10995 {
10996 gl::Context *context = gl::getNonLostContext();
10997
10998 if (context)
10999 {
11000 if (context->getClientVersion() < 3)
11001 {
11002 return gl::error(GL_INVALID_OPERATION);
11003 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011004
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011005 UNIMPLEMENTED();
11006 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011007 }
11008 catch(std::bad_alloc&)
11009 {
11010 return gl::error(GL_OUT_OF_MEMORY);
11011 }
11012}
11013
11014void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
11015{
11016 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
11017 program, bufSize, length, binaryFormat, binary);
11018
11019 try
11020 {
11021 gl::Context *context = gl::getNonLostContext();
11022
11023 if (context)
11024 {
11025 if (context->getClientVersion() < 3)
11026 {
11027 return gl::error(GL_INVALID_OPERATION);
11028 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011029
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011030 UNIMPLEMENTED();
11031 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011032 }
11033 catch(std::bad_alloc&)
11034 {
11035 return gl::error(GL_OUT_OF_MEMORY);
11036 }
11037}
11038
11039void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
11040{
11041 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
11042 program, binaryFormat, binary, length);
11043
11044 try
11045 {
11046 gl::Context *context = gl::getNonLostContext();
11047
11048 if (context)
11049 {
11050 if (context->getClientVersion() < 3)
11051 {
11052 return gl::error(GL_INVALID_OPERATION);
11053 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011054
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011055 UNIMPLEMENTED();
11056 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011057 }
11058 catch(std::bad_alloc&)
11059 {
11060 return gl::error(GL_OUT_OF_MEMORY);
11061 }
11062}
11063
11064void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value)
11065{
11066 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
11067 program, pname, value);
11068
11069 try
11070 {
11071 gl::Context *context = gl::getNonLostContext();
11072
11073 if (context)
11074 {
11075 if (context->getClientVersion() < 3)
11076 {
11077 return gl::error(GL_INVALID_OPERATION);
11078 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011079
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011080 UNIMPLEMENTED();
11081 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011082 }
11083 catch(std::bad_alloc&)
11084 {
11085 return gl::error(GL_OUT_OF_MEMORY);
11086 }
11087}
11088
11089void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
11090{
11091 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
11092 target, numAttachments, attachments);
11093
11094 try
11095 {
11096 gl::Context *context = gl::getNonLostContext();
11097
11098 if (context)
11099 {
11100 if (context->getClientVersion() < 3)
11101 {
11102 return gl::error(GL_INVALID_OPERATION);
11103 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011104
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +000011105 if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
11106 {
11107 return;
11108 }
11109
11110 int maxDimension = context->getMaximumRenderbufferDimension();
11111 context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension);
11112 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011113 }
11114 catch(std::bad_alloc&)
11115 {
11116 return gl::error(GL_OUT_OF_MEMORY);
11117 }
11118}
11119
11120void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
11121{
11122 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
11123 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
11124 target, numAttachments, attachments, x, y, width, height);
11125
11126 try
11127 {
11128 gl::Context *context = gl::getNonLostContext();
11129
11130 if (context)
11131 {
11132 if (context->getClientVersion() < 3)
11133 {
11134 return gl::error(GL_INVALID_OPERATION);
11135 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011136
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +000011137 if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
11138 {
11139 return;
11140 }
11141
11142 context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height);
11143 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011144 }
11145 catch(std::bad_alloc&)
11146 {
11147 return gl::error(GL_OUT_OF_MEMORY);
11148 }
11149}
11150
11151void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
11152{
11153 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
11154 target, levels, internalformat, width, height);
11155
11156 try
11157 {
11158 gl::Context *context = gl::getNonLostContext();
11159
11160 if (context)
11161 {
11162 if (context->getClientVersion() < 3)
11163 {
11164 return gl::error(GL_INVALID_OPERATION);
11165 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011166
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +000011167 if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
11168 {
11169 return;
11170 }
11171
11172 switch (target)
11173 {
11174 case GL_TEXTURE_2D:
11175 {
11176 gl::Texture2D *texture2d = context->getTexture2D();
11177 texture2d->storage(levels, internalformat, width, height);
11178 }
11179 break;
11180
11181 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
11182 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
11183 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
11184 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
11185 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
11186 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
11187 {
11188 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
11189 textureCube->storage(levels, internalformat, width);
11190 }
11191 break;
11192
11193 default:
11194 return gl::error(GL_INVALID_ENUM);
11195 }
11196 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011197 }
11198 catch(std::bad_alloc&)
11199 {
11200 return gl::error(GL_OUT_OF_MEMORY);
11201 }
11202}
11203
11204void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
11205{
11206 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
11207 "GLsizei height = %d, GLsizei depth = %d)",
11208 target, levels, internalformat, width, height, depth);
11209
11210 try
11211 {
11212 gl::Context *context = gl::getNonLostContext();
11213
11214 if (context)
11215 {
11216 if (context->getClientVersion() < 3)
11217 {
11218 return gl::error(GL_INVALID_OPERATION);
11219 }
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +000011220
11221 if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
11222 {
11223 return;
11224 }
11225
11226 switch (target)
11227 {
11228 case GL_TEXTURE_3D:
11229 {
11230 gl::Texture3D *texture3d = context->getTexture3D();
11231 texture3d->storage(levels, internalformat, width, height, depth);
11232 }
11233 break;
11234
11235 case GL_TEXTURE_2D_ARRAY:
11236 {
11237 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
11238 texture2darray->storage(levels, internalformat, width, height, depth);
11239 }
11240 break;
11241
11242 default:
11243 return gl::error(GL_INVALID_ENUM);
11244 }
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +000011245 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011246 }
11247 catch(std::bad_alloc&)
11248 {
11249 return gl::error(GL_OUT_OF_MEMORY);
11250 }
11251}
11252
11253void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
11254{
11255 EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
11256 "GLint* params = 0x%0.8p)",
11257 target, internalformat, pname, bufSize, params);
11258
11259 try
11260 {
11261 gl::Context *context = gl::getNonLostContext();
11262
11263 if (context)
11264 {
11265 if (context->getClientVersion() < 3)
11266 {
11267 return gl::error(GL_INVALID_OPERATION);
11268 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011269
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011270 UNIMPLEMENTED();
11271 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011272 }
11273 catch(std::bad_alloc&)
11274 {
11275 return gl::error(GL_OUT_OF_MEMORY);
11276 }
11277}
11278
11279// Extension functions
11280
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011281void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
11282 GLbitfield mask, GLenum filter)
11283{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000011284 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011285 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
11286 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
11287 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
11288
11289 try
11290 {
11291 switch (filter)
11292 {
11293 case GL_NEAREST:
11294 break;
11295 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011296 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011297 }
11298
11299 if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0)
11300 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011301 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011302 }
11303
11304 if (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0)
11305 {
11306 ERR("Scaling and flipping in BlitFramebufferANGLE not supported by this implementation");
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011307 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011308 }
11309
daniel@transgaming.com9d788502011-11-09 17:46:55 +000011310 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011311
11312 if (context)
11313 {
11314 if (context->getReadFramebufferHandle() == context->getDrawFramebufferHandle())
11315 {
11316 ERR("Blits with the same source and destination framebuffer are not supported by this implementation.");
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011317 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011318 }
11319
11320 context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask);
11321 }
11322 }
11323 catch(std::bad_alloc&)
11324 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011325 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011326 }
11327}
11328
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +000011329void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
11330 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011331{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000011332 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +000011333 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +000011334 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011335 target, level, internalformat, width, height, depth, border, format, type, pixels);
11336
11337 try
11338 {
11339 UNIMPLEMENTED(); // FIXME
11340 }
11341 catch(std::bad_alloc&)
11342 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011343 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011344 }
11345}
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011346
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011347void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
11348 GLenum *binaryFormat, void *binary)
11349{
apatrick@chromium.org90080e32012-07-09 22:15:33 +000011350 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 +000011351 program, bufSize, length, binaryFormat, binary);
11352
11353 try
11354 {
11355 gl::Context *context = gl::getNonLostContext();
11356
11357 if (context)
11358 {
11359 gl::Program *programObject = context->getProgram(program);
11360
daniel@transgaming.com716056c2012-07-24 18:38:59 +000011361 if (!programObject || !programObject->isLinked())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011362 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011363 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011364 }
11365
11366 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
11367
11368 if (!programBinary)
11369 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011370 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011371 }
11372
apatrick@chromium.org90080e32012-07-09 22:15:33 +000011373 if (!programBinary->save(binary, bufSize, length))
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 }
apatrick@chromium.org90080e32012-07-09 22:15:33 +000011377
11378 *binaryFormat = GL_PROGRAM_BINARY_ANGLE;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011379 }
11380 }
11381 catch(std::bad_alloc&)
11382 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011383 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011384 }
11385}
11386
11387void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat,
11388 const void *binary, GLint length)
11389{
11390 EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
11391 program, binaryFormat, binary, length);
11392
11393 try
11394 {
11395 gl::Context *context = gl::getNonLostContext();
11396
11397 if (context)
11398 {
11399 if (binaryFormat != GL_PROGRAM_BINARY_ANGLE)
11400 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011401 return gl::error(GL_INVALID_ENUM);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011402 }
11403
11404 gl::Program *programObject = context->getProgram(program);
11405
11406 if (!programObject)
11407 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011408 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011409 }
11410
daniel@transgaming.com95d29422012-07-24 18:36:10 +000011411 context->setProgramBinary(program, binary, length);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011412 }
11413 }
11414 catch(std::bad_alloc&)
11415 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011416 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011417 }
11418}
11419
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011420void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
11421{
11422 EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
11423
11424 try
11425 {
11426 gl::Context *context = gl::getNonLostContext();
11427
11428 if (context)
11429 {
11430 if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets())
11431 {
11432 return gl::error(GL_INVALID_VALUE);
11433 }
11434
11435 if (context->getDrawFramebufferHandle() == 0)
11436 {
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011437 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011438 {
11439 return gl::error(GL_INVALID_OPERATION);
11440 }
11441
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011442 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011443 {
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011444 return gl::error(GL_INVALID_OPERATION);
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011445 }
11446 }
11447 else
11448 {
11449 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
11450 {
11451 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
11452 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
11453 {
11454 return gl::error(GL_INVALID_OPERATION);
11455 }
11456 }
11457 }
11458
11459 gl::Framebuffer *framebuffer = context->getDrawFramebuffer();
11460
11461 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
11462 {
11463 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
11464 }
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011465
11466 for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++)
11467 {
11468 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
11469 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011470 }
11471 }
11472 catch (std::bad_alloc&)
11473 {
11474 return gl::error(GL_OUT_OF_MEMORY);
11475 }
11476}
11477
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011478__eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname)
11479{
11480 struct Extension
11481 {
11482 const char *name;
11483 __eglMustCastToProperFunctionPointerType address;
11484 };
11485
11486 static const Extension glExtensions[] =
11487 {
11488 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +000011489 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +000011490 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000011491 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
11492 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
11493 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
11494 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
11495 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
11496 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
11497 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +000011498 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +000011499 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +000011500 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
11501 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
11502 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
11503 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000011504 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
11505 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
11506 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
11507 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
11508 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
11509 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
11510 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +000011511 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +000011512 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
11513 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
11514 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011515 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
11516 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011517
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +000011518 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011519 {
11520 if (strcmp(procname, glExtensions[ext].name) == 0)
11521 {
11522 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
11523 }
11524 }
11525
11526 return NULL;
11527}
11528
daniel@transgaming.com17f548c2011-11-09 17:47:02 +000011529// Non-public functions used by EGL
11530
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000011531bool __stdcall glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011532{
11533 EVENT("(egl::Surface* surface = 0x%0.8p)",
11534 surface);
11535
11536 try
11537 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +000011538 gl::Context *context = gl::getNonLostContext();
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011539
11540 if (context)
11541 {
11542 gl::Texture2D *textureObject = context->getTexture2D();
11543
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000011544 if (textureObject->isImmutable())
11545 {
11546 return false;
11547 }
11548
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011549 if (textureObject)
11550 {
11551 textureObject->bindTexImage(surface);
11552 }
11553 }
11554 }
11555 catch(std::bad_alloc&)
11556 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011557 return gl::error(GL_OUT_OF_MEMORY, false);
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011558 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000011559
11560 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011561}
11562
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011563}