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