daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame^] | 1 | // |
| 2 | // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions. |
| 8 | |
| 9 | #define GL_APICALL |
| 10 | #include <GLES2/gl2.h> |
| 11 | #include <GLES2/gl2ext.h> |
| 12 | |
| 13 | #include "Context.h" |
| 14 | #include "main.h" |
| 15 | #include "Program.h" |
| 16 | #include "Shader.h" |
| 17 | #include "Buffer.h" |
| 18 | #include "Texture.h" |
| 19 | #include "Renderbuffer.h" |
| 20 | #include "Framebuffer.h" |
| 21 | #include "mathutil.h" |
| 22 | #include "debug.h" |
| 23 | |
| 24 | #include <exception> |
| 25 | |
| 26 | extern "C" |
| 27 | { |
| 28 | |
| 29 | void __stdcall glActiveTexture(GLenum texture) |
| 30 | { |
| 31 | TRACE("GLenum texture = 0x%X", texture); |
| 32 | |
| 33 | try |
| 34 | { |
| 35 | if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + gl::MAX_TEXTURE_IMAGE_UNITS - 1) |
| 36 | { |
| 37 | return error(GL_INVALID_ENUM); |
| 38 | } |
| 39 | |
| 40 | gl::Context *context = gl::getContext(); |
| 41 | |
| 42 | if (context) |
| 43 | { |
| 44 | context->activeSampler = texture - GL_TEXTURE0; |
| 45 | } |
| 46 | } |
| 47 | catch(std::bad_alloc&) |
| 48 | { |
| 49 | return error(GL_OUT_OF_MEMORY); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | void __stdcall glAttachShader(GLuint program, GLuint shader) |
| 54 | { |
| 55 | TRACE("GLuint program = %d, GLuint shader = %d", program, shader); |
| 56 | |
| 57 | try |
| 58 | { |
| 59 | gl::Context *context = gl::getContext(); |
| 60 | |
| 61 | if (context) |
| 62 | { |
| 63 | gl::Program *programObject = context->getProgram(program); |
| 64 | gl::Shader *shaderObject = context->getShader(shader); |
| 65 | |
| 66 | if(!programObject || !shaderObject) |
| 67 | { |
| 68 | return error(GL_INVALID_VALUE); |
| 69 | } |
| 70 | |
| 71 | if (!programObject->attachShader(shaderObject)) |
| 72 | { |
| 73 | return error(GL_INVALID_OPERATION); |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | catch(std::bad_alloc&) |
| 78 | { |
| 79 | return error(GL_OUT_OF_MEMORY); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | void __stdcall glBindAttribLocation(GLuint program, GLuint index, const char* name) |
| 84 | { |
| 85 | TRACE("GLuint program = %d, GLuint index = %d, const char* name = 0x%0.8p", program, index, name); |
| 86 | |
| 87 | try |
| 88 | { |
| 89 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 90 | { |
| 91 | return error(GL_INVALID_VALUE); |
| 92 | } |
| 93 | |
| 94 | gl::Context *context = gl::getContext(); |
| 95 | |
| 96 | if (context) |
| 97 | { |
| 98 | gl::Program *programObject = context->getProgram(program); |
| 99 | |
| 100 | if (!programObject) |
| 101 | { |
| 102 | return error(GL_INVALID_VALUE); |
| 103 | } |
| 104 | |
| 105 | programObject->bindAttributeLocation(index, name); |
| 106 | } |
| 107 | } |
| 108 | catch(std::bad_alloc&) |
| 109 | { |
| 110 | return error(GL_OUT_OF_MEMORY); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | void __stdcall glBindBuffer(GLenum target, GLuint buffer) |
| 115 | { |
| 116 | TRACE("GLenum target = 0x%X, GLuint buffer = %d", target, buffer); |
| 117 | |
| 118 | try |
| 119 | { |
| 120 | gl::Context *context = gl::getContext(); |
| 121 | |
| 122 | if (context) |
| 123 | { |
| 124 | switch (target) |
| 125 | { |
| 126 | case GL_ARRAY_BUFFER: |
| 127 | context->bindArrayBuffer(buffer); |
| 128 | return; |
| 129 | case GL_ELEMENT_ARRAY_BUFFER: |
| 130 | context->bindElementArrayBuffer(buffer); |
| 131 | return; |
| 132 | default: |
| 133 | return error(GL_INVALID_ENUM); |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | catch(std::bad_alloc&) |
| 138 | { |
| 139 | return error(GL_OUT_OF_MEMORY); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer) |
| 144 | { |
| 145 | TRACE("GLenum target = 0x%X, GLuint framebuffer = %d", target, framebuffer); |
| 146 | |
| 147 | try |
| 148 | { |
| 149 | if (target != GL_FRAMEBUFFER) |
| 150 | { |
| 151 | return error(GL_INVALID_ENUM); |
| 152 | } |
| 153 | |
| 154 | gl::Context *context = gl::getContext(); |
| 155 | |
| 156 | if (context) |
| 157 | { |
| 158 | context->bindFramebuffer(framebuffer); |
| 159 | } |
| 160 | } |
| 161 | catch(std::bad_alloc&) |
| 162 | { |
| 163 | return error(GL_OUT_OF_MEMORY); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 168 | { |
| 169 | TRACE("GLenum target = 0x%X, GLuint renderbuffer = %d", target, renderbuffer); |
| 170 | |
| 171 | try |
| 172 | { |
| 173 | if (target != GL_RENDERBUFFER) |
| 174 | { |
| 175 | return error(GL_INVALID_ENUM); |
| 176 | } |
| 177 | |
| 178 | gl::Context *context = gl::getContext(); |
| 179 | |
| 180 | if (context) |
| 181 | { |
| 182 | context->bindRenderbuffer(renderbuffer); |
| 183 | } |
| 184 | } |
| 185 | catch(std::bad_alloc&) |
| 186 | { |
| 187 | return error(GL_OUT_OF_MEMORY); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | void __stdcall glBindTexture(GLenum target, GLuint texture) |
| 192 | { |
| 193 | TRACE("GLenum target = 0x%X, GLuint texture = %d", target, texture); |
| 194 | |
| 195 | try |
| 196 | { |
| 197 | gl::Context *context = gl::getContext(); |
| 198 | |
| 199 | if (context) |
| 200 | { |
| 201 | gl::Texture *textureObject = context->getTexture(texture); |
| 202 | |
| 203 | if (textureObject && textureObject->getTarget() != target && texture != 0) |
| 204 | { |
| 205 | return error(GL_INVALID_OPERATION); |
| 206 | } |
| 207 | |
| 208 | switch (target) |
| 209 | { |
| 210 | case GL_TEXTURE_2D: |
| 211 | context->bindTexture2D(texture); |
| 212 | return; |
| 213 | case GL_TEXTURE_CUBE_MAP: |
| 214 | context->bindTextureCubeMap(texture); |
| 215 | return; |
| 216 | default: |
| 217 | return error(GL_INVALID_ENUM); |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | catch(std::bad_alloc&) |
| 222 | { |
| 223 | return error(GL_OUT_OF_MEMORY); |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 228 | { |
| 229 | TRACE("GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f", red, green, blue, alpha); |
| 230 | |
| 231 | try |
| 232 | { |
| 233 | gl::Context* context = gl::getContext(); |
| 234 | |
| 235 | if (context) |
| 236 | { |
| 237 | context->blendColor.red = gl::clamp01(red); |
| 238 | context->blendColor.blue = gl::clamp01(blue); |
| 239 | context->blendColor.green = gl::clamp01(green); |
| 240 | context->blendColor.alpha = gl::clamp01(alpha); |
| 241 | } |
| 242 | } |
| 243 | catch(std::bad_alloc&) |
| 244 | { |
| 245 | return error(GL_OUT_OF_MEMORY); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | void __stdcall glBlendEquation(GLenum mode) |
| 250 | { |
| 251 | glBlendEquationSeparate(mode, mode); |
| 252 | } |
| 253 | |
| 254 | void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 255 | { |
| 256 | TRACE("GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X", modeRGB, modeAlpha); |
| 257 | |
| 258 | try |
| 259 | { |
| 260 | switch (modeRGB) |
| 261 | { |
| 262 | case GL_FUNC_ADD: |
| 263 | case GL_FUNC_SUBTRACT: |
| 264 | case GL_FUNC_REVERSE_SUBTRACT: |
| 265 | break; |
| 266 | default: |
| 267 | return error(GL_INVALID_ENUM); |
| 268 | } |
| 269 | |
| 270 | switch (modeAlpha) |
| 271 | { |
| 272 | case GL_FUNC_ADD: |
| 273 | case GL_FUNC_SUBTRACT: |
| 274 | case GL_FUNC_REVERSE_SUBTRACT: |
| 275 | break; |
| 276 | default: |
| 277 | return error(GL_INVALID_ENUM); |
| 278 | } |
| 279 | |
| 280 | gl::Context *context = gl::getContext(); |
| 281 | |
| 282 | if (context) |
| 283 | { |
| 284 | context->blendEquationRGB = modeRGB; |
| 285 | context->blendEquationAlpha = modeAlpha; |
| 286 | } |
| 287 | } |
| 288 | catch(std::bad_alloc&) |
| 289 | { |
| 290 | return error(GL_OUT_OF_MEMORY); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor) |
| 295 | { |
| 296 | glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor); |
| 297 | } |
| 298 | |
| 299 | void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 300 | { |
| 301 | TRACE("GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X", srcRGB, dstRGB, srcAlpha, dstAlpha); |
| 302 | |
| 303 | try |
| 304 | { |
| 305 | switch (srcRGB) |
| 306 | { |
| 307 | case GL_ZERO: |
| 308 | case GL_ONE: |
| 309 | case GL_SRC_COLOR: |
| 310 | case GL_ONE_MINUS_SRC_COLOR: |
| 311 | case GL_DST_COLOR: |
| 312 | case GL_ONE_MINUS_DST_COLOR: |
| 313 | case GL_SRC_ALPHA: |
| 314 | case GL_ONE_MINUS_SRC_ALPHA: |
| 315 | case GL_DST_ALPHA: |
| 316 | case GL_ONE_MINUS_DST_ALPHA: |
| 317 | case GL_CONSTANT_COLOR: |
| 318 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 319 | case GL_CONSTANT_ALPHA: |
| 320 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 321 | case GL_SRC_ALPHA_SATURATE: |
| 322 | break; |
| 323 | default: |
| 324 | return error(GL_INVALID_ENUM); |
| 325 | } |
| 326 | |
| 327 | switch (dstRGB) |
| 328 | { |
| 329 | case GL_ZERO: |
| 330 | case GL_ONE: |
| 331 | case GL_SRC_COLOR: |
| 332 | case GL_ONE_MINUS_SRC_COLOR: |
| 333 | case GL_DST_COLOR: |
| 334 | case GL_ONE_MINUS_DST_COLOR: |
| 335 | case GL_SRC_ALPHA: |
| 336 | case GL_ONE_MINUS_SRC_ALPHA: |
| 337 | case GL_DST_ALPHA: |
| 338 | case GL_ONE_MINUS_DST_ALPHA: |
| 339 | case GL_CONSTANT_COLOR: |
| 340 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 341 | case GL_CONSTANT_ALPHA: |
| 342 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 343 | break; |
| 344 | default: |
| 345 | return error(GL_INVALID_ENUM); |
| 346 | } |
| 347 | |
| 348 | switch (srcAlpha) |
| 349 | { |
| 350 | case GL_ZERO: |
| 351 | case GL_ONE: |
| 352 | case GL_SRC_COLOR: |
| 353 | case GL_ONE_MINUS_SRC_COLOR: |
| 354 | case GL_DST_COLOR: |
| 355 | case GL_ONE_MINUS_DST_COLOR: |
| 356 | case GL_SRC_ALPHA: |
| 357 | case GL_ONE_MINUS_SRC_ALPHA: |
| 358 | case GL_DST_ALPHA: |
| 359 | case GL_ONE_MINUS_DST_ALPHA: |
| 360 | case GL_CONSTANT_COLOR: |
| 361 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 362 | case GL_CONSTANT_ALPHA: |
| 363 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 364 | case GL_SRC_ALPHA_SATURATE: |
| 365 | break; |
| 366 | default: |
| 367 | return error(GL_INVALID_ENUM); |
| 368 | } |
| 369 | |
| 370 | switch (dstAlpha) |
| 371 | { |
| 372 | case GL_ZERO: |
| 373 | case GL_ONE: |
| 374 | case GL_SRC_COLOR: |
| 375 | case GL_ONE_MINUS_SRC_COLOR: |
| 376 | case GL_DST_COLOR: |
| 377 | case GL_ONE_MINUS_DST_COLOR: |
| 378 | case GL_SRC_ALPHA: |
| 379 | case GL_ONE_MINUS_SRC_ALPHA: |
| 380 | case GL_DST_ALPHA: |
| 381 | case GL_ONE_MINUS_DST_ALPHA: |
| 382 | case GL_CONSTANT_COLOR: |
| 383 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 384 | case GL_CONSTANT_ALPHA: |
| 385 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 386 | break; |
| 387 | default: |
| 388 | return error(GL_INVALID_ENUM); |
| 389 | } |
| 390 | |
| 391 | if ((srcRGB == GL_CONSTANT_COLOR && dstRGB == GL_CONSTANT_ALPHA) || |
| 392 | (srcRGB == GL_CONSTANT_ALPHA && dstRGB == GL_CONSTANT_COLOR)) |
| 393 | { |
| 394 | UNIMPLEMENTED(); |
| 395 | } |
| 396 | |
| 397 | gl::Context *context = gl::getContext(); |
| 398 | |
| 399 | if (context) |
| 400 | { |
| 401 | context->sourceBlendRGB = srcRGB; |
| 402 | context->sourceBlendAlpha = srcAlpha; |
| 403 | context->destBlendRGB = dstRGB; |
| 404 | context->destBlendAlpha = dstAlpha; |
| 405 | } |
| 406 | } |
| 407 | catch(std::bad_alloc&) |
| 408 | { |
| 409 | return error(GL_OUT_OF_MEMORY); |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | void __stdcall glBufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) |
| 414 | { |
| 415 | TRACE("GLenum target = 0x%X, GLsizeiptr size = %d, const void* data = 0x%0.8p, GLenum usage = %d", target, size, data, usage); |
| 416 | |
| 417 | try |
| 418 | { |
| 419 | if (size < 0) |
| 420 | { |
| 421 | return error(GL_INVALID_VALUE); |
| 422 | } |
| 423 | |
| 424 | switch (usage) |
| 425 | { |
| 426 | case GL_STREAM_DRAW: |
| 427 | case GL_STATIC_DRAW: |
| 428 | case GL_DYNAMIC_DRAW: |
| 429 | break; |
| 430 | default: |
| 431 | return error(GL_INVALID_ENUM); |
| 432 | } |
| 433 | |
| 434 | gl::Context *context = gl::getContext(); |
| 435 | |
| 436 | if (context) |
| 437 | { |
| 438 | gl::Buffer *buffer; |
| 439 | |
| 440 | switch (target) |
| 441 | { |
| 442 | case GL_ARRAY_BUFFER: |
| 443 | buffer = context->getArrayBuffer(); |
| 444 | break; |
| 445 | case GL_ELEMENT_ARRAY_BUFFER: |
| 446 | buffer = context->getElementArrayBuffer(); |
| 447 | break; |
| 448 | default: |
| 449 | return error(GL_INVALID_ENUM); |
| 450 | } |
| 451 | |
| 452 | if (!buffer) |
| 453 | { |
| 454 | return error(GL_INVALID_OPERATION); |
| 455 | } |
| 456 | |
| 457 | buffer->storeData(size, data); |
| 458 | } |
| 459 | } |
| 460 | catch(std::bad_alloc&) |
| 461 | { |
| 462 | return error(GL_OUT_OF_MEMORY); |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) |
| 467 | { |
| 468 | TRACE("GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const void* data = 0x%0.8p", target, offset, size, data); |
| 469 | |
| 470 | try |
| 471 | { |
| 472 | if (size < 0) |
| 473 | { |
| 474 | return error(GL_INVALID_VALUE); |
| 475 | } |
| 476 | |
| 477 | UNIMPLEMENTED(); // FIXME |
| 478 | } |
| 479 | catch(std::bad_alloc&) |
| 480 | { |
| 481 | return error(GL_OUT_OF_MEMORY); |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | GLenum __stdcall glCheckFramebufferStatus(GLenum target) |
| 486 | { |
| 487 | TRACE("GLenum target = 0x%X", target); |
| 488 | |
| 489 | try |
| 490 | { |
| 491 | if (target != GL_FRAMEBUFFER) |
| 492 | { |
| 493 | return error(GL_INVALID_ENUM, 0); |
| 494 | } |
| 495 | |
| 496 | gl::Context *context = gl::getContext(); |
| 497 | |
| 498 | if (context) |
| 499 | { |
| 500 | gl::Framebuffer *framebuffer = context->getFramebuffer(); |
| 501 | |
| 502 | return framebuffer->completeness(); |
| 503 | } |
| 504 | } |
| 505 | catch(std::bad_alloc&) |
| 506 | { |
| 507 | return error(GL_OUT_OF_MEMORY, 0); |
| 508 | } |
| 509 | |
| 510 | return 0; |
| 511 | } |
| 512 | |
| 513 | void __stdcall glClear(GLbitfield mask) |
| 514 | { |
| 515 | TRACE("GLbitfield mask = %X", mask); |
| 516 | |
| 517 | try |
| 518 | { |
| 519 | gl::Context *context = gl::getContext(); |
| 520 | |
| 521 | if (context) |
| 522 | { |
| 523 | context->clear(mask); |
| 524 | } |
| 525 | } |
| 526 | catch(std::bad_alloc&) |
| 527 | { |
| 528 | return error(GL_OUT_OF_MEMORY); |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 533 | { |
| 534 | TRACE("GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f", red, green, blue, alpha); |
| 535 | |
| 536 | try |
| 537 | { |
| 538 | gl::Context *context = gl::getContext(); |
| 539 | |
| 540 | if (context) |
| 541 | { |
| 542 | context->setClearColor(red, green, blue, alpha); |
| 543 | } |
| 544 | } |
| 545 | catch(std::bad_alloc&) |
| 546 | { |
| 547 | return error(GL_OUT_OF_MEMORY); |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | void __stdcall glClearDepthf(GLclampf depth) |
| 552 | { |
| 553 | TRACE("GLclampf depth = %f", depth); |
| 554 | |
| 555 | try |
| 556 | { |
| 557 | gl::Context *context = gl::getContext(); |
| 558 | |
| 559 | if (context) |
| 560 | { |
| 561 | context->setClearDepth(depth); |
| 562 | } |
| 563 | } |
| 564 | catch(std::bad_alloc&) |
| 565 | { |
| 566 | return error(GL_OUT_OF_MEMORY); |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | void __stdcall glClearStencil(GLint s) |
| 571 | { |
| 572 | TRACE("GLint s = %d", s); |
| 573 | |
| 574 | try |
| 575 | { |
| 576 | gl::Context *context = gl::getContext(); |
| 577 | |
| 578 | if (context) |
| 579 | { |
| 580 | context->setClearStencil(s); |
| 581 | } |
| 582 | } |
| 583 | catch(std::bad_alloc&) |
| 584 | { |
| 585 | return error(GL_OUT_OF_MEMORY); |
| 586 | } |
| 587 | } |
| 588 | |
| 589 | void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 590 | { |
| 591 | TRACE("GLboolean red = %d, GLboolean green = %d, GLboolean blue = %d, GLboolean alpha = %d", red, green, blue, alpha); |
| 592 | |
| 593 | try |
| 594 | { |
| 595 | gl::Context *context = gl::getContext(); |
| 596 | |
| 597 | if (context) |
| 598 | { |
| 599 | context->colorMaskRed = red != GL_FALSE; |
| 600 | context->colorMaskGreen = green != GL_FALSE; |
| 601 | context->colorMaskBlue = blue != GL_FALSE; |
| 602 | context->colorMaskAlpha = alpha != GL_FALSE; |
| 603 | } |
| 604 | } |
| 605 | catch(std::bad_alloc&) |
| 606 | { |
| 607 | return error(GL_OUT_OF_MEMORY); |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | void __stdcall glCompileShader(GLuint shader) |
| 612 | { |
| 613 | TRACE("GLuint shader = %d", shader); |
| 614 | |
| 615 | try |
| 616 | { |
| 617 | gl::Context *context = gl::getContext(); |
| 618 | |
| 619 | if (context) |
| 620 | { |
| 621 | gl::Shader *shaderObject = context->getShader(shader); |
| 622 | |
| 623 | if (!shaderObject) |
| 624 | { |
| 625 | return error(GL_INVALID_VALUE); |
| 626 | } |
| 627 | |
| 628 | shaderObject->compile(); |
| 629 | } |
| 630 | } |
| 631 | catch(std::bad_alloc&) |
| 632 | { |
| 633 | return error(GL_OUT_OF_MEMORY); |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) |
| 638 | { |
| 639 | TRACE("GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const void* data = 0x%0.8p", |
| 640 | target, level, internalformat, width, height, border, imageSize, data); |
| 641 | |
| 642 | try |
| 643 | { |
| 644 | if (width < 0 || height < 0 || imageSize < 0) |
| 645 | { |
| 646 | return error(GL_INVALID_VALUE); |
| 647 | } |
| 648 | |
| 649 | UNIMPLEMENTED(); // FIXME |
| 650 | } |
| 651 | catch(std::bad_alloc&) |
| 652 | { |
| 653 | return error(GL_OUT_OF_MEMORY); |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) |
| 658 | { |
| 659 | TRACE("GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLsizei imageSize = %d, const void* data = 0x%0.8p", |
| 660 | target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 661 | |
| 662 | try |
| 663 | { |
| 664 | if (width < 0 || height < 0 || imageSize < 0) |
| 665 | { |
| 666 | return error(GL_INVALID_VALUE); |
| 667 | } |
| 668 | |
| 669 | UNIMPLEMENTED(); // FIXME |
| 670 | } |
| 671 | catch(std::bad_alloc&) |
| 672 | { |
| 673 | return error(GL_OUT_OF_MEMORY); |
| 674 | } |
| 675 | } |
| 676 | |
| 677 | void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) |
| 678 | { |
| 679 | TRACE("GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d", |
| 680 | target, level, internalformat, x, y, width, height, border); |
| 681 | |
| 682 | try |
| 683 | { |
| 684 | if (width < 0 || height < 0) |
| 685 | { |
| 686 | return error(GL_INVALID_VALUE); |
| 687 | } |
| 688 | |
| 689 | UNIMPLEMENTED(); // FIXME |
| 690 | } |
| 691 | catch(std::bad_alloc&) |
| 692 | { |
| 693 | return error(GL_OUT_OF_MEMORY); |
| 694 | } |
| 695 | } |
| 696 | |
| 697 | void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 698 | { |
| 699 | TRACE("GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d", |
| 700 | target, level, xoffset, yoffset, x, y, width, height); |
| 701 | |
| 702 | try |
| 703 | { |
| 704 | if (width < 0 || height < 0) |
| 705 | { |
| 706 | return error(GL_INVALID_VALUE); |
| 707 | } |
| 708 | |
| 709 | UNIMPLEMENTED(); // FIXME |
| 710 | } |
| 711 | catch(std::bad_alloc&) |
| 712 | { |
| 713 | return error(GL_OUT_OF_MEMORY); |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | GLuint __stdcall glCreateProgram(void) |
| 718 | { |
| 719 | TRACE(""); |
| 720 | |
| 721 | try |
| 722 | { |
| 723 | gl::Context *context = gl::getContext(); |
| 724 | |
| 725 | if (context) |
| 726 | { |
| 727 | return context->createProgram(); |
| 728 | } |
| 729 | } |
| 730 | catch(std::bad_alloc&) |
| 731 | { |
| 732 | return error(GL_OUT_OF_MEMORY, 0); |
| 733 | } |
| 734 | |
| 735 | return 0; |
| 736 | } |
| 737 | |
| 738 | GLuint __stdcall glCreateShader(GLenum type) |
| 739 | { |
| 740 | TRACE("GLenum type = 0x%X", type); |
| 741 | |
| 742 | try |
| 743 | { |
| 744 | gl::Context *context = gl::getContext(); |
| 745 | |
| 746 | if (context) |
| 747 | { |
| 748 | switch (type) |
| 749 | { |
| 750 | case GL_FRAGMENT_SHADER: |
| 751 | case GL_VERTEX_SHADER: |
| 752 | return context->createShader(type); |
| 753 | default: |
| 754 | return error(GL_INVALID_ENUM, 0); |
| 755 | } |
| 756 | } |
| 757 | } |
| 758 | catch(std::bad_alloc&) |
| 759 | { |
| 760 | return error(GL_OUT_OF_MEMORY, 0); |
| 761 | } |
| 762 | |
| 763 | return 0; |
| 764 | } |
| 765 | |
| 766 | void __stdcall glCullFace(GLenum mode) |
| 767 | { |
| 768 | TRACE("GLenum mode = 0x%X", mode); |
| 769 | |
| 770 | try |
| 771 | { |
| 772 | switch (mode) |
| 773 | { |
| 774 | case GL_FRONT: |
| 775 | case GL_BACK: |
| 776 | case GL_FRONT_AND_BACK: |
| 777 | { |
| 778 | gl::Context *context = gl::getContext(); |
| 779 | |
| 780 | if (context) |
| 781 | { |
| 782 | context->cullMode = mode; |
| 783 | } |
| 784 | } |
| 785 | break; |
| 786 | default: |
| 787 | return error(GL_INVALID_ENUM); |
| 788 | } |
| 789 | } |
| 790 | catch(std::bad_alloc&) |
| 791 | { |
| 792 | return error(GL_OUT_OF_MEMORY); |
| 793 | } |
| 794 | } |
| 795 | |
| 796 | void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers) |
| 797 | { |
| 798 | TRACE("GLsizei n = %d, const GLuint* buffers = 0x%0.8p", n, buffers); |
| 799 | |
| 800 | try |
| 801 | { |
| 802 | if (n < 0) |
| 803 | { |
| 804 | return error(GL_INVALID_VALUE); |
| 805 | } |
| 806 | |
| 807 | gl::Context *context = gl::getContext(); |
| 808 | |
| 809 | if (context) |
| 810 | { |
| 811 | for (int i = 0; i < n; i++) |
| 812 | { |
| 813 | context->deleteBuffer(buffers[i]); |
| 814 | } |
| 815 | } |
| 816 | } |
| 817 | catch(std::bad_alloc&) |
| 818 | { |
| 819 | return error(GL_OUT_OF_MEMORY); |
| 820 | } |
| 821 | } |
| 822 | |
| 823 | void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) |
| 824 | { |
| 825 | TRACE("GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p", n, framebuffers); |
| 826 | |
| 827 | try |
| 828 | { |
| 829 | if (n < 0) |
| 830 | { |
| 831 | return error(GL_INVALID_VALUE); |
| 832 | } |
| 833 | |
| 834 | gl::Context *context = gl::getContext(); |
| 835 | |
| 836 | if (context) |
| 837 | { |
| 838 | for (int i = 0; i < n; i++) |
| 839 | { |
| 840 | if (framebuffers[i] != 0) |
| 841 | { |
| 842 | context->deleteFramebuffer(framebuffers[i]); |
| 843 | } |
| 844 | } |
| 845 | } |
| 846 | } |
| 847 | catch(std::bad_alloc&) |
| 848 | { |
| 849 | return error(GL_OUT_OF_MEMORY); |
| 850 | } |
| 851 | } |
| 852 | |
| 853 | void __stdcall glDeleteProgram(GLuint program) |
| 854 | { |
| 855 | TRACE("GLuint program = %d", program); |
| 856 | |
| 857 | try |
| 858 | { |
| 859 | gl::Context *context = gl::getContext(); |
| 860 | |
| 861 | if (context) |
| 862 | { |
| 863 | context->deleteProgram(program); |
| 864 | } |
| 865 | } |
| 866 | catch(std::bad_alloc&) |
| 867 | { |
| 868 | return error(GL_OUT_OF_MEMORY); |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) |
| 873 | { |
| 874 | TRACE("GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p", n, renderbuffers); |
| 875 | |
| 876 | try |
| 877 | { |
| 878 | if (n < 0) |
| 879 | { |
| 880 | return error(GL_INVALID_VALUE); |
| 881 | } |
| 882 | |
| 883 | gl::Context *context = gl::getContext(); |
| 884 | |
| 885 | if (context) |
| 886 | { |
| 887 | for(int i = 0; i < n; i++) |
| 888 | { |
| 889 | context->deleteRenderbuffer(renderbuffers[i]); |
| 890 | } |
| 891 | } |
| 892 | } |
| 893 | catch(std::bad_alloc&) |
| 894 | { |
| 895 | return error(GL_OUT_OF_MEMORY); |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | void __stdcall glDeleteShader(GLuint shader) |
| 900 | { |
| 901 | TRACE("GLuint shader = %d", shader); |
| 902 | |
| 903 | try |
| 904 | { |
| 905 | gl::Context *context = gl::getContext(); |
| 906 | |
| 907 | if (context) |
| 908 | { |
| 909 | context->deleteShader(shader); |
| 910 | } |
| 911 | } |
| 912 | catch(std::bad_alloc&) |
| 913 | { |
| 914 | return error(GL_OUT_OF_MEMORY); |
| 915 | } |
| 916 | } |
| 917 | |
| 918 | void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures) |
| 919 | { |
| 920 | TRACE("GLsizei n = %d, const GLuint* textures = 0x%0.8p", n, textures); |
| 921 | |
| 922 | try |
| 923 | { |
| 924 | if (n < 0) |
| 925 | { |
| 926 | return error(GL_INVALID_VALUE); |
| 927 | } |
| 928 | |
| 929 | gl::Context *context = gl::getContext(); |
| 930 | |
| 931 | if (context) |
| 932 | { |
| 933 | for (int i = 0; i < n; i++) |
| 934 | { |
| 935 | if (textures[i] != 0) |
| 936 | { |
| 937 | context->deleteTexture(textures[i]); |
| 938 | } |
| 939 | } |
| 940 | } |
| 941 | } |
| 942 | catch(std::bad_alloc&) |
| 943 | { |
| 944 | return error(GL_OUT_OF_MEMORY); |
| 945 | } |
| 946 | } |
| 947 | |
| 948 | void __stdcall glDepthFunc(GLenum func) |
| 949 | { |
| 950 | TRACE("GLenum func = 0x%X", func); |
| 951 | |
| 952 | try |
| 953 | { |
| 954 | switch (func) |
| 955 | { |
| 956 | case GL_NEVER: |
| 957 | case GL_ALWAYS: |
| 958 | case GL_LESS: |
| 959 | case GL_LEQUAL: |
| 960 | case GL_EQUAL: |
| 961 | case GL_GREATER: |
| 962 | case GL_GEQUAL: |
| 963 | case GL_NOTEQUAL: |
| 964 | break; |
| 965 | default: |
| 966 | return error(GL_INVALID_ENUM); |
| 967 | } |
| 968 | |
| 969 | gl::Context *context = gl::getContext(); |
| 970 | |
| 971 | if (context) |
| 972 | { |
| 973 | context->depthFunc = func; |
| 974 | } |
| 975 | } |
| 976 | catch(std::bad_alloc&) |
| 977 | { |
| 978 | return error(GL_OUT_OF_MEMORY); |
| 979 | } |
| 980 | } |
| 981 | |
| 982 | void __stdcall glDepthMask(GLboolean flag) |
| 983 | { |
| 984 | TRACE("GLboolean flag = %d", flag); |
| 985 | |
| 986 | try |
| 987 | { |
| 988 | gl::Context *context = gl::getContext(); |
| 989 | |
| 990 | if (context) |
| 991 | { |
| 992 | context->depthMask = flag != GL_FALSE; |
| 993 | } |
| 994 | } |
| 995 | catch(std::bad_alloc&) |
| 996 | { |
| 997 | return error(GL_OUT_OF_MEMORY); |
| 998 | } |
| 999 | } |
| 1000 | |
| 1001 | void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar) |
| 1002 | { |
| 1003 | TRACE("GLclampf zNear = %f, GLclampf zFar = %f", zNear, zFar); |
| 1004 | |
| 1005 | try |
| 1006 | { |
| 1007 | gl::Context *context = gl::getContext(); |
| 1008 | |
| 1009 | if (context) |
| 1010 | { |
| 1011 | context->zNear = zNear; |
| 1012 | context->zFar = zFar; |
| 1013 | } |
| 1014 | } |
| 1015 | catch(std::bad_alloc&) |
| 1016 | { |
| 1017 | return error(GL_OUT_OF_MEMORY); |
| 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | void __stdcall glDetachShader(GLuint program, GLuint shader) |
| 1022 | { |
| 1023 | TRACE("GLuint program = %d, GLuint shader = %d", program, shader); |
| 1024 | |
| 1025 | try |
| 1026 | { |
| 1027 | gl::Context *context = gl::getContext(); |
| 1028 | |
| 1029 | if (context) |
| 1030 | { |
| 1031 | gl::Program *programObject = context->getProgram(program); |
| 1032 | gl::Shader *shaderObject = context->getShader(shader); |
| 1033 | |
| 1034 | if (!programObject || !shaderObject) |
| 1035 | { |
| 1036 | return error(GL_INVALID_VALUE); |
| 1037 | } |
| 1038 | |
| 1039 | if (!programObject->detachShader(shaderObject)) |
| 1040 | { |
| 1041 | return error(GL_INVALID_OPERATION); |
| 1042 | } |
| 1043 | |
| 1044 | if (shaderObject->isDeletable()) |
| 1045 | { |
| 1046 | context->deleteShader(shader); |
| 1047 | } |
| 1048 | } |
| 1049 | } |
| 1050 | catch(std::bad_alloc&) |
| 1051 | { |
| 1052 | return error(GL_OUT_OF_MEMORY); |
| 1053 | } |
| 1054 | } |
| 1055 | |
| 1056 | void __stdcall glDisable(GLenum cap) |
| 1057 | { |
| 1058 | TRACE("GLenum cap = 0x%X", cap); |
| 1059 | |
| 1060 | try |
| 1061 | { |
| 1062 | gl::Context *context = gl::getContext(); |
| 1063 | |
| 1064 | if (context) |
| 1065 | { |
| 1066 | switch (cap) |
| 1067 | { |
| 1068 | case GL_CULL_FACE: context->cullFace = false; break; |
| 1069 | case GL_POLYGON_OFFSET_FILL: context->polygonOffsetFill = false; break; |
| 1070 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->sampleAlphaToCoverage = false; break; |
| 1071 | case GL_SAMPLE_COVERAGE: context->sampleCoverage = false; break; |
| 1072 | case GL_SCISSOR_TEST: context->scissorTest = false; break; |
| 1073 | case GL_STENCIL_TEST: context->stencilTest = false; break; |
| 1074 | case GL_DEPTH_TEST: context->depthTest = false; break; |
| 1075 | case GL_BLEND: context->blend = false; break; |
| 1076 | case GL_DITHER: context->dither = false; break; |
| 1077 | default: |
| 1078 | return error(GL_INVALID_ENUM); |
| 1079 | } |
| 1080 | } |
| 1081 | } |
| 1082 | catch(std::bad_alloc&) |
| 1083 | { |
| 1084 | return error(GL_OUT_OF_MEMORY); |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | void __stdcall glDisableVertexAttribArray(GLuint index) |
| 1089 | { |
| 1090 | TRACE("GLuint index = %d", index); |
| 1091 | |
| 1092 | try |
| 1093 | { |
| 1094 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 1095 | { |
| 1096 | return error(GL_INVALID_VALUE); |
| 1097 | } |
| 1098 | |
| 1099 | gl::Context *context = gl::getContext(); |
| 1100 | |
| 1101 | if (context) |
| 1102 | { |
| 1103 | context->vertexAttribute[index].enabled = false; |
| 1104 | } |
| 1105 | } |
| 1106 | catch(std::bad_alloc&) |
| 1107 | { |
| 1108 | return error(GL_OUT_OF_MEMORY); |
| 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count) |
| 1113 | { |
| 1114 | TRACE("GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d", mode, first, count); |
| 1115 | |
| 1116 | try |
| 1117 | { |
| 1118 | if (count < 0 || first < 0) |
| 1119 | { |
| 1120 | return error(GL_INVALID_VALUE); |
| 1121 | } |
| 1122 | |
| 1123 | gl::Context *context = gl::getContext(); |
| 1124 | |
| 1125 | if (context) |
| 1126 | { |
| 1127 | context->drawArrays(mode, first, count); |
| 1128 | } |
| 1129 | } |
| 1130 | catch(std::bad_alloc&) |
| 1131 | { |
| 1132 | return error(GL_OUT_OF_MEMORY); |
| 1133 | } |
| 1134 | } |
| 1135 | |
| 1136 | void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) |
| 1137 | { |
| 1138 | TRACE("GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const void* indices = 0x%0.8p", mode, count, type, indices); |
| 1139 | |
| 1140 | try |
| 1141 | { |
| 1142 | if (count < 0) |
| 1143 | { |
| 1144 | return error(GL_INVALID_VALUE); |
| 1145 | } |
| 1146 | |
| 1147 | switch (type) |
| 1148 | { |
| 1149 | case GL_UNSIGNED_BYTE: |
| 1150 | UNIMPLEMENTED(); // FIXME |
| 1151 | case GL_UNSIGNED_SHORT: |
| 1152 | break; |
| 1153 | default: |
| 1154 | return error(GL_INVALID_ENUM); |
| 1155 | } |
| 1156 | |
| 1157 | gl::Context *context = gl::getContext(); |
| 1158 | |
| 1159 | if (context) |
| 1160 | { |
| 1161 | context->drawElements(mode, count, type, indices); |
| 1162 | } |
| 1163 | } |
| 1164 | catch(std::bad_alloc&) |
| 1165 | { |
| 1166 | return error(GL_OUT_OF_MEMORY); |
| 1167 | } |
| 1168 | } |
| 1169 | |
| 1170 | void __stdcall glEnable(GLenum cap) |
| 1171 | { |
| 1172 | TRACE("GLenum cap = 0x%X", cap); |
| 1173 | |
| 1174 | try |
| 1175 | { |
| 1176 | gl::Context *context = gl::getContext(); |
| 1177 | |
| 1178 | if (context) |
| 1179 | { |
| 1180 | switch (cap) |
| 1181 | { |
| 1182 | case GL_CULL_FACE: context->cullFace = true; break; |
| 1183 | case GL_POLYGON_OFFSET_FILL: context->polygonOffsetFill = true; break; |
| 1184 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->sampleAlphaToCoverage = true; break; |
| 1185 | case GL_SAMPLE_COVERAGE: context->sampleCoverage = true; break; |
| 1186 | case GL_SCISSOR_TEST: context->scissorTest = true; break; |
| 1187 | case GL_STENCIL_TEST: context->stencilTest = true; break; |
| 1188 | case GL_DEPTH_TEST: context->depthTest = true; break; |
| 1189 | case GL_BLEND: context->blend = true; break; |
| 1190 | case GL_DITHER: context->dither = true; break; |
| 1191 | default: |
| 1192 | return error(GL_INVALID_ENUM); |
| 1193 | } |
| 1194 | } |
| 1195 | } |
| 1196 | catch(std::bad_alloc&) |
| 1197 | { |
| 1198 | return error(GL_OUT_OF_MEMORY); |
| 1199 | } |
| 1200 | } |
| 1201 | |
| 1202 | void __stdcall glEnableVertexAttribArray(GLuint index) |
| 1203 | { |
| 1204 | TRACE("GLuint index = %d", index); |
| 1205 | |
| 1206 | try |
| 1207 | { |
| 1208 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 1209 | { |
| 1210 | return error(GL_INVALID_VALUE); |
| 1211 | } |
| 1212 | |
| 1213 | gl::Context *context = gl::getContext(); |
| 1214 | |
| 1215 | if (context) |
| 1216 | { |
| 1217 | context->vertexAttribute[index].enabled = true; |
| 1218 | } |
| 1219 | } |
| 1220 | catch(std::bad_alloc&) |
| 1221 | { |
| 1222 | return error(GL_OUT_OF_MEMORY); |
| 1223 | } |
| 1224 | } |
| 1225 | |
| 1226 | void __stdcall glFinish(void) |
| 1227 | { |
| 1228 | TRACE(""); |
| 1229 | |
| 1230 | try |
| 1231 | { |
| 1232 | gl::Context *context = gl::getContext(); |
| 1233 | |
| 1234 | if (context) |
| 1235 | { |
| 1236 | context->finish(); |
| 1237 | } |
| 1238 | } |
| 1239 | catch(std::bad_alloc&) |
| 1240 | { |
| 1241 | return error(GL_OUT_OF_MEMORY); |
| 1242 | } |
| 1243 | } |
| 1244 | |
| 1245 | void __stdcall glFlush(void) |
| 1246 | { |
| 1247 | TRACE(""); |
| 1248 | |
| 1249 | try |
| 1250 | { |
| 1251 | gl::Context *context = gl::getContext(); |
| 1252 | |
| 1253 | if (context) |
| 1254 | { |
| 1255 | context->flush(); |
| 1256 | } |
| 1257 | } |
| 1258 | catch(std::bad_alloc&) |
| 1259 | { |
| 1260 | return error(GL_OUT_OF_MEMORY); |
| 1261 | } |
| 1262 | } |
| 1263 | |
| 1264 | void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) |
| 1265 | { |
| 1266 | TRACE("GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, GLuint renderbuffer = %d", target, attachment, renderbuffertarget, renderbuffer); |
| 1267 | |
| 1268 | try |
| 1269 | { |
| 1270 | if (target != GL_FRAMEBUFFER || renderbuffertarget != GL_RENDERBUFFER) |
| 1271 | { |
| 1272 | return error(GL_INVALID_ENUM); |
| 1273 | } |
| 1274 | |
| 1275 | gl::Context *context = gl::getContext(); |
| 1276 | |
| 1277 | if (context) |
| 1278 | { |
| 1279 | gl::Framebuffer *framebuffer = context->getFramebuffer(); |
| 1280 | |
| 1281 | if (context->framebuffer == 0 || !framebuffer) |
| 1282 | { |
| 1283 | return error(GL_INVALID_OPERATION); |
| 1284 | } |
| 1285 | |
| 1286 | switch (attachment) |
| 1287 | { |
| 1288 | case GL_COLOR_ATTACHMENT0: |
| 1289 | framebuffer->setColorbuffer(GL_RENDERBUFFER, renderbuffer); |
| 1290 | break; |
| 1291 | case GL_DEPTH_ATTACHMENT: |
| 1292 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer); |
| 1293 | break; |
| 1294 | case GL_STENCIL_ATTACHMENT: |
| 1295 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer); |
| 1296 | break; |
| 1297 | default: |
| 1298 | return error(GL_INVALID_ENUM); |
| 1299 | } |
| 1300 | } |
| 1301 | } |
| 1302 | catch(std::bad_alloc&) |
| 1303 | { |
| 1304 | return error(GL_OUT_OF_MEMORY); |
| 1305 | } |
| 1306 | } |
| 1307 | |
| 1308 | void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) |
| 1309 | { |
| 1310 | TRACE("GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, GLuint texture = %d, GLint level = %d", target, attachment, textarget, texture, level); |
| 1311 | |
| 1312 | try |
| 1313 | { |
| 1314 | if (target != GL_FRAMEBUFFER) |
| 1315 | { |
| 1316 | return error(GL_INVALID_ENUM); |
| 1317 | } |
| 1318 | |
| 1319 | switch (attachment) |
| 1320 | { |
| 1321 | case GL_COLOR_ATTACHMENT0: |
| 1322 | break; |
| 1323 | default: |
| 1324 | return error(GL_INVALID_ENUM); |
| 1325 | } |
| 1326 | |
| 1327 | gl::Context *context = gl::getContext(); |
| 1328 | |
| 1329 | if (context) |
| 1330 | { |
| 1331 | if (texture) |
| 1332 | { |
| 1333 | switch (textarget) |
| 1334 | { |
| 1335 | case GL_TEXTURE_2D: |
| 1336 | if (!context->getTexture2D()) |
| 1337 | { |
| 1338 | return error(GL_INVALID_OPERATION); |
| 1339 | } |
| 1340 | break; |
| 1341 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 1342 | UNIMPLEMENTED(); // FIXME |
| 1343 | break; |
| 1344 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 1345 | UNIMPLEMENTED(); // FIXME |
| 1346 | break; |
| 1347 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 1348 | UNIMPLEMENTED(); // FIXME |
| 1349 | break; |
| 1350 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 1351 | UNIMPLEMENTED(); // FIXME |
| 1352 | break; |
| 1353 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 1354 | UNIMPLEMENTED(); // FIXME |
| 1355 | break; |
| 1356 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 1357 | UNIMPLEMENTED(); // FIXME |
| 1358 | break; |
| 1359 | default: |
| 1360 | return error(GL_INVALID_ENUM); |
| 1361 | } |
| 1362 | |
| 1363 | if (level != 0) |
| 1364 | { |
| 1365 | return error(GL_INVALID_VALUE); |
| 1366 | } |
| 1367 | } |
| 1368 | |
| 1369 | gl::Framebuffer *framebuffer = context->getFramebuffer(); |
| 1370 | |
| 1371 | if (context->framebuffer == 0 || !framebuffer) |
| 1372 | { |
| 1373 | return error(GL_INVALID_OPERATION); |
| 1374 | } |
| 1375 | |
| 1376 | framebuffer->setColorbuffer(GL_TEXTURE, texture); |
| 1377 | } |
| 1378 | } |
| 1379 | catch(std::bad_alloc&) |
| 1380 | { |
| 1381 | return error(GL_OUT_OF_MEMORY); |
| 1382 | } |
| 1383 | } |
| 1384 | |
| 1385 | void __stdcall glFrontFace(GLenum mode) |
| 1386 | { |
| 1387 | TRACE("GLenum mode = 0x%X", mode); |
| 1388 | |
| 1389 | try |
| 1390 | { |
| 1391 | switch (mode) |
| 1392 | { |
| 1393 | case GL_CW: |
| 1394 | case GL_CCW: |
| 1395 | { |
| 1396 | gl::Context *context = gl::getContext(); |
| 1397 | |
| 1398 | if (context) |
| 1399 | { |
| 1400 | context->frontFace = mode; |
| 1401 | } |
| 1402 | } |
| 1403 | break; |
| 1404 | default: |
| 1405 | return error(GL_INVALID_ENUM); |
| 1406 | } |
| 1407 | } |
| 1408 | catch(std::bad_alloc&) |
| 1409 | { |
| 1410 | return error(GL_OUT_OF_MEMORY); |
| 1411 | } |
| 1412 | } |
| 1413 | |
| 1414 | void __stdcall glGenBuffers(GLsizei n, GLuint* buffers) |
| 1415 | { |
| 1416 | TRACE("GLsizei n = %d, GLuint* buffers = 0x%0.8p", n, buffers); |
| 1417 | |
| 1418 | try |
| 1419 | { |
| 1420 | if (n < 0) |
| 1421 | { |
| 1422 | return error(GL_INVALID_VALUE); |
| 1423 | } |
| 1424 | |
| 1425 | gl::Context *context = gl::getContext(); |
| 1426 | |
| 1427 | if (context) |
| 1428 | { |
| 1429 | for (int i = 0; i < n; i++) |
| 1430 | { |
| 1431 | buffers[i] = context->createBuffer(); |
| 1432 | } |
| 1433 | } |
| 1434 | } |
| 1435 | catch(std::bad_alloc&) |
| 1436 | { |
| 1437 | return error(GL_OUT_OF_MEMORY); |
| 1438 | } |
| 1439 | } |
| 1440 | |
| 1441 | void __stdcall glGenerateMipmap(GLenum target) |
| 1442 | { |
| 1443 | TRACE("GLenum target = 0x%X", target); |
| 1444 | |
| 1445 | try |
| 1446 | { |
| 1447 | UNIMPLEMENTED(); // FIXME |
| 1448 | } |
| 1449 | catch(std::bad_alloc&) |
| 1450 | { |
| 1451 | return error(GL_OUT_OF_MEMORY); |
| 1452 | } |
| 1453 | } |
| 1454 | |
| 1455 | void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers) |
| 1456 | { |
| 1457 | TRACE("GLsizei n = %d, GLuint* framebuffers = 0x%0.8p", n, framebuffers); |
| 1458 | |
| 1459 | try |
| 1460 | { |
| 1461 | if (n < 0) |
| 1462 | { |
| 1463 | return error(GL_INVALID_VALUE); |
| 1464 | } |
| 1465 | |
| 1466 | gl::Context *context = gl::getContext(); |
| 1467 | |
| 1468 | if (context) |
| 1469 | { |
| 1470 | for (int i = 0; i < n; i++) |
| 1471 | { |
| 1472 | framebuffers[i] = context->createFramebuffer(); |
| 1473 | } |
| 1474 | } |
| 1475 | } |
| 1476 | catch(std::bad_alloc&) |
| 1477 | { |
| 1478 | return error(GL_OUT_OF_MEMORY); |
| 1479 | } |
| 1480 | } |
| 1481 | |
| 1482 | void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) |
| 1483 | { |
| 1484 | TRACE("GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p", n, renderbuffers); |
| 1485 | |
| 1486 | try |
| 1487 | { |
| 1488 | if (n < 0) |
| 1489 | { |
| 1490 | return error(GL_INVALID_VALUE); |
| 1491 | } |
| 1492 | |
| 1493 | gl::Context *context = gl::getContext(); |
| 1494 | |
| 1495 | if (context) |
| 1496 | { |
| 1497 | for (int i = 0; i < n; i++) |
| 1498 | { |
| 1499 | renderbuffers[i] = context->createRenderbuffer(); |
| 1500 | } |
| 1501 | } |
| 1502 | } |
| 1503 | catch(std::bad_alloc&) |
| 1504 | { |
| 1505 | return error(GL_OUT_OF_MEMORY); |
| 1506 | } |
| 1507 | } |
| 1508 | |
| 1509 | void __stdcall glGenTextures(GLsizei n, GLuint* textures) |
| 1510 | { |
| 1511 | TRACE("GLsizei n = %d, GLuint* textures = 0x%0.8p", n, textures); |
| 1512 | |
| 1513 | try |
| 1514 | { |
| 1515 | if (n < 0) |
| 1516 | { |
| 1517 | return error(GL_INVALID_VALUE); |
| 1518 | } |
| 1519 | |
| 1520 | gl::Context *context = gl::getContext(); |
| 1521 | |
| 1522 | if (context) |
| 1523 | { |
| 1524 | for (int i = 0; i < n; i++) |
| 1525 | { |
| 1526 | textures[i] = context->createTexture(); |
| 1527 | } |
| 1528 | } |
| 1529 | } |
| 1530 | catch(std::bad_alloc&) |
| 1531 | { |
| 1532 | return error(GL_OUT_OF_MEMORY); |
| 1533 | } |
| 1534 | } |
| 1535 | |
| 1536 | void __stdcall glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) |
| 1537 | { |
| 1538 | TRACE("GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLint* size = 0x%0.8p, GLenum* type = %0.8p, char* name = %0.8p", |
| 1539 | program, index, bufsize, length, size, type, name); |
| 1540 | |
| 1541 | try |
| 1542 | { |
| 1543 | if (bufsize < 0) |
| 1544 | { |
| 1545 | return error(GL_INVALID_VALUE); |
| 1546 | } |
| 1547 | |
| 1548 | UNIMPLEMENTED(); // FIXME |
| 1549 | } |
| 1550 | catch(std::bad_alloc&) |
| 1551 | { |
| 1552 | return error(GL_OUT_OF_MEMORY); |
| 1553 | } |
| 1554 | } |
| 1555 | |
| 1556 | void __stdcall glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) |
| 1557 | { |
| 1558 | TRACE("GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLint* size = 0x%0.8p, GLenum* type = 0x%0.8p, char* name = 0x%0.8p", |
| 1559 | program, index, bufsize, length, size, type, name); |
| 1560 | |
| 1561 | try |
| 1562 | { |
| 1563 | if (bufsize < 0) |
| 1564 | { |
| 1565 | return error(GL_INVALID_VALUE); |
| 1566 | } |
| 1567 | |
| 1568 | UNIMPLEMENTED(); // FIXME |
| 1569 | } |
| 1570 | catch(std::bad_alloc&) |
| 1571 | { |
| 1572 | return error(GL_OUT_OF_MEMORY); |
| 1573 | } |
| 1574 | } |
| 1575 | |
| 1576 | void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) |
| 1577 | { |
| 1578 | TRACE("GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = 0x%0.8p, GLuint* shaders = 0x%0.8p", program, maxcount, count, shaders); |
| 1579 | |
| 1580 | try |
| 1581 | { |
| 1582 | if (maxcount < 0) |
| 1583 | { |
| 1584 | return error(GL_INVALID_VALUE); |
| 1585 | } |
| 1586 | |
| 1587 | UNIMPLEMENTED(); // FIXME |
| 1588 | } |
| 1589 | catch(std::bad_alloc&) |
| 1590 | { |
| 1591 | return error(GL_OUT_OF_MEMORY); |
| 1592 | } |
| 1593 | } |
| 1594 | |
| 1595 | int __stdcall glGetAttribLocation(GLuint program, const char* name) |
| 1596 | { |
| 1597 | TRACE("GLuint program = %d, const char* name = %s", program, name); |
| 1598 | |
| 1599 | try |
| 1600 | { |
| 1601 | gl::Context *context = gl::getContext(); |
| 1602 | |
| 1603 | if (context) |
| 1604 | { |
| 1605 | gl::Program *programObject = context->getProgram(program); |
| 1606 | |
| 1607 | if (!programObject) |
| 1608 | { |
| 1609 | return error(GL_INVALID_VALUE, -1); |
| 1610 | } |
| 1611 | |
| 1612 | return programObject->getAttributeLocation(name); |
| 1613 | } |
| 1614 | } |
| 1615 | catch(std::bad_alloc&) |
| 1616 | { |
| 1617 | return error(GL_OUT_OF_MEMORY, -1); |
| 1618 | } |
| 1619 | |
| 1620 | return -1; |
| 1621 | } |
| 1622 | |
| 1623 | void __stdcall glGetBooleanv(GLenum pname, GLboolean* params) |
| 1624 | { |
| 1625 | TRACE("GLenum pname = 0x%X, GLboolean* params = 0x%0.8p", pname, params); |
| 1626 | |
| 1627 | try |
| 1628 | { |
| 1629 | switch (pname) |
| 1630 | { |
| 1631 | case GL_SHADER_COMPILER: *params = GL_TRUE; break; |
| 1632 | default: |
| 1633 | UNIMPLEMENTED(); // FIXME |
| 1634 | return error(GL_INVALID_ENUM); |
| 1635 | } |
| 1636 | } |
| 1637 | catch(std::bad_alloc&) |
| 1638 | { |
| 1639 | return error(GL_OUT_OF_MEMORY); |
| 1640 | } |
| 1641 | } |
| 1642 | |
| 1643 | void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 1644 | { |
| 1645 | TRACE("GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p", target, pname, params); |
| 1646 | |
| 1647 | try |
| 1648 | { |
| 1649 | UNIMPLEMENTED(); // FIXME |
| 1650 | } |
| 1651 | catch(std::bad_alloc&) |
| 1652 | { |
| 1653 | return error(GL_OUT_OF_MEMORY); |
| 1654 | } |
| 1655 | } |
| 1656 | |
| 1657 | GLenum __stdcall glGetError(void) |
| 1658 | { |
| 1659 | TRACE(""); |
| 1660 | |
| 1661 | gl::Context *context = gl::getContext(); |
| 1662 | |
| 1663 | if (context) |
| 1664 | { |
| 1665 | return context->getError(); |
| 1666 | } |
| 1667 | |
| 1668 | return GL_NO_ERROR; |
| 1669 | } |
| 1670 | |
| 1671 | void __stdcall glGetFloatv(GLenum pname, GLfloat* params) |
| 1672 | { |
| 1673 | TRACE("GLenum pname = 0x%X, GLfloat* params = 0x%0.8p", pname, params); |
| 1674 | |
| 1675 | try |
| 1676 | { |
| 1677 | UNIMPLEMENTED(); // FIXME |
| 1678 | } |
| 1679 | catch(std::bad_alloc&) |
| 1680 | { |
| 1681 | return error(GL_OUT_OF_MEMORY); |
| 1682 | } |
| 1683 | } |
| 1684 | |
| 1685 | void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) |
| 1686 | { |
| 1687 | TRACE("GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p", target, attachment, pname, params); |
| 1688 | |
| 1689 | try |
| 1690 | { |
| 1691 | gl::Context *context = gl::getContext(); |
| 1692 | |
| 1693 | if (context) |
| 1694 | { |
| 1695 | if (context->framebuffer == 0) |
| 1696 | { |
| 1697 | return error(GL_INVALID_OPERATION); |
| 1698 | } |
| 1699 | |
| 1700 | UNIMPLEMENTED(); // FIXME |
| 1701 | } |
| 1702 | } |
| 1703 | catch(std::bad_alloc&) |
| 1704 | { |
| 1705 | return error(GL_OUT_OF_MEMORY); |
| 1706 | } |
| 1707 | } |
| 1708 | |
| 1709 | void __stdcall glGetIntegerv(GLenum pname, GLint* params) |
| 1710 | { |
| 1711 | TRACE("GLenum pname = 0x%X, GLint* params = 0x%0.8p", pname, params); |
| 1712 | |
| 1713 | try |
| 1714 | { |
| 1715 | gl::Context *context = gl::getContext(); |
| 1716 | |
| 1717 | if (context) |
| 1718 | { |
| 1719 | switch (pname) |
| 1720 | { |
| 1721 | case GL_MAX_VERTEX_ATTRIBS: *params = gl::MAX_VERTEX_ATTRIBS; break; |
| 1722 | case GL_MAX_VERTEX_UNIFORM_VECTORS: *params = gl::MAX_VERTEX_UNIFORM_VECTORS; break; |
| 1723 | case GL_MAX_VARYING_VECTORS: *params = gl::MAX_VARYING_VECTORS; break; |
| 1724 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: *params = gl::MAX_COMBINED_TEXTURE_IMAGE_UNITS; break; |
| 1725 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: *params = gl::MAX_VERTEX_TEXTURE_IMAGE_UNITS; break; |
| 1726 | case GL_MAX_TEXTURE_IMAGE_UNITS: *params = gl::MAX_TEXTURE_IMAGE_UNITS; break; |
| 1727 | case GL_MAX_FRAGMENT_UNIFORM_VECTORS: *params = gl::MAX_FRAGMENT_UNIFORM_VECTORS; break; |
| 1728 | case GL_MAX_RENDERBUFFER_SIZE: *params = gl::MAX_RENDERBUFFER_SIZE; break; |
| 1729 | case GL_NUM_SHADER_BINARY_FORMATS: *params = 0; break; |
| 1730 | case GL_ARRAY_BUFFER_BINDING: *params = context->arrayBuffer; break; |
| 1731 | case GL_FRAMEBUFFER_BINDING: *params = context->framebuffer; break; |
| 1732 | case GL_RENDERBUFFER_BINDING: *params = context->renderbuffer; break; |
| 1733 | case GL_CURRENT_PROGRAM: *params = context->currentProgram; break; |
| 1734 | case GL_RED_BITS: |
| 1735 | case GL_GREEN_BITS: |
| 1736 | case GL_BLUE_BITS: |
| 1737 | case GL_ALPHA_BITS: |
| 1738 | { |
| 1739 | gl::Framebuffer *framebuffer = context->getFramebuffer(); |
| 1740 | gl::Colorbuffer *colorbuffer = framebuffer->getColorbuffer(); |
| 1741 | |
| 1742 | if (colorbuffer) |
| 1743 | { |
| 1744 | switch (pname) |
| 1745 | { |
| 1746 | case GL_RED_BITS: *params = colorbuffer->getRedSize(); break; |
| 1747 | case GL_GREEN_BITS: *params = colorbuffer->getGreenSize(); break; |
| 1748 | case GL_BLUE_BITS: *params = colorbuffer->getBlueSize(); break; |
| 1749 | case GL_ALPHA_BITS: *params = colorbuffer->getAlphaSize(); break; |
| 1750 | } |
| 1751 | } |
| 1752 | else |
| 1753 | { |
| 1754 | *params = 0; |
| 1755 | } |
| 1756 | } |
| 1757 | break; |
| 1758 | case GL_DEPTH_BITS: |
| 1759 | { |
| 1760 | gl::Framebuffer *framebuffer = context->getFramebuffer(); |
| 1761 | gl::Depthbuffer *depthbuffer = framebuffer->getDepthbuffer(); |
| 1762 | |
| 1763 | if (depthbuffer) |
| 1764 | { |
| 1765 | *params = depthbuffer->getDepthSize(); |
| 1766 | } |
| 1767 | else |
| 1768 | { |
| 1769 | *params = 0; |
| 1770 | } |
| 1771 | } |
| 1772 | break; |
| 1773 | case GL_STENCIL_BITS: |
| 1774 | { |
| 1775 | gl::Framebuffer *framebuffer = context->getFramebuffer(); |
| 1776 | gl::Stencilbuffer *stencilbuffer = framebuffer->getStencilbuffer(); |
| 1777 | |
| 1778 | if (stencilbuffer) |
| 1779 | { |
| 1780 | *params = stencilbuffer->getStencilSize(); |
| 1781 | } |
| 1782 | else |
| 1783 | { |
| 1784 | *params = 0; |
| 1785 | } |
| 1786 | } |
| 1787 | break; |
| 1788 | default: |
| 1789 | UNIMPLEMENTED(); // FIXME |
| 1790 | return error(GL_INVALID_ENUM); |
| 1791 | } |
| 1792 | } |
| 1793 | } |
| 1794 | catch(std::bad_alloc&) |
| 1795 | { |
| 1796 | return error(GL_OUT_OF_MEMORY); |
| 1797 | } |
| 1798 | } |
| 1799 | |
| 1800 | void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params) |
| 1801 | { |
| 1802 | TRACE("GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p", program, pname, params); |
| 1803 | |
| 1804 | try |
| 1805 | { |
| 1806 | gl::Context *context = gl::getContext(); |
| 1807 | |
| 1808 | if (context) |
| 1809 | { |
| 1810 | gl::Program *programObject = context->getProgram(program); |
| 1811 | |
| 1812 | if (!programObject) |
| 1813 | { |
| 1814 | return error(GL_INVALID_VALUE); |
| 1815 | } |
| 1816 | |
| 1817 | switch (pname) |
| 1818 | { |
| 1819 | case GL_DELETE_STATUS: |
| 1820 | UNIMPLEMENTED(); // FIXME |
| 1821 | *params = GL_FALSE; |
| 1822 | return; |
| 1823 | case GL_LINK_STATUS: |
| 1824 | *params = programObject->isLinked(); |
| 1825 | return; |
| 1826 | case GL_VALIDATE_STATUS: |
| 1827 | UNIMPLEMENTED(); // FIXME |
| 1828 | *params = GL_TRUE; |
| 1829 | return; |
| 1830 | case GL_INFO_LOG_LENGTH: |
| 1831 | UNIMPLEMENTED(); // FIXME |
| 1832 | *params = 0; |
| 1833 | return; |
| 1834 | case GL_ATTACHED_SHADERS: |
| 1835 | UNIMPLEMENTED(); // FIXME |
| 1836 | *params = 2; |
| 1837 | return; |
| 1838 | case GL_ACTIVE_ATTRIBUTES: |
| 1839 | UNIMPLEMENTED(); // FIXME |
| 1840 | *params = 0; |
| 1841 | return; |
| 1842 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
| 1843 | UNIMPLEMENTED(); // FIXME |
| 1844 | *params = 0; |
| 1845 | return; |
| 1846 | case GL_ACTIVE_UNIFORMS: |
| 1847 | UNIMPLEMENTED(); // FIXME |
| 1848 | *params = 0; |
| 1849 | return; |
| 1850 | case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
| 1851 | UNIMPLEMENTED(); // FIXME |
| 1852 | *params = 0; |
| 1853 | return; |
| 1854 | default: |
| 1855 | return error(GL_INVALID_ENUM); |
| 1856 | } |
| 1857 | } |
| 1858 | } |
| 1859 | catch(std::bad_alloc&) |
| 1860 | { |
| 1861 | return error(GL_OUT_OF_MEMORY); |
| 1862 | } |
| 1863 | } |
| 1864 | |
| 1865 | void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) |
| 1866 | { |
| 1867 | TRACE("GLuint program = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, char* infolog = 0x%0.8p", program, bufsize, length, infolog); |
| 1868 | |
| 1869 | try |
| 1870 | { |
| 1871 | if (bufsize < 0) |
| 1872 | { |
| 1873 | return error(GL_INVALID_VALUE); |
| 1874 | } |
| 1875 | |
| 1876 | UNIMPLEMENTED(); // FIXME |
| 1877 | } |
| 1878 | catch(std::bad_alloc&) |
| 1879 | { |
| 1880 | return error(GL_OUT_OF_MEMORY); |
| 1881 | } |
| 1882 | } |
| 1883 | |
| 1884 | void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 1885 | { |
| 1886 | TRACE("GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p", target, pname, params); |
| 1887 | |
| 1888 | try |
| 1889 | { |
| 1890 | UNIMPLEMENTED(); // FIXME |
| 1891 | } |
| 1892 | catch(std::bad_alloc&) |
| 1893 | { |
| 1894 | return error(GL_OUT_OF_MEMORY); |
| 1895 | } |
| 1896 | } |
| 1897 | |
| 1898 | void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params) |
| 1899 | { |
| 1900 | TRACE("GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p", shader, pname, params); |
| 1901 | |
| 1902 | try |
| 1903 | { |
| 1904 | gl::Context *context = gl::getContext(); |
| 1905 | |
| 1906 | if (context) |
| 1907 | { |
| 1908 | gl::Shader *shaderObject = context->getShader(shader); |
| 1909 | |
| 1910 | if (!shaderObject) |
| 1911 | { |
| 1912 | return error(GL_INVALID_VALUE); |
| 1913 | } |
| 1914 | |
| 1915 | switch (pname) |
| 1916 | { |
| 1917 | case GL_SHADER_TYPE: |
| 1918 | *params = shaderObject->getType(); |
| 1919 | return; |
| 1920 | case GL_DELETE_STATUS: |
| 1921 | UNIMPLEMENTED(); // FIXME |
| 1922 | *params = GL_FALSE; |
| 1923 | return; |
| 1924 | case GL_COMPILE_STATUS: |
| 1925 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; |
| 1926 | return; |
| 1927 | case GL_INFO_LOG_LENGTH: |
| 1928 | UNIMPLEMENTED(); // FIXME |
| 1929 | *params = 0; |
| 1930 | return; |
| 1931 | case GL_SHADER_SOURCE_LENGTH: |
| 1932 | UNIMPLEMENTED(); // FIXME |
| 1933 | *params = 1; |
| 1934 | return; |
| 1935 | default: |
| 1936 | return error(GL_INVALID_ENUM); |
| 1937 | } |
| 1938 | } |
| 1939 | } |
| 1940 | catch(std::bad_alloc&) |
| 1941 | { |
| 1942 | return error(GL_OUT_OF_MEMORY); |
| 1943 | } |
| 1944 | } |
| 1945 | |
| 1946 | void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) |
| 1947 | { |
| 1948 | TRACE("GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, char* infolog = 0x%0.8p", shader, bufsize, length, infolog); |
| 1949 | |
| 1950 | try |
| 1951 | { |
| 1952 | if (bufsize < 0) |
| 1953 | { |
| 1954 | return error(GL_INVALID_VALUE); |
| 1955 | } |
| 1956 | |
| 1957 | UNIMPLEMENTED(); // FIXME |
| 1958 | } |
| 1959 | catch(std::bad_alloc&) |
| 1960 | { |
| 1961 | return error(GL_OUT_OF_MEMORY); |
| 1962 | } |
| 1963 | } |
| 1964 | |
| 1965 | void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) |
| 1966 | { |
| 1967 | TRACE("GLenum shadertype = 0x%X, GLenum precisiontype = 0x%X, GLint* range = 0x%0.8p, GLint* precision = 0x%0.8p", shadertype, precisiontype, range, precision); |
| 1968 | |
| 1969 | try |
| 1970 | { |
| 1971 | UNIMPLEMENTED(); // FIXME |
| 1972 | } |
| 1973 | catch(std::bad_alloc&) |
| 1974 | { |
| 1975 | return error(GL_OUT_OF_MEMORY); |
| 1976 | } |
| 1977 | } |
| 1978 | |
| 1979 | void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) |
| 1980 | { |
| 1981 | TRACE("GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, char* source = 0x%0.8p", shader, bufsize, length, source); |
| 1982 | |
| 1983 | try |
| 1984 | { |
| 1985 | if (bufsize < 0) |
| 1986 | { |
| 1987 | return error(GL_INVALID_VALUE); |
| 1988 | } |
| 1989 | |
| 1990 | UNIMPLEMENTED(); // FIXME |
| 1991 | } |
| 1992 | catch(std::bad_alloc&) |
| 1993 | { |
| 1994 | return error(GL_OUT_OF_MEMORY); |
| 1995 | } |
| 1996 | } |
| 1997 | |
| 1998 | const GLubyte* __stdcall glGetString(GLenum name) |
| 1999 | { |
| 2000 | TRACE("GLenum name = 0x%X", name); |
| 2001 | |
| 2002 | try |
| 2003 | { |
| 2004 | switch (name) |
| 2005 | { |
| 2006 | case GL_VENDOR: |
| 2007 | return (GLubyte*)"TransGaming Inc."; |
| 2008 | case GL_RENDERER: |
| 2009 | return (GLubyte*)"ANGLE"; |
| 2010 | case GL_VERSION: |
| 2011 | return (GLubyte*)"OpenGL ES 2.0 (git-devel "__DATE__ " " __TIME__")"; |
| 2012 | case GL_SHADING_LANGUAGE_VERSION: |
| 2013 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 (git-devel "__DATE__ " " __TIME__")"; |
| 2014 | case GL_EXTENSIONS: |
| 2015 | return (GLubyte*)""; |
| 2016 | default: |
| 2017 | return error(GL_INVALID_ENUM, (GLubyte*)NULL); |
| 2018 | } |
| 2019 | } |
| 2020 | catch(std::bad_alloc&) |
| 2021 | { |
| 2022 | return error(GL_OUT_OF_MEMORY, (GLubyte*)NULL); |
| 2023 | } |
| 2024 | |
| 2025 | return NULL; |
| 2026 | } |
| 2027 | |
| 2028 | void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) |
| 2029 | { |
| 2030 | TRACE("GLenum target = 0x%X, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p", target, pname, params); |
| 2031 | |
| 2032 | try |
| 2033 | { |
| 2034 | UNIMPLEMENTED(); // FIXME |
| 2035 | } |
| 2036 | catch(std::bad_alloc&) |
| 2037 | { |
| 2038 | return error(GL_OUT_OF_MEMORY); |
| 2039 | } |
| 2040 | } |
| 2041 | |
| 2042 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 2043 | { |
| 2044 | TRACE("GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p", target, pname, params); |
| 2045 | |
| 2046 | try |
| 2047 | { |
| 2048 | UNIMPLEMENTED(); // FIXME |
| 2049 | } |
| 2050 | catch(std::bad_alloc&) |
| 2051 | { |
| 2052 | return error(GL_OUT_OF_MEMORY); |
| 2053 | } |
| 2054 | } |
| 2055 | |
| 2056 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 2057 | { |
| 2058 | TRACE("GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p", program, location, params); |
| 2059 | |
| 2060 | try |
| 2061 | { |
| 2062 | UNIMPLEMENTED(); // FIXME |
| 2063 | } |
| 2064 | catch(std::bad_alloc&) |
| 2065 | { |
| 2066 | return error(GL_OUT_OF_MEMORY); |
| 2067 | } |
| 2068 | } |
| 2069 | |
| 2070 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 2071 | { |
| 2072 | TRACE("GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p", program, location, params); |
| 2073 | |
| 2074 | try |
| 2075 | { |
| 2076 | UNIMPLEMENTED(); // FIXME |
| 2077 | } |
| 2078 | catch(std::bad_alloc&) |
| 2079 | { |
| 2080 | return error(GL_OUT_OF_MEMORY); |
| 2081 | } |
| 2082 | } |
| 2083 | |
| 2084 | int __stdcall glGetUniformLocation(GLuint program, const char* name) |
| 2085 | { |
| 2086 | TRACE("GLuint program = %d, const char* name = 0x%0.8p", program, name); |
| 2087 | |
| 2088 | try |
| 2089 | { |
| 2090 | gl::Context *context = gl::getContext(); |
| 2091 | |
| 2092 | if (strstr(name, "gl_") == name) |
| 2093 | { |
| 2094 | return -1; |
| 2095 | } |
| 2096 | |
| 2097 | if (context) |
| 2098 | { |
| 2099 | gl::Program *programObject = context->getProgram(program); |
| 2100 | |
| 2101 | if (!programObject) |
| 2102 | { |
| 2103 | return error(GL_INVALID_VALUE, -1); |
| 2104 | } |
| 2105 | |
| 2106 | if (!programObject->isLinked()) |
| 2107 | { |
| 2108 | return error(GL_INVALID_OPERATION, -1); |
| 2109 | } |
| 2110 | |
| 2111 | return programObject->getUniformLocation(name); |
| 2112 | } |
| 2113 | } |
| 2114 | catch(std::bad_alloc&) |
| 2115 | { |
| 2116 | return error(GL_OUT_OF_MEMORY, -1); |
| 2117 | } |
| 2118 | |
| 2119 | return -1; |
| 2120 | } |
| 2121 | |
| 2122 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 2123 | { |
| 2124 | TRACE("GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p", index, pname, params); |
| 2125 | |
| 2126 | try |
| 2127 | { |
| 2128 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 2129 | { |
| 2130 | return error(GL_INVALID_VALUE); |
| 2131 | } |
| 2132 | |
| 2133 | UNIMPLEMENTED(); // FIXME |
| 2134 | } |
| 2135 | catch(std::bad_alloc&) |
| 2136 | { |
| 2137 | return error(GL_OUT_OF_MEMORY); |
| 2138 | } |
| 2139 | } |
| 2140 | |
| 2141 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 2142 | { |
| 2143 | TRACE("GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p", index, pname, params); |
| 2144 | |
| 2145 | try |
| 2146 | { |
| 2147 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 2148 | { |
| 2149 | return error(GL_INVALID_VALUE); |
| 2150 | } |
| 2151 | |
| 2152 | UNIMPLEMENTED(); // FIXME |
| 2153 | } |
| 2154 | catch(std::bad_alloc&) |
| 2155 | { |
| 2156 | return error(GL_OUT_OF_MEMORY); |
| 2157 | } |
| 2158 | } |
| 2159 | |
| 2160 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) |
| 2161 | { |
| 2162 | TRACE("GLuint index = %d, GLenum pname = 0x%X, void** pointer = 0x%0.8p", index, pname, pointer); |
| 2163 | |
| 2164 | try |
| 2165 | { |
| 2166 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 2167 | { |
| 2168 | return error(GL_INVALID_VALUE); |
| 2169 | } |
| 2170 | |
| 2171 | UNIMPLEMENTED(); // FIXME |
| 2172 | } |
| 2173 | catch(std::bad_alloc&) |
| 2174 | { |
| 2175 | return error(GL_OUT_OF_MEMORY); |
| 2176 | } |
| 2177 | } |
| 2178 | |
| 2179 | void __stdcall glHint(GLenum target, GLenum mode) |
| 2180 | { |
| 2181 | TRACE("GLenum target = 0x%X, GLenum mode = 0x%X", target, mode); |
| 2182 | |
| 2183 | try |
| 2184 | { |
| 2185 | UNIMPLEMENTED(); // FIXME |
| 2186 | } |
| 2187 | catch(std::bad_alloc&) |
| 2188 | { |
| 2189 | return error(GL_OUT_OF_MEMORY); |
| 2190 | } |
| 2191 | } |
| 2192 | |
| 2193 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 2194 | { |
| 2195 | TRACE("GLuint buffer = %d", buffer); |
| 2196 | |
| 2197 | try |
| 2198 | { |
| 2199 | gl::Context *context = gl::getContext(); |
| 2200 | |
| 2201 | if (context && buffer) |
| 2202 | { |
| 2203 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 2204 | |
| 2205 | if (bufferObject) |
| 2206 | { |
| 2207 | return GL_TRUE; |
| 2208 | } |
| 2209 | } |
| 2210 | } |
| 2211 | catch(std::bad_alloc&) |
| 2212 | { |
| 2213 | return error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 2214 | } |
| 2215 | |
| 2216 | return GL_FALSE; |
| 2217 | } |
| 2218 | |
| 2219 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 2220 | { |
| 2221 | TRACE("GLenum cap = 0x%X", cap); |
| 2222 | |
| 2223 | try |
| 2224 | { |
| 2225 | gl::Context *context = gl::getContext(); |
| 2226 | |
| 2227 | if (context) |
| 2228 | { |
| 2229 | switch (cap) |
| 2230 | { |
| 2231 | case GL_CULL_FACE: return context->cullFace; |
| 2232 | case GL_POLYGON_OFFSET_FILL: return context->polygonOffsetFill; |
| 2233 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->sampleAlphaToCoverage; |
| 2234 | case GL_SAMPLE_COVERAGE: return context->sampleCoverage; |
| 2235 | case GL_SCISSOR_TEST: return context->scissorTest; |
| 2236 | case GL_STENCIL_TEST: return context->stencilTest; |
| 2237 | case GL_DEPTH_TEST: return context->depthTest; |
| 2238 | case GL_BLEND: return context->blend; |
| 2239 | case GL_DITHER: return context->dither; |
| 2240 | default: |
| 2241 | return error(GL_INVALID_ENUM, false); |
| 2242 | } |
| 2243 | } |
| 2244 | } |
| 2245 | catch(std::bad_alloc&) |
| 2246 | { |
| 2247 | return error(GL_OUT_OF_MEMORY, false); |
| 2248 | } |
| 2249 | |
| 2250 | return false; |
| 2251 | } |
| 2252 | |
| 2253 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 2254 | { |
| 2255 | TRACE("GLuint framebuffer = %d", framebuffer); |
| 2256 | |
| 2257 | try |
| 2258 | { |
| 2259 | gl::Context *context = gl::getContext(); |
| 2260 | |
| 2261 | if (context && framebuffer) |
| 2262 | { |
| 2263 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 2264 | |
| 2265 | if (framebufferObject) |
| 2266 | { |
| 2267 | return GL_TRUE; |
| 2268 | } |
| 2269 | } |
| 2270 | } |
| 2271 | catch(std::bad_alloc&) |
| 2272 | { |
| 2273 | return error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 2274 | } |
| 2275 | |
| 2276 | return GL_FALSE; |
| 2277 | } |
| 2278 | |
| 2279 | GLboolean __stdcall glIsProgram(GLuint program) |
| 2280 | { |
| 2281 | TRACE("GLuint program = %d", program); |
| 2282 | |
| 2283 | try |
| 2284 | { |
| 2285 | gl::Context *context = gl::getContext(); |
| 2286 | |
| 2287 | if (context && program) |
| 2288 | { |
| 2289 | gl::Program *programObject = context->getProgram(program); |
| 2290 | |
| 2291 | if (programObject) |
| 2292 | { |
| 2293 | return GL_TRUE; |
| 2294 | } |
| 2295 | } |
| 2296 | } |
| 2297 | catch(std::bad_alloc&) |
| 2298 | { |
| 2299 | return error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 2300 | } |
| 2301 | |
| 2302 | return GL_FALSE; |
| 2303 | } |
| 2304 | |
| 2305 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 2306 | { |
| 2307 | TRACE("GLuint renderbuffer = %d", renderbuffer); |
| 2308 | |
| 2309 | try |
| 2310 | { |
| 2311 | gl::Context *context = gl::getContext(); |
| 2312 | |
| 2313 | if (context && renderbuffer) |
| 2314 | { |
| 2315 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 2316 | |
| 2317 | if (renderbufferObject) |
| 2318 | { |
| 2319 | return GL_TRUE; |
| 2320 | } |
| 2321 | } |
| 2322 | } |
| 2323 | catch(std::bad_alloc&) |
| 2324 | { |
| 2325 | return error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 2326 | } |
| 2327 | |
| 2328 | return GL_FALSE; |
| 2329 | } |
| 2330 | |
| 2331 | GLboolean __stdcall glIsShader(GLuint shader) |
| 2332 | { |
| 2333 | TRACE("GLuint shader = %d", shader); |
| 2334 | |
| 2335 | try |
| 2336 | { |
| 2337 | gl::Context *context = gl::getContext(); |
| 2338 | |
| 2339 | if (context && shader) |
| 2340 | { |
| 2341 | gl::Shader *shaderObject = context->getShader(shader); |
| 2342 | |
| 2343 | if (shaderObject) |
| 2344 | { |
| 2345 | return GL_TRUE; |
| 2346 | } |
| 2347 | } |
| 2348 | } |
| 2349 | catch(std::bad_alloc&) |
| 2350 | { |
| 2351 | return error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 2352 | } |
| 2353 | |
| 2354 | return GL_FALSE; |
| 2355 | } |
| 2356 | |
| 2357 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 2358 | { |
| 2359 | TRACE("GLuint texture = %d", texture); |
| 2360 | |
| 2361 | try |
| 2362 | { |
| 2363 | gl::Context *context = gl::getContext(); |
| 2364 | |
| 2365 | if (context && texture) |
| 2366 | { |
| 2367 | gl::Texture *textureObject = context->getTexture(texture); |
| 2368 | |
| 2369 | if (textureObject) |
| 2370 | { |
| 2371 | return GL_TRUE; |
| 2372 | } |
| 2373 | } |
| 2374 | } |
| 2375 | catch(std::bad_alloc&) |
| 2376 | { |
| 2377 | return error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 2378 | } |
| 2379 | |
| 2380 | return GL_FALSE; |
| 2381 | } |
| 2382 | |
| 2383 | void __stdcall glLineWidth(GLfloat width) |
| 2384 | { |
| 2385 | TRACE("GLfloat width = %f", width); |
| 2386 | |
| 2387 | try |
| 2388 | { |
| 2389 | if (width <= 0.0f) |
| 2390 | { |
| 2391 | return error(GL_INVALID_VALUE); |
| 2392 | } |
| 2393 | |
| 2394 | if (width != 1.0f) |
| 2395 | { |
| 2396 | UNIMPLEMENTED(); // FIXME |
| 2397 | } |
| 2398 | } |
| 2399 | catch(std::bad_alloc&) |
| 2400 | { |
| 2401 | return error(GL_OUT_OF_MEMORY); |
| 2402 | } |
| 2403 | } |
| 2404 | |
| 2405 | void __stdcall glLinkProgram(GLuint program) |
| 2406 | { |
| 2407 | TRACE("GLuint program = %d", program); |
| 2408 | |
| 2409 | try |
| 2410 | { |
| 2411 | gl::Context *context = gl::getContext(); |
| 2412 | |
| 2413 | if (context) |
| 2414 | { |
| 2415 | gl::Program *programObject = context->getProgram(program); |
| 2416 | |
| 2417 | if (!programObject) |
| 2418 | { |
| 2419 | return error(GL_INVALID_VALUE); |
| 2420 | } |
| 2421 | |
| 2422 | programObject->link(); |
| 2423 | } |
| 2424 | } |
| 2425 | catch(std::bad_alloc&) |
| 2426 | { |
| 2427 | return error(GL_OUT_OF_MEMORY); |
| 2428 | } |
| 2429 | } |
| 2430 | |
| 2431 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 2432 | { |
| 2433 | TRACE("GLenum pname = 0x%X, GLint param = %d", pname, param); |
| 2434 | |
| 2435 | try |
| 2436 | { |
| 2437 | switch (pname) |
| 2438 | { |
| 2439 | case GL_UNPACK_ALIGNMENT: |
| 2440 | // UNIMPLEMENTED(); // FIXME |
| 2441 | break; |
| 2442 | case GL_PACK_ALIGNMENT: |
| 2443 | // UNIMPLEMENTED(); // FIXME |
| 2444 | break; |
| 2445 | default: |
| 2446 | return error(GL_INVALID_ENUM); |
| 2447 | } |
| 2448 | } |
| 2449 | catch(std::bad_alloc&) |
| 2450 | { |
| 2451 | return error(GL_OUT_OF_MEMORY); |
| 2452 | } |
| 2453 | } |
| 2454 | |
| 2455 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 2456 | { |
| 2457 | TRACE("GLfloat factor = %f, GLfloat units = %f", factor, units); |
| 2458 | |
| 2459 | try |
| 2460 | { |
| 2461 | if (factor != 0.0f || units != 0.0f) |
| 2462 | { |
| 2463 | UNIMPLEMENTED(); // FIXME |
| 2464 | } |
| 2465 | } |
| 2466 | catch(std::bad_alloc&) |
| 2467 | { |
| 2468 | return error(GL_OUT_OF_MEMORY); |
| 2469 | } |
| 2470 | } |
| 2471 | |
| 2472 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) |
| 2473 | { |
| 2474 | TRACE("GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, void* pixels = 0x%0.8p", x, y, width, height, format, type, pixels); |
| 2475 | |
| 2476 | try |
| 2477 | { |
| 2478 | if (width < 0 || height < 0) |
| 2479 | { |
| 2480 | return error(GL_INVALID_VALUE); |
| 2481 | } |
| 2482 | |
| 2483 | switch (format) |
| 2484 | { |
| 2485 | case GL_RGBA: |
| 2486 | switch (type) |
| 2487 | { |
| 2488 | case GL_UNSIGNED_BYTE: |
| 2489 | break; |
| 2490 | default: |
| 2491 | return error(GL_INVALID_OPERATION); |
| 2492 | } |
| 2493 | break; |
| 2494 | case gl::IMPLEMENTATION_COLOR_READ_FORMAT: |
| 2495 | switch (type) |
| 2496 | { |
| 2497 | case gl::IMPLEMENTATION_COLOR_READ_TYPE: |
| 2498 | break; |
| 2499 | default: |
| 2500 | return error(GL_INVALID_OPERATION); |
| 2501 | } |
| 2502 | break; |
| 2503 | default: |
| 2504 | return error(GL_INVALID_OPERATION); |
| 2505 | } |
| 2506 | |
| 2507 | gl::Context *context = gl::getContext(); |
| 2508 | |
| 2509 | if (context) |
| 2510 | { |
| 2511 | context->readPixels(x, y, width, height, format, type, pixels); |
| 2512 | } |
| 2513 | } |
| 2514 | catch(std::bad_alloc&) |
| 2515 | { |
| 2516 | return error(GL_OUT_OF_MEMORY); |
| 2517 | } |
| 2518 | } |
| 2519 | |
| 2520 | void __stdcall glReleaseShaderCompiler(void) |
| 2521 | { |
| 2522 | TRACE(""); |
| 2523 | |
| 2524 | try |
| 2525 | { |
| 2526 | gl::Shader::releaseCompiler(); |
| 2527 | } |
| 2528 | catch(std::bad_alloc&) |
| 2529 | { |
| 2530 | return error(GL_OUT_OF_MEMORY); |
| 2531 | } |
| 2532 | } |
| 2533 | |
| 2534 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 2535 | { |
| 2536 | TRACE("GLenum target = 0x%X, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d", target, internalformat, width, height); |
| 2537 | |
| 2538 | try |
| 2539 | { |
| 2540 | switch (target) |
| 2541 | { |
| 2542 | case GL_RENDERBUFFER: |
| 2543 | break; |
| 2544 | default: |
| 2545 | return error(GL_INVALID_ENUM); |
| 2546 | } |
| 2547 | |
| 2548 | switch (internalformat) |
| 2549 | { |
| 2550 | case GL_DEPTH_COMPONENT16: |
| 2551 | case GL_RGBA4: |
| 2552 | case GL_RGB5_A1: |
| 2553 | case GL_RGB565: |
| 2554 | case GL_STENCIL_INDEX8: |
| 2555 | break; |
| 2556 | default: |
| 2557 | return error(GL_INVALID_ENUM); |
| 2558 | } |
| 2559 | |
| 2560 | if (width < 0 || height < 0 || width > gl::MAX_RENDERBUFFER_SIZE || height > gl::MAX_RENDERBUFFER_SIZE) |
| 2561 | { |
| 2562 | return error(GL_INVALID_VALUE); |
| 2563 | } |
| 2564 | |
| 2565 | gl::Context *context = gl::getContext(); |
| 2566 | |
| 2567 | if (context) |
| 2568 | { |
| 2569 | if (context->framebuffer == 0 || context->renderbuffer == 0) |
| 2570 | { |
| 2571 | return error(GL_INVALID_OPERATION); |
| 2572 | } |
| 2573 | |
| 2574 | switch (internalformat) |
| 2575 | { |
| 2576 | case GL_DEPTH_COMPONENT16: |
| 2577 | context->setRenderbuffer(new gl::Depthbuffer(width, height)); |
| 2578 | break; |
| 2579 | case GL_RGBA4: |
| 2580 | case GL_RGB5_A1: |
| 2581 | case GL_RGB565: |
| 2582 | UNIMPLEMENTED(); // FIXME |
| 2583 | // context->setRenderbuffer(new Colorbuffer(renderTarget)); |
| 2584 | break; |
| 2585 | case GL_STENCIL_INDEX8: |
| 2586 | UNIMPLEMENTED(); // FIXME |
| 2587 | // context->setRenderbuffer(new Stencilbuffer(depthStencil)); |
| 2588 | break; |
| 2589 | default: |
| 2590 | return error(GL_INVALID_ENUM); |
| 2591 | } |
| 2592 | } |
| 2593 | } |
| 2594 | catch(std::bad_alloc&) |
| 2595 | { |
| 2596 | return error(GL_OUT_OF_MEMORY); |
| 2597 | } |
| 2598 | } |
| 2599 | |
| 2600 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 2601 | { |
| 2602 | TRACE("GLclampf value = %f, GLboolean invert = %d", value, invert); |
| 2603 | |
| 2604 | try |
| 2605 | { |
| 2606 | gl::Context* context = gl::getContext(); |
| 2607 | |
| 2608 | if (context) |
| 2609 | { |
| 2610 | context->sampleCoverageValue = gl::clamp01(value); |
| 2611 | context->sampleCoverageInvert = invert; |
| 2612 | } |
| 2613 | } |
| 2614 | catch(std::bad_alloc&) |
| 2615 | { |
| 2616 | return error(GL_OUT_OF_MEMORY); |
| 2617 | } |
| 2618 | } |
| 2619 | |
| 2620 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 2621 | { |
| 2622 | TRACE("GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d", x, y, width, height); |
| 2623 | |
| 2624 | try |
| 2625 | { |
| 2626 | if (width < 0 || height < 0) |
| 2627 | { |
| 2628 | return error(GL_INVALID_VALUE); |
| 2629 | } |
| 2630 | |
| 2631 | gl::Context* context = gl::getContext(); |
| 2632 | |
| 2633 | if (context) |
| 2634 | { |
| 2635 | context->scissorX = x; |
| 2636 | context->scissorY = y; |
| 2637 | context->scissorWidth = width; |
| 2638 | context->scissorHeight = height; |
| 2639 | } |
| 2640 | } |
| 2641 | catch(std::bad_alloc&) |
| 2642 | { |
| 2643 | return error(GL_OUT_OF_MEMORY); |
| 2644 | } |
| 2645 | } |
| 2646 | |
| 2647 | void __stdcall glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) |
| 2648 | { |
| 2649 | TRACE("GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, const void* binary = 0x%0.8p, GLsizei length = %d", |
| 2650 | n, shaders, binaryformat, binary, length); |
| 2651 | |
| 2652 | try |
| 2653 | { |
| 2654 | if (n < 0 || length < 0) |
| 2655 | { |
| 2656 | return error(GL_INVALID_VALUE); |
| 2657 | } |
| 2658 | |
| 2659 | UNIMPLEMENTED(); // FIXME |
| 2660 | } |
| 2661 | catch(std::bad_alloc&) |
| 2662 | { |
| 2663 | return error(GL_OUT_OF_MEMORY); |
| 2664 | } |
| 2665 | } |
| 2666 | |
| 2667 | void __stdcall glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) |
| 2668 | { |
| 2669 | TRACE("GLuint shader = %d, GLsizei count = %d, const char** string = 0x%0.8p, const GLint* length = 0x%0.8p", shader, count, string, length); |
| 2670 | |
| 2671 | try |
| 2672 | { |
| 2673 | if (count < 0) |
| 2674 | { |
| 2675 | return error(GL_INVALID_VALUE); |
| 2676 | } |
| 2677 | |
| 2678 | gl::Context *context = gl::getContext(); |
| 2679 | |
| 2680 | if (context) |
| 2681 | { |
| 2682 | gl::Shader *shaderObject = context->getShader(shader); |
| 2683 | |
| 2684 | if (!shaderObject) |
| 2685 | { |
| 2686 | return error(GL_INVALID_VALUE); |
| 2687 | } |
| 2688 | |
| 2689 | shaderObject->setSource(count, string, length); |
| 2690 | } |
| 2691 | } |
| 2692 | catch(std::bad_alloc&) |
| 2693 | { |
| 2694 | return error(GL_OUT_OF_MEMORY); |
| 2695 | } |
| 2696 | } |
| 2697 | |
| 2698 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 2699 | { |
| 2700 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
| 2701 | } |
| 2702 | |
| 2703 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 2704 | { |
| 2705 | TRACE("GLenum face = 0x%X, GLenum func = 0x%X, GLint ref = %d, GLuint mask = %d", face, func, ref, mask); |
| 2706 | |
| 2707 | try |
| 2708 | { |
| 2709 | switch (face) |
| 2710 | { |
| 2711 | case GL_FRONT: |
| 2712 | case GL_BACK: |
| 2713 | case GL_FRONT_AND_BACK: |
| 2714 | break; |
| 2715 | default: |
| 2716 | return error(GL_INVALID_ENUM); |
| 2717 | } |
| 2718 | |
| 2719 | switch (func) |
| 2720 | { |
| 2721 | case GL_NEVER: |
| 2722 | case GL_ALWAYS: |
| 2723 | case GL_LESS: |
| 2724 | case GL_LEQUAL: |
| 2725 | case GL_EQUAL: |
| 2726 | case GL_GEQUAL: |
| 2727 | case GL_GREATER: |
| 2728 | case GL_NOTEQUAL: |
| 2729 | break; |
| 2730 | default: |
| 2731 | return error(GL_INVALID_ENUM); |
| 2732 | } |
| 2733 | |
| 2734 | gl::Context *context = gl::getContext(); |
| 2735 | |
| 2736 | if (context) |
| 2737 | { |
| 2738 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 2739 | { |
| 2740 | context->stencilFunc = func; |
| 2741 | context->stencilRef = ref; |
| 2742 | context->stencilMask = mask; |
| 2743 | } |
| 2744 | |
| 2745 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 2746 | { |
| 2747 | context->stencilBackFunc = func; |
| 2748 | context->stencilBackRef = ref; |
| 2749 | context->stencilBackMask = mask; |
| 2750 | } |
| 2751 | } |
| 2752 | } |
| 2753 | catch(std::bad_alloc&) |
| 2754 | { |
| 2755 | return error(GL_OUT_OF_MEMORY); |
| 2756 | } |
| 2757 | } |
| 2758 | |
| 2759 | void __stdcall glStencilMask(GLuint mask) |
| 2760 | { |
| 2761 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 2762 | } |
| 2763 | |
| 2764 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 2765 | { |
| 2766 | TRACE("GLenum face = 0x%X, GLuint mask = %d", face, mask); |
| 2767 | |
| 2768 | try |
| 2769 | { |
| 2770 | switch (face) |
| 2771 | { |
| 2772 | case GL_FRONT: |
| 2773 | case GL_BACK: |
| 2774 | case GL_FRONT_AND_BACK: |
| 2775 | break; |
| 2776 | default: |
| 2777 | return error(GL_INVALID_ENUM); |
| 2778 | } |
| 2779 | |
| 2780 | gl::Context *context = gl::getContext(); |
| 2781 | |
| 2782 | if (context) |
| 2783 | { |
| 2784 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 2785 | { |
| 2786 | context->stencilWritemask = mask; |
| 2787 | } |
| 2788 | |
| 2789 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 2790 | { |
| 2791 | context->stencilBackWritemask = mask; |
| 2792 | } |
| 2793 | } |
| 2794 | } |
| 2795 | catch(std::bad_alloc&) |
| 2796 | { |
| 2797 | return error(GL_OUT_OF_MEMORY); |
| 2798 | } |
| 2799 | } |
| 2800 | |
| 2801 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 2802 | { |
| 2803 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 2804 | } |
| 2805 | |
| 2806 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 2807 | { |
| 2808 | TRACE("GLenum face = 0x%X, GLenum fail = 0x%X, GLenum zfail = 0x%X, GLenum zpas = 0x%Xs", face, fail, zfail, zpass); |
| 2809 | |
| 2810 | try |
| 2811 | { |
| 2812 | switch (face) |
| 2813 | { |
| 2814 | case GL_FRONT: |
| 2815 | case GL_BACK: |
| 2816 | case GL_FRONT_AND_BACK: |
| 2817 | break; |
| 2818 | default: |
| 2819 | return error(GL_INVALID_ENUM); |
| 2820 | } |
| 2821 | |
| 2822 | switch (fail) |
| 2823 | { |
| 2824 | case GL_ZERO: |
| 2825 | case GL_KEEP: |
| 2826 | case GL_REPLACE: |
| 2827 | case GL_INCR: |
| 2828 | case GL_DECR: |
| 2829 | case GL_INVERT: |
| 2830 | case GL_INCR_WRAP: |
| 2831 | case GL_DECR_WRAP: |
| 2832 | break; |
| 2833 | default: |
| 2834 | return error(GL_INVALID_ENUM); |
| 2835 | } |
| 2836 | |
| 2837 | switch (zfail) |
| 2838 | { |
| 2839 | case GL_ZERO: |
| 2840 | case GL_KEEP: |
| 2841 | case GL_REPLACE: |
| 2842 | case GL_INCR: |
| 2843 | case GL_DECR: |
| 2844 | case GL_INVERT: |
| 2845 | case GL_INCR_WRAP: |
| 2846 | case GL_DECR_WRAP: |
| 2847 | break; |
| 2848 | default: |
| 2849 | return error(GL_INVALID_ENUM); |
| 2850 | } |
| 2851 | |
| 2852 | switch (zpass) |
| 2853 | { |
| 2854 | case GL_ZERO: |
| 2855 | case GL_KEEP: |
| 2856 | case GL_REPLACE: |
| 2857 | case GL_INCR: |
| 2858 | case GL_DECR: |
| 2859 | case GL_INVERT: |
| 2860 | case GL_INCR_WRAP: |
| 2861 | case GL_DECR_WRAP: |
| 2862 | break; |
| 2863 | default: |
| 2864 | return error(GL_INVALID_ENUM); |
| 2865 | } |
| 2866 | |
| 2867 | gl::Context *context = gl::getContext(); |
| 2868 | |
| 2869 | if (context) |
| 2870 | { |
| 2871 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 2872 | { |
| 2873 | context->stencilFail = fail; |
| 2874 | context->stencilPassDepthFail = zfail; |
| 2875 | context->stencilPassDepthPass = zpass; |
| 2876 | } |
| 2877 | |
| 2878 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 2879 | { |
| 2880 | context->stencilBackFail = fail; |
| 2881 | context->stencilBackPassDepthFail = zfail; |
| 2882 | context->stencilBackPassDepthPass = zpass; |
| 2883 | } |
| 2884 | } |
| 2885 | } |
| 2886 | catch(std::bad_alloc&) |
| 2887 | { |
| 2888 | return error(GL_OUT_OF_MEMORY); |
| 2889 | } |
| 2890 | } |
| 2891 | |
| 2892 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) |
| 2893 | { |
| 2894 | TRACE("GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d, GLenum format = 0x%X, GLenum type = 0x%X, const void* pixels = 0x%0.8p", target, level, internalformat, width, height, border, format, type, pixels); |
| 2895 | |
| 2896 | try |
| 2897 | { |
| 2898 | if (level < 0 || width < 0 || height < 0) |
| 2899 | { |
| 2900 | return error(GL_INVALID_VALUE); |
| 2901 | } |
| 2902 | |
| 2903 | if (level > 0 && (!gl::isPow2(width) || !gl::isPow2(height))) |
| 2904 | { |
| 2905 | return error(GL_INVALID_VALUE); |
| 2906 | } |
| 2907 | |
| 2908 | switch (target) |
| 2909 | { |
| 2910 | case GL_TEXTURE_2D: |
| 2911 | if (width > (gl::MAX_TEXTURE_SIZE >> level) || height > (gl::MAX_TEXTURE_SIZE >> level)) |
| 2912 | { |
| 2913 | return error(GL_INVALID_VALUE); |
| 2914 | } |
| 2915 | break; |
| 2916 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2917 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2918 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2919 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2920 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2921 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 2922 | if (!gl::isPow2(width) || !gl::isPow2(height)) |
| 2923 | { |
| 2924 | return error(GL_INVALID_VALUE); |
| 2925 | } |
| 2926 | |
| 2927 | if (width > (gl::MAX_CUBE_MAP_TEXTURE_SIZE >> level) || height > (gl::MAX_CUBE_MAP_TEXTURE_SIZE >> level)) |
| 2928 | { |
| 2929 | return error(GL_INVALID_VALUE); |
| 2930 | } |
| 2931 | break; |
| 2932 | default: |
| 2933 | return error(GL_INVALID_ENUM); |
| 2934 | } |
| 2935 | |
| 2936 | if (internalformat != format) |
| 2937 | { |
| 2938 | return error(GL_INVALID_OPERATION); |
| 2939 | } |
| 2940 | |
| 2941 | switch (internalformat) |
| 2942 | { |
| 2943 | case GL_ALPHA: |
| 2944 | case GL_LUMINANCE: |
| 2945 | case GL_LUMINANCE_ALPHA: |
| 2946 | switch (type) |
| 2947 | { |
| 2948 | case GL_UNSIGNED_BYTE: |
| 2949 | break; |
| 2950 | default: |
| 2951 | return error(GL_INVALID_ENUM); |
| 2952 | } |
| 2953 | break; |
| 2954 | case GL_RGB: |
| 2955 | switch (type) |
| 2956 | { |
| 2957 | case GL_UNSIGNED_BYTE: |
| 2958 | case GL_UNSIGNED_SHORT_5_6_5: |
| 2959 | break; |
| 2960 | default: |
| 2961 | return error(GL_INVALID_ENUM); |
| 2962 | } |
| 2963 | break; |
| 2964 | case GL_RGBA: |
| 2965 | switch (type) |
| 2966 | { |
| 2967 | case GL_UNSIGNED_BYTE: |
| 2968 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 2969 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 2970 | break; |
| 2971 | default: |
| 2972 | return error(GL_INVALID_ENUM); |
| 2973 | } |
| 2974 | break; |
| 2975 | default: |
| 2976 | return error(GL_INVALID_VALUE); |
| 2977 | } |
| 2978 | |
| 2979 | if (border != 0) |
| 2980 | { |
| 2981 | return error(GL_INVALID_VALUE); |
| 2982 | } |
| 2983 | |
| 2984 | gl::Context *context = gl::getContext(); |
| 2985 | |
| 2986 | if (context) |
| 2987 | { |
| 2988 | if (target == GL_TEXTURE_2D) |
| 2989 | { |
| 2990 | gl::Texture2D *texture = context->getTexture2D(); |
| 2991 | |
| 2992 | if (!texture) |
| 2993 | { |
| 2994 | return error(GL_INVALID_OPERATION); |
| 2995 | } |
| 2996 | |
| 2997 | texture->setImage(level, internalformat, width, height, format, type, pixels); |
| 2998 | } |
| 2999 | else |
| 3000 | { |
| 3001 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3002 | |
| 3003 | if (!texture) |
| 3004 | { |
| 3005 | return error(GL_INVALID_OPERATION); |
| 3006 | } |
| 3007 | |
| 3008 | switch (target) |
| 3009 | { |
| 3010 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3011 | texture->setImagePosX(level, internalformat, width, height, format, type, pixels); |
| 3012 | break; |
| 3013 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3014 | texture->setImageNegX(level, internalformat, width, height, format, type, pixels); |
| 3015 | break; |
| 3016 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3017 | texture->setImagePosY(level, internalformat, width, height, format, type, pixels); |
| 3018 | break; |
| 3019 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3020 | texture->setImageNegY(level, internalformat, width, height, format, type, pixels); |
| 3021 | break; |
| 3022 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3023 | texture->setImagePosZ(level, internalformat, width, height, format, type, pixels); |
| 3024 | break; |
| 3025 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 3026 | texture->setImageNegZ(level, internalformat, width, height, format, type, pixels); |
| 3027 | break; |
| 3028 | default: UNREACHABLE(); |
| 3029 | } |
| 3030 | } |
| 3031 | } |
| 3032 | } |
| 3033 | catch(std::bad_alloc&) |
| 3034 | { |
| 3035 | return error(GL_OUT_OF_MEMORY); |
| 3036 | } |
| 3037 | } |
| 3038 | |
| 3039 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 3040 | { |
| 3041 | glTexParameteri(target, pname, (GLint)param); |
| 3042 | } |
| 3043 | |
| 3044 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 3045 | { |
| 3046 | glTexParameteri(target, pname, (GLint)*params); |
| 3047 | } |
| 3048 | |
| 3049 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 3050 | { |
| 3051 | TRACE("GLenum target = 0x%X, GLenum pname = 0x%X, GLfloat param = %f", target, pname, param); |
| 3052 | |
| 3053 | try |
| 3054 | { |
| 3055 | gl::Context *context = gl::getContext(); |
| 3056 | |
| 3057 | if (context) |
| 3058 | { |
| 3059 | gl::Texture *texture; |
| 3060 | |
| 3061 | switch (target) |
| 3062 | { |
| 3063 | case GL_TEXTURE_2D: |
| 3064 | texture = context->getTexture2D(); |
| 3065 | break; |
| 3066 | case GL_TEXTURE_CUBE_MAP: |
| 3067 | texture = context->getTextureCubeMap(); |
| 3068 | break; |
| 3069 | default: |
| 3070 | return error(GL_INVALID_ENUM); |
| 3071 | } |
| 3072 | |
| 3073 | switch (pname) |
| 3074 | { |
| 3075 | case GL_TEXTURE_WRAP_S: |
| 3076 | if (!texture->setWrapS((GLenum)param)) |
| 3077 | { |
| 3078 | return error(GL_INVALID_ENUM); |
| 3079 | } |
| 3080 | break; |
| 3081 | case GL_TEXTURE_WRAP_T: |
| 3082 | if (!texture->setWrapT((GLenum)param)) |
| 3083 | { |
| 3084 | return error(GL_INVALID_ENUM); |
| 3085 | } |
| 3086 | break; |
| 3087 | case GL_TEXTURE_MIN_FILTER: |
| 3088 | if (!texture->setMinFilter((GLenum)param)) |
| 3089 | { |
| 3090 | return error(GL_INVALID_ENUM); |
| 3091 | } |
| 3092 | break; |
| 3093 | case GL_TEXTURE_MAG_FILTER: |
| 3094 | if (!texture->setMagFilter((GLenum)param)) |
| 3095 | { |
| 3096 | return error(GL_INVALID_ENUM); |
| 3097 | } |
| 3098 | break; |
| 3099 | default: |
| 3100 | return error(GL_INVALID_ENUM); |
| 3101 | } |
| 3102 | } |
| 3103 | } |
| 3104 | catch(std::bad_alloc&) |
| 3105 | { |
| 3106 | return error(GL_OUT_OF_MEMORY); |
| 3107 | } |
| 3108 | } |
| 3109 | |
| 3110 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 3111 | { |
| 3112 | glTexParameteri(target, pname, *params); |
| 3113 | } |
| 3114 | |
| 3115 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) |
| 3116 | { |
| 3117 | TRACE("GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, const void* pixels = 0x%0.8p", |
| 3118 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 3119 | |
| 3120 | try |
| 3121 | { |
| 3122 | if (width < 0 || height < 0) |
| 3123 | { |
| 3124 | return error(GL_INVALID_VALUE); |
| 3125 | } |
| 3126 | |
| 3127 | UNIMPLEMENTED(); // FIXME |
| 3128 | } |
| 3129 | catch(std::bad_alloc&) |
| 3130 | { |
| 3131 | return error(GL_OUT_OF_MEMORY); |
| 3132 | } |
| 3133 | } |
| 3134 | |
| 3135 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 3136 | { |
| 3137 | glUniform1fv(location, 1, &x); |
| 3138 | } |
| 3139 | |
| 3140 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 3141 | { |
| 3142 | TRACE("GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p", location, count, v); |
| 3143 | |
| 3144 | try |
| 3145 | { |
| 3146 | if (location == -1) |
| 3147 | { |
| 3148 | return; |
| 3149 | } |
| 3150 | |
| 3151 | if (count < 0) |
| 3152 | { |
| 3153 | return error(GL_INVALID_VALUE); |
| 3154 | } |
| 3155 | |
| 3156 | gl::Context *context = gl::getContext(); |
| 3157 | |
| 3158 | if (context) |
| 3159 | { |
| 3160 | gl::Program *program = context->getCurrentProgram(); |
| 3161 | |
| 3162 | if (!program) |
| 3163 | { |
| 3164 | return error(GL_INVALID_OPERATION); |
| 3165 | } |
| 3166 | |
| 3167 | if (!program->setUniform1fv(location, count, v)) |
| 3168 | { |
| 3169 | return error(GL_INVALID_OPERATION); |
| 3170 | } |
| 3171 | } |
| 3172 | } |
| 3173 | catch(std::bad_alloc&) |
| 3174 | { |
| 3175 | return error(GL_OUT_OF_MEMORY); |
| 3176 | } |
| 3177 | } |
| 3178 | |
| 3179 | void __stdcall glUniform1i(GLint location, GLint x) |
| 3180 | { |
| 3181 | glUniform1iv(location, 1, &x); |
| 3182 | } |
| 3183 | |
| 3184 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 3185 | { |
| 3186 | TRACE("GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p", location, count, v); |
| 3187 | |
| 3188 | try |
| 3189 | { |
| 3190 | if (count < 0) |
| 3191 | { |
| 3192 | return error(GL_INVALID_VALUE); |
| 3193 | } |
| 3194 | |
| 3195 | gl::Context *context = gl::getContext(); |
| 3196 | |
| 3197 | if (context) |
| 3198 | { |
| 3199 | gl::Program *program = context->getCurrentProgram(); |
| 3200 | |
| 3201 | if (!program) |
| 3202 | { |
| 3203 | return error(GL_INVALID_OPERATION); |
| 3204 | } |
| 3205 | |
| 3206 | if (!program->setUniform1iv(location, count, v)) |
| 3207 | { |
| 3208 | return error(GL_INVALID_OPERATION); |
| 3209 | } |
| 3210 | } |
| 3211 | } |
| 3212 | catch(std::bad_alloc&) |
| 3213 | { |
| 3214 | return error(GL_OUT_OF_MEMORY); |
| 3215 | } |
| 3216 | } |
| 3217 | |
| 3218 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 3219 | { |
| 3220 | GLfloat xy[2] = {x, y}; |
| 3221 | |
| 3222 | glUniform2fv(location, 1, (GLfloat*)&xy); |
| 3223 | } |
| 3224 | |
| 3225 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 3226 | { |
| 3227 | TRACE("GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p", location, count, v); |
| 3228 | |
| 3229 | try |
| 3230 | { |
| 3231 | if (location == -1) |
| 3232 | { |
| 3233 | return; |
| 3234 | } |
| 3235 | |
| 3236 | if (count < 0) |
| 3237 | { |
| 3238 | return error(GL_INVALID_VALUE); |
| 3239 | } |
| 3240 | |
| 3241 | gl::Context *context = gl::getContext(); |
| 3242 | |
| 3243 | if (context) |
| 3244 | { |
| 3245 | gl::Program *program = context->getCurrentProgram(); |
| 3246 | |
| 3247 | if (!program) |
| 3248 | { |
| 3249 | return error(GL_INVALID_OPERATION); |
| 3250 | } |
| 3251 | |
| 3252 | if (!program->setUniform2fv(location, count, v)) |
| 3253 | { |
| 3254 | return error(GL_INVALID_OPERATION); |
| 3255 | } |
| 3256 | } |
| 3257 | } |
| 3258 | catch(std::bad_alloc&) |
| 3259 | { |
| 3260 | return error(GL_OUT_OF_MEMORY); |
| 3261 | } |
| 3262 | } |
| 3263 | |
| 3264 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 3265 | { |
| 3266 | GLint xy[4] = {x, y}; |
| 3267 | |
| 3268 | glUniform2iv(location, 1, (GLint*)&xy); |
| 3269 | } |
| 3270 | |
| 3271 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 3272 | { |
| 3273 | TRACE("GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p", location, count, v); |
| 3274 | |
| 3275 | try |
| 3276 | { |
| 3277 | if (count < 0) |
| 3278 | { |
| 3279 | return error(GL_INVALID_VALUE); |
| 3280 | } |
| 3281 | |
| 3282 | UNIMPLEMENTED(); // FIXME |
| 3283 | } |
| 3284 | catch(std::bad_alloc&) |
| 3285 | { |
| 3286 | return error(GL_OUT_OF_MEMORY); |
| 3287 | } |
| 3288 | } |
| 3289 | |
| 3290 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 3291 | { |
| 3292 | GLfloat xyz[3] = {x, y, z}; |
| 3293 | |
| 3294 | glUniform3fv(location, 1, (GLfloat*)&xyz); |
| 3295 | } |
| 3296 | |
| 3297 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 3298 | { |
| 3299 | TRACE("GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p", location, count, v); |
| 3300 | |
| 3301 | try |
| 3302 | { |
| 3303 | if (count < 0) |
| 3304 | { |
| 3305 | return error(GL_INVALID_VALUE); |
| 3306 | } |
| 3307 | |
| 3308 | if (location == -1) |
| 3309 | { |
| 3310 | return; |
| 3311 | } |
| 3312 | |
| 3313 | gl::Context *context = gl::getContext(); |
| 3314 | |
| 3315 | if (context) |
| 3316 | { |
| 3317 | gl::Program *program = context->getCurrentProgram(); |
| 3318 | |
| 3319 | if (!program) |
| 3320 | { |
| 3321 | return error(GL_INVALID_OPERATION); |
| 3322 | } |
| 3323 | |
| 3324 | if (!program->setUniform3fv(location, count, v)) |
| 3325 | { |
| 3326 | return error(GL_INVALID_OPERATION); |
| 3327 | } |
| 3328 | } |
| 3329 | } |
| 3330 | catch(std::bad_alloc&) |
| 3331 | { |
| 3332 | return error(GL_OUT_OF_MEMORY); |
| 3333 | } |
| 3334 | } |
| 3335 | |
| 3336 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 3337 | { |
| 3338 | GLint xyz[3] = {x, y, z}; |
| 3339 | |
| 3340 | glUniform3iv(location, 1, (GLint*)&xyz); |
| 3341 | } |
| 3342 | |
| 3343 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 3344 | { |
| 3345 | TRACE("GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p", location, count, v); |
| 3346 | |
| 3347 | try |
| 3348 | { |
| 3349 | if (count < 0) |
| 3350 | { |
| 3351 | return error(GL_INVALID_VALUE); |
| 3352 | } |
| 3353 | |
| 3354 | UNIMPLEMENTED(); // FIXME |
| 3355 | } |
| 3356 | catch(std::bad_alloc&) |
| 3357 | { |
| 3358 | return error(GL_OUT_OF_MEMORY); |
| 3359 | } |
| 3360 | } |
| 3361 | |
| 3362 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 3363 | { |
| 3364 | GLfloat xyzw[4] = {x, y, z, w}; |
| 3365 | |
| 3366 | glUniform4fv(location, 1, (GLfloat*)&xyzw); |
| 3367 | } |
| 3368 | |
| 3369 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 3370 | { |
| 3371 | TRACE("GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p", location, count, v); |
| 3372 | |
| 3373 | try |
| 3374 | { |
| 3375 | if (count < 0) |
| 3376 | { |
| 3377 | return error(GL_INVALID_VALUE); |
| 3378 | } |
| 3379 | |
| 3380 | if (location == -1) |
| 3381 | { |
| 3382 | return; |
| 3383 | } |
| 3384 | |
| 3385 | gl::Context *context = gl::getContext(); |
| 3386 | |
| 3387 | if (context) |
| 3388 | { |
| 3389 | gl::Program *program = context->getCurrentProgram(); |
| 3390 | |
| 3391 | if (!program) |
| 3392 | { |
| 3393 | return error(GL_INVALID_OPERATION); |
| 3394 | } |
| 3395 | |
| 3396 | if (!program->setUniform4fv(location, count, v)) |
| 3397 | { |
| 3398 | return error(GL_INVALID_OPERATION); |
| 3399 | } |
| 3400 | } |
| 3401 | } |
| 3402 | catch(std::bad_alloc&) |
| 3403 | { |
| 3404 | return error(GL_OUT_OF_MEMORY); |
| 3405 | } |
| 3406 | } |
| 3407 | |
| 3408 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 3409 | { |
| 3410 | GLint xyzw[4] = {x, y, z, w}; |
| 3411 | |
| 3412 | glUniform4iv(location, 1, (GLint*)&xyzw); |
| 3413 | } |
| 3414 | |
| 3415 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 3416 | { |
| 3417 | TRACE("GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p", location, count, v); |
| 3418 | |
| 3419 | try |
| 3420 | { |
| 3421 | if (count < 0) |
| 3422 | { |
| 3423 | return error(GL_INVALID_VALUE); |
| 3424 | } |
| 3425 | |
| 3426 | UNIMPLEMENTED(); // FIXME |
| 3427 | } |
| 3428 | catch(std::bad_alloc&) |
| 3429 | { |
| 3430 | return error(GL_OUT_OF_MEMORY); |
| 3431 | } |
| 3432 | } |
| 3433 | |
| 3434 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 3435 | { |
| 3436 | TRACE("GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p", location, count, transpose, value); |
| 3437 | |
| 3438 | try |
| 3439 | { |
| 3440 | if (count < 0 || transpose != GL_FALSE) |
| 3441 | { |
| 3442 | return error(GL_INVALID_VALUE); |
| 3443 | } |
| 3444 | |
| 3445 | if (location == -1) |
| 3446 | { |
| 3447 | return; |
| 3448 | } |
| 3449 | |
| 3450 | gl::Context *context = gl::getContext(); |
| 3451 | |
| 3452 | if (context) |
| 3453 | { |
| 3454 | gl::Program *program = context->getCurrentProgram(); |
| 3455 | |
| 3456 | if (!program) |
| 3457 | { |
| 3458 | return error(GL_INVALID_OPERATION); |
| 3459 | } |
| 3460 | |
| 3461 | if (!program->setUniformMatrix2fv(location, count, value)) |
| 3462 | { |
| 3463 | return error(GL_INVALID_OPERATION); |
| 3464 | } |
| 3465 | } |
| 3466 | } |
| 3467 | catch(std::bad_alloc&) |
| 3468 | { |
| 3469 | return error(GL_OUT_OF_MEMORY); |
| 3470 | } |
| 3471 | } |
| 3472 | |
| 3473 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 3474 | { |
| 3475 | TRACE("GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p", location, count, transpose, value); |
| 3476 | |
| 3477 | try |
| 3478 | { |
| 3479 | if (count < 0 || transpose != GL_FALSE) |
| 3480 | { |
| 3481 | return error(GL_INVALID_VALUE); |
| 3482 | } |
| 3483 | |
| 3484 | if (location == -1) |
| 3485 | { |
| 3486 | return; |
| 3487 | } |
| 3488 | |
| 3489 | gl::Context *context = gl::getContext(); |
| 3490 | |
| 3491 | if (context) |
| 3492 | { |
| 3493 | gl::Program *program = context->getCurrentProgram(); |
| 3494 | |
| 3495 | if (!program) |
| 3496 | { |
| 3497 | return error(GL_INVALID_OPERATION); |
| 3498 | } |
| 3499 | |
| 3500 | if (!program->setUniformMatrix3fv(location, count, value)) |
| 3501 | { |
| 3502 | return error(GL_INVALID_OPERATION); |
| 3503 | } |
| 3504 | } |
| 3505 | } |
| 3506 | catch(std::bad_alloc&) |
| 3507 | { |
| 3508 | return error(GL_OUT_OF_MEMORY); |
| 3509 | } |
| 3510 | } |
| 3511 | |
| 3512 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 3513 | { |
| 3514 | TRACE("GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p", location, count, transpose, value); |
| 3515 | |
| 3516 | try |
| 3517 | { |
| 3518 | if (count < 0 || transpose != GL_FALSE) |
| 3519 | { |
| 3520 | return error(GL_INVALID_VALUE); |
| 3521 | } |
| 3522 | |
| 3523 | if (location == -1) |
| 3524 | { |
| 3525 | return; |
| 3526 | } |
| 3527 | |
| 3528 | gl::Context *context = gl::getContext(); |
| 3529 | |
| 3530 | if (context) |
| 3531 | { |
| 3532 | gl::Program *program = context->getCurrentProgram(); |
| 3533 | |
| 3534 | if (!program) |
| 3535 | { |
| 3536 | return error(GL_INVALID_OPERATION); |
| 3537 | } |
| 3538 | |
| 3539 | if (!program->setUniformMatrix4fv(location, count, value)) |
| 3540 | { |
| 3541 | return error(GL_INVALID_OPERATION); |
| 3542 | } |
| 3543 | } |
| 3544 | } |
| 3545 | catch(std::bad_alloc&) |
| 3546 | { |
| 3547 | return error(GL_OUT_OF_MEMORY); |
| 3548 | } |
| 3549 | } |
| 3550 | |
| 3551 | void __stdcall glUseProgram(GLuint program) |
| 3552 | { |
| 3553 | TRACE("GLuint program = %d", program); |
| 3554 | |
| 3555 | try |
| 3556 | { |
| 3557 | gl::Context *context = gl::getContext(); |
| 3558 | |
| 3559 | if (context) |
| 3560 | { |
| 3561 | gl::Program *programObject = context->getProgram(program); |
| 3562 | |
| 3563 | if (programObject && !programObject->isLinked()) |
| 3564 | { |
| 3565 | return error(GL_INVALID_OPERATION); |
| 3566 | } |
| 3567 | |
| 3568 | context->useProgram(program); |
| 3569 | } |
| 3570 | } |
| 3571 | catch(std::bad_alloc&) |
| 3572 | { |
| 3573 | return error(GL_OUT_OF_MEMORY); |
| 3574 | } |
| 3575 | } |
| 3576 | |
| 3577 | void __stdcall glValidateProgram(GLuint program) |
| 3578 | { |
| 3579 | TRACE("GLuint program = %d", program); |
| 3580 | |
| 3581 | try |
| 3582 | { |
| 3583 | UNIMPLEMENTED(); // FIXME |
| 3584 | } |
| 3585 | catch(std::bad_alloc&) |
| 3586 | { |
| 3587 | return error(GL_OUT_OF_MEMORY); |
| 3588 | } |
| 3589 | } |
| 3590 | |
| 3591 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 3592 | { |
| 3593 | TRACE("GLuint index = %d, GLfloat x = %f", index, x); |
| 3594 | |
| 3595 | try |
| 3596 | { |
| 3597 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3598 | { |
| 3599 | return error(GL_INVALID_VALUE); |
| 3600 | } |
| 3601 | |
| 3602 | UNIMPLEMENTED(); // FIXME |
| 3603 | } |
| 3604 | catch(std::bad_alloc&) |
| 3605 | { |
| 3606 | return error(GL_OUT_OF_MEMORY); |
| 3607 | } |
| 3608 | } |
| 3609 | |
| 3610 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 3611 | { |
| 3612 | TRACE("GLuint index = %d, const GLfloat* values = 0x%0.8p", index, values); |
| 3613 | |
| 3614 | try |
| 3615 | { |
| 3616 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3617 | { |
| 3618 | return error(GL_INVALID_VALUE); |
| 3619 | } |
| 3620 | |
| 3621 | UNIMPLEMENTED(); // FIXME |
| 3622 | } |
| 3623 | catch(std::bad_alloc&) |
| 3624 | { |
| 3625 | return error(GL_OUT_OF_MEMORY); |
| 3626 | } |
| 3627 | } |
| 3628 | |
| 3629 | void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 3630 | { |
| 3631 | TRACE("GLuint index = %d, GLfloat x = %f, GLfloat y = %f", index, x, y); |
| 3632 | |
| 3633 | try |
| 3634 | { |
| 3635 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3636 | { |
| 3637 | return error(GL_INVALID_VALUE); |
| 3638 | } |
| 3639 | |
| 3640 | UNIMPLEMENTED(); // FIXME |
| 3641 | } |
| 3642 | catch(std::bad_alloc&) |
| 3643 | { |
| 3644 | return error(GL_OUT_OF_MEMORY); |
| 3645 | } |
| 3646 | } |
| 3647 | |
| 3648 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 3649 | { |
| 3650 | TRACE("GLuint index = %d, const GLfloat* values = 0x%0.8p", index, values); |
| 3651 | |
| 3652 | try |
| 3653 | { |
| 3654 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3655 | { |
| 3656 | return error(GL_INVALID_VALUE); |
| 3657 | } |
| 3658 | |
| 3659 | UNIMPLEMENTED(); // FIXME |
| 3660 | } |
| 3661 | catch(std::bad_alloc&) |
| 3662 | { |
| 3663 | return error(GL_OUT_OF_MEMORY); |
| 3664 | } |
| 3665 | } |
| 3666 | |
| 3667 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 3668 | { |
| 3669 | TRACE("GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f", index, x, y, z); |
| 3670 | |
| 3671 | try |
| 3672 | { |
| 3673 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3674 | { |
| 3675 | return error(GL_INVALID_VALUE); |
| 3676 | } |
| 3677 | |
| 3678 | UNIMPLEMENTED(); // FIXME |
| 3679 | } |
| 3680 | catch(std::bad_alloc&) |
| 3681 | { |
| 3682 | return error(GL_OUT_OF_MEMORY); |
| 3683 | } |
| 3684 | } |
| 3685 | |
| 3686 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 3687 | { |
| 3688 | TRACE("GLuint index = %d, const GLfloat* values = 0x%0.8p", index, values); |
| 3689 | |
| 3690 | try |
| 3691 | { |
| 3692 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3693 | { |
| 3694 | return error(GL_INVALID_VALUE); |
| 3695 | } |
| 3696 | |
| 3697 | UNIMPLEMENTED(); // FIXME |
| 3698 | } |
| 3699 | catch(std::bad_alloc&) |
| 3700 | { |
| 3701 | return error(GL_OUT_OF_MEMORY); |
| 3702 | } |
| 3703 | } |
| 3704 | |
| 3705 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 3706 | { |
| 3707 | TRACE("GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f, GLfloat w = %f", index, x, y, z, w); |
| 3708 | |
| 3709 | try |
| 3710 | { |
| 3711 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3712 | { |
| 3713 | return error(GL_INVALID_VALUE); |
| 3714 | } |
| 3715 | |
| 3716 | UNIMPLEMENTED(); // FIXME |
| 3717 | } |
| 3718 | catch(std::bad_alloc&) |
| 3719 | { |
| 3720 | return error(GL_OUT_OF_MEMORY); |
| 3721 | } |
| 3722 | } |
| 3723 | |
| 3724 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 3725 | { |
| 3726 | TRACE("GLuint index = %d, const GLfloat* values = 0x%0.8p", index, values); |
| 3727 | |
| 3728 | try |
| 3729 | { |
| 3730 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3731 | { |
| 3732 | return error(GL_INVALID_VALUE); |
| 3733 | } |
| 3734 | |
| 3735 | UNIMPLEMENTED(); // FIXME |
| 3736 | } |
| 3737 | catch(std::bad_alloc&) |
| 3738 | { |
| 3739 | return error(GL_OUT_OF_MEMORY); |
| 3740 | } |
| 3741 | } |
| 3742 | |
| 3743 | void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) |
| 3744 | { |
| 3745 | TRACE("GLuint index = %d, GLint size = %d, GLenum type = 0x%X, GLboolean normalized = %d, GLsizei stride = %d, const void* ptr = 0x%0.8p", index, size, type, normalized, stride, ptr); |
| 3746 | |
| 3747 | try |
| 3748 | { |
| 3749 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3750 | { |
| 3751 | return error(GL_INVALID_VALUE); |
| 3752 | } |
| 3753 | |
| 3754 | if (size < 1 || size > 4) |
| 3755 | { |
| 3756 | return error(GL_INVALID_VALUE); |
| 3757 | } |
| 3758 | |
| 3759 | switch (type) |
| 3760 | { |
| 3761 | case GL_BYTE: |
| 3762 | case GL_UNSIGNED_BYTE: |
| 3763 | case GL_SHORT: |
| 3764 | case GL_UNSIGNED_SHORT: |
| 3765 | case GL_FIXED: |
| 3766 | case GL_FLOAT: |
| 3767 | break; |
| 3768 | default: |
| 3769 | return error(GL_INVALID_ENUM); |
| 3770 | } |
| 3771 | |
| 3772 | if (stride < 0) |
| 3773 | { |
| 3774 | return error(GL_INVALID_VALUE); |
| 3775 | } |
| 3776 | |
| 3777 | gl::Context *context = gl::getContext(); |
| 3778 | |
| 3779 | if (context) |
| 3780 | { |
| 3781 | context->vertexAttribute[index].boundBuffer = context->arrayBuffer; |
| 3782 | context->vertexAttribute[index].size = size; |
| 3783 | context->vertexAttribute[index].type = type; |
| 3784 | context->vertexAttribute[index].normalized = normalized; |
| 3785 | context->vertexAttribute[index].stride = stride; |
| 3786 | context->vertexAttribute[index].pointer = ptr; |
| 3787 | } |
| 3788 | } |
| 3789 | catch(std::bad_alloc&) |
| 3790 | { |
| 3791 | return error(GL_OUT_OF_MEMORY); |
| 3792 | } |
| 3793 | } |
| 3794 | |
| 3795 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 3796 | { |
| 3797 | TRACE("GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d", x, y, width, height); |
| 3798 | |
| 3799 | try |
| 3800 | { |
| 3801 | if (width < 0 || height < 0) |
| 3802 | { |
| 3803 | return error(GL_INVALID_VALUE); |
| 3804 | } |
| 3805 | |
| 3806 | gl::Context *context = gl::getContext(); |
| 3807 | |
| 3808 | if (context) |
| 3809 | { |
| 3810 | context->viewportX = x; |
| 3811 | context->viewportY = y; |
| 3812 | context->viewportWidth = width; |
| 3813 | context->viewportHeight = height; |
| 3814 | } |
| 3815 | } |
| 3816 | catch(std::bad_alloc&) |
| 3817 | { |
| 3818 | return error(GL_OUT_OF_MEMORY); |
| 3819 | } |
| 3820 | } |
| 3821 | |
| 3822 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels) |
| 3823 | { |
| 3824 | TRACE("GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, GLenum type = 0x%x, const void* pixels = 0x%0.8p", |
| 3825 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 3826 | |
| 3827 | try |
| 3828 | { |
| 3829 | UNIMPLEMENTED(); // FIXME |
| 3830 | } |
| 3831 | catch(std::bad_alloc&) |
| 3832 | { |
| 3833 | return error(GL_OUT_OF_MEMORY); |
| 3834 | } |
| 3835 | } |
| 3836 | } |