blob: 5a34f04f1335880ef424cb8c6d0a1dd4397d30eb [file] [log] [blame]
shannon.woods@transgaming.combdf2d802013-02-28 23:16:20 +00001#include "precompiled.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002//
shannon.woods%transgaming.com@gtempaccount.com8dce6512013-04-13 03:42:19 +00003// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004// Use of this source code is governed by a BSD-style license that can be
5// found in the LICENSE file.
6//
7
8// libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions.
9
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +000010#include "common/version.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000011
12#include "libGLESv2/main.h"
shannonwoods@chromium.orga2ecfcc2013-05-30 00:11:59 +000013#include "common/utilities.h"
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +000014#include "libGLESv2/formatutils.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000015#include "libGLESv2/Buffer.h"
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000016#include "libGLESv2/Fence.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000017#include "libGLESv2/Framebuffer.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000018#include "libGLESv2/Renderbuffer.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000019#include "libGLESv2/Program.h"
apatrick@chromium.orgea09f9b2012-06-08 00:45:32 +000020#include "libGLESv2/ProgramBinary.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000021#include "libGLESv2/Texture.h"
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000022#include "libGLESv2/Query.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000023#include "libGLESv2/Context.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000024
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +000025bool validImageSize(const gl::Context *context, GLint level, GLsizei width, GLsizei height, GLsizei depth)
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000026{
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +000027 if (level < 0 || width < 0 || height < 0 || depth < 0)
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000028 {
29 return false;
30 }
31
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +000032 if (context->supportsNonPower2Texture())
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000033 {
34 return true;
35 }
36
37 if (level == 0)
38 {
39 return true;
40 }
41
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +000042 if (gl::isPow2(width) && gl::isPow2(height) && gl::isPow2(depth))
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +000043 {
44 return true;
45 }
46
47 return false;
48}
49
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +000050bool validCompressedImageSize(GLsizei width, GLsizei height)
51{
52 if (width != 1 && width != 2 && width % 4 != 0)
53 {
54 return false;
55 }
56
57 if (height != 1 && height != 2 && height % 4 != 0)
58 {
59 return false;
60 }
61
62 return true;
63}
64
daniel@transgaming.com8833dd22012-06-05 19:49:58 +000065// Verify that format/type are one of the combinations from table 3.4.
66bool checkTextureFormatType(GLenum format, GLenum type)
67{
68 // validate <format> by itself (used as secondary key below)
69 switch (format)
70 {
71 case GL_RGBA:
72 case GL_BGRA_EXT:
73 case GL_RGB:
74 case GL_ALPHA:
75 case GL_LUMINANCE:
76 case GL_LUMINANCE_ALPHA:
77 case GL_DEPTH_COMPONENT:
78 case GL_DEPTH_STENCIL_OES:
79 break;
80 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000081 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +000082 }
83
84 // invalid <type> -> sets INVALID_ENUM
85 // invalid <format>+<type> combination -> sets INVALID_OPERATION
86 switch (type)
87 {
88 case GL_UNSIGNED_BYTE:
89 switch (format)
90 {
91 case GL_RGBA:
92 case GL_BGRA_EXT:
93 case GL_RGB:
94 case GL_ALPHA:
95 case GL_LUMINANCE:
96 case GL_LUMINANCE_ALPHA:
97 return true;
98 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000099 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000100 }
101
102 case GL_FLOAT:
103 case GL_HALF_FLOAT_OES:
104 switch (format)
105 {
106 case GL_RGBA:
107 case GL_RGB:
108 case GL_ALPHA:
109 case GL_LUMINANCE:
110 case GL_LUMINANCE_ALPHA:
111 return true;
112 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000113 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000114 }
115
116 case GL_UNSIGNED_SHORT_4_4_4_4:
117 case GL_UNSIGNED_SHORT_5_5_5_1:
118 switch (format)
119 {
120 case GL_RGBA:
121 return true;
122 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000123 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000124 }
125
126 case GL_UNSIGNED_SHORT_5_6_5:
127 switch (format)
128 {
129 case GL_RGB:
130 return true;
131 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000132 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000133 }
134
135 case GL_UNSIGNED_SHORT:
136 case GL_UNSIGNED_INT:
137 switch (format)
138 {
139 case GL_DEPTH_COMPONENT:
140 return true;
141 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000142 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000143 }
144
145 case GL_UNSIGNED_INT_24_8_OES:
146 switch (format)
147 {
148 case GL_DEPTH_STENCIL_OES:
149 return true;
150 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000151 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000152 }
153
154 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000155 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com8833dd22012-06-05 19:49:58 +0000156 }
157}
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000158
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000159bool validateSubImageParams2D(bool compressed, GLsizei width, GLsizei height,
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000160 GLint xoffset, GLint yoffset, GLint level, GLenum format, GLenum type,
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000161 gl::Texture2D *texture)
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000162{
163 if (!texture)
164 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000165 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000166 }
167
daniel@transgaming.com92f49922012-05-09 15:49:19 +0000168 if (compressed != texture->isCompressed(level))
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000169 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000170 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000171 }
172
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000173 if (format != GL_NONE)
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000174 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000175 GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000176 if (internalformat != texture->getInternalFormat(level))
177 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000178 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000179 }
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000180 }
181
182 if (compressed)
183 {
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000184 if ((width % 4 != 0 && width != texture->getWidth(0)) ||
185 (height % 4 != 0 && height != texture->getHeight(0)))
186 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000187 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000188 }
189 }
190
191 if (xoffset + width > texture->getWidth(level) ||
192 yoffset + height > texture->getHeight(level))
193 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000194 return gl::error(GL_INVALID_VALUE, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000195 }
196
197 return true;
198}
199
200bool validateSubImageParamsCube(bool compressed, GLsizei width, GLsizei height,
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000201 GLint xoffset, GLint yoffset, GLenum target, GLint level, GLenum format, GLenum type,
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000202 gl::TextureCubeMap *texture)
203{
204 if (!texture)
205 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000206 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000207 }
208
daniel@transgaming.com4df88e82012-05-09 15:49:24 +0000209 if (compressed != texture->isCompressed(target, level))
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000210 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000211 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000212 }
213
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000214 if (format != GL_NONE)
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000215 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000216 GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000217 if (internalformat != texture->getInternalFormat(target, level))
218 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000219 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +0000220 }
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +0000221 }
222
223 if (compressed)
224 {
daniel@transgaming.com4df88e82012-05-09 15:49:24 +0000225 if ((width % 4 != 0 && width != texture->getWidth(target, 0)) ||
226 (height % 4 != 0 && height != texture->getHeight(target, 0)))
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000227 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000228 return gl::error(GL_INVALID_OPERATION, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000229 }
230 }
231
daniel@transgaming.com4df88e82012-05-09 15:49:24 +0000232 if (xoffset + width > texture->getWidth(target, level) ||
233 yoffset + height > texture->getHeight(target, level))
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000234 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000235 return gl::error(GL_INVALID_VALUE, false);
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000236 }
237
238 return true;
239}
240
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000241bool validateES2TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage,
242 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
243 GLint border, GLenum format, GLenum type, const GLvoid *pixels)
244{
245 if (!validImageSize(context, level, width, height, 1))
246 {
247 return gl::error(GL_INVALID_VALUE, false);
248 }
249
250 if (isCompressed && !validCompressedImageSize(width, height))
251 {
252 return gl::error(GL_INVALID_OPERATION, false);
253 }
254
255 if (level < 0 || xoffset < 0 ||
256 std::numeric_limits<GLsizei>::max() - xoffset < width ||
257 std::numeric_limits<GLsizei>::max() - yoffset < height)
258 {
259 return gl::error(GL_INVALID_VALUE, false);
260 }
261
262 if (!isSubImage && !isCompressed && internalformat != GLint(format))
263 {
264 return gl::error(GL_INVALID_OPERATION, false);
265 }
266
267 gl::Texture *texture = NULL;
268 bool textureCompressed = false;
269 GLenum textureInternalFormat = GL_NONE;
270 GLint textureLevelWidth = 0;
271 GLint textureLevelHeight = 0;
272 switch (target)
273 {
274 case GL_TEXTURE_2D:
275 {
276 if (width > (context->getMaximum2DTextureDimension() >> level) ||
277 height > (context->getMaximum2DTextureDimension() >> level))
278 {
279 return gl::error(GL_INVALID_VALUE, false);
280 }
281
282 gl::Texture2D *tex2d = context->getTexture2D();
283 if (tex2d)
284 {
285 textureCompressed = tex2d->isCompressed(level);
286 textureInternalFormat = tex2d->getInternalFormat(level);
287 textureLevelWidth = tex2d->getWidth(level);
288 textureLevelHeight = tex2d->getHeight(level);
289 texture = tex2d;
290 }
291
292 if (isSubImage && !validateSubImageParams2D(isCompressed, width, height, xoffset, yoffset,
293 level, format, type, tex2d))
294 {
295 return false;
296 }
297
298 texture = tex2d;
299 }
300 break;
301
302 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
303 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
304 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
305 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
306 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
307 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
308 {
309 if (!isSubImage && width != height)
310 {
311 return gl::error(GL_INVALID_VALUE, false);
312 }
313
314 if (width > (context->getMaximumCubeTextureDimension() >> level) ||
315 height > (context->getMaximumCubeTextureDimension() >> level))
316 {
317 return gl::error(GL_INVALID_VALUE, false);
318 }
319
320 gl::TextureCubeMap *texCube = context->getTextureCubeMap();
321 if (texCube)
322 {
323 textureCompressed = texCube->isCompressed(target, level);
324 textureInternalFormat = texCube->getInternalFormat(target, level);
325 textureLevelWidth = texCube->getWidth(target, level);
326 textureLevelHeight = texCube->getHeight(target, level);
327 texture = texCube;
328 }
329
330 if (isSubImage && !validateSubImageParamsCube(isCompressed, width, height, xoffset, yoffset,
331 target, level, format, type, texCube))
332 {
333 return false;
334 }
335 }
336 break;
337
338 default:
339 return gl::error(GL_INVALID_ENUM, false);
340 }
341
342 if (!texture)
343 {
344 return gl::error(GL_INVALID_OPERATION, false);
345 }
346
347 if (!isSubImage && texture->isImmutable())
348 {
349 return gl::error(GL_INVALID_OPERATION, false);
350 }
351
352 // Verify zero border
353 if (border != 0)
354 {
355 return gl::error(GL_INVALID_VALUE, false);
356 }
357
358 // Verify texture is not requesting more mip levels than are available.
359 if (level > context->getMaximumTextureLevel())
360 {
361 return gl::error(GL_INVALID_VALUE, false);
362 }
363
364 GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat;
365 if (isCompressed)
366 {
367 switch (actualInternalFormat)
368 {
369 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
370 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
371 if (!context->supportsDXT1Textures())
372 {
373 return gl::error(GL_INVALID_ENUM, false);
374 }
375 break;
376 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
377 if (!context->supportsDXT3Textures())
378 {
379 return gl::error(GL_INVALID_ENUM, false);
380 }
381 break;
382 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
383 if (!context->supportsDXT5Textures())
384 {
385 return gl::error(GL_INVALID_ENUM, false);
386 }
387 break;
388 default:
389 return gl::error(GL_INVALID_ENUM, false);
390 }
391 }
392 else
393 {
394 // validate <type> by itself (used as secondary key below)
395 switch (type)
396 {
397 case GL_UNSIGNED_BYTE:
398 case GL_UNSIGNED_SHORT_5_6_5:
399 case GL_UNSIGNED_SHORT_4_4_4_4:
400 case GL_UNSIGNED_SHORT_5_5_5_1:
401 case GL_UNSIGNED_SHORT:
402 case GL_UNSIGNED_INT:
403 case GL_UNSIGNED_INT_24_8_OES:
404 case GL_HALF_FLOAT_OES:
405 case GL_FLOAT:
406 break;
407 default:
408 return gl::error(GL_INVALID_ENUM, false);
409 }
410
411 // validate <format> + <type> combinations
412 // - invalid <format> -> sets INVALID_ENUM
413 // - invalid <format>+<type> combination -> sets INVALID_OPERATION
414 switch (format)
415 {
416 case GL_ALPHA:
417 case GL_LUMINANCE:
418 case GL_LUMINANCE_ALPHA:
419 switch (type)
420 {
421 case GL_UNSIGNED_BYTE:
422 case GL_FLOAT:
423 case GL_HALF_FLOAT_OES:
424 break;
425 default:
426 return gl::error(GL_INVALID_OPERATION, false);
427 }
428 break;
429 case GL_RGB:
430 switch (type)
431 {
432 case GL_UNSIGNED_BYTE:
433 case GL_UNSIGNED_SHORT_5_6_5:
434 case GL_FLOAT:
435 case GL_HALF_FLOAT_OES:
436 break;
437 default:
438 return gl::error(GL_INVALID_OPERATION, false);
439 }
440 break;
441 case GL_RGBA:
442 switch (type)
443 {
444 case GL_UNSIGNED_BYTE:
445 case GL_UNSIGNED_SHORT_4_4_4_4:
446 case GL_UNSIGNED_SHORT_5_5_5_1:
447 case GL_FLOAT:
448 case GL_HALF_FLOAT_OES:
449 break;
450 default:
451 return gl::error(GL_INVALID_OPERATION, false);
452 }
453 break;
454 case GL_BGRA_EXT:
455 switch (type)
456 {
457 case GL_UNSIGNED_BYTE:
458 break;
459 default:
460 return gl::error(GL_INVALID_OPERATION, false);
461 }
462 break;
463 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below
464 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
465 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
466 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
467 break;
468 case GL_DEPTH_COMPONENT:
469 switch (type)
470 {
471 case GL_UNSIGNED_SHORT:
472 case GL_UNSIGNED_INT:
473 break;
474 default:
475 return gl::error(GL_INVALID_OPERATION, false);
476 }
477 break;
478 case GL_DEPTH_STENCIL_OES:
479 switch (type)
480 {
481 case GL_UNSIGNED_INT_24_8_OES:
482 break;
483 default:
484 return gl::error(GL_INVALID_OPERATION, false);
485 }
486 break;
487 default:
488 return gl::error(GL_INVALID_ENUM, false);
489 }
490
491 switch (format)
492 {
493 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
494 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
495 if (context->supportsDXT1Textures())
496 {
497 return gl::error(GL_INVALID_OPERATION, false);
498 }
499 else
500 {
501 return gl::error(GL_INVALID_ENUM, false);
502 }
503 break;
504 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
505 if (context->supportsDXT3Textures())
506 {
507 return gl::error(GL_INVALID_OPERATION, false);
508 }
509 else
510 {
511 return gl::error(GL_INVALID_ENUM, false);
512 }
513 break;
514 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
515 if (context->supportsDXT5Textures())
516 {
517 return gl::error(GL_INVALID_OPERATION, false);
518 }
519 else
520 {
521 return gl::error(GL_INVALID_ENUM, false);
522 }
523 break;
524 case GL_DEPTH_COMPONENT:
525 case GL_DEPTH_STENCIL_OES:
526 if (!context->supportsDepthTextures())
527 {
528 return gl::error(GL_INVALID_VALUE, false);
529 }
530 if (target != GL_TEXTURE_2D)
531 {
532 return gl::error(GL_INVALID_OPERATION, false);
533 }
534 // OES_depth_texture supports loading depth data and multiple levels,
535 // but ANGLE_depth_texture does not
536 if (pixels != NULL || level != 0)
537 {
538 return gl::error(GL_INVALID_OPERATION, false);
539 }
540 break;
541 default:
542 break;
543 }
544
545 if (type == GL_FLOAT)
546 {
547 if (!context->supportsFloat32Textures())
548 {
549 return gl::error(GL_INVALID_ENUM, false);
550 }
551 }
552 else if (type == GL_HALF_FLOAT_OES)
553 {
554 if (!context->supportsFloat16Textures())
555 {
556 return gl::error(GL_INVALID_ENUM, false);
557 }
558 }
559 }
560
561 return true;
562}
563
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +0000564bool validateES3TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage,
565 GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
566 GLint border, GLenum format, GLenum type)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000567{
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000568 // Validate image size
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000569 if (!validImageSize(context, level, width, height, depth))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000570 {
571 return gl::error(GL_INVALID_VALUE, false);
572 }
573
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000574 if (isCompressed && !validCompressedImageSize(width, height))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000575 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000576 return gl::error(GL_INVALID_OPERATION, false);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000577 }
578
579 // Verify zero border
580 if (border != 0)
581 {
582 return gl::error(GL_INVALID_VALUE, false);
583 }
584
585 // Validate dimensions based on Context limits and validate the texture
586 if (level > context->getMaximumTextureLevel())
587 {
588 return gl::error(GL_INVALID_VALUE, false);
589 }
590
591 gl::Texture *texture = NULL;
592 bool textureCompressed = false;
593 GLenum textureInternalFormat = GL_NONE;
594 GLint textureLevelWidth = 0;
595 GLint textureLevelHeight = 0;
596 GLint textureLevelDepth = 0;
597 switch (target)
598 {
599 case GL_TEXTURE_2D:
600 {
601 if (width > (context->getMaximum2DTextureDimension() >> level) ||
602 height > (context->getMaximum2DTextureDimension() >> level))
603 {
604 return gl::error(GL_INVALID_VALUE, false);
605 }
606
607 gl::Texture2D *texture2d = context->getTexture2D();
608 if (texture2d)
609 {
610 textureCompressed = texture2d->isCompressed(level);
611 textureInternalFormat = texture2d->getInternalFormat(level);
612 textureLevelWidth = texture2d->getWidth(level);
613 textureLevelHeight = texture2d->getHeight(level);
614 textureLevelDepth = 1;
615 texture = texture2d;
616 }
617 }
618 break;
619
620 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
621 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
622 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
623 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
624 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
625 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
626 {
shannonwoods@chromium.org92852cf2013-05-30 00:14:12 +0000627 if (!isSubImage && width != height)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000628 {
629 return gl::error(GL_INVALID_VALUE, false);
630 }
631
632 if (width > (context->getMaximumCubeTextureDimension() >> level))
633 {
634 return gl::error(GL_INVALID_VALUE, false);
635 }
636
637 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
638 if (textureCube)
639 {
640 textureCompressed = textureCube->isCompressed(target, level);
641 textureInternalFormat = textureCube->getInternalFormat(target, level);
642 textureLevelWidth = textureCube->getWidth(target, level);
643 textureLevelHeight = textureCube->getHeight(target, level);
644 textureLevelDepth = 1;
645 texture = textureCube;
646 }
647 }
648 break;
649
650 case GL_TEXTURE_3D:
651 {
652 if (width > (context->getMaximum3DTextureDimension() >> level) ||
653 height > (context->getMaximum3DTextureDimension() >> level) ||
654 depth > (context->getMaximum3DTextureDimension() >> level))
655 {
656 return gl::error(GL_INVALID_VALUE, false);
657 }
658
659 gl::Texture3D *texture3d = context->getTexture3D();
660 if (texture3d)
661 {
662 textureCompressed = texture3d->isCompressed(level);
663 textureInternalFormat = texture3d->getInternalFormat(level);
664 textureLevelWidth = texture3d->getWidth(level);
665 textureLevelHeight = texture3d->getHeight(level);
666 textureLevelDepth = texture3d->getDepth(level);
667 texture = texture3d;
668 }
669 }
670 break;
671
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +0000672 case GL_TEXTURE_2D_ARRAY:
673 {
674 if (width > (context->getMaximum2DTextureDimension() >> level) ||
675 height > (context->getMaximum2DTextureDimension() >> level) ||
676 depth > (context->getMaximum2DArrayTextureLayers() >> level))
677 {
678 return gl::error(GL_INVALID_VALUE, false);
679 }
680
681 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
682 if (texture2darray)
683 {
684 textureCompressed = texture2darray->isCompressed(level);
685 textureInternalFormat = texture2darray->getInternalFormat(level);
686 textureLevelWidth = texture2darray->getWidth(level);
687 textureLevelHeight = texture2darray->getHeight(level);
688 textureLevelDepth = texture2darray->getDepth(level);
689 texture = texture2darray;
690 }
691 }
692 break;
693
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000694 default:
695 return gl::error(GL_INVALID_ENUM, false);
696 }
697
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000698 if (!texture)
699 {
700 return gl::error(GL_INVALID_OPERATION, false);
701 }
702
shannonwoods@chromium.orgcf2533c2013-05-30 00:14:18 +0000703 if (texture->isImmutable() && !isSubImage)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000704 {
705 return gl::error(GL_INVALID_OPERATION, false);
706 }
707
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000708 // Validate texture formats
709 GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat;
710 if (isCompressed)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000711 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000712 if (!gl::IsFormatCompressed(actualInternalFormat, context->getClientVersion()))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000713 {
714 return gl::error(GL_INVALID_ENUM, false);
715 }
716
717 if (target == GL_TEXTURE_3D)
718 {
719 return gl::error(GL_INVALID_OPERATION, false);
720 }
721 }
722 else
723 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000724 if (!gl::IsValidInternalFormat(actualInternalFormat, context) ||
725 !gl::IsValidFormat(format, context->getClientVersion()) ||
726 !gl::IsValidType(type, context->getClientVersion()))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000727 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000728 return gl::error(GL_INVALID_ENUM, false);
729 }
730
731 if (!gl::IsValidFormatCombination(actualInternalFormat, format, type, context->getClientVersion()))
732 {
733 return gl::error(GL_INVALID_OPERATION, false);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000734 }
735
736 if ((target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) &&
737 (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL))
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000738 {
739 return gl::error(GL_INVALID_OPERATION, false);
740 }
741 }
742
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000743 // Validate sub image parameters
744 if (isSubImage)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000745 {
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000746 if (isCompressed != textureCompressed)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000747 {
748 return gl::error(GL_INVALID_OPERATION, false);
749 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000750
751 if (format != GL_NONE)
752 {
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +0000753 GLenum internalformat = gl::GetSizedInternalFormat(format, type, context->getClientVersion());
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000754 if (internalformat != textureInternalFormat)
755 {
756 return gl::error(GL_INVALID_OPERATION, false);
757 }
758 }
759
760 if (isCompressed)
761 {
762 if ((width % 4 != 0 && width != textureLevelWidth) ||
763 (height % 4 != 0 && height != textureLevelHeight))
764 {
765 return gl::error(GL_INVALID_OPERATION, false);
766 }
767 }
768
769 if (width == 0 || height == 0 || depth == 0)
770 {
771 return false;
772 }
773
774 if (xoffset < 0 || yoffset < 0 || zoffset < 0)
775 {
776 return gl::error(GL_INVALID_VALUE, false);
777 }
778
779 if (std::numeric_limits<GLsizei>::max() - xoffset < width ||
780 std::numeric_limits<GLsizei>::max() - yoffset < height ||
781 std::numeric_limits<GLsizei>::max() - zoffset < depth)
782 {
783 return gl::error(GL_INVALID_VALUE, false);
784 }
785
786 if (xoffset + width > textureLevelWidth ||
787 yoffset + height > textureLevelHeight ||
788 zoffset + depth > textureLevelDepth)
789 {
790 return gl::error(GL_INVALID_VALUE, false);
791 }
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +0000792 }
793
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +0000794 return true;
795}
796
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000797
798bool validateES2CopyTexImageParameters(gl::Context* context, GLenum target, GLint level, GLenum internalformat, bool isSubImage,
799 GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height,
800 GLint border)
801{
802 if (!gl::IsInternalTextureTarget(target))
803 {
804 return gl::error(GL_INVALID_ENUM, false);
805 }
806
807 if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0)
808 {
809 return gl::error(GL_INVALID_VALUE, false);
810 }
811
812 if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
813 {
814 return gl::error(GL_INVALID_VALUE, false);
815 }
816
817 if (width == 0 || height == 0)
818 {
819 return false;
820 }
821
822 // Verify zero border
823 if (border != 0)
824 {
825 return gl::error(GL_INVALID_VALUE, false);
826 }
827
828 // Validate dimensions based on Context limits and validate the texture
829 if (level > context->getMaximumTextureLevel())
830 {
831 return gl::error(GL_INVALID_VALUE, false);
832 }
833
834 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
835
836 if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
837 {
838 return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
839 }
840
841 if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0)
842 {
843 return gl::error(GL_INVALID_OPERATION, false);
844 }
845
846 GLenum colorbufferFormat = framebuffer->getReadColorbuffer()->getInternalFormat();
847 gl::Texture *texture = NULL;
848 GLenum textureFormat = GL_RGBA;
849
850 switch (target)
851 {
852 case GL_TEXTURE_2D:
853 {
854 if (width > (context->getMaximum2DTextureDimension() >> level) ||
855 height > (context->getMaximum2DTextureDimension() >> level))
856 {
857 return gl::error(GL_INVALID_VALUE, false);
858 }
859
860 gl::Texture2D *tex2d = context->getTexture2D();
861 if (tex2d)
862 {
863 if (isSubImage && !validateSubImageParams2D(false, width, height, xoffset, yoffset, level, GL_NONE, GL_NONE, tex2d))
864 {
865 return false; // error already registered by validateSubImageParams
866 }
867 texture = tex2d;
868 textureFormat = gl::GetFormat(tex2d->getInternalFormat(level), context->getClientVersion());
869 }
870 }
871 break;
872
873 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
874 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
875 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
876 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
877 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
878 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
879 {
880 if (!isSubImage && width != height)
881 {
882 return gl::error(GL_INVALID_VALUE, false);
883 }
884
885 if (width > (context->getMaximumCubeTextureDimension() >> level) ||
886 height > (context->getMaximumCubeTextureDimension() >> level))
887 {
888 return gl::error(GL_INVALID_VALUE, false);
889 }
890
891 gl::TextureCubeMap *texcube = context->getTextureCubeMap();
892 if (texcube)
893 {
894 if (isSubImage && !validateSubImageParamsCube(false, width, height, xoffset, yoffset, target, level, GL_NONE, GL_NONE, texcube))
895 {
896 return false; // error already registered by validateSubImageParams
897 }
898 texture = texcube;
899 textureFormat = gl::GetFormat(texcube->getInternalFormat(target, level), context->getClientVersion());
900 }
901 }
902 break;
903
904 default:
905 return gl::error(GL_INVALID_ENUM, false);
906 }
907
908 if (!texture)
909 {
910 return gl::error(GL_INVALID_OPERATION, false);
911 }
912
913 if (texture->isImmutable() && !isSubImage)
914 {
915 return gl::error(GL_INVALID_OPERATION, false);
916 }
917
918
919 // [OpenGL ES 2.0.24] table 3.9
920 if (isSubImage)
921 {
922 switch (textureFormat)
923 {
924 case GL_ALPHA:
925 if (colorbufferFormat != GL_ALPHA8_EXT &&
926 colorbufferFormat != GL_RGBA4 &&
927 colorbufferFormat != GL_RGB5_A1 &&
928 colorbufferFormat != GL_RGBA8_OES)
929 {
930 return gl::error(GL_INVALID_OPERATION, false);
931 }
932 break;
933 case GL_LUMINANCE:
934 case GL_RGB:
935 if (colorbufferFormat != GL_RGB565 &&
936 colorbufferFormat != GL_RGB8_OES &&
937 colorbufferFormat != GL_RGBA4 &&
938 colorbufferFormat != GL_RGB5_A1 &&
939 colorbufferFormat != GL_RGBA8_OES)
940 {
941 return gl::error(GL_INVALID_OPERATION, false);
942 }
943 break;
944 case GL_LUMINANCE_ALPHA:
945 case GL_RGBA:
946 if (colorbufferFormat != GL_RGBA4 &&
947 colorbufferFormat != GL_RGB5_A1 &&
948 colorbufferFormat != GL_RGBA8_OES)
949 {
950 return gl::error(GL_INVALID_OPERATION, false);
951 }
952 break;
953 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
954 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
955 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
956 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
957 return gl::error(GL_INVALID_OPERATION, false);
958 case GL_DEPTH_COMPONENT:
959 case GL_DEPTH_STENCIL_OES:
960 return gl::error(GL_INVALID_OPERATION, false);
961 default:
962 return gl::error(GL_INVALID_OPERATION, false);
963 }
964 }
965 else
966 {
967 switch (internalformat)
968 {
969 case GL_ALPHA:
970 if (colorbufferFormat != GL_ALPHA8_EXT &&
971 colorbufferFormat != GL_RGBA4 &&
972 colorbufferFormat != GL_RGB5_A1 &&
973 colorbufferFormat != GL_BGRA8_EXT &&
974 colorbufferFormat != GL_RGBA8_OES)
975 {
976 return gl::error(GL_INVALID_OPERATION, false);
977 }
978 break;
979 case GL_LUMINANCE:
980 case GL_RGB:
981 if (colorbufferFormat != GL_RGB565 &&
982 colorbufferFormat != GL_RGB8_OES &&
983 colorbufferFormat != GL_RGBA4 &&
984 colorbufferFormat != GL_RGB5_A1 &&
985 colorbufferFormat != GL_BGRA8_EXT &&
986 colorbufferFormat != GL_RGBA8_OES)
987 {
988 return gl::error(GL_INVALID_OPERATION, false);
989 }
990 break;
991 case GL_LUMINANCE_ALPHA:
992 case GL_RGBA:
993 if (colorbufferFormat != GL_RGBA4 &&
994 colorbufferFormat != GL_RGB5_A1 &&
995 colorbufferFormat != GL_BGRA8_EXT &&
996 colorbufferFormat != GL_RGBA8_OES)
997 {
998 return gl::error(GL_INVALID_OPERATION, false);
999 }
1000 break;
1001 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1002 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1003 if (context->supportsDXT1Textures())
1004 {
1005 return gl::error(GL_INVALID_OPERATION, false);
1006 }
1007 else
1008 {
1009 return gl::error(GL_INVALID_ENUM, false);
1010 }
1011 break;
1012 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
1013 if (context->supportsDXT3Textures())
1014 {
1015 return gl::error(GL_INVALID_OPERATION, false);
1016 }
1017 else
1018 {
1019 return gl::error(GL_INVALID_ENUM, false);
1020 }
1021 break;
1022 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
1023 if (context->supportsDXT5Textures())
1024 {
1025 return gl::error(GL_INVALID_OPERATION, false);
1026 }
1027 else
1028 {
1029 return gl::error(GL_INVALID_ENUM, false);
1030 }
1031 break;
1032 case GL_DEPTH_COMPONENT:
1033 case GL_DEPTH_COMPONENT16:
1034 case GL_DEPTH_COMPONENT32_OES:
1035 case GL_DEPTH_STENCIL_OES:
1036 case GL_DEPTH24_STENCIL8_OES:
1037 if (context->supportsDepthTextures())
1038 {
1039 return gl::error(GL_INVALID_OPERATION, false);
1040 }
1041 else
1042 {
1043 return gl::error(GL_INVALID_ENUM, false);
1044 }
1045 default:
1046 return gl::error(GL_INVALID_ENUM, false);
1047 }
1048 }
1049
1050 return true;
1051}
1052
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001053bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLint level, GLenum internalformat,
1054 bool isSubImage, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y,
1055 GLsizei width, GLsizei height, GLint border)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001056{
1057 if (level < 0 || xoffset < 0 || yoffset < 0 || zoffset < 0 || width < 0 || height < 0)
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +00001058 {
1059 return gl::error(GL_INVALID_VALUE, false);
1060 }
1061
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001062 if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
1063 {
1064 return gl::error(GL_INVALID_VALUE, false);
1065 }
1066
1067 if (width == 0 || height == 0)
1068 {
1069 return false;
1070 }
1071
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001072 if (border != 0)
1073 {
1074 return gl::error(GL_INVALID_VALUE, false);
1075 }
1076
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001077 if (level > context->getMaximumTextureLevel())
1078 {
1079 return gl::error(GL_INVALID_VALUE, false);
1080 }
1081
1082 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
1083
1084 if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
1085 {
1086 return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
1087 }
1088
1089 if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0)
1090 {
1091 return gl::error(GL_INVALID_OPERATION, false);
1092 }
1093
1094 gl::Renderbuffer *source = framebuffer->getReadColorbuffer();
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001095 GLenum colorbufferInternalFormat = source->getInternalFormat();
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001096 gl::Texture *texture = NULL;
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001097 GLenum textureInternalFormat = GL_NONE;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001098 bool textureCompressed = false;
1099 GLint textureLevelWidth = 0;
1100 GLint textureLevelHeight = 0;
1101 GLint textureLevelDepth = 0;
1102 switch (target)
1103 {
1104 case GL_TEXTURE_2D:
1105 {
1106 gl::Texture2D *texture2d = context->getTexture2D();
1107 if (texture2d)
1108 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001109 textureInternalFormat = texture2d->getInternalFormat(level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001110 textureCompressed = texture2d->isCompressed(level);
1111 textureLevelWidth = texture2d->getWidth(level);
1112 textureLevelHeight = texture2d->getHeight(level);
1113 textureLevelDepth = 1;
1114 texture = texture2d;
1115 }
1116 }
1117 break;
1118
1119 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1120 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1121 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1122 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1123 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1124 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1125 {
1126 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
1127 if (textureCube)
1128 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001129 textureInternalFormat = textureCube->getInternalFormat(target, level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001130 textureCompressed = textureCube->isCompressed(target, level);
1131 textureLevelWidth = textureCube->getWidth(target, level);
1132 textureLevelHeight = textureCube->getHeight(target, level);
1133 textureLevelDepth = 1;
1134 texture = textureCube;
1135 }
1136 }
1137 break;
1138
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001139 case GL_TEXTURE_2D_ARRAY:
1140 {
1141 gl::Texture2DArray *texture2dArray = context->getTexture2DArray();
1142 if (texture2dArray)
1143 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001144 textureInternalFormat = texture2dArray->getInternalFormat(level);
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001145 textureCompressed = texture2dArray->isCompressed(level);
1146 textureLevelWidth = texture2dArray->getWidth(level);
1147 textureLevelHeight = texture2dArray->getHeight(level);
1148 textureLevelDepth = texture2dArray->getDepth(level);
1149 texture = texture2dArray;
1150 }
1151 }
1152 break;
1153
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001154 case GL_TEXTURE_3D:
1155 {
1156 gl::Texture3D *texture3d = context->getTexture3D();
1157 if (texture3d)
1158 {
shannonwoods@chromium.orgffab47d2013-05-30 00:16:22 +00001159 textureInternalFormat = texture3d->getInternalFormat(level);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001160 textureCompressed = texture3d->isCompressed(level);
1161 textureLevelWidth = texture3d->getWidth(level);
1162 textureLevelHeight = texture3d->getHeight(level);
1163 textureLevelDepth = texture3d->getDepth(level);
1164 texture = texture3d;
1165 }
1166 }
1167 break;
1168
1169 default:
1170 return gl::error(GL_INVALID_ENUM, false);
1171 }
1172
1173 if (!texture)
1174 {
1175 return gl::error(GL_INVALID_OPERATION, false);
1176 }
1177
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001178 if (texture->isImmutable() && !isSubImage)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001179 {
1180 return gl::error(GL_INVALID_OPERATION, false);
1181 }
1182
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00001183 if (textureCompressed)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001184 {
1185 if ((width % 4 != 0 && width != textureLevelWidth) ||
1186 (height % 4 != 0 && height != textureLevelHeight))
1187 {
1188 return gl::error(GL_INVALID_OPERATION, false);
1189 }
1190 }
1191
Geoff Langa4d13322013-06-05 14:57:51 -04001192 if (isSubImage)
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001193 {
Geoff Langa4d13322013-06-05 14:57:51 -04001194 if (xoffset + width > textureLevelWidth ||
1195 yoffset + height > textureLevelHeight ||
1196 zoffset >= textureLevelDepth)
1197 {
1198 return gl::error(GL_INVALID_VALUE, false);
1199 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001200
Geoff Langa4d13322013-06-05 14:57:51 -04001201 if (!gl::IsValidCopyTexImageCombination(textureInternalFormat, colorbufferInternalFormat,
1202 context->getClientVersion()))
1203 {
1204 return gl::error(GL_INVALID_OPERATION, false);
1205 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00001206 }
1207
shannon.woods%transgaming.com@gtempaccount.com6d73c4e2013-04-13 03:45:12 +00001208 return true;
1209}
1210
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00001211bool validateES2TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat,
1212 GLsizei width, GLsizei height)
1213{
1214 if (target != GL_TEXTURE_2D && target != GL_TEXTURE_CUBE_MAP)
1215 {
1216 return gl::error(GL_INVALID_ENUM, false);
1217 }
1218
1219 if (width < 1 || height < 1 || levels < 1)
1220 {
1221 return gl::error(GL_INVALID_VALUE, false);
1222 }
1223
1224 if (target == GL_TEXTURE_CUBE_MAP && width != height)
1225 {
1226 return gl::error(GL_INVALID_VALUE, false);
1227 }
1228
1229 if (levels != 1 && levels != gl::log2(std::max(width, height)) + 1)
1230 {
1231 return gl::error(GL_INVALID_OPERATION, false);
1232 }
1233
1234 GLenum format = gl::GetFormat(internalformat, context->getClientVersion());
1235 GLenum type = gl::GetType(internalformat, context->getClientVersion());
1236
1237 if (format == GL_NONE || type == GL_NONE)
1238 {
1239 return gl::error(GL_INVALID_ENUM, false);
1240 }
1241
1242 switch (target)
1243 {
1244 case GL_TEXTURE_2D:
1245 if (width > context->getMaximum2DTextureDimension() ||
1246 height > context->getMaximum2DTextureDimension())
1247 {
1248 return gl::error(GL_INVALID_VALUE, false);
1249 }
1250 break;
1251 case GL_TEXTURE_CUBE_MAP:
1252 if (width > context->getMaximumCubeTextureDimension() ||
1253 height > context->getMaximumCubeTextureDimension())
1254 {
1255 return gl::error(GL_INVALID_VALUE, false);
1256 }
1257 break;
1258 default:
1259 return gl::error(GL_INVALID_ENUM, false);
1260 }
1261
1262 if (levels != 1 && !context->supportsNonPower2Texture())
1263 {
1264 if (!gl::isPow2(width) || !gl::isPow2(height))
1265 {
1266 return gl::error(GL_INVALID_OPERATION, false);
1267 }
1268 }
1269
1270 switch (internalformat)
1271 {
1272 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1273 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1274 if (!context->supportsDXT1Textures())
1275 {
1276 return gl::error(GL_INVALID_ENUM, false);
1277 }
1278 break;
1279 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
1280 if (!context->supportsDXT3Textures())
1281 {
1282 return gl::error(GL_INVALID_ENUM, false);
1283 }
1284 break;
1285 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
1286 if (!context->supportsDXT5Textures())
1287 {
1288 return gl::error(GL_INVALID_ENUM, false);
1289 }
1290 break;
1291 case GL_RGBA32F_EXT:
1292 case GL_RGB32F_EXT:
1293 case GL_ALPHA32F_EXT:
1294 case GL_LUMINANCE32F_EXT:
1295 case GL_LUMINANCE_ALPHA32F_EXT:
1296 if (!context->supportsFloat32Textures())
1297 {
1298 return gl::error(GL_INVALID_ENUM, false);
1299 }
1300 break;
1301 case GL_RGBA16F_EXT:
1302 case GL_RGB16F_EXT:
1303 case GL_ALPHA16F_EXT:
1304 case GL_LUMINANCE16F_EXT:
1305 case GL_LUMINANCE_ALPHA16F_EXT:
1306 if (!context->supportsFloat16Textures())
1307 {
1308 return gl::error(GL_INVALID_ENUM, false);
1309 }
1310 break;
1311 case GL_DEPTH_COMPONENT16:
1312 case GL_DEPTH_COMPONENT32_OES:
1313 case GL_DEPTH24_STENCIL8_OES:
1314 if (!context->supportsDepthTextures())
1315 {
1316 return gl::error(GL_INVALID_ENUM, false);
1317 }
1318 if (target != GL_TEXTURE_2D)
1319 {
1320 return gl::error(GL_INVALID_OPERATION, false);
1321 }
1322 // ANGLE_depth_texture only supports 1-level textures
1323 if (levels != 1)
1324 {
1325 return gl::error(GL_INVALID_OPERATION, false);
1326 }
1327 break;
1328 default:
1329 break;
1330 }
1331
1332 gl::Texture *texture = NULL;
1333 switch(target)
1334 {
1335 case GL_TEXTURE_2D:
1336 texture = context->getTexture2D();
1337 break;
1338 case GL_TEXTURE_CUBE_MAP:
1339 texture = context->getTextureCubeMap();
1340 break;
1341 default:
1342 UNREACHABLE();
1343 }
1344
1345 if (!texture || texture->id() == 0)
1346 {
1347 return gl::error(GL_INVALID_OPERATION, false);
1348 }
1349
1350 if (texture->isImmutable())
1351 {
1352 return gl::error(GL_INVALID_OPERATION, false);
1353 }
1354
1355 return true;
1356}
1357
1358bool validateES3TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat,
1359 GLsizei width, GLsizei height, GLsizei depth)
1360{
1361 if (width < 1 || height < 1 || depth < 1 || levels < 1)
1362 {
1363 return gl::error(GL_INVALID_VALUE, false);
1364 }
1365
1366 if (levels > gl::log2(std::max(std::max(width, height), depth)) + 1)
1367 {
1368 return gl::error(GL_INVALID_OPERATION, false);
1369 }
1370
1371 gl::Texture *texture = NULL;
1372 switch (target)
1373 {
1374 case GL_TEXTURE_2D:
1375 {
1376 texture = context->getTexture2D();
1377
1378 if (width > (context->getMaximum2DTextureDimension()) ||
1379 height > (context->getMaximum2DTextureDimension()))
1380 {
1381 return gl::error(GL_INVALID_VALUE, false);
1382 }
1383 }
1384 break;
1385
1386 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1387 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1388 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1389 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1390 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1391 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1392 {
1393 texture = context->getTextureCubeMap();
1394
1395 if (width != height)
1396 {
1397 return gl::error(GL_INVALID_VALUE, false);
1398 }
1399
1400 if (width > (context->getMaximumCubeTextureDimension()))
1401 {
1402 return gl::error(GL_INVALID_VALUE, false);
1403 }
1404 }
1405 break;
1406
1407 case GL_TEXTURE_3D:
1408 {
1409 texture = context->getTexture3D();
1410
1411 if (width > (context->getMaximum3DTextureDimension()) ||
1412 height > (context->getMaximum3DTextureDimension()) ||
1413 depth > (context->getMaximum3DTextureDimension()))
1414 {
1415 return gl::error(GL_INVALID_VALUE, false);
1416 }
1417 }
1418 break;
1419
1420 case GL_TEXTURE_2D_ARRAY:
1421 {
1422 texture = context->getTexture2DArray();
1423
1424 if (width > (context->getMaximum2DTextureDimension()) ||
1425 height > (context->getMaximum2DTextureDimension()) ||
1426 depth > (context->getMaximum2DArrayTextureLayers()))
1427 {
1428 return gl::error(GL_INVALID_VALUE, false);
1429 }
1430 }
1431 break;
1432
1433 default:
1434 return gl::error(GL_INVALID_ENUM, false);
1435 }
1436
1437 if (!texture || texture->id() == 0)
1438 {
1439 return gl::error(GL_INVALID_OPERATION, false);
1440 }
1441
1442 if (texture->isImmutable())
1443 {
1444 return gl::error(GL_INVALID_OPERATION, false);
1445 }
1446
1447 if (!gl::IsValidInternalFormat(internalformat, context))
1448 {
1449 return gl::error(GL_INVALID_ENUM, false);
1450 }
1451
1452 if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion()))
1453 {
1454 return gl::error(GL_INVALID_ENUM, false);
1455 }
1456
1457 return true;
1458}
1459
Geoff Lang2e1dcd52013-05-29 10:34:08 -04001460bool validateRenderbufferStorageParameters(const gl::Context *context, GLenum target, GLsizei samples,
1461 GLenum internalformat, GLsizei width, GLsizei height,
1462 bool angleExtension)
1463{
1464 switch (target)
1465 {
1466 case GL_RENDERBUFFER:
1467 break;
1468 default:
1469 return gl::error(GL_INVALID_ENUM, false);
1470 }
1471
1472 if (width < 0 || height < 0 || samples < 0)
1473 {
1474 return gl::error(GL_INVALID_VALUE, false);
1475 }
1476
1477 if (!gl::IsValidInternalFormat(internalformat, context))
1478 {
1479 return gl::error(GL_INVALID_ENUM, false);
1480 }
1481
1482 // ANGLE_framebuffer_multisample does not explicitly state that the internal format must be
1483 // sized but it does state that the format must be in the ES2.0 spec table 4.5 which contains
1484 // only sized internal formats. The ES3 spec (section 4.4.2) does, however, state that the
1485 // internal format must be sized and not an integer format if samples is greater than zero.
1486 if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion()))
1487 {
1488 return gl::error(GL_INVALID_ENUM, false);
1489 }
1490
1491 if (gl::IsIntegerFormat(internalformat, context->getClientVersion()) && samples > 0)
1492 {
1493 return gl::error(GL_INVALID_OPERATION, false);
1494 }
1495
1496 if (!gl::IsColorRenderingSupported(internalformat, context) &&
1497 !gl::IsDepthRenderingSupported(internalformat, context) &&
1498 !gl::IsStencilRenderingSupported(internalformat, context))
1499 {
1500 return gl::error(GL_INVALID_ENUM, false);
1501 }
1502
1503 if (std::max(width, height) > context->getMaximumRenderbufferDimension())
1504 {
1505 return gl::error(GL_INVALID_VALUE, false);
1506 }
1507
1508 // ANGLE_framebuffer_multisample states that the value of samples must be less than or equal
1509 // to MAX_SAMPLES_ANGLE (Context::getMaxSupportedSamples) while the ES3.0 spec (section 4.4.2)
1510 // states that samples must be less than or equal to the maximum samples for the specified
1511 // internal format.
1512 if (angleExtension)
1513 {
1514 if (samples > context->getMaxSupportedSamples())
1515 {
1516 return gl::error(GL_INVALID_VALUE, false);
1517 }
1518 }
1519 else
1520 {
1521 if (samples > context->getMaxSupportedFormatSamples(internalformat))
1522 {
1523 return gl::error(GL_INVALID_VALUE, false);
1524 }
1525 }
1526
1527 GLuint handle = context->getRenderbufferHandle();
1528 if (handle == 0)
1529 {
1530 return gl::error(GL_INVALID_OPERATION, false);
1531 }
1532
1533 return true;
1534}
1535
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00001536// check for combinations of format and type that are valid for ReadPixels
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00001537bool validES2ReadFormatType(GLenum format, GLenum type)
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00001538{
1539 switch (format)
1540 {
1541 case GL_RGBA:
1542 switch (type)
1543 {
1544 case GL_UNSIGNED_BYTE:
1545 break;
1546 default:
1547 return false;
1548 }
1549 break;
1550 case GL_BGRA_EXT:
1551 switch (type)
1552 {
1553 case GL_UNSIGNED_BYTE:
1554 case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
1555 case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
1556 break;
1557 default:
1558 return false;
1559 }
1560 break;
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00001561 default:
1562 return false;
1563 }
1564 return true;
1565}
1566
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00001567bool validES3ReadFormatType(GLenum internalFormat, GLenum format, GLenum type)
1568{
1569 switch (format)
1570 {
1571 case GL_RGBA:
1572 switch (type)
1573 {
1574 case GL_UNSIGNED_BYTE:
1575 break;
1576 case GL_UNSIGNED_INT_2_10_10_10_REV:
1577 if (internalFormat != GL_RGB10_A2)
1578 {
1579 return false;
1580 }
1581 break;
1582 default:
1583 return false;
1584 }
1585 break;
1586 case GL_RGBA_INTEGER:
1587 switch (type)
1588 {
1589 case GL_INT:
1590 case GL_UNSIGNED_INT:
1591 break;
1592 default:
1593 return false;
1594 }
1595 break;
1596 case GL_BGRA_EXT:
1597 switch (type)
1598 {
1599 case GL_UNSIGNED_BYTE:
1600 case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
1601 case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
1602 break;
1603 default:
1604 return false;
1605 }
1606 break;
1607 default:
1608 return false;
1609 }
1610 return true;
1611}
1612
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00001613bool validateInvalidateFramebufferParameters(gl::Context *context, GLenum target, GLsizei numAttachments,
1614 const GLenum* attachments)
1615{
1616 bool defaultFramebuffer = false;
1617
1618 switch (target)
1619 {
1620 case GL_DRAW_FRAMEBUFFER:
1621 case GL_FRAMEBUFFER:
1622 defaultFramebuffer = context->getDrawFramebufferHandle() == 0;
1623 break;
1624 case GL_READ_FRAMEBUFFER:
1625 defaultFramebuffer = context->getReadFramebufferHandle() == 0;
1626 break;
1627 default:
1628 return gl::error(GL_INVALID_ENUM, false);
1629 }
1630
1631 for (int i = 0; i < numAttachments; ++i)
1632 {
1633 if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15)
1634 {
1635 if (defaultFramebuffer)
1636 {
1637 return gl::error(GL_INVALID_ENUM, false);
1638 }
1639
1640 if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getMaximumRenderTargets())
1641 {
1642 return gl::error(GL_INVALID_OPERATION, false);
1643 }
1644 }
1645 else
1646 {
1647 switch (attachments[i])
1648 {
1649 case GL_DEPTH_ATTACHMENT:
1650 case GL_STENCIL_ATTACHMENT:
1651 case GL_DEPTH_STENCIL_ATTACHMENT:
1652 if (defaultFramebuffer)
1653 {
1654 return gl::error(GL_INVALID_ENUM, false);
1655 }
1656 break;
1657 case GL_COLOR:
1658 case GL_DEPTH:
1659 case GL_STENCIL:
1660 if (!defaultFramebuffer)
1661 {
1662 return gl::error(GL_INVALID_ENUM, false);
1663 }
1664 break;
1665 default:
1666 return gl::error(GL_INVALID_ENUM, false);
1667 }
1668 }
1669 }
1670
1671 return true;
1672}
1673
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001674extern "C"
1675{
1676
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00001677// OpenGL ES 2.0 functions
1678
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001679void __stdcall glActiveTexture(GLenum texture)
1680{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001681 EVENT("(GLenum texture = 0x%X)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001682
1683 try
1684 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001685 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001686
1687 if (context)
1688 {
daniel@transgaming.com3f74c7a2011-05-11 15:36:51 +00001689 if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1)
1690 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001691 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3f74c7a2011-05-11 15:36:51 +00001692 }
1693
daniel@transgaming.com428d1582010-05-04 03:35:25 +00001694 context->setActiveSampler(texture - GL_TEXTURE0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001695 }
1696 }
1697 catch(std::bad_alloc&)
1698 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001699 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001700 }
1701}
1702
1703void __stdcall glAttachShader(GLuint program, GLuint shader)
1704{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001705 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001706
1707 try
1708 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001709 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001710
1711 if (context)
1712 {
1713 gl::Program *programObject = context->getProgram(program);
1714 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00001715
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001716 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001717 {
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001718 if (context->getShader(program))
1719 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001720 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001721 }
1722 else
1723 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001724 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001725 }
1726 }
1727
1728 if (!shaderObject)
1729 {
1730 if (context->getProgram(shader))
1731 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001732 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001733 }
1734 else
1735 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001736 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +00001737 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001738 }
1739
1740 if (!programObject->attachShader(shaderObject))
1741 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001742 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001743 }
1744 }
1745 }
1746 catch(std::bad_alloc&)
1747 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001748 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001749 }
1750}
1751
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001752void __stdcall glBeginQueryEXT(GLenum target, GLuint id)
1753{
1754 EVENT("(GLenum target = 0x%X, GLuint %d)", target, id);
1755
1756 try
1757 {
1758 switch (target)
1759 {
1760 case GL_ANY_SAMPLES_PASSED_EXT:
1761 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
1762 break;
1763 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001764 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001765 }
1766
1767 if (id == 0)
1768 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001769 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001770 }
1771
1772 gl::Context *context = gl::getNonLostContext();
1773
1774 if (context)
1775 {
1776 context->beginQuery(target, id);
1777 }
1778 }
1779 catch(std::bad_alloc&)
1780 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001781 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001782 }
1783}
1784
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001785void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001786{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001787 EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001788
1789 try
1790 {
1791 if (index >= gl::MAX_VERTEX_ATTRIBS)
1792 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001793 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001794 }
1795
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001796 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001797
1798 if (context)
1799 {
1800 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00001801
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001802 if (!programObject)
1803 {
daniel@transgaming.com98079832010-04-13 03:26:29 +00001804 if (context->getShader(program))
1805 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001806 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com98079832010-04-13 03:26:29 +00001807 }
1808 else
1809 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001810 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com98079832010-04-13 03:26:29 +00001811 }
1812 }
1813
1814 if (strncmp(name, "gl_", 3) == 0)
1815 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001816 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001817 }
1818
1819 programObject->bindAttributeLocation(index, name);
1820 }
1821 }
1822 catch(std::bad_alloc&)
1823 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001824 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001825 }
1826}
1827
1828void __stdcall glBindBuffer(GLenum target, GLuint buffer)
1829{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001830 EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001831
1832 try
1833 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001834 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001835
1836 if (context)
1837 {
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00001838 // Check ES3 specific targets
1839 switch (target)
1840 {
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00001841 case GL_COPY_READ_BUFFER:
1842 case GL_COPY_WRITE_BUFFER:
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00001843 case GL_PIXEL_PACK_BUFFER:
1844 case GL_PIXEL_UNPACK_BUFFER:
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00001845 case GL_UNIFORM_BUFFER:
1846 case GL_TRANSFORM_FEEDBACK_BUFFER:
1847 if (context->getClientVersion() < 3)
1848 {
1849 return gl::error(GL_INVALID_ENUM);
1850 }
1851 }
1852
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001853 switch (target)
1854 {
1855 case GL_ARRAY_BUFFER:
1856 context->bindArrayBuffer(buffer);
1857 return;
1858 case GL_ELEMENT_ARRAY_BUFFER:
1859 context->bindElementArrayBuffer(buffer);
1860 return;
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00001861 case GL_COPY_READ_BUFFER:
1862 context->bindCopyReadBuffer(buffer);
1863 return;
1864 case GL_COPY_WRITE_BUFFER:
1865 context->bindCopyWriteBuffer(buffer);
1866 return;
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00001867 case GL_PIXEL_PACK_BUFFER:
1868 context->bindPixelPackBuffer(buffer);
1869 return;
1870 case GL_PIXEL_UNPACK_BUFFER:
1871 context->bindPixelUnpackBuffer(buffer);
1872 return;
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00001873 case GL_UNIFORM_BUFFER:
1874 context->bindGenericUniformBuffer(buffer);
1875 return;
1876 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.org7a1ebad2013-05-30 00:05:20 +00001877 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00001878 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001879 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001880 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001881 }
1882 }
1883 }
1884 catch(std::bad_alloc&)
1885 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001886 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001887 }
1888}
1889
1890void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer)
1891{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001892 EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001893
1894 try
1895 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00001896 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001897 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001898 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001899 }
1900
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001901 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001902
1903 if (context)
1904 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00001905 if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
1906 {
1907 context->bindReadFramebuffer(framebuffer);
1908 }
1909
1910 if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
1911 {
1912 context->bindDrawFramebuffer(framebuffer);
1913 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001914 }
1915 }
1916 catch(std::bad_alloc&)
1917 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001918 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001919 }
1920}
1921
1922void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer)
1923{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001924 EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001925
1926 try
1927 {
1928 if (target != GL_RENDERBUFFER)
1929 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001930 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001931 }
1932
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001933 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001934
1935 if (context)
1936 {
1937 context->bindRenderbuffer(renderbuffer);
1938 }
1939 }
1940 catch(std::bad_alloc&)
1941 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001942 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001943 }
1944}
1945
1946void __stdcall glBindTexture(GLenum target, GLuint texture)
1947{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001948 EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001949
1950 try
1951 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001952 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001953
1954 if (context)
1955 {
1956 gl::Texture *textureObject = context->getTexture(texture);
1957
1958 if (textureObject && textureObject->getTarget() != target && texture != 0)
1959 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001960 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001961 }
1962
1963 switch (target)
1964 {
1965 case GL_TEXTURE_2D:
1966 context->bindTexture2D(texture);
1967 return;
1968 case GL_TEXTURE_CUBE_MAP:
1969 context->bindTextureCubeMap(texture);
1970 return;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00001971 case GL_TEXTURE_3D:
1972 if (context->getClientVersion() < 3)
1973 {
1974 return gl::error(GL_INVALID_ENUM);
1975 }
1976 context->bindTexture3D(texture);
1977 return;
shannon.woods%transgaming.com@gtempaccount.com90dbc442013-04-13 03:46:14 +00001978 case GL_TEXTURE_2D_ARRAY:
1979 if (context->getClientVersion() < 3)
1980 {
1981 return gl::error(GL_INVALID_ENUM);
1982 }
1983 context->bindTexture2DArray(texture);
1984 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001985 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001986 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001987 }
1988 }
1989 }
1990 catch(std::bad_alloc&)
1991 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001992 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001993 }
1994}
1995
1996void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
1997{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001998 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001999 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002000
2001 try
2002 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002003 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002004
2005 if (context)
2006 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002007 context->setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002008 }
2009 }
2010 catch(std::bad_alloc&)
2011 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002012 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002013 }
2014}
2015
2016void __stdcall glBlendEquation(GLenum mode)
2017{
2018 glBlendEquationSeparate(mode, mode);
2019}
2020
2021void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
2022{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002023 EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002024
2025 try
2026 {
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +00002027 gl::Context *context = gl::getNonLostContext();
2028
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002029 switch (modeRGB)
2030 {
2031 case GL_FUNC_ADD:
2032 case GL_FUNC_SUBTRACT:
2033 case GL_FUNC_REVERSE_SUBTRACT:
2034 break;
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +00002035
2036 case GL_MIN:
2037 case GL_MAX:
2038 if (context && context->getClientVersion() < 3)
2039 {
2040 return gl::error(GL_INVALID_ENUM);
2041 }
2042 break;
2043
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002044 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002045 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002046 }
2047
2048 switch (modeAlpha)
2049 {
2050 case GL_FUNC_ADD:
2051 case GL_FUNC_SUBTRACT:
2052 case GL_FUNC_REVERSE_SUBTRACT:
2053 break;
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +00002054
2055 case GL_MIN:
2056 case GL_MAX:
2057 if (context && context->getClientVersion() < 3)
2058 {
2059 return gl::error(GL_INVALID_ENUM);
2060 }
2061 break;
2062
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002063 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002064 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002065 }
2066
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002067 if (context)
2068 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002069 context->setBlendEquation(modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002070 }
2071 }
2072 catch(std::bad_alloc&)
2073 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002074 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002075 }
2076}
2077
2078void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor)
2079{
2080 glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
2081}
2082
2083void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
2084{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002085 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 +00002086 srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002087
2088 try
2089 {
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +00002090 gl::Context *context = gl::getNonLostContext();
2091
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002092 switch (srcRGB)
2093 {
2094 case GL_ZERO:
2095 case GL_ONE:
2096 case GL_SRC_COLOR:
2097 case GL_ONE_MINUS_SRC_COLOR:
2098 case GL_DST_COLOR:
2099 case GL_ONE_MINUS_DST_COLOR:
2100 case GL_SRC_ALPHA:
2101 case GL_ONE_MINUS_SRC_ALPHA:
2102 case GL_DST_ALPHA:
2103 case GL_ONE_MINUS_DST_ALPHA:
2104 case GL_CONSTANT_COLOR:
2105 case GL_ONE_MINUS_CONSTANT_COLOR:
2106 case GL_CONSTANT_ALPHA:
2107 case GL_ONE_MINUS_CONSTANT_ALPHA:
2108 case GL_SRC_ALPHA_SATURATE:
2109 break;
2110 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002111 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002112 }
2113
2114 switch (dstRGB)
2115 {
2116 case GL_ZERO:
2117 case GL_ONE:
2118 case GL_SRC_COLOR:
2119 case GL_ONE_MINUS_SRC_COLOR:
2120 case GL_DST_COLOR:
2121 case GL_ONE_MINUS_DST_COLOR:
2122 case GL_SRC_ALPHA:
2123 case GL_ONE_MINUS_SRC_ALPHA:
2124 case GL_DST_ALPHA:
2125 case GL_ONE_MINUS_DST_ALPHA:
2126 case GL_CONSTANT_COLOR:
2127 case GL_ONE_MINUS_CONSTANT_COLOR:
2128 case GL_CONSTANT_ALPHA:
2129 case GL_ONE_MINUS_CONSTANT_ALPHA:
2130 break;
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +00002131
2132 case GL_SRC_ALPHA_SATURATE:
2133 if (!context || context->getClientVersion() < 3)
2134 {
2135 return gl::error(GL_INVALID_ENUM);
2136 }
2137 break;
2138
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002139 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002140 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002141 }
2142
2143 switch (srcAlpha)
2144 {
2145 case GL_ZERO:
2146 case GL_ONE:
2147 case GL_SRC_COLOR:
2148 case GL_ONE_MINUS_SRC_COLOR:
2149 case GL_DST_COLOR:
2150 case GL_ONE_MINUS_DST_COLOR:
2151 case GL_SRC_ALPHA:
2152 case GL_ONE_MINUS_SRC_ALPHA:
2153 case GL_DST_ALPHA:
2154 case GL_ONE_MINUS_DST_ALPHA:
2155 case GL_CONSTANT_COLOR:
2156 case GL_ONE_MINUS_CONSTANT_COLOR:
2157 case GL_CONSTANT_ALPHA:
2158 case GL_ONE_MINUS_CONSTANT_ALPHA:
2159 case GL_SRC_ALPHA_SATURATE:
2160 break;
2161 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002162 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002163 }
2164
2165 switch (dstAlpha)
2166 {
2167 case GL_ZERO:
2168 case GL_ONE:
2169 case GL_SRC_COLOR:
2170 case GL_ONE_MINUS_SRC_COLOR:
2171 case GL_DST_COLOR:
2172 case GL_ONE_MINUS_DST_COLOR:
2173 case GL_SRC_ALPHA:
2174 case GL_ONE_MINUS_SRC_ALPHA:
2175 case GL_DST_ALPHA:
2176 case GL_ONE_MINUS_DST_ALPHA:
2177 case GL_CONSTANT_COLOR:
2178 case GL_ONE_MINUS_CONSTANT_COLOR:
2179 case GL_CONSTANT_ALPHA:
2180 case GL_ONE_MINUS_CONSTANT_ALPHA:
2181 break;
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +00002182
2183 case GL_SRC_ALPHA_SATURATE:
2184 if (!context || context->getClientVersion() < 3)
2185 {
2186 return gl::error(GL_INVALID_ENUM);
2187 }
2188 break;
2189
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002190 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002191 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002192 }
2193
daniel@transgaming.comfe453652010-03-16 06:23:28 +00002194 bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
2195 dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
2196
2197 bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
2198 dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
2199
2200 if (constantColorUsed && constantAlphaUsed)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002201 {
daniel@transgaming.comfe453652010-03-16 06:23:28 +00002202 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 +00002203 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002204 }
2205
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002206 if (context)
2207 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002208 context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002209 }
2210 }
2211 catch(std::bad_alloc&)
2212 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002213 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002214 }
2215}
2216
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002217void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002218{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002219 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 +00002220 target, size, data, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002221
2222 try
2223 {
2224 if (size < 0)
2225 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002226 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002227 }
2228
shannon.woods%transgaming.com@gtempaccount.comf2db40b2013-04-13 03:37:09 +00002229 gl::Context *context = gl::getNonLostContext();
2230
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002231 switch (usage)
2232 {
2233 case GL_STREAM_DRAW:
2234 case GL_STATIC_DRAW:
2235 case GL_DYNAMIC_DRAW:
2236 break;
shannon.woods%transgaming.com@gtempaccount.comf2db40b2013-04-13 03:37:09 +00002237
2238 case GL_STREAM_READ:
2239 case GL_STREAM_COPY:
2240 case GL_STATIC_READ:
2241 case GL_STATIC_COPY:
2242 case GL_DYNAMIC_READ:
2243 case GL_DYNAMIC_COPY:
2244 if (context && context->getClientVersion() < 3)
2245 {
2246 return gl::error(GL_INVALID_ENUM);
2247 }
2248 break;
2249
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002250 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002251 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002252 }
2253
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002254 if (context)
2255 {
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002256 // Check ES3 specific targets
2257 switch (target)
2258 {
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002259 case GL_COPY_READ_BUFFER:
2260 case GL_COPY_WRITE_BUFFER:
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002261 case GL_PIXEL_PACK_BUFFER:
2262 case GL_PIXEL_UNPACK_BUFFER:
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002263 case GL_UNIFORM_BUFFER:
2264 case GL_TRANSFORM_FEEDBACK_BUFFER:
2265 if (context->getClientVersion() < 3)
2266 {
2267 return gl::error(GL_INVALID_ENUM);
2268 }
2269 }
2270
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002271 gl::Buffer *buffer;
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00002272
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002273 switch (target)
2274 {
2275 case GL_ARRAY_BUFFER:
2276 buffer = context->getArrayBuffer();
2277 break;
2278 case GL_ELEMENT_ARRAY_BUFFER:
2279 buffer = context->getElementArrayBuffer();
2280 break;
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002281 case GL_COPY_READ_BUFFER:
2282 buffer = context->getCopyReadBuffer();
2283 break;
2284 case GL_COPY_WRITE_BUFFER:
2285 buffer = context->getCopyWriteBuffer();
2286 break;
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002287 case GL_PIXEL_PACK_BUFFER:
2288 buffer = context->getPixelPackBuffer();
2289 break;
2290 case GL_PIXEL_UNPACK_BUFFER:
2291 buffer = context->getPixelUnpackBuffer();
2292 break;
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002293 case GL_TRANSFORM_FEEDBACK_BUFFER:
2294 buffer = context->getGenericTransformFeedbackBuffer();
2295 break;
2296 case GL_UNIFORM_BUFFER:
2297 buffer = context->getGenericUniformBuffer();
2298 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002299 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002300 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002301 }
2302
2303 if (!buffer)
2304 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002305 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002306 }
2307
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002308 buffer->bufferData(data, size, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002309 }
2310 }
2311 catch(std::bad_alloc&)
2312 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002313 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002314 }
2315}
2316
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002317void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002318{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002319 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 +00002320 target, offset, size, data);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002321
2322 try
2323 {
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +00002324 if (size < 0 || offset < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002325 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002326 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002327 }
2328
daniel@transgaming.comd4620a32010-03-21 04:31:28 +00002329 if (data == NULL)
2330 {
2331 return;
2332 }
2333
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002334 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002335
2336 if (context)
2337 {
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002338 // Check ES3 specific targets
2339 switch (target)
2340 {
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002341 case GL_COPY_READ_BUFFER:
2342 case GL_COPY_WRITE_BUFFER:
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002343 case GL_PIXEL_PACK_BUFFER:
2344 case GL_PIXEL_UNPACK_BUFFER:
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002345 case GL_UNIFORM_BUFFER:
2346 case GL_TRANSFORM_FEEDBACK_BUFFER:
2347 if (context->getClientVersion() < 3)
2348 {
2349 return gl::error(GL_INVALID_ENUM);
2350 }
2351 }
2352
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002353 gl::Buffer *buffer;
2354
2355 switch (target)
2356 {
2357 case GL_ARRAY_BUFFER:
2358 buffer = context->getArrayBuffer();
2359 break;
2360 case GL_ELEMENT_ARRAY_BUFFER:
2361 buffer = context->getElementArrayBuffer();
2362 break;
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +00002363 case GL_COPY_READ_BUFFER:
2364 buffer = context->getCopyReadBuffer();
2365 break;
2366 case GL_COPY_WRITE_BUFFER:
2367 buffer = context->getCopyWriteBuffer();
2368 break;
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +00002369 case GL_PIXEL_PACK_BUFFER:
2370 buffer = context->getPixelPackBuffer();
2371 break;
2372 case GL_PIXEL_UNPACK_BUFFER:
2373 buffer = context->getPixelUnpackBuffer();
2374 break;
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00002375 case GL_TRANSFORM_FEEDBACK_BUFFER:
2376 buffer = context->getGenericTransformFeedbackBuffer();
2377 break;
2378 case GL_UNIFORM_BUFFER:
2379 buffer = context->getGenericUniformBuffer();
2380 break;
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002381 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002382 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002383 }
2384
2385 if (!buffer)
2386 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002387 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002388 }
2389
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +00002390 if ((size_t)size + offset > buffer->size())
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002391 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002392 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002393 }
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +00002394
2395 buffer->bufferSubData(data, size, offset);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +00002396 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002397 }
2398 catch(std::bad_alloc&)
2399 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002400 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002401 }
2402}
2403
2404GLenum __stdcall glCheckFramebufferStatus(GLenum target)
2405{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002406 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002407
2408 try
2409 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002410 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002411 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002412 return gl::error(GL_INVALID_ENUM, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002413 }
2414
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002415 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002416
2417 if (context)
2418 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002419 gl::Framebuffer *framebuffer = NULL;
2420 if (target == GL_READ_FRAMEBUFFER_ANGLE)
2421 {
2422 framebuffer = context->getReadFramebuffer();
2423 }
2424 else
2425 {
2426 framebuffer = context->getDrawFramebuffer();
2427 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002428
2429 return framebuffer->completeness();
2430 }
2431 }
2432 catch(std::bad_alloc&)
2433 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002434 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002435 }
2436
2437 return 0;
2438}
2439
2440void __stdcall glClear(GLbitfield mask)
2441{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00002442 EVENT("(GLbitfield mask = 0x%X)", mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002443
2444 try
2445 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002446 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002447
2448 if (context)
2449 {
2450 context->clear(mask);
2451 }
2452 }
2453 catch(std::bad_alloc&)
2454 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002455 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002456 }
2457}
2458
2459void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
2460{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002461 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002462 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002463
2464 try
2465 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002466 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002467
2468 if (context)
2469 {
2470 context->setClearColor(red, green, blue, alpha);
2471 }
2472 }
2473 catch(std::bad_alloc&)
2474 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002475 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002476 }
2477}
2478
2479void __stdcall glClearDepthf(GLclampf depth)
2480{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002481 EVENT("(GLclampf depth = %f)", depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002482
2483 try
2484 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002485 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002486
2487 if (context)
2488 {
2489 context->setClearDepth(depth);
2490 }
2491 }
2492 catch(std::bad_alloc&)
2493 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002494 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002495 }
2496}
2497
2498void __stdcall glClearStencil(GLint s)
2499{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002500 EVENT("(GLint s = %d)", s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002501
2502 try
2503 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002504 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002505
2506 if (context)
2507 {
2508 context->setClearStencil(s);
2509 }
2510 }
2511 catch(std::bad_alloc&)
2512 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002513 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002514 }
2515}
2516
2517void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
2518{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00002519 EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002520 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002521
2522 try
2523 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002524 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002525
2526 if (context)
2527 {
daniel@transgaming.coma36f98e2010-05-18 18:51:09 +00002528 context->setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002529 }
2530 }
2531 catch(std::bad_alloc&)
2532 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002533 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002534 }
2535}
2536
2537void __stdcall glCompileShader(GLuint shader)
2538{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002539 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002540
2541 try
2542 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002543 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002544
2545 if (context)
2546 {
2547 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00002548
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002549 if (!shaderObject)
2550 {
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +00002551 if (context->getProgram(shader))
2552 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002553 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +00002554 }
2555 else
2556 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002557 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +00002558 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002559 }
2560
2561 shaderObject->compile();
2562 }
2563 }
2564 catch(std::bad_alloc&)
2565 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002566 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002567 }
2568}
2569
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002570void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
2571 GLint border, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002572{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002573 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002574 "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002575 target, level, internalformat, width, height, border, imageSize, data);
2576
2577 try
2578 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002579 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com01868132010-08-24 19:21:17 +00002580
2581 if (context)
2582 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002583 if (context->getClientVersion() < 3 &&
2584 !validateES2TexImageParameters(context, target, level, internalformat, true, false,
2585 0, 0, width, height, 0, GL_NONE, GL_NONE, data))
2586 {
2587 return;
2588 }
2589
2590 if (context->getClientVersion() >= 3 &&
2591 !validateES3TexImageParameters(context, target, level, internalformat, true, false,
2592 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE))
2593 {
2594 return;
2595 }
2596
2597 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002598 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002599 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002600 }
2601
2602 switch (target)
2603 {
2604 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002605 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002606 gl::Texture2D *texture = context->getTexture2D();
2607 texture->setCompressedImage(level, internalformat, width, height, imageSize, data);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002608 }
2609 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002610
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002611 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2612 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2613 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2614 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2615 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2616 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002617 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002618 gl::TextureCubeMap *texture = context->getTextureCubeMap();
2619 texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002620 }
2621 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002622
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002623 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002624 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002625 }
daniel@transgaming.com01868132010-08-24 19:21:17 +00002626 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002627 }
2628 catch(std::bad_alloc&)
2629 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002630 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002631 }
2632}
2633
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002634void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
2635 GLenum format, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002636{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002637 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002638 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002639 "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002640 target, level, xoffset, yoffset, width, height, format, imageSize, data);
2641
2642 try
2643 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002644 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com01868132010-08-24 19:21:17 +00002645
2646 if (context)
2647 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002648 if (context->getClientVersion() < 3 &&
2649 !validateES2TexImageParameters(context, target, level, GL_NONE, true, true,
2650 xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
2651 {
2652 return;
2653 }
2654
2655 if (context->getClientVersion() >= 3 &&
2656 !validateES3TexImageParameters(context, target, level, GL_NONE, true, true,
2657 xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE))
2658 {
2659 return;
2660 }
2661
2662 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002663 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002664 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002665 }
2666
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002667 switch (target)
daniel@transgaming.com01868132010-08-24 19:21:17 +00002668 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002669 case GL_TEXTURE_2D:
daniel@transgaming.com01868132010-08-24 19:21:17 +00002670 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002671 gl::Texture2D *texture = context->getTexture2D();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00002672 texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
daniel@transgaming.com01868132010-08-24 19:21:17 +00002673 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002674 break;
2675
2676 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2677 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2678 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2679 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2680 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2681 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com01868132010-08-24 19:21:17 +00002682 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002683 gl::TextureCubeMap *texture = context->getTextureCubeMap();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00002684 texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
daniel@transgaming.com01868132010-08-24 19:21:17 +00002685 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002686 break;
2687
2688 default:
2689 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com01868132010-08-24 19:21:17 +00002690 }
2691 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002692 }
2693 catch(std::bad_alloc&)
2694 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002695 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002696 }
2697}
2698
2699void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
2700{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002701 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002702 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002703 target, level, internalformat, x, y, width, height, border);
2704
2705 try
2706 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002707 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002708
2709 if (context)
2710 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002711 if (context->getClientVersion() < 3 &&
2712 !validateES2CopyTexImageParameters(context, target, level, internalformat, false,
2713 0, 0, x, y, width, height, border))
daniel@transgaming.com32b11442011-11-19 02:42:48 +00002714 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002715 return;
daniel@transgaming.com32b11442011-11-19 02:42:48 +00002716 }
2717
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002718 if (context->getClientVersion() >= 3 &&
2719 !validateES3CopyTexImageParameters(context, target, level, internalformat, false,
2720 0, 0, 0, x, y, width, height, border))
2721 {
2722 return;
2723 }
2724
2725 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
2726
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002727 switch (target)
2728 {
2729 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002730 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002731 gl::Texture2D *texture = context->getTexture2D();
2732 texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002733 }
2734 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002735
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002736 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2737 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2738 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2739 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2740 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2741 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002742 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002743 gl::TextureCubeMap *texture = context->getTextureCubeMap();
2744 texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002745 }
2746 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002747
2748 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002749 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002750 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002751 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002752 }
2753 catch(std::bad_alloc&)
2754 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002755 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002756 }
2757}
2758
2759void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
2760{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002761 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002762 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002763 target, level, xoffset, yoffset, x, y, width, height);
2764
2765 try
2766 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002767 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002768
2769 if (context)
2770 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002771 if (context->getClientVersion() < 3 &&
2772 !validateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
2773 xoffset, yoffset, x, y, width, height, 0))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002774 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002775 return;
2776 }
2777
2778 if (context->getClientVersion() >= 3 &&
2779 !validateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
2780 xoffset, yoffset, 0, x, y, width, height, 0))
2781 {
2782 return;
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00002783 }
2784
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002785 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00002786
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002787 switch (target)
daniel@transgaming.combbc57792010-07-28 19:21:05 +00002788 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002789 case GL_TEXTURE_2D:
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +00002790 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002791 gl::Texture2D *texture = context->getTexture2D();
2792 texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00002793 }
2794 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002795
2796 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
2797 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
2798 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
2799 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
2800 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
2801 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com6452adf2012-10-17 18:22:35 +00002802 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002803 gl::TextureCubeMap *texture = context->getTextureCubeMap();
2804 texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +00002805 }
2806 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002807
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00002808 default:
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00002809 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00002810 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002811 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002812 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00002813
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002814 catch(std::bad_alloc&)
2815 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002816 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002817 }
2818}
2819
2820GLuint __stdcall glCreateProgram(void)
2821{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002822 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002823
2824 try
2825 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002826 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002827
2828 if (context)
2829 {
2830 return context->createProgram();
2831 }
2832 }
2833 catch(std::bad_alloc&)
2834 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002835 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002836 }
2837
2838 return 0;
2839}
2840
2841GLuint __stdcall glCreateShader(GLenum type)
2842{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002843 EVENT("(GLenum type = 0x%X)", type);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002844
2845 try
2846 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002847 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002848
2849 if (context)
2850 {
2851 switch (type)
2852 {
2853 case GL_FRAGMENT_SHADER:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00002854 case GL_VERTEX_SHADER:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002855 return context->createShader(type);
2856 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002857 return gl::error(GL_INVALID_ENUM, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002858 }
2859 }
2860 }
2861 catch(std::bad_alloc&)
2862 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002863 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002864 }
2865
2866 return 0;
2867}
2868
2869void __stdcall glCullFace(GLenum mode)
2870{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002871 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002872
2873 try
2874 {
2875 switch (mode)
2876 {
2877 case GL_FRONT:
2878 case GL_BACK:
2879 case GL_FRONT_AND_BACK:
2880 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002881 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002882
2883 if (context)
2884 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00002885 context->setCullMode(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002886 }
2887 }
2888 break;
2889 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002890 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002891 }
2892 }
2893 catch(std::bad_alloc&)
2894 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002895 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002896 }
2897}
2898
2899void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers)
2900{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002901 EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002902
2903 try
2904 {
2905 if (n < 0)
2906 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002907 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002908 }
2909
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002910 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002911
2912 if (context)
2913 {
2914 for (int i = 0; i < n; i++)
2915 {
2916 context->deleteBuffer(buffers[i]);
2917 }
2918 }
2919 }
2920 catch(std::bad_alloc&)
2921 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002922 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002923 }
2924}
2925
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002926void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences)
2927{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002928 EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002929
2930 try
2931 {
2932 if (n < 0)
2933 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002934 return gl::error(GL_INVALID_VALUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002935 }
2936
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002937 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002938
2939 if (context)
2940 {
2941 for (int i = 0; i < n; i++)
2942 {
2943 context->deleteFence(fences[i]);
2944 }
2945 }
2946 }
2947 catch(std::bad_alloc&)
2948 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002949 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002950 }
2951}
2952
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002953void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
2954{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002955 EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002956
2957 try
2958 {
2959 if (n < 0)
2960 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002961 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002962 }
2963
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002964 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002965
2966 if (context)
2967 {
2968 for (int i = 0; i < n; i++)
2969 {
2970 if (framebuffers[i] != 0)
2971 {
2972 context->deleteFramebuffer(framebuffers[i]);
2973 }
2974 }
2975 }
2976 }
2977 catch(std::bad_alloc&)
2978 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002979 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002980 }
2981}
2982
2983void __stdcall glDeleteProgram(GLuint program)
2984{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002985 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002986
2987 try
2988 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00002989 if (program == 0)
2990 {
2991 return;
2992 }
2993
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002994 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002995
2996 if (context)
2997 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00002998 if (!context->getProgram(program))
2999 {
3000 if(context->getShader(program))
3001 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003002 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003003 }
3004 else
3005 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003006 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003007 }
3008 }
3009
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003010 context->deleteProgram(program);
3011 }
3012 }
3013 catch(std::bad_alloc&)
3014 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003015 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003016 }
3017}
3018
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003019void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
3020{
3021 EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
3022
3023 try
3024 {
3025 if (n < 0)
3026 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003027 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003028 }
3029
3030 gl::Context *context = gl::getNonLostContext();
3031
3032 if (context)
3033 {
3034 for (int i = 0; i < n; i++)
3035 {
3036 context->deleteQuery(ids[i]);
3037 }
3038 }
3039 }
3040 catch(std::bad_alloc&)
3041 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003042 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003043 }
3044}
3045
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003046void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
3047{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003048 EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003049
3050 try
3051 {
3052 if (n < 0)
3053 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003054 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003055 }
3056
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003057 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003058
3059 if (context)
3060 {
daniel@transgaming.come2b22122010-03-11 19:22:14 +00003061 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003062 {
3063 context->deleteRenderbuffer(renderbuffers[i]);
3064 }
3065 }
3066 }
3067 catch(std::bad_alloc&)
3068 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003069 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003070 }
3071}
3072
3073void __stdcall glDeleteShader(GLuint shader)
3074{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003075 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003076
3077 try
3078 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003079 if (shader == 0)
3080 {
3081 return;
3082 }
3083
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003084 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003085
3086 if (context)
3087 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003088 if (!context->getShader(shader))
3089 {
3090 if(context->getProgram(shader))
3091 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003092 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003093 }
3094 else
3095 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003096 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00003097 }
3098 }
3099
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003100 context->deleteShader(shader);
3101 }
3102 }
3103 catch(std::bad_alloc&)
3104 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003105 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003106 }
3107}
3108
3109void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures)
3110{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003111 EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003112
3113 try
3114 {
3115 if (n < 0)
3116 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003117 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003118 }
3119
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003120 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003121
3122 if (context)
3123 {
3124 for (int i = 0; i < n; i++)
3125 {
3126 if (textures[i] != 0)
3127 {
3128 context->deleteTexture(textures[i]);
3129 }
3130 }
3131 }
3132 }
3133 catch(std::bad_alloc&)
3134 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003135 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003136 }
3137}
3138
3139void __stdcall glDepthFunc(GLenum func)
3140{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003141 EVENT("(GLenum func = 0x%X)", func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003142
3143 try
3144 {
3145 switch (func)
3146 {
3147 case GL_NEVER:
3148 case GL_ALWAYS:
3149 case GL_LESS:
3150 case GL_LEQUAL:
3151 case GL_EQUAL:
3152 case GL_GREATER:
3153 case GL_GEQUAL:
3154 case GL_NOTEQUAL:
3155 break;
3156 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003157 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003158 }
3159
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003160 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003161
3162 if (context)
3163 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003164 context->setDepthFunc(func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003165 }
3166 }
3167 catch(std::bad_alloc&)
3168 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003169 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003170 }
3171}
3172
3173void __stdcall glDepthMask(GLboolean flag)
3174{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00003175 EVENT("(GLboolean flag = %u)", flag);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003176
3177 try
3178 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003179 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003180
3181 if (context)
3182 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003183 context->setDepthMask(flag != GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003184 }
3185 }
3186 catch(std::bad_alloc&)
3187 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003188 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003189 }
3190}
3191
3192void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar)
3193{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003194 EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003195
3196 try
3197 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003198 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003199
3200 if (context)
3201 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003202 context->setDepthRange(zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003203 }
3204 }
3205 catch(std::bad_alloc&)
3206 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003207 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003208 }
3209}
3210
3211void __stdcall glDetachShader(GLuint program, GLuint shader)
3212{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003213 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003214
3215 try
3216 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003217 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003218
3219 if (context)
3220 {
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003221
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003222 gl::Program *programObject = context->getProgram(program);
3223 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003224
3225 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003226 {
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003227 gl::Shader *shaderByProgramHandle;
3228 shaderByProgramHandle = context->getShader(program);
3229 if (!shaderByProgramHandle)
3230 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003231 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003232 }
3233 else
3234 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003235 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003236 }
3237 }
3238
3239 if (!shaderObject)
3240 {
3241 gl::Program *programByShaderHandle = context->getProgram(shader);
3242 if (!programByShaderHandle)
3243 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003244 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003245 }
3246 else
3247 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003248 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00003249 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003250 }
3251
3252 if (!programObject->detachShader(shaderObject))
3253 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003254 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003255 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003256 }
3257 }
3258 catch(std::bad_alloc&)
3259 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003260 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003261 }
3262}
3263
3264void __stdcall glDisable(GLenum cap)
3265{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003266 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003267
3268 try
3269 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003270 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003271
3272 if (context)
3273 {
3274 switch (cap)
3275 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003276 case GL_CULL_FACE: context->setCullFace(false); break;
3277 case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break;
3278 case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break;
3279 case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break;
3280 case GL_SCISSOR_TEST: context->setScissorTest(false); break;
3281 case GL_STENCIL_TEST: context->setStencilTest(false); break;
3282 case GL_DEPTH_TEST: context->setDepthTest(false); break;
3283 case GL_BLEND: context->setBlend(false); break;
3284 case GL_DITHER: context->setDither(false); break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00003285
3286 case GL_PRIMITIVE_RESTART_FIXED_INDEX:
3287 case GL_RASTERIZER_DISCARD:
3288 if (context->getClientVersion() < 3)
3289 {
3290 return gl::error(GL_INVALID_ENUM);
3291 }
3292 UNIMPLEMENTED();
3293 break;
3294
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003295 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003296 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003297 }
3298 }
3299 }
3300 catch(std::bad_alloc&)
3301 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003302 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003303 }
3304}
3305
3306void __stdcall glDisableVertexAttribArray(GLuint index)
3307{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003308 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003309
3310 try
3311 {
3312 if (index >= gl::MAX_VERTEX_ATTRIBS)
3313 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003314 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003315 }
3316
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003317 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003318
3319 if (context)
3320 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00003321 context->setEnableVertexAttribArray(index, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003322 }
3323 }
3324 catch(std::bad_alloc&)
3325 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003326 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003327 }
3328}
3329
3330void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count)
3331{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003332 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003333
3334 try
3335 {
3336 if (count < 0 || first < 0)
3337 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003338 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003339 }
3340
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003341 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003342
3343 if (context)
3344 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003345 context->drawArrays(mode, first, count, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003346 }
3347 }
3348 catch(std::bad_alloc&)
3349 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003350 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003351 }
3352}
3353
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003354void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
3355{
3356 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
3357
3358 try
3359 {
3360 if (count < 0 || first < 0 || primcount < 0)
3361 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003362 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003363 }
3364
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003365 if (primcount > 0)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003366 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003367 gl::Context *context = gl::getNonLostContext();
3368
3369 if (context)
3370 {
3371 context->drawArrays(mode, first, count, primcount);
3372 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003373 }
3374 }
3375 catch(std::bad_alloc&)
3376 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003377 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003378 }
3379}
3380
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003381void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003382{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003383 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 +00003384 mode, count, type, indices);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003385
3386 try
3387 {
3388 if (count < 0)
3389 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003390 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003391 }
3392
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003393 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003394
3395 if (context)
3396 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00003397 switch (type)
3398 {
3399 case GL_UNSIGNED_BYTE:
3400 case GL_UNSIGNED_SHORT:
3401 break;
3402 case GL_UNSIGNED_INT:
3403 if (!context->supports32bitIndices())
3404 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003405 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com83921382011-01-08 05:46:00 +00003406 }
3407 break;
3408 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003409 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com83921382011-01-08 05:46:00 +00003410 }
3411
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003412 context->drawElements(mode, count, type, indices, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003413 }
3414 }
3415 catch(std::bad_alloc&)
3416 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003417 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003418 }
3419}
3420
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003421void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
3422{
3423 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
3424 mode, count, type, indices, primcount);
3425
3426 try
3427 {
3428 if (count < 0 || primcount < 0)
3429 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003430 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003431 }
3432
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003433 if (primcount > 0)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003434 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003435 gl::Context *context = gl::getNonLostContext();
3436
3437 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003438 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003439 switch (type)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003440 {
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003441 case GL_UNSIGNED_BYTE:
3442 case GL_UNSIGNED_SHORT:
3443 break;
3444 case GL_UNSIGNED_INT:
3445 if (!context->supports32bitIndices())
3446 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003447 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003448 }
3449 break;
3450 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003451 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003452 }
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00003453
3454 context->drawElements(mode, count, type, indices, primcount);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003455 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003456 }
3457 }
3458 catch(std::bad_alloc&)
3459 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003460 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00003461 }
3462}
3463
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003464void __stdcall glEnable(GLenum cap)
3465{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003466 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003467
3468 try
3469 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003470 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003471
3472 if (context)
3473 {
3474 switch (cap)
3475 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003476 case GL_CULL_FACE: context->setCullFace(true); break;
3477 case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break;
3478 case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break;
3479 case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break;
3480 case GL_SCISSOR_TEST: context->setScissorTest(true); break;
3481 case GL_STENCIL_TEST: context->setStencilTest(true); break;
3482 case GL_DEPTH_TEST: context->setDepthTest(true); break;
3483 case GL_BLEND: context->setBlend(true); break;
3484 case GL_DITHER: context->setDither(true); break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003485 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003486 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003487 }
3488 }
3489 }
3490 catch(std::bad_alloc&)
3491 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003492 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003493 }
3494}
3495
3496void __stdcall glEnableVertexAttribArray(GLuint index)
3497{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003498 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003499
3500 try
3501 {
3502 if (index >= gl::MAX_VERTEX_ATTRIBS)
3503 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003504 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003505 }
3506
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003507 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003508
3509 if (context)
3510 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00003511 context->setEnableVertexAttribArray(index, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003512 }
3513 }
3514 catch(std::bad_alloc&)
3515 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003516 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003517 }
3518}
3519
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003520void __stdcall glEndQueryEXT(GLenum target)
3521{
3522 EVENT("GLenum target = 0x%X)", target);
3523
3524 try
3525 {
3526 switch (target)
3527 {
3528 case GL_ANY_SAMPLES_PASSED_EXT:
3529 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
3530 break;
3531 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003532 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003533 }
3534
3535 gl::Context *context = gl::getNonLostContext();
3536
3537 if (context)
3538 {
3539 context->endQuery(target);
3540 }
3541 }
3542 catch(std::bad_alloc&)
3543 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003544 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003545 }
3546}
3547
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003548void __stdcall glFinishFenceNV(GLuint fence)
3549{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003550 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003551
3552 try
3553 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003554 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003555
3556 if (context)
3557 {
3558 gl::Fence* fenceObject = context->getFence(fence);
3559
3560 if (fenceObject == NULL)
3561 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003562 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003563 }
3564
3565 fenceObject->finishFence();
3566 }
3567 }
3568 catch(std::bad_alloc&)
3569 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003570 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003571 }
3572}
3573
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003574void __stdcall glFinish(void)
3575{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003576 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003577
3578 try
3579 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003580 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003581
3582 if (context)
3583 {
daniel@transgaming.com0d86aa72011-10-26 02:35:10 +00003584 context->sync(true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003585 }
3586 }
3587 catch(std::bad_alloc&)
3588 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003589 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003590 }
3591}
3592
3593void __stdcall glFlush(void)
3594{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003595 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003596
3597 try
3598 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003599 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003600
3601 if (context)
3602 {
daniel@transgaming.com0d86aa72011-10-26 02:35:10 +00003603 context->sync(false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003604 }
3605 }
3606 catch(std::bad_alloc&)
3607 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003608 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003609 }
3610}
3611
3612void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
3613{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003614 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003615 "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003616
3617 try
3618 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003619 if ((target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com2fa45512011-10-04 18:43:18 +00003620 || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003621 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003622 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003623 }
3624
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003625 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003626
3627 if (context)
3628 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003629 gl::Framebuffer *framebuffer = NULL;
3630 GLuint framebufferHandle = 0;
3631 if (target == GL_READ_FRAMEBUFFER_ANGLE)
3632 {
3633 framebuffer = context->getReadFramebuffer();
3634 framebufferHandle = context->getReadFramebufferHandle();
3635 }
daniel@transgaming.com2fa45512011-10-04 18:43:18 +00003636 else
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003637 {
3638 framebuffer = context->getDrawFramebuffer();
3639 framebufferHandle = context->getDrawFramebufferHandle();
3640 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003641
daniel@transgaming.com2fa45512011-10-04 18:43:18 +00003642 if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003643 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003644 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003645 }
3646
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003647 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003648 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003649 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
3650
3651 if (colorAttachment >= context->getMaximumRenderTargets())
3652 {
3653 return gl::error(GL_INVALID_VALUE);
3654 }
3655
3656 framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer);
3657 }
3658 else
3659 {
3660 switch (attachment)
3661 {
3662 case GL_DEPTH_ATTACHMENT:
3663 framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer);
3664 break;
3665 case GL_STENCIL_ATTACHMENT:
3666 framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer);
3667 break;
3668 default:
3669 return gl::error(GL_INVALID_ENUM);
3670 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003671 }
3672 }
3673 }
3674 catch(std::bad_alloc&)
3675 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003676 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003677 }
3678}
3679
3680void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
3681{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003682 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003683 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003684
3685 try
3686 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003687 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003688 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003689 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003690 }
3691
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003692 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003693
3694 if (context)
3695 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003696 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
3697 {
3698 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
3699
3700 if (colorAttachment >= context->getMaximumRenderTargets())
3701 {
3702 return gl::error(GL_INVALID_VALUE);
3703 }
3704 }
3705 else
3706 {
3707 switch (attachment)
3708 {
3709 case GL_DEPTH_ATTACHMENT:
3710 case GL_STENCIL_ATTACHMENT:
3711 break;
3712 default:
3713 return gl::error(GL_INVALID_ENUM);
3714 }
3715 }
3716
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003717 if (texture == 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003718 {
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003719 textarget = GL_NONE;
3720 }
3721 else
3722 {
3723 gl::Texture *tex = context->getTexture(texture);
3724
3725 if (tex == NULL)
3726 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003727 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003728 }
3729
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003730 switch (textarget)
3731 {
3732 case GL_TEXTURE_2D:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003733 {
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003734 if (tex->getTarget() != GL_TEXTURE_2D)
3735 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003736 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003737 }
3738 gl::Texture2D *tex2d = static_cast<gl::Texture2D *>(tex);
daniel@transgaming.com92f49922012-05-09 15:49:19 +00003739 if (tex2d->isCompressed(0))
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003740 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003741 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003742 }
3743 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003744 }
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003745
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003746 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003747 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003748 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003749 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003750 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003751 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003752 {
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003753 if (tex->getTarget() != GL_TEXTURE_CUBE_MAP)
3754 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003755 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003756 }
3757 gl::TextureCubeMap *texcube = static_cast<gl::TextureCubeMap *>(tex);
daniel@transgaming.com4df88e82012-05-09 15:49:24 +00003758 if (texcube->isCompressed(textarget, level))
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003759 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003760 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003761 }
3762 break;
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003763 }
daniel@transgaming.com93a81472010-04-20 18:52:58 +00003764
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003765 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003766 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003767 }
3768
3769 if (level != 0)
3770 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003771 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003772 }
3773 }
3774
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003775 gl::Framebuffer *framebuffer = NULL;
3776 GLuint framebufferHandle = 0;
3777 if (target == GL_READ_FRAMEBUFFER_ANGLE)
3778 {
3779 framebuffer = context->getReadFramebuffer();
3780 framebufferHandle = context->getReadFramebufferHandle();
3781 }
3782 else
3783 {
3784 framebuffer = context->getDrawFramebuffer();
3785 framebufferHandle = context->getDrawFramebufferHandle();
3786 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003787
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00003788 if (framebufferHandle == 0 || !framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003789 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003790 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003791 }
3792
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003793 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00003794 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00003795 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
3796
3797 if (colorAttachment >= context->getMaximumRenderTargets())
3798 {
3799 return gl::error(GL_INVALID_VALUE);
3800 }
3801
3802 framebuffer->setColorbuffer(colorAttachment, textarget, texture);
3803 }
3804 else
3805 {
3806 switch (attachment)
3807 {
3808 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break;
3809 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break;
3810 }
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00003811 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003812 }
3813 }
3814 catch(std::bad_alloc&)
3815 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003816 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003817 }
3818}
3819
3820void __stdcall glFrontFace(GLenum mode)
3821{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003822 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003823
3824 try
3825 {
3826 switch (mode)
3827 {
3828 case GL_CW:
3829 case GL_CCW:
3830 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003831 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003832
3833 if (context)
3834 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003835 context->setFrontFace(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003836 }
3837 }
3838 break;
3839 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003840 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003841 }
3842 }
3843 catch(std::bad_alloc&)
3844 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003845 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003846 }
3847}
3848
3849void __stdcall glGenBuffers(GLsizei n, GLuint* buffers)
3850{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003851 EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003852
3853 try
3854 {
3855 if (n < 0)
3856 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003857 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003858 }
3859
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003860 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003861
3862 if (context)
3863 {
3864 for (int i = 0; i < n; i++)
3865 {
3866 buffers[i] = context->createBuffer();
3867 }
3868 }
3869 }
3870 catch(std::bad_alloc&)
3871 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003872 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003873 }
3874}
3875
3876void __stdcall glGenerateMipmap(GLenum target)
3877{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003878 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003879
3880 try
3881 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003882 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003883
3884 if (context)
3885 {
Geoff Langae4852a2013-06-05 15:00:34 -04003886 gl::Texture *texture = NULL;
3887 GLint internalFormat = GL_NONE;
3888 bool isCompressed = false;
3889 bool isDepth = false;
3890
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003891 switch (target)
3892 {
3893 case GL_TEXTURE_2D:
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003894 {
3895 gl::Texture2D *tex2d = context->getTexture2D();
Geoff Langae4852a2013-06-05 15:00:34 -04003896 if (tex2d)
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003897 {
Geoff Langae4852a2013-06-05 15:00:34 -04003898 internalFormat = tex2d->getInternalFormat(0);
3899 isCompressed = tex2d->isCompressed(0);
3900 isDepth = tex2d->isDepth(0);
3901 texture = tex2d;
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003902 }
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003903 break;
3904 }
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003905
3906 case GL_TEXTURE_CUBE_MAP:
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003907 {
3908 gl::TextureCubeMap *texcube = context->getTextureCubeMap();
Geoff Langae4852a2013-06-05 15:00:34 -04003909 if (texcube)
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003910 {
Geoff Langae4852a2013-06-05 15:00:34 -04003911 internalFormat = texcube->getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0);
3912 isCompressed = texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0);
3913 isDepth = false;
3914 texture = texcube;
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003915 }
daniel@transgaming.comeb3c01a2012-05-09 15:49:12 +00003916 break;
3917 }
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003918
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00003919 case GL_TEXTURE_3D:
3920 {
3921 if (context->getClientVersion() < 3)
3922 {
3923 return gl::error(GL_INVALID_ENUM);
3924 }
3925
3926 gl::Texture3D *tex3D = context->getTexture3D();
Geoff Langae4852a2013-06-05 15:00:34 -04003927 if (tex3D)
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00003928 {
Geoff Langae4852a2013-06-05 15:00:34 -04003929 internalFormat = tex3D->getInternalFormat(0);
3930 isCompressed = tex3D->isCompressed(0);
3931 isDepth = tex3D->isDepth(0);
3932 texture = tex3D;
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00003933 }
shannon.woods%transgaming.com@gtempaccount.com86740a92013-04-13 03:45:24 +00003934 break;
3935 }
3936
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00003937 case GL_TEXTURE_2D_ARRAY:
3938 {
3939 if (context->getClientVersion() < 3)
3940 {
3941 return gl::error(GL_INVALID_ENUM);
3942 }
3943
3944 gl::Texture2DArray *tex2darr = context->getTexture2DArray();
Geoff Langae4852a2013-06-05 15:00:34 -04003945 if (tex2darr)
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00003946 {
Geoff Langae4852a2013-06-05 15:00:34 -04003947 internalFormat = tex2darr->getInternalFormat(0);
3948 isCompressed = tex2darr->isCompressed(0);
3949 isDepth = tex2darr->isDepth(0);
3950 texture = tex2darr;
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00003951 }
shannonwoods@chromium.org30aa1a92013-05-30 00:03:13 +00003952 break;
3953 }
3954
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003955 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003956 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003957 }
Geoff Langae4852a2013-06-05 15:00:34 -04003958
3959 if (!texture)
3960 {
3961 return gl::error(GL_INVALID_OPERATION);
3962 }
3963
3964 // Internally, all texture formats are sized so checking if the format
3965 // is color renderable and filterable will not fail.
3966 if (isDepth || isCompressed ||
3967 !gl::IsColorRenderingSupported(internalFormat, context) ||
3968 !gl::IsTextureFilteringSupported(internalFormat, context))
3969 {
3970 return gl::error(GL_INVALID_OPERATION);
3971 }
3972
3973 texture->generateMipmaps();
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00003974 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003975 }
3976 catch(std::bad_alloc&)
3977 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003978 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003979 }
3980}
3981
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003982void __stdcall glGenFencesNV(GLsizei n, GLuint* fences)
3983{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003984 EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003985
3986 try
3987 {
3988 if (n < 0)
3989 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003990 return gl::error(GL_INVALID_VALUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003991 }
3992
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003993 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003994
3995 if (context)
3996 {
3997 for (int i = 0; i < n; i++)
3998 {
3999 fences[i] = context->createFence();
4000 }
4001 }
4002 }
4003 catch(std::bad_alloc&)
4004 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004005 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004006 }
4007}
4008
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004009void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers)
4010{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004011 EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004012
4013 try
4014 {
4015 if (n < 0)
4016 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004017 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004018 }
4019
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004020 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004021
4022 if (context)
4023 {
4024 for (int i = 0; i < n; i++)
4025 {
4026 framebuffers[i] = context->createFramebuffer();
4027 }
4028 }
4029 }
4030 catch(std::bad_alloc&)
4031 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004032 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004033 }
4034}
4035
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004036void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids)
4037{
4038 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
4039
4040 try
4041 {
4042 if (n < 0)
4043 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004044 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004045 }
4046
4047 gl::Context *context = gl::getNonLostContext();
4048
4049 if (context)
4050 {
4051 for (int i = 0; i < n; i++)
4052 {
4053 ids[i] = context->createQuery();
4054 }
4055 }
4056 }
4057 catch(std::bad_alloc&)
4058 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004059 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004060 }
4061}
4062
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004063void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
4064{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004065 EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004066
4067 try
4068 {
4069 if (n < 0)
4070 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004071 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004072 }
4073
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004074 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004075
4076 if (context)
4077 {
4078 for (int i = 0; i < n; i++)
4079 {
4080 renderbuffers[i] = context->createRenderbuffer();
4081 }
4082 }
4083 }
4084 catch(std::bad_alloc&)
4085 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004086 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004087 }
4088}
4089
4090void __stdcall glGenTextures(GLsizei n, GLuint* textures)
4091{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004092 EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004093
4094 try
4095 {
4096 if (n < 0)
4097 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004098 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004099 }
4100
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004101 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004102
4103 if (context)
4104 {
4105 for (int i = 0; i < n; i++)
4106 {
4107 textures[i] = context->createTexture();
4108 }
4109 }
4110 }
4111 catch(std::bad_alloc&)
4112 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004113 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004114 }
4115}
4116
daniel@transgaming.com85423182010-04-22 13:35:27 +00004117void __stdcall glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004118{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004119 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
daniel@transgaming.com85423182010-04-22 13:35:27 +00004120 "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004121 program, index, bufsize, length, size, type, name);
4122
4123 try
4124 {
4125 if (bufsize < 0)
4126 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004127 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004128 }
4129
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004130 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com85423182010-04-22 13:35:27 +00004131
4132 if (context)
4133 {
4134 gl::Program *programObject = context->getProgram(program);
4135
4136 if (!programObject)
4137 {
4138 if (context->getShader(program))
4139 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004140 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com85423182010-04-22 13:35:27 +00004141 }
4142 else
4143 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004144 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com85423182010-04-22 13:35:27 +00004145 }
4146 }
4147
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004148 if (index >= (GLuint)programObject->getActiveAttributeCount())
daniel@transgaming.com85423182010-04-22 13:35:27 +00004149 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004150 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com85423182010-04-22 13:35:27 +00004151 }
4152
4153 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
4154 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004155 }
4156 catch(std::bad_alloc&)
4157 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004158 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004159 }
4160}
4161
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004162void __stdcall glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004163{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004164 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004165 "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 +00004166 program, index, bufsize, length, size, type, name);
4167
4168 try
4169 {
4170 if (bufsize < 0)
4171 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004172 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004173 }
4174
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004175 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004176
4177 if (context)
4178 {
4179 gl::Program *programObject = context->getProgram(program);
4180
4181 if (!programObject)
4182 {
4183 if (context->getShader(program))
4184 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004185 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004186 }
4187 else
4188 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004189 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004190 }
4191 }
4192
4193 if (index >= (GLuint)programObject->getActiveUniformCount())
4194 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004195 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004196 }
4197
4198 programObject->getActiveUniform(index, bufsize, length, size, type, name);
4199 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004200 }
4201 catch(std::bad_alloc&)
4202 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004203 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004204 }
4205}
4206
4207void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
4208{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004209 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 +00004210 program, maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004211
4212 try
4213 {
4214 if (maxcount < 0)
4215 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004216 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004217 }
4218
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004219 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com6c785212010-03-30 03:36:17 +00004220
4221 if (context)
4222 {
4223 gl::Program *programObject = context->getProgram(program);
4224
4225 if (!programObject)
4226 {
daniel@transgaming.com23953e32010-04-13 19:53:31 +00004227 if (context->getShader(program))
4228 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004229 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com23953e32010-04-13 19:53:31 +00004230 }
4231 else
4232 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004233 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com23953e32010-04-13 19:53:31 +00004234 }
daniel@transgaming.com6c785212010-03-30 03:36:17 +00004235 }
4236
4237 return programObject->getAttachedShaders(maxcount, count, shaders);
4238 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004239 }
4240 catch(std::bad_alloc&)
4241 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004242 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004243 }
4244}
4245
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004246int __stdcall glGetAttribLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004247{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004248 EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004249
4250 try
4251 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004252 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004253
4254 if (context)
4255 {
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004256
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004257 gl::Program *programObject = context->getProgram(program);
4258
4259 if (!programObject)
4260 {
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004261 if (context->getShader(program))
4262 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004263 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004264 }
4265 else
4266 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004267 return gl::error(GL_INVALID_VALUE, -1);
daniel@transgaming.combb274c32010-04-13 03:26:21 +00004268 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004269 }
4270
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00004271 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
daniel@transgaming.com716056c2012-07-24 18:38:59 +00004272 if (!programObject->isLinked() || !programBinary)
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00004273 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004274 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00004275 }
4276
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00004277 return programBinary->getAttributeLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004278 }
4279 }
4280 catch(std::bad_alloc&)
4281 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004282 return gl::error(GL_OUT_OF_MEMORY, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004283 }
4284
4285 return -1;
4286}
4287
4288void __stdcall glGetBooleanv(GLenum pname, GLboolean* params)
4289{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004290 EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004291
4292 try
4293 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004294 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004295
4296 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004297 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004298 if (!(context->getBooleanv(pname, params)))
4299 {
4300 GLenum nativeType;
4301 unsigned int numParams = 0;
4302 if (!context->getQueryParameterInfo(pname, &nativeType, &numParams))
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004303 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004304
4305 if (numParams == 0)
4306 return; // it is known that the pname is valid, but there are no parameters to return
4307
4308 if (nativeType == GL_FLOAT)
4309 {
4310 GLfloat *floatParams = NULL;
4311 floatParams = new GLfloat[numParams];
4312
4313 context->getFloatv(pname, floatParams);
4314
4315 for (unsigned int i = 0; i < numParams; ++i)
4316 {
4317 if (floatParams[i] == 0.0f)
4318 params[i] = GL_FALSE;
4319 else
4320 params[i] = GL_TRUE;
4321 }
4322
4323 delete [] floatParams;
4324 }
4325 else if (nativeType == GL_INT)
4326 {
4327 GLint *intParams = NULL;
4328 intParams = new GLint[numParams];
4329
4330 context->getIntegerv(pname, intParams);
4331
4332 for (unsigned int i = 0; i < numParams; ++i)
4333 {
4334 if (intParams[i] == 0)
4335 params[i] = GL_FALSE;
4336 else
4337 params[i] = GL_TRUE;
4338 }
4339
4340 delete [] intParams;
4341 }
4342 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004343 }
4344 }
4345 catch(std::bad_alloc&)
4346 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004347 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004348 }
4349}
4350
4351void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
4352{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004353 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 +00004354
4355 try
4356 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004357 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004358
4359 if (context)
4360 {
4361 gl::Buffer *buffer;
4362
4363 switch (target)
4364 {
4365 case GL_ARRAY_BUFFER:
4366 buffer = context->getArrayBuffer();
4367 break;
4368 case GL_ELEMENT_ARRAY_BUFFER:
4369 buffer = context->getElementArrayBuffer();
4370 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004371 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004372 }
4373
4374 if (!buffer)
4375 {
4376 // A null buffer means that "0" is bound to the requested buffer target
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004377 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004378 }
4379
4380 switch (pname)
4381 {
4382 case GL_BUFFER_USAGE:
4383 *params = buffer->usage();
4384 break;
4385 case GL_BUFFER_SIZE:
4386 *params = buffer->size();
4387 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004388 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00004389 }
4390 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004391 }
4392 catch(std::bad_alloc&)
4393 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004394 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004395 }
4396}
4397
4398GLenum __stdcall glGetError(void)
4399{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004400 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004401
4402 gl::Context *context = gl::getContext();
4403
4404 if (context)
4405 {
daniel@transgaming.com82b28912011-12-12 21:01:35 +00004406 return context->getError();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004407 }
4408
4409 return GL_NO_ERROR;
4410}
4411
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004412void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
4413{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004414 EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004415
4416 try
4417 {
4418
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004419 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004420
4421 if (context)
4422 {
4423 gl::Fence *fenceObject = context->getFence(fence);
4424
4425 if (fenceObject == NULL)
4426 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004427 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004428 }
4429
4430 fenceObject->getFenceiv(pname, params);
4431 }
4432 }
4433 catch(std::bad_alloc&)
4434 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004435 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004436 }
4437}
4438
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004439void __stdcall glGetFloatv(GLenum pname, GLfloat* params)
4440{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004441 EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004442
4443 try
4444 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004445 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004446
4447 if (context)
4448 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004449 if (!(context->getFloatv(pname, params)))
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004450 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004451 GLenum nativeType;
4452 unsigned int numParams = 0;
4453 if (!context->getQueryParameterInfo(pname, &nativeType, &numParams))
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004454 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004455
4456 if (numParams == 0)
4457 return; // it is known that the pname is valid, but that there are no parameters to return.
4458
4459 if (nativeType == GL_BOOL)
4460 {
4461 GLboolean *boolParams = NULL;
4462 boolParams = new GLboolean[numParams];
4463
4464 context->getBooleanv(pname, boolParams);
4465
4466 for (unsigned int i = 0; i < numParams; ++i)
4467 {
4468 if (boolParams[i] == GL_FALSE)
4469 params[i] = 0.0f;
4470 else
4471 params[i] = 1.0f;
4472 }
4473
4474 delete [] boolParams;
4475 }
4476 else if (nativeType == GL_INT)
4477 {
4478 GLint *intParams = NULL;
4479 intParams = new GLint[numParams];
4480
4481 context->getIntegerv(pname, intParams);
4482
4483 for (unsigned int i = 0; i < numParams; ++i)
4484 {
4485 params[i] = (GLfloat)intParams[i];
4486 }
4487
4488 delete [] intParams;
4489 }
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004490 }
4491 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004492 }
4493 catch(std::bad_alloc&)
4494 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004495 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004496 }
4497}
4498
4499void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
4500{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004501 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 +00004502 target, attachment, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004503
4504 try
4505 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004506 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004507
4508 if (context)
4509 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004510 if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004511 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004512 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004513 }
4514
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004515 gl::Framebuffer *framebuffer = NULL;
4516 if (target == GL_READ_FRAMEBUFFER_ANGLE)
4517 {
4518 if(context->getReadFramebufferHandle() == 0)
4519 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004520 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004521 }
4522
4523 framebuffer = context->getReadFramebuffer();
4524 }
4525 else
4526 {
4527 if (context->getDrawFramebufferHandle() == 0)
4528 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004529 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00004530 }
4531
4532 framebuffer = context->getDrawFramebuffer();
4533 }
4534
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004535 GLenum attachmentType;
4536 GLuint attachmentHandle;
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00004537
4538 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004539 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00004540 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
4541
4542 if (colorAttachment >= context->getMaximumRenderTargets())
4543 {
4544 return gl::error(GL_INVALID_ENUM);
4545 }
4546
4547 attachmentType = framebuffer->getColorbufferType(colorAttachment);
4548 attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment);
4549 }
4550 else
4551 {
4552 switch (attachment)
4553 {
4554 case GL_DEPTH_ATTACHMENT:
4555 attachmentType = framebuffer->getDepthbufferType();
4556 attachmentHandle = framebuffer->getDepthbufferHandle();
4557 break;
4558 case GL_STENCIL_ATTACHMENT:
4559 attachmentType = framebuffer->getStencilbufferType();
4560 attachmentHandle = framebuffer->getStencilbufferHandle();
4561 break;
4562 default: return gl::error(GL_INVALID_ENUM);
4563 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004564 }
4565
4566 GLenum attachmentObjectType; // Type category
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00004567 if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004568 {
4569 attachmentObjectType = attachmentType;
4570 }
apatrick@chromium.org551022e2012-01-23 19:56:54 +00004571 else if (gl::IsInternalTextureTarget(attachmentType))
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004572 {
4573 attachmentObjectType = GL_TEXTURE;
4574 }
apatrick@chromium.orga1d80592012-01-25 21:52:10 +00004575 else
4576 {
4577 UNREACHABLE();
4578 return;
4579 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004580
4581 switch (pname)
4582 {
4583 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
4584 *params = attachmentObjectType;
4585 break;
4586 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
4587 if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE)
4588 {
4589 *params = attachmentHandle;
4590 }
4591 else
4592 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004593 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004594 }
4595 break;
4596 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
4597 if (attachmentObjectType == GL_TEXTURE)
4598 {
4599 *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0
4600 }
4601 else
4602 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004603 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004604 }
4605 break;
4606 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
4607 if (attachmentObjectType == GL_TEXTURE)
4608 {
daniel@transgaming.com19ffc242010-05-04 03:35:21 +00004609 if (gl::IsCubemapTextureTarget(attachmentType))
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004610 {
4611 *params = attachmentType;
4612 }
4613 else
4614 {
4615 *params = 0;
4616 }
4617 }
4618 else
4619 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004620 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004621 }
4622 break;
4623 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004624 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00004625 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004626 }
4627 }
4628 catch(std::bad_alloc&)
4629 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004630 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004631 }
4632}
4633
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00004634GLenum __stdcall glGetGraphicsResetStatusEXT(void)
4635{
4636 EVENT("()");
4637
4638 try
4639 {
4640 gl::Context *context = gl::getContext();
4641
4642 if (context)
4643 {
4644 return context->getResetStatus();
4645 }
4646
4647 return GL_NO_ERROR;
4648 }
4649 catch(std::bad_alloc&)
4650 {
4651 return GL_OUT_OF_MEMORY;
4652 }
4653}
4654
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004655void __stdcall glGetIntegerv(GLenum pname, GLint* params)
4656{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004657 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004658
4659 try
4660 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004661 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004662
4663 if (context)
4664 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004665 if (!(context->getIntegerv(pname, params)))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004666 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004667 GLenum nativeType;
4668 unsigned int numParams = 0;
4669 if (!context->getQueryParameterInfo(pname, &nativeType, &numParams))
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004670 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004671
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004672 if (numParams == 0)
4673 return; // it is known that pname is valid, but there are no parameters to return
4674
4675 if (nativeType == GL_BOOL)
4676 {
4677 GLboolean *boolParams = NULL;
4678 boolParams = new GLboolean[numParams];
4679
4680 context->getBooleanv(pname, boolParams);
4681
4682 for (unsigned int i = 0; i < numParams; ++i)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004683 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004684 if (boolParams[i] == GL_FALSE)
4685 params[i] = 0;
4686 else
4687 params[i] = 1;
4688 }
4689
4690 delete [] boolParams;
4691 }
4692 else if (nativeType == GL_FLOAT)
4693 {
4694 GLfloat *floatParams = NULL;
4695 floatParams = new GLfloat[numParams];
4696
4697 context->getFloatv(pname, floatParams);
4698
4699 for (unsigned int i = 0; i < numParams; ++i)
4700 {
daniel@transgaming.comc1641352010-04-26 15:33:36 +00004701 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 +00004702 {
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004703 params[i] = (GLint)(((GLfloat)(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004704 }
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004705 else
4706 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 +00004707 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004708
daniel@transgaming.com777f2672010-04-07 03:25:16 +00004709 delete [] floatParams;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004710 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004711 }
4712 }
4713 }
4714 catch(std::bad_alloc&)
4715 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004716 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004717 }
4718}
4719
4720void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params)
4721{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004722 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004723
4724 try
4725 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004726 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004727
4728 if (context)
4729 {
4730 gl::Program *programObject = context->getProgram(program);
4731
4732 if (!programObject)
4733 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004734 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004735 }
4736
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00004737 if (context->getClientVersion() < 3)
4738 {
4739 switch (pname)
4740 {
4741 case GL_ACTIVE_UNIFORM_BLOCKS:
4742 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
4743 return gl::error(GL_INVALID_ENUM);
4744 }
4745 }
4746
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004747 switch (pname)
4748 {
4749 case GL_DELETE_STATUS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004750 *params = programObject->isFlaggedForDeletion();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004751 return;
4752 case GL_LINK_STATUS:
daniel@transgaming.com716056c2012-07-24 18:38:59 +00004753 *params = programObject->isLinked();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004754 return;
4755 case GL_VALIDATE_STATUS:
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004756 *params = programObject->isValidated();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004757 return;
4758 case GL_INFO_LOG_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004759 *params = programObject->getInfoLogLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004760 return;
4761 case GL_ATTACHED_SHADERS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004762 *params = programObject->getAttachedShadersCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004763 return;
4764 case GL_ACTIVE_ATTRIBUTES:
daniel@transgaming.com85423182010-04-22 13:35:27 +00004765 *params = programObject->getActiveAttributeCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004766 return;
4767 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
daniel@transgaming.com85423182010-04-22 13:35:27 +00004768 *params = programObject->getActiveAttributeMaxLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004769 return;
4770 case GL_ACTIVE_UNIFORMS:
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004771 *params = programObject->getActiveUniformCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004772 return;
4773 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00004774 *params = programObject->getActiveUniformMaxLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004775 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00004776 case GL_PROGRAM_BINARY_LENGTH_OES:
apatrick@chromium.org90080e32012-07-09 22:15:33 +00004777 *params = programObject->getProgramBinaryLength();
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00004778 return;
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00004779 case GL_ACTIVE_UNIFORM_BLOCKS:
4780 *params = programObject->getActiveUniformBlockCount();
4781 return;
4782 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
4783 *params = programObject->getActiveUniformBlockMaxLength();
4784 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004785 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004786 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004787 }
4788 }
4789 }
4790 catch(std::bad_alloc&)
4791 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004792 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004793 }
4794}
4795
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004796void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004797{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004798 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 +00004799 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004800
4801 try
4802 {
4803 if (bufsize < 0)
4804 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004805 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004806 }
4807
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004808 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004809
4810 if (context)
4811 {
4812 gl::Program *programObject = context->getProgram(program);
4813
4814 if (!programObject)
4815 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004816 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004817 }
4818
4819 programObject->getInfoLog(bufsize, length, infolog);
4820 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004821 }
4822 catch(std::bad_alloc&)
4823 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004824 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004825 }
4826}
4827
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004828void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
4829{
4830 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
4831
4832 try
4833 {
4834 switch (pname)
4835 {
4836 case GL_CURRENT_QUERY_EXT:
4837 break;
4838 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004839 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004840 }
4841
4842 gl::Context *context = gl::getNonLostContext();
4843
4844 if (context)
4845 {
4846 params[0] = context->getActiveQuery(target);
4847 }
4848 }
4849 catch(std::bad_alloc&)
4850 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004851 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004852 }
4853}
4854
4855void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
4856{
4857 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
4858
4859 try
4860 {
4861 switch (pname)
4862 {
4863 case GL_QUERY_RESULT_EXT:
4864 case GL_QUERY_RESULT_AVAILABLE_EXT:
4865 break;
4866 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004867 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004868 }
4869 gl::Context *context = gl::getNonLostContext();
4870
4871 if (context)
4872 {
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004873 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
4874
4875 if (!queryObject)
4876 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004877 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004878 }
4879
4880 if (context->getActiveQuery(queryObject->getType()) == id)
4881 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004882 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004883 }
4884
4885 switch(pname)
4886 {
4887 case GL_QUERY_RESULT_EXT:
4888 params[0] = queryObject->getResult();
4889 break;
4890 case GL_QUERY_RESULT_AVAILABLE_EXT:
4891 params[0] = queryObject->isResultAvailable();
4892 break;
4893 default:
4894 ASSERT(false);
4895 }
4896 }
4897 }
4898 catch(std::bad_alloc&)
4899 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004900 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004901 }
4902}
4903
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004904void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
4905{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004906 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 +00004907
4908 try
4909 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004910 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004911
4912 if (context)
4913 {
4914 if (target != GL_RENDERBUFFER)
4915 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004916 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004917 }
4918
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004919 if (context->getRenderbufferHandle() == 0)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004920 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004921 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004922 }
4923
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004924 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle());
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004925
4926 switch (pname)
4927 {
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00004928 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
4929 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
4930 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
4931 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
4932 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
4933 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
4934 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
4935 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
4936 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00004937 case GL_RENDERBUFFER_SAMPLES_ANGLE:
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00004938 if (context->getMaxSupportedSamples() != 0)
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00004939 {
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00004940 *params = renderbuffer->getSamples();
4941 }
4942 else
4943 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004944 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00004945 }
4946 break;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004947 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004948 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00004949 }
4950 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004951 }
4952 catch(std::bad_alloc&)
4953 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004954 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004955 }
4956}
4957
4958void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
4959{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004960 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004961
4962 try
4963 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004964 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004965
4966 if (context)
4967 {
4968 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004969
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004970 if (!shaderObject)
4971 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004972 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004973 }
4974
4975 switch (pname)
4976 {
4977 case GL_SHADER_TYPE:
4978 *params = shaderObject->getType();
4979 return;
4980 case GL_DELETE_STATUS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004981 *params = shaderObject->isFlaggedForDeletion();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004982 return;
4983 case GL_COMPILE_STATUS:
4984 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
4985 return;
4986 case GL_INFO_LOG_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004987 *params = shaderObject->getInfoLogLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004988 return;
4989 case GL_SHADER_SOURCE_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00004990 *params = shaderObject->getSourceLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004991 return;
zmo@google.coma574f782011-10-03 21:45:23 +00004992 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
4993 *params = shaderObject->getTranslatedSourceLength();
4994 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004995 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004996 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004997 }
4998 }
4999 }
5000 catch(std::bad_alloc&)
5001 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005002 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005003 }
5004}
5005
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005006void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005007{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005008 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 +00005009 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005010
5011 try
5012 {
5013 if (bufsize < 0)
5014 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005015 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005016 }
5017
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005018 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005019
5020 if (context)
5021 {
5022 gl::Shader *shaderObject = context->getShader(shader);
5023
5024 if (!shaderObject)
5025 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005026 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005027 }
5028
5029 shaderObject->getInfoLog(bufsize, length, infolog);
5030 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005031 }
5032 catch(std::bad_alloc&)
5033 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005034 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005035 }
5036}
5037
5038void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
5039{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005040 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 +00005041 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005042
5043 try
5044 {
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005045 switch (shadertype)
5046 {
5047 case GL_VERTEX_SHADER:
5048 case GL_FRAGMENT_SHADER:
5049 break;
5050 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005051 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005052 }
5053
5054 switch (precisiontype)
5055 {
5056 case GL_LOW_FLOAT:
5057 case GL_MEDIUM_FLOAT:
5058 case GL_HIGH_FLOAT:
5059 // Assume IEEE 754 precision
5060 range[0] = 127;
5061 range[1] = 127;
daniel@transgaming.comc5c15382010-04-23 18:34:49 +00005062 *precision = 23;
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005063 break;
5064 case GL_LOW_INT:
5065 case GL_MEDIUM_INT:
5066 case GL_HIGH_INT:
5067 // Some (most) hardware only supports single-precision floating-point numbers,
5068 // which can accurately represent integers up to +/-16777216
5069 range[0] = 24;
5070 range[1] = 24;
daniel@transgaming.comc5c15382010-04-23 18:34:49 +00005071 *precision = 0;
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005072 break;
5073 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005074 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com6c785212010-03-30 03:36:17 +00005075 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005076 }
5077 catch(std::bad_alloc&)
5078 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005079 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005080 }
5081}
5082
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005083void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005084{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005085 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 +00005086 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005087
5088 try
5089 {
5090 if (bufsize < 0)
5091 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005092 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005093 }
5094
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005095 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005096
5097 if (context)
5098 {
5099 gl::Shader *shaderObject = context->getShader(shader);
5100
5101 if (!shaderObject)
5102 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005103 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00005104 }
5105
5106 shaderObject->getSource(bufsize, length, source);
5107 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005108 }
5109 catch(std::bad_alloc&)
5110 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005111 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005112 }
5113}
5114
zmo@google.coma574f782011-10-03 21:45:23 +00005115void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
5116{
5117 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
5118 shader, bufsize, length, source);
5119
5120 try
5121 {
5122 if (bufsize < 0)
5123 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005124 return gl::error(GL_INVALID_VALUE);
zmo@google.coma574f782011-10-03 21:45:23 +00005125 }
5126
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005127 gl::Context *context = gl::getNonLostContext();
zmo@google.coma574f782011-10-03 21:45:23 +00005128
5129 if (context)
5130 {
5131 gl::Shader *shaderObject = context->getShader(shader);
5132
5133 if (!shaderObject)
5134 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005135 return gl::error(GL_INVALID_OPERATION);
zmo@google.coma574f782011-10-03 21:45:23 +00005136 }
5137
5138 shaderObject->getTranslatedSource(bufsize, length, source);
5139 }
5140 }
5141 catch(std::bad_alloc&)
5142 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005143 return gl::error(GL_OUT_OF_MEMORY);
zmo@google.coma574f782011-10-03 21:45:23 +00005144 }
5145}
5146
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005147const GLubyte* __stdcall glGetString(GLenum name)
5148{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005149 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005150
5151 try
5152 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005153 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00005154
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005155 switch (name)
5156 {
5157 case GL_VENDOR:
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +00005158 return (GLubyte*)"Google Inc.";
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005159 case GL_RENDERER:
daniel@transgaming.comc23ff642011-08-16 20:28:45 +00005160 return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005161 case GL_VERSION:
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00005162 if (context->getClientVersion() == 2)
5163 {
5164 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")";
5165 }
5166 else
5167 {
5168 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")";
5169 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005170 case GL_SHADING_LANGUAGE_VERSION:
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00005171 if (context->getClientVersion() == 2)
5172 {
5173 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")";
5174 }
5175 else
5176 {
5177 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")";
5178 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005179 case GL_EXTENSIONS:
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00005180 return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : "");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005181 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005182 return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005183 }
5184 }
5185 catch(std::bad_alloc&)
5186 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005187 return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005188 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005189}
5190
5191void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
5192{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005193 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 +00005194
5195 try
5196 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005197 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005198
5199 if (context)
5200 {
5201 gl::Texture *texture;
5202
5203 switch (target)
5204 {
5205 case GL_TEXTURE_2D:
5206 texture = context->getTexture2D();
5207 break;
5208 case GL_TEXTURE_CUBE_MAP:
5209 texture = context->getTextureCubeMap();
5210 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00005211 case GL_TEXTURE_3D:
5212 if (context->getClientVersion() < 3)
5213 {
5214 return gl::error(GL_INVALID_ENUM);
5215 }
5216 texture = context->getTexture3D();
5217 break;
shannonwoods@chromium.org0c611d12013-05-30 00:15:05 +00005218 case GL_TEXTURE_2D_ARRAY:
5219 if (context->getClientVersion() < 3)
5220 {
5221 return gl::error(GL_INVALID_ENUM);
5222 }
5223 texture = context->getTexture2DArray();
5224 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005225 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005226 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005227 }
5228
5229 switch (pname)
5230 {
5231 case GL_TEXTURE_MAG_FILTER:
5232 *params = (GLfloat)texture->getMagFilter();
5233 break;
5234 case GL_TEXTURE_MIN_FILTER:
5235 *params = (GLfloat)texture->getMinFilter();
5236 break;
5237 case GL_TEXTURE_WRAP_S:
5238 *params = (GLfloat)texture->getWrapS();
5239 break;
5240 case GL_TEXTURE_WRAP_T:
5241 *params = (GLfloat)texture->getWrapT();
5242 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00005243 case GL_TEXTURE_WRAP_R:
5244 if (context->getClientVersion() < 3)
5245 {
5246 return gl::error(GL_INVALID_ENUM);
5247 }
5248 *params = (GLfloat)texture->getWrapR();
5249 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005250 case GL_TEXTURE_IMMUTABLE_FORMAT:
5251 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
daniel@transgaming.comd30bd0a2011-11-11 04:10:34 +00005252 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
5253 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005254 case GL_TEXTURE_IMMUTABLE_LEVELS:
5255 if (context->getClientVersion() < 3)
5256 {
5257 return gl::error(GL_INVALID_ENUM);
5258 }
5259 *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0);
5260 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00005261 case GL_TEXTURE_USAGE_ANGLE:
5262 *params = (GLfloat)texture->getUsage();
5263 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005264 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
5265 if (!context->supportsTextureFilterAnisotropy())
5266 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005267 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005268 }
5269 *params = (GLfloat)texture->getMaxAnisotropy();
5270 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005271 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005272 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005273 }
5274 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005275 }
5276 catch(std::bad_alloc&)
5277 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005278 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005279 }
5280}
5281
5282void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
5283{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005284 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 +00005285
5286 try
5287 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005288 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005289
5290 if (context)
5291 {
5292 gl::Texture *texture;
5293
5294 switch (target)
5295 {
5296 case GL_TEXTURE_2D:
5297 texture = context->getTexture2D();
5298 break;
5299 case GL_TEXTURE_CUBE_MAP:
5300 texture = context->getTextureCubeMap();
5301 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00005302 case GL_TEXTURE_3D:
5303 if (context->getClientVersion() < 3)
5304 {
5305 return gl::error(GL_INVALID_ENUM);
5306 }
5307 texture = context->getTexture3D();
5308 break;
shannonwoods@chromium.org0c611d12013-05-30 00:15:05 +00005309 case GL_TEXTURE_2D_ARRAY:
5310 if (context->getClientVersion() < 3)
5311 {
5312 return gl::error(GL_INVALID_ENUM);
5313 }
5314 texture = context->getTexture2DArray();
5315 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005316 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005317 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005318 }
5319
5320 switch (pname)
5321 {
5322 case GL_TEXTURE_MAG_FILTER:
5323 *params = texture->getMagFilter();
5324 break;
5325 case GL_TEXTURE_MIN_FILTER:
5326 *params = texture->getMinFilter();
5327 break;
5328 case GL_TEXTURE_WRAP_S:
5329 *params = texture->getWrapS();
5330 break;
5331 case GL_TEXTURE_WRAP_T:
5332 *params = texture->getWrapT();
5333 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00005334 case GL_TEXTURE_WRAP_R:
5335 if (context->getClientVersion() < 3)
5336 {
5337 return gl::error(GL_INVALID_ENUM);
5338 }
5339 *params = texture->getWrapR();
5340 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005341 case GL_TEXTURE_IMMUTABLE_FORMAT:
5342 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
daniel@transgaming.comd30bd0a2011-11-11 04:10:34 +00005343 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
5344 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005345 case GL_TEXTURE_IMMUTABLE_LEVELS:
5346 if (context->getClientVersion() < 3)
5347 {
5348 return gl::error(GL_INVALID_ENUM);
5349 }
5350 *params = texture->isImmutable() ? texture->levelCount() : 0;
5351 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00005352 case GL_TEXTURE_USAGE_ANGLE:
5353 *params = texture->getUsage();
5354 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005355 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
5356 if (!context->supportsTextureFilterAnisotropy())
5357 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005358 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00005359 }
5360 *params = (GLint)texture->getMaxAnisotropy();
5361 break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00005362
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005363 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005364 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00005365 }
5366 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005367 }
5368 catch(std::bad_alloc&)
5369 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005370 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005371 }
5372}
5373
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005374void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
5375{
5376 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
5377 program, location, bufSize, params);
5378
5379 try
5380 {
5381 if (bufSize < 0)
5382 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005383 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005384 }
5385
5386 gl::Context *context = gl::getNonLostContext();
5387
5388 if (context)
5389 {
5390 if (program == 0)
5391 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005392 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005393 }
5394
5395 gl::Program *programObject = context->getProgram(program);
5396
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005397 if (!programObject || !programObject->isLinked())
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005398 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005399 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005400 }
5401
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005402 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5403 if (!programBinary)
5404 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005405 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005406 }
5407
5408 if (!programBinary->getUniformfv(location, &bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005409 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005410 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005411 }
5412 }
5413 }
5414 catch(std::bad_alloc&)
5415 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005416 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005417 }
5418}
5419
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005420void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params)
5421{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005422 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005423
5424 try
5425 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005426 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005427
5428 if (context)
5429 {
5430 if (program == 0)
5431 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005432 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005433 }
5434
5435 gl::Program *programObject = context->getProgram(program);
5436
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005437 if (!programObject || !programObject->isLinked())
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005438 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005439 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005440 }
5441
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005442 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5443 if (!programBinary)
5444 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005445 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005446 }
5447
5448 if (!programBinary->getUniformfv(location, NULL, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005449 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005450 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005451 }
5452 }
5453 }
5454 catch(std::bad_alloc&)
5455 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005456 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005457 }
5458}
5459
5460void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
5461{
5462 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
5463 program, location, bufSize, params);
5464
5465 try
5466 {
5467 if (bufSize < 0)
5468 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005469 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005470 }
5471
5472 gl::Context *context = gl::getNonLostContext();
5473
5474 if (context)
5475 {
5476 if (program == 0)
5477 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005478 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005479 }
5480
5481 gl::Program *programObject = context->getProgram(program);
5482
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005483 if (!programObject || !programObject->isLinked())
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005484 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005485 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00005486 }
5487
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005488 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5489 if (!programBinary)
5490 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005491 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005492 }
5493
5494 if (!programBinary->getUniformiv(location, &bufSize, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005495 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005496 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005497 }
5498 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005499 }
5500 catch(std::bad_alloc&)
5501 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005502 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005503 }
5504}
5505
5506void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params)
5507{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005508 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005509
5510 try
5511 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005512 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005513
5514 if (context)
5515 {
5516 if (program == 0)
5517 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005518 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005519 }
5520
5521 gl::Program *programObject = context->getProgram(program);
5522
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005523 if (!programObject || !programObject->isLinked())
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005524 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005525 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005526 }
5527
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005528 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
5529 if (!programBinary)
5530 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005531 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005532 }
5533
5534 if (!programBinary->getUniformiv(location, NULL, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005535 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005536 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00005537 }
5538 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005539 }
5540 catch(std::bad_alloc&)
5541 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005542 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005543 }
5544}
5545
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005546int __stdcall glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005547{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005548 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005549
5550 try
5551 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005552 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005553
5554 if (strstr(name, "gl_") == name)
5555 {
5556 return -1;
5557 }
5558
5559 if (context)
5560 {
5561 gl::Program *programObject = context->getProgram(program);
5562
5563 if (!programObject)
5564 {
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00005565 if (context->getShader(program))
5566 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005567 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00005568 }
5569 else
5570 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005571 return gl::error(GL_INVALID_VALUE, -1);
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00005572 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005573 }
5574
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005575 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005576 if (!programObject->isLinked() || !programBinary)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005577 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005578 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005579 }
5580
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005581 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005582 }
5583 }
5584 catch(std::bad_alloc&)
5585 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005586 return gl::error(GL_OUT_OF_MEMORY, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005587 }
5588
5589 return -1;
5590}
5591
5592void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
5593{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005594 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005595
5596 try
5597 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005598 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005599
daniel@transgaming.come0078962010-04-15 20:45:08 +00005600 if (context)
5601 {
5602 if (index >= gl::MAX_VERTEX_ATTRIBS)
5603 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005604 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005605 }
5606
daniel@transgaming.com83921382011-01-08 05:46:00 +00005607 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005608
daniel@transgaming.come0078962010-04-15 20:45:08 +00005609 switch (pname)
5610 {
5611 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
daniel@transgaming.com83921382011-01-08 05:46:00 +00005612 *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005613 break;
5614 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005615 *params = (GLfloat)attribState.mSize;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005616 break;
5617 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005618 *params = (GLfloat)attribState.mStride;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005619 break;
5620 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005621 *params = (GLfloat)attribState.mType;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005622 break;
5623 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005624 *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005625 break;
5626 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +00005627 *params = (GLfloat)attribState.mBoundBuffer.id();
daniel@transgaming.come0078962010-04-15 20:45:08 +00005628 break;
5629 case GL_CURRENT_VERTEX_ATTRIB:
5630 for (int i = 0; i < 4; ++i)
5631 {
shannon.woods%transgaming.com@gtempaccount.com3026dc72013-04-13 03:37:27 +00005632 params[i] = attribState.mCurrentValue.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00005633 }
5634 break;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00005635 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
5636 // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses
5637 // the same constant.
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005638 *params = (GLfloat)attribState.mDivisor;
5639 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005640 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005641 }
5642 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005643 }
5644 catch(std::bad_alloc&)
5645 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005646 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005647 }
5648}
5649
5650void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
5651{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005652 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005653
5654 try
5655 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005656 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005657
daniel@transgaming.come0078962010-04-15 20:45:08 +00005658 if (context)
5659 {
5660 if (index >= gl::MAX_VERTEX_ATTRIBS)
5661 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005662 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005663 }
5664
daniel@transgaming.com83921382011-01-08 05:46:00 +00005665 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005666
daniel@transgaming.come0078962010-04-15 20:45:08 +00005667 switch (pname)
5668 {
5669 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
daniel@transgaming.com83921382011-01-08 05:46:00 +00005670 *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005671 break;
5672 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005673 *params = attribState.mSize;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005674 break;
5675 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005676 *params = attribState.mStride;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005677 break;
5678 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005679 *params = attribState.mType;
daniel@transgaming.come0078962010-04-15 20:45:08 +00005680 break;
5681 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005682 *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005683 break;
5684 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +00005685 *params = attribState.mBoundBuffer.id();
daniel@transgaming.come0078962010-04-15 20:45:08 +00005686 break;
5687 case GL_CURRENT_VERTEX_ATTRIB:
5688 for (int i = 0; i < 4; ++i)
5689 {
shannon.woods%transgaming.com@gtempaccount.com3026dc72013-04-13 03:37:27 +00005690 float currentValue = attribState.mCurrentValue.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00005691 params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f));
5692 }
5693 break;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00005694 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
5695 // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses
5696 // the same constant.
5697 META_ASSERT(GL_VERTEX_ATTRIB_ARRAY_DIVISOR == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005698 *params = (GLint)attribState.mDivisor;
5699 break;
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005700 default: return gl::error(GL_INVALID_ENUM);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005701 }
5702 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005703 }
5704 catch(std::bad_alloc&)
5705 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005706 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005707 }
5708}
5709
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005710void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005711{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005712 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005713
5714 try
5715 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005716 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005717
daniel@transgaming.come0078962010-04-15 20:45:08 +00005718 if (context)
5719 {
5720 if (index >= gl::MAX_VERTEX_ATTRIBS)
5721 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005722 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005723 }
5724
5725 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
5726 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005727 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.come0078962010-04-15 20:45:08 +00005728 }
5729
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005730 *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index));
daniel@transgaming.come0078962010-04-15 20:45:08 +00005731 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005732 }
5733 catch(std::bad_alloc&)
5734 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005735 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005736 }
5737}
5738
5739void __stdcall glHint(GLenum target, GLenum mode)
5740{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005741 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005742
5743 try
5744 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005745 switch (mode)
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005746 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005747 case GL_FASTEST:
5748 case GL_NICEST:
5749 case GL_DONT_CARE:
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005750 break;
5751 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005752 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005753 }
5754
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005755 gl::Context *context = gl::getNonLostContext();
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005756 switch (target)
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005757 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00005758 case GL_GENERATE_MIPMAP_HINT:
5759 if (context) context->setGenerateMipmapHint(mode);
5760 break;
5761 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
5762 if (context) context->setFragmentShaderDerivativeHint(mode);
5763 break;
5764 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005765 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00005766 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005767 }
5768 catch(std::bad_alloc&)
5769 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005770 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005771 }
5772}
5773
5774GLboolean __stdcall glIsBuffer(GLuint buffer)
5775{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005776 EVENT("(GLuint buffer = %d)", buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005777
5778 try
5779 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005780 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005781
5782 if (context && buffer)
5783 {
5784 gl::Buffer *bufferObject = context->getBuffer(buffer);
5785
5786 if (bufferObject)
5787 {
5788 return GL_TRUE;
5789 }
5790 }
5791 }
5792 catch(std::bad_alloc&)
5793 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005794 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005795 }
5796
5797 return GL_FALSE;
5798}
5799
5800GLboolean __stdcall glIsEnabled(GLenum cap)
5801{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005802 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005803
5804 try
5805 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005806 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005807
5808 if (context)
5809 {
5810 switch (cap)
5811 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005812 case GL_CULL_FACE: return context->isCullFaceEnabled();
5813 case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled();
5814 case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled();
5815 case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled();
5816 case GL_SCISSOR_TEST: return context->isScissorTestEnabled();
5817 case GL_STENCIL_TEST: return context->isStencilTestEnabled();
5818 case GL_DEPTH_TEST: return context->isDepthTestEnabled();
5819 case GL_BLEND: return context->isBlendEnabled();
5820 case GL_DITHER: return context->isDitherEnabled();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005821 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005822 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005823 }
5824 }
5825 }
5826 catch(std::bad_alloc&)
5827 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005828 return gl::error(GL_OUT_OF_MEMORY, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005829 }
5830
5831 return false;
5832}
5833
daniel@transgaming.comfe208882010-09-01 15:47:57 +00005834GLboolean __stdcall glIsFenceNV(GLuint fence)
5835{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005836 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00005837
5838 try
5839 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005840 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00005841
5842 if (context)
5843 {
5844 gl::Fence *fenceObject = context->getFence(fence);
5845
5846 if (fenceObject == NULL)
5847 {
5848 return GL_FALSE;
5849 }
5850
5851 return fenceObject->isFence();
5852 }
5853 }
5854 catch(std::bad_alloc&)
5855 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005856 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00005857 }
5858
5859 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00005860}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00005861
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005862GLboolean __stdcall glIsFramebuffer(GLuint framebuffer)
5863{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005864 EVENT("(GLuint framebuffer = %d)", framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005865
5866 try
5867 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005868 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005869
5870 if (context && framebuffer)
5871 {
5872 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
5873
5874 if (framebufferObject)
5875 {
5876 return GL_TRUE;
5877 }
5878 }
5879 }
5880 catch(std::bad_alloc&)
5881 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005882 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005883 }
5884
5885 return GL_FALSE;
5886}
5887
5888GLboolean __stdcall glIsProgram(GLuint program)
5889{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005890 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005891
5892 try
5893 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005894 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005895
5896 if (context && program)
5897 {
5898 gl::Program *programObject = context->getProgram(program);
5899
5900 if (programObject)
5901 {
5902 return GL_TRUE;
5903 }
5904 }
5905 }
5906 catch(std::bad_alloc&)
5907 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005908 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005909 }
5910
5911 return GL_FALSE;
5912}
5913
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00005914GLboolean __stdcall glIsQueryEXT(GLuint id)
5915{
5916 EVENT("(GLuint id = %d)", id);
5917
5918 try
5919 {
5920 if (id == 0)
5921 {
5922 return GL_FALSE;
5923 }
5924
5925 gl::Context *context = gl::getNonLostContext();
5926
5927 if (context)
5928 {
5929 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
5930
5931 if (queryObject)
5932 {
5933 return GL_TRUE;
5934 }
5935 }
5936 }
5937 catch(std::bad_alloc&)
5938 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005939 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00005940 }
5941
5942 return GL_FALSE;
5943}
5944
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005945GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer)
5946{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005947 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005948
5949 try
5950 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005951 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005952
5953 if (context && renderbuffer)
5954 {
5955 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
5956
5957 if (renderbufferObject)
5958 {
5959 return GL_TRUE;
5960 }
5961 }
5962 }
5963 catch(std::bad_alloc&)
5964 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005965 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005966 }
5967
5968 return GL_FALSE;
5969}
5970
5971GLboolean __stdcall glIsShader(GLuint shader)
5972{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005973 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005974
5975 try
5976 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005977 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005978
5979 if (context && shader)
5980 {
5981 gl::Shader *shaderObject = context->getShader(shader);
5982
5983 if (shaderObject)
5984 {
5985 return GL_TRUE;
5986 }
5987 }
5988 }
5989 catch(std::bad_alloc&)
5990 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005991 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005992 }
5993
5994 return GL_FALSE;
5995}
5996
5997GLboolean __stdcall glIsTexture(GLuint texture)
5998{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005999 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006000
6001 try
6002 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006003 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006004
6005 if (context && texture)
6006 {
6007 gl::Texture *textureObject = context->getTexture(texture);
6008
6009 if (textureObject)
6010 {
6011 return GL_TRUE;
6012 }
6013 }
6014 }
6015 catch(std::bad_alloc&)
6016 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006017 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006018 }
6019
6020 return GL_FALSE;
6021}
6022
6023void __stdcall glLineWidth(GLfloat width)
6024{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006025 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006026
6027 try
6028 {
6029 if (width <= 0.0f)
6030 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006031 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006032 }
6033
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006034 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00006035
6036 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006037 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006038 context->setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006039 }
6040 }
6041 catch(std::bad_alloc&)
6042 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006043 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006044 }
6045}
6046
6047void __stdcall glLinkProgram(GLuint program)
6048{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006049 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006050
6051 try
6052 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006053 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006054
6055 if (context)
6056 {
6057 gl::Program *programObject = context->getProgram(program);
6058
6059 if (!programObject)
6060 {
daniel@transgaming.com277b7142010-04-13 03:26:44 +00006061 if (context->getShader(program))
6062 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006063 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com277b7142010-04-13 03:26:44 +00006064 }
6065 else
6066 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006067 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com277b7142010-04-13 03:26:44 +00006068 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006069 }
6070
daniel@transgaming.com95d29422012-07-24 18:36:10 +00006071 context->linkProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006072 }
6073 }
6074 catch(std::bad_alloc&)
6075 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006076 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006077 }
6078}
6079
6080void __stdcall glPixelStorei(GLenum pname, GLint param)
6081{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006082 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006083
6084 try
6085 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006086 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006087
6088 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006089 {
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006090 switch (pname)
6091 {
6092 case GL_UNPACK_ALIGNMENT:
6093 if (param != 1 && param != 2 && param != 4 && param != 8)
6094 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006095 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006096 }
6097
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006098 context->setUnpackAlignment(param);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006099 break;
6100
6101 case GL_PACK_ALIGNMENT:
6102 if (param != 1 && param != 2 && param != 4 && param != 8)
6103 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006104 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006105 }
6106
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006107 context->setPackAlignment(param);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006108 break;
6109
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00006110 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
6111 context->setPackReverseRowOrder(param != 0);
6112 break;
6113
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00006114 case GL_UNPACK_IMAGE_HEIGHT:
6115 case GL_UNPACK_SKIP_IMAGES:
6116 case GL_UNPACK_ROW_LENGTH:
6117 case GL_UNPACK_SKIP_ROWS:
6118 case GL_UNPACK_SKIP_PIXELS:
6119 case GL_PACK_ROW_LENGTH:
6120 case GL_PACK_SKIP_ROWS:
6121 case GL_PACK_SKIP_PIXELS:
6122 if (context->getClientVersion() < 3)
6123 {
6124 return gl::error(GL_INVALID_ENUM);
6125 }
6126 UNIMPLEMENTED();
6127 break;
6128
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006129 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006130 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00006131 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006132 }
6133 }
6134 catch(std::bad_alloc&)
6135 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006136 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006137 }
6138}
6139
6140void __stdcall glPolygonOffset(GLfloat factor, GLfloat units)
6141{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006142 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006143
6144 try
6145 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006146 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comaede6302010-04-29 03:35:48 +00006147
6148 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006149 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006150 context->setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006151 }
6152 }
6153 catch(std::bad_alloc&)
6154 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006155 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006156 }
6157}
6158
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006159void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
6160 GLenum format, GLenum type, GLsizei bufSize,
6161 GLvoid *data)
6162{
6163 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
6164 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
6165 x, y, width, height, format, type, bufSize, data);
6166
6167 try
6168 {
6169 if (width < 0 || height < 0 || bufSize < 0)
6170 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006171 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006172 }
6173
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006174 gl::Context *context = gl::getNonLostContext();
6175
6176 if (context)
6177 {
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006178 GLint currentInternalFormat;
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006179 GLenum currentFormat, currentType;
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006180
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006181 // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound,
6182 // and attempting to read back if that's the case is an error. The error will be registered
6183 // by getCurrentReadFormat.
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006184 if (!context->getCurrentReadFormatType(&currentInternalFormat, &currentFormat, &currentType))
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006185 return;
6186
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006187 bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) :
6188 validES3ReadFormatType(currentInternalFormat, format, type);
6189
6190 if (!(currentFormat == format && currentType == type) && !validReadFormat)
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006191 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006192 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006193 }
6194
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006195 context->readPixels(x, y, width, height, format, type, &bufSize, data);
6196 }
6197 }
6198 catch(std::bad_alloc&)
6199 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006200 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006201 }
6202}
6203
6204void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
6205 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006206{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006207 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006208 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00006209 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006210
6211 try
6212 {
6213 if (width < 0 || height < 0)
6214 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006215 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006216 }
6217
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006218 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006219
6220 if (context)
6221 {
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006222 GLint currentInternalFormat;
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006223 GLenum currentFormat, currentType;
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006224
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006225 // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound,
6226 // and attempting to read back if that's the case is an error. The error will be registered
6227 // by getCurrentReadFormat.
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006228 if (!context->getCurrentReadFormatType(&currentInternalFormat, &currentFormat, &currentType))
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006229 return;
6230
shannonwoods@chromium.org44a4f982013-05-30 00:13:49 +00006231 bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) :
6232 validES3ReadFormatType(currentInternalFormat, format, type);
6233
6234 if (!(currentFormat == format && currentType == type) && !validReadFormat)
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006235 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006236 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com42944b02012-09-27 17:45:57 +00006237 }
6238
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00006239 context->readPixels(x, y, width, height, format, type, NULL, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006240 }
6241 }
6242 catch(std::bad_alloc&)
6243 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006244 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006245 }
6246}
6247
6248void __stdcall glReleaseShaderCompiler(void)
6249{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006250 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006251
6252 try
6253 {
6254 gl::Shader::releaseCompiler();
6255 }
6256 catch(std::bad_alloc&)
6257 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006258 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006259 }
6260}
6261
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00006262void __stdcall glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006263{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006264 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 +00006265 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006266
6267 try
6268 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006269 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006270
6271 if (context)
6272 {
Geoff Lang2e1dcd52013-05-29 10:34:08 -04006273 if (!validateRenderbufferStorageParameters(context, target, samples, internalformat,
6274 width, height, true))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006275 {
Geoff Lang2e1dcd52013-05-29 10:34:08 -04006276 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006277 }
shannon.woods%transgaming.com@gtempaccount.com8dce6512013-04-13 03:42:19 +00006278
6279 context->setRenderbufferStorage(width, height, internalformat, samples);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006280 }
6281 }
6282 catch(std::bad_alloc&)
6283 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006284 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006285 }
6286}
6287
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00006288void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
6289{
6290 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
6291}
6292
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006293void __stdcall glSampleCoverage(GLclampf value, GLboolean invert)
6294{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006295 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006296
6297 try
6298 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006299 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006300
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006301 if (context)
6302 {
daniel@transgaming.coma36f98e2010-05-18 18:51:09 +00006303 context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006304 }
6305 }
6306 catch(std::bad_alloc&)
6307 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006308 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006309 }
6310}
6311
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006312void __stdcall glSetFenceNV(GLuint fence, GLenum condition)
6313{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006314 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006315
6316 try
6317 {
6318 if (condition != GL_ALL_COMPLETED_NV)
6319 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006320 return gl::error(GL_INVALID_ENUM);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006321 }
6322
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006323 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006324
6325 if (context)
6326 {
6327 gl::Fence *fenceObject = context->getFence(fence);
6328
6329 if (fenceObject == NULL)
6330 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006331 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006332 }
6333
6334 fenceObject->setFence(condition);
6335 }
6336 }
6337 catch(std::bad_alloc&)
6338 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006339 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006340 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006341}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006342
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006343void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
6344{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006345 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 +00006346
6347 try
6348 {
6349 if (width < 0 || height < 0)
6350 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006351 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006352 }
6353
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006354 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006355
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006356 if (context)
6357 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006358 context->setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006359 }
6360 }
6361 catch(std::bad_alloc&)
6362 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006363 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006364 }
6365}
6366
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006367void __stdcall glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006368{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006369 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006370 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00006371 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006372
6373 try
6374 {
daniel@transgaming.comd1f667f2010-04-29 03:38:52 +00006375 // No binary shader formats are supported.
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006376 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006377 }
6378 catch(std::bad_alloc&)
6379 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006380 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006381 }
6382}
6383
shannon.woods%transgaming.com@gtempaccount.com5f339332013-04-13 03:29:02 +00006384void __stdcall glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006385{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006386 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 +00006387 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006388
6389 try
6390 {
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006391 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006392 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006393 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006394 }
6395
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006396 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006397
6398 if (context)
6399 {
6400 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006401
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006402 if (!shaderObject)
6403 {
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006404 if (context->getProgram(shader))
6405 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006406 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006407 }
6408 else
6409 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006410 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00006411 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006412 }
6413
6414 shaderObject->setSource(count, string, length);
6415 }
6416 }
6417 catch(std::bad_alloc&)
6418 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006419 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006420 }
6421}
6422
6423void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask)
6424{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006425 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006426}
6427
6428void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
6429{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006430 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 +00006431
6432 try
6433 {
6434 switch (face)
6435 {
6436 case GL_FRONT:
6437 case GL_BACK:
6438 case GL_FRONT_AND_BACK:
6439 break;
6440 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006441 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006442 }
6443
6444 switch (func)
6445 {
6446 case GL_NEVER:
6447 case GL_ALWAYS:
6448 case GL_LESS:
6449 case GL_LEQUAL:
6450 case GL_EQUAL:
6451 case GL_GEQUAL:
6452 case GL_GREATER:
6453 case GL_NOTEQUAL:
6454 break;
6455 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006456 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006457 }
6458
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006459 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006460
6461 if (context)
6462 {
6463 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
6464 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006465 context->setStencilParams(func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006466 }
6467
6468 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
6469 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006470 context->setStencilBackParams(func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006471 }
6472 }
6473 }
6474 catch(std::bad_alloc&)
6475 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006476 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006477 }
6478}
6479
6480void __stdcall glStencilMask(GLuint mask)
6481{
6482 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
6483}
6484
6485void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask)
6486{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006487 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006488
6489 try
6490 {
6491 switch (face)
6492 {
6493 case GL_FRONT:
6494 case GL_BACK:
6495 case GL_FRONT_AND_BACK:
6496 break;
6497 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006498 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006499 }
6500
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006501 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006502
6503 if (context)
6504 {
6505 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
6506 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006507 context->setStencilWritemask(mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006508 }
6509
6510 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
6511 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006512 context->setStencilBackWritemask(mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006513 }
6514 }
6515 }
6516 catch(std::bad_alloc&)
6517 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006518 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006519 }
6520}
6521
6522void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
6523{
6524 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
6525}
6526
6527void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
6528{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006529 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 +00006530 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006531
6532 try
6533 {
6534 switch (face)
6535 {
6536 case GL_FRONT:
6537 case GL_BACK:
6538 case GL_FRONT_AND_BACK:
6539 break;
6540 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006541 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006542 }
6543
6544 switch (fail)
6545 {
6546 case GL_ZERO:
6547 case GL_KEEP:
6548 case GL_REPLACE:
6549 case GL_INCR:
6550 case GL_DECR:
6551 case GL_INVERT:
6552 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006553 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006554 break;
6555 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006556 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006557 }
6558
6559 switch (zfail)
6560 {
6561 case GL_ZERO:
6562 case GL_KEEP:
6563 case GL_REPLACE:
6564 case GL_INCR:
6565 case GL_DECR:
6566 case GL_INVERT:
6567 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006568 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006569 break;
6570 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006571 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006572 }
6573
6574 switch (zpass)
6575 {
6576 case GL_ZERO:
6577 case GL_KEEP:
6578 case GL_REPLACE:
6579 case GL_INCR:
6580 case GL_DECR:
6581 case GL_INVERT:
6582 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00006583 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006584 break;
6585 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006586 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006587 }
6588
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006589 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006590
6591 if (context)
6592 {
6593 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
6594 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006595 context->setStencilOperations(fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006596 }
6597
6598 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
6599 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00006600 context->setStencilBackOperations(fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006601 }
6602 }
6603 }
6604 catch(std::bad_alloc&)
6605 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006606 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006607 }
6608}
6609
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006610GLboolean __stdcall glTestFenceNV(GLuint fence)
6611{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006612 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006613
6614 try
6615 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006616 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006617
6618 if (context)
6619 {
6620 gl::Fence *fenceObject = context->getFence(fence);
6621
6622 if (fenceObject == NULL)
6623 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006624 return gl::error(GL_INVALID_OPERATION, GL_TRUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006625 }
6626
6627 return fenceObject->testFence();
6628 }
6629 }
6630 catch(std::bad_alloc&)
6631 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006632 gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006633 }
6634
6635 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00006636}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00006637
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00006638void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
6639 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006640{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006641 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 +00006642 "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 +00006643 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006644
6645 try
6646 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006647 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006648
6649 if (context)
6650 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006651 if (context->getClientVersion() < 3 &&
6652 !validateES2TexImageParameters(context, target, level, internalformat, false, false,
6653 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com32b11442011-11-19 02:42:48 +00006654 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006655 return;
6656 }
6657
6658 if (context->getClientVersion() >= 3 &&
6659 !validateES3TexImageParameters(context, target, level, internalformat, false, false,
6660 0, 0, 0, width, height, 1, border, format, type))
6661 {
6662 return;
daniel@transgaming.com32b11442011-11-19 02:42:48 +00006663 }
6664
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006665 switch (target)
6666 {
6667 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006668 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006669 gl::Texture2D *texture = context->getTexture2D();
6670 texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006671 }
6672 break;
6673 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00006674 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006675 gl::TextureCubeMap *texture = context->getTextureCubeMap();
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +00006676 texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006677 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00006678 break;
6679 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
6680 {
6681 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6682 texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6683 }
6684 break;
6685 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
6686 {
6687 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6688 texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6689 }
6690 break;
6691 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
6692 {
6693 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6694 texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6695 }
6696 break;
6697 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
6698 {
6699 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6700 texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6701 }
6702 break;
6703 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
6704 {
6705 gl::TextureCubeMap *texture = context->getTextureCubeMap();
6706 texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels);
6707 }
6708 break;
6709 default: UNREACHABLE();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006710 }
6711 }
6712 }
6713 catch(std::bad_alloc&)
6714 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006715 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006716 }
6717}
6718
6719void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param)
6720{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006721 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
6722
6723 try
6724 {
6725 gl::Context *context = gl::getNonLostContext();
6726
6727 if (context)
6728 {
6729 gl::Texture *texture;
6730
6731 switch (target)
6732 {
6733 case GL_TEXTURE_2D:
6734 texture = context->getTexture2D();
6735 break;
6736 case GL_TEXTURE_CUBE_MAP:
6737 texture = context->getTextureCubeMap();
6738 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00006739 case GL_TEXTURE_3D:
6740 if (context->getClientVersion() < 3)
6741 {
6742 return gl::error(GL_INVALID_ENUM);
6743 }
6744 texture = context->getTexture3D();
shannon.woods%transgaming.com@gtempaccount.com90dbc442013-04-13 03:46:14 +00006745 case GL_TEXTURE_2D_ARRAY:
6746 if (context->getClientVersion() < 3)
6747 {
6748 return gl::error(GL_INVALID_ENUM);
6749 }
6750 texture = context->getTexture2DArray();
6751 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006752 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006753 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006754 }
6755
6756 switch (pname)
6757 {
6758 case GL_TEXTURE_WRAP_S:
6759 if (!texture->setWrapS((GLenum)param))
6760 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006761 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006762 }
6763 break;
6764 case GL_TEXTURE_WRAP_T:
6765 if (!texture->setWrapT((GLenum)param))
6766 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006767 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006768 }
6769 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00006770 case GL_TEXTURE_WRAP_R:
6771 if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param))
6772 {
6773 return gl::error(GL_INVALID_ENUM);
6774 }
6775 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006776 case GL_TEXTURE_MIN_FILTER:
6777 if (!texture->setMinFilter((GLenum)param))
6778 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006779 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006780 }
6781 break;
6782 case GL_TEXTURE_MAG_FILTER:
6783 if (!texture->setMagFilter((GLenum)param))
6784 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006785 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006786 }
6787 break;
6788 case GL_TEXTURE_USAGE_ANGLE:
6789 if (!texture->setUsage((GLenum)param))
6790 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006791 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006792 }
6793 break;
6794 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
6795 if (!context->supportsTextureFilterAnisotropy())
6796 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006797 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006798 }
6799 if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()))
6800 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006801 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006802 }
6803 break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00006804
6805 case GL_TEXTURE_MIN_LOD:
6806 case GL_TEXTURE_MAX_LOD:
6807 if (context->getClientVersion() < 3)
6808 {
6809 return gl::error(GL_INVALID_ENUM);
6810 }
6811 UNIMPLEMENTED();
6812 break;
6813
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006814 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006815 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006816 }
6817 }
6818 }
6819 catch(std::bad_alloc&)
6820 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006821 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006822 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006823}
6824
6825void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
6826{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006827 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006828}
6829
6830void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param)
6831{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00006832 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006833
6834 try
6835 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00006836 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006837
6838 if (context)
6839 {
6840 gl::Texture *texture;
6841
6842 switch (target)
6843 {
6844 case GL_TEXTURE_2D:
6845 texture = context->getTexture2D();
6846 break;
6847 case GL_TEXTURE_CUBE_MAP:
6848 texture = context->getTextureCubeMap();
6849 break;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +00006850 case GL_TEXTURE_3D:
6851 if (context->getClientVersion() < 3)
6852 {
6853 return gl::error(GL_INVALID_ENUM);
6854 }
6855 texture = context->getTexture3D();
6856 break;
shannon.woods%transgaming.com@gtempaccount.com90dbc442013-04-13 03:46:14 +00006857 case GL_TEXTURE_2D_ARRAY:
6858 if (context->getClientVersion() < 3)
6859 {
6860 return gl::error(GL_INVALID_ENUM);
6861 }
6862 texture = context->getTexture2DArray();
6863 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006864 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006865 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006866 }
6867
6868 switch (pname)
6869 {
6870 case GL_TEXTURE_WRAP_S:
6871 if (!texture->setWrapS((GLenum)param))
6872 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006873 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006874 }
6875 break;
6876 case GL_TEXTURE_WRAP_T:
6877 if (!texture->setWrapT((GLenum)param))
6878 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006879 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006880 }
6881 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00006882 case GL_TEXTURE_WRAP_R:
6883 if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param))
6884 {
6885 return gl::error(GL_INVALID_ENUM);
6886 }
6887 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006888 case GL_TEXTURE_MIN_FILTER:
6889 if (!texture->setMinFilter((GLenum)param))
6890 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006891 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006892 }
6893 break;
6894 case GL_TEXTURE_MAG_FILTER:
6895 if (!texture->setMagFilter((GLenum)param))
6896 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006897 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006898 }
6899 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00006900 case GL_TEXTURE_USAGE_ANGLE:
6901 if (!texture->setUsage((GLenum)param))
6902 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006903 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00006904 }
6905 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006906 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
6907 if (!context->supportsTextureFilterAnisotropy())
6908 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006909 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006910 }
6911 if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()))
6912 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006913 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00006914 }
6915 break;
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00006916
6917 case GL_TEXTURE_SWIZZLE_R:
6918 case GL_TEXTURE_SWIZZLE_G:
6919 case GL_TEXTURE_SWIZZLE_B:
6920 case GL_TEXTURE_SWIZZLE_A:
6921 case GL_TEXTURE_BASE_LEVEL:
6922 case GL_TEXTURE_MAX_LEVEL:
6923 case GL_TEXTURE_COMPARE_MODE:
6924 case GL_TEXTURE_COMPARE_FUNC:
6925 if (context->getClientVersion() < 3)
6926 {
6927 return gl::error(GL_INVALID_ENUM);
6928 }
6929 UNIMPLEMENTED();
6930 break;
6931
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006932 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006933 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006934 }
6935 }
6936 }
6937 catch(std::bad_alloc&)
6938 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006939 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00006940 }
6941}
6942
6943void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
6944{
6945 glTexParameteri(target, pname, *params);
6946}
6947
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00006948void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
6949{
6950 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
6951 target, levels, internalformat, width, height);
6952
6953 try
6954 {
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00006955 gl::Context *context = gl::getNonLostContext();
6956
6957 if (context)
6958 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006959 if (context->getClientVersion() < 3 &&
6960 !validateES2TexStorageParameters(context, target, levels, internalformat, width, height))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006961 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006962 return;
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006963 }
6964
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006965 if (context->getClientVersion() >= 3 &&
6966 !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006967 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006968 return;
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00006969 }
6970
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006971 switch (target)
6972 {
6973 case GL_TEXTURE_2D:
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006974 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006975 gl::Texture2D *texture2d = context->getTexture2D();
6976 texture2d->storage(levels, internalformat, width, height);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006977 }
6978 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006979
6980 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
6981 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
6982 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
6983 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
6984 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
6985 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006986 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006987 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
6988 textureCube->storage(levels, internalformat, width);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006989 }
6990 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00006991
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006992 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006993 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00006994 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00006995 }
6996 }
6997 catch(std::bad_alloc&)
6998 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00006999 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00007000 }
7001}
7002
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00007003void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
7004 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007005{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007006 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007007 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00007008 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007009 target, level, xoffset, yoffset, width, height, format, type, pixels);
7010
7011 try
7012 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007013 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007014
7015 if (context)
7016 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007017 if (context->getClientVersion() < 3 &&
7018 !validateES2TexImageParameters(context, target, level, GL_NONE, false, true,
7019 0, 0, width, height, 0, format, type, pixels))
daniel@transgaming.com1d2d3c42012-05-31 01:14:15 +00007020 {
7021 return;
7022 }
7023
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007024 if (context->getClientVersion() >= 3 &&
7025 !validateES3TexImageParameters(context, target, level, GL_NONE, false, true,
7026 0, 0, 0, width, height, 1, 0, format, type))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007027 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007028 return;
7029 }
7030
7031 switch (target)
7032 {
7033 case GL_TEXTURE_2D:
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007034 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007035 gl::Texture2D *texture = context->getTexture2D();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00007036 texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007037 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007038 break;
7039
7040 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
7041 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
7042 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
7043 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
7044 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
7045 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007046 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007047 gl::TextureCubeMap *texture = context->getTextureCubeMap();
daniel@transgaming.com343373a2011-11-29 19:42:32 +00007048 texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007049 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00007050 break;
7051
7052 default:
7053 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00007054 }
7055 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007056 }
7057 catch(std::bad_alloc&)
7058 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007059 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007060 }
7061}
7062
7063void __stdcall glUniform1f(GLint location, GLfloat x)
7064{
7065 glUniform1fv(location, 1, &x);
7066}
7067
7068void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
7069{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007070 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007071
7072 try
7073 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007074 if (count < 0)
7075 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007076 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007077 }
7078
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007079 if (location == -1)
7080 {
7081 return;
7082 }
7083
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007084 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007085
7086 if (context)
7087 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007088 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007089 if (!programBinary)
7090 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007091 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007092 }
7093
7094 if (!programBinary->setUniform1fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007095 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007096 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007097 }
7098 }
7099 }
7100 catch(std::bad_alloc&)
7101 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007102 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007103 }
7104}
7105
7106void __stdcall glUniform1i(GLint location, GLint x)
7107{
7108 glUniform1iv(location, 1, &x);
7109}
7110
7111void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v)
7112{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007113 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007114
7115 try
7116 {
7117 if (count < 0)
7118 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007119 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007120 }
7121
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007122 if (location == -1)
7123 {
7124 return;
7125 }
7126
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007127 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007128
7129 if (context)
7130 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007131 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007132 if (!programBinary)
7133 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007134 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007135 }
7136
7137 if (!programBinary->setUniform1iv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007138 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007139 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007140 }
7141 }
7142 }
7143 catch(std::bad_alloc&)
7144 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007145 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007146 }
7147}
7148
7149void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y)
7150{
7151 GLfloat xy[2] = {x, y};
7152
7153 glUniform2fv(location, 1, (GLfloat*)&xy);
7154}
7155
7156void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
7157{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007158 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007159
7160 try
7161 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007162 if (count < 0)
7163 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007164 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007165 }
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007166
7167 if (location == -1)
7168 {
7169 return;
7170 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007171
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007172 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007173
7174 if (context)
7175 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007176 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007177 if (!programBinary)
7178 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007179 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007180 }
7181
7182 if (!programBinary->setUniform2fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007183 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007184 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007185 }
7186 }
7187 }
7188 catch(std::bad_alloc&)
7189 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007190 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007191 }
7192}
7193
7194void __stdcall glUniform2i(GLint location, GLint x, GLint y)
7195{
7196 GLint xy[4] = {x, y};
7197
7198 glUniform2iv(location, 1, (GLint*)&xy);
7199}
7200
7201void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v)
7202{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007203 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007204
7205 try
7206 {
7207 if (count < 0)
7208 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007209 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007210 }
7211
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007212 if (location == -1)
7213 {
7214 return;
7215 }
7216
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007217 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007218
7219 if (context)
7220 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007221 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007222 if (!programBinary)
7223 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007224 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007225 }
7226
7227 if (!programBinary->setUniform2iv(location, count, v))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007228 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007229 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007230 }
7231 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007232 }
7233 catch(std::bad_alloc&)
7234 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007235 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007236 }
7237}
7238
7239void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
7240{
7241 GLfloat xyz[3] = {x, y, z};
7242
7243 glUniform3fv(location, 1, (GLfloat*)&xyz);
7244}
7245
7246void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
7247{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007248 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007249
7250 try
7251 {
7252 if (count < 0)
7253 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007254 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007255 }
7256
7257 if (location == -1)
7258 {
7259 return;
7260 }
7261
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007262 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007263
7264 if (context)
7265 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007266 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007267 if (!programBinary)
7268 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007269 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007270 }
7271
7272 if (!programBinary->setUniform3fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007273 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007274 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007275 }
7276 }
7277 }
7278 catch(std::bad_alloc&)
7279 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007280 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007281 }
7282}
7283
7284void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z)
7285{
7286 GLint xyz[3] = {x, y, z};
7287
7288 glUniform3iv(location, 1, (GLint*)&xyz);
7289}
7290
7291void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v)
7292{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007293 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007294
7295 try
7296 {
7297 if (count < 0)
7298 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007299 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007300 }
7301
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007302 if (location == -1)
7303 {
7304 return;
7305 }
7306
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007307 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007308
7309 if (context)
7310 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007311 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007312 if (!programBinary)
7313 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007314 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007315 }
7316
7317 if (!programBinary->setUniform3iv(location, count, v))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007318 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007319 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007320 }
7321 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007322 }
7323 catch(std::bad_alloc&)
7324 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007325 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007326 }
7327}
7328
7329void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
7330{
7331 GLfloat xyzw[4] = {x, y, z, w};
7332
7333 glUniform4fv(location, 1, (GLfloat*)&xyzw);
7334}
7335
7336void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
7337{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007338 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007339
7340 try
7341 {
7342 if (count < 0)
7343 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007344 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007345 }
7346
7347 if (location == -1)
7348 {
7349 return;
7350 }
7351
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007352 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007353
7354 if (context)
7355 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007356 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007357 if (!programBinary)
7358 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007359 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007360 }
7361
7362 if (!programBinary->setUniform4fv(location, count, v))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007363 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007364 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007365 }
7366 }
7367 }
7368 catch(std::bad_alloc&)
7369 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007370 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007371 }
7372}
7373
7374void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
7375{
7376 GLint xyzw[4] = {x, y, z, w};
7377
7378 glUniform4iv(location, 1, (GLint*)&xyzw);
7379}
7380
7381void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v)
7382{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007383 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007384
7385 try
7386 {
7387 if (count < 0)
7388 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007389 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007390 }
7391
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007392 if (location == -1)
7393 {
7394 return;
7395 }
7396
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007397 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007398
7399 if (context)
7400 {
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007401 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007402 if (!programBinary)
7403 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007404 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007405 }
7406
7407 if (!programBinary->setUniform4iv(location, count, v))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007408 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007409 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00007410 }
7411 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007412 }
7413 catch(std::bad_alloc&)
7414 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007415 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007416 }
7417}
7418
7419void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
7420{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007421 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007422 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007423
7424 try
7425 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007426 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007427 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007428 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007429 }
7430
7431 if (location == -1)
7432 {
7433 return;
7434 }
7435
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007436 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007437
7438 if (context)
7439 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007440 if (transpose != GL_FALSE && context->getClientVersion() < 3)
7441 {
7442 return gl::error(GL_INVALID_VALUE);
7443 }
7444
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007445 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007446 if (!programBinary)
7447 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007448 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007449 }
7450
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007451 if (!programBinary->setUniformMatrix2fv(location, count, transpose, value))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007452 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007453 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007454 }
7455 }
7456 }
7457 catch(std::bad_alloc&)
7458 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007459 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007460 }
7461}
7462
7463void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
7464{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007465 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007466 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007467
7468 try
7469 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007470 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007471 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007472 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007473 }
7474
7475 if (location == -1)
7476 {
7477 return;
7478 }
7479
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007480 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007481
7482 if (context)
7483 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007484 if (transpose != GL_FALSE && context->getClientVersion() < 3)
7485 {
7486 return gl::error(GL_INVALID_VALUE);
7487 }
7488
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007489 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007490 if (!programBinary)
7491 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007492 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007493 }
7494
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007495 if (!programBinary->setUniformMatrix3fv(location, count, transpose, value))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007496 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007497 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007498 }
7499 }
7500 }
7501 catch(std::bad_alloc&)
7502 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007503 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007504 }
7505}
7506
7507void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
7508{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007509 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007510 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007511
7512 try
7513 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007514 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007515 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007516 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007517 }
7518
7519 if (location == -1)
7520 {
7521 return;
7522 }
7523
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007524 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007525
7526 if (context)
7527 {
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007528 if (transpose != GL_FALSE && context->getClientVersion() < 3)
7529 {
7530 return gl::error(GL_INVALID_VALUE);
7531 }
7532
daniel@transgaming.com62a28462012-07-24 18:33:59 +00007533 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007534 if (!programBinary)
7535 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007536 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00007537 }
7538
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00007539 if (!programBinary->setUniformMatrix4fv(location, count, transpose, value))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007540 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007541 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007542 }
7543 }
7544 }
7545 catch(std::bad_alloc&)
7546 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007547 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007548 }
7549}
7550
7551void __stdcall glUseProgram(GLuint program)
7552{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007553 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007554
7555 try
7556 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007557 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007558
7559 if (context)
7560 {
7561 gl::Program *programObject = context->getProgram(program);
7562
daniel@transgaming.comc8478202010-04-13 19:53:35 +00007563 if (!programObject && program != 0)
7564 {
7565 if (context->getShader(program))
7566 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007567 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comc8478202010-04-13 19:53:35 +00007568 }
7569 else
7570 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007571 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comc8478202010-04-13 19:53:35 +00007572 }
7573 }
7574
daniel@transgaming.com716056c2012-07-24 18:38:59 +00007575 if (program != 0 && !programObject->isLinked())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007576 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007577 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007578 }
7579
7580 context->useProgram(program);
7581 }
7582 }
7583 catch(std::bad_alloc&)
7584 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007585 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007586 }
7587}
7588
7589void __stdcall glValidateProgram(GLuint program)
7590{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007591 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007592
7593 try
7594 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007595 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007596
7597 if (context)
7598 {
7599 gl::Program *programObject = context->getProgram(program);
7600
7601 if (!programObject)
7602 {
7603 if (context->getShader(program))
7604 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007605 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007606 }
7607 else
7608 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007609 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007610 }
7611 }
7612
apatrick@chromium.org253b8d22012-06-22 19:27:21 +00007613 programObject->validate();
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00007614 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007615 }
7616 catch(std::bad_alloc&)
7617 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007618 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007619 }
7620}
7621
7622void __stdcall glVertexAttrib1f(GLuint index, GLfloat x)
7623{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007624 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007625
7626 try
7627 {
7628 if (index >= gl::MAX_VERTEX_ATTRIBS)
7629 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007630 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007631 }
7632
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007633 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007634
7635 if (context)
7636 {
7637 GLfloat vals[4] = { x, 0, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007638 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007639 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007640 }
7641 catch(std::bad_alloc&)
7642 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007643 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007644 }
7645}
7646
7647void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values)
7648{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007649 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007650
7651 try
7652 {
7653 if (index >= gl::MAX_VERTEX_ATTRIBS)
7654 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007655 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007656 }
7657
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007658 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007659
7660 if (context)
7661 {
7662 GLfloat vals[4] = { values[0], 0, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007663 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007664 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007665 }
7666 catch(std::bad_alloc&)
7667 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007668 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007669 }
7670}
7671
7672void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
7673{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007674 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007675
7676 try
7677 {
7678 if (index >= gl::MAX_VERTEX_ATTRIBS)
7679 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007680 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007681 }
7682
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007683 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007684
7685 if (context)
7686 {
7687 GLfloat vals[4] = { x, y, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007688 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007689 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007690 }
7691 catch(std::bad_alloc&)
7692 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007693 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007694 }
7695}
7696
7697void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values)
7698{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007699 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007700
7701 try
7702 {
7703 if (index >= gl::MAX_VERTEX_ATTRIBS)
7704 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007705 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007706 }
7707
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007708 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007709
7710 if (context)
7711 {
7712 GLfloat vals[4] = { values[0], values[1], 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007713 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007714 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007715 }
7716 catch(std::bad_alloc&)
7717 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007718 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007719 }
7720}
7721
7722void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
7723{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007724 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 +00007725
7726 try
7727 {
7728 if (index >= gl::MAX_VERTEX_ATTRIBS)
7729 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007730 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007731 }
7732
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007733 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007734
7735 if (context)
7736 {
7737 GLfloat vals[4] = { x, y, z, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007738 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007739 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007740 }
7741 catch(std::bad_alloc&)
7742 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007743 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007744 }
7745}
7746
7747void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values)
7748{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007749 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007750
7751 try
7752 {
7753 if (index >= gl::MAX_VERTEX_ATTRIBS)
7754 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007755 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007756 }
7757
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007758 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007759
7760 if (context)
7761 {
7762 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007763 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007764 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007765 }
7766 catch(std::bad_alloc&)
7767 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007768 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007769 }
7770}
7771
7772void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
7773{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007774 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 +00007775
7776 try
7777 {
7778 if (index >= gl::MAX_VERTEX_ATTRIBS)
7779 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007780 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007781 }
7782
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007783 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007784
7785 if (context)
7786 {
7787 GLfloat vals[4] = { x, y, z, w };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007788 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007789 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007790 }
7791 catch(std::bad_alloc&)
7792 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007793 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007794 }
7795}
7796
7797void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values)
7798{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007799 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007800
7801 try
7802 {
7803 if (index >= gl::MAX_VERTEX_ATTRIBS)
7804 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007805 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007806 }
7807
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007808 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007809
7810 if (context)
7811 {
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007812 context->setVertexAttribf(index, values);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00007813 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007814 }
7815 catch(std::bad_alloc&)
7816 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007817 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007818 }
7819}
7820
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00007821void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
7822{
7823 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
7824
7825 try
7826 {
7827 if (index >= gl::MAX_VERTEX_ATTRIBS)
7828 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007829 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00007830 }
7831
7832 gl::Context *context = gl::getNonLostContext();
7833
7834 if (context)
7835 {
7836 context->setVertexAttribDivisor(index, divisor);
7837 }
7838 }
7839 catch(std::bad_alloc&)
7840 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007841 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00007842 }
7843}
7844
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00007845void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007846{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007847 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007848 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00007849 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007850
7851 try
7852 {
7853 if (index >= gl::MAX_VERTEX_ATTRIBS)
7854 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007855 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007856 }
7857
7858 if (size < 1 || size > 4)
7859 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007860 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007861 }
7862
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00007863 gl::Context *context = gl::getNonLostContext();
7864
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007865 switch (type)
7866 {
7867 case GL_BYTE:
7868 case GL_UNSIGNED_BYTE:
7869 case GL_SHORT:
7870 case GL_UNSIGNED_SHORT:
7871 case GL_FIXED:
7872 case GL_FLOAT:
7873 break;
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00007874 case GL_HALF_FLOAT:
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007875 case GL_INT:
7876 case GL_UNSIGNED_INT:
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00007877 case GL_INT_2_10_10_10_REV:
7878 case GL_UNSIGNED_INT_2_10_10_10_REV:
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00007879 if (context && context->getClientVersion() < 3)
7880 {
7881 return gl::error(GL_INVALID_ENUM);
7882 }
7883 else
7884 {
7885 break;
7886 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007887 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007888 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007889 }
7890
7891 if (stride < 0)
7892 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007893 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007894 }
7895
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00007896 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
7897 {
7898 return gl::error(GL_INVALID_OPERATION);
7899 }
7900
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007901 if (context)
7902 {
shannon.woods%transgaming.com@gtempaccount.com8de4e6a2013-04-13 03:37:44 +00007903 context->setVertexAttribState(index, context->getArrayBuffer(), size, type,
7904 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007905 }
7906 }
7907 catch(std::bad_alloc&)
7908 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007909 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007910 }
7911}
7912
7913void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
7914{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00007915 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 +00007916
7917 try
7918 {
7919 if (width < 0 || height < 0)
7920 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007921 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007922 }
7923
daniel@transgaming.com9d788502011-11-09 17:46:55 +00007924 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007925
7926 if (context)
7927 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00007928 context->setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007929 }
7930 }
7931 catch(std::bad_alloc&)
7932 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00007933 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00007934 }
7935}
7936
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007937// OpenGL ES 3.0 functions
7938
7939void __stdcall glReadBuffer(GLenum mode)
7940{
7941 EVENT("(GLenum mode = 0x%X)", mode);
7942
7943 try
7944 {
7945 gl::Context *context = gl::getNonLostContext();
7946
7947 if (context)
7948 {
7949 if (context->getClientVersion() < 3)
7950 {
7951 return gl::error(GL_INVALID_OPERATION);
7952 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007953
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007954 UNIMPLEMENTED();
7955 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007956 }
7957 catch(std::bad_alloc&)
7958 {
7959 return gl::error(GL_OUT_OF_MEMORY);
7960 }
7961}
7962
7963void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
7964{
7965 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
7966 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
7967
7968 try
7969 {
7970 gl::Context *context = gl::getNonLostContext();
7971
7972 if (context)
7973 {
7974 if (context->getClientVersion() < 3)
7975 {
7976 return gl::error(GL_INVALID_OPERATION);
7977 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007978
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007979 UNIMPLEMENTED();
7980 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007981 }
7982 catch(std::bad_alloc&)
7983 {
7984 return gl::error(GL_OUT_OF_MEMORY);
7985 }
7986}
7987
7988void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
7989{
7990 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
7991 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
7992 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
7993 target, level, internalformat, width, height, depth, border, format, type, pixels);
7994
7995 try
7996 {
7997 gl::Context *context = gl::getNonLostContext();
7998
7999 if (context)
8000 {
8001 if (context->getClientVersion() < 3)
8002 {
8003 return gl::error(GL_INVALID_OPERATION);
8004 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008005
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008006 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008007 if (!validateES3TexImageParameters(context, target, level, internalformat, false, false,
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008008 0, 0, 0, width, height, depth, border, format, type))
8009 {
8010 return;
8011 }
8012
8013 switch(target)
8014 {
8015 case GL_TEXTURE_3D:
8016 {
8017 gl::Texture3D *texture = context->getTexture3D();
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +00008018 texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackAlignment(), pixels);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008019 }
8020 break;
8021
8022 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008023 {
8024 gl::Texture2DArray *texture = context->getTexture2DArray();
shannonwoods@chromium.org4ad58e02013-05-30 00:08:11 +00008025 texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackAlignment(), pixels);
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008026 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008027 break;
8028
8029 default:
8030 return gl::error(GL_INVALID_ENUM);
8031 }
8032 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008033 }
8034 catch(std::bad_alloc&)
8035 {
8036 return gl::error(GL_OUT_OF_MEMORY);
8037 }
8038}
8039
8040void __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)
8041{
8042 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
8043 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
8044 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
8045 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
8046
8047 try
8048 {
8049 gl::Context *context = gl::getNonLostContext();
8050
8051 if (context)
8052 {
8053 if (context->getClientVersion() < 3)
8054 {
8055 return gl::error(GL_INVALID_OPERATION);
8056 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008057
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008058 if (!pixels)
8059 {
8060 return gl::error(GL_INVALID_VALUE);
8061 }
8062
8063 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008064 if (!validateES3TexImageParameters(context, target, level, GL_NONE, false, true,
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008065 xoffset, yoffset, zoffset, width, height, depth, 0,
8066 format, type))
8067 {
8068 return;
8069 }
8070
8071 switch(target)
8072 {
8073 case GL_TEXTURE_3D:
8074 {
8075 gl::Texture3D *texture = context->getTexture3D();
8076 texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels);
8077 }
8078 break;
8079
8080 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008081 {
8082 gl::Texture2DArray *texture = context->getTexture2DArray();
8083 texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels);
8084 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008085 break;
8086
8087 default:
8088 return gl::error(GL_INVALID_ENUM);
8089 }
8090 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008091 }
8092 catch(std::bad_alloc&)
8093 {
8094 return gl::error(GL_OUT_OF_MEMORY);
8095 }
8096}
8097
8098void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
8099{
8100 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
8101 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
8102 target, level, xoffset, yoffset, zoffset, x, y, width, height);
8103
8104 try
8105 {
8106 gl::Context *context = gl::getNonLostContext();
8107
8108 if (context)
8109 {
8110 if (context->getClientVersion() < 3)
8111 {
8112 return gl::error(GL_INVALID_OPERATION);
8113 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008114
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008115 if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset,
8116 x, y, width, height, 0))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008117 {
8118 return;
8119 }
8120
8121 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
8122 gl::Texture *texture = NULL;
8123 switch (target)
8124 {
8125 case GL_TEXTURE_3D:
8126 texture = context->getTexture3D();
8127 break;
8128
8129 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008130 texture = context->getTexture2DArray();
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008131 break;
8132
8133 default:
8134 return gl::error(GL_INVALID_ENUM);
8135 }
8136
8137 texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
8138 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008139 }
8140 catch(std::bad_alloc&)
8141 {
8142 return gl::error(GL_OUT_OF_MEMORY);
8143 }
8144}
8145
8146void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
8147{
8148 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
8149 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
8150 "const GLvoid* data = 0x%0.8p)",
8151 target, level, internalformat, width, height, depth, border, imageSize, data);
8152
8153 try
8154 {
8155 gl::Context *context = gl::getNonLostContext();
8156
8157 if (context)
8158 {
8159 if (context->getClientVersion() < 3)
8160 {
8161 return gl::error(GL_INVALID_OPERATION);
8162 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008163
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00008164 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 +00008165 {
8166 return gl::error(GL_INVALID_VALUE);
8167 }
8168
8169 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008170 if (!validateES3TexImageParameters(context, target, level, internalformat, true, false,
8171 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008172 {
8173 return;
8174 }
8175
8176 switch(target)
8177 {
8178 case GL_TEXTURE_3D:
8179 {
8180 gl::Texture3D *texture = context->getTexture3D();
8181 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
8182 }
8183 break;
8184
8185 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008186 {
8187 gl::Texture2DArray *texture = context->getTexture2DArray();
8188 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
8189 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008190 break;
8191
8192 default:
8193 return gl::error(GL_INVALID_ENUM);
8194 }
8195 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008196 }
8197 catch(std::bad_alloc&)
8198 {
8199 return gl::error(GL_OUT_OF_MEMORY);
8200 }
8201}
8202
8203void __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)
8204{
8205 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
8206 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
8207 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
8208 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
8209
8210 try
8211 {
8212 gl::Context *context = gl::getNonLostContext();
8213
8214 if (context)
8215 {
8216 if (context->getClientVersion() < 3)
8217 {
8218 return gl::error(GL_INVALID_OPERATION);
8219 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008220
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00008221 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 +00008222 {
8223 return gl::error(GL_INVALID_VALUE);
8224 }
8225
8226 if (!data)
8227 {
8228 return gl::error(GL_INVALID_VALUE);
8229 }
8230
8231 // validateES3TexImageFormat sets the error code if there is an error
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00008232 if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true,
8233 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008234 {
8235 return;
8236 }
8237
8238 switch(target)
8239 {
8240 case GL_TEXTURE_3D:
8241 {
8242 gl::Texture3D *texture = context->getTexture3D();
8243 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
8244 format, imageSize, data);
8245 }
8246 break;
8247
8248 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00008249 {
8250 gl::Texture2DArray *texture = context->getTexture2DArray();
8251 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
8252 format, imageSize, data);
8253 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00008254 break;
8255
8256 default:
8257 return gl::error(GL_INVALID_ENUM);
8258 }
8259 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008260 }
8261 catch(std::bad_alloc&)
8262 {
8263 return gl::error(GL_OUT_OF_MEMORY);
8264 }
8265}
8266
8267void __stdcall glGenQueries(GLsizei n, GLuint* ids)
8268{
8269 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8270
8271 try
8272 {
8273 gl::Context *context = gl::getNonLostContext();
8274
8275 if (context)
8276 {
8277 if (context->getClientVersion() < 3)
8278 {
8279 return gl::error(GL_INVALID_OPERATION);
8280 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008281
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008282 UNIMPLEMENTED();
8283 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008284 }
8285 catch(std::bad_alloc&)
8286 {
8287 return gl::error(GL_OUT_OF_MEMORY);
8288 }
8289}
8290
8291void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids)
8292{
8293 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8294
8295 try
8296 {
8297 gl::Context *context = gl::getNonLostContext();
8298
8299 if (context)
8300 {
8301 if (context->getClientVersion() < 3)
8302 {
8303 return gl::error(GL_INVALID_OPERATION);
8304 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008305
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008306 UNIMPLEMENTED();
8307 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008308 }
8309 catch(std::bad_alloc&)
8310 {
8311 return gl::error(GL_OUT_OF_MEMORY);
8312 }
8313}
8314
8315GLboolean __stdcall glIsQuery(GLuint id)
8316{
8317 EVENT("(GLuint id = %u)", id);
8318
8319 try
8320 {
8321 gl::Context *context = gl::getNonLostContext();
8322
8323 if (context)
8324 {
8325 if (context->getClientVersion() < 3)
8326 {
8327 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8328 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008329
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008330 UNIMPLEMENTED();
8331 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008332 }
8333 catch(std::bad_alloc&)
8334 {
8335 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8336 }
8337
8338 return GL_FALSE;
8339}
8340
8341void __stdcall glBeginQuery(GLenum target, GLuint id)
8342{
8343 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
8344
8345 try
8346 {
8347 gl::Context *context = gl::getNonLostContext();
8348
8349 if (context)
8350 {
8351 if (context->getClientVersion() < 3)
8352 {
8353 return gl::error(GL_INVALID_OPERATION);
8354 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008355
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008356 UNIMPLEMENTED();
8357 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008358 }
8359 catch(std::bad_alloc&)
8360 {
8361 return gl::error(GL_OUT_OF_MEMORY);
8362 }
8363}
8364
8365void __stdcall glEndQuery(GLenum target)
8366{
8367 EVENT("(GLenum target = 0x%X)", target);
8368
8369 try
8370 {
8371 gl::Context *context = gl::getNonLostContext();
8372
8373 if (context)
8374 {
8375 if (context->getClientVersion() < 3)
8376 {
8377 return gl::error(GL_INVALID_OPERATION);
8378 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008379
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008380 UNIMPLEMENTED();
8381 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008382 }
8383 catch(std::bad_alloc&)
8384 {
8385 return gl::error(GL_OUT_OF_MEMORY);
8386 }
8387}
8388
8389void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params)
8390{
8391 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
8392
8393 try
8394 {
8395 gl::Context *context = gl::getNonLostContext();
8396
8397 if (context)
8398 {
8399 if (context->getClientVersion() < 3)
8400 {
8401 return gl::error(GL_INVALID_OPERATION);
8402 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008403
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008404 UNIMPLEMENTED();
8405 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008406 }
8407 catch(std::bad_alloc&)
8408 {
8409 return gl::error(GL_OUT_OF_MEMORY);
8410 }
8411}
8412
8413void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
8414{
8415 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
8416
8417 try
8418 {
8419 gl::Context *context = gl::getNonLostContext();
8420
8421 if (context)
8422 {
8423 if (context->getClientVersion() < 3)
8424 {
8425 return gl::error(GL_INVALID_OPERATION);
8426 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008427
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008428 UNIMPLEMENTED();
8429 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008430 }
8431 catch(std::bad_alloc&)
8432 {
8433 return gl::error(GL_OUT_OF_MEMORY);
8434 }
8435}
8436
8437GLboolean __stdcall glUnmapBuffer(GLenum target)
8438{
8439 EVENT("(GLenum target = 0x%X)", target);
8440
8441 try
8442 {
8443 gl::Context *context = gl::getNonLostContext();
8444
8445 if (context)
8446 {
8447 if (context->getClientVersion() < 3)
8448 {
8449 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8450 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008451
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008452 UNIMPLEMENTED();
8453 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008454 }
8455 catch(std::bad_alloc&)
8456 {
8457 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8458 }
8459
8460 return GL_FALSE;
8461}
8462
8463void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
8464{
8465 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
8466
8467 try
8468 {
8469 gl::Context *context = gl::getNonLostContext();
8470
8471 if (context)
8472 {
8473 if (context->getClientVersion() < 3)
8474 {
8475 return gl::error(GL_INVALID_OPERATION);
8476 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008477
shannonwoods@chromium.org2d2190a2013-05-30 00:17:35 +00008478 UNIMPLEMENTED();
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008479 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008480 }
8481 catch(std::bad_alloc&)
8482 {
8483 return gl::error(GL_OUT_OF_MEMORY);
8484 }
8485}
8486
8487void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs)
8488{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008489 try
8490 {
8491 gl::Context *context = gl::getNonLostContext();
8492
8493 if (context)
8494 {
8495 if (context->getClientVersion() < 3)
8496 {
8497 return gl::error(GL_INVALID_OPERATION);
8498 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008499
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00008500 glDrawBuffersEXT(n, bufs);
8501 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008502 }
8503 catch(std::bad_alloc&)
8504 {
8505 return gl::error(GL_OUT_OF_MEMORY);
8506 }
8507}
8508
8509void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8510{
8511 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8512 location, count, transpose, value);
8513
8514 try
8515 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008516 if (count < 0)
8517 {
8518 return gl::error(GL_INVALID_VALUE);
8519 }
8520
8521 if (location == -1)
8522 {
8523 return;
8524 }
8525
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008526 gl::Context *context = gl::getNonLostContext();
8527
8528 if (context)
8529 {
8530 if (context->getClientVersion() < 3)
8531 {
8532 return gl::error(GL_INVALID_OPERATION);
8533 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008534
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008535 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8536 if (!programBinary)
8537 {
8538 return gl::error(GL_INVALID_OPERATION);
8539 }
8540
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008541 if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008542 {
8543 return gl::error(GL_INVALID_OPERATION);
8544 }
8545 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008546 }
8547 catch(std::bad_alloc&)
8548 {
8549 return gl::error(GL_OUT_OF_MEMORY);
8550 }
8551}
8552
8553void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8554{
8555 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8556 location, count, transpose, value);
8557
8558 try
8559 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008560 if (count < 0)
8561 {
8562 return gl::error(GL_INVALID_VALUE);
8563 }
8564
8565 if (location == -1)
8566 {
8567 return;
8568 }
8569
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008570 gl::Context *context = gl::getNonLostContext();
8571
8572 if (context)
8573 {
8574 if (context->getClientVersion() < 3)
8575 {
8576 return gl::error(GL_INVALID_OPERATION);
8577 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008578
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008579 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8580 if (!programBinary)
8581 {
8582 return gl::error(GL_INVALID_OPERATION);
8583 }
8584
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008585 if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008586 {
8587 return gl::error(GL_INVALID_OPERATION);
8588 }
8589 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008590 }
8591 catch(std::bad_alloc&)
8592 {
8593 return gl::error(GL_OUT_OF_MEMORY);
8594 }
8595}
8596
8597void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8598{
8599 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8600 location, count, transpose, value);
8601
8602 try
8603 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008604 if (count < 0)
8605 {
8606 return gl::error(GL_INVALID_VALUE);
8607 }
8608
8609 if (location == -1)
8610 {
8611 return;
8612 }
8613
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008614 gl::Context *context = gl::getNonLostContext();
8615
8616 if (context)
8617 {
8618 if (context->getClientVersion() < 3)
8619 {
8620 return gl::error(GL_INVALID_OPERATION);
8621 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008622
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008623 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8624 if (!programBinary)
8625 {
8626 return gl::error(GL_INVALID_OPERATION);
8627 }
8628
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008629 if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008630 {
8631 return gl::error(GL_INVALID_OPERATION);
8632 }
8633 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008634 }
8635 catch(std::bad_alloc&)
8636 {
8637 return gl::error(GL_OUT_OF_MEMORY);
8638 }
8639}
8640
8641void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8642{
8643 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8644 location, count, transpose, value);
8645
8646 try
8647 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008648 if (count < 0)
8649 {
8650 return gl::error(GL_INVALID_VALUE);
8651 }
8652
8653 if (location == -1)
8654 {
8655 return;
8656 }
8657
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008658 gl::Context *context = gl::getNonLostContext();
8659
8660 if (context)
8661 {
8662 if (context->getClientVersion() < 3)
8663 {
8664 return gl::error(GL_INVALID_OPERATION);
8665 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008666
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008667 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8668 if (!programBinary)
8669 {
8670 return gl::error(GL_INVALID_OPERATION);
8671 }
8672
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008673 if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008674 {
8675 return gl::error(GL_INVALID_OPERATION);
8676 }
8677 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008678 }
8679 catch(std::bad_alloc&)
8680 {
8681 return gl::error(GL_OUT_OF_MEMORY);
8682 }
8683}
8684
8685void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8686{
8687 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8688 location, count, transpose, value);
8689
8690 try
8691 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008692 if (count < 0)
8693 {
8694 return gl::error(GL_INVALID_VALUE);
8695 }
8696
8697 if (location == -1)
8698 {
8699 return;
8700 }
8701
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008702 gl::Context *context = gl::getNonLostContext();
8703
8704 if (context)
8705 {
8706 if (context->getClientVersion() < 3)
8707 {
8708 return gl::error(GL_INVALID_OPERATION);
8709 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008710
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008711 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8712 if (!programBinary)
8713 {
8714 return gl::error(GL_INVALID_OPERATION);
8715 }
8716
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008717 if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008718 {
8719 return gl::error(GL_INVALID_OPERATION);
8720 }
8721 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008722 }
8723 catch(std::bad_alloc&)
8724 {
8725 return gl::error(GL_OUT_OF_MEMORY);
8726 }
8727}
8728
8729void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
8730{
8731 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
8732 location, count, transpose, value);
8733
8734 try
8735 {
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008736 if (count < 0)
8737 {
8738 return gl::error(GL_INVALID_VALUE);
8739 }
8740
8741 if (location == -1)
8742 {
8743 return;
8744 }
8745
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008746 gl::Context *context = gl::getNonLostContext();
8747
8748 if (context)
8749 {
8750 if (context->getClientVersion() < 3)
8751 {
8752 return gl::error(GL_INVALID_OPERATION);
8753 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008754
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008755 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
8756 if (!programBinary)
8757 {
8758 return gl::error(GL_INVALID_OPERATION);
8759 }
8760
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00008761 if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value))
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00008762 {
8763 return gl::error(GL_INVALID_OPERATION);
8764 }
8765 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008766 }
8767 catch(std::bad_alloc&)
8768 {
8769 return gl::error(GL_OUT_OF_MEMORY);
8770 }
8771}
8772
8773void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
8774{
8775 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
8776 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
8777 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
8778
8779 try
8780 {
8781 gl::Context *context = gl::getNonLostContext();
8782
8783 if (context)
8784 {
8785 if (context->getClientVersion() < 3)
8786 {
8787 return gl::error(GL_INVALID_OPERATION);
8788 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008789
shannonwoods@chromium.orgee148562013-05-30 00:17:21 +00008790 glBlitFramebufferANGLE(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008791 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008792 }
8793 catch(std::bad_alloc&)
8794 {
8795 return gl::error(GL_OUT_OF_MEMORY);
8796 }
8797}
8798
8799void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
8800{
8801 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
8802 target, samples, internalformat, width, height);
8803
8804 try
8805 {
8806 gl::Context *context = gl::getNonLostContext();
8807
8808 if (context)
8809 {
8810 if (context->getClientVersion() < 3)
8811 {
8812 return gl::error(GL_INVALID_OPERATION);
8813 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008814
Geoff Lang2e1dcd52013-05-29 10:34:08 -04008815 if (!validateRenderbufferStorageParameters(context, target, samples, internalformat,
8816 width, height, false))
8817 {
8818 return;
8819 }
8820
8821 context->setRenderbufferStorage(width, height, internalformat, samples);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008822 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008823 }
8824 catch(std::bad_alloc&)
8825 {
8826 return gl::error(GL_OUT_OF_MEMORY);
8827 }
8828}
8829
8830void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
8831{
8832 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
8833 target, attachment, texture, level, layer);
8834
8835 try
8836 {
8837 gl::Context *context = gl::getNonLostContext();
8838
8839 if (context)
8840 {
8841 if (context->getClientVersion() < 3)
8842 {
8843 return gl::error(GL_INVALID_OPERATION);
8844 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008845
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008846 UNIMPLEMENTED();
8847 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008848 }
8849 catch(std::bad_alloc&)
8850 {
8851 return gl::error(GL_OUT_OF_MEMORY);
8852 }
8853}
8854
8855GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
8856{
8857 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
8858 target, offset, length, access);
8859
8860 try
8861 {
8862 gl::Context *context = gl::getNonLostContext();
8863
8864 if (context)
8865 {
8866 if (context->getClientVersion() < 3)
8867 {
8868 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
8869 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008870
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008871 UNIMPLEMENTED();
8872 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008873 }
8874 catch(std::bad_alloc&)
8875 {
8876 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL));
8877 }
8878
8879 return NULL;
8880}
8881
8882void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
8883{
8884 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
8885
8886 try
8887 {
8888 gl::Context *context = gl::getNonLostContext();
8889
8890 if (context)
8891 {
8892 if (context->getClientVersion() < 3)
8893 {
8894 return gl::error(GL_INVALID_OPERATION);
8895 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008896
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008897 UNIMPLEMENTED();
8898 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008899 }
8900 catch(std::bad_alloc&)
8901 {
8902 return gl::error(GL_OUT_OF_MEMORY);
8903 }
8904}
8905
8906void __stdcall glBindVertexArray(GLuint array)
8907{
8908 EVENT("(GLuint array = %u)", array);
8909
8910 try
8911 {
8912 gl::Context *context = gl::getNonLostContext();
8913
8914 if (context)
8915 {
8916 if (context->getClientVersion() < 3)
8917 {
8918 return gl::error(GL_INVALID_OPERATION);
8919 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008920
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008921 UNIMPLEMENTED();
8922 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008923 }
8924 catch(std::bad_alloc&)
8925 {
8926 return gl::error(GL_OUT_OF_MEMORY);
8927 }
8928}
8929
8930void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
8931{
8932 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
8933
8934 try
8935 {
8936 gl::Context *context = gl::getNonLostContext();
8937
8938 if (context)
8939 {
8940 if (context->getClientVersion() < 3)
8941 {
8942 return gl::error(GL_INVALID_OPERATION);
8943 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008944
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008945 UNIMPLEMENTED();
8946 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008947 }
8948 catch(std::bad_alloc&)
8949 {
8950 return gl::error(GL_OUT_OF_MEMORY);
8951 }
8952}
8953
8954void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays)
8955{
8956 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
8957
8958 try
8959 {
8960 gl::Context *context = gl::getNonLostContext();
8961
8962 if (context)
8963 {
8964 if (context->getClientVersion() < 3)
8965 {
8966 return gl::error(GL_INVALID_OPERATION);
8967 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008968
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008969 UNIMPLEMENTED();
8970 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008971 }
8972 catch(std::bad_alloc&)
8973 {
8974 return gl::error(GL_OUT_OF_MEMORY);
8975 }
8976}
8977
8978GLboolean __stdcall glIsVertexArray(GLuint array)
8979{
8980 EVENT("(GLuint array = %u)", array);
8981
8982 try
8983 {
8984 gl::Context *context = gl::getNonLostContext();
8985
8986 if (context)
8987 {
8988 if (context->getClientVersion() < 3)
8989 {
8990 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8991 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008992
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008993 UNIMPLEMENTED();
8994 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008995 }
8996 catch(std::bad_alloc&)
8997 {
8998 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8999 }
9000
9001 return GL_FALSE;
9002}
9003
9004void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
9005{
9006 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
9007 target, index, data);
9008
9009 try
9010 {
9011 gl::Context *context = gl::getNonLostContext();
9012
9013 if (context)
9014 {
9015 if (context->getClientVersion() < 3)
9016 {
9017 return gl::error(GL_INVALID_OPERATION);
9018 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009019
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009020 UNIMPLEMENTED();
9021 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009022 }
9023 catch(std::bad_alloc&)
9024 {
9025 return gl::error(GL_OUT_OF_MEMORY);
9026 }
9027}
9028
9029void __stdcall glBeginTransformFeedback(GLenum primitiveMode)
9030{
9031 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
9032
9033 try
9034 {
9035 gl::Context *context = gl::getNonLostContext();
9036
9037 if (context)
9038 {
9039 if (context->getClientVersion() < 3)
9040 {
9041 return gl::error(GL_INVALID_OPERATION);
9042 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009043
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009044 UNIMPLEMENTED();
9045 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009046 }
9047 catch(std::bad_alloc&)
9048 {
9049 return gl::error(GL_OUT_OF_MEMORY);
9050 }
9051}
9052
9053void __stdcall glEndTransformFeedback(void)
9054{
9055 EVENT("(void)");
9056
9057 try
9058 {
9059 gl::Context *context = gl::getNonLostContext();
9060
9061 if (context)
9062 {
9063 if (context->getClientVersion() < 3)
9064 {
9065 return gl::error(GL_INVALID_OPERATION);
9066 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009067
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009068 UNIMPLEMENTED();
9069 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009070 }
9071 catch(std::bad_alloc&)
9072 {
9073 return gl::error(GL_OUT_OF_MEMORY);
9074 }
9075}
9076
9077void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
9078{
9079 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
9080 target, index, buffer, offset, size);
9081
9082 try
9083 {
9084 gl::Context *context = gl::getNonLostContext();
9085
9086 if (context)
9087 {
9088 if (context->getClientVersion() < 3)
9089 {
9090 return gl::error(GL_INVALID_OPERATION);
9091 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009092
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009093 switch (target)
9094 {
9095 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00009096 if (index >= context->getMaxTransformFeedbackBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009097 {
9098 return gl::error(GL_INVALID_VALUE);
9099 }
9100 break;
9101
9102 case GL_UNIFORM_BUFFER:
9103 if (index >= context->getMaximumCombinedUniformBufferBindings())
9104 {
9105 return gl::error(GL_INVALID_VALUE);
9106 }
9107 break;
9108
9109 default:
9110 return gl::error(GL_INVALID_ENUM);
9111 }
9112
shannonwoods@chromium.orge6e00792013-05-30 00:06:07 +00009113 if (buffer != 0 && size <= 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009114 {
9115 return gl::error(GL_INVALID_VALUE);
9116 }
9117
9118 switch (target)
9119 {
9120 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orga26aeaf2013-05-30 00:06:13 +00009121
9122 // size and offset must be a multiple of 4
9123 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
9124 {
9125 return gl::error(GL_INVALID_VALUE);
9126 }
9127
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009128 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
9129 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009130 break;
9131
9132 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.org97c3d502013-05-30 00:04:34 +00009133
9134 // it is an error to bind an offset not a multiple of the alignment
9135 if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0)
9136 {
9137 return gl::error(GL_INVALID_VALUE);
9138 }
9139
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009140 context->bindIndexedUniformBuffer(buffer, index, offset, size);
9141 context->bindGenericUniformBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009142 break;
9143
9144 default:
9145 UNREACHABLE();
9146 }
9147 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009148 }
9149 catch(std::bad_alloc&)
9150 {
9151 return gl::error(GL_OUT_OF_MEMORY);
9152 }
9153}
9154
9155void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
9156{
9157 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
9158 target, index, buffer);
9159
9160 try
9161 {
9162 gl::Context *context = gl::getNonLostContext();
9163
9164 if (context)
9165 {
9166 if (context->getClientVersion() < 3)
9167 {
9168 return gl::error(GL_INVALID_OPERATION);
9169 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009170
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009171 switch (target)
9172 {
9173 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00009174 if (index >= context->getMaxTransformFeedbackBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009175 {
9176 return gl::error(GL_INVALID_VALUE);
9177 }
9178 break;
9179
9180 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00009181 if (index >= context->getMaximumCombinedUniformBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009182 {
9183 return gl::error(GL_INVALID_VALUE);
9184 }
9185 break;
9186
9187 default:
9188 return gl::error(GL_INVALID_ENUM);
9189 }
9190
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009191 switch (target)
9192 {
9193 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.org3eeca1e2013-05-30 00:04:28 +00009194 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009195 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009196 break;
9197
9198 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.org3eeca1e2013-05-30 00:04:28 +00009199 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00009200 context->bindGenericUniformBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00009201 break;
9202
9203 default:
9204 UNREACHABLE();
9205 }
9206 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009207 }
9208 catch(std::bad_alloc&)
9209 {
9210 return gl::error(GL_OUT_OF_MEMORY);
9211 }
9212}
9213
9214void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
9215{
9216 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
9217 program, count, varyings, bufferMode);
9218
9219 try
9220 {
9221 gl::Context *context = gl::getNonLostContext();
9222
9223 if (context)
9224 {
9225 if (context->getClientVersion() < 3)
9226 {
9227 return gl::error(GL_INVALID_OPERATION);
9228 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009229
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009230 UNIMPLEMENTED();
9231 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009232 }
9233 catch(std::bad_alloc&)
9234 {
9235 return gl::error(GL_OUT_OF_MEMORY);
9236 }
9237}
9238
9239void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
9240{
9241 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
9242 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
9243 program, index, bufSize, length, size, type, name);
9244
9245 try
9246 {
9247 gl::Context *context = gl::getNonLostContext();
9248
9249 if (context)
9250 {
9251 if (context->getClientVersion() < 3)
9252 {
9253 return gl::error(GL_INVALID_OPERATION);
9254 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009255
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009256 UNIMPLEMENTED();
9257 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009258 }
9259 catch(std::bad_alloc&)
9260 {
9261 return gl::error(GL_OUT_OF_MEMORY);
9262 }
9263}
9264
9265void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
9266{
9267 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
9268 index, size, type, stride, pointer);
9269
9270 try
9271 {
9272 gl::Context *context = gl::getNonLostContext();
9273
9274 if (context)
9275 {
9276 if (context->getClientVersion() < 3)
9277 {
9278 return gl::error(GL_INVALID_OPERATION);
9279 }
9280 }
9281
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009282 if (index >= gl::MAX_VERTEX_ATTRIBS)
9283 {
9284 return gl::error(GL_INVALID_VALUE);
9285 }
9286
9287 if (size < 1 || size > 4)
9288 {
9289 return gl::error(GL_INVALID_VALUE);
9290 }
9291
9292 switch (type)
9293 {
9294 case GL_BYTE:
9295 case GL_UNSIGNED_BYTE:
9296 case GL_SHORT:
9297 case GL_UNSIGNED_SHORT:
9298 case GL_INT:
9299 case GL_UNSIGNED_INT:
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00009300 case GL_INT_2_10_10_10_REV:
9301 case GL_UNSIGNED_INT_2_10_10_10_REV:
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009302 break;
9303 default:
9304 return gl::error(GL_INVALID_ENUM);
9305 }
9306
9307 if (stride < 0)
9308 {
9309 return gl::error(GL_INVALID_VALUE);
9310 }
9311
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00009312 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
9313 {
9314 return gl::error(GL_INVALID_OPERATION);
9315 }
9316
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009317 if (context)
9318 {
9319 context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true,
9320 stride, pointer);
9321 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009322 }
9323 catch(std::bad_alloc&)
9324 {
9325 return gl::error(GL_OUT_OF_MEMORY);
9326 }
9327}
9328
9329void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
9330{
9331 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
9332 index, pname, params);
9333
9334 try
9335 {
9336 gl::Context *context = gl::getNonLostContext();
9337
9338 if (context)
9339 {
9340 if (context->getClientVersion() < 3)
9341 {
9342 return gl::error(GL_INVALID_OPERATION);
9343 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009344
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009345 UNIMPLEMENTED();
9346 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009347 }
9348 catch(std::bad_alloc&)
9349 {
9350 return gl::error(GL_OUT_OF_MEMORY);
9351 }
9352}
9353
9354void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
9355{
9356 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
9357 index, pname, params);
9358
9359 try
9360 {
9361 gl::Context *context = gl::getNonLostContext();
9362
9363 if (context)
9364 {
9365 if (context->getClientVersion() < 3)
9366 {
9367 return gl::error(GL_INVALID_OPERATION);
9368 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009369
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009370 UNIMPLEMENTED();
9371 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009372 }
9373 catch(std::bad_alloc&)
9374 {
9375 return gl::error(GL_OUT_OF_MEMORY);
9376 }
9377}
9378
9379void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
9380{
9381 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
9382 index, x, y, z, w);
9383
9384 try
9385 {
9386 gl::Context *context = gl::getNonLostContext();
9387
9388 if (context)
9389 {
9390 if (context->getClientVersion() < 3)
9391 {
9392 return gl::error(GL_INVALID_OPERATION);
9393 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009394
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009395 if (index >= gl::MAX_VERTEX_ATTRIBS)
9396 {
9397 return gl::error(GL_INVALID_VALUE);
9398 }
9399
9400 GLint vals[4] = { x, y, z, w };
9401 context->setVertexAttribi(index, vals);
9402 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009403 }
9404 catch(std::bad_alloc&)
9405 {
9406 return gl::error(GL_OUT_OF_MEMORY);
9407 }
9408}
9409
9410void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
9411{
9412 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
9413 index, x, y, z, w);
9414
9415 try
9416 {
9417 gl::Context *context = gl::getNonLostContext();
9418
9419 if (context)
9420 {
9421 if (context->getClientVersion() < 3)
9422 {
9423 return gl::error(GL_INVALID_OPERATION);
9424 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009425
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009426 if (index >= gl::MAX_VERTEX_ATTRIBS)
9427 {
9428 return gl::error(GL_INVALID_VALUE);
9429 }
9430
9431 GLuint vals[4] = { x, y, z, w };
9432 context->setVertexAttribu(index, vals);
9433 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009434 }
9435 catch(std::bad_alloc&)
9436 {
9437 return gl::error(GL_OUT_OF_MEMORY);
9438 }
9439}
9440
9441void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v)
9442{
9443 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
9444
9445 try
9446 {
9447 gl::Context *context = gl::getNonLostContext();
9448
9449 if (context)
9450 {
9451 if (context->getClientVersion() < 3)
9452 {
9453 return gl::error(GL_INVALID_OPERATION);
9454 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009455
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009456 if (index >= gl::MAX_VERTEX_ATTRIBS)
9457 {
9458 return gl::error(GL_INVALID_VALUE);
9459 }
9460
9461 context->setVertexAttribi(index, v);
9462 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009463 }
9464 catch(std::bad_alloc&)
9465 {
9466 return gl::error(GL_OUT_OF_MEMORY);
9467 }
9468}
9469
9470void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v)
9471{
9472 EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
9473
9474 try
9475 {
9476 gl::Context *context = gl::getNonLostContext();
9477
9478 if (context)
9479 {
9480 if (context->getClientVersion() < 3)
9481 {
9482 return gl::error(GL_INVALID_OPERATION);
9483 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009484
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00009485 if (index >= gl::MAX_VERTEX_ATTRIBS)
9486 {
9487 return gl::error(GL_INVALID_VALUE);
9488 }
9489
9490 context->setVertexAttribu(index, v);
9491 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009492 }
9493 catch(std::bad_alloc&)
9494 {
9495 return gl::error(GL_OUT_OF_MEMORY);
9496 }
9497}
9498
9499void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params)
9500{
9501 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
9502 program, location, params);
9503
9504 try
9505 {
9506 gl::Context *context = gl::getNonLostContext();
9507
9508 if (context)
9509 {
9510 if (context->getClientVersion() < 3)
9511 {
9512 return gl::error(GL_INVALID_OPERATION);
9513 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009514
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00009515 if (program == 0)
9516 {
9517 return gl::error(GL_INVALID_VALUE);
9518 }
9519
9520 gl::Program *programObject = context->getProgram(program);
9521
9522 if (!programObject || !programObject->isLinked())
9523 {
9524 return gl::error(GL_INVALID_OPERATION);
9525 }
9526
9527 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
9528 if (!programBinary)
9529 {
9530 return gl::error(GL_INVALID_OPERATION);
9531 }
9532
9533 if (!programBinary->getUniformuiv(location, NULL, params))
9534 {
9535 return gl::error(GL_INVALID_OPERATION);
9536 }
9537 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009538 }
9539 catch(std::bad_alloc&)
9540 {
9541 return gl::error(GL_OUT_OF_MEMORY);
9542 }
9543}
9544
9545GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name)
9546{
9547 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
9548 program, name);
9549
9550 try
9551 {
9552 gl::Context *context = gl::getNonLostContext();
9553
9554 if (context)
9555 {
9556 if (context->getClientVersion() < 3)
9557 {
9558 return gl::error(GL_INVALID_OPERATION, 0);
9559 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009560
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009561 UNIMPLEMENTED();
9562 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009563 }
9564 catch(std::bad_alloc&)
9565 {
9566 return gl::error(GL_OUT_OF_MEMORY, 0);
9567 }
9568
9569 return 0;
9570}
9571
9572void __stdcall glUniform1ui(GLint location, GLuint v0)
9573{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00009574 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009575}
9576
9577void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1)
9578{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00009579 const GLuint xy[] = { v0, v1 };
9580 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009581}
9582
9583void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
9584{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00009585 const GLuint xyz[] = { v0, v1, v2 };
9586 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009587}
9588
9589void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
9590{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00009591 const GLuint xyzw[] = { v0, v1, v2, v3 };
9592 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009593}
9594
9595void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
9596{
9597 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
9598 location, count, value);
9599
9600 try
9601 {
9602 gl::Context *context = gl::getNonLostContext();
9603
9604 if (context)
9605 {
9606 if (context->getClientVersion() < 3)
9607 {
9608 return gl::error(GL_INVALID_OPERATION);
9609 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009610
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00009611 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9612 if (!programBinary)
9613 {
9614 return gl::error(GL_INVALID_OPERATION);
9615 }
9616
9617 if (!programBinary->setUniform1uiv(location, count, value))
9618 {
9619 return gl::error(GL_INVALID_OPERATION);
9620 }
9621 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009622 }
9623 catch(std::bad_alloc&)
9624 {
9625 return gl::error(GL_OUT_OF_MEMORY);
9626 }
9627}
9628
9629void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
9630{
9631 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
9632 location, count, value);
9633
9634 try
9635 {
9636 gl::Context *context = gl::getNonLostContext();
9637
9638 if (context)
9639 {
9640 if (context->getClientVersion() < 3)
9641 {
9642 return gl::error(GL_INVALID_OPERATION);
9643 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009644
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00009645 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9646 if (!programBinary)
9647 {
9648 return gl::error(GL_INVALID_OPERATION);
9649 }
9650
9651 if (!programBinary->setUniform2uiv(location, count, value))
9652 {
9653 return gl::error(GL_INVALID_OPERATION);
9654 }
9655 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009656 }
9657 catch(std::bad_alloc&)
9658 {
9659 return gl::error(GL_OUT_OF_MEMORY);
9660 }
9661}
9662
9663void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
9664{
9665 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
9666 location, count, value);
9667
9668 try
9669 {
9670 gl::Context *context = gl::getNonLostContext();
9671
9672 if (context)
9673 {
9674 if (context->getClientVersion() < 3)
9675 {
9676 return gl::error(GL_INVALID_OPERATION);
9677 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009678
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00009679 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9680 if (!programBinary)
9681 {
9682 return gl::error(GL_INVALID_OPERATION);
9683 }
9684
9685 if (!programBinary->setUniform3uiv(location, count, value))
9686 {
9687 return gl::error(GL_INVALID_OPERATION);
9688 }
9689 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009690 }
9691 catch(std::bad_alloc&)
9692 {
9693 return gl::error(GL_OUT_OF_MEMORY);
9694 }
9695}
9696
9697void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
9698{
9699 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
9700 location, count, value);
9701
9702 try
9703 {
9704 gl::Context *context = gl::getNonLostContext();
9705
9706 if (context)
9707 {
9708 if (context->getClientVersion() < 3)
9709 {
9710 return gl::error(GL_INVALID_OPERATION);
9711 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009712
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00009713 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
9714 if (!programBinary)
9715 {
9716 return gl::error(GL_INVALID_OPERATION);
9717 }
9718
9719 if (!programBinary->setUniform4uiv(location, count, value))
9720 {
9721 return gl::error(GL_INVALID_OPERATION);
9722 }
9723 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009724 }
9725 catch(std::bad_alloc&)
9726 {
9727 return gl::error(GL_OUT_OF_MEMORY);
9728 }
9729}
9730
9731void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
9732{
9733 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
9734 buffer, drawbuffer, value);
9735
9736 try
9737 {
9738 gl::Context *context = gl::getNonLostContext();
9739
9740 if (context)
9741 {
9742 if (context->getClientVersion() < 3)
9743 {
9744 return gl::error(GL_INVALID_OPERATION);
9745 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009746
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009747 UNIMPLEMENTED();
9748 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009749 }
9750 catch(std::bad_alloc&)
9751 {
9752 return gl::error(GL_OUT_OF_MEMORY);
9753 }
9754}
9755
9756void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
9757{
9758 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
9759 buffer, drawbuffer, value);
9760
9761 try
9762 {
9763 gl::Context *context = gl::getNonLostContext();
9764
9765 if (context)
9766 {
9767 if (context->getClientVersion() < 3)
9768 {
9769 return gl::error(GL_INVALID_OPERATION);
9770 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009771
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009772 UNIMPLEMENTED();
9773 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009774 }
9775 catch(std::bad_alloc&)
9776 {
9777 return gl::error(GL_OUT_OF_MEMORY);
9778 }
9779}
9780
9781void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
9782{
9783 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
9784 buffer, drawbuffer, value);
9785
9786 try
9787 {
9788 gl::Context *context = gl::getNonLostContext();
9789
9790 if (context)
9791 {
9792 if (context->getClientVersion() < 3)
9793 {
9794 return gl::error(GL_INVALID_OPERATION);
9795 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009796
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009797 UNIMPLEMENTED();
9798 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009799 }
9800 catch(std::bad_alloc&)
9801 {
9802 return gl::error(GL_OUT_OF_MEMORY);
9803 }
9804}
9805
9806void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
9807{
9808 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
9809 buffer, drawbuffer, depth, stencil);
9810
9811 try
9812 {
9813 gl::Context *context = gl::getNonLostContext();
9814
9815 if (context)
9816 {
9817 if (context->getClientVersion() < 3)
9818 {
9819 return gl::error(GL_INVALID_OPERATION);
9820 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009821
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009822 UNIMPLEMENTED();
9823 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009824 }
9825 catch(std::bad_alloc&)
9826 {
9827 return gl::error(GL_OUT_OF_MEMORY);
9828 }
9829}
9830
9831const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index)
9832{
9833 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
9834
9835 try
9836 {
9837 gl::Context *context = gl::getNonLostContext();
9838
9839 if (context)
9840 {
9841 if (context->getClientVersion() < 3)
9842 {
9843 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL));
9844 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009845
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00009846 if (name != GL_EXTENSIONS)
9847 {
9848 return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL));
9849 }
9850
9851 if (index >= context->getNumExtensions())
9852 {
9853 return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL));
9854 }
9855
9856 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index));
9857 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009858 }
9859 catch(std::bad_alloc&)
9860 {
9861 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL));
9862 }
9863
9864 return NULL;
9865}
9866
9867void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
9868{
9869 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
9870 readTarget, writeTarget, readOffset, writeOffset, size);
9871
9872 try
9873 {
9874 gl::Context *context = gl::getNonLostContext();
9875
9876 if (context)
9877 {
9878 if (context->getClientVersion() < 3)
9879 {
9880 return gl::error(GL_INVALID_OPERATION);
9881 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009882
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00009883 gl::Buffer *readBuffer = NULL;
9884 switch (readTarget)
9885 {
9886 case GL_ARRAY_BUFFER:
9887 readBuffer = context->getArrayBuffer();
9888 break;
9889 case GL_COPY_READ_BUFFER:
9890 readBuffer = context->getCopyReadBuffer();
9891 break;
9892 case GL_COPY_WRITE_BUFFER:
9893 readBuffer = context->getCopyWriteBuffer();
9894 break;
9895 case GL_ELEMENT_ARRAY_BUFFER:
9896 readBuffer = context->getElementArrayBuffer();
9897 break;
9898 case GL_PIXEL_PACK_BUFFER:
9899 readBuffer = context->getPixelPackBuffer();
9900 break;
9901 case GL_PIXEL_UNPACK_BUFFER:
9902 readBuffer = context->getPixelUnpackBuffer();
9903 break;
9904 case GL_TRANSFORM_FEEDBACK_BUFFER:
9905 readBuffer = context->getGenericTransformFeedbackBuffer();
9906 break;
9907 case GL_UNIFORM_BUFFER:
9908 readBuffer = context->getGenericUniformBuffer();
9909 break;
9910 default:
9911 return gl::error(GL_INVALID_ENUM);
9912 }
9913
9914 gl::Buffer *writeBuffer = NULL;
9915 switch (writeTarget)
9916 {
9917 case GL_ARRAY_BUFFER:
9918 writeBuffer = context->getArrayBuffer();
9919 break;
9920 case GL_COPY_READ_BUFFER:
9921 writeBuffer = context->getCopyReadBuffer();
9922 break;
9923 case GL_COPY_WRITE_BUFFER:
9924 writeBuffer = context->getCopyWriteBuffer();
9925 break;
9926 case GL_ELEMENT_ARRAY_BUFFER:
9927 writeBuffer = context->getElementArrayBuffer();
9928 break;
9929 case GL_PIXEL_PACK_BUFFER:
9930 writeBuffer = context->getPixelPackBuffer();
9931 break;
9932 case GL_PIXEL_UNPACK_BUFFER:
9933 writeBuffer = context->getPixelUnpackBuffer();
9934 break;
9935 case GL_TRANSFORM_FEEDBACK_BUFFER:
9936 writeBuffer = context->getGenericTransformFeedbackBuffer();
9937 break;
9938 case GL_UNIFORM_BUFFER:
9939 writeBuffer = context->getGenericUniformBuffer();
9940 break;
9941 default:
9942 return gl::error(GL_INVALID_ENUM);
9943 }
9944
9945 if (!readBuffer || !writeBuffer)
9946 {
9947 return gl::error(GL_INVALID_OPERATION);
9948 }
9949
9950 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
9951 static_cast<unsigned int>(readOffset + size) > readBuffer->size() ||
9952 static_cast<unsigned int>(writeOffset + size) > writeBuffer->size())
9953 {
9954 return gl::error(GL_INVALID_VALUE);
9955 }
9956
9957 if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size)
9958 {
9959 return gl::error(GL_INVALID_VALUE);
9960 }
9961
9962 // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION)
9963
shannon.woods%transgaming.com@gtempaccount.comc53376a2013-04-13 03:41:23 +00009964 // if size is zero, the copy is a successful no-op
9965 if (size > 0)
9966 {
9967 writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
9968 }
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00009969 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009970 }
9971 catch(std::bad_alloc&)
9972 {
9973 return gl::error(GL_OUT_OF_MEMORY);
9974 }
9975}
9976
9977void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
9978{
9979 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
9980 program, uniformCount, uniformNames, uniformIndices);
9981
9982 try
9983 {
9984 gl::Context *context = gl::getNonLostContext();
9985
9986 if (context)
9987 {
9988 if (context->getClientVersion() < 3)
9989 {
9990 return gl::error(GL_INVALID_OPERATION);
9991 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009992
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00009993 if (uniformCount < 0)
9994 {
9995 return gl::error(GL_INVALID_VALUE);
9996 }
9997
9998 gl::Program *programObject = context->getProgram(program);
9999
10000 if (!programObject)
10001 {
10002 if (context->getShader(program))
10003 {
10004 return gl::error(GL_INVALID_OPERATION);
10005 }
10006 else
10007 {
10008 return gl::error(GL_INVALID_VALUE);
10009 }
10010 }
10011
10012 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10013 if (!programObject->isLinked() || !programBinary)
10014 {
10015 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10016 {
10017 uniformIndices[uniformId] = GL_INVALID_INDEX;
10018 }
10019 }
10020 else
10021 {
10022 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10023 {
10024 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
10025 }
10026 }
10027 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010028 }
10029 catch(std::bad_alloc&)
10030 {
10031 return gl::error(GL_OUT_OF_MEMORY);
10032 }
10033}
10034
10035void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
10036{
10037 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
10038 program, uniformCount, uniformIndices, pname, params);
10039
10040 try
10041 {
10042 gl::Context *context = gl::getNonLostContext();
10043
10044 if (context)
10045 {
10046 if (context->getClientVersion() < 3)
10047 {
10048 return gl::error(GL_INVALID_OPERATION);
10049 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010050
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +000010051 if (uniformCount < 0)
10052 {
10053 return gl::error(GL_INVALID_VALUE);
10054 }
10055
10056 gl::Program *programObject = context->getProgram(program);
10057
10058 if (!programObject)
10059 {
10060 if (context->getShader(program))
10061 {
10062 return gl::error(GL_INVALID_OPERATION);
10063 }
10064 else
10065 {
10066 return gl::error(GL_INVALID_VALUE);
10067 }
10068 }
10069
10070 switch (pname)
10071 {
10072 case GL_UNIFORM_TYPE:
10073 case GL_UNIFORM_SIZE:
10074 case GL_UNIFORM_NAME_LENGTH:
10075 case GL_UNIFORM_BLOCK_INDEX:
10076 case GL_UNIFORM_OFFSET:
10077 case GL_UNIFORM_ARRAY_STRIDE:
10078 case GL_UNIFORM_MATRIX_STRIDE:
10079 case GL_UNIFORM_IS_ROW_MAJOR:
10080 break;
10081 default:
10082 return gl::error(GL_INVALID_ENUM);
10083 }
10084
10085 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10086
10087 if (!programBinary && uniformCount > 0)
10088 {
10089 return gl::error(GL_INVALID_VALUE);
10090 }
10091
10092 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10093 {
10094 const GLuint index = uniformIndices[uniformId];
10095
10096 if (index >= (GLuint)programBinary->getActiveUniformCount())
10097 {
10098 return gl::error(GL_INVALID_VALUE);
10099 }
10100 }
10101
10102 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
10103 {
10104 const GLuint index = uniformIndices[uniformId];
10105 params[uniformId] = programBinary->getActiveUniformi(index, pname);
10106 }
10107 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010108 }
10109 catch(std::bad_alloc&)
10110 {
10111 return gl::error(GL_OUT_OF_MEMORY);
10112 }
10113}
10114
10115GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
10116{
10117 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
10118
10119 try
10120 {
10121 gl::Context *context = gl::getNonLostContext();
10122
10123 if (context)
10124 {
10125 if (context->getClientVersion() < 3)
10126 {
shannonwoods@chromium.org42766252013-05-30 00:07:12 +000010127 return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010128 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010129
shannonwoods@chromium.org42766252013-05-30 00:07:12 +000010130 gl::Program *programObject = context->getProgram(program);
10131
10132 if (!programObject)
10133 {
10134 if (context->getShader(program))
10135 {
10136 return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
10137 }
10138 else
10139 {
10140 return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX);
10141 }
10142 }
10143
10144 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10145 if (!programBinary)
10146 {
10147 return GL_INVALID_INDEX;
10148 }
10149
10150 return programBinary->getUniformBlockIndex(uniformBlockName);
10151 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010152 }
10153 catch(std::bad_alloc&)
10154 {
10155 return gl::error(GL_OUT_OF_MEMORY, 0);
10156 }
10157
10158 return 0;
10159}
10160
10161void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
10162{
10163 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
10164 program, uniformBlockIndex, pname, params);
10165
10166 try
10167 {
10168 gl::Context *context = gl::getNonLostContext();
10169
10170 if (context)
10171 {
10172 if (context->getClientVersion() < 3)
10173 {
10174 return gl::error(GL_INVALID_OPERATION);
10175 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +000010176 gl::Program *programObject = context->getProgram(program);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010177
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +000010178 if (!programObject)
10179 {
10180 if (context->getShader(program))
10181 {
10182 return gl::error(GL_INVALID_OPERATION);
10183 }
10184 else
10185 {
10186 return gl::error(GL_INVALID_VALUE);
10187 }
10188 }
10189
10190 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10191
10192 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
10193 {
10194 return gl::error(GL_INVALID_VALUE);
10195 }
10196
10197 switch (pname)
10198 {
10199 case GL_UNIFORM_BLOCK_BINDING:
10200 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
10201 break;
10202
10203 case GL_UNIFORM_BLOCK_DATA_SIZE:
10204 case GL_UNIFORM_BLOCK_NAME_LENGTH:
10205 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
10206 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
10207 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
10208 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
10209 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
10210 break;
10211
10212 default:
10213 return gl::error(GL_INVALID_ENUM);
10214 }
10215 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010216 }
10217 catch(std::bad_alloc&)
10218 {
10219 return gl::error(GL_OUT_OF_MEMORY);
10220 }
10221}
10222
10223void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
10224{
10225 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
10226 program, uniformBlockIndex, bufSize, length, uniformBlockName);
10227
10228 try
10229 {
10230 gl::Context *context = gl::getNonLostContext();
10231
10232 if (context)
10233 {
10234 if (context->getClientVersion() < 3)
10235 {
10236 return gl::error(GL_INVALID_OPERATION);
10237 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010238
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +000010239 gl::Program *programObject = context->getProgram(program);
10240
10241 if (!programObject)
10242 {
10243 if (context->getShader(program))
10244 {
10245 return gl::error(GL_INVALID_OPERATION);
10246 }
10247 else
10248 {
10249 return gl::error(GL_INVALID_VALUE);
10250 }
10251 }
10252
10253 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10254
10255 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
10256 {
10257 return gl::error(GL_INVALID_VALUE);
10258 }
10259
10260 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
10261 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010262 }
10263 catch(std::bad_alloc&)
10264 {
10265 return gl::error(GL_OUT_OF_MEMORY);
10266 }
10267}
10268
10269void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
10270{
10271 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
10272 program, uniformBlockIndex, uniformBlockBinding);
10273
10274 try
10275 {
10276 gl::Context *context = gl::getNonLostContext();
10277
10278 if (context)
10279 {
10280 if (context->getClientVersion() < 3)
10281 {
10282 return gl::error(GL_INVALID_OPERATION);
10283 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010284
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +000010285 if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings())
10286 {
10287 return gl::error(GL_INVALID_VALUE);
10288 }
10289
10290 gl::Program *programObject = context->getProgram(program);
10291
10292 if (!programObject)
10293 {
10294 if (context->getShader(program))
10295 {
10296 return gl::error(GL_INVALID_OPERATION);
10297 }
10298 else
10299 {
10300 return gl::error(GL_INVALID_VALUE);
10301 }
10302 }
10303
10304 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
10305
10306 // if never linked, there won't be any uniform blocks
10307 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
10308 {
10309 return gl::error(GL_INVALID_VALUE);
10310 }
10311
10312 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
10313 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010314 }
10315 catch(std::bad_alloc&)
10316 {
10317 return gl::error(GL_OUT_OF_MEMORY);
10318 }
10319}
10320
10321void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
10322{
10323 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
10324 mode, first, count, instanceCount);
10325
10326 try
10327 {
10328 gl::Context *context = gl::getNonLostContext();
10329
10330 if (context)
10331 {
10332 if (context->getClientVersion() < 3)
10333 {
10334 return gl::error(GL_INVALID_OPERATION);
10335 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010336
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010337 UNIMPLEMENTED();
10338 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010339 }
10340 catch(std::bad_alloc&)
10341 {
10342 return gl::error(GL_OUT_OF_MEMORY);
10343 }
10344}
10345
10346void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
10347{
10348 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
10349 mode, count, type, indices, instanceCount);
10350
10351 try
10352 {
10353 gl::Context *context = gl::getNonLostContext();
10354
10355 if (context)
10356 {
10357 if (context->getClientVersion() < 3)
10358 {
10359 return gl::error(GL_INVALID_OPERATION);
10360 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010361
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010362 UNIMPLEMENTED();
10363 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010364 }
10365 catch(std::bad_alloc&)
10366 {
10367 return gl::error(GL_OUT_OF_MEMORY);
10368 }
10369}
10370
10371GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags)
10372{
10373 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
10374
10375 try
10376 {
10377 gl::Context *context = gl::getNonLostContext();
10378
10379 if (context)
10380 {
10381 if (context->getClientVersion() < 3)
10382 {
10383 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(NULL));
10384 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010385
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010386 UNIMPLEMENTED();
10387 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010388 }
10389 catch(std::bad_alloc&)
10390 {
10391 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL));
10392 }
10393
10394 return NULL;
10395}
10396
10397GLboolean __stdcall glIsSync(GLsync sync)
10398{
10399 EVENT("(GLsync sync = 0x%0.8p)", sync);
10400
10401 try
10402 {
10403 gl::Context *context = gl::getNonLostContext();
10404
10405 if (context)
10406 {
10407 if (context->getClientVersion() < 3)
10408 {
10409 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10410 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010411
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010412 UNIMPLEMENTED();
10413 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010414 }
10415 catch(std::bad_alloc&)
10416 {
10417 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10418 }
10419
10420 return GL_FALSE;
10421}
10422
10423void __stdcall glDeleteSync(GLsync sync)
10424{
10425 EVENT("(GLsync sync = 0x%0.8p)", sync);
10426
10427 try
10428 {
10429 gl::Context *context = gl::getNonLostContext();
10430
10431 if (context)
10432 {
10433 if (context->getClientVersion() < 3)
10434 {
10435 return gl::error(GL_INVALID_OPERATION);
10436 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010437
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010438 UNIMPLEMENTED();
10439 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010440 }
10441 catch(std::bad_alloc&)
10442 {
10443 return gl::error(GL_OUT_OF_MEMORY);
10444 }
10445}
10446
10447GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
10448{
10449 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
10450 sync, flags, timeout);
10451
10452 try
10453 {
10454 gl::Context *context = gl::getNonLostContext();
10455
10456 if (context)
10457 {
10458 if (context->getClientVersion() < 3)
10459 {
10460 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10461 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010462
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010463 UNIMPLEMENTED();
10464 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010465 }
10466 catch(std::bad_alloc&)
10467 {
10468 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10469 }
10470
10471 return GL_FALSE;
10472}
10473
10474void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
10475{
10476 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
10477 sync, flags, timeout);
10478
10479 try
10480 {
10481 gl::Context *context = gl::getNonLostContext();
10482
10483 if (context)
10484 {
10485 if (context->getClientVersion() < 3)
10486 {
10487 return gl::error(GL_INVALID_OPERATION);
10488 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010489
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010490 UNIMPLEMENTED();
10491 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010492 }
10493 catch(std::bad_alloc&)
10494 {
10495 return gl::error(GL_OUT_OF_MEMORY);
10496 }
10497}
10498
10499void __stdcall glGetInteger64v(GLenum pname, GLint64* params)
10500{
10501 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
10502 pname, params);
10503
10504 try
10505 {
10506 gl::Context *context = gl::getNonLostContext();
10507
10508 if (context)
10509 {
10510 if (context->getClientVersion() < 3)
10511 {
10512 return gl::error(GL_INVALID_OPERATION);
10513 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010514
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010515 UNIMPLEMENTED();
10516 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010517 }
10518 catch(std::bad_alloc&)
10519 {
10520 return gl::error(GL_OUT_OF_MEMORY);
10521 }
10522}
10523
10524void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
10525{
10526 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
10527 sync, pname, bufSize, length, values);
10528
10529 try
10530 {
10531 gl::Context *context = gl::getNonLostContext();
10532
10533 if (context)
10534 {
10535 if (context->getClientVersion() < 3)
10536 {
10537 return gl::error(GL_INVALID_OPERATION);
10538 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010539
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010540 UNIMPLEMENTED();
10541 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010542 }
10543 catch(std::bad_alloc&)
10544 {
10545 return gl::error(GL_OUT_OF_MEMORY);
10546 }
10547}
10548
10549void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
10550{
10551 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
10552 target, index, data);
10553
10554 try
10555 {
10556 gl::Context *context = gl::getNonLostContext();
10557
10558 if (context)
10559 {
10560 if (context->getClientVersion() < 3)
10561 {
10562 return gl::error(GL_INVALID_OPERATION);
10563 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010564
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010565 UNIMPLEMENTED();
10566 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010567 }
10568 catch(std::bad_alloc&)
10569 {
10570 return gl::error(GL_OUT_OF_MEMORY);
10571 }
10572}
10573
10574void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
10575{
10576 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
10577 target, pname, params);
10578
10579 try
10580 {
10581 gl::Context *context = gl::getNonLostContext();
10582
10583 if (context)
10584 {
10585 if (context->getClientVersion() < 3)
10586 {
10587 return gl::error(GL_INVALID_OPERATION);
10588 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010589
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010590 UNIMPLEMENTED();
10591 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010592 }
10593 catch(std::bad_alloc&)
10594 {
10595 return gl::error(GL_OUT_OF_MEMORY);
10596 }
10597}
10598
10599void __stdcall glGenSamplers(GLsizei count, GLuint* samplers)
10600{
10601 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
10602
10603 try
10604 {
10605 gl::Context *context = gl::getNonLostContext();
10606
10607 if (context)
10608 {
10609 if (context->getClientVersion() < 3)
10610 {
10611 return gl::error(GL_INVALID_OPERATION);
10612 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010613
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010614 UNIMPLEMENTED();
10615 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010616 }
10617 catch(std::bad_alloc&)
10618 {
10619 return gl::error(GL_OUT_OF_MEMORY);
10620 }
10621}
10622
10623void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers)
10624{
10625 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
10626
10627 try
10628 {
10629 gl::Context *context = gl::getNonLostContext();
10630
10631 if (context)
10632 {
10633 if (context->getClientVersion() < 3)
10634 {
10635 return gl::error(GL_INVALID_OPERATION);
10636 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010637
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010638 UNIMPLEMENTED();
10639 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010640 }
10641 catch(std::bad_alloc&)
10642 {
10643 return gl::error(GL_OUT_OF_MEMORY);
10644 }
10645}
10646
10647GLboolean __stdcall glIsSampler(GLuint sampler)
10648{
10649 EVENT("(GLuint sampler = %u)", sampler);
10650
10651 try
10652 {
10653 gl::Context *context = gl::getNonLostContext();
10654
10655 if (context)
10656 {
10657 if (context->getClientVersion() < 3)
10658 {
10659 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10660 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010661
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010662 UNIMPLEMENTED();
10663 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010664 }
10665 catch(std::bad_alloc&)
10666 {
10667 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10668 }
10669
10670 return GL_FALSE;
10671}
10672
10673void __stdcall glBindSampler(GLuint unit, GLuint sampler)
10674{
10675 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
10676
10677 try
10678 {
10679 gl::Context *context = gl::getNonLostContext();
10680
10681 if (context)
10682 {
10683 if (context->getClientVersion() < 3)
10684 {
10685 return gl::error(GL_INVALID_OPERATION);
10686 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010687
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010688 UNIMPLEMENTED();
10689 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010690 }
10691 catch(std::bad_alloc&)
10692 {
10693 return gl::error(GL_OUT_OF_MEMORY);
10694 }
10695}
10696
10697void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
10698{
10699 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
10700
10701 try
10702 {
10703 gl::Context *context = gl::getNonLostContext();
10704
10705 if (context)
10706 {
10707 if (context->getClientVersion() < 3)
10708 {
10709 return gl::error(GL_INVALID_OPERATION);
10710 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010711
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010712 UNIMPLEMENTED();
10713 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010714 }
10715 catch(std::bad_alloc&)
10716 {
10717 return gl::error(GL_OUT_OF_MEMORY);
10718 }
10719}
10720
10721void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
10722{
10723 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLint* param = 0x%0.8p)",
10724 sampler, pname, param);
10725
10726 try
10727 {
10728 gl::Context *context = gl::getNonLostContext();
10729
10730 if (context)
10731 {
10732 if (context->getClientVersion() < 3)
10733 {
10734 return gl::error(GL_INVALID_OPERATION);
10735 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010736
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010737 UNIMPLEMENTED();
10738 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010739 }
10740 catch(std::bad_alloc&)
10741 {
10742 return gl::error(GL_OUT_OF_MEMORY);
10743 }
10744}
10745
10746void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
10747{
10748 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
10749
10750 try
10751 {
10752 gl::Context *context = gl::getNonLostContext();
10753
10754 if (context)
10755 {
10756 if (context->getClientVersion() < 3)
10757 {
10758 return gl::error(GL_INVALID_OPERATION);
10759 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010760
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010761 UNIMPLEMENTED();
10762 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010763 }
10764 catch(std::bad_alloc&)
10765 {
10766 return gl::error(GL_OUT_OF_MEMORY);
10767 }
10768}
10769
10770void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
10771{
10772 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLfloat* param = 0x%0.8p)", sampler, pname, param);
10773
10774 try
10775 {
10776 gl::Context *context = gl::getNonLostContext();
10777
10778 if (context)
10779 {
10780 if (context->getClientVersion() < 3)
10781 {
10782 return gl::error(GL_INVALID_OPERATION);
10783 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010784
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010785 UNIMPLEMENTED();
10786 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010787 }
10788 catch(std::bad_alloc&)
10789 {
10790 return gl::error(GL_OUT_OF_MEMORY);
10791 }
10792}
10793
10794void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
10795{
10796 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
10797
10798 try
10799 {
10800 gl::Context *context = gl::getNonLostContext();
10801
10802 if (context)
10803 {
10804 if (context->getClientVersion() < 3)
10805 {
10806 return gl::error(GL_INVALID_OPERATION);
10807 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010808
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010809 UNIMPLEMENTED();
10810 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010811 }
10812 catch(std::bad_alloc&)
10813 {
10814 return gl::error(GL_OUT_OF_MEMORY);
10815 }
10816}
10817
10818void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
10819{
10820 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
10821
10822 try
10823 {
10824 gl::Context *context = gl::getNonLostContext();
10825
10826 if (context)
10827 {
10828 if (context->getClientVersion() < 3)
10829 {
10830 return gl::error(GL_INVALID_OPERATION);
10831 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010832
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010833 UNIMPLEMENTED();
10834 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010835 }
10836 catch(std::bad_alloc&)
10837 {
10838 return gl::error(GL_OUT_OF_MEMORY);
10839 }
10840}
10841
10842void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor)
10843{
10844 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
10845
10846 try
10847 {
shannon.woods%transgaming.com@gtempaccount.com8736bd62013-04-13 03:35:41 +000010848 if (index >= gl::MAX_VERTEX_ATTRIBS)
10849 {
10850 return gl::error(GL_INVALID_VALUE);
10851 }
10852
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010853 gl::Context *context = gl::getNonLostContext();
10854
10855 if (context)
10856 {
10857 if (context->getClientVersion() < 3)
10858 {
10859 return gl::error(GL_INVALID_OPERATION);
10860 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010861
shannon.woods%transgaming.com@gtempaccount.com8736bd62013-04-13 03:35:41 +000010862 context->setVertexAttribDivisor(index, divisor);
10863 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010864 }
10865 catch(std::bad_alloc&)
10866 {
10867 return gl::error(GL_OUT_OF_MEMORY);
10868 }
10869}
10870
10871void __stdcall glBindTransformFeedback(GLenum target, GLuint id)
10872{
10873 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
10874
10875 try
10876 {
10877 gl::Context *context = gl::getNonLostContext();
10878
10879 if (context)
10880 {
10881 if (context->getClientVersion() < 3)
10882 {
10883 return gl::error(GL_INVALID_OPERATION);
10884 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010885
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010886 UNIMPLEMENTED();
10887 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010888 }
10889 catch(std::bad_alloc&)
10890 {
10891 return gl::error(GL_OUT_OF_MEMORY);
10892 }
10893}
10894
10895void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
10896{
10897 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
10898
10899 try
10900 {
10901 gl::Context *context = gl::getNonLostContext();
10902
10903 if (context)
10904 {
10905 if (context->getClientVersion() < 3)
10906 {
10907 return gl::error(GL_INVALID_OPERATION);
10908 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010909
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010910 UNIMPLEMENTED();
10911 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010912 }
10913 catch(std::bad_alloc&)
10914 {
10915 return gl::error(GL_OUT_OF_MEMORY);
10916 }
10917}
10918
10919void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids)
10920{
10921 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
10922
10923 try
10924 {
10925 gl::Context *context = gl::getNonLostContext();
10926
10927 if (context)
10928 {
10929 if (context->getClientVersion() < 3)
10930 {
10931 return gl::error(GL_INVALID_OPERATION);
10932 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010933
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010934 UNIMPLEMENTED();
10935 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010936 }
10937 catch(std::bad_alloc&)
10938 {
10939 return gl::error(GL_OUT_OF_MEMORY);
10940 }
10941}
10942
10943GLboolean __stdcall glIsTransformFeedback(GLuint id)
10944{
10945 EVENT("(GLuint id = %u)", id);
10946
10947 try
10948 {
10949 gl::Context *context = gl::getNonLostContext();
10950
10951 if (context)
10952 {
10953 if (context->getClientVersion() < 3)
10954 {
10955 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
10956 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010957
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010958 UNIMPLEMENTED();
10959 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010960 }
10961 catch(std::bad_alloc&)
10962 {
10963 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
10964 }
10965
10966 return GL_FALSE;
10967}
10968
10969void __stdcall glPauseTransformFeedback(void)
10970{
10971 EVENT("(void)");
10972
10973 try
10974 {
10975 gl::Context *context = gl::getNonLostContext();
10976
10977 if (context)
10978 {
10979 if (context->getClientVersion() < 3)
10980 {
10981 return gl::error(GL_INVALID_OPERATION);
10982 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010983
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000010984 UNIMPLEMENTED();
10985 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000010986 }
10987 catch(std::bad_alloc&)
10988 {
10989 return gl::error(GL_OUT_OF_MEMORY);
10990 }
10991}
10992
10993void __stdcall glResumeTransformFeedback(void)
10994{
10995 EVENT("(void)");
10996
10997 try
10998 {
10999 gl::Context *context = gl::getNonLostContext();
11000
11001 if (context)
11002 {
11003 if (context->getClientVersion() < 3)
11004 {
11005 return gl::error(GL_INVALID_OPERATION);
11006 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011007
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011008 UNIMPLEMENTED();
11009 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011010 }
11011 catch(std::bad_alloc&)
11012 {
11013 return gl::error(GL_OUT_OF_MEMORY);
11014 }
11015}
11016
11017void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
11018{
11019 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
11020 program, bufSize, length, binaryFormat, binary);
11021
11022 try
11023 {
11024 gl::Context *context = gl::getNonLostContext();
11025
11026 if (context)
11027 {
11028 if (context->getClientVersion() < 3)
11029 {
11030 return gl::error(GL_INVALID_OPERATION);
11031 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011032
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011033 UNIMPLEMENTED();
11034 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011035 }
11036 catch(std::bad_alloc&)
11037 {
11038 return gl::error(GL_OUT_OF_MEMORY);
11039 }
11040}
11041
11042void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
11043{
11044 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
11045 program, binaryFormat, binary, length);
11046
11047 try
11048 {
11049 gl::Context *context = gl::getNonLostContext();
11050
11051 if (context)
11052 {
11053 if (context->getClientVersion() < 3)
11054 {
11055 return gl::error(GL_INVALID_OPERATION);
11056 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011057
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011058 UNIMPLEMENTED();
11059 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011060 }
11061 catch(std::bad_alloc&)
11062 {
11063 return gl::error(GL_OUT_OF_MEMORY);
11064 }
11065}
11066
11067void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value)
11068{
11069 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
11070 program, pname, value);
11071
11072 try
11073 {
11074 gl::Context *context = gl::getNonLostContext();
11075
11076 if (context)
11077 {
11078 if (context->getClientVersion() < 3)
11079 {
11080 return gl::error(GL_INVALID_OPERATION);
11081 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011082
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011083 UNIMPLEMENTED();
11084 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011085 }
11086 catch(std::bad_alloc&)
11087 {
11088 return gl::error(GL_OUT_OF_MEMORY);
11089 }
11090}
11091
11092void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
11093{
11094 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
11095 target, numAttachments, attachments);
11096
11097 try
11098 {
11099 gl::Context *context = gl::getNonLostContext();
11100
11101 if (context)
11102 {
11103 if (context->getClientVersion() < 3)
11104 {
11105 return gl::error(GL_INVALID_OPERATION);
11106 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011107
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +000011108 if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
11109 {
11110 return;
11111 }
11112
11113 int maxDimension = context->getMaximumRenderbufferDimension();
11114 context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension);
11115 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011116 }
11117 catch(std::bad_alloc&)
11118 {
11119 return gl::error(GL_OUT_OF_MEMORY);
11120 }
11121}
11122
11123void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
11124{
11125 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
11126 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
11127 target, numAttachments, attachments, x, y, width, height);
11128
11129 try
11130 {
11131 gl::Context *context = gl::getNonLostContext();
11132
11133 if (context)
11134 {
11135 if (context->getClientVersion() < 3)
11136 {
11137 return gl::error(GL_INVALID_OPERATION);
11138 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011139
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +000011140 if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
11141 {
11142 return;
11143 }
11144
11145 context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height);
11146 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011147 }
11148 catch(std::bad_alloc&)
11149 {
11150 return gl::error(GL_OUT_OF_MEMORY);
11151 }
11152}
11153
11154void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
11155{
11156 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
11157 target, levels, internalformat, width, height);
11158
11159 try
11160 {
11161 gl::Context *context = gl::getNonLostContext();
11162
11163 if (context)
11164 {
11165 if (context->getClientVersion() < 3)
11166 {
11167 return gl::error(GL_INVALID_OPERATION);
11168 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011169
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +000011170 if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
11171 {
11172 return;
11173 }
11174
11175 switch (target)
11176 {
11177 case GL_TEXTURE_2D:
11178 {
11179 gl::Texture2D *texture2d = context->getTexture2D();
11180 texture2d->storage(levels, internalformat, width, height);
11181 }
11182 break;
11183
11184 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
11185 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
11186 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
11187 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
11188 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
11189 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
11190 {
11191 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
11192 textureCube->storage(levels, internalformat, width);
11193 }
11194 break;
11195
11196 default:
11197 return gl::error(GL_INVALID_ENUM);
11198 }
11199 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011200 }
11201 catch(std::bad_alloc&)
11202 {
11203 return gl::error(GL_OUT_OF_MEMORY);
11204 }
11205}
11206
11207void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
11208{
11209 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
11210 "GLsizei height = %d, GLsizei depth = %d)",
11211 target, levels, internalformat, width, height, depth);
11212
11213 try
11214 {
11215 gl::Context *context = gl::getNonLostContext();
11216
11217 if (context)
11218 {
11219 if (context->getClientVersion() < 3)
11220 {
11221 return gl::error(GL_INVALID_OPERATION);
11222 }
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +000011223
11224 if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
11225 {
11226 return;
11227 }
11228
11229 switch (target)
11230 {
11231 case GL_TEXTURE_3D:
11232 {
11233 gl::Texture3D *texture3d = context->getTexture3D();
11234 texture3d->storage(levels, internalformat, width, height, depth);
11235 }
11236 break;
11237
11238 case GL_TEXTURE_2D_ARRAY:
11239 {
11240 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
11241 texture2darray->storage(levels, internalformat, width, height, depth);
11242 }
11243 break;
11244
11245 default:
11246 return gl::error(GL_INVALID_ENUM);
11247 }
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +000011248 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011249 }
11250 catch(std::bad_alloc&)
11251 {
11252 return gl::error(GL_OUT_OF_MEMORY);
11253 }
11254}
11255
11256void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
11257{
11258 EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
11259 "GLint* params = 0x%0.8p)",
11260 target, internalformat, pname, bufSize, params);
11261
11262 try
11263 {
11264 gl::Context *context = gl::getNonLostContext();
11265
11266 if (context)
11267 {
11268 if (context->getClientVersion() < 3)
11269 {
11270 return gl::error(GL_INVALID_OPERATION);
11271 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011272
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +000011273 UNIMPLEMENTED();
11274 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000011275 }
11276 catch(std::bad_alloc&)
11277 {
11278 return gl::error(GL_OUT_OF_MEMORY);
11279 }
11280}
11281
11282// Extension functions
11283
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011284void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
11285 GLbitfield mask, GLenum filter)
11286{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000011287 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011288 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
11289 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
11290 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
11291
11292 try
11293 {
11294 switch (filter)
11295 {
11296 case GL_NEAREST:
11297 break;
11298 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011299 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011300 }
11301
11302 if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0)
11303 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011304 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011305 }
11306
11307 if (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0)
11308 {
11309 ERR("Scaling and flipping in BlitFramebufferANGLE not supported by this implementation");
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011310 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011311 }
11312
daniel@transgaming.com9d788502011-11-09 17:46:55 +000011313 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011314
11315 if (context)
11316 {
11317 if (context->getReadFramebufferHandle() == context->getDrawFramebufferHandle())
11318 {
11319 ERR("Blits with the same source and destination framebuffer are not supported by this implementation.");
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011320 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011321 }
11322
11323 context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask);
11324 }
11325 }
11326 catch(std::bad_alloc&)
11327 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011328 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000011329 }
11330}
11331
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +000011332void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
11333 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011334{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000011335 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +000011336 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +000011337 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011338 target, level, internalformat, width, height, depth, border, format, type, pixels);
11339
11340 try
11341 {
11342 UNIMPLEMENTED(); // FIXME
11343 }
11344 catch(std::bad_alloc&)
11345 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011346 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011347 }
11348}
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011349
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011350void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
11351 GLenum *binaryFormat, void *binary)
11352{
apatrick@chromium.org90080e32012-07-09 22:15:33 +000011353 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 +000011354 program, bufSize, length, binaryFormat, binary);
11355
11356 try
11357 {
11358 gl::Context *context = gl::getNonLostContext();
11359
11360 if (context)
11361 {
11362 gl::Program *programObject = context->getProgram(program);
11363
daniel@transgaming.com716056c2012-07-24 18:38:59 +000011364 if (!programObject || !programObject->isLinked())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011365 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011366 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011367 }
11368
11369 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
11370
11371 if (!programBinary)
11372 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011373 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011374 }
11375
apatrick@chromium.org90080e32012-07-09 22:15:33 +000011376 if (!programBinary->save(binary, bufSize, length))
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011377 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011378 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011379 }
apatrick@chromium.org90080e32012-07-09 22:15:33 +000011380
11381 *binaryFormat = GL_PROGRAM_BINARY_ANGLE;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011382 }
11383 }
11384 catch(std::bad_alloc&)
11385 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011386 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011387 }
11388}
11389
11390void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat,
11391 const void *binary, GLint length)
11392{
11393 EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
11394 program, binaryFormat, binary, length);
11395
11396 try
11397 {
11398 gl::Context *context = gl::getNonLostContext();
11399
11400 if (context)
11401 {
11402 if (binaryFormat != GL_PROGRAM_BINARY_ANGLE)
11403 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011404 return gl::error(GL_INVALID_ENUM);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011405 }
11406
11407 gl::Program *programObject = context->getProgram(program);
11408
11409 if (!programObject)
11410 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011411 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011412 }
11413
daniel@transgaming.com95d29422012-07-24 18:36:10 +000011414 context->setProgramBinary(program, binary, length);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011415 }
11416 }
11417 catch(std::bad_alloc&)
11418 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011419 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011420 }
11421}
11422
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011423void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
11424{
11425 EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
11426
11427 try
11428 {
11429 gl::Context *context = gl::getNonLostContext();
11430
11431 if (context)
11432 {
11433 if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets())
11434 {
11435 return gl::error(GL_INVALID_VALUE);
11436 }
11437
11438 if (context->getDrawFramebufferHandle() == 0)
11439 {
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011440 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011441 {
11442 return gl::error(GL_INVALID_OPERATION);
11443 }
11444
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011445 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011446 {
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011447 return gl::error(GL_INVALID_OPERATION);
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011448 }
11449 }
11450 else
11451 {
11452 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
11453 {
11454 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
11455 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
11456 {
11457 return gl::error(GL_INVALID_OPERATION);
11458 }
11459 }
11460 }
11461
11462 gl::Framebuffer *framebuffer = context->getDrawFramebuffer();
11463
11464 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
11465 {
11466 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
11467 }
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +000011468
11469 for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++)
11470 {
11471 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
11472 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +000011473 }
11474 }
11475 catch (std::bad_alloc&)
11476 {
11477 return gl::error(GL_OUT_OF_MEMORY);
11478 }
11479}
11480
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011481__eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname)
11482{
11483 struct Extension
11484 {
11485 const char *name;
11486 __eglMustCastToProperFunctionPointerType address;
11487 };
11488
11489 static const Extension glExtensions[] =
11490 {
11491 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +000011492 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +000011493 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000011494 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
11495 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
11496 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
11497 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
11498 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
11499 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
11500 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +000011501 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +000011502 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +000011503 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
11504 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
11505 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
11506 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000011507 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
11508 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
11509 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
11510 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
11511 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
11512 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
11513 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +000011514 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +000011515 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
11516 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
11517 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000011518 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
11519 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011520
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +000011521 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000011522 {
11523 if (strcmp(procname, glExtensions[ext].name) == 0)
11524 {
11525 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
11526 }
11527 }
11528
11529 return NULL;
11530}
11531
daniel@transgaming.com17f548c2011-11-09 17:47:02 +000011532// Non-public functions used by EGL
11533
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000011534bool __stdcall glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011535{
11536 EVENT("(egl::Surface* surface = 0x%0.8p)",
11537 surface);
11538
11539 try
11540 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +000011541 gl::Context *context = gl::getNonLostContext();
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011542
11543 if (context)
11544 {
11545 gl::Texture2D *textureObject = context->getTexture2D();
11546
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000011547 if (textureObject->isImmutable())
11548 {
11549 return false;
11550 }
11551
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011552 if (textureObject)
11553 {
11554 textureObject->bindTexImage(surface);
11555 }
11556 }
11557 }
11558 catch(std::bad_alloc&)
11559 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000011560 return gl::error(GL_OUT_OF_MEMORY, false);
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011561 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000011562
11563 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +000011564}
11565
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011566}