shannon.woods@transgaming.com | bdf2d80 | 2013-02-28 23:16:20 +0000 | [diff] [blame] | 1 | #include "precompiled.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2 | // |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 3 | // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4 | // Use of this source code is governed by a BSD-style license that can be |
| 5 | // found in the LICENSE file. |
| 6 | // |
| 7 | |
| 8 | // libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions. |
| 9 | |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 10 | #include "common/version.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 11 | |
| 12 | #include "libGLESv2/main.h" |
shannonwoods@chromium.org | a2ecfcc | 2013-05-30 00:11:59 +0000 | [diff] [blame] | 13 | #include "common/utilities.h" |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 14 | #include "libGLESv2/formatutils.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 15 | #include "libGLESv2/Buffer.h" |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 16 | #include "libGLESv2/Fence.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 17 | #include "libGLESv2/Framebuffer.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 18 | #include "libGLESv2/Renderbuffer.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 19 | #include "libGLESv2/Program.h" |
apatrick@chromium.org | ea09f9b | 2012-06-08 00:45:32 +0000 | [diff] [blame] | 20 | #include "libGLESv2/ProgramBinary.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 21 | #include "libGLESv2/Texture.h" |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 22 | #include "libGLESv2/Query.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 23 | #include "libGLESv2/Context.h" |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 24 | #include "libGLESv2/VertexArray.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 25 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 26 | #include "libGLESv2/validationES.h" |
| 27 | #include "libGLESv2/validationES2.h" |
| 28 | #include "libGLESv2/validationES3.h" |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 29 | |
| 30 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 31 | gl::Texture *getTargetTexture(gl::Context *context, GLenum target) |
| 32 | { |
| 33 | if (context->getClientVersion() < 3) |
| 34 | { |
| 35 | if (target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) |
| 36 | { |
| 37 | return NULL; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | switch (target) |
| 42 | { |
| 43 | case GL_TEXTURE_2D: return context->getTexture2D(); |
| 44 | case GL_TEXTURE_CUBE_MAP: return context->getTextureCubeMap(); |
| 45 | case GL_TEXTURE_3D: return context->getTexture3D(); |
| 46 | case GL_TEXTURE_2D_ARRAY: return context->getTexture2DArray(); |
| 47 | default: return NULL; |
| 48 | } |
| 49 | } |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 50 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 51 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 52 | extern "C" |
| 53 | { |
| 54 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 55 | // OpenGL ES 2.0 functions |
| 56 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 57 | void __stdcall glActiveTexture(GLenum texture) |
| 58 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 59 | EVENT("(GLenum texture = 0x%X)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 60 | |
| 61 | try |
| 62 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 63 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 64 | |
| 65 | if (context) |
| 66 | { |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 67 | if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1) |
| 68 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 69 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 70 | } |
| 71 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 72 | context->setActiveSampler(texture - GL_TEXTURE0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 73 | } |
| 74 | } |
| 75 | catch(std::bad_alloc&) |
| 76 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 77 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 78 | } |
| 79 | } |
| 80 | |
| 81 | void __stdcall glAttachShader(GLuint program, GLuint shader) |
| 82 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 83 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 84 | |
| 85 | try |
| 86 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 87 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 88 | |
| 89 | if (context) |
| 90 | { |
| 91 | gl::Program *programObject = context->getProgram(program); |
| 92 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 93 | |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 94 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 95 | { |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 96 | if (context->getShader(program)) |
| 97 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 98 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 99 | } |
| 100 | else |
| 101 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 102 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 103 | } |
| 104 | } |
| 105 | |
| 106 | if (!shaderObject) |
| 107 | { |
| 108 | if (context->getProgram(shader)) |
| 109 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 110 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 111 | } |
| 112 | else |
| 113 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 114 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 115 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | if (!programObject->attachShader(shaderObject)) |
| 119 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 120 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 121 | } |
| 122 | } |
| 123 | } |
| 124 | catch(std::bad_alloc&) |
| 125 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 126 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 127 | } |
| 128 | } |
| 129 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 130 | void __stdcall glBeginQueryEXT(GLenum target, GLuint id) |
| 131 | { |
| 132 | EVENT("(GLenum target = 0x%X, GLuint %d)", target, id); |
| 133 | |
| 134 | try |
| 135 | { |
| 136 | switch (target) |
| 137 | { |
| 138 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 139 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 140 | break; |
| 141 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 142 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | if (id == 0) |
| 146 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 147 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | gl::Context *context = gl::getNonLostContext(); |
| 151 | |
| 152 | if (context) |
| 153 | { |
| 154 | context->beginQuery(target, id); |
| 155 | } |
| 156 | } |
| 157 | catch(std::bad_alloc&) |
| 158 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 159 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 160 | } |
| 161 | } |
| 162 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 163 | void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 164 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 165 | EVENT("(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] | 166 | |
| 167 | try |
| 168 | { |
| 169 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 170 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 171 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 172 | } |
| 173 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 174 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 175 | |
| 176 | if (context) |
| 177 | { |
| 178 | gl::Program *programObject = context->getProgram(program); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 179 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 180 | if (!programObject) |
| 181 | { |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 182 | if (context->getShader(program)) |
| 183 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 184 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 185 | } |
| 186 | else |
| 187 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 188 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 189 | } |
| 190 | } |
| 191 | |
| 192 | if (strncmp(name, "gl_", 3) == 0) |
| 193 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 194 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | programObject->bindAttributeLocation(index, name); |
| 198 | } |
| 199 | } |
| 200 | catch(std::bad_alloc&) |
| 201 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 202 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 203 | } |
| 204 | } |
| 205 | |
| 206 | void __stdcall glBindBuffer(GLenum target, GLuint buffer) |
| 207 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 208 | EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 209 | |
| 210 | try |
| 211 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 212 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 213 | |
| 214 | if (context) |
| 215 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 216 | // Check ES3 specific targets |
| 217 | switch (target) |
| 218 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 219 | case GL_COPY_READ_BUFFER: |
| 220 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 221 | case GL_PIXEL_PACK_BUFFER: |
| 222 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 223 | case GL_UNIFORM_BUFFER: |
| 224 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 225 | if (context->getClientVersion() < 3) |
| 226 | { |
| 227 | return gl::error(GL_INVALID_ENUM); |
| 228 | } |
| 229 | } |
| 230 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 231 | switch (target) |
| 232 | { |
| 233 | case GL_ARRAY_BUFFER: |
| 234 | context->bindArrayBuffer(buffer); |
| 235 | return; |
| 236 | case GL_ELEMENT_ARRAY_BUFFER: |
| 237 | context->bindElementArrayBuffer(buffer); |
| 238 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 239 | case GL_COPY_READ_BUFFER: |
| 240 | context->bindCopyReadBuffer(buffer); |
| 241 | return; |
| 242 | case GL_COPY_WRITE_BUFFER: |
| 243 | context->bindCopyWriteBuffer(buffer); |
| 244 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 245 | case GL_PIXEL_PACK_BUFFER: |
| 246 | context->bindPixelPackBuffer(buffer); |
| 247 | return; |
| 248 | case GL_PIXEL_UNPACK_BUFFER: |
| 249 | context->bindPixelUnpackBuffer(buffer); |
| 250 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 251 | case GL_UNIFORM_BUFFER: |
| 252 | context->bindGenericUniformBuffer(buffer); |
| 253 | return; |
| 254 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 7a1ebad | 2013-05-30 00:05:20 +0000 | [diff] [blame] | 255 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 256 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 257 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 258 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 259 | } |
| 260 | } |
| 261 | } |
| 262 | catch(std::bad_alloc&) |
| 263 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 264 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 265 | } |
| 266 | } |
| 267 | |
| 268 | void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer) |
| 269 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 270 | EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 271 | |
| 272 | try |
| 273 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 274 | if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 275 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 276 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 277 | } |
| 278 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 279 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 280 | |
| 281 | if (context) |
| 282 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 283 | if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 284 | { |
| 285 | context->bindReadFramebuffer(framebuffer); |
| 286 | } |
| 287 | |
| 288 | if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 289 | { |
| 290 | context->bindDrawFramebuffer(framebuffer); |
| 291 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 292 | } |
| 293 | } |
| 294 | catch(std::bad_alloc&) |
| 295 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 296 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 297 | } |
| 298 | } |
| 299 | |
| 300 | void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 301 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 302 | EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 303 | |
| 304 | try |
| 305 | { |
| 306 | if (target != GL_RENDERBUFFER) |
| 307 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 308 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 309 | } |
| 310 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 311 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 312 | |
| 313 | if (context) |
| 314 | { |
| 315 | context->bindRenderbuffer(renderbuffer); |
| 316 | } |
| 317 | } |
| 318 | catch(std::bad_alloc&) |
| 319 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 320 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 321 | } |
| 322 | } |
| 323 | |
| 324 | void __stdcall glBindTexture(GLenum target, GLuint texture) |
| 325 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 326 | EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 327 | |
| 328 | try |
| 329 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 330 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 331 | |
| 332 | if (context) |
| 333 | { |
| 334 | gl::Texture *textureObject = context->getTexture(texture); |
| 335 | |
| 336 | if (textureObject && textureObject->getTarget() != target && texture != 0) |
| 337 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 338 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | switch (target) |
| 342 | { |
| 343 | case GL_TEXTURE_2D: |
| 344 | context->bindTexture2D(texture); |
| 345 | return; |
| 346 | case GL_TEXTURE_CUBE_MAP: |
| 347 | context->bindTextureCubeMap(texture); |
| 348 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 349 | case GL_TEXTURE_3D: |
| 350 | if (context->getClientVersion() < 3) |
| 351 | { |
| 352 | return gl::error(GL_INVALID_ENUM); |
| 353 | } |
| 354 | context->bindTexture3D(texture); |
| 355 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 356 | case GL_TEXTURE_2D_ARRAY: |
| 357 | if (context->getClientVersion() < 3) |
| 358 | { |
| 359 | return gl::error(GL_INVALID_ENUM); |
| 360 | } |
| 361 | context->bindTexture2DArray(texture); |
| 362 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 363 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 364 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 365 | } |
| 366 | } |
| 367 | } |
| 368 | catch(std::bad_alloc&) |
| 369 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 370 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 371 | } |
| 372 | } |
| 373 | |
| 374 | void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 375 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 376 | EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 377 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 378 | |
| 379 | try |
| 380 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 381 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 382 | |
| 383 | if (context) |
| 384 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 385 | context->setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha)); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 386 | } |
| 387 | } |
| 388 | catch(std::bad_alloc&) |
| 389 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 390 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 391 | } |
| 392 | } |
| 393 | |
| 394 | void __stdcall glBlendEquation(GLenum mode) |
| 395 | { |
| 396 | glBlendEquationSeparate(mode, mode); |
| 397 | } |
| 398 | |
| 399 | void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 400 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 401 | EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 402 | |
| 403 | try |
| 404 | { |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 405 | gl::Context *context = gl::getNonLostContext(); |
| 406 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 407 | switch (modeRGB) |
| 408 | { |
| 409 | case GL_FUNC_ADD: |
| 410 | case GL_FUNC_SUBTRACT: |
| 411 | case GL_FUNC_REVERSE_SUBTRACT: |
| 412 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 413 | |
| 414 | case GL_MIN: |
| 415 | case GL_MAX: |
| 416 | if (context && context->getClientVersion() < 3) |
| 417 | { |
| 418 | return gl::error(GL_INVALID_ENUM); |
| 419 | } |
| 420 | break; |
| 421 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 422 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 423 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | switch (modeAlpha) |
| 427 | { |
| 428 | case GL_FUNC_ADD: |
| 429 | case GL_FUNC_SUBTRACT: |
| 430 | case GL_FUNC_REVERSE_SUBTRACT: |
| 431 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 432 | |
| 433 | case GL_MIN: |
| 434 | case GL_MAX: |
| 435 | if (context && context->getClientVersion() < 3) |
| 436 | { |
| 437 | return gl::error(GL_INVALID_ENUM); |
| 438 | } |
| 439 | break; |
| 440 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 441 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 442 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 443 | } |
| 444 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 445 | if (context) |
| 446 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 447 | context->setBlendEquation(modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 448 | } |
| 449 | } |
| 450 | catch(std::bad_alloc&) |
| 451 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 452 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 453 | } |
| 454 | } |
| 455 | |
| 456 | void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor) |
| 457 | { |
| 458 | glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor); |
| 459 | } |
| 460 | |
| 461 | void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 462 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 463 | EVENT("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 464 | srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 465 | |
| 466 | try |
| 467 | { |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 468 | gl::Context *context = gl::getNonLostContext(); |
| 469 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 470 | switch (srcRGB) |
| 471 | { |
| 472 | case GL_ZERO: |
| 473 | case GL_ONE: |
| 474 | case GL_SRC_COLOR: |
| 475 | case GL_ONE_MINUS_SRC_COLOR: |
| 476 | case GL_DST_COLOR: |
| 477 | case GL_ONE_MINUS_DST_COLOR: |
| 478 | case GL_SRC_ALPHA: |
| 479 | case GL_ONE_MINUS_SRC_ALPHA: |
| 480 | case GL_DST_ALPHA: |
| 481 | case GL_ONE_MINUS_DST_ALPHA: |
| 482 | case GL_CONSTANT_COLOR: |
| 483 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 484 | case GL_CONSTANT_ALPHA: |
| 485 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 486 | case GL_SRC_ALPHA_SATURATE: |
| 487 | break; |
| 488 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 489 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | switch (dstRGB) |
| 493 | { |
| 494 | case GL_ZERO: |
| 495 | case GL_ONE: |
| 496 | case GL_SRC_COLOR: |
| 497 | case GL_ONE_MINUS_SRC_COLOR: |
| 498 | case GL_DST_COLOR: |
| 499 | case GL_ONE_MINUS_DST_COLOR: |
| 500 | case GL_SRC_ALPHA: |
| 501 | case GL_ONE_MINUS_SRC_ALPHA: |
| 502 | case GL_DST_ALPHA: |
| 503 | case GL_ONE_MINUS_DST_ALPHA: |
| 504 | case GL_CONSTANT_COLOR: |
| 505 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 506 | case GL_CONSTANT_ALPHA: |
| 507 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 508 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 509 | |
| 510 | case GL_SRC_ALPHA_SATURATE: |
| 511 | if (!context || context->getClientVersion() < 3) |
| 512 | { |
| 513 | return gl::error(GL_INVALID_ENUM); |
| 514 | } |
| 515 | break; |
| 516 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 517 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 518 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | switch (srcAlpha) |
| 522 | { |
| 523 | case GL_ZERO: |
| 524 | case GL_ONE: |
| 525 | case GL_SRC_COLOR: |
| 526 | case GL_ONE_MINUS_SRC_COLOR: |
| 527 | case GL_DST_COLOR: |
| 528 | case GL_ONE_MINUS_DST_COLOR: |
| 529 | case GL_SRC_ALPHA: |
| 530 | case GL_ONE_MINUS_SRC_ALPHA: |
| 531 | case GL_DST_ALPHA: |
| 532 | case GL_ONE_MINUS_DST_ALPHA: |
| 533 | case GL_CONSTANT_COLOR: |
| 534 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 535 | case GL_CONSTANT_ALPHA: |
| 536 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 537 | case GL_SRC_ALPHA_SATURATE: |
| 538 | break; |
| 539 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 540 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | switch (dstAlpha) |
| 544 | { |
| 545 | case GL_ZERO: |
| 546 | case GL_ONE: |
| 547 | case GL_SRC_COLOR: |
| 548 | case GL_ONE_MINUS_SRC_COLOR: |
| 549 | case GL_DST_COLOR: |
| 550 | case GL_ONE_MINUS_DST_COLOR: |
| 551 | case GL_SRC_ALPHA: |
| 552 | case GL_ONE_MINUS_SRC_ALPHA: |
| 553 | case GL_DST_ALPHA: |
| 554 | case GL_ONE_MINUS_DST_ALPHA: |
| 555 | case GL_CONSTANT_COLOR: |
| 556 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 557 | case GL_CONSTANT_ALPHA: |
| 558 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 559 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 560 | |
| 561 | case GL_SRC_ALPHA_SATURATE: |
| 562 | if (!context || context->getClientVersion() < 3) |
| 563 | { |
| 564 | return gl::error(GL_INVALID_ENUM); |
| 565 | } |
| 566 | break; |
| 567 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 568 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 569 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 570 | } |
| 571 | |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 572 | bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR || |
| 573 | dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR); |
| 574 | |
| 575 | bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA || |
| 576 | dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA); |
| 577 | |
| 578 | if (constantColorUsed && constantAlphaUsed) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 579 | { |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 580 | ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR invalid under WebGL"); |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 581 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 582 | } |
| 583 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 584 | if (context) |
| 585 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 586 | context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 587 | } |
| 588 | } |
| 589 | catch(std::bad_alloc&) |
| 590 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 591 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 592 | } |
| 593 | } |
| 594 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 595 | 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] | 596 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 597 | EVENT("(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] | 598 | target, size, data, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 599 | |
| 600 | try |
| 601 | { |
| 602 | if (size < 0) |
| 603 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 604 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 605 | } |
| 606 | |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 607 | gl::Context *context = gl::getNonLostContext(); |
| 608 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 609 | switch (usage) |
| 610 | { |
| 611 | case GL_STREAM_DRAW: |
| 612 | case GL_STATIC_DRAW: |
| 613 | case GL_DYNAMIC_DRAW: |
| 614 | break; |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 615 | |
| 616 | case GL_STREAM_READ: |
| 617 | case GL_STREAM_COPY: |
| 618 | case GL_STATIC_READ: |
| 619 | case GL_STATIC_COPY: |
| 620 | case GL_DYNAMIC_READ: |
| 621 | case GL_DYNAMIC_COPY: |
| 622 | if (context && context->getClientVersion() < 3) |
| 623 | { |
| 624 | return gl::error(GL_INVALID_ENUM); |
| 625 | } |
| 626 | break; |
| 627 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 628 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 629 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 630 | } |
| 631 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 632 | if (context) |
| 633 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 634 | // Check ES3 specific targets |
| 635 | switch (target) |
| 636 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 637 | case GL_COPY_READ_BUFFER: |
| 638 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 639 | case GL_PIXEL_PACK_BUFFER: |
| 640 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 641 | case GL_UNIFORM_BUFFER: |
| 642 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 643 | if (context->getClientVersion() < 3) |
| 644 | { |
| 645 | return gl::error(GL_INVALID_ENUM); |
| 646 | } |
| 647 | } |
| 648 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 649 | gl::Buffer *buffer; |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 650 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 651 | switch (target) |
| 652 | { |
| 653 | case GL_ARRAY_BUFFER: |
| 654 | buffer = context->getArrayBuffer(); |
| 655 | break; |
| 656 | case GL_ELEMENT_ARRAY_BUFFER: |
| 657 | buffer = context->getElementArrayBuffer(); |
| 658 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 659 | case GL_COPY_READ_BUFFER: |
| 660 | buffer = context->getCopyReadBuffer(); |
| 661 | break; |
| 662 | case GL_COPY_WRITE_BUFFER: |
| 663 | buffer = context->getCopyWriteBuffer(); |
| 664 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 665 | case GL_PIXEL_PACK_BUFFER: |
| 666 | buffer = context->getPixelPackBuffer(); |
| 667 | break; |
| 668 | case GL_PIXEL_UNPACK_BUFFER: |
| 669 | buffer = context->getPixelUnpackBuffer(); |
| 670 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 671 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 672 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 673 | break; |
| 674 | case GL_UNIFORM_BUFFER: |
| 675 | buffer = context->getGenericUniformBuffer(); |
| 676 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 677 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 678 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | if (!buffer) |
| 682 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 683 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 684 | } |
| 685 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 686 | buffer->bufferData(data, size, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 687 | } |
| 688 | } |
| 689 | catch(std::bad_alloc&) |
| 690 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 691 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 692 | } |
| 693 | } |
| 694 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 695 | 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] | 696 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 697 | EVENT("(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] | 698 | target, offset, size, data); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 699 | |
| 700 | try |
| 701 | { |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 702 | if (size < 0 || offset < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 703 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 704 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 705 | } |
| 706 | |
daniel@transgaming.com | d4620a3 | 2010-03-21 04:31:28 +0000 | [diff] [blame] | 707 | if (data == NULL) |
| 708 | { |
| 709 | return; |
| 710 | } |
| 711 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 712 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 713 | |
| 714 | if (context) |
| 715 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 716 | // Check ES3 specific targets |
| 717 | switch (target) |
| 718 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 719 | case GL_COPY_READ_BUFFER: |
| 720 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 721 | case GL_PIXEL_PACK_BUFFER: |
| 722 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 723 | case GL_UNIFORM_BUFFER: |
| 724 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 725 | if (context->getClientVersion() < 3) |
| 726 | { |
| 727 | return gl::error(GL_INVALID_ENUM); |
| 728 | } |
| 729 | } |
| 730 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 731 | gl::Buffer *buffer; |
| 732 | |
| 733 | switch (target) |
| 734 | { |
| 735 | case GL_ARRAY_BUFFER: |
| 736 | buffer = context->getArrayBuffer(); |
| 737 | break; |
| 738 | case GL_ELEMENT_ARRAY_BUFFER: |
| 739 | buffer = context->getElementArrayBuffer(); |
| 740 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 741 | case GL_COPY_READ_BUFFER: |
| 742 | buffer = context->getCopyReadBuffer(); |
| 743 | break; |
| 744 | case GL_COPY_WRITE_BUFFER: |
| 745 | buffer = context->getCopyWriteBuffer(); |
| 746 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 747 | case GL_PIXEL_PACK_BUFFER: |
| 748 | buffer = context->getPixelPackBuffer(); |
| 749 | break; |
| 750 | case GL_PIXEL_UNPACK_BUFFER: |
| 751 | buffer = context->getPixelUnpackBuffer(); |
| 752 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 753 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 754 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 755 | break; |
| 756 | case GL_UNIFORM_BUFFER: |
| 757 | buffer = context->getGenericUniformBuffer(); |
| 758 | break; |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 759 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 760 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 761 | } |
| 762 | |
| 763 | if (!buffer) |
| 764 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 765 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 766 | } |
| 767 | |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 768 | if ((size_t)size + offset > buffer->size()) |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 769 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 770 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 771 | } |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 772 | |
| 773 | buffer->bufferSubData(data, size, offset); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 774 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 775 | } |
| 776 | catch(std::bad_alloc&) |
| 777 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 778 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 779 | } |
| 780 | } |
| 781 | |
| 782 | GLenum __stdcall glCheckFramebufferStatus(GLenum target) |
| 783 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 784 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 785 | |
| 786 | try |
| 787 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 788 | if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 789 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 790 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 791 | } |
| 792 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 793 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 794 | |
| 795 | if (context) |
| 796 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 797 | gl::Framebuffer *framebuffer = NULL; |
| 798 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 799 | { |
| 800 | framebuffer = context->getReadFramebuffer(); |
| 801 | } |
| 802 | else |
| 803 | { |
| 804 | framebuffer = context->getDrawFramebuffer(); |
| 805 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 806 | |
| 807 | return framebuffer->completeness(); |
| 808 | } |
| 809 | } |
| 810 | catch(std::bad_alloc&) |
| 811 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 812 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 813 | } |
| 814 | |
| 815 | return 0; |
| 816 | } |
| 817 | |
| 818 | void __stdcall glClear(GLbitfield mask) |
| 819 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 820 | EVENT("(GLbitfield mask = 0x%X)", mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 821 | |
| 822 | try |
| 823 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 824 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 825 | |
| 826 | if (context) |
| 827 | { |
| 828 | context->clear(mask); |
| 829 | } |
| 830 | } |
| 831 | catch(std::bad_alloc&) |
| 832 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 833 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 834 | } |
| 835 | } |
| 836 | |
| 837 | void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 838 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 839 | EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 840 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 841 | |
| 842 | try |
| 843 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 844 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 845 | |
| 846 | if (context) |
| 847 | { |
| 848 | context->setClearColor(red, green, blue, alpha); |
| 849 | } |
| 850 | } |
| 851 | catch(std::bad_alloc&) |
| 852 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 853 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 854 | } |
| 855 | } |
| 856 | |
| 857 | void __stdcall glClearDepthf(GLclampf depth) |
| 858 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 859 | EVENT("(GLclampf depth = %f)", depth); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 860 | |
| 861 | try |
| 862 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 863 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 864 | |
| 865 | if (context) |
| 866 | { |
| 867 | context->setClearDepth(depth); |
| 868 | } |
| 869 | } |
| 870 | catch(std::bad_alloc&) |
| 871 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 872 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 873 | } |
| 874 | } |
| 875 | |
| 876 | void __stdcall glClearStencil(GLint s) |
| 877 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 878 | EVENT("(GLint s = %d)", s); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 879 | |
| 880 | try |
| 881 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 882 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 883 | |
| 884 | if (context) |
| 885 | { |
| 886 | context->setClearStencil(s); |
| 887 | } |
| 888 | } |
| 889 | catch(std::bad_alloc&) |
| 890 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 891 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 892 | } |
| 893 | } |
| 894 | |
| 895 | void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 896 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 897 | EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 898 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 899 | |
| 900 | try |
| 901 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 902 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 903 | |
| 904 | if (context) |
| 905 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 906 | context->setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 907 | } |
| 908 | } |
| 909 | catch(std::bad_alloc&) |
| 910 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 911 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 912 | } |
| 913 | } |
| 914 | |
| 915 | void __stdcall glCompileShader(GLuint shader) |
| 916 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 917 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 918 | |
| 919 | try |
| 920 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 921 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 922 | |
| 923 | if (context) |
| 924 | { |
| 925 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 926 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 927 | if (!shaderObject) |
| 928 | { |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 929 | if (context->getProgram(shader)) |
| 930 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 931 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 932 | } |
| 933 | else |
| 934 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 935 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 936 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 937 | } |
| 938 | |
| 939 | shaderObject->compile(); |
| 940 | } |
| 941 | } |
| 942 | catch(std::bad_alloc&) |
| 943 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 944 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 945 | } |
| 946 | } |
| 947 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 948 | void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, |
| 949 | GLint border, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 950 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 951 | EVENT("(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] | 952 | "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] | 953 | target, level, internalformat, width, height, border, imageSize, data); |
| 954 | |
| 955 | try |
| 956 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 957 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 958 | |
| 959 | if (context) |
| 960 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 961 | if (context->getClientVersion() < 3 && |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 962 | !ValidateES2TexImageParameters(context, target, level, internalformat, true, false, |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 963 | 0, 0, width, height, 0, GL_NONE, GL_NONE, data)) |
| 964 | { |
| 965 | return; |
| 966 | } |
| 967 | |
| 968 | if (context->getClientVersion() >= 3 && |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 969 | !ValidateES3TexImageParameters(context, target, level, internalformat, true, false, |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 970 | 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 971 | { |
| 972 | return; |
| 973 | } |
| 974 | |
| 975 | if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 976 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 977 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 978 | } |
| 979 | |
| 980 | switch (target) |
| 981 | { |
| 982 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 983 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 984 | gl::Texture2D *texture = context->getTexture2D(); |
| 985 | texture->setCompressedImage(level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 986 | } |
| 987 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 988 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 989 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 990 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 991 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 992 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 993 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 994 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 995 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 996 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 997 | texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 998 | } |
| 999 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1000 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 1001 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1002 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 1003 | } |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 1004 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1005 | } |
| 1006 | catch(std::bad_alloc&) |
| 1007 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1008 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1009 | } |
| 1010 | } |
| 1011 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 1012 | void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 1013 | GLenum format, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1014 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1015 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 1016 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 1017 | "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1018 | target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 1019 | |
| 1020 | try |
| 1021 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1022 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 1023 | |
| 1024 | if (context) |
| 1025 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1026 | if (context->getClientVersion() < 3 && |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 1027 | !ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true, |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1028 | xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data)) |
| 1029 | { |
| 1030 | return; |
| 1031 | } |
| 1032 | |
| 1033 | if (context->getClientVersion() >= 3 && |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 1034 | !ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1035 | xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 1036 | { |
| 1037 | return; |
| 1038 | } |
| 1039 | |
| 1040 | if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 1041 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1042 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 1043 | } |
| 1044 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1045 | switch (target) |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 1046 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1047 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 1048 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1049 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 1050 | texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 1051 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1052 | break; |
| 1053 | |
| 1054 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 1055 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 1056 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 1057 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 1058 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 1059 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 1060 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1061 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 1062 | texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 1063 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1064 | break; |
| 1065 | |
| 1066 | default: |
| 1067 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 1068 | } |
| 1069 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1070 | } |
| 1071 | catch(std::bad_alloc&) |
| 1072 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1073 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1074 | } |
| 1075 | } |
| 1076 | |
| 1077 | void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) |
| 1078 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1079 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 1080 | "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] | 1081 | target, level, internalformat, x, y, width, height, border); |
| 1082 | |
| 1083 | try |
| 1084 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1085 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 1086 | |
| 1087 | if (context) |
| 1088 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1089 | if (context->getClientVersion() < 3 && |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 1090 | !ValidateES2CopyTexImageParameters(context, target, level, internalformat, false, |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1091 | 0, 0, x, y, width, height, border)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 1092 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1093 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 1094 | } |
| 1095 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1096 | if (context->getClientVersion() >= 3 && |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 1097 | !ValidateES3CopyTexImageParameters(context, target, level, internalformat, false, |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1098 | 0, 0, 0, x, y, width, height, border)) |
| 1099 | { |
| 1100 | return; |
| 1101 | } |
| 1102 | |
| 1103 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 1104 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 1105 | switch (target) |
| 1106 | { |
| 1107 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 1108 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1109 | gl::Texture2D *texture = context->getTexture2D(); |
| 1110 | texture->copyImage(level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 1111 | } |
| 1112 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1113 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 1114 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 1115 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 1116 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 1117 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 1118 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 1119 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 1120 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1121 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 1122 | texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 1123 | } |
| 1124 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1125 | |
| 1126 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1127 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 1128 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 1129 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1130 | } |
| 1131 | catch(std::bad_alloc&) |
| 1132 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1133 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1134 | } |
| 1135 | } |
| 1136 | |
| 1137 | void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 1138 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1139 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 1140 | "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] | 1141 | target, level, xoffset, yoffset, x, y, width, height); |
| 1142 | |
| 1143 | try |
| 1144 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1145 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 1146 | |
| 1147 | if (context) |
| 1148 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1149 | if (context->getClientVersion() < 3 && |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 1150 | !ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true, |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1151 | xoffset, yoffset, x, y, width, height, 0)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 1152 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1153 | return; |
| 1154 | } |
| 1155 | |
| 1156 | if (context->getClientVersion() >= 3 && |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 1157 | !ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1158 | xoffset, yoffset, 0, x, y, width, height, 0)) |
| 1159 | { |
| 1160 | return; |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 1161 | } |
| 1162 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 1163 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 1164 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1165 | switch (target) |
daniel@transgaming.com | bbc5779 | 2010-07-28 19:21:05 +0000 | [diff] [blame] | 1166 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1167 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 1168 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1169 | gl::Texture2D *texture = context->getTexture2D(); |
| 1170 | texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 1171 | } |
| 1172 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1173 | |
| 1174 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 1175 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 1176 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 1177 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 1178 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 1179 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 1180 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1181 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 1182 | texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 1183 | } |
| 1184 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1185 | |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 1186 | default: |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1187 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 1188 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 1189 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1190 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 1191 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1192 | catch(std::bad_alloc&) |
| 1193 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1194 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1195 | } |
| 1196 | } |
| 1197 | |
| 1198 | GLuint __stdcall glCreateProgram(void) |
| 1199 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1200 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1201 | |
| 1202 | try |
| 1203 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1204 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1205 | |
| 1206 | if (context) |
| 1207 | { |
| 1208 | return context->createProgram(); |
| 1209 | } |
| 1210 | } |
| 1211 | catch(std::bad_alloc&) |
| 1212 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1213 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1214 | } |
| 1215 | |
| 1216 | return 0; |
| 1217 | } |
| 1218 | |
| 1219 | GLuint __stdcall glCreateShader(GLenum type) |
| 1220 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1221 | EVENT("(GLenum type = 0x%X)", type); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1222 | |
| 1223 | try |
| 1224 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1225 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1226 | |
| 1227 | if (context) |
| 1228 | { |
| 1229 | switch (type) |
| 1230 | { |
| 1231 | case GL_FRAGMENT_SHADER: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 1232 | case GL_VERTEX_SHADER: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1233 | return context->createShader(type); |
| 1234 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1235 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1236 | } |
| 1237 | } |
| 1238 | } |
| 1239 | catch(std::bad_alloc&) |
| 1240 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1241 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1242 | } |
| 1243 | |
| 1244 | return 0; |
| 1245 | } |
| 1246 | |
| 1247 | void __stdcall glCullFace(GLenum mode) |
| 1248 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1249 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1250 | |
| 1251 | try |
| 1252 | { |
| 1253 | switch (mode) |
| 1254 | { |
| 1255 | case GL_FRONT: |
| 1256 | case GL_BACK: |
| 1257 | case GL_FRONT_AND_BACK: |
| 1258 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1259 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1260 | |
| 1261 | if (context) |
| 1262 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 1263 | context->setCullMode(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1264 | } |
| 1265 | } |
| 1266 | break; |
| 1267 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1268 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1269 | } |
| 1270 | } |
| 1271 | catch(std::bad_alloc&) |
| 1272 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1273 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1274 | } |
| 1275 | } |
| 1276 | |
| 1277 | void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers) |
| 1278 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1279 | EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1280 | |
| 1281 | try |
| 1282 | { |
| 1283 | if (n < 0) |
| 1284 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1285 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1286 | } |
| 1287 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1288 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1289 | |
| 1290 | if (context) |
| 1291 | { |
| 1292 | for (int i = 0; i < n; i++) |
| 1293 | { |
| 1294 | context->deleteBuffer(buffers[i]); |
| 1295 | } |
| 1296 | } |
| 1297 | } |
| 1298 | catch(std::bad_alloc&) |
| 1299 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1300 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1301 | } |
| 1302 | } |
| 1303 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1304 | void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences) |
| 1305 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1306 | EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1307 | |
| 1308 | try |
| 1309 | { |
| 1310 | if (n < 0) |
| 1311 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1312 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1313 | } |
| 1314 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1315 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1316 | |
| 1317 | if (context) |
| 1318 | { |
| 1319 | for (int i = 0; i < n; i++) |
| 1320 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 1321 | context->deleteFenceNV(fences[i]); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1322 | } |
| 1323 | } |
| 1324 | } |
| 1325 | catch(std::bad_alloc&) |
| 1326 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1327 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1328 | } |
| 1329 | } |
| 1330 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1331 | void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) |
| 1332 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1333 | EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1334 | |
| 1335 | try |
| 1336 | { |
| 1337 | if (n < 0) |
| 1338 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1339 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1340 | } |
| 1341 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1342 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1343 | |
| 1344 | if (context) |
| 1345 | { |
| 1346 | for (int i = 0; i < n; i++) |
| 1347 | { |
| 1348 | if (framebuffers[i] != 0) |
| 1349 | { |
| 1350 | context->deleteFramebuffer(framebuffers[i]); |
| 1351 | } |
| 1352 | } |
| 1353 | } |
| 1354 | } |
| 1355 | catch(std::bad_alloc&) |
| 1356 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1357 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1358 | } |
| 1359 | } |
| 1360 | |
| 1361 | void __stdcall glDeleteProgram(GLuint program) |
| 1362 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1363 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1364 | |
| 1365 | try |
| 1366 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 1367 | if (program == 0) |
| 1368 | { |
| 1369 | return; |
| 1370 | } |
| 1371 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1372 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1373 | |
| 1374 | if (context) |
| 1375 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 1376 | if (!context->getProgram(program)) |
| 1377 | { |
| 1378 | if(context->getShader(program)) |
| 1379 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1380 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 1381 | } |
| 1382 | else |
| 1383 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1384 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 1385 | } |
| 1386 | } |
| 1387 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1388 | context->deleteProgram(program); |
| 1389 | } |
| 1390 | } |
| 1391 | catch(std::bad_alloc&) |
| 1392 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1393 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1394 | } |
| 1395 | } |
| 1396 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1397 | void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids) |
| 1398 | { |
| 1399 | EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids); |
| 1400 | |
| 1401 | try |
| 1402 | { |
| 1403 | if (n < 0) |
| 1404 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1405 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1406 | } |
| 1407 | |
| 1408 | gl::Context *context = gl::getNonLostContext(); |
| 1409 | |
| 1410 | if (context) |
| 1411 | { |
| 1412 | for (int i = 0; i < n; i++) |
| 1413 | { |
| 1414 | context->deleteQuery(ids[i]); |
| 1415 | } |
| 1416 | } |
| 1417 | } |
| 1418 | catch(std::bad_alloc&) |
| 1419 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1420 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1421 | } |
| 1422 | } |
| 1423 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1424 | void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) |
| 1425 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1426 | EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1427 | |
| 1428 | try |
| 1429 | { |
| 1430 | if (n < 0) |
| 1431 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1432 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1433 | } |
| 1434 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1435 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1436 | |
| 1437 | if (context) |
| 1438 | { |
daniel@transgaming.com | e2b2212 | 2010-03-11 19:22:14 +0000 | [diff] [blame] | 1439 | for (int i = 0; i < n; i++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1440 | { |
| 1441 | context->deleteRenderbuffer(renderbuffers[i]); |
| 1442 | } |
| 1443 | } |
| 1444 | } |
| 1445 | catch(std::bad_alloc&) |
| 1446 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1447 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1448 | } |
| 1449 | } |
| 1450 | |
| 1451 | void __stdcall glDeleteShader(GLuint shader) |
| 1452 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1453 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1454 | |
| 1455 | try |
| 1456 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 1457 | if (shader == 0) |
| 1458 | { |
| 1459 | return; |
| 1460 | } |
| 1461 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1462 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1463 | |
| 1464 | if (context) |
| 1465 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 1466 | if (!context->getShader(shader)) |
| 1467 | { |
| 1468 | if(context->getProgram(shader)) |
| 1469 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1470 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 1471 | } |
| 1472 | else |
| 1473 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1474 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 1475 | } |
| 1476 | } |
| 1477 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1478 | context->deleteShader(shader); |
| 1479 | } |
| 1480 | } |
| 1481 | catch(std::bad_alloc&) |
| 1482 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1483 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1484 | } |
| 1485 | } |
| 1486 | |
| 1487 | void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures) |
| 1488 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1489 | EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1490 | |
| 1491 | try |
| 1492 | { |
| 1493 | if (n < 0) |
| 1494 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1495 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1496 | } |
| 1497 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1498 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1499 | |
| 1500 | if (context) |
| 1501 | { |
| 1502 | for (int i = 0; i < n; i++) |
| 1503 | { |
| 1504 | if (textures[i] != 0) |
| 1505 | { |
| 1506 | context->deleteTexture(textures[i]); |
| 1507 | } |
| 1508 | } |
| 1509 | } |
| 1510 | } |
| 1511 | catch(std::bad_alloc&) |
| 1512 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1513 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1514 | } |
| 1515 | } |
| 1516 | |
| 1517 | void __stdcall glDepthFunc(GLenum func) |
| 1518 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1519 | EVENT("(GLenum func = 0x%X)", func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1520 | |
| 1521 | try |
| 1522 | { |
| 1523 | switch (func) |
| 1524 | { |
| 1525 | case GL_NEVER: |
| 1526 | case GL_ALWAYS: |
| 1527 | case GL_LESS: |
| 1528 | case GL_LEQUAL: |
| 1529 | case GL_EQUAL: |
| 1530 | case GL_GREATER: |
| 1531 | case GL_GEQUAL: |
| 1532 | case GL_NOTEQUAL: |
| 1533 | break; |
| 1534 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1535 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1536 | } |
| 1537 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1538 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1539 | |
| 1540 | if (context) |
| 1541 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 1542 | context->setDepthFunc(func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1543 | } |
| 1544 | } |
| 1545 | catch(std::bad_alloc&) |
| 1546 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1547 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1548 | } |
| 1549 | } |
| 1550 | |
| 1551 | void __stdcall glDepthMask(GLboolean flag) |
| 1552 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 1553 | EVENT("(GLboolean flag = %u)", flag); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1554 | |
| 1555 | try |
| 1556 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1557 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1558 | |
| 1559 | if (context) |
| 1560 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 1561 | context->setDepthMask(flag != GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1562 | } |
| 1563 | } |
| 1564 | catch(std::bad_alloc&) |
| 1565 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1566 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1567 | } |
| 1568 | } |
| 1569 | |
| 1570 | void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar) |
| 1571 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1572 | EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1573 | |
| 1574 | try |
| 1575 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1576 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1577 | |
| 1578 | if (context) |
| 1579 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 1580 | context->setDepthRange(zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1581 | } |
| 1582 | } |
| 1583 | catch(std::bad_alloc&) |
| 1584 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1585 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1586 | } |
| 1587 | } |
| 1588 | |
| 1589 | void __stdcall glDetachShader(GLuint program, GLuint shader) |
| 1590 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1591 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1592 | |
| 1593 | try |
| 1594 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1595 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1596 | |
| 1597 | if (context) |
| 1598 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 1599 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1600 | gl::Program *programObject = context->getProgram(program); |
| 1601 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 1602 | |
| 1603 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1604 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 1605 | gl::Shader *shaderByProgramHandle; |
| 1606 | shaderByProgramHandle = context->getShader(program); |
| 1607 | if (!shaderByProgramHandle) |
| 1608 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1609 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 1610 | } |
| 1611 | else |
| 1612 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1613 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 1614 | } |
| 1615 | } |
| 1616 | |
| 1617 | if (!shaderObject) |
| 1618 | { |
| 1619 | gl::Program *programByShaderHandle = context->getProgram(shader); |
| 1620 | if (!programByShaderHandle) |
| 1621 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1622 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 1623 | } |
| 1624 | else |
| 1625 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1626 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 1627 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1628 | } |
| 1629 | |
| 1630 | if (!programObject->detachShader(shaderObject)) |
| 1631 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1632 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1633 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1634 | } |
| 1635 | } |
| 1636 | catch(std::bad_alloc&) |
| 1637 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1638 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1639 | } |
| 1640 | } |
| 1641 | |
| 1642 | void __stdcall glDisable(GLenum cap) |
| 1643 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1644 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1645 | |
| 1646 | try |
| 1647 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1648 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1649 | |
| 1650 | if (context) |
| 1651 | { |
| 1652 | switch (cap) |
| 1653 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 1654 | case GL_CULL_FACE: context->setCullFace(false); break; |
| 1655 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break; |
| 1656 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break; |
| 1657 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break; |
| 1658 | case GL_SCISSOR_TEST: context->setScissorTest(false); break; |
| 1659 | case GL_STENCIL_TEST: context->setStencilTest(false); break; |
| 1660 | case GL_DEPTH_TEST: context->setDepthTest(false); break; |
| 1661 | case GL_BLEND: context->setBlend(false); break; |
| 1662 | case GL_DITHER: context->setDither(false); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 1663 | |
| 1664 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 1665 | case GL_RASTERIZER_DISCARD: |
| 1666 | if (context->getClientVersion() < 3) |
| 1667 | { |
| 1668 | return gl::error(GL_INVALID_ENUM); |
| 1669 | } |
| 1670 | UNIMPLEMENTED(); |
| 1671 | break; |
| 1672 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1673 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1674 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1675 | } |
| 1676 | } |
| 1677 | } |
| 1678 | catch(std::bad_alloc&) |
| 1679 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1680 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1681 | } |
| 1682 | } |
| 1683 | |
| 1684 | void __stdcall glDisableVertexAttribArray(GLuint index) |
| 1685 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1686 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1687 | |
| 1688 | try |
| 1689 | { |
| 1690 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 1691 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1692 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1693 | } |
| 1694 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1695 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1696 | |
| 1697 | if (context) |
| 1698 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 1699 | context->setEnableVertexAttribArray(index, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1700 | } |
| 1701 | } |
| 1702 | catch(std::bad_alloc&) |
| 1703 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1704 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1705 | } |
| 1706 | } |
| 1707 | |
| 1708 | void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count) |
| 1709 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1710 | EVENT("(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] | 1711 | |
| 1712 | try |
| 1713 | { |
| 1714 | if (count < 0 || first < 0) |
| 1715 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1716 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1717 | } |
| 1718 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1719 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1720 | |
| 1721 | if (context) |
| 1722 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 1723 | context->drawArrays(mode, first, count, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1724 | } |
| 1725 | } |
| 1726 | catch(std::bad_alloc&) |
| 1727 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1728 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1729 | } |
| 1730 | } |
| 1731 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1732 | void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
| 1733 | { |
| 1734 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount); |
| 1735 | |
| 1736 | try |
| 1737 | { |
| 1738 | if (count < 0 || first < 0 || primcount < 0) |
| 1739 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1740 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1741 | } |
| 1742 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 1743 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1744 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 1745 | gl::Context *context = gl::getNonLostContext(); |
| 1746 | |
| 1747 | if (context) |
| 1748 | { |
| 1749 | context->drawArrays(mode, first, count, primcount); |
| 1750 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1751 | } |
| 1752 | } |
| 1753 | catch(std::bad_alloc&) |
| 1754 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1755 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1756 | } |
| 1757 | } |
| 1758 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 1759 | 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] | 1760 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1761 | EVENT("(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] | 1762 | mode, count, type, indices); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1763 | |
| 1764 | try |
| 1765 | { |
| 1766 | if (count < 0) |
| 1767 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1768 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1769 | } |
| 1770 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1771 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1772 | |
| 1773 | if (context) |
| 1774 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 1775 | switch (type) |
| 1776 | { |
| 1777 | case GL_UNSIGNED_BYTE: |
| 1778 | case GL_UNSIGNED_SHORT: |
| 1779 | break; |
| 1780 | case GL_UNSIGNED_INT: |
| 1781 | if (!context->supports32bitIndices()) |
| 1782 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1783 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 1784 | } |
| 1785 | break; |
| 1786 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1787 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 1788 | } |
| 1789 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 1790 | context->drawElements(mode, count, type, indices, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1791 | } |
| 1792 | } |
| 1793 | catch(std::bad_alloc&) |
| 1794 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1795 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1796 | } |
| 1797 | } |
| 1798 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1799 | void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount) |
| 1800 | { |
| 1801 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)", |
| 1802 | mode, count, type, indices, primcount); |
| 1803 | |
| 1804 | try |
| 1805 | { |
| 1806 | if (count < 0 || primcount < 0) |
| 1807 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1808 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1809 | } |
| 1810 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 1811 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1812 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 1813 | gl::Context *context = gl::getNonLostContext(); |
| 1814 | |
| 1815 | if (context) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1816 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 1817 | switch (type) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1818 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 1819 | case GL_UNSIGNED_BYTE: |
| 1820 | case GL_UNSIGNED_SHORT: |
| 1821 | break; |
| 1822 | case GL_UNSIGNED_INT: |
| 1823 | if (!context->supports32bitIndices()) |
| 1824 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1825 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 1826 | } |
| 1827 | break; |
| 1828 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1829 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1830 | } |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 1831 | |
| 1832 | context->drawElements(mode, count, type, indices, primcount); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1833 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1834 | } |
| 1835 | } |
| 1836 | catch(std::bad_alloc&) |
| 1837 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1838 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1839 | } |
| 1840 | } |
| 1841 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1842 | void __stdcall glEnable(GLenum cap) |
| 1843 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1844 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1845 | |
| 1846 | try |
| 1847 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1848 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1849 | |
| 1850 | if (context) |
| 1851 | { |
| 1852 | switch (cap) |
| 1853 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 1854 | case GL_CULL_FACE: context->setCullFace(true); break; |
| 1855 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break; |
| 1856 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break; |
| 1857 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break; |
| 1858 | case GL_SCISSOR_TEST: context->setScissorTest(true); break; |
| 1859 | case GL_STENCIL_TEST: context->setStencilTest(true); break; |
| 1860 | case GL_DEPTH_TEST: context->setDepthTest(true); break; |
| 1861 | case GL_BLEND: context->setBlend(true); break; |
| 1862 | case GL_DITHER: context->setDither(true); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1863 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1864 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1865 | } |
| 1866 | } |
| 1867 | } |
| 1868 | catch(std::bad_alloc&) |
| 1869 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1870 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1871 | } |
| 1872 | } |
| 1873 | |
| 1874 | void __stdcall glEnableVertexAttribArray(GLuint index) |
| 1875 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1876 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1877 | |
| 1878 | try |
| 1879 | { |
| 1880 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 1881 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1882 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1883 | } |
| 1884 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1885 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1886 | |
| 1887 | if (context) |
| 1888 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 1889 | context->setEnableVertexAttribArray(index, true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1890 | } |
| 1891 | } |
| 1892 | catch(std::bad_alloc&) |
| 1893 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1894 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1895 | } |
| 1896 | } |
| 1897 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1898 | void __stdcall glEndQueryEXT(GLenum target) |
| 1899 | { |
| 1900 | EVENT("GLenum target = 0x%X)", target); |
| 1901 | |
| 1902 | try |
| 1903 | { |
| 1904 | switch (target) |
| 1905 | { |
| 1906 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 1907 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 1908 | break; |
| 1909 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1910 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1911 | } |
| 1912 | |
| 1913 | gl::Context *context = gl::getNonLostContext(); |
| 1914 | |
| 1915 | if (context) |
| 1916 | { |
| 1917 | context->endQuery(target); |
| 1918 | } |
| 1919 | } |
| 1920 | catch(std::bad_alloc&) |
| 1921 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1922 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1923 | } |
| 1924 | } |
| 1925 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1926 | void __stdcall glFinishFenceNV(GLuint fence) |
| 1927 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1928 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1929 | |
| 1930 | try |
| 1931 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1932 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1933 | |
| 1934 | if (context) |
| 1935 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 1936 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1937 | |
| 1938 | if (fenceObject == NULL) |
| 1939 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1940 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1941 | } |
| 1942 | |
Jamie Madill | fb9a740 | 2013-07-26 11:55:01 -0400 | [diff] [blame] | 1943 | if (fenceObject->isFence() != GL_TRUE) |
| 1944 | { |
| 1945 | return gl::error(GL_INVALID_OPERATION); |
| 1946 | } |
| 1947 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1948 | fenceObject->finishFence(); |
| 1949 | } |
| 1950 | } |
| 1951 | catch(std::bad_alloc&) |
| 1952 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1953 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1954 | } |
| 1955 | } |
| 1956 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1957 | void __stdcall glFinish(void) |
| 1958 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1959 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1960 | |
| 1961 | try |
| 1962 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1963 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1964 | |
| 1965 | if (context) |
| 1966 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 1967 | context->sync(true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1968 | } |
| 1969 | } |
| 1970 | catch(std::bad_alloc&) |
| 1971 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1972 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1973 | } |
| 1974 | } |
| 1975 | |
| 1976 | void __stdcall glFlush(void) |
| 1977 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1978 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1979 | |
| 1980 | try |
| 1981 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1982 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1983 | |
| 1984 | if (context) |
| 1985 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 1986 | context->sync(false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1987 | } |
| 1988 | } |
| 1989 | catch(std::bad_alloc&) |
| 1990 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1991 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1992 | } |
| 1993 | } |
| 1994 | |
| 1995 | void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) |
| 1996 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1997 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 1998 | "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1999 | |
| 2000 | try |
| 2001 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2002 | if ((target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE) |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 2003 | || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2004 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2005 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2006 | } |
| 2007 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2008 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2009 | |
| 2010 | if (context) |
| 2011 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2012 | gl::Framebuffer *framebuffer = NULL; |
| 2013 | GLuint framebufferHandle = 0; |
| 2014 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 2015 | { |
| 2016 | framebuffer = context->getReadFramebuffer(); |
| 2017 | framebufferHandle = context->getReadFramebufferHandle(); |
| 2018 | } |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 2019 | else |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2020 | { |
| 2021 | framebuffer = context->getDrawFramebuffer(); |
| 2022 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 2023 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2024 | |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 2025 | if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2026 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2027 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2028 | } |
| 2029 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2030 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2031 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2032 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 2033 | |
| 2034 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 2035 | { |
| 2036 | return gl::error(GL_INVALID_VALUE); |
| 2037 | } |
| 2038 | |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 2039 | framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2040 | } |
| 2041 | else |
| 2042 | { |
| 2043 | switch (attachment) |
| 2044 | { |
| 2045 | case GL_DEPTH_ATTACHMENT: |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 2046 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2047 | break; |
| 2048 | case GL_STENCIL_ATTACHMENT: |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 2049 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2050 | break; |
Geoff Lang | 7e9ee23 | 2013-08-05 10:18:42 -0400 | [diff] [blame] | 2051 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 2052 | if (context->getClientVersion() < 3) |
| 2053 | { |
| 2054 | return gl::error(GL_INVALID_ENUM); |
| 2055 | } |
| 2056 | framebuffer->setDepthStencilBuffer(GL_RENDERBUFFER, renderbuffer, 0, 0); |
| 2057 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2058 | default: |
| 2059 | return gl::error(GL_INVALID_ENUM); |
| 2060 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2061 | } |
| 2062 | } |
| 2063 | } |
| 2064 | catch(std::bad_alloc&) |
| 2065 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2066 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2067 | } |
| 2068 | } |
| 2069 | |
| 2070 | void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) |
| 2071 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2072 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 2073 | "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2074 | |
| 2075 | try |
| 2076 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2077 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2078 | if (context) |
| 2079 | { |
Geoff Lang | 3ed0c48 | 2013-07-25 17:03:18 -0400 | [diff] [blame] | 2080 | if (context->getClientVersion() < 3 && |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 2081 | !ValidateES2FramebufferTextureParameters(context, target, attachment, textarget, texture, level)) |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2082 | { |
Geoff Lang | 3ed0c48 | 2013-07-25 17:03:18 -0400 | [diff] [blame] | 2083 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2084 | } |
Geoff Lang | 3ed0c48 | 2013-07-25 17:03:18 -0400 | [diff] [blame] | 2085 | |
| 2086 | if (context->getClientVersion() >= 3 && |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 2087 | !ValidateES3FramebufferTextureParameters(context, target, attachment, textarget, texture, level, 0, false)) |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2088 | { |
Geoff Lang | 3ed0c48 | 2013-07-25 17:03:18 -0400 | [diff] [blame] | 2089 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2090 | } |
| 2091 | |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 2092 | if (texture == 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2093 | { |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 2094 | textarget = GL_NONE; |
| 2095 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2096 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2097 | gl::Framebuffer *framebuffer = NULL; |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2098 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 2099 | { |
| 2100 | framebuffer = context->getReadFramebuffer(); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2101 | } |
| 2102 | else |
| 2103 | { |
| 2104 | framebuffer = context->getDrawFramebuffer(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2105 | } |
| 2106 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2107 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 2108 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2109 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 2110 | framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2111 | } |
| 2112 | else |
| 2113 | { |
| 2114 | switch (attachment) |
| 2115 | { |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 2116 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, 0); break; |
| 2117 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, 0); break; |
| 2118 | case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, 0); break; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2119 | } |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 2120 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2121 | } |
| 2122 | } |
| 2123 | catch(std::bad_alloc&) |
| 2124 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2125 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2126 | } |
| 2127 | } |
| 2128 | |
| 2129 | void __stdcall glFrontFace(GLenum mode) |
| 2130 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2131 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2132 | |
| 2133 | try |
| 2134 | { |
| 2135 | switch (mode) |
| 2136 | { |
| 2137 | case GL_CW: |
| 2138 | case GL_CCW: |
| 2139 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2140 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2141 | |
| 2142 | if (context) |
| 2143 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2144 | context->setFrontFace(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2145 | } |
| 2146 | } |
| 2147 | break; |
| 2148 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2149 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2150 | } |
| 2151 | } |
| 2152 | catch(std::bad_alloc&) |
| 2153 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2154 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2155 | } |
| 2156 | } |
| 2157 | |
| 2158 | void __stdcall glGenBuffers(GLsizei n, GLuint* buffers) |
| 2159 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2160 | EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2161 | |
| 2162 | try |
| 2163 | { |
| 2164 | if (n < 0) |
| 2165 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2166 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2167 | } |
| 2168 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2169 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2170 | |
| 2171 | if (context) |
| 2172 | { |
| 2173 | for (int i = 0; i < n; i++) |
| 2174 | { |
| 2175 | buffers[i] = context->createBuffer(); |
| 2176 | } |
| 2177 | } |
| 2178 | } |
| 2179 | catch(std::bad_alloc&) |
| 2180 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2181 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2182 | } |
| 2183 | } |
| 2184 | |
| 2185 | void __stdcall glGenerateMipmap(GLenum target) |
| 2186 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2187 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2188 | |
| 2189 | try |
| 2190 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2191 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 2192 | |
| 2193 | if (context) |
| 2194 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 2195 | gl::Texture *texture = NULL; |
| 2196 | GLint internalFormat = GL_NONE; |
| 2197 | bool isCompressed = false; |
| 2198 | bool isDepth = false; |
| 2199 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 2200 | switch (target) |
| 2201 | { |
| 2202 | case GL_TEXTURE_2D: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 2203 | { |
| 2204 | gl::Texture2D *tex2d = context->getTexture2D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 2205 | if (tex2d) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 2206 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 2207 | internalFormat = tex2d->getInternalFormat(0); |
| 2208 | isCompressed = tex2d->isCompressed(0); |
| 2209 | isDepth = tex2d->isDepth(0); |
| 2210 | texture = tex2d; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 2211 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 2212 | break; |
| 2213 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 2214 | |
| 2215 | case GL_TEXTURE_CUBE_MAP: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 2216 | { |
| 2217 | gl::TextureCubeMap *texcube = context->getTextureCubeMap(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 2218 | if (texcube) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 2219 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 2220 | internalFormat = texcube->getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 2221 | isCompressed = texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 2222 | isDepth = false; |
| 2223 | texture = texcube; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 2224 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 2225 | break; |
| 2226 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 2227 | |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 2228 | case GL_TEXTURE_3D: |
| 2229 | { |
| 2230 | if (context->getClientVersion() < 3) |
| 2231 | { |
| 2232 | return gl::error(GL_INVALID_ENUM); |
| 2233 | } |
| 2234 | |
| 2235 | gl::Texture3D *tex3D = context->getTexture3D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 2236 | if (tex3D) |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 2237 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 2238 | internalFormat = tex3D->getInternalFormat(0); |
| 2239 | isCompressed = tex3D->isCompressed(0); |
| 2240 | isDepth = tex3D->isDepth(0); |
| 2241 | texture = tex3D; |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 2242 | } |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 2243 | break; |
| 2244 | } |
| 2245 | |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 2246 | case GL_TEXTURE_2D_ARRAY: |
| 2247 | { |
| 2248 | if (context->getClientVersion() < 3) |
| 2249 | { |
| 2250 | return gl::error(GL_INVALID_ENUM); |
| 2251 | } |
| 2252 | |
| 2253 | gl::Texture2DArray *tex2darr = context->getTexture2DArray(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 2254 | if (tex2darr) |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 2255 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 2256 | internalFormat = tex2darr->getInternalFormat(0); |
| 2257 | isCompressed = tex2darr->isCompressed(0); |
| 2258 | isDepth = tex2darr->isDepth(0); |
| 2259 | texture = tex2darr; |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 2260 | } |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 2261 | break; |
| 2262 | } |
| 2263 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 2264 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2265 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 2266 | } |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 2267 | |
| 2268 | if (!texture) |
| 2269 | { |
| 2270 | return gl::error(GL_INVALID_OPERATION); |
| 2271 | } |
| 2272 | |
| 2273 | // Internally, all texture formats are sized so checking if the format |
| 2274 | // is color renderable and filterable will not fail. |
| 2275 | if (isDepth || isCompressed || |
| 2276 | !gl::IsColorRenderingSupported(internalFormat, context) || |
| 2277 | !gl::IsTextureFilteringSupported(internalFormat, context)) |
| 2278 | { |
| 2279 | return gl::error(GL_INVALID_OPERATION); |
| 2280 | } |
| 2281 | |
| 2282 | texture->generateMipmaps(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 2283 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2284 | } |
| 2285 | catch(std::bad_alloc&) |
| 2286 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2287 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2288 | } |
| 2289 | } |
| 2290 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2291 | void __stdcall glGenFencesNV(GLsizei n, GLuint* fences) |
| 2292 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2293 | EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2294 | |
| 2295 | try |
| 2296 | { |
| 2297 | if (n < 0) |
| 2298 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2299 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2300 | } |
| 2301 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2302 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2303 | |
| 2304 | if (context) |
| 2305 | { |
| 2306 | for (int i = 0; i < n; i++) |
| 2307 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 2308 | fences[i] = context->createFenceNV(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2309 | } |
| 2310 | } |
| 2311 | } |
| 2312 | catch(std::bad_alloc&) |
| 2313 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2314 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2315 | } |
| 2316 | } |
| 2317 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2318 | void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers) |
| 2319 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2320 | EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2321 | |
| 2322 | try |
| 2323 | { |
| 2324 | if (n < 0) |
| 2325 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2326 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2327 | } |
| 2328 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2329 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2330 | |
| 2331 | if (context) |
| 2332 | { |
| 2333 | for (int i = 0; i < n; i++) |
| 2334 | { |
| 2335 | framebuffers[i] = context->createFramebuffer(); |
| 2336 | } |
| 2337 | } |
| 2338 | } |
| 2339 | catch(std::bad_alloc&) |
| 2340 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2341 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2342 | } |
| 2343 | } |
| 2344 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2345 | void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids) |
| 2346 | { |
| 2347 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 2348 | |
| 2349 | try |
| 2350 | { |
| 2351 | if (n < 0) |
| 2352 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2353 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2354 | } |
| 2355 | |
| 2356 | gl::Context *context = gl::getNonLostContext(); |
| 2357 | |
| 2358 | if (context) |
| 2359 | { |
| 2360 | for (int i = 0; i < n; i++) |
| 2361 | { |
| 2362 | ids[i] = context->createQuery(); |
| 2363 | } |
| 2364 | } |
| 2365 | } |
| 2366 | catch(std::bad_alloc&) |
| 2367 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2368 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2369 | } |
| 2370 | } |
| 2371 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2372 | void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) |
| 2373 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2374 | EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2375 | |
| 2376 | try |
| 2377 | { |
| 2378 | if (n < 0) |
| 2379 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2380 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2381 | } |
| 2382 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2383 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2384 | |
| 2385 | if (context) |
| 2386 | { |
| 2387 | for (int i = 0; i < n; i++) |
| 2388 | { |
| 2389 | renderbuffers[i] = context->createRenderbuffer(); |
| 2390 | } |
| 2391 | } |
| 2392 | } |
| 2393 | catch(std::bad_alloc&) |
| 2394 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2395 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2396 | } |
| 2397 | } |
| 2398 | |
| 2399 | void __stdcall glGenTextures(GLsizei n, GLuint* textures) |
| 2400 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2401 | EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2402 | |
| 2403 | try |
| 2404 | { |
| 2405 | if (n < 0) |
| 2406 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2407 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2408 | } |
| 2409 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2410 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2411 | |
| 2412 | if (context) |
| 2413 | { |
| 2414 | for (int i = 0; i < n; i++) |
| 2415 | { |
| 2416 | textures[i] = context->createTexture(); |
| 2417 | } |
| 2418 | } |
| 2419 | } |
| 2420 | catch(std::bad_alloc&) |
| 2421 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2422 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2423 | } |
| 2424 | } |
| 2425 | |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 2426 | 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] | 2427 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2428 | EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, " |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 2429 | "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] | 2430 | program, index, bufsize, length, size, type, name); |
| 2431 | |
| 2432 | try |
| 2433 | { |
| 2434 | if (bufsize < 0) |
| 2435 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2436 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2437 | } |
| 2438 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2439 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 2440 | |
| 2441 | if (context) |
| 2442 | { |
| 2443 | gl::Program *programObject = context->getProgram(program); |
| 2444 | |
| 2445 | if (!programObject) |
| 2446 | { |
| 2447 | if (context->getShader(program)) |
| 2448 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2449 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 2450 | } |
| 2451 | else |
| 2452 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2453 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 2454 | } |
| 2455 | } |
| 2456 | |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 2457 | if (index >= (GLuint)programObject->getActiveAttributeCount()) |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 2458 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2459 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 2460 | } |
| 2461 | |
| 2462 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 2463 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2464 | } |
| 2465 | catch(std::bad_alloc&) |
| 2466 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2467 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2468 | } |
| 2469 | } |
| 2470 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2471 | 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] | 2472 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2473 | EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2474 | "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] | 2475 | program, index, bufsize, length, size, type, name); |
| 2476 | |
| 2477 | try |
| 2478 | { |
| 2479 | if (bufsize < 0) |
| 2480 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2481 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2482 | } |
| 2483 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2484 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 2485 | |
| 2486 | if (context) |
| 2487 | { |
| 2488 | gl::Program *programObject = context->getProgram(program); |
| 2489 | |
| 2490 | if (!programObject) |
| 2491 | { |
| 2492 | if (context->getShader(program)) |
| 2493 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2494 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 2495 | } |
| 2496 | else |
| 2497 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2498 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 2499 | } |
| 2500 | } |
| 2501 | |
| 2502 | if (index >= (GLuint)programObject->getActiveUniformCount()) |
| 2503 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2504 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 2505 | } |
| 2506 | |
| 2507 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 2508 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2509 | } |
| 2510 | catch(std::bad_alloc&) |
| 2511 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2512 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2513 | } |
| 2514 | } |
| 2515 | |
| 2516 | void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) |
| 2517 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2518 | EVENT("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = 0x%0.8p, GLuint* shaders = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 2519 | program, maxcount, count, shaders); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2520 | |
| 2521 | try |
| 2522 | { |
| 2523 | if (maxcount < 0) |
| 2524 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2525 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2526 | } |
| 2527 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2528 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 2529 | |
| 2530 | if (context) |
| 2531 | { |
| 2532 | gl::Program *programObject = context->getProgram(program); |
| 2533 | |
| 2534 | if (!programObject) |
| 2535 | { |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 2536 | if (context->getShader(program)) |
| 2537 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2538 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 2539 | } |
| 2540 | else |
| 2541 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2542 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 2543 | } |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 2544 | } |
| 2545 | |
| 2546 | return programObject->getAttachedShaders(maxcount, count, shaders); |
| 2547 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2548 | } |
| 2549 | catch(std::bad_alloc&) |
| 2550 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2551 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2552 | } |
| 2553 | } |
| 2554 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2555 | int __stdcall glGetAttribLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2556 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2557 | EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2558 | |
| 2559 | try |
| 2560 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2561 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2562 | |
| 2563 | if (context) |
| 2564 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 2565 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2566 | gl::Program *programObject = context->getProgram(program); |
| 2567 | |
| 2568 | if (!programObject) |
| 2569 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 2570 | if (context->getShader(program)) |
| 2571 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2572 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 2573 | } |
| 2574 | else |
| 2575 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2576 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 2577 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2578 | } |
| 2579 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 2580 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 2581 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 2582 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2583 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 2584 | } |
| 2585 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 2586 | return programBinary->getAttributeLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2587 | } |
| 2588 | } |
| 2589 | catch(std::bad_alloc&) |
| 2590 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2591 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2592 | } |
| 2593 | |
| 2594 | return -1; |
| 2595 | } |
| 2596 | |
| 2597 | void __stdcall glGetBooleanv(GLenum pname, GLboolean* params) |
| 2598 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2599 | EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2600 | |
| 2601 | try |
| 2602 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2603 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 2604 | |
| 2605 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2606 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 2607 | if (!(context->getBooleanv(pname, params))) |
| 2608 | { |
| 2609 | GLenum nativeType; |
| 2610 | unsigned int numParams = 0; |
| 2611 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2612 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 2613 | |
| 2614 | if (numParams == 0) |
| 2615 | return; // it is known that the pname is valid, but there are no parameters to return |
| 2616 | |
| 2617 | if (nativeType == GL_FLOAT) |
| 2618 | { |
| 2619 | GLfloat *floatParams = NULL; |
| 2620 | floatParams = new GLfloat[numParams]; |
| 2621 | |
| 2622 | context->getFloatv(pname, floatParams); |
| 2623 | |
| 2624 | for (unsigned int i = 0; i < numParams; ++i) |
| 2625 | { |
| 2626 | if (floatParams[i] == 0.0f) |
| 2627 | params[i] = GL_FALSE; |
| 2628 | else |
| 2629 | params[i] = GL_TRUE; |
| 2630 | } |
| 2631 | |
| 2632 | delete [] floatParams; |
| 2633 | } |
| 2634 | else if (nativeType == GL_INT) |
| 2635 | { |
| 2636 | GLint *intParams = NULL; |
| 2637 | intParams = new GLint[numParams]; |
| 2638 | |
| 2639 | context->getIntegerv(pname, intParams); |
| 2640 | |
| 2641 | for (unsigned int i = 0; i < numParams; ++i) |
| 2642 | { |
| 2643 | if (intParams[i] == 0) |
| 2644 | params[i] = GL_FALSE; |
| 2645 | else |
| 2646 | params[i] = GL_TRUE; |
| 2647 | } |
| 2648 | |
| 2649 | delete [] intParams; |
| 2650 | } |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 2651 | else if (nativeType == GL_INT_64_ANGLEX) |
| 2652 | { |
| 2653 | GLint64 *int64Params = NULL; |
| 2654 | int64Params = new GLint64[numParams]; |
| 2655 | |
| 2656 | context->getInteger64v(pname, int64Params); |
| 2657 | |
| 2658 | for (unsigned int i = 0; i < numParams; ++i) |
| 2659 | { |
| 2660 | if (int64Params[i] == 0) |
| 2661 | params[i] = GL_FALSE; |
| 2662 | else |
| 2663 | params[i] = GL_TRUE; |
| 2664 | } |
| 2665 | |
| 2666 | delete [] int64Params; |
| 2667 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 2668 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2669 | } |
| 2670 | } |
| 2671 | catch(std::bad_alloc&) |
| 2672 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2673 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2674 | } |
| 2675 | } |
| 2676 | |
| 2677 | void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 2678 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2679 | EVENT("(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] | 2680 | |
| 2681 | try |
| 2682 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2683 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 2684 | |
| 2685 | if (context) |
| 2686 | { |
| 2687 | gl::Buffer *buffer; |
| 2688 | |
| 2689 | switch (target) |
| 2690 | { |
| 2691 | case GL_ARRAY_BUFFER: |
| 2692 | buffer = context->getArrayBuffer(); |
| 2693 | break; |
| 2694 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2695 | buffer = context->getElementArrayBuffer(); |
| 2696 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2697 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 2698 | } |
| 2699 | |
| 2700 | if (!buffer) |
| 2701 | { |
| 2702 | // A null buffer means that "0" is bound to the requested buffer target |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2703 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 2704 | } |
| 2705 | |
| 2706 | switch (pname) |
| 2707 | { |
| 2708 | case GL_BUFFER_USAGE: |
| 2709 | *params = buffer->usage(); |
| 2710 | break; |
| 2711 | case GL_BUFFER_SIZE: |
| 2712 | *params = buffer->size(); |
| 2713 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2714 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 2715 | } |
| 2716 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2717 | } |
| 2718 | catch(std::bad_alloc&) |
| 2719 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2720 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2721 | } |
| 2722 | } |
| 2723 | |
| 2724 | GLenum __stdcall glGetError(void) |
| 2725 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2726 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2727 | |
| 2728 | gl::Context *context = gl::getContext(); |
| 2729 | |
| 2730 | if (context) |
| 2731 | { |
daniel@transgaming.com | 82b2891 | 2011-12-12 21:01:35 +0000 | [diff] [blame] | 2732 | return context->getError(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2733 | } |
| 2734 | |
| 2735 | return GL_NO_ERROR; |
| 2736 | } |
| 2737 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2738 | void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 2739 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2740 | EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2741 | |
| 2742 | try |
| 2743 | { |
| 2744 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2745 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2746 | |
| 2747 | if (context) |
| 2748 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 2749 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2750 | |
| 2751 | if (fenceObject == NULL) |
| 2752 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2753 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2754 | } |
| 2755 | |
Jamie Madill | fb9a740 | 2013-07-26 11:55:01 -0400 | [diff] [blame] | 2756 | if (fenceObject->isFence() != GL_TRUE) |
| 2757 | { |
| 2758 | return gl::error(GL_INVALID_OPERATION); |
| 2759 | } |
| 2760 | |
| 2761 | switch (pname) |
| 2762 | { |
| 2763 | case GL_FENCE_STATUS_NV: |
| 2764 | case GL_FENCE_CONDITION_NV: |
| 2765 | break; |
| 2766 | |
| 2767 | default: return gl::error(GL_INVALID_ENUM); |
| 2768 | } |
| 2769 | |
| 2770 | params[0] = fenceObject->getFencei(pname); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2771 | } |
| 2772 | } |
| 2773 | catch(std::bad_alloc&) |
| 2774 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2775 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2776 | } |
| 2777 | } |
| 2778 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2779 | void __stdcall glGetFloatv(GLenum pname, GLfloat* params) |
| 2780 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2781 | EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2782 | |
| 2783 | try |
| 2784 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2785 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 2786 | |
| 2787 | if (context) |
| 2788 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 2789 | if (!(context->getFloatv(pname, params))) |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 2790 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 2791 | GLenum nativeType; |
| 2792 | unsigned int numParams = 0; |
| 2793 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2794 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 2795 | |
| 2796 | if (numParams == 0) |
| 2797 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 2798 | |
| 2799 | if (nativeType == GL_BOOL) |
| 2800 | { |
| 2801 | GLboolean *boolParams = NULL; |
| 2802 | boolParams = new GLboolean[numParams]; |
| 2803 | |
| 2804 | context->getBooleanv(pname, boolParams); |
| 2805 | |
| 2806 | for (unsigned int i = 0; i < numParams; ++i) |
| 2807 | { |
| 2808 | if (boolParams[i] == GL_FALSE) |
| 2809 | params[i] = 0.0f; |
| 2810 | else |
| 2811 | params[i] = 1.0f; |
| 2812 | } |
| 2813 | |
| 2814 | delete [] boolParams; |
| 2815 | } |
| 2816 | else if (nativeType == GL_INT) |
| 2817 | { |
| 2818 | GLint *intParams = NULL; |
| 2819 | intParams = new GLint[numParams]; |
| 2820 | |
| 2821 | context->getIntegerv(pname, intParams); |
| 2822 | |
| 2823 | for (unsigned int i = 0; i < numParams; ++i) |
| 2824 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 2825 | params[i] = static_cast<GLfloat>(intParams[i]); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 2826 | } |
| 2827 | |
| 2828 | delete [] intParams; |
| 2829 | } |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 2830 | else if (nativeType == GL_INT_64_ANGLEX) |
| 2831 | { |
| 2832 | GLint64 *int64Params = NULL; |
| 2833 | int64Params = new GLint64[numParams]; |
| 2834 | |
| 2835 | context->getInteger64v(pname, int64Params); |
| 2836 | |
| 2837 | for (unsigned int i = 0; i < numParams; ++i) |
| 2838 | { |
| 2839 | params[i] = static_cast<GLfloat>(int64Params[i]); |
| 2840 | } |
| 2841 | |
| 2842 | delete [] int64Params; |
| 2843 | } |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 2844 | } |
| 2845 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2846 | } |
| 2847 | catch(std::bad_alloc&) |
| 2848 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2849 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2850 | } |
| 2851 | } |
| 2852 | |
| 2853 | void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) |
| 2854 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2855 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 2856 | target, attachment, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2857 | |
| 2858 | try |
| 2859 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2860 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2861 | |
| 2862 | if (context) |
| 2863 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2864 | if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2865 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2866 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2867 | } |
| 2868 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2869 | gl::Framebuffer *framebuffer = NULL; |
| 2870 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 2871 | { |
| 2872 | if(context->getReadFramebufferHandle() == 0) |
| 2873 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2874 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2875 | } |
| 2876 | |
| 2877 | framebuffer = context->getReadFramebuffer(); |
| 2878 | } |
| 2879 | else |
| 2880 | { |
| 2881 | if (context->getDrawFramebufferHandle() == 0) |
| 2882 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2883 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2884 | } |
| 2885 | |
| 2886 | framebuffer = context->getDrawFramebuffer(); |
| 2887 | } |
| 2888 | |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2889 | GLenum attachmentType; |
| 2890 | GLuint attachmentHandle; |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 2891 | GLuint attachmentLevel; |
| 2892 | GLuint attachmentLayer; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2893 | |
| 2894 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2895 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2896 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 2897 | |
| 2898 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 2899 | { |
| 2900 | return gl::error(GL_INVALID_ENUM); |
| 2901 | } |
| 2902 | |
| 2903 | attachmentType = framebuffer->getColorbufferType(colorAttachment); |
| 2904 | attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment); |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 2905 | attachmentLevel = framebuffer->getColorbufferMipLevel(colorAttachment); |
| 2906 | attachmentLayer = framebuffer->getColorbufferLayer(colorAttachment); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2907 | } |
| 2908 | else |
| 2909 | { |
| 2910 | switch (attachment) |
| 2911 | { |
| 2912 | case GL_DEPTH_ATTACHMENT: |
| 2913 | attachmentType = framebuffer->getDepthbufferType(); |
| 2914 | attachmentHandle = framebuffer->getDepthbufferHandle(); |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 2915 | attachmentLevel = framebuffer->getDepthbufferMipLevel(); |
| 2916 | attachmentLayer = framebuffer->getDepthbufferLayer(); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2917 | break; |
| 2918 | case GL_STENCIL_ATTACHMENT: |
| 2919 | attachmentType = framebuffer->getStencilbufferType(); |
| 2920 | attachmentHandle = framebuffer->getStencilbufferHandle(); |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 2921 | attachmentLevel = framebuffer->getStencilbufferMipLevel(); |
| 2922 | attachmentLayer = framebuffer->getStencilbufferLayer(); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2923 | break; |
Geoff Lang | 55ba29c | 2013-07-11 16:57:53 -0400 | [diff] [blame] | 2924 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 2925 | if (context->getClientVersion() < 3) |
| 2926 | { |
| 2927 | return gl::error(GL_INVALID_ENUM); |
| 2928 | } |
| 2929 | if (framebuffer->getDepthbufferHandle() != framebuffer->getStencilbufferHandle()) |
| 2930 | { |
| 2931 | return gl::error(GL_INVALID_OPERATION); |
| 2932 | } |
| 2933 | attachmentType = framebuffer->getDepthStencilbufferType(); |
| 2934 | attachmentHandle = framebuffer->getDepthStencilbufferHandle(); |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 2935 | attachmentLevel = framebuffer->getDepthStencilbufferMipLevel(); |
| 2936 | attachmentLayer = framebuffer->getDepthStencilbufferLayer(); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2937 | default: return gl::error(GL_INVALID_ENUM); |
| 2938 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2939 | } |
| 2940 | |
| 2941 | GLenum attachmentObjectType; // Type category |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 2942 | if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2943 | { |
| 2944 | attachmentObjectType = attachmentType; |
| 2945 | } |
Geoff Lang | 0fe1949 | 2013-07-25 17:04:31 -0400 | [diff] [blame] | 2946 | else if (gl::IsInternalTextureTarget(attachmentType, context->getClientVersion())) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2947 | { |
| 2948 | attachmentObjectType = GL_TEXTURE; |
| 2949 | } |
apatrick@chromium.org | a1d8059 | 2012-01-25 21:52:10 +0000 | [diff] [blame] | 2950 | else |
| 2951 | { |
| 2952 | UNREACHABLE(); |
| 2953 | return; |
| 2954 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2955 | |
| 2956 | switch (pname) |
| 2957 | { |
| 2958 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 2959 | *params = attachmentObjectType; |
| 2960 | break; |
| 2961 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 2962 | if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE) |
| 2963 | { |
| 2964 | *params = attachmentHandle; |
| 2965 | } |
| 2966 | else |
| 2967 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2968 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2969 | } |
| 2970 | break; |
| 2971 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 2972 | if (attachmentObjectType == GL_TEXTURE) |
| 2973 | { |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 2974 | *params = attachmentLevel; |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2975 | } |
| 2976 | else |
| 2977 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2978 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2979 | } |
| 2980 | break; |
| 2981 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 2982 | if (attachmentObjectType == GL_TEXTURE) |
| 2983 | { |
daniel@transgaming.com | 19ffc24 | 2010-05-04 03:35:21 +0000 | [diff] [blame] | 2984 | if (gl::IsCubemapTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2985 | { |
| 2986 | *params = attachmentType; |
| 2987 | } |
| 2988 | else |
| 2989 | { |
| 2990 | *params = 0; |
| 2991 | } |
| 2992 | } |
| 2993 | else |
| 2994 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2995 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2996 | } |
| 2997 | break; |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 2998 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: |
| 2999 | if (context->getClientVersion() < 3) |
| 3000 | { |
| 3001 | return gl::error(GL_INVALID_ENUM); |
| 3002 | } |
| 3003 | if (attachmentObjectType == GL_TEXTURE) |
| 3004 | { |
| 3005 | *params = attachmentLayer; |
| 3006 | } |
| 3007 | else |
| 3008 | { |
| 3009 | return gl::error(GL_INVALID_ENUM); |
| 3010 | } |
| 3011 | break; |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 3012 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3013 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 3014 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3015 | } |
| 3016 | } |
| 3017 | catch(std::bad_alloc&) |
| 3018 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3019 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3020 | } |
| 3021 | } |
| 3022 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 3023 | GLenum __stdcall glGetGraphicsResetStatusEXT(void) |
| 3024 | { |
| 3025 | EVENT("()"); |
| 3026 | |
| 3027 | try |
| 3028 | { |
| 3029 | gl::Context *context = gl::getContext(); |
| 3030 | |
| 3031 | if (context) |
| 3032 | { |
| 3033 | return context->getResetStatus(); |
| 3034 | } |
| 3035 | |
| 3036 | return GL_NO_ERROR; |
| 3037 | } |
| 3038 | catch(std::bad_alloc&) |
| 3039 | { |
| 3040 | return GL_OUT_OF_MEMORY; |
| 3041 | } |
| 3042 | } |
| 3043 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3044 | void __stdcall glGetIntegerv(GLenum pname, GLint* params) |
| 3045 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3046 | EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3047 | |
| 3048 | try |
| 3049 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3050 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3051 | |
| 3052 | if (context) |
| 3053 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 3054 | if (!(context->getIntegerv(pname, params))) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3055 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 3056 | GLenum nativeType; |
| 3057 | unsigned int numParams = 0; |
| 3058 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3059 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3060 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 3061 | if (numParams == 0) |
| 3062 | return; // it is known that pname is valid, but there are no parameters to return |
| 3063 | |
| 3064 | if (nativeType == GL_BOOL) |
| 3065 | { |
| 3066 | GLboolean *boolParams = NULL; |
| 3067 | boolParams = new GLboolean[numParams]; |
| 3068 | |
| 3069 | context->getBooleanv(pname, boolParams); |
| 3070 | |
| 3071 | for (unsigned int i = 0; i < numParams; ++i) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3072 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 3073 | if (boolParams[i] == GL_FALSE) |
| 3074 | params[i] = 0; |
| 3075 | else |
| 3076 | params[i] = 1; |
| 3077 | } |
| 3078 | |
| 3079 | delete [] boolParams; |
| 3080 | } |
| 3081 | else if (nativeType == GL_FLOAT) |
| 3082 | { |
| 3083 | GLfloat *floatParams = NULL; |
| 3084 | floatParams = new GLfloat[numParams]; |
| 3085 | |
| 3086 | context->getFloatv(pname, floatParams); |
| 3087 | |
| 3088 | for (unsigned int i = 0; i < numParams; ++i) |
| 3089 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 3090 | // RGBA color values and DepthRangeF values are converted to integer using Equation 2.4 from Table 4.5 |
daniel@transgaming.com | c164135 | 2010-04-26 15:33:36 +0000 | [diff] [blame] | 3091 | if (pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE || pname == GL_BLEND_COLOR) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3092 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 3093 | params[i] = static_cast<GLint>((static_cast<GLfloat>(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3094 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 3095 | else |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 3096 | { |
Jamie Madill | af49691 | 2013-07-19 16:36:54 -0400 | [diff] [blame] | 3097 | params[i] = gl::iround<GLint>(floatParams[i]); |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 3098 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3099 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3100 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 3101 | delete [] floatParams; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3102 | } |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 3103 | else if (nativeType == GL_INT_64_ANGLEX) |
| 3104 | { |
| 3105 | GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min()); |
| 3106 | GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max()); |
| 3107 | GLint64 *int64Params = NULL; |
| 3108 | int64Params = new GLint64[numParams]; |
| 3109 | |
| 3110 | context->getInteger64v(pname, int64Params); |
| 3111 | |
| 3112 | for (unsigned int i = 0; i < numParams; ++i) |
| 3113 | { |
| 3114 | GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue); |
| 3115 | params[i] = static_cast<GLint>(clampedValue); |
| 3116 | } |
| 3117 | |
| 3118 | delete [] int64Params; |
| 3119 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3120 | } |
| 3121 | } |
| 3122 | } |
| 3123 | catch(std::bad_alloc&) |
| 3124 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3125 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3126 | } |
| 3127 | } |
| 3128 | |
| 3129 | void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params) |
| 3130 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3131 | EVENT("(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] | 3132 | |
| 3133 | try |
| 3134 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3135 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3136 | |
| 3137 | if (context) |
| 3138 | { |
| 3139 | gl::Program *programObject = context->getProgram(program); |
| 3140 | |
| 3141 | if (!programObject) |
| 3142 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3143 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3144 | } |
| 3145 | |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 3146 | if (context->getClientVersion() < 3) |
| 3147 | { |
| 3148 | switch (pname) |
| 3149 | { |
| 3150 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 3151 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 3152 | return gl::error(GL_INVALID_ENUM); |
| 3153 | } |
| 3154 | } |
| 3155 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3156 | switch (pname) |
| 3157 | { |
| 3158 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 3159 | *params = programObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3160 | return; |
| 3161 | case GL_LINK_STATUS: |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 3162 | *params = programObject->isLinked(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3163 | return; |
| 3164 | case GL_VALIDATE_STATUS: |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 3165 | *params = programObject->isValidated(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3166 | return; |
| 3167 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 3168 | *params = programObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3169 | return; |
| 3170 | case GL_ATTACHED_SHADERS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 3171 | *params = programObject->getAttachedShadersCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3172 | return; |
| 3173 | case GL_ACTIVE_ATTRIBUTES: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 3174 | *params = programObject->getActiveAttributeCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3175 | return; |
| 3176 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 3177 | *params = programObject->getActiveAttributeMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3178 | return; |
| 3179 | case GL_ACTIVE_UNIFORMS: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 3180 | *params = programObject->getActiveUniformCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3181 | return; |
| 3182 | case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 3183 | *params = programObject->getActiveUniformMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3184 | return; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 3185 | case GL_PROGRAM_BINARY_LENGTH_OES: |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 3186 | *params = programObject->getProgramBinaryLength(); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 3187 | return; |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 3188 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 3189 | *params = programObject->getActiveUniformBlockCount(); |
| 3190 | return; |
| 3191 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 3192 | *params = programObject->getActiveUniformBlockMaxLength(); |
| 3193 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3194 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3195 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3196 | } |
| 3197 | } |
| 3198 | } |
| 3199 | catch(std::bad_alloc&) |
| 3200 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3201 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3202 | } |
| 3203 | } |
| 3204 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3205 | void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3206 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3207 | EVENT("(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] | 3208 | program, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3209 | |
| 3210 | try |
| 3211 | { |
| 3212 | if (bufsize < 0) |
| 3213 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3214 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3215 | } |
| 3216 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3217 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 3218 | |
| 3219 | if (context) |
| 3220 | { |
| 3221 | gl::Program *programObject = context->getProgram(program); |
| 3222 | |
| 3223 | if (!programObject) |
| 3224 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3225 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 3226 | } |
| 3227 | |
| 3228 | programObject->getInfoLog(bufsize, length, infolog); |
| 3229 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3230 | } |
| 3231 | catch(std::bad_alloc&) |
| 3232 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3233 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3234 | } |
| 3235 | } |
| 3236 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3237 | void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params) |
| 3238 | { |
| 3239 | EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params); |
| 3240 | |
| 3241 | try |
| 3242 | { |
| 3243 | switch (pname) |
| 3244 | { |
| 3245 | case GL_CURRENT_QUERY_EXT: |
| 3246 | break; |
| 3247 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3248 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3249 | } |
| 3250 | |
| 3251 | gl::Context *context = gl::getNonLostContext(); |
| 3252 | |
| 3253 | if (context) |
| 3254 | { |
| 3255 | params[0] = context->getActiveQuery(target); |
| 3256 | } |
| 3257 | } |
| 3258 | catch(std::bad_alloc&) |
| 3259 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3260 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3261 | } |
| 3262 | } |
| 3263 | |
| 3264 | void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) |
| 3265 | { |
| 3266 | EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params); |
| 3267 | |
| 3268 | try |
| 3269 | { |
| 3270 | switch (pname) |
| 3271 | { |
| 3272 | case GL_QUERY_RESULT_EXT: |
| 3273 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 3274 | break; |
| 3275 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3276 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3277 | } |
| 3278 | gl::Context *context = gl::getNonLostContext(); |
| 3279 | |
| 3280 | if (context) |
| 3281 | { |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3282 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 3283 | |
| 3284 | if (!queryObject) |
| 3285 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3286 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3287 | } |
| 3288 | |
| 3289 | if (context->getActiveQuery(queryObject->getType()) == id) |
| 3290 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3291 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3292 | } |
| 3293 | |
| 3294 | switch(pname) |
| 3295 | { |
| 3296 | case GL_QUERY_RESULT_EXT: |
| 3297 | params[0] = queryObject->getResult(); |
| 3298 | break; |
| 3299 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 3300 | params[0] = queryObject->isResultAvailable(); |
| 3301 | break; |
| 3302 | default: |
| 3303 | ASSERT(false); |
| 3304 | } |
| 3305 | } |
| 3306 | } |
| 3307 | catch(std::bad_alloc&) |
| 3308 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3309 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3310 | } |
| 3311 | } |
| 3312 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3313 | void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 3314 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3315 | EVENT("(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] | 3316 | |
| 3317 | try |
| 3318 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3319 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 3320 | |
| 3321 | if (context) |
| 3322 | { |
| 3323 | if (target != GL_RENDERBUFFER) |
| 3324 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3325 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 3326 | } |
| 3327 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3328 | if (context->getRenderbufferHandle() == 0) |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 3329 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3330 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 3331 | } |
| 3332 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3333 | gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle()); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 3334 | |
| 3335 | switch (pname) |
| 3336 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 3337 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break; |
| 3338 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break; |
| 3339 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break; |
| 3340 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break; |
| 3341 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break; |
| 3342 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break; |
| 3343 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break; |
| 3344 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break; |
| 3345 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break; |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 3346 | case GL_RENDERBUFFER_SAMPLES_ANGLE: |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 3347 | if (context->getMaxSupportedSamples() != 0) |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 3348 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 3349 | *params = renderbuffer->getSamples(); |
| 3350 | } |
| 3351 | else |
| 3352 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3353 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 3354 | } |
| 3355 | break; |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 3356 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3357 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 3358 | } |
| 3359 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3360 | } |
| 3361 | catch(std::bad_alloc&) |
| 3362 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3363 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3364 | } |
| 3365 | } |
| 3366 | |
| 3367 | void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params) |
| 3368 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3369 | EVENT("(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] | 3370 | |
| 3371 | try |
| 3372 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3373 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3374 | |
| 3375 | if (context) |
| 3376 | { |
| 3377 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 3378 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3379 | if (!shaderObject) |
| 3380 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3381 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3382 | } |
| 3383 | |
| 3384 | switch (pname) |
| 3385 | { |
| 3386 | case GL_SHADER_TYPE: |
| 3387 | *params = shaderObject->getType(); |
| 3388 | return; |
| 3389 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 3390 | *params = shaderObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3391 | return; |
| 3392 | case GL_COMPILE_STATUS: |
| 3393 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; |
| 3394 | return; |
| 3395 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 3396 | *params = shaderObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3397 | return; |
| 3398 | case GL_SHADER_SOURCE_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 3399 | *params = shaderObject->getSourceLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3400 | return; |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 3401 | case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: |
| 3402 | *params = shaderObject->getTranslatedSourceLength(); |
| 3403 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3404 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3405 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3406 | } |
| 3407 | } |
| 3408 | } |
| 3409 | catch(std::bad_alloc&) |
| 3410 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3411 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3412 | } |
| 3413 | } |
| 3414 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3415 | void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3416 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3417 | EVENT("(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] | 3418 | shader, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3419 | |
| 3420 | try |
| 3421 | { |
| 3422 | if (bufsize < 0) |
| 3423 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3424 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3425 | } |
| 3426 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3427 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 3428 | |
| 3429 | if (context) |
| 3430 | { |
| 3431 | gl::Shader *shaderObject = context->getShader(shader); |
| 3432 | |
| 3433 | if (!shaderObject) |
| 3434 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3435 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 3436 | } |
| 3437 | |
| 3438 | shaderObject->getInfoLog(bufsize, length, infolog); |
| 3439 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3440 | } |
| 3441 | catch(std::bad_alloc&) |
| 3442 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3443 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3444 | } |
| 3445 | } |
| 3446 | |
| 3447 | void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) |
| 3448 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3449 | EVENT("(GLenum shadertype = 0x%X, GLenum precisiontype = 0x%X, GLint* range = 0x%0.8p, GLint* precision = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 3450 | shadertype, precisiontype, range, precision); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3451 | |
| 3452 | try |
| 3453 | { |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 3454 | switch (shadertype) |
| 3455 | { |
| 3456 | case GL_VERTEX_SHADER: |
| 3457 | case GL_FRAGMENT_SHADER: |
| 3458 | break; |
| 3459 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3460 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 3461 | } |
| 3462 | |
| 3463 | switch (precisiontype) |
| 3464 | { |
| 3465 | case GL_LOW_FLOAT: |
| 3466 | case GL_MEDIUM_FLOAT: |
| 3467 | case GL_HIGH_FLOAT: |
| 3468 | // Assume IEEE 754 precision |
| 3469 | range[0] = 127; |
| 3470 | range[1] = 127; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 3471 | *precision = 23; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 3472 | break; |
| 3473 | case GL_LOW_INT: |
| 3474 | case GL_MEDIUM_INT: |
| 3475 | case GL_HIGH_INT: |
| 3476 | // Some (most) hardware only supports single-precision floating-point numbers, |
| 3477 | // which can accurately represent integers up to +/-16777216 |
| 3478 | range[0] = 24; |
| 3479 | range[1] = 24; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 3480 | *precision = 0; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 3481 | break; |
| 3482 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3483 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 3484 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3485 | } |
| 3486 | catch(std::bad_alloc&) |
| 3487 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3488 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3489 | } |
| 3490 | } |
| 3491 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3492 | void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3493 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3494 | EVENT("(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] | 3495 | shader, bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3496 | |
| 3497 | try |
| 3498 | { |
| 3499 | if (bufsize < 0) |
| 3500 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3501 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3502 | } |
| 3503 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3504 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 3505 | |
| 3506 | if (context) |
| 3507 | { |
| 3508 | gl::Shader *shaderObject = context->getShader(shader); |
| 3509 | |
| 3510 | if (!shaderObject) |
| 3511 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3512 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 3513 | } |
| 3514 | |
| 3515 | shaderObject->getSource(bufsize, length, source); |
| 3516 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3517 | } |
| 3518 | catch(std::bad_alloc&) |
| 3519 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3520 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3521 | } |
| 3522 | } |
| 3523 | |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 3524 | void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
| 3525 | { |
| 3526 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)", |
| 3527 | shader, bufsize, length, source); |
| 3528 | |
| 3529 | try |
| 3530 | { |
| 3531 | if (bufsize < 0) |
| 3532 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3533 | return gl::error(GL_INVALID_VALUE); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 3534 | } |
| 3535 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3536 | gl::Context *context = gl::getNonLostContext(); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 3537 | |
| 3538 | if (context) |
| 3539 | { |
| 3540 | gl::Shader *shaderObject = context->getShader(shader); |
| 3541 | |
| 3542 | if (!shaderObject) |
| 3543 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3544 | return gl::error(GL_INVALID_OPERATION); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 3545 | } |
| 3546 | |
| 3547 | shaderObject->getTranslatedSource(bufsize, length, source); |
| 3548 | } |
| 3549 | } |
| 3550 | catch(std::bad_alloc&) |
| 3551 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3552 | return gl::error(GL_OUT_OF_MEMORY); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 3553 | } |
| 3554 | } |
| 3555 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3556 | const GLubyte* __stdcall glGetString(GLenum name) |
| 3557 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3558 | EVENT("(GLenum name = 0x%X)", name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3559 | |
| 3560 | try |
| 3561 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3562 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3e4c600 | 2010-05-05 18:50:13 +0000 | [diff] [blame] | 3563 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3564 | switch (name) |
| 3565 | { |
| 3566 | case GL_VENDOR: |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 3567 | return (GLubyte*)"Google Inc."; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3568 | case GL_RENDERER: |
daniel@transgaming.com | c23ff64 | 2011-08-16 20:28:45 +0000 | [diff] [blame] | 3569 | return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3570 | case GL_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 3571 | if (context->getClientVersion() == 2) |
| 3572 | { |
| 3573 | return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")"; |
| 3574 | } |
| 3575 | else |
| 3576 | { |
| 3577 | return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")"; |
| 3578 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3579 | case GL_SHADING_LANGUAGE_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 3580 | if (context->getClientVersion() == 2) |
| 3581 | { |
| 3582 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")"; |
| 3583 | } |
| 3584 | else |
| 3585 | { |
| 3586 | return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")"; |
| 3587 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3588 | case GL_EXTENSIONS: |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 3589 | return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : ""); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3590 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3591 | return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3592 | } |
| 3593 | } |
| 3594 | catch(std::bad_alloc&) |
| 3595 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3596 | return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3597 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3598 | } |
| 3599 | |
| 3600 | void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) |
| 3601 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3602 | EVENT("(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] | 3603 | |
| 3604 | try |
| 3605 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3606 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 3607 | |
| 3608 | if (context) |
| 3609 | { |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 3610 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 3611 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 3612 | if (!texture) |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 3613 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3614 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 3615 | } |
| 3616 | |
| 3617 | switch (pname) |
| 3618 | { |
| 3619 | case GL_TEXTURE_MAG_FILTER: |
| 3620 | *params = (GLfloat)texture->getMagFilter(); |
| 3621 | break; |
| 3622 | case GL_TEXTURE_MIN_FILTER: |
| 3623 | *params = (GLfloat)texture->getMinFilter(); |
| 3624 | break; |
| 3625 | case GL_TEXTURE_WRAP_S: |
| 3626 | *params = (GLfloat)texture->getWrapS(); |
| 3627 | break; |
| 3628 | case GL_TEXTURE_WRAP_T: |
| 3629 | *params = (GLfloat)texture->getWrapT(); |
| 3630 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 3631 | case GL_TEXTURE_WRAP_R: |
| 3632 | if (context->getClientVersion() < 3) |
| 3633 | { |
| 3634 | return gl::error(GL_INVALID_ENUM); |
| 3635 | } |
| 3636 | *params = (GLfloat)texture->getWrapR(); |
| 3637 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 3638 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 3639 | // Exposed to ES2.0 through EXT_texture_storage, no client version validation. |
daniel@transgaming.com | d30bd0a | 2011-11-11 04:10:34 +0000 | [diff] [blame] | 3640 | *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE); |
| 3641 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 3642 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 3643 | if (context->getClientVersion() < 3) |
| 3644 | { |
| 3645 | return gl::error(GL_INVALID_ENUM); |
| 3646 | } |
| 3647 | *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0); |
| 3648 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 3649 | case GL_TEXTURE_USAGE_ANGLE: |
| 3650 | *params = (GLfloat)texture->getUsage(); |
| 3651 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 3652 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 3653 | if (!context->supportsTextureFilterAnisotropy()) |
| 3654 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3655 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 3656 | } |
| 3657 | *params = (GLfloat)texture->getMaxAnisotropy(); |
| 3658 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 3659 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3660 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 3661 | } |
| 3662 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3663 | } |
| 3664 | catch(std::bad_alloc&) |
| 3665 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3666 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3667 | } |
| 3668 | } |
| 3669 | |
| 3670 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 3671 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3672 | EVENT("(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] | 3673 | |
| 3674 | try |
| 3675 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3676 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 3677 | |
| 3678 | if (context) |
| 3679 | { |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 3680 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 3681 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 3682 | if (!texture) |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 3683 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3684 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 3685 | } |
| 3686 | |
| 3687 | switch (pname) |
| 3688 | { |
| 3689 | case GL_TEXTURE_MAG_FILTER: |
| 3690 | *params = texture->getMagFilter(); |
| 3691 | break; |
| 3692 | case GL_TEXTURE_MIN_FILTER: |
| 3693 | *params = texture->getMinFilter(); |
| 3694 | break; |
| 3695 | case GL_TEXTURE_WRAP_S: |
| 3696 | *params = texture->getWrapS(); |
| 3697 | break; |
| 3698 | case GL_TEXTURE_WRAP_T: |
| 3699 | *params = texture->getWrapT(); |
| 3700 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 3701 | case GL_TEXTURE_WRAP_R: |
| 3702 | if (context->getClientVersion() < 3) |
| 3703 | { |
| 3704 | return gl::error(GL_INVALID_ENUM); |
| 3705 | } |
| 3706 | *params = texture->getWrapR(); |
| 3707 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 3708 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 3709 | // Exposed to ES2.0 through EXT_texture_storage, no client version validation. |
daniel@transgaming.com | d30bd0a | 2011-11-11 04:10:34 +0000 | [diff] [blame] | 3710 | *params = texture->isImmutable() ? GL_TRUE : GL_FALSE; |
| 3711 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 3712 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 3713 | if (context->getClientVersion() < 3) |
| 3714 | { |
| 3715 | return gl::error(GL_INVALID_ENUM); |
| 3716 | } |
| 3717 | *params = texture->isImmutable() ? texture->levelCount() : 0; |
| 3718 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 3719 | case GL_TEXTURE_USAGE_ANGLE: |
| 3720 | *params = texture->getUsage(); |
| 3721 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 3722 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 3723 | if (!context->supportsTextureFilterAnisotropy()) |
| 3724 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3725 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 3726 | } |
| 3727 | *params = (GLint)texture->getMaxAnisotropy(); |
| 3728 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 3729 | |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 3730 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3731 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 3732 | } |
| 3733 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3734 | } |
| 3735 | catch(std::bad_alloc&) |
| 3736 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3737 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3738 | } |
| 3739 | } |
| 3740 | |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3741 | void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
| 3742 | { |
| 3743 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)", |
| 3744 | program, location, bufSize, params); |
| 3745 | |
| 3746 | try |
| 3747 | { |
| 3748 | if (bufSize < 0) |
| 3749 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3750 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3751 | } |
| 3752 | |
| 3753 | gl::Context *context = gl::getNonLostContext(); |
| 3754 | |
| 3755 | if (context) |
| 3756 | { |
| 3757 | if (program == 0) |
| 3758 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3759 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3760 | } |
| 3761 | |
| 3762 | gl::Program *programObject = context->getProgram(program); |
| 3763 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 3764 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3765 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3766 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3767 | } |
| 3768 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 3769 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 3770 | if (!programBinary) |
| 3771 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3772 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 3773 | } |
| 3774 | |
| 3775 | if (!programBinary->getUniformfv(location, &bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3776 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3777 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3778 | } |
| 3779 | } |
| 3780 | } |
| 3781 | catch(std::bad_alloc&) |
| 3782 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3783 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3784 | } |
| 3785 | } |
| 3786 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3787 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 3788 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3789 | EVENT("(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] | 3790 | |
| 3791 | try |
| 3792 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3793 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3794 | |
| 3795 | if (context) |
| 3796 | { |
| 3797 | if (program == 0) |
| 3798 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3799 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3800 | } |
| 3801 | |
| 3802 | gl::Program *programObject = context->getProgram(program); |
| 3803 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 3804 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3805 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3806 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3807 | } |
| 3808 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 3809 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 3810 | if (!programBinary) |
| 3811 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3812 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 3813 | } |
| 3814 | |
| 3815 | if (!programBinary->getUniformfv(location, NULL, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3816 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3817 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3818 | } |
| 3819 | } |
| 3820 | } |
| 3821 | catch(std::bad_alloc&) |
| 3822 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3823 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3824 | } |
| 3825 | } |
| 3826 | |
| 3827 | void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) |
| 3828 | { |
| 3829 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)", |
| 3830 | program, location, bufSize, params); |
| 3831 | |
| 3832 | try |
| 3833 | { |
| 3834 | if (bufSize < 0) |
| 3835 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3836 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3837 | } |
| 3838 | |
| 3839 | gl::Context *context = gl::getNonLostContext(); |
| 3840 | |
| 3841 | if (context) |
| 3842 | { |
| 3843 | if (program == 0) |
| 3844 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3845 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3846 | } |
| 3847 | |
| 3848 | gl::Program *programObject = context->getProgram(program); |
| 3849 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 3850 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3851 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3852 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3853 | } |
| 3854 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 3855 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 3856 | if (!programBinary) |
| 3857 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3858 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 3859 | } |
| 3860 | |
| 3861 | if (!programBinary->getUniformiv(location, &bufSize, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3862 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3863 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3864 | } |
| 3865 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3866 | } |
| 3867 | catch(std::bad_alloc&) |
| 3868 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3869 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3870 | } |
| 3871 | } |
| 3872 | |
| 3873 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 3874 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3875 | EVENT("(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] | 3876 | |
| 3877 | try |
| 3878 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3879 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3880 | |
| 3881 | if (context) |
| 3882 | { |
| 3883 | if (program == 0) |
| 3884 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3885 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3886 | } |
| 3887 | |
| 3888 | gl::Program *programObject = context->getProgram(program); |
| 3889 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 3890 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3891 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3892 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3893 | } |
| 3894 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 3895 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 3896 | if (!programBinary) |
| 3897 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3898 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 3899 | } |
| 3900 | |
| 3901 | if (!programBinary->getUniformiv(location, NULL, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3902 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3903 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3904 | } |
| 3905 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3906 | } |
| 3907 | catch(std::bad_alloc&) |
| 3908 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3909 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3910 | } |
| 3911 | } |
| 3912 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3913 | int __stdcall glGetUniformLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3914 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3915 | EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3916 | |
| 3917 | try |
| 3918 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3919 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3920 | |
| 3921 | if (strstr(name, "gl_") == name) |
| 3922 | { |
| 3923 | return -1; |
| 3924 | } |
| 3925 | |
| 3926 | if (context) |
| 3927 | { |
| 3928 | gl::Program *programObject = context->getProgram(program); |
| 3929 | |
| 3930 | if (!programObject) |
| 3931 | { |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 3932 | if (context->getShader(program)) |
| 3933 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3934 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 3935 | } |
| 3936 | else |
| 3937 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3938 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 3939 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3940 | } |
| 3941 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 3942 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 3943 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3944 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3945 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3946 | } |
| 3947 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 3948 | return programBinary->getUniformLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3949 | } |
| 3950 | } |
| 3951 | catch(std::bad_alloc&) |
| 3952 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3953 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3954 | } |
| 3955 | |
| 3956 | return -1; |
| 3957 | } |
| 3958 | |
| 3959 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 3960 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3961 | EVENT("(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] | 3962 | |
| 3963 | try |
| 3964 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3965 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3966 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3967 | if (context) |
| 3968 | { |
| 3969 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3970 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3971 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3972 | } |
| 3973 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3974 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3975 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 3976 | if (!gl::ValidateGetVertexAttribParameters(pname, context->getClientVersion())) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3977 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 3978 | return; |
| 3979 | } |
| 3980 | |
| 3981 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 3982 | { |
| 3983 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 3984 | for (int i = 0; i < 4; ++i) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3985 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 3986 | params[i] = currentValueData.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3987 | } |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 3988 | } |
| 3989 | else |
| 3990 | { |
| 3991 | *params = attribState.querySingleParameter<GLfloat>(pname); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3992 | } |
| 3993 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3994 | } |
| 3995 | catch(std::bad_alloc&) |
| 3996 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3997 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3998 | } |
| 3999 | } |
| 4000 | |
| 4001 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 4002 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4003 | EVENT("(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] | 4004 | |
| 4005 | try |
| 4006 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4007 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4008 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 4009 | if (context) |
| 4010 | { |
| 4011 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 4012 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4013 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 4014 | } |
| 4015 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 4016 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4017 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 4018 | if (!gl::ValidateGetVertexAttribParameters(pname, context->getClientVersion())) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 4019 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 4020 | return; |
| 4021 | } |
| 4022 | |
| 4023 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 4024 | { |
| 4025 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 4026 | for (int i = 0; i < 4; ++i) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 4027 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 4028 | float currentValue = currentValueData.FloatValues[i]; |
Jamie Madill | af49691 | 2013-07-19 16:36:54 -0400 | [diff] [blame] | 4029 | params[i] = gl::iround<GLint>(currentValue); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 4030 | } |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 4031 | } |
| 4032 | else |
| 4033 | { |
| 4034 | *params = attribState.querySingleParameter<GLint>(pname); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 4035 | } |
| 4036 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4037 | } |
| 4038 | catch(std::bad_alloc&) |
| 4039 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4040 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4041 | } |
| 4042 | } |
| 4043 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4044 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4045 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4046 | EVENT("(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] | 4047 | |
| 4048 | try |
| 4049 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4050 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4051 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 4052 | if (context) |
| 4053 | { |
| 4054 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 4055 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4056 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 4057 | } |
| 4058 | |
| 4059 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) |
| 4060 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4061 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 4062 | } |
| 4063 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4064 | *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index)); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 4065 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4066 | } |
| 4067 | catch(std::bad_alloc&) |
| 4068 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4069 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4070 | } |
| 4071 | } |
| 4072 | |
| 4073 | void __stdcall glHint(GLenum target, GLenum mode) |
| 4074 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4075 | EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4076 | |
| 4077 | try |
| 4078 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 4079 | switch (mode) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 4080 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 4081 | case GL_FASTEST: |
| 4082 | case GL_NICEST: |
| 4083 | case GL_DONT_CARE: |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 4084 | break; |
| 4085 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4086 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 4087 | } |
| 4088 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4089 | gl::Context *context = gl::getNonLostContext(); |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 4090 | switch (target) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 4091 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 4092 | case GL_GENERATE_MIPMAP_HINT: |
| 4093 | if (context) context->setGenerateMipmapHint(mode); |
| 4094 | break; |
| 4095 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 4096 | if (context) context->setFragmentShaderDerivativeHint(mode); |
| 4097 | break; |
| 4098 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4099 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 4100 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4101 | } |
| 4102 | catch(std::bad_alloc&) |
| 4103 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4104 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4105 | } |
| 4106 | } |
| 4107 | |
| 4108 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 4109 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4110 | EVENT("(GLuint buffer = %d)", buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4111 | |
| 4112 | try |
| 4113 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4114 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4115 | |
| 4116 | if (context && buffer) |
| 4117 | { |
| 4118 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 4119 | |
| 4120 | if (bufferObject) |
| 4121 | { |
| 4122 | return GL_TRUE; |
| 4123 | } |
| 4124 | } |
| 4125 | } |
| 4126 | catch(std::bad_alloc&) |
| 4127 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4128 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4129 | } |
| 4130 | |
| 4131 | return GL_FALSE; |
| 4132 | } |
| 4133 | |
| 4134 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 4135 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4136 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4137 | |
| 4138 | try |
| 4139 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4140 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4141 | |
| 4142 | if (context) |
| 4143 | { |
| 4144 | switch (cap) |
| 4145 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4146 | case GL_CULL_FACE: return context->isCullFaceEnabled(); |
| 4147 | case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled(); |
| 4148 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled(); |
| 4149 | case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled(); |
| 4150 | case GL_SCISSOR_TEST: return context->isScissorTestEnabled(); |
| 4151 | case GL_STENCIL_TEST: return context->isStencilTestEnabled(); |
| 4152 | case GL_DEPTH_TEST: return context->isDepthTestEnabled(); |
| 4153 | case GL_BLEND: return context->isBlendEnabled(); |
| 4154 | case GL_DITHER: return context->isDitherEnabled(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4155 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4156 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4157 | } |
| 4158 | } |
| 4159 | } |
| 4160 | catch(std::bad_alloc&) |
| 4161 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4162 | return gl::error(GL_OUT_OF_MEMORY, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4163 | } |
| 4164 | |
| 4165 | return false; |
| 4166 | } |
| 4167 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 4168 | GLboolean __stdcall glIsFenceNV(GLuint fence) |
| 4169 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4170 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4171 | |
| 4172 | try |
| 4173 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4174 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4175 | |
| 4176 | if (context) |
| 4177 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 4178 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4179 | |
| 4180 | if (fenceObject == NULL) |
| 4181 | { |
| 4182 | return GL_FALSE; |
| 4183 | } |
| 4184 | |
| 4185 | return fenceObject->isFence(); |
| 4186 | } |
| 4187 | } |
| 4188 | catch(std::bad_alloc&) |
| 4189 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4190 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4191 | } |
| 4192 | |
| 4193 | return GL_FALSE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 4194 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4195 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4196 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 4197 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4198 | EVENT("(GLuint framebuffer = %d)", framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4199 | |
| 4200 | try |
| 4201 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4202 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4203 | |
| 4204 | if (context && framebuffer) |
| 4205 | { |
| 4206 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 4207 | |
| 4208 | if (framebufferObject) |
| 4209 | { |
| 4210 | return GL_TRUE; |
| 4211 | } |
| 4212 | } |
| 4213 | } |
| 4214 | catch(std::bad_alloc&) |
| 4215 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4216 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4217 | } |
| 4218 | |
| 4219 | return GL_FALSE; |
| 4220 | } |
| 4221 | |
| 4222 | GLboolean __stdcall glIsProgram(GLuint program) |
| 4223 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4224 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4225 | |
| 4226 | try |
| 4227 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4228 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4229 | |
| 4230 | if (context && program) |
| 4231 | { |
| 4232 | gl::Program *programObject = context->getProgram(program); |
| 4233 | |
| 4234 | if (programObject) |
| 4235 | { |
| 4236 | return GL_TRUE; |
| 4237 | } |
| 4238 | } |
| 4239 | } |
| 4240 | catch(std::bad_alloc&) |
| 4241 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4242 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4243 | } |
| 4244 | |
| 4245 | return GL_FALSE; |
| 4246 | } |
| 4247 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4248 | GLboolean __stdcall glIsQueryEXT(GLuint id) |
| 4249 | { |
| 4250 | EVENT("(GLuint id = %d)", id); |
| 4251 | |
| 4252 | try |
| 4253 | { |
| 4254 | if (id == 0) |
| 4255 | { |
| 4256 | return GL_FALSE; |
| 4257 | } |
| 4258 | |
| 4259 | gl::Context *context = gl::getNonLostContext(); |
| 4260 | |
| 4261 | if (context) |
| 4262 | { |
| 4263 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 4264 | |
| 4265 | if (queryObject) |
| 4266 | { |
| 4267 | return GL_TRUE; |
| 4268 | } |
| 4269 | } |
| 4270 | } |
| 4271 | catch(std::bad_alloc&) |
| 4272 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4273 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4274 | } |
| 4275 | |
| 4276 | return GL_FALSE; |
| 4277 | } |
| 4278 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4279 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 4280 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4281 | EVENT("(GLuint renderbuffer = %d)", renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4282 | |
| 4283 | try |
| 4284 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4285 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4286 | |
| 4287 | if (context && renderbuffer) |
| 4288 | { |
| 4289 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 4290 | |
| 4291 | if (renderbufferObject) |
| 4292 | { |
| 4293 | return GL_TRUE; |
| 4294 | } |
| 4295 | } |
| 4296 | } |
| 4297 | catch(std::bad_alloc&) |
| 4298 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4299 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4300 | } |
| 4301 | |
| 4302 | return GL_FALSE; |
| 4303 | } |
| 4304 | |
| 4305 | GLboolean __stdcall glIsShader(GLuint shader) |
| 4306 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4307 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4308 | |
| 4309 | try |
| 4310 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4311 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4312 | |
| 4313 | if (context && shader) |
| 4314 | { |
| 4315 | gl::Shader *shaderObject = context->getShader(shader); |
| 4316 | |
| 4317 | if (shaderObject) |
| 4318 | { |
| 4319 | return GL_TRUE; |
| 4320 | } |
| 4321 | } |
| 4322 | } |
| 4323 | catch(std::bad_alloc&) |
| 4324 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4325 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4326 | } |
| 4327 | |
| 4328 | return GL_FALSE; |
| 4329 | } |
| 4330 | |
| 4331 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 4332 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4333 | EVENT("(GLuint texture = %d)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4334 | |
| 4335 | try |
| 4336 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4337 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4338 | |
| 4339 | if (context && texture) |
| 4340 | { |
| 4341 | gl::Texture *textureObject = context->getTexture(texture); |
| 4342 | |
| 4343 | if (textureObject) |
| 4344 | { |
| 4345 | return GL_TRUE; |
| 4346 | } |
| 4347 | } |
| 4348 | } |
| 4349 | catch(std::bad_alloc&) |
| 4350 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4351 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4352 | } |
| 4353 | |
| 4354 | return GL_FALSE; |
| 4355 | } |
| 4356 | |
| 4357 | void __stdcall glLineWidth(GLfloat width) |
| 4358 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4359 | EVENT("(GLfloat width = %f)", width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4360 | |
| 4361 | try |
| 4362 | { |
| 4363 | if (width <= 0.0f) |
| 4364 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4365 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4366 | } |
| 4367 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4368 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4369 | |
| 4370 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4371 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4372 | context->setLineWidth(width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4373 | } |
| 4374 | } |
| 4375 | catch(std::bad_alloc&) |
| 4376 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4377 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4378 | } |
| 4379 | } |
| 4380 | |
| 4381 | void __stdcall glLinkProgram(GLuint program) |
| 4382 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4383 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4384 | |
| 4385 | try |
| 4386 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4387 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4388 | |
| 4389 | if (context) |
| 4390 | { |
| 4391 | gl::Program *programObject = context->getProgram(program); |
| 4392 | |
| 4393 | if (!programObject) |
| 4394 | { |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 4395 | if (context->getShader(program)) |
| 4396 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4397 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 4398 | } |
| 4399 | else |
| 4400 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4401 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 4402 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4403 | } |
| 4404 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 4405 | context->linkProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4406 | } |
| 4407 | } |
| 4408 | catch(std::bad_alloc&) |
| 4409 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4410 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4411 | } |
| 4412 | } |
| 4413 | |
| 4414 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 4415 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4416 | EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4417 | |
| 4418 | try |
| 4419 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4420 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 4421 | |
| 4422 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4423 | { |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 4424 | switch (pname) |
| 4425 | { |
| 4426 | case GL_UNPACK_ALIGNMENT: |
| 4427 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 4428 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4429 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 4430 | } |
| 4431 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4432 | context->setUnpackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 4433 | break; |
| 4434 | |
| 4435 | case GL_PACK_ALIGNMENT: |
| 4436 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 4437 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4438 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 4439 | } |
| 4440 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4441 | context->setPackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 4442 | break; |
| 4443 | |
bsalomon@google.com | 56d46ab | 2011-11-23 14:53:10 +0000 | [diff] [blame] | 4444 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 4445 | context->setPackReverseRowOrder(param != 0); |
| 4446 | break; |
| 4447 | |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 4448 | case GL_UNPACK_IMAGE_HEIGHT: |
| 4449 | case GL_UNPACK_SKIP_IMAGES: |
| 4450 | case GL_UNPACK_ROW_LENGTH: |
| 4451 | case GL_UNPACK_SKIP_ROWS: |
| 4452 | case GL_UNPACK_SKIP_PIXELS: |
| 4453 | case GL_PACK_ROW_LENGTH: |
| 4454 | case GL_PACK_SKIP_ROWS: |
| 4455 | case GL_PACK_SKIP_PIXELS: |
| 4456 | if (context->getClientVersion() < 3) |
| 4457 | { |
| 4458 | return gl::error(GL_INVALID_ENUM); |
| 4459 | } |
| 4460 | UNIMPLEMENTED(); |
| 4461 | break; |
| 4462 | |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 4463 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4464 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 4465 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4466 | } |
| 4467 | } |
| 4468 | catch(std::bad_alloc&) |
| 4469 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4470 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4471 | } |
| 4472 | } |
| 4473 | |
| 4474 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 4475 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4476 | EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4477 | |
| 4478 | try |
| 4479 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4480 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aede630 | 2010-04-29 03:35:48 +0000 | [diff] [blame] | 4481 | |
| 4482 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4483 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4484 | context->setPolygonOffsetParams(factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4485 | } |
| 4486 | } |
| 4487 | catch(std::bad_alloc&) |
| 4488 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4489 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4490 | } |
| 4491 | } |
| 4492 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 4493 | void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, |
| 4494 | GLenum format, GLenum type, GLsizei bufSize, |
| 4495 | GLvoid *data) |
| 4496 | { |
| 4497 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
| 4498 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)", |
| 4499 | x, y, width, height, format, type, bufSize, data); |
| 4500 | |
| 4501 | try |
| 4502 | { |
| 4503 | if (width < 0 || height < 0 || bufSize < 0) |
| 4504 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4505 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 4506 | } |
| 4507 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 4508 | gl::Context *context = gl::getNonLostContext(); |
| 4509 | |
| 4510 | if (context) |
| 4511 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 4512 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 4513 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 4514 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 4515 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 4516 | // and attempting to read back if that's the case is an error. The error will be registered |
| 4517 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 4518 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 4519 | return; |
| 4520 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 4521 | bool validReadFormat = (context->getClientVersion() < 3) ? gl::ValidES2ReadFormatType(format, type) : |
| 4522 | gl::ValidES3ReadFormatType(currentInternalFormat, format, type); |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 4523 | |
| 4524 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 4525 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4526 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 4527 | } |
| 4528 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 4529 | context->readPixels(x, y, width, height, format, type, &bufSize, data); |
| 4530 | } |
| 4531 | } |
| 4532 | catch(std::bad_alloc&) |
| 4533 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4534 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 4535 | } |
| 4536 | } |
| 4537 | |
| 4538 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, |
| 4539 | GLenum format, GLenum type, GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4540 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4541 | EVENT("(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] | 4542 | "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] | 4543 | x, y, width, height, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4544 | |
| 4545 | try |
| 4546 | { |
| 4547 | if (width < 0 || height < 0) |
| 4548 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4549 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4550 | } |
| 4551 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4552 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4553 | |
| 4554 | if (context) |
| 4555 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 4556 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 4557 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 4558 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 4559 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 4560 | // and attempting to read back if that's the case is an error. The error will be registered |
| 4561 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 4562 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 4563 | return; |
| 4564 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 4565 | bool validReadFormat = (context->getClientVersion() < 3) ? gl::ValidES2ReadFormatType(format, type) : |
| 4566 | gl::ValidES3ReadFormatType(currentInternalFormat, format, type); |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 4567 | |
| 4568 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 4569 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4570 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 4571 | } |
| 4572 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 4573 | context->readPixels(x, y, width, height, format, type, NULL, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4574 | } |
| 4575 | } |
| 4576 | catch(std::bad_alloc&) |
| 4577 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4578 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4579 | } |
| 4580 | } |
| 4581 | |
| 4582 | void __stdcall glReleaseShaderCompiler(void) |
| 4583 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4584 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4585 | |
| 4586 | try |
| 4587 | { |
| 4588 | gl::Shader::releaseCompiler(); |
| 4589 | } |
| 4590 | catch(std::bad_alloc&) |
| 4591 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4592 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4593 | } |
| 4594 | } |
| 4595 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 4596 | void __stdcall glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4597 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4598 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 4599 | target, samples, internalformat, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4600 | |
| 4601 | try |
| 4602 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4603 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4604 | |
| 4605 | if (context) |
| 4606 | { |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 4607 | if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat, |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 4608 | width, height, true)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 4609 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 4610 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4611 | } |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 4612 | |
| 4613 | context->setRenderbufferStorage(width, height, internalformat, samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4614 | } |
| 4615 | } |
| 4616 | catch(std::bad_alloc&) |
| 4617 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4618 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4619 | } |
| 4620 | } |
| 4621 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 4622 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 4623 | { |
| 4624 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height); |
| 4625 | } |
| 4626 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4627 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 4628 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4629 | EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4630 | |
| 4631 | try |
| 4632 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4633 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 4634 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4635 | if (context) |
| 4636 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 4637 | context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4638 | } |
| 4639 | } |
| 4640 | catch(std::bad_alloc&) |
| 4641 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4642 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4643 | } |
| 4644 | } |
| 4645 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 4646 | void __stdcall glSetFenceNV(GLuint fence, GLenum condition) |
| 4647 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4648 | EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4649 | |
| 4650 | try |
| 4651 | { |
| 4652 | if (condition != GL_ALL_COMPLETED_NV) |
| 4653 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4654 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4655 | } |
| 4656 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4657 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4658 | |
| 4659 | if (context) |
| 4660 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 4661 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4662 | |
| 4663 | if (fenceObject == NULL) |
| 4664 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4665 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4666 | } |
| 4667 | |
| 4668 | fenceObject->setFence(condition); |
| 4669 | } |
| 4670 | } |
| 4671 | catch(std::bad_alloc&) |
| 4672 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4673 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4674 | } |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 4675 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4676 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4677 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 4678 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4679 | EVENT("(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] | 4680 | |
| 4681 | try |
| 4682 | { |
| 4683 | if (width < 0 || height < 0) |
| 4684 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4685 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4686 | } |
| 4687 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4688 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 4689 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4690 | if (context) |
| 4691 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4692 | context->setScissorParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4693 | } |
| 4694 | } |
| 4695 | catch(std::bad_alloc&) |
| 4696 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4697 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4698 | } |
| 4699 | } |
| 4700 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4701 | 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] | 4702 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4703 | EVENT("(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] | 4704 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 4705 | n, shaders, binaryformat, binary, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4706 | |
| 4707 | try |
| 4708 | { |
daniel@transgaming.com | d1f667f | 2010-04-29 03:38:52 +0000 | [diff] [blame] | 4709 | // No binary shader formats are supported. |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4710 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4711 | } |
| 4712 | catch(std::bad_alloc&) |
| 4713 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4714 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4715 | } |
| 4716 | } |
| 4717 | |
shannon.woods%transgaming.com@gtempaccount.com | 5f33933 | 2013-04-13 03:29:02 +0000 | [diff] [blame] | 4718 | void __stdcall glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4719 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4720 | EVENT("(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] | 4721 | shader, count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4722 | |
| 4723 | try |
| 4724 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 4725 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4726 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4727 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4728 | } |
| 4729 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4730 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4731 | |
| 4732 | if (context) |
| 4733 | { |
| 4734 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 4735 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4736 | if (!shaderObject) |
| 4737 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 4738 | if (context->getProgram(shader)) |
| 4739 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4740 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 4741 | } |
| 4742 | else |
| 4743 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4744 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 4745 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4746 | } |
| 4747 | |
| 4748 | shaderObject->setSource(count, string, length); |
| 4749 | } |
| 4750 | } |
| 4751 | catch(std::bad_alloc&) |
| 4752 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4753 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4754 | } |
| 4755 | } |
| 4756 | |
| 4757 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 4758 | { |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 4759 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4760 | } |
| 4761 | |
| 4762 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 4763 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4764 | EVENT("(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] | 4765 | |
| 4766 | try |
| 4767 | { |
| 4768 | switch (face) |
| 4769 | { |
| 4770 | case GL_FRONT: |
| 4771 | case GL_BACK: |
| 4772 | case GL_FRONT_AND_BACK: |
| 4773 | break; |
| 4774 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4775 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4776 | } |
| 4777 | |
| 4778 | switch (func) |
| 4779 | { |
| 4780 | case GL_NEVER: |
| 4781 | case GL_ALWAYS: |
| 4782 | case GL_LESS: |
| 4783 | case GL_LEQUAL: |
| 4784 | case GL_EQUAL: |
| 4785 | case GL_GEQUAL: |
| 4786 | case GL_GREATER: |
| 4787 | case GL_NOTEQUAL: |
| 4788 | break; |
| 4789 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4790 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4791 | } |
| 4792 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4793 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4794 | |
| 4795 | if (context) |
| 4796 | { |
| 4797 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4798 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4799 | context->setStencilParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4800 | } |
| 4801 | |
| 4802 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4803 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4804 | context->setStencilBackParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4805 | } |
| 4806 | } |
| 4807 | } |
| 4808 | catch(std::bad_alloc&) |
| 4809 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4810 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4811 | } |
| 4812 | } |
| 4813 | |
| 4814 | void __stdcall glStencilMask(GLuint mask) |
| 4815 | { |
| 4816 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 4817 | } |
| 4818 | |
| 4819 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 4820 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4821 | EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4822 | |
| 4823 | try |
| 4824 | { |
| 4825 | switch (face) |
| 4826 | { |
| 4827 | case GL_FRONT: |
| 4828 | case GL_BACK: |
| 4829 | case GL_FRONT_AND_BACK: |
| 4830 | break; |
| 4831 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4832 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4833 | } |
| 4834 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4835 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4836 | |
| 4837 | if (context) |
| 4838 | { |
| 4839 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4840 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4841 | context->setStencilWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4842 | } |
| 4843 | |
| 4844 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4845 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4846 | context->setStencilBackWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4847 | } |
| 4848 | } |
| 4849 | } |
| 4850 | catch(std::bad_alloc&) |
| 4851 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4852 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4853 | } |
| 4854 | } |
| 4855 | |
| 4856 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 4857 | { |
| 4858 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 4859 | } |
| 4860 | |
| 4861 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 4862 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4863 | EVENT("(GLenum face = 0x%X, GLenum fail = 0x%X, GLenum zfail = 0x%X, GLenum zpas = 0x%Xs)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 4864 | face, fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4865 | |
| 4866 | try |
| 4867 | { |
| 4868 | switch (face) |
| 4869 | { |
| 4870 | case GL_FRONT: |
| 4871 | case GL_BACK: |
| 4872 | case GL_FRONT_AND_BACK: |
| 4873 | break; |
| 4874 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4875 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4876 | } |
| 4877 | |
| 4878 | switch (fail) |
| 4879 | { |
| 4880 | case GL_ZERO: |
| 4881 | case GL_KEEP: |
| 4882 | case GL_REPLACE: |
| 4883 | case GL_INCR: |
| 4884 | case GL_DECR: |
| 4885 | case GL_INVERT: |
| 4886 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 4887 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4888 | break; |
| 4889 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4890 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4891 | } |
| 4892 | |
| 4893 | switch (zfail) |
| 4894 | { |
| 4895 | case GL_ZERO: |
| 4896 | case GL_KEEP: |
| 4897 | case GL_REPLACE: |
| 4898 | case GL_INCR: |
| 4899 | case GL_DECR: |
| 4900 | case GL_INVERT: |
| 4901 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 4902 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4903 | break; |
| 4904 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4905 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4906 | } |
| 4907 | |
| 4908 | switch (zpass) |
| 4909 | { |
| 4910 | case GL_ZERO: |
| 4911 | case GL_KEEP: |
| 4912 | case GL_REPLACE: |
| 4913 | case GL_INCR: |
| 4914 | case GL_DECR: |
| 4915 | case GL_INVERT: |
| 4916 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 4917 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4918 | break; |
| 4919 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4920 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4921 | } |
| 4922 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4923 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4924 | |
| 4925 | if (context) |
| 4926 | { |
| 4927 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4928 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4929 | context->setStencilOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4930 | } |
| 4931 | |
| 4932 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4933 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4934 | context->setStencilBackOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4935 | } |
| 4936 | } |
| 4937 | } |
| 4938 | catch(std::bad_alloc&) |
| 4939 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4940 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4941 | } |
| 4942 | } |
| 4943 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 4944 | GLboolean __stdcall glTestFenceNV(GLuint fence) |
| 4945 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4946 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4947 | |
| 4948 | try |
| 4949 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4950 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4951 | |
| 4952 | if (context) |
| 4953 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 4954 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4955 | |
| 4956 | if (fenceObject == NULL) |
| 4957 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4958 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4959 | } |
| 4960 | |
Jamie Madill | fb9a740 | 2013-07-26 11:55:01 -0400 | [diff] [blame] | 4961 | if (fenceObject->isFence() != GL_TRUE) |
| 4962 | { |
| 4963 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
| 4964 | } |
| 4965 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4966 | return fenceObject->testFence(); |
| 4967 | } |
| 4968 | } |
| 4969 | catch(std::bad_alloc&) |
| 4970 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4971 | gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4972 | } |
| 4973 | |
| 4974 | return GL_TRUE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 4975 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4976 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4977 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, |
| 4978 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4979 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4980 | EVENT("(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] | 4981 | "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] | 4982 | target, level, internalformat, width, height, border, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4983 | |
| 4984 | try |
| 4985 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4986 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4987 | |
| 4988 | if (context) |
| 4989 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 4990 | if (context->getClientVersion() < 3 && |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 4991 | !ValidateES2TexImageParameters(context, target, level, internalformat, false, false, |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 4992 | 0, 0, width, height, border, format, type, pixels)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 4993 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 4994 | return; |
| 4995 | } |
| 4996 | |
| 4997 | if (context->getClientVersion() >= 3 && |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 4998 | !ValidateES3TexImageParameters(context, target, level, internalformat, false, false, |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 4999 | 0, 0, 0, width, height, 1, border, format, type)) |
| 5000 | { |
| 5001 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 5002 | } |
| 5003 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 5004 | switch (target) |
| 5005 | { |
| 5006 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 5007 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 5008 | gl::Texture2D *texture = context->getTexture2D(); |
| 5009 | texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 5010 | } |
| 5011 | break; |
| 5012 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 5013 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 5014 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 5015 | texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5016 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 5017 | break; |
| 5018 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 5019 | { |
| 5020 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 5021 | texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 5022 | } |
| 5023 | break; |
| 5024 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 5025 | { |
| 5026 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 5027 | texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 5028 | } |
| 5029 | break; |
| 5030 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 5031 | { |
| 5032 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 5033 | texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 5034 | } |
| 5035 | break; |
| 5036 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 5037 | { |
| 5038 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 5039 | texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 5040 | } |
| 5041 | break; |
| 5042 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 5043 | { |
| 5044 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 5045 | texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 5046 | } |
| 5047 | break; |
| 5048 | default: UNREACHABLE(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5049 | } |
| 5050 | } |
| 5051 | } |
| 5052 | catch(std::bad_alloc&) |
| 5053 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5054 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5055 | } |
| 5056 | } |
| 5057 | |
| 5058 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 5059 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5060 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param); |
| 5061 | |
| 5062 | try |
| 5063 | { |
| 5064 | gl::Context *context = gl::getNonLostContext(); |
| 5065 | |
| 5066 | if (context) |
| 5067 | { |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 5068 | if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param))) |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 5069 | { |
| 5070 | return; |
| 5071 | } |
| 5072 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 5073 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5074 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 5075 | if (!texture) |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5076 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5077 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5078 | } |
| 5079 | |
| 5080 | switch (pname) |
| 5081 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 5082 | case GL_TEXTURE_WRAP_S: texture->setWrapS(gl::uiround<GLenum>(param)); break; |
| 5083 | case GL_TEXTURE_WRAP_T: texture->setWrapT(gl::uiround<GLenum>(param)); break; |
| 5084 | case GL_TEXTURE_WRAP_R: texture->setWrapR(gl::uiround<GLenum>(param)); break; |
| 5085 | case GL_TEXTURE_MIN_FILTER: texture->setMinFilter(gl::uiround<GLenum>(param)); break; |
| 5086 | case GL_TEXTURE_MAG_FILTER: texture->setMagFilter(gl::uiround<GLenum>(param)); break; |
| 5087 | case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break; |
| 5088 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy(static_cast<GLfloat>(param), context->getTextureMaxAnisotropy()); break; |
| 5089 | case GL_TEXTURE_COMPARE_MODE: texture->setCompareMode(gl::uiround<GLenum>(param)); break; |
| 5090 | case GL_TEXTURE_COMPARE_FUNC: texture->setCompareFunc(gl::uiround<GLenum>(param)); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 5091 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 5092 | case GL_TEXTURE_SWIZZLE_R: |
| 5093 | case GL_TEXTURE_SWIZZLE_G: |
| 5094 | case GL_TEXTURE_SWIZZLE_B: |
| 5095 | case GL_TEXTURE_SWIZZLE_A: |
| 5096 | case GL_TEXTURE_BASE_LEVEL: |
| 5097 | case GL_TEXTURE_MAX_LEVEL: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 5098 | case GL_TEXTURE_MIN_LOD: |
| 5099 | case GL_TEXTURE_MAX_LOD: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 5100 | UNIMPLEMENTED(); |
| 5101 | break; |
| 5102 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 5103 | default: UNREACHABLE(); break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5104 | } |
| 5105 | } |
| 5106 | } |
| 5107 | catch(std::bad_alloc&) |
| 5108 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5109 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5110 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5111 | } |
| 5112 | |
| 5113 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 5114 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5115 | glTexParameterf(target, pname, (GLfloat)*params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5116 | } |
| 5117 | |
| 5118 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 5119 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5120 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5121 | |
| 5122 | try |
| 5123 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5124 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5125 | |
| 5126 | if (context) |
| 5127 | { |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 5128 | if (!ValidateTexParamParameters(context, pname, param)) |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 5129 | { |
| 5130 | return; |
| 5131 | } |
| 5132 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 5133 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5134 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 5135 | if (!texture) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5136 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5137 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5138 | } |
| 5139 | |
| 5140 | switch (pname) |
| 5141 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 5142 | case GL_TEXTURE_WRAP_S: texture->setWrapS((GLenum)param); break; |
| 5143 | case GL_TEXTURE_WRAP_T: texture->setWrapT((GLenum)param); break; |
| 5144 | case GL_TEXTURE_WRAP_R: texture->setWrapR((GLenum)param); break; |
| 5145 | case GL_TEXTURE_MIN_FILTER: texture->setMinFilter((GLenum)param); break; |
| 5146 | case GL_TEXTURE_MAG_FILTER: texture->setMagFilter((GLenum)param); break; |
| 5147 | case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break; |
| 5148 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()); break; |
| 5149 | case GL_TEXTURE_COMPARE_MODE: texture->setCompareMode((GLenum)param); break; |
| 5150 | case GL_TEXTURE_COMPARE_FUNC: texture->setCompareFunc((GLenum)param); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 5151 | |
| 5152 | case GL_TEXTURE_SWIZZLE_R: |
| 5153 | case GL_TEXTURE_SWIZZLE_G: |
| 5154 | case GL_TEXTURE_SWIZZLE_B: |
| 5155 | case GL_TEXTURE_SWIZZLE_A: |
| 5156 | case GL_TEXTURE_BASE_LEVEL: |
| 5157 | case GL_TEXTURE_MAX_LEVEL: |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 5158 | case GL_TEXTURE_MIN_LOD: |
| 5159 | case GL_TEXTURE_MAX_LOD: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 5160 | UNIMPLEMENTED(); |
| 5161 | break; |
| 5162 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 5163 | default: UNREACHABLE(); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5164 | } |
| 5165 | } |
| 5166 | } |
| 5167 | catch(std::bad_alloc&) |
| 5168 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5169 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5170 | } |
| 5171 | } |
| 5172 | |
| 5173 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 5174 | { |
| 5175 | glTexParameteri(target, pname, *params); |
| 5176 | } |
| 5177 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 5178 | void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 5179 | { |
| 5180 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 5181 | target, levels, internalformat, width, height); |
| 5182 | |
| 5183 | try |
| 5184 | { |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 5185 | gl::Context *context = gl::getNonLostContext(); |
| 5186 | |
| 5187 | if (context) |
| 5188 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5189 | if (context->getClientVersion() < 3 && |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 5190 | !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 5191 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5192 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 5193 | } |
| 5194 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5195 | if (context->getClientVersion() >= 3 && |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 5196 | !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 5197 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5198 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 5199 | } |
| 5200 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 5201 | switch (target) |
| 5202 | { |
| 5203 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 5204 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5205 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 5206 | texture2d->storage(levels, internalformat, width, height); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 5207 | } |
| 5208 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5209 | |
| 5210 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 5211 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 5212 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 5213 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 5214 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 5215 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 5216 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5217 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 5218 | textureCube->storage(levels, internalformat, width); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 5219 | } |
| 5220 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5221 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 5222 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5223 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 5224 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 5225 | } |
| 5226 | } |
| 5227 | catch(std::bad_alloc&) |
| 5228 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5229 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 5230 | } |
| 5231 | } |
| 5232 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5233 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 5234 | GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5235 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5236 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 5237 | "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] | 5238 | "const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5239 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 5240 | |
| 5241 | try |
| 5242 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5243 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 5244 | |
| 5245 | if (context) |
| 5246 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 5247 | if (context->getClientVersion() < 3 && |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 5248 | !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true, |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 5249 | 0, 0, width, height, 0, format, type, pixels)) |
daniel@transgaming.com | 1d2d3c4 | 2012-05-31 01:14:15 +0000 | [diff] [blame] | 5250 | { |
| 5251 | return; |
| 5252 | } |
| 5253 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 5254 | if (context->getClientVersion() >= 3 && |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 5255 | !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 5256 | 0, 0, 0, width, height, 1, 0, format, type)) |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 5257 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 5258 | return; |
| 5259 | } |
| 5260 | |
| 5261 | switch (target) |
| 5262 | { |
| 5263 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 5264 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 5265 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 5266 | texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 5267 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 5268 | break; |
| 5269 | |
| 5270 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 5271 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 5272 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 5273 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 5274 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 5275 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 5276 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 5277 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 5278 | texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 5279 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 5280 | break; |
| 5281 | |
| 5282 | default: |
| 5283 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 5284 | } |
| 5285 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5286 | } |
| 5287 | catch(std::bad_alloc&) |
| 5288 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5289 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5290 | } |
| 5291 | } |
| 5292 | |
| 5293 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 5294 | { |
| 5295 | glUniform1fv(location, 1, &x); |
| 5296 | } |
| 5297 | |
| 5298 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 5299 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5300 | EVENT("(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] | 5301 | |
| 5302 | try |
| 5303 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5304 | if (count < 0) |
| 5305 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5306 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5307 | } |
| 5308 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 5309 | if (location == -1) |
| 5310 | { |
| 5311 | return; |
| 5312 | } |
| 5313 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5314 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5315 | |
| 5316 | if (context) |
| 5317 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 5318 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5319 | if (!programBinary) |
| 5320 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5321 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5322 | } |
| 5323 | |
| 5324 | if (!programBinary->setUniform1fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5325 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5326 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5327 | } |
| 5328 | } |
| 5329 | } |
| 5330 | catch(std::bad_alloc&) |
| 5331 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5332 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5333 | } |
| 5334 | } |
| 5335 | |
| 5336 | void __stdcall glUniform1i(GLint location, GLint x) |
| 5337 | { |
| 5338 | glUniform1iv(location, 1, &x); |
| 5339 | } |
| 5340 | |
| 5341 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 5342 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5343 | EVENT("(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] | 5344 | |
| 5345 | try |
| 5346 | { |
| 5347 | if (count < 0) |
| 5348 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5349 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5350 | } |
| 5351 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 5352 | if (location == -1) |
| 5353 | { |
| 5354 | return; |
| 5355 | } |
| 5356 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5357 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5358 | |
| 5359 | if (context) |
| 5360 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 5361 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5362 | if (!programBinary) |
| 5363 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5364 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5365 | } |
| 5366 | |
| 5367 | if (!programBinary->setUniform1iv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5368 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5369 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5370 | } |
| 5371 | } |
| 5372 | } |
| 5373 | catch(std::bad_alloc&) |
| 5374 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5375 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5376 | } |
| 5377 | } |
| 5378 | |
| 5379 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 5380 | { |
| 5381 | GLfloat xy[2] = {x, y}; |
| 5382 | |
| 5383 | glUniform2fv(location, 1, (GLfloat*)&xy); |
| 5384 | } |
| 5385 | |
| 5386 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 5387 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5388 | EVENT("(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] | 5389 | |
| 5390 | try |
| 5391 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5392 | if (count < 0) |
| 5393 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5394 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5395 | } |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 5396 | |
| 5397 | if (location == -1) |
| 5398 | { |
| 5399 | return; |
| 5400 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5401 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5402 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5403 | |
| 5404 | if (context) |
| 5405 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 5406 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5407 | if (!programBinary) |
| 5408 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5409 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5410 | } |
| 5411 | |
| 5412 | if (!programBinary->setUniform2fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5413 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5414 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5415 | } |
| 5416 | } |
| 5417 | } |
| 5418 | catch(std::bad_alloc&) |
| 5419 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5420 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5421 | } |
| 5422 | } |
| 5423 | |
| 5424 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 5425 | { |
| 5426 | GLint xy[4] = {x, y}; |
| 5427 | |
| 5428 | glUniform2iv(location, 1, (GLint*)&xy); |
| 5429 | } |
| 5430 | |
| 5431 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 5432 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5433 | EVENT("(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] | 5434 | |
| 5435 | try |
| 5436 | { |
| 5437 | if (count < 0) |
| 5438 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5439 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5440 | } |
| 5441 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 5442 | if (location == -1) |
| 5443 | { |
| 5444 | return; |
| 5445 | } |
| 5446 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5447 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 5448 | |
| 5449 | if (context) |
| 5450 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 5451 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5452 | if (!programBinary) |
| 5453 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5454 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5455 | } |
| 5456 | |
| 5457 | if (!programBinary->setUniform2iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 5458 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5459 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 5460 | } |
| 5461 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5462 | } |
| 5463 | catch(std::bad_alloc&) |
| 5464 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5465 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5466 | } |
| 5467 | } |
| 5468 | |
| 5469 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 5470 | { |
| 5471 | GLfloat xyz[3] = {x, y, z}; |
| 5472 | |
| 5473 | glUniform3fv(location, 1, (GLfloat*)&xyz); |
| 5474 | } |
| 5475 | |
| 5476 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 5477 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5478 | EVENT("(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] | 5479 | |
| 5480 | try |
| 5481 | { |
| 5482 | if (count < 0) |
| 5483 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5484 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5485 | } |
| 5486 | |
| 5487 | if (location == -1) |
| 5488 | { |
| 5489 | return; |
| 5490 | } |
| 5491 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5492 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5493 | |
| 5494 | if (context) |
| 5495 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 5496 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5497 | if (!programBinary) |
| 5498 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5499 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5500 | } |
| 5501 | |
| 5502 | if (!programBinary->setUniform3fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5503 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5504 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5505 | } |
| 5506 | } |
| 5507 | } |
| 5508 | catch(std::bad_alloc&) |
| 5509 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5510 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5511 | } |
| 5512 | } |
| 5513 | |
| 5514 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 5515 | { |
| 5516 | GLint xyz[3] = {x, y, z}; |
| 5517 | |
| 5518 | glUniform3iv(location, 1, (GLint*)&xyz); |
| 5519 | } |
| 5520 | |
| 5521 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 5522 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5523 | EVENT("(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] | 5524 | |
| 5525 | try |
| 5526 | { |
| 5527 | if (count < 0) |
| 5528 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5529 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5530 | } |
| 5531 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 5532 | if (location == -1) |
| 5533 | { |
| 5534 | return; |
| 5535 | } |
| 5536 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5537 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 5538 | |
| 5539 | if (context) |
| 5540 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 5541 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5542 | if (!programBinary) |
| 5543 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5544 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5545 | } |
| 5546 | |
| 5547 | if (!programBinary->setUniform3iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 5548 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5549 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 5550 | } |
| 5551 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5552 | } |
| 5553 | catch(std::bad_alloc&) |
| 5554 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5555 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5556 | } |
| 5557 | } |
| 5558 | |
| 5559 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 5560 | { |
| 5561 | GLfloat xyzw[4] = {x, y, z, w}; |
| 5562 | |
| 5563 | glUniform4fv(location, 1, (GLfloat*)&xyzw); |
| 5564 | } |
| 5565 | |
| 5566 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 5567 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5568 | EVENT("(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] | 5569 | |
| 5570 | try |
| 5571 | { |
| 5572 | if (count < 0) |
| 5573 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5574 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5575 | } |
| 5576 | |
| 5577 | if (location == -1) |
| 5578 | { |
| 5579 | return; |
| 5580 | } |
| 5581 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5582 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5583 | |
| 5584 | if (context) |
| 5585 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 5586 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5587 | if (!programBinary) |
| 5588 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5589 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5590 | } |
| 5591 | |
| 5592 | if (!programBinary->setUniform4fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5593 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5594 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5595 | } |
| 5596 | } |
| 5597 | } |
| 5598 | catch(std::bad_alloc&) |
| 5599 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5600 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5601 | } |
| 5602 | } |
| 5603 | |
| 5604 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 5605 | { |
| 5606 | GLint xyzw[4] = {x, y, z, w}; |
| 5607 | |
| 5608 | glUniform4iv(location, 1, (GLint*)&xyzw); |
| 5609 | } |
| 5610 | |
| 5611 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 5612 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5613 | EVENT("(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] | 5614 | |
| 5615 | try |
| 5616 | { |
| 5617 | if (count < 0) |
| 5618 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5619 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5620 | } |
| 5621 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 5622 | if (location == -1) |
| 5623 | { |
| 5624 | return; |
| 5625 | } |
| 5626 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5627 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 5628 | |
| 5629 | if (context) |
| 5630 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 5631 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5632 | if (!programBinary) |
| 5633 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5634 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5635 | } |
| 5636 | |
| 5637 | if (!programBinary->setUniform4iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 5638 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5639 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 5640 | } |
| 5641 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5642 | } |
| 5643 | catch(std::bad_alloc&) |
| 5644 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5645 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5646 | } |
| 5647 | } |
| 5648 | |
| 5649 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 5650 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5651 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 5652 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5653 | |
| 5654 | try |
| 5655 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 5656 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5657 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5658 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5659 | } |
| 5660 | |
| 5661 | if (location == -1) |
| 5662 | { |
| 5663 | return; |
| 5664 | } |
| 5665 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5666 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5667 | |
| 5668 | if (context) |
| 5669 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 5670 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 5671 | { |
| 5672 | return gl::error(GL_INVALID_VALUE); |
| 5673 | } |
| 5674 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 5675 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5676 | if (!programBinary) |
| 5677 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5678 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5679 | } |
| 5680 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 5681 | if (!programBinary->setUniformMatrix2fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5682 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5683 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5684 | } |
| 5685 | } |
| 5686 | } |
| 5687 | catch(std::bad_alloc&) |
| 5688 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5689 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5690 | } |
| 5691 | } |
| 5692 | |
| 5693 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 5694 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5695 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 5696 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5697 | |
| 5698 | try |
| 5699 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 5700 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5701 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5702 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5703 | } |
| 5704 | |
| 5705 | if (location == -1) |
| 5706 | { |
| 5707 | return; |
| 5708 | } |
| 5709 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5710 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5711 | |
| 5712 | if (context) |
| 5713 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 5714 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 5715 | { |
| 5716 | return gl::error(GL_INVALID_VALUE); |
| 5717 | } |
| 5718 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 5719 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5720 | if (!programBinary) |
| 5721 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5722 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5723 | } |
| 5724 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 5725 | if (!programBinary->setUniformMatrix3fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5726 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5727 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5728 | } |
| 5729 | } |
| 5730 | } |
| 5731 | catch(std::bad_alloc&) |
| 5732 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5733 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5734 | } |
| 5735 | } |
| 5736 | |
| 5737 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 5738 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5739 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 5740 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5741 | |
| 5742 | try |
| 5743 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 5744 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5745 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5746 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5747 | } |
| 5748 | |
| 5749 | if (location == -1) |
| 5750 | { |
| 5751 | return; |
| 5752 | } |
| 5753 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5754 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5755 | |
| 5756 | if (context) |
| 5757 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 5758 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 5759 | { |
| 5760 | return gl::error(GL_INVALID_VALUE); |
| 5761 | } |
| 5762 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 5763 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5764 | if (!programBinary) |
| 5765 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5766 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5767 | } |
| 5768 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 5769 | if (!programBinary->setUniformMatrix4fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5770 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5771 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5772 | } |
| 5773 | } |
| 5774 | } |
| 5775 | catch(std::bad_alloc&) |
| 5776 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5777 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5778 | } |
| 5779 | } |
| 5780 | |
| 5781 | void __stdcall glUseProgram(GLuint program) |
| 5782 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5783 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5784 | |
| 5785 | try |
| 5786 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5787 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5788 | |
| 5789 | if (context) |
| 5790 | { |
| 5791 | gl::Program *programObject = context->getProgram(program); |
| 5792 | |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 5793 | if (!programObject && program != 0) |
| 5794 | { |
| 5795 | if (context->getShader(program)) |
| 5796 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5797 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 5798 | } |
| 5799 | else |
| 5800 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5801 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 5802 | } |
| 5803 | } |
| 5804 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5805 | if (program != 0 && !programObject->isLinked()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5806 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5807 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5808 | } |
| 5809 | |
| 5810 | context->useProgram(program); |
| 5811 | } |
| 5812 | } |
| 5813 | catch(std::bad_alloc&) |
| 5814 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5815 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5816 | } |
| 5817 | } |
| 5818 | |
| 5819 | void __stdcall glValidateProgram(GLuint program) |
| 5820 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5821 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5822 | |
| 5823 | try |
| 5824 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5825 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 5826 | |
| 5827 | if (context) |
| 5828 | { |
| 5829 | gl::Program *programObject = context->getProgram(program); |
| 5830 | |
| 5831 | if (!programObject) |
| 5832 | { |
| 5833 | if (context->getShader(program)) |
| 5834 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5835 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 5836 | } |
| 5837 | else |
| 5838 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5839 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 5840 | } |
| 5841 | } |
| 5842 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 5843 | programObject->validate(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 5844 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5845 | } |
| 5846 | catch(std::bad_alloc&) |
| 5847 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5848 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5849 | } |
| 5850 | } |
| 5851 | |
| 5852 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 5853 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5854 | EVENT("(GLuint index = %d, GLfloat x = %f)", index, x); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5855 | |
| 5856 | try |
| 5857 | { |
| 5858 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5859 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5860 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5861 | } |
| 5862 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5863 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 5864 | |
| 5865 | if (context) |
| 5866 | { |
| 5867 | GLfloat vals[4] = { x, 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 5868 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 5869 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5870 | } |
| 5871 | catch(std::bad_alloc&) |
| 5872 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5873 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5874 | } |
| 5875 | } |
| 5876 | |
| 5877 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 5878 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5879 | EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5880 | |
| 5881 | try |
| 5882 | { |
| 5883 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5884 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5885 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5886 | } |
| 5887 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5888 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 5889 | |
| 5890 | if (context) |
| 5891 | { |
| 5892 | GLfloat vals[4] = { values[0], 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 5893 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 5894 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5895 | } |
| 5896 | catch(std::bad_alloc&) |
| 5897 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5898 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5899 | } |
| 5900 | } |
| 5901 | |
| 5902 | void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 5903 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5904 | EVENT("(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] | 5905 | |
| 5906 | try |
| 5907 | { |
| 5908 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5909 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5910 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5911 | } |
| 5912 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5913 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 5914 | |
| 5915 | if (context) |
| 5916 | { |
| 5917 | GLfloat vals[4] = { x, y, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 5918 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 5919 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5920 | } |
| 5921 | catch(std::bad_alloc&) |
| 5922 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5923 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5924 | } |
| 5925 | } |
| 5926 | |
| 5927 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 5928 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5929 | EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5930 | |
| 5931 | try |
| 5932 | { |
| 5933 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5934 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5935 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5936 | } |
| 5937 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5938 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 5939 | |
| 5940 | if (context) |
| 5941 | { |
| 5942 | GLfloat vals[4] = { values[0], values[1], 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 5943 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 5944 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5945 | } |
| 5946 | catch(std::bad_alloc&) |
| 5947 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5948 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5949 | } |
| 5950 | } |
| 5951 | |
| 5952 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 5953 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5954 | EVENT("(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] | 5955 | |
| 5956 | try |
| 5957 | { |
| 5958 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5959 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5960 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5961 | } |
| 5962 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5963 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 5964 | |
| 5965 | if (context) |
| 5966 | { |
| 5967 | GLfloat vals[4] = { x, y, z, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 5968 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 5969 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5970 | } |
| 5971 | catch(std::bad_alloc&) |
| 5972 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5973 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5974 | } |
| 5975 | } |
| 5976 | |
| 5977 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 5978 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5979 | EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5980 | |
| 5981 | try |
| 5982 | { |
| 5983 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5984 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5985 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5986 | } |
| 5987 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5988 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 5989 | |
| 5990 | if (context) |
| 5991 | { |
| 5992 | GLfloat vals[4] = { values[0], values[1], values[2], 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 5993 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 5994 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5995 | } |
| 5996 | catch(std::bad_alloc&) |
| 5997 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5998 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5999 | } |
| 6000 | } |
| 6001 | |
| 6002 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 6003 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6004 | EVENT("(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] | 6005 | |
| 6006 | try |
| 6007 | { |
| 6008 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6009 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6010 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6011 | } |
| 6012 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6013 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 6014 | |
| 6015 | if (context) |
| 6016 | { |
| 6017 | GLfloat vals[4] = { x, y, z, w }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 6018 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 6019 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6020 | } |
| 6021 | catch(std::bad_alloc&) |
| 6022 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6023 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6024 | } |
| 6025 | } |
| 6026 | |
| 6027 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 6028 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6029 | EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6030 | |
| 6031 | try |
| 6032 | { |
| 6033 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6034 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6035 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6036 | } |
| 6037 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6038 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 6039 | |
| 6040 | if (context) |
| 6041 | { |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 6042 | context->setVertexAttribf(index, values); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 6043 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6044 | } |
| 6045 | catch(std::bad_alloc&) |
| 6046 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6047 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6048 | } |
| 6049 | } |
| 6050 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 6051 | void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
| 6052 | { |
| 6053 | EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor); |
| 6054 | |
| 6055 | try |
| 6056 | { |
| 6057 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6058 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6059 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 6060 | } |
| 6061 | |
| 6062 | gl::Context *context = gl::getNonLostContext(); |
| 6063 | |
| 6064 | if (context) |
| 6065 | { |
| 6066 | context->setVertexAttribDivisor(index, divisor); |
| 6067 | } |
| 6068 | } |
| 6069 | catch(std::bad_alloc&) |
| 6070 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6071 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 6072 | } |
| 6073 | } |
| 6074 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6075 | 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] | 6076 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6077 | EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, " |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6078 | "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 6079 | index, size, type, normalized, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6080 | |
| 6081 | try |
| 6082 | { |
| 6083 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6084 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6085 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6086 | } |
| 6087 | |
| 6088 | if (size < 1 || size > 4) |
| 6089 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6090 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6091 | } |
| 6092 | |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 6093 | gl::Context *context = gl::getNonLostContext(); |
| 6094 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6095 | switch (type) |
| 6096 | { |
| 6097 | case GL_BYTE: |
| 6098 | case GL_UNSIGNED_BYTE: |
| 6099 | case GL_SHORT: |
| 6100 | case GL_UNSIGNED_SHORT: |
| 6101 | case GL_FIXED: |
| 6102 | case GL_FLOAT: |
| 6103 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 6104 | case GL_HALF_FLOAT: |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 6105 | case GL_INT: |
| 6106 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 6107 | case GL_INT_2_10_10_10_REV: |
| 6108 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 6109 | if (context && context->getClientVersion() < 3) |
| 6110 | { |
| 6111 | return gl::error(GL_INVALID_ENUM); |
| 6112 | } |
| 6113 | else |
| 6114 | { |
| 6115 | break; |
| 6116 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6117 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6118 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6119 | } |
| 6120 | |
| 6121 | if (stride < 0) |
| 6122 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6123 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6124 | } |
| 6125 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 6126 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 6127 | { |
| 6128 | return gl::error(GL_INVALID_OPERATION); |
| 6129 | } |
| 6130 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6131 | if (context) |
| 6132 | { |
Jamie Madill | d8db866 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 6133 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 6134 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 6135 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 6136 | // and the pointer argument is not NULL. |
| 6137 | if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && ptr != NULL) |
| 6138 | { |
| 6139 | return gl::error(GL_INVALID_OPERATION); |
| 6140 | } |
| 6141 | |
shannon.woods%transgaming.com@gtempaccount.com | 8de4e6a | 2013-04-13 03:37:44 +0000 | [diff] [blame] | 6142 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, |
| 6143 | normalized == GL_TRUE, false, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6144 | } |
| 6145 | } |
| 6146 | catch(std::bad_alloc&) |
| 6147 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6148 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6149 | } |
| 6150 | } |
| 6151 | |
| 6152 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 6153 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6154 | EVENT("(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] | 6155 | |
| 6156 | try |
| 6157 | { |
| 6158 | if (width < 0 || height < 0) |
| 6159 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6160 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6161 | } |
| 6162 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6163 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6164 | |
| 6165 | if (context) |
| 6166 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6167 | context->setViewportParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6168 | } |
| 6169 | } |
| 6170 | catch(std::bad_alloc&) |
| 6171 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6172 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6173 | } |
| 6174 | } |
| 6175 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6176 | // OpenGL ES 3.0 functions |
| 6177 | |
| 6178 | void __stdcall glReadBuffer(GLenum mode) |
| 6179 | { |
| 6180 | EVENT("(GLenum mode = 0x%X)", mode); |
| 6181 | |
| 6182 | try |
| 6183 | { |
| 6184 | gl::Context *context = gl::getNonLostContext(); |
| 6185 | |
| 6186 | if (context) |
| 6187 | { |
| 6188 | if (context->getClientVersion() < 3) |
| 6189 | { |
| 6190 | return gl::error(GL_INVALID_OPERATION); |
| 6191 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6192 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 6193 | // glReadBuffer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6194 | UNIMPLEMENTED(); |
| 6195 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6196 | } |
| 6197 | catch(std::bad_alloc&) |
| 6198 | { |
| 6199 | return gl::error(GL_OUT_OF_MEMORY); |
| 6200 | } |
| 6201 | } |
| 6202 | |
| 6203 | void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) |
| 6204 | { |
| 6205 | EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, " |
| 6206 | "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices); |
| 6207 | |
| 6208 | try |
| 6209 | { |
| 6210 | gl::Context *context = gl::getNonLostContext(); |
| 6211 | |
| 6212 | if (context) |
| 6213 | { |
| 6214 | if (context->getClientVersion() < 3) |
| 6215 | { |
| 6216 | return gl::error(GL_INVALID_OPERATION); |
| 6217 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6218 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 6219 | // glDrawRangeElements |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6220 | UNIMPLEMENTED(); |
| 6221 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6222 | } |
| 6223 | catch(std::bad_alloc&) |
| 6224 | { |
| 6225 | return gl::error(GL_OUT_OF_MEMORY); |
| 6226 | } |
| 6227 | } |
| 6228 | |
| 6229 | void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
| 6230 | { |
| 6231 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 6232 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " |
| 6233 | "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 6234 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 6235 | |
| 6236 | try |
| 6237 | { |
| 6238 | gl::Context *context = gl::getNonLostContext(); |
| 6239 | |
| 6240 | if (context) |
| 6241 | { |
| 6242 | if (context->getClientVersion() < 3) |
| 6243 | { |
| 6244 | return gl::error(GL_INVALID_OPERATION); |
| 6245 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6246 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 6247 | // validateES3TexImageFormat sets the error code if there is an error |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 6248 | if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false, |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 6249 | 0, 0, 0, width, height, depth, border, format, type)) |
| 6250 | { |
| 6251 | return; |
| 6252 | } |
| 6253 | |
| 6254 | switch(target) |
| 6255 | { |
| 6256 | case GL_TEXTURE_3D: |
| 6257 | { |
| 6258 | gl::Texture3D *texture = context->getTexture3D(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 6259 | texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackAlignment(), pixels); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 6260 | } |
| 6261 | break; |
| 6262 | |
| 6263 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 6264 | { |
| 6265 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 6266 | texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackAlignment(), pixels); |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 6267 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 6268 | break; |
| 6269 | |
| 6270 | default: |
| 6271 | return gl::error(GL_INVALID_ENUM); |
| 6272 | } |
| 6273 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6274 | } |
| 6275 | catch(std::bad_alloc&) |
| 6276 | { |
| 6277 | return gl::error(GL_OUT_OF_MEMORY); |
| 6278 | } |
| 6279 | } |
| 6280 | |
| 6281 | void __stdcall glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) |
| 6282 | { |
| 6283 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 6284 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 6285 | "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 6286 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); |
| 6287 | |
| 6288 | try |
| 6289 | { |
| 6290 | gl::Context *context = gl::getNonLostContext(); |
| 6291 | |
| 6292 | if (context) |
| 6293 | { |
| 6294 | if (context->getClientVersion() < 3) |
| 6295 | { |
| 6296 | return gl::error(GL_INVALID_OPERATION); |
| 6297 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6298 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 6299 | if (!pixels) |
| 6300 | { |
| 6301 | return gl::error(GL_INVALID_VALUE); |
| 6302 | } |
| 6303 | |
| 6304 | // validateES3TexImageFormat sets the error code if there is an error |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 6305 | if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 6306 | xoffset, yoffset, zoffset, width, height, depth, 0, |
| 6307 | format, type)) |
| 6308 | { |
| 6309 | return; |
| 6310 | } |
| 6311 | |
| 6312 | switch(target) |
| 6313 | { |
| 6314 | case GL_TEXTURE_3D: |
| 6315 | { |
| 6316 | gl::Texture3D *texture = context->getTexture3D(); |
| 6317 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 6318 | } |
| 6319 | break; |
| 6320 | |
| 6321 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 6322 | { |
| 6323 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 6324 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 6325 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 6326 | break; |
| 6327 | |
| 6328 | default: |
| 6329 | return gl::error(GL_INVALID_ENUM); |
| 6330 | } |
| 6331 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6332 | } |
| 6333 | catch(std::bad_alloc&) |
| 6334 | { |
| 6335 | return gl::error(GL_OUT_OF_MEMORY); |
| 6336 | } |
| 6337 | } |
| 6338 | |
| 6339 | void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 6340 | { |
| 6341 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 6342 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 6343 | target, level, xoffset, yoffset, zoffset, x, y, width, height); |
| 6344 | |
| 6345 | try |
| 6346 | { |
| 6347 | gl::Context *context = gl::getNonLostContext(); |
| 6348 | |
| 6349 | if (context) |
| 6350 | { |
| 6351 | if (context->getClientVersion() < 3) |
| 6352 | { |
| 6353 | return gl::error(GL_INVALID_OPERATION); |
| 6354 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6355 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 6356 | if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset, |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 6357 | x, y, width, height, 0)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 6358 | { |
| 6359 | return; |
| 6360 | } |
| 6361 | |
| 6362 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 6363 | gl::Texture *texture = NULL; |
| 6364 | switch (target) |
| 6365 | { |
| 6366 | case GL_TEXTURE_3D: |
| 6367 | texture = context->getTexture3D(); |
| 6368 | break; |
| 6369 | |
| 6370 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 6371 | texture = context->getTexture2DArray(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 6372 | break; |
| 6373 | |
| 6374 | default: |
| 6375 | return gl::error(GL_INVALID_ENUM); |
| 6376 | } |
| 6377 | |
| 6378 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer); |
| 6379 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6380 | } |
| 6381 | catch(std::bad_alloc&) |
| 6382 | { |
| 6383 | return gl::error(GL_OUT_OF_MEMORY); |
| 6384 | } |
| 6385 | } |
| 6386 | |
| 6387 | void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) |
| 6388 | { |
| 6389 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 6390 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, " |
| 6391 | "const GLvoid* data = 0x%0.8p)", |
| 6392 | target, level, internalformat, width, height, depth, border, imageSize, data); |
| 6393 | |
| 6394 | try |
| 6395 | { |
| 6396 | gl::Context *context = gl::getNonLostContext(); |
| 6397 | |
| 6398 | if (context) |
| 6399 | { |
| 6400 | if (context->getClientVersion() < 3) |
| 6401 | { |
| 6402 | return gl::error(GL_INVALID_OPERATION); |
| 6403 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6404 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6405 | if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 6406 | { |
| 6407 | return gl::error(GL_INVALID_VALUE); |
| 6408 | } |
| 6409 | |
| 6410 | // validateES3TexImageFormat sets the error code if there is an error |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 6411 | if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false, |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 6412 | 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 6413 | { |
| 6414 | return; |
| 6415 | } |
| 6416 | |
| 6417 | switch(target) |
| 6418 | { |
| 6419 | case GL_TEXTURE_3D: |
| 6420 | { |
| 6421 | gl::Texture3D *texture = context->getTexture3D(); |
| 6422 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 6423 | } |
| 6424 | break; |
| 6425 | |
| 6426 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 6427 | { |
| 6428 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 6429 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 6430 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 6431 | break; |
| 6432 | |
| 6433 | default: |
| 6434 | return gl::error(GL_INVALID_ENUM); |
| 6435 | } |
| 6436 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6437 | } |
| 6438 | catch(std::bad_alloc&) |
| 6439 | { |
| 6440 | return gl::error(GL_OUT_OF_MEMORY); |
| 6441 | } |
| 6442 | } |
| 6443 | |
| 6444 | void __stdcall glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) |
| 6445 | { |
| 6446 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 6447 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 6448 | "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 6449 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); |
| 6450 | |
| 6451 | try |
| 6452 | { |
| 6453 | gl::Context *context = gl::getNonLostContext(); |
| 6454 | |
| 6455 | if (context) |
| 6456 | { |
| 6457 | if (context->getClientVersion() < 3) |
| 6458 | { |
| 6459 | return gl::error(GL_INVALID_OPERATION); |
| 6460 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6461 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6462 | if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 6463 | { |
| 6464 | return gl::error(GL_INVALID_VALUE); |
| 6465 | } |
| 6466 | |
| 6467 | if (!data) |
| 6468 | { |
| 6469 | return gl::error(GL_INVALID_VALUE); |
| 6470 | } |
| 6471 | |
| 6472 | // validateES3TexImageFormat sets the error code if there is an error |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 6473 | if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 6474 | 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 6475 | { |
| 6476 | return; |
| 6477 | } |
| 6478 | |
| 6479 | switch(target) |
| 6480 | { |
| 6481 | case GL_TEXTURE_3D: |
| 6482 | { |
| 6483 | gl::Texture3D *texture = context->getTexture3D(); |
| 6484 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 6485 | format, imageSize, data); |
| 6486 | } |
| 6487 | break; |
| 6488 | |
| 6489 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 6490 | { |
| 6491 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 6492 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 6493 | format, imageSize, data); |
| 6494 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 6495 | break; |
| 6496 | |
| 6497 | default: |
| 6498 | return gl::error(GL_INVALID_ENUM); |
| 6499 | } |
| 6500 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6501 | } |
| 6502 | catch(std::bad_alloc&) |
| 6503 | { |
| 6504 | return gl::error(GL_OUT_OF_MEMORY); |
| 6505 | } |
| 6506 | } |
| 6507 | |
| 6508 | void __stdcall glGenQueries(GLsizei n, GLuint* ids) |
| 6509 | { |
| 6510 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 6511 | |
| 6512 | try |
| 6513 | { |
| 6514 | gl::Context *context = gl::getNonLostContext(); |
| 6515 | |
| 6516 | if (context) |
| 6517 | { |
| 6518 | if (context->getClientVersion() < 3) |
| 6519 | { |
| 6520 | return gl::error(GL_INVALID_OPERATION); |
| 6521 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6522 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 6523 | glGenQueriesEXT(n, ids); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6524 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6525 | } |
| 6526 | catch(std::bad_alloc&) |
| 6527 | { |
| 6528 | return gl::error(GL_OUT_OF_MEMORY); |
| 6529 | } |
| 6530 | } |
| 6531 | |
| 6532 | void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids) |
| 6533 | { |
| 6534 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 6535 | |
| 6536 | try |
| 6537 | { |
| 6538 | gl::Context *context = gl::getNonLostContext(); |
| 6539 | |
| 6540 | if (context) |
| 6541 | { |
| 6542 | if (context->getClientVersion() < 3) |
| 6543 | { |
| 6544 | return gl::error(GL_INVALID_OPERATION); |
| 6545 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6546 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 6547 | glDeleteQueriesEXT(n, ids); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6548 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6549 | } |
| 6550 | catch(std::bad_alloc&) |
| 6551 | { |
| 6552 | return gl::error(GL_OUT_OF_MEMORY); |
| 6553 | } |
| 6554 | } |
| 6555 | |
| 6556 | GLboolean __stdcall glIsQuery(GLuint id) |
| 6557 | { |
| 6558 | EVENT("(GLuint id = %u)", id); |
| 6559 | |
| 6560 | try |
| 6561 | { |
| 6562 | gl::Context *context = gl::getNonLostContext(); |
| 6563 | |
| 6564 | if (context) |
| 6565 | { |
| 6566 | if (context->getClientVersion() < 3) |
| 6567 | { |
| 6568 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 6569 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6570 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 6571 | // TODO: XFB queries |
| 6572 | return glIsQueryEXT(id); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6573 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6574 | } |
| 6575 | catch(std::bad_alloc&) |
| 6576 | { |
| 6577 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 6578 | } |
| 6579 | |
| 6580 | return GL_FALSE; |
| 6581 | } |
| 6582 | |
| 6583 | void __stdcall glBeginQuery(GLenum target, GLuint id) |
| 6584 | { |
| 6585 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 6586 | |
| 6587 | try |
| 6588 | { |
| 6589 | gl::Context *context = gl::getNonLostContext(); |
| 6590 | |
| 6591 | if (context) |
| 6592 | { |
| 6593 | if (context->getClientVersion() < 3) |
| 6594 | { |
| 6595 | return gl::error(GL_INVALID_OPERATION); |
| 6596 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6597 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 6598 | switch (target) |
| 6599 | { |
| 6600 | case GL_ANY_SAMPLES_PASSED: |
| 6601 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE: |
| 6602 | case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: |
| 6603 | break; |
| 6604 | default: |
| 6605 | return gl::error(GL_INVALID_ENUM); |
| 6606 | } |
| 6607 | |
| 6608 | if (id == 0) |
| 6609 | { |
| 6610 | return gl::error(GL_INVALID_OPERATION); |
| 6611 | } |
| 6612 | |
| 6613 | if (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN) |
| 6614 | { |
| 6615 | // TODO: XFB queries |
| 6616 | UNIMPLEMENTED(); |
| 6617 | } |
| 6618 | else |
| 6619 | { |
| 6620 | context->beginQuery(target, id); |
| 6621 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6622 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6623 | } |
| 6624 | catch(std::bad_alloc&) |
| 6625 | { |
| 6626 | return gl::error(GL_OUT_OF_MEMORY); |
| 6627 | } |
| 6628 | } |
| 6629 | |
| 6630 | void __stdcall glEndQuery(GLenum target) |
| 6631 | { |
| 6632 | EVENT("(GLenum target = 0x%X)", target); |
| 6633 | |
| 6634 | try |
| 6635 | { |
| 6636 | gl::Context *context = gl::getNonLostContext(); |
| 6637 | |
| 6638 | if (context) |
| 6639 | { |
| 6640 | if (context->getClientVersion() < 3) |
| 6641 | { |
| 6642 | return gl::error(GL_INVALID_OPERATION); |
| 6643 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6644 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 6645 | if (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN) |
| 6646 | { |
| 6647 | // TODO: XFB queries |
| 6648 | UNIMPLEMENTED(); |
| 6649 | } |
| 6650 | else |
| 6651 | { |
| 6652 | glEndQueryEXT(target); |
| 6653 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6654 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6655 | } |
| 6656 | catch(std::bad_alloc&) |
| 6657 | { |
| 6658 | return gl::error(GL_OUT_OF_MEMORY); |
| 6659 | } |
| 6660 | } |
| 6661 | |
| 6662 | void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params) |
| 6663 | { |
| 6664 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
| 6665 | |
| 6666 | try |
| 6667 | { |
| 6668 | gl::Context *context = gl::getNonLostContext(); |
| 6669 | |
| 6670 | if (context) |
| 6671 | { |
| 6672 | if (context->getClientVersion() < 3) |
| 6673 | { |
| 6674 | return gl::error(GL_INVALID_OPERATION); |
| 6675 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6676 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 6677 | if (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN) |
| 6678 | { |
| 6679 | // TODO: XFB queries |
| 6680 | UNIMPLEMENTED(); |
| 6681 | } |
| 6682 | else |
| 6683 | { |
| 6684 | glGetQueryivEXT(target, pname, params); |
| 6685 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6686 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6687 | } |
| 6688 | catch(std::bad_alloc&) |
| 6689 | { |
| 6690 | return gl::error(GL_OUT_OF_MEMORY); |
| 6691 | } |
| 6692 | } |
| 6693 | |
| 6694 | void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) |
| 6695 | { |
| 6696 | EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params); |
| 6697 | |
| 6698 | try |
| 6699 | { |
| 6700 | gl::Context *context = gl::getNonLostContext(); |
| 6701 | |
| 6702 | if (context) |
| 6703 | { |
| 6704 | if (context->getClientVersion() < 3) |
| 6705 | { |
| 6706 | return gl::error(GL_INVALID_OPERATION); |
| 6707 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6708 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 6709 | // TODO: XFB queries |
| 6710 | glGetQueryObjectuivEXT(id, pname, params); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6711 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6712 | } |
| 6713 | catch(std::bad_alloc&) |
| 6714 | { |
| 6715 | return gl::error(GL_OUT_OF_MEMORY); |
| 6716 | } |
| 6717 | } |
| 6718 | |
| 6719 | GLboolean __stdcall glUnmapBuffer(GLenum target) |
| 6720 | { |
| 6721 | EVENT("(GLenum target = 0x%X)", target); |
| 6722 | |
| 6723 | try |
| 6724 | { |
| 6725 | gl::Context *context = gl::getNonLostContext(); |
| 6726 | |
| 6727 | if (context) |
| 6728 | { |
| 6729 | if (context->getClientVersion() < 3) |
| 6730 | { |
| 6731 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 6732 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6733 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 6734 | // glUnmapBuffer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6735 | UNIMPLEMENTED(); |
| 6736 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6737 | } |
| 6738 | catch(std::bad_alloc&) |
| 6739 | { |
| 6740 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 6741 | } |
| 6742 | |
| 6743 | return GL_FALSE; |
| 6744 | } |
| 6745 | |
| 6746 | void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) |
| 6747 | { |
| 6748 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 6749 | |
| 6750 | try |
| 6751 | { |
| 6752 | gl::Context *context = gl::getNonLostContext(); |
| 6753 | |
| 6754 | if (context) |
| 6755 | { |
| 6756 | if (context->getClientVersion() < 3) |
| 6757 | { |
| 6758 | return gl::error(GL_INVALID_OPERATION); |
| 6759 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6760 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 6761 | // glGetBufferPointerv |
shannonwoods@chromium.org | 2d2190a | 2013-05-30 00:17:35 +0000 | [diff] [blame] | 6762 | UNIMPLEMENTED(); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6763 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6764 | } |
| 6765 | catch(std::bad_alloc&) |
| 6766 | { |
| 6767 | return gl::error(GL_OUT_OF_MEMORY); |
| 6768 | } |
| 6769 | } |
| 6770 | |
| 6771 | void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs) |
| 6772 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6773 | try |
| 6774 | { |
| 6775 | gl::Context *context = gl::getNonLostContext(); |
| 6776 | |
| 6777 | if (context) |
| 6778 | { |
| 6779 | if (context->getClientVersion() < 3) |
| 6780 | { |
| 6781 | return gl::error(GL_INVALID_OPERATION); |
| 6782 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6783 | |
shannon.woods%transgaming.com@gtempaccount.com | 7948c5f | 2013-04-13 03:38:58 +0000 | [diff] [blame] | 6784 | glDrawBuffersEXT(n, bufs); |
| 6785 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6786 | } |
| 6787 | catch(std::bad_alloc&) |
| 6788 | { |
| 6789 | return gl::error(GL_OUT_OF_MEMORY); |
| 6790 | } |
| 6791 | } |
| 6792 | |
| 6793 | void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 6794 | { |
| 6795 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 6796 | location, count, transpose, value); |
| 6797 | |
| 6798 | try |
| 6799 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 6800 | if (count < 0) |
| 6801 | { |
| 6802 | return gl::error(GL_INVALID_VALUE); |
| 6803 | } |
| 6804 | |
| 6805 | if (location == -1) |
| 6806 | { |
| 6807 | return; |
| 6808 | } |
| 6809 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6810 | gl::Context *context = gl::getNonLostContext(); |
| 6811 | |
| 6812 | if (context) |
| 6813 | { |
| 6814 | if (context->getClientVersion() < 3) |
| 6815 | { |
| 6816 | return gl::error(GL_INVALID_OPERATION); |
| 6817 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6818 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 6819 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 6820 | if (!programBinary) |
| 6821 | { |
| 6822 | return gl::error(GL_INVALID_OPERATION); |
| 6823 | } |
| 6824 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 6825 | if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 6826 | { |
| 6827 | return gl::error(GL_INVALID_OPERATION); |
| 6828 | } |
| 6829 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6830 | } |
| 6831 | catch(std::bad_alloc&) |
| 6832 | { |
| 6833 | return gl::error(GL_OUT_OF_MEMORY); |
| 6834 | } |
| 6835 | } |
| 6836 | |
| 6837 | void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 6838 | { |
| 6839 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 6840 | location, count, transpose, value); |
| 6841 | |
| 6842 | try |
| 6843 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 6844 | if (count < 0) |
| 6845 | { |
| 6846 | return gl::error(GL_INVALID_VALUE); |
| 6847 | } |
| 6848 | |
| 6849 | if (location == -1) |
| 6850 | { |
| 6851 | return; |
| 6852 | } |
| 6853 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6854 | gl::Context *context = gl::getNonLostContext(); |
| 6855 | |
| 6856 | if (context) |
| 6857 | { |
| 6858 | if (context->getClientVersion() < 3) |
| 6859 | { |
| 6860 | return gl::error(GL_INVALID_OPERATION); |
| 6861 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6862 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 6863 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 6864 | if (!programBinary) |
| 6865 | { |
| 6866 | return gl::error(GL_INVALID_OPERATION); |
| 6867 | } |
| 6868 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 6869 | if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 6870 | { |
| 6871 | return gl::error(GL_INVALID_OPERATION); |
| 6872 | } |
| 6873 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6874 | } |
| 6875 | catch(std::bad_alloc&) |
| 6876 | { |
| 6877 | return gl::error(GL_OUT_OF_MEMORY); |
| 6878 | } |
| 6879 | } |
| 6880 | |
| 6881 | void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 6882 | { |
| 6883 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 6884 | location, count, transpose, value); |
| 6885 | |
| 6886 | try |
| 6887 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 6888 | if (count < 0) |
| 6889 | { |
| 6890 | return gl::error(GL_INVALID_VALUE); |
| 6891 | } |
| 6892 | |
| 6893 | if (location == -1) |
| 6894 | { |
| 6895 | return; |
| 6896 | } |
| 6897 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6898 | gl::Context *context = gl::getNonLostContext(); |
| 6899 | |
| 6900 | if (context) |
| 6901 | { |
| 6902 | if (context->getClientVersion() < 3) |
| 6903 | { |
| 6904 | return gl::error(GL_INVALID_OPERATION); |
| 6905 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6906 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 6907 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 6908 | if (!programBinary) |
| 6909 | { |
| 6910 | return gl::error(GL_INVALID_OPERATION); |
| 6911 | } |
| 6912 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 6913 | if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 6914 | { |
| 6915 | return gl::error(GL_INVALID_OPERATION); |
| 6916 | } |
| 6917 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6918 | } |
| 6919 | catch(std::bad_alloc&) |
| 6920 | { |
| 6921 | return gl::error(GL_OUT_OF_MEMORY); |
| 6922 | } |
| 6923 | } |
| 6924 | |
| 6925 | void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 6926 | { |
| 6927 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 6928 | location, count, transpose, value); |
| 6929 | |
| 6930 | try |
| 6931 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 6932 | if (count < 0) |
| 6933 | { |
| 6934 | return gl::error(GL_INVALID_VALUE); |
| 6935 | } |
| 6936 | |
| 6937 | if (location == -1) |
| 6938 | { |
| 6939 | return; |
| 6940 | } |
| 6941 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6942 | gl::Context *context = gl::getNonLostContext(); |
| 6943 | |
| 6944 | if (context) |
| 6945 | { |
| 6946 | if (context->getClientVersion() < 3) |
| 6947 | { |
| 6948 | return gl::error(GL_INVALID_OPERATION); |
| 6949 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6950 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 6951 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 6952 | if (!programBinary) |
| 6953 | { |
| 6954 | return gl::error(GL_INVALID_OPERATION); |
| 6955 | } |
| 6956 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 6957 | if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 6958 | { |
| 6959 | return gl::error(GL_INVALID_OPERATION); |
| 6960 | } |
| 6961 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6962 | } |
| 6963 | catch(std::bad_alloc&) |
| 6964 | { |
| 6965 | return gl::error(GL_OUT_OF_MEMORY); |
| 6966 | } |
| 6967 | } |
| 6968 | |
| 6969 | void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 6970 | { |
| 6971 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 6972 | location, count, transpose, value); |
| 6973 | |
| 6974 | try |
| 6975 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 6976 | if (count < 0) |
| 6977 | { |
| 6978 | return gl::error(GL_INVALID_VALUE); |
| 6979 | } |
| 6980 | |
| 6981 | if (location == -1) |
| 6982 | { |
| 6983 | return; |
| 6984 | } |
| 6985 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6986 | gl::Context *context = gl::getNonLostContext(); |
| 6987 | |
| 6988 | if (context) |
| 6989 | { |
| 6990 | if (context->getClientVersion() < 3) |
| 6991 | { |
| 6992 | return gl::error(GL_INVALID_OPERATION); |
| 6993 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6994 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 6995 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 6996 | if (!programBinary) |
| 6997 | { |
| 6998 | return gl::error(GL_INVALID_OPERATION); |
| 6999 | } |
| 7000 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7001 | if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 7002 | { |
| 7003 | return gl::error(GL_INVALID_OPERATION); |
| 7004 | } |
| 7005 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7006 | } |
| 7007 | catch(std::bad_alloc&) |
| 7008 | { |
| 7009 | return gl::error(GL_OUT_OF_MEMORY); |
| 7010 | } |
| 7011 | } |
| 7012 | |
| 7013 | void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7014 | { |
| 7015 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 7016 | location, count, transpose, value); |
| 7017 | |
| 7018 | try |
| 7019 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 7020 | if (count < 0) |
| 7021 | { |
| 7022 | return gl::error(GL_INVALID_VALUE); |
| 7023 | } |
| 7024 | |
| 7025 | if (location == -1) |
| 7026 | { |
| 7027 | return; |
| 7028 | } |
| 7029 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7030 | gl::Context *context = gl::getNonLostContext(); |
| 7031 | |
| 7032 | if (context) |
| 7033 | { |
| 7034 | if (context->getClientVersion() < 3) |
| 7035 | { |
| 7036 | return gl::error(GL_INVALID_OPERATION); |
| 7037 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7038 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 7039 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 7040 | if (!programBinary) |
| 7041 | { |
| 7042 | return gl::error(GL_INVALID_OPERATION); |
| 7043 | } |
| 7044 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7045 | if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 7046 | { |
| 7047 | return gl::error(GL_INVALID_OPERATION); |
| 7048 | } |
| 7049 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7050 | } |
| 7051 | catch(std::bad_alloc&) |
| 7052 | { |
| 7053 | return gl::error(GL_OUT_OF_MEMORY); |
| 7054 | } |
| 7055 | } |
| 7056 | |
| 7057 | void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) |
| 7058 | { |
| 7059 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, " |
| 7060 | "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 7061 | srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 7062 | |
| 7063 | try |
| 7064 | { |
| 7065 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7066 | if (context) |
| 7067 | { |
| 7068 | if (context->getClientVersion() < 3) |
| 7069 | { |
| 7070 | return gl::error(GL_INVALID_OPERATION); |
| 7071 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7072 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 7073 | if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 7074 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 7075 | false)) |
| 7076 | { |
| 7077 | return; |
| 7078 | } |
| 7079 | |
| 7080 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 7081 | mask, filter); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7082 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7083 | } |
| 7084 | catch(std::bad_alloc&) |
| 7085 | { |
| 7086 | return gl::error(GL_OUT_OF_MEMORY); |
| 7087 | } |
| 7088 | } |
| 7089 | |
| 7090 | void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| 7091 | { |
| 7092 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 7093 | target, samples, internalformat, width, height); |
| 7094 | |
| 7095 | try |
| 7096 | { |
| 7097 | gl::Context *context = gl::getNonLostContext(); |
| 7098 | |
| 7099 | if (context) |
| 7100 | { |
| 7101 | if (context->getClientVersion() < 3) |
| 7102 | { |
| 7103 | return gl::error(GL_INVALID_OPERATION); |
| 7104 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7105 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 7106 | if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat, |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 7107 | width, height, false)) |
| 7108 | { |
| 7109 | return; |
| 7110 | } |
| 7111 | |
| 7112 | context->setRenderbufferStorage(width, height, internalformat, samples); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7113 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7114 | } |
| 7115 | catch(std::bad_alloc&) |
| 7116 | { |
| 7117 | return gl::error(GL_OUT_OF_MEMORY); |
| 7118 | } |
| 7119 | } |
| 7120 | |
| 7121 | void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) |
| 7122 | { |
| 7123 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)", |
| 7124 | target, attachment, texture, level, layer); |
| 7125 | |
| 7126 | try |
| 7127 | { |
| 7128 | gl::Context *context = gl::getNonLostContext(); |
| 7129 | |
| 7130 | if (context) |
| 7131 | { |
| 7132 | if (context->getClientVersion() < 3) |
| 7133 | { |
| 7134 | return gl::error(GL_INVALID_OPERATION); |
| 7135 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7136 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 7137 | if (!ValidateES3FramebufferTextureParameters(context, target, attachment, GL_NONE, texture, level, layer, true)) |
Geoff Lang | 3ed0c48 | 2013-07-25 17:03:18 -0400 | [diff] [blame] | 7138 | { |
| 7139 | return; |
| 7140 | } |
| 7141 | |
| 7142 | gl::Framebuffer *framebuffer = NULL; |
| 7143 | if (target == GL_READ_FRAMEBUFFER) |
| 7144 | { |
| 7145 | framebuffer = context->getReadFramebuffer(); |
| 7146 | } |
| 7147 | else |
| 7148 | { |
| 7149 | framebuffer = context->getDrawFramebuffer(); |
| 7150 | } |
| 7151 | |
| 7152 | gl::Texture *textureObject = context->getTexture(texture); |
| 7153 | GLenum textarget = textureObject ? textureObject->getTarget() : GL_NONE; |
| 7154 | |
| 7155 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 7156 | { |
| 7157 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 7158 | framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, layer); |
| 7159 | } |
| 7160 | else |
| 7161 | { |
| 7162 | switch (attachment) |
| 7163 | { |
| 7164 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, layer); break; |
| 7165 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, layer); break; |
| 7166 | case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, layer); break; |
| 7167 | } |
| 7168 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7169 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7170 | } |
| 7171 | catch(std::bad_alloc&) |
| 7172 | { |
| 7173 | return gl::error(GL_OUT_OF_MEMORY); |
| 7174 | } |
| 7175 | } |
| 7176 | |
| 7177 | GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 7178 | { |
| 7179 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 7180 | target, offset, length, access); |
| 7181 | |
| 7182 | try |
| 7183 | { |
| 7184 | gl::Context *context = gl::getNonLostContext(); |
| 7185 | |
| 7186 | if (context) |
| 7187 | { |
| 7188 | if (context->getClientVersion() < 3) |
| 7189 | { |
| 7190 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 7191 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7192 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 7193 | // glMapBufferRange |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7194 | UNIMPLEMENTED(); |
| 7195 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7196 | } |
| 7197 | catch(std::bad_alloc&) |
| 7198 | { |
| 7199 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL)); |
| 7200 | } |
| 7201 | |
| 7202 | return NULL; |
| 7203 | } |
| 7204 | |
| 7205 | void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) |
| 7206 | { |
| 7207 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 7208 | |
| 7209 | try |
| 7210 | { |
| 7211 | gl::Context *context = gl::getNonLostContext(); |
| 7212 | |
| 7213 | if (context) |
| 7214 | { |
| 7215 | if (context->getClientVersion() < 3) |
| 7216 | { |
| 7217 | return gl::error(GL_INVALID_OPERATION); |
| 7218 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7219 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 7220 | // glFlushMappedBufferRange |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7221 | UNIMPLEMENTED(); |
| 7222 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7223 | } |
| 7224 | catch(std::bad_alloc&) |
| 7225 | { |
| 7226 | return gl::error(GL_OUT_OF_MEMORY); |
| 7227 | } |
| 7228 | } |
| 7229 | |
| 7230 | void __stdcall glBindVertexArray(GLuint array) |
| 7231 | { |
| 7232 | EVENT("(GLuint array = %u)", array); |
| 7233 | |
| 7234 | try |
| 7235 | { |
| 7236 | gl::Context *context = gl::getNonLostContext(); |
| 7237 | |
| 7238 | if (context) |
| 7239 | { |
| 7240 | if (context->getClientVersion() < 3) |
| 7241 | { |
| 7242 | return gl::error(GL_INVALID_OPERATION); |
| 7243 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7244 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 7245 | gl::VertexArray *vao = context->getVertexArray(array); |
| 7246 | |
| 7247 | if (!vao) |
| 7248 | { |
| 7249 | // The default VAO should always exist |
| 7250 | ASSERT(array != 0); |
| 7251 | return gl::error(GL_INVALID_OPERATION); |
| 7252 | } |
| 7253 | |
| 7254 | context->bindVertexArray(array); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7255 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7256 | } |
| 7257 | catch(std::bad_alloc&) |
| 7258 | { |
| 7259 | return gl::error(GL_OUT_OF_MEMORY); |
| 7260 | } |
| 7261 | } |
| 7262 | |
| 7263 | void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) |
| 7264 | { |
| 7265 | EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays); |
| 7266 | |
| 7267 | try |
| 7268 | { |
| 7269 | gl::Context *context = gl::getNonLostContext(); |
| 7270 | |
| 7271 | if (context) |
| 7272 | { |
| 7273 | if (context->getClientVersion() < 3) |
| 7274 | { |
| 7275 | return gl::error(GL_INVALID_OPERATION); |
| 7276 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7277 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 7278 | if (n < 0) |
| 7279 | { |
| 7280 | return gl::error(GL_INVALID_VALUE); |
| 7281 | } |
| 7282 | |
| 7283 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 7284 | { |
| 7285 | if (arrays[arrayIndex] != 0) |
| 7286 | { |
| 7287 | context->deleteVertexArray(arrays[arrayIndex]); |
| 7288 | } |
| 7289 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7290 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7291 | } |
| 7292 | catch(std::bad_alloc&) |
| 7293 | { |
| 7294 | return gl::error(GL_OUT_OF_MEMORY); |
| 7295 | } |
| 7296 | } |
| 7297 | |
| 7298 | void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) |
| 7299 | { |
| 7300 | EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays); |
| 7301 | |
| 7302 | try |
| 7303 | { |
| 7304 | gl::Context *context = gl::getNonLostContext(); |
| 7305 | |
| 7306 | if (context) |
| 7307 | { |
| 7308 | if (context->getClientVersion() < 3) |
| 7309 | { |
| 7310 | return gl::error(GL_INVALID_OPERATION); |
| 7311 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7312 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 7313 | if (n < 0) |
| 7314 | { |
| 7315 | return gl::error(GL_INVALID_VALUE); |
| 7316 | } |
| 7317 | |
| 7318 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 7319 | { |
| 7320 | arrays[arrayIndex] = context->createVertexArray(); |
| 7321 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7322 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7323 | } |
| 7324 | catch(std::bad_alloc&) |
| 7325 | { |
| 7326 | return gl::error(GL_OUT_OF_MEMORY); |
| 7327 | } |
| 7328 | } |
| 7329 | |
| 7330 | GLboolean __stdcall glIsVertexArray(GLuint array) |
| 7331 | { |
| 7332 | EVENT("(GLuint array = %u)", array); |
| 7333 | |
| 7334 | try |
| 7335 | { |
| 7336 | gl::Context *context = gl::getNonLostContext(); |
| 7337 | |
| 7338 | if (context) |
| 7339 | { |
| 7340 | if (context->getClientVersion() < 3) |
| 7341 | { |
| 7342 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 7343 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7344 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 7345 | if (array == 0) |
| 7346 | { |
| 7347 | return GL_FALSE; |
| 7348 | } |
| 7349 | |
| 7350 | gl::VertexArray *vao = context->getVertexArray(array); |
| 7351 | |
| 7352 | return (vao != NULL ? GL_TRUE : GL_FALSE); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7353 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7354 | } |
| 7355 | catch(std::bad_alloc&) |
| 7356 | { |
| 7357 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 7358 | } |
| 7359 | |
| 7360 | return GL_FALSE; |
| 7361 | } |
| 7362 | |
| 7363 | void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data) |
| 7364 | { |
| 7365 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)", |
| 7366 | target, index, data); |
| 7367 | |
| 7368 | try |
| 7369 | { |
| 7370 | gl::Context *context = gl::getNonLostContext(); |
| 7371 | |
| 7372 | if (context) |
| 7373 | { |
| 7374 | if (context->getClientVersion() < 3) |
| 7375 | { |
| 7376 | return gl::error(GL_INVALID_OPERATION); |
| 7377 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7378 | |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame^] | 7379 | switch (target) |
| 7380 | { |
| 7381 | case GL_TRANSFORM_FEEDBACK_BUFFER_START: |
| 7382 | case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: |
| 7383 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 7384 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
| 7385 | return gl::error(GL_INVALID_VALUE); |
| 7386 | break; |
| 7387 | case GL_UNIFORM_BUFFER_START: |
| 7388 | case GL_UNIFORM_BUFFER_SIZE: |
| 7389 | case GL_UNIFORM_BUFFER_BINDING: |
| 7390 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 7391 | return gl::error(GL_INVALID_VALUE); |
| 7392 | break; |
| 7393 | default: |
| 7394 | return gl::error(GL_INVALID_ENUM); |
| 7395 | } |
| 7396 | |
| 7397 | if (!(context->getIndexedIntegerv(target, index, data))) |
| 7398 | { |
| 7399 | GLenum nativeType; |
| 7400 | unsigned int numParams = 0; |
| 7401 | if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams)) |
| 7402 | return gl::error(GL_INVALID_ENUM); |
| 7403 | |
| 7404 | if (numParams == 0) |
| 7405 | return; // it is known that pname is valid, but there are no parameters to return |
| 7406 | |
| 7407 | if (nativeType == GL_INT_64_ANGLEX) |
| 7408 | { |
| 7409 | GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min()); |
| 7410 | GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max()); |
| 7411 | GLint64 *int64Params = new GLint64[numParams]; |
| 7412 | |
| 7413 | context->getIndexedInteger64v(target, index, int64Params); |
| 7414 | |
| 7415 | for (unsigned int i = 0; i < numParams; ++i) |
| 7416 | { |
| 7417 | GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue); |
| 7418 | data[i] = static_cast<GLint>(clampedValue); |
| 7419 | } |
| 7420 | |
| 7421 | delete [] int64Params; |
| 7422 | } |
| 7423 | else |
| 7424 | { |
| 7425 | UNREACHABLE(); |
| 7426 | } |
| 7427 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7428 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7429 | } |
| 7430 | catch(std::bad_alloc&) |
| 7431 | { |
| 7432 | return gl::error(GL_OUT_OF_MEMORY); |
| 7433 | } |
| 7434 | } |
| 7435 | |
| 7436 | void __stdcall glBeginTransformFeedback(GLenum primitiveMode) |
| 7437 | { |
| 7438 | EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode); |
| 7439 | |
| 7440 | try |
| 7441 | { |
| 7442 | gl::Context *context = gl::getNonLostContext(); |
| 7443 | |
| 7444 | if (context) |
| 7445 | { |
| 7446 | if (context->getClientVersion() < 3) |
| 7447 | { |
| 7448 | return gl::error(GL_INVALID_OPERATION); |
| 7449 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7450 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 7451 | // glBeginTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7452 | UNIMPLEMENTED(); |
| 7453 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7454 | } |
| 7455 | catch(std::bad_alloc&) |
| 7456 | { |
| 7457 | return gl::error(GL_OUT_OF_MEMORY); |
| 7458 | } |
| 7459 | } |
| 7460 | |
| 7461 | void __stdcall glEndTransformFeedback(void) |
| 7462 | { |
| 7463 | EVENT("(void)"); |
| 7464 | |
| 7465 | try |
| 7466 | { |
| 7467 | gl::Context *context = gl::getNonLostContext(); |
| 7468 | |
| 7469 | if (context) |
| 7470 | { |
| 7471 | if (context->getClientVersion() < 3) |
| 7472 | { |
| 7473 | return gl::error(GL_INVALID_OPERATION); |
| 7474 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7475 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 7476 | // glEndTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7477 | UNIMPLEMENTED(); |
| 7478 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7479 | } |
| 7480 | catch(std::bad_alloc&) |
| 7481 | { |
| 7482 | return gl::error(GL_OUT_OF_MEMORY); |
| 7483 | } |
| 7484 | } |
| 7485 | |
| 7486 | void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
| 7487 | { |
| 7488 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)", |
| 7489 | target, index, buffer, offset, size); |
| 7490 | |
| 7491 | try |
| 7492 | { |
| 7493 | gl::Context *context = gl::getNonLostContext(); |
| 7494 | |
| 7495 | if (context) |
| 7496 | { |
| 7497 | if (context->getClientVersion() < 3) |
| 7498 | { |
| 7499 | return gl::error(GL_INVALID_OPERATION); |
| 7500 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7501 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 7502 | switch (target) |
| 7503 | { |
| 7504 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 7505 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 7506 | { |
| 7507 | return gl::error(GL_INVALID_VALUE); |
| 7508 | } |
| 7509 | break; |
| 7510 | |
| 7511 | case GL_UNIFORM_BUFFER: |
| 7512 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 7513 | { |
| 7514 | return gl::error(GL_INVALID_VALUE); |
| 7515 | } |
| 7516 | break; |
| 7517 | |
| 7518 | default: |
| 7519 | return gl::error(GL_INVALID_ENUM); |
| 7520 | } |
| 7521 | |
shannonwoods@chromium.org | e6e0079 | 2013-05-30 00:06:07 +0000 | [diff] [blame] | 7522 | if (buffer != 0 && size <= 0) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 7523 | { |
| 7524 | return gl::error(GL_INVALID_VALUE); |
| 7525 | } |
| 7526 | |
| 7527 | switch (target) |
| 7528 | { |
| 7529 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | a26aeaf | 2013-05-30 00:06:13 +0000 | [diff] [blame] | 7530 | |
| 7531 | // size and offset must be a multiple of 4 |
| 7532 | if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) |
| 7533 | { |
| 7534 | return gl::error(GL_INVALID_VALUE); |
| 7535 | } |
| 7536 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 7537 | context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 7538 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 7539 | break; |
| 7540 | |
| 7541 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 97c3d50 | 2013-05-30 00:04:34 +0000 | [diff] [blame] | 7542 | |
| 7543 | // it is an error to bind an offset not a multiple of the alignment |
| 7544 | if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0) |
| 7545 | { |
| 7546 | return gl::error(GL_INVALID_VALUE); |
| 7547 | } |
| 7548 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 7549 | context->bindIndexedUniformBuffer(buffer, index, offset, size); |
| 7550 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 7551 | break; |
| 7552 | |
| 7553 | default: |
| 7554 | UNREACHABLE(); |
| 7555 | } |
| 7556 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7557 | } |
| 7558 | catch(std::bad_alloc&) |
| 7559 | { |
| 7560 | return gl::error(GL_OUT_OF_MEMORY); |
| 7561 | } |
| 7562 | } |
| 7563 | |
| 7564 | void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 7565 | { |
| 7566 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)", |
| 7567 | target, index, buffer); |
| 7568 | |
| 7569 | try |
| 7570 | { |
| 7571 | gl::Context *context = gl::getNonLostContext(); |
| 7572 | |
| 7573 | if (context) |
| 7574 | { |
| 7575 | if (context->getClientVersion() < 3) |
| 7576 | { |
| 7577 | return gl::error(GL_INVALID_OPERATION); |
| 7578 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7579 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 7580 | switch (target) |
| 7581 | { |
| 7582 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 7583 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 7584 | { |
| 7585 | return gl::error(GL_INVALID_VALUE); |
| 7586 | } |
| 7587 | break; |
| 7588 | |
| 7589 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 7590 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 7591 | { |
| 7592 | return gl::error(GL_INVALID_VALUE); |
| 7593 | } |
| 7594 | break; |
| 7595 | |
| 7596 | default: |
| 7597 | return gl::error(GL_INVALID_ENUM); |
| 7598 | } |
| 7599 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 7600 | switch (target) |
| 7601 | { |
| 7602 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 7603 | context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 7604 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 7605 | break; |
| 7606 | |
| 7607 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 7608 | context->bindIndexedUniformBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 7609 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 7610 | break; |
| 7611 | |
| 7612 | default: |
| 7613 | UNREACHABLE(); |
| 7614 | } |
| 7615 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7616 | } |
| 7617 | catch(std::bad_alloc&) |
| 7618 | { |
| 7619 | return gl::error(GL_OUT_OF_MEMORY); |
| 7620 | } |
| 7621 | } |
| 7622 | |
| 7623 | void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
| 7624 | { |
| 7625 | EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)", |
| 7626 | program, count, varyings, bufferMode); |
| 7627 | |
| 7628 | try |
| 7629 | { |
| 7630 | gl::Context *context = gl::getNonLostContext(); |
| 7631 | |
| 7632 | if (context) |
| 7633 | { |
| 7634 | if (context->getClientVersion() < 3) |
| 7635 | { |
| 7636 | return gl::error(GL_INVALID_OPERATION); |
| 7637 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7638 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 7639 | // glTransformFeedbackVaryings |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7640 | UNIMPLEMENTED(); |
| 7641 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7642 | } |
| 7643 | catch(std::bad_alloc&) |
| 7644 | { |
| 7645 | return gl::error(GL_OUT_OF_MEMORY); |
| 7646 | } |
| 7647 | } |
| 7648 | |
| 7649 | void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
| 7650 | { |
| 7651 | EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, " |
| 7652 | "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
| 7653 | program, index, bufSize, length, size, type, name); |
| 7654 | |
| 7655 | try |
| 7656 | { |
| 7657 | gl::Context *context = gl::getNonLostContext(); |
| 7658 | |
| 7659 | if (context) |
| 7660 | { |
| 7661 | if (context->getClientVersion() < 3) |
| 7662 | { |
| 7663 | return gl::error(GL_INVALID_OPERATION); |
| 7664 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7665 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 7666 | // glGetTransformFeedbackVarying |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7667 | UNIMPLEMENTED(); |
| 7668 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7669 | } |
| 7670 | catch(std::bad_alloc&) |
| 7671 | { |
| 7672 | return gl::error(GL_OUT_OF_MEMORY); |
| 7673 | } |
| 7674 | } |
| 7675 | |
| 7676 | void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) |
| 7677 | { |
| 7678 | EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)", |
| 7679 | index, size, type, stride, pointer); |
| 7680 | |
| 7681 | try |
| 7682 | { |
| 7683 | gl::Context *context = gl::getNonLostContext(); |
| 7684 | |
| 7685 | if (context) |
| 7686 | { |
| 7687 | if (context->getClientVersion() < 3) |
| 7688 | { |
| 7689 | return gl::error(GL_INVALID_OPERATION); |
| 7690 | } |
| 7691 | } |
| 7692 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7693 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7694 | { |
| 7695 | return gl::error(GL_INVALID_VALUE); |
| 7696 | } |
| 7697 | |
| 7698 | if (size < 1 || size > 4) |
| 7699 | { |
| 7700 | return gl::error(GL_INVALID_VALUE); |
| 7701 | } |
| 7702 | |
| 7703 | switch (type) |
| 7704 | { |
| 7705 | case GL_BYTE: |
| 7706 | case GL_UNSIGNED_BYTE: |
| 7707 | case GL_SHORT: |
| 7708 | case GL_UNSIGNED_SHORT: |
| 7709 | case GL_INT: |
| 7710 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 7711 | case GL_INT_2_10_10_10_REV: |
| 7712 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7713 | break; |
| 7714 | default: |
| 7715 | return gl::error(GL_INVALID_ENUM); |
| 7716 | } |
| 7717 | |
| 7718 | if (stride < 0) |
| 7719 | { |
| 7720 | return gl::error(GL_INVALID_VALUE); |
| 7721 | } |
| 7722 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 7723 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 7724 | { |
| 7725 | return gl::error(GL_INVALID_OPERATION); |
| 7726 | } |
| 7727 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7728 | if (context) |
| 7729 | { |
Jamie Madill | d8db866 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 7730 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 7731 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 7732 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 7733 | // and the pointer argument is not NULL. |
| 7734 | if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && pointer != NULL) |
| 7735 | { |
| 7736 | return gl::error(GL_INVALID_OPERATION); |
| 7737 | } |
| 7738 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7739 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true, |
| 7740 | stride, pointer); |
| 7741 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7742 | } |
| 7743 | catch(std::bad_alloc&) |
| 7744 | { |
| 7745 | return gl::error(GL_OUT_OF_MEMORY); |
| 7746 | } |
| 7747 | } |
| 7748 | |
| 7749 | void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) |
| 7750 | { |
| 7751 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 7752 | index, pname, params); |
| 7753 | |
| 7754 | try |
| 7755 | { |
| 7756 | gl::Context *context = gl::getNonLostContext(); |
| 7757 | |
| 7758 | if (context) |
| 7759 | { |
| 7760 | if (context->getClientVersion() < 3) |
| 7761 | { |
| 7762 | return gl::error(GL_INVALID_OPERATION); |
| 7763 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7764 | |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 7765 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7766 | { |
| 7767 | return gl::error(GL_INVALID_VALUE); |
| 7768 | } |
| 7769 | |
| 7770 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
| 7771 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 7772 | if (!gl::ValidateGetVertexAttribParameters(pname, context->getClientVersion())) |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 7773 | { |
| 7774 | return; |
| 7775 | } |
| 7776 | |
| 7777 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 7778 | { |
| 7779 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 7780 | for (int i = 0; i < 4; ++i) |
| 7781 | { |
| 7782 | params[i] = currentValueData.IntValues[i]; |
| 7783 | } |
| 7784 | } |
| 7785 | else |
| 7786 | { |
| 7787 | *params = attribState.querySingleParameter<GLint>(pname); |
| 7788 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7789 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7790 | } |
| 7791 | catch(std::bad_alloc&) |
| 7792 | { |
| 7793 | return gl::error(GL_OUT_OF_MEMORY); |
| 7794 | } |
| 7795 | } |
| 7796 | |
| 7797 | void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) |
| 7798 | { |
| 7799 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)", |
| 7800 | index, pname, params); |
| 7801 | |
| 7802 | try |
| 7803 | { |
| 7804 | gl::Context *context = gl::getNonLostContext(); |
| 7805 | |
| 7806 | if (context) |
| 7807 | { |
| 7808 | if (context->getClientVersion() < 3) |
| 7809 | { |
| 7810 | return gl::error(GL_INVALID_OPERATION); |
| 7811 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7812 | |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 7813 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7814 | { |
| 7815 | return gl::error(GL_INVALID_VALUE); |
| 7816 | } |
| 7817 | |
| 7818 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
| 7819 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 7820 | if (!gl::ValidateGetVertexAttribParameters(pname, context->getClientVersion())) |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 7821 | { |
| 7822 | return; |
| 7823 | } |
| 7824 | |
| 7825 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 7826 | { |
| 7827 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 7828 | for (int i = 0; i < 4; ++i) |
| 7829 | { |
| 7830 | params[i] = currentValueData.UnsignedIntValues[i]; |
| 7831 | } |
| 7832 | } |
| 7833 | else |
| 7834 | { |
| 7835 | *params = attribState.querySingleParameter<GLuint>(pname); |
| 7836 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7837 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7838 | } |
| 7839 | catch(std::bad_alloc&) |
| 7840 | { |
| 7841 | return gl::error(GL_OUT_OF_MEMORY); |
| 7842 | } |
| 7843 | } |
| 7844 | |
| 7845 | void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 7846 | { |
| 7847 | EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)", |
| 7848 | index, x, y, z, w); |
| 7849 | |
| 7850 | try |
| 7851 | { |
| 7852 | gl::Context *context = gl::getNonLostContext(); |
| 7853 | |
| 7854 | if (context) |
| 7855 | { |
| 7856 | if (context->getClientVersion() < 3) |
| 7857 | { |
| 7858 | return gl::error(GL_INVALID_OPERATION); |
| 7859 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7860 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7861 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7862 | { |
| 7863 | return gl::error(GL_INVALID_VALUE); |
| 7864 | } |
| 7865 | |
| 7866 | GLint vals[4] = { x, y, z, w }; |
| 7867 | context->setVertexAttribi(index, vals); |
| 7868 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7869 | } |
| 7870 | catch(std::bad_alloc&) |
| 7871 | { |
| 7872 | return gl::error(GL_OUT_OF_MEMORY); |
| 7873 | } |
| 7874 | } |
| 7875 | |
| 7876 | void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 7877 | { |
| 7878 | EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)", |
| 7879 | index, x, y, z, w); |
| 7880 | |
| 7881 | try |
| 7882 | { |
| 7883 | gl::Context *context = gl::getNonLostContext(); |
| 7884 | |
| 7885 | if (context) |
| 7886 | { |
| 7887 | if (context->getClientVersion() < 3) |
| 7888 | { |
| 7889 | return gl::error(GL_INVALID_OPERATION); |
| 7890 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7891 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7892 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7893 | { |
| 7894 | return gl::error(GL_INVALID_VALUE); |
| 7895 | } |
| 7896 | |
| 7897 | GLuint vals[4] = { x, y, z, w }; |
| 7898 | context->setVertexAttribu(index, vals); |
| 7899 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7900 | } |
| 7901 | catch(std::bad_alloc&) |
| 7902 | { |
| 7903 | return gl::error(GL_OUT_OF_MEMORY); |
| 7904 | } |
| 7905 | } |
| 7906 | |
| 7907 | void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) |
| 7908 | { |
| 7909 | EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v); |
| 7910 | |
| 7911 | try |
| 7912 | { |
| 7913 | gl::Context *context = gl::getNonLostContext(); |
| 7914 | |
| 7915 | if (context) |
| 7916 | { |
| 7917 | if (context->getClientVersion() < 3) |
| 7918 | { |
| 7919 | return gl::error(GL_INVALID_OPERATION); |
| 7920 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7921 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7922 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7923 | { |
| 7924 | return gl::error(GL_INVALID_VALUE); |
| 7925 | } |
| 7926 | |
| 7927 | context->setVertexAttribi(index, v); |
| 7928 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7929 | } |
| 7930 | catch(std::bad_alloc&) |
| 7931 | { |
| 7932 | return gl::error(GL_OUT_OF_MEMORY); |
| 7933 | } |
| 7934 | } |
| 7935 | |
| 7936 | void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v) |
| 7937 | { |
| 7938 | EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v); |
| 7939 | |
| 7940 | try |
| 7941 | { |
| 7942 | gl::Context *context = gl::getNonLostContext(); |
| 7943 | |
| 7944 | if (context) |
| 7945 | { |
| 7946 | if (context->getClientVersion() < 3) |
| 7947 | { |
| 7948 | return gl::error(GL_INVALID_OPERATION); |
| 7949 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7950 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7951 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7952 | { |
| 7953 | return gl::error(GL_INVALID_VALUE); |
| 7954 | } |
| 7955 | |
| 7956 | context->setVertexAttribu(index, v); |
| 7957 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7958 | } |
| 7959 | catch(std::bad_alloc&) |
| 7960 | { |
| 7961 | return gl::error(GL_OUT_OF_MEMORY); |
| 7962 | } |
| 7963 | } |
| 7964 | |
| 7965 | void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) |
| 7966 | { |
| 7967 | EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)", |
| 7968 | program, location, params); |
| 7969 | |
| 7970 | try |
| 7971 | { |
| 7972 | gl::Context *context = gl::getNonLostContext(); |
| 7973 | |
| 7974 | if (context) |
| 7975 | { |
| 7976 | if (context->getClientVersion() < 3) |
| 7977 | { |
| 7978 | return gl::error(GL_INVALID_OPERATION); |
| 7979 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7980 | |
shannon.woods%transgaming.com@gtempaccount.com | e229012 | 2013-04-13 03:41:07 +0000 | [diff] [blame] | 7981 | if (program == 0) |
| 7982 | { |
| 7983 | return gl::error(GL_INVALID_VALUE); |
| 7984 | } |
| 7985 | |
| 7986 | gl::Program *programObject = context->getProgram(program); |
| 7987 | |
| 7988 | if (!programObject || !programObject->isLinked()) |
| 7989 | { |
| 7990 | return gl::error(GL_INVALID_OPERATION); |
| 7991 | } |
| 7992 | |
| 7993 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 7994 | if (!programBinary) |
| 7995 | { |
| 7996 | return gl::error(GL_INVALID_OPERATION); |
| 7997 | } |
| 7998 | |
| 7999 | if (!programBinary->getUniformuiv(location, NULL, params)) |
| 8000 | { |
| 8001 | return gl::error(GL_INVALID_OPERATION); |
| 8002 | } |
| 8003 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8004 | } |
| 8005 | catch(std::bad_alloc&) |
| 8006 | { |
| 8007 | return gl::error(GL_OUT_OF_MEMORY); |
| 8008 | } |
| 8009 | } |
| 8010 | |
| 8011 | GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) |
| 8012 | { |
| 8013 | EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)", |
| 8014 | program, name); |
| 8015 | |
| 8016 | try |
| 8017 | { |
| 8018 | gl::Context *context = gl::getNonLostContext(); |
| 8019 | |
| 8020 | if (context) |
| 8021 | { |
| 8022 | if (context->getClientVersion() < 3) |
| 8023 | { |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame] | 8024 | return gl::error(GL_INVALID_OPERATION, -1); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8025 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8026 | |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame] | 8027 | if (program == 0) |
| 8028 | { |
| 8029 | return gl::error(GL_INVALID_VALUE, -1); |
| 8030 | } |
| 8031 | |
| 8032 | gl::Program *programObject = context->getProgram(program); |
| 8033 | |
| 8034 | if (!programObject || !programObject->isLinked()) |
| 8035 | { |
| 8036 | return gl::error(GL_INVALID_OPERATION, -1); |
| 8037 | } |
| 8038 | |
| 8039 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 8040 | if (!programBinary) |
| 8041 | { |
| 8042 | return gl::error(GL_INVALID_OPERATION, -1); |
| 8043 | } |
| 8044 | |
| 8045 | return programBinary->getFragDataLocation(name); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8046 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8047 | } |
| 8048 | catch(std::bad_alloc&) |
| 8049 | { |
| 8050 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 8051 | } |
| 8052 | |
| 8053 | return 0; |
| 8054 | } |
| 8055 | |
| 8056 | void __stdcall glUniform1ui(GLint location, GLuint v0) |
| 8057 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 8058 | glUniform1uiv(location, 1, &v0); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8059 | } |
| 8060 | |
| 8061 | void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1) |
| 8062 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 8063 | const GLuint xy[] = { v0, v1 }; |
| 8064 | glUniform2uiv(location, 1, xy); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8065 | } |
| 8066 | |
| 8067 | void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 8068 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 8069 | const GLuint xyz[] = { v0, v1, v2 }; |
| 8070 | glUniform3uiv(location, 1, xyz); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8071 | } |
| 8072 | |
| 8073 | void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 8074 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 8075 | const GLuint xyzw[] = { v0, v1, v2, v3 }; |
| 8076 | glUniform4uiv(location, 1, xyzw); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8077 | } |
| 8078 | |
| 8079 | void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) |
| 8080 | { |
| 8081 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 8082 | location, count, value); |
| 8083 | |
| 8084 | try |
| 8085 | { |
| 8086 | gl::Context *context = gl::getNonLostContext(); |
| 8087 | |
| 8088 | if (context) |
| 8089 | { |
| 8090 | if (context->getClientVersion() < 3) |
| 8091 | { |
| 8092 | return gl::error(GL_INVALID_OPERATION); |
| 8093 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8094 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 8095 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8096 | if (!programBinary) |
| 8097 | { |
| 8098 | return gl::error(GL_INVALID_OPERATION); |
| 8099 | } |
| 8100 | |
| 8101 | if (!programBinary->setUniform1uiv(location, count, value)) |
| 8102 | { |
| 8103 | return gl::error(GL_INVALID_OPERATION); |
| 8104 | } |
| 8105 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8106 | } |
| 8107 | catch(std::bad_alloc&) |
| 8108 | { |
| 8109 | return gl::error(GL_OUT_OF_MEMORY); |
| 8110 | } |
| 8111 | } |
| 8112 | |
| 8113 | void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) |
| 8114 | { |
| 8115 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 8116 | location, count, value); |
| 8117 | |
| 8118 | try |
| 8119 | { |
| 8120 | gl::Context *context = gl::getNonLostContext(); |
| 8121 | |
| 8122 | if (context) |
| 8123 | { |
| 8124 | if (context->getClientVersion() < 3) |
| 8125 | { |
| 8126 | return gl::error(GL_INVALID_OPERATION); |
| 8127 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8128 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 8129 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8130 | if (!programBinary) |
| 8131 | { |
| 8132 | return gl::error(GL_INVALID_OPERATION); |
| 8133 | } |
| 8134 | |
| 8135 | if (!programBinary->setUniform2uiv(location, count, value)) |
| 8136 | { |
| 8137 | return gl::error(GL_INVALID_OPERATION); |
| 8138 | } |
| 8139 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8140 | } |
| 8141 | catch(std::bad_alloc&) |
| 8142 | { |
| 8143 | return gl::error(GL_OUT_OF_MEMORY); |
| 8144 | } |
| 8145 | } |
| 8146 | |
| 8147 | void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) |
| 8148 | { |
| 8149 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)", |
| 8150 | location, count, value); |
| 8151 | |
| 8152 | try |
| 8153 | { |
| 8154 | gl::Context *context = gl::getNonLostContext(); |
| 8155 | |
| 8156 | if (context) |
| 8157 | { |
| 8158 | if (context->getClientVersion() < 3) |
| 8159 | { |
| 8160 | return gl::error(GL_INVALID_OPERATION); |
| 8161 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8162 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 8163 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8164 | if (!programBinary) |
| 8165 | { |
| 8166 | return gl::error(GL_INVALID_OPERATION); |
| 8167 | } |
| 8168 | |
| 8169 | if (!programBinary->setUniform3uiv(location, count, value)) |
| 8170 | { |
| 8171 | return gl::error(GL_INVALID_OPERATION); |
| 8172 | } |
| 8173 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8174 | } |
| 8175 | catch(std::bad_alloc&) |
| 8176 | { |
| 8177 | return gl::error(GL_OUT_OF_MEMORY); |
| 8178 | } |
| 8179 | } |
| 8180 | |
| 8181 | void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) |
| 8182 | { |
| 8183 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 8184 | location, count, value); |
| 8185 | |
| 8186 | try |
| 8187 | { |
| 8188 | gl::Context *context = gl::getNonLostContext(); |
| 8189 | |
| 8190 | if (context) |
| 8191 | { |
| 8192 | if (context->getClientVersion() < 3) |
| 8193 | { |
| 8194 | return gl::error(GL_INVALID_OPERATION); |
| 8195 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8196 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 8197 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8198 | if (!programBinary) |
| 8199 | { |
| 8200 | return gl::error(GL_INVALID_OPERATION); |
| 8201 | } |
| 8202 | |
| 8203 | if (!programBinary->setUniform4uiv(location, count, value)) |
| 8204 | { |
| 8205 | return gl::error(GL_INVALID_OPERATION); |
| 8206 | } |
| 8207 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8208 | } |
| 8209 | catch(std::bad_alloc&) |
| 8210 | { |
| 8211 | return gl::error(GL_OUT_OF_MEMORY); |
| 8212 | } |
| 8213 | } |
| 8214 | |
| 8215 | void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) |
| 8216 | { |
| 8217 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)", |
| 8218 | buffer, drawbuffer, value); |
| 8219 | |
| 8220 | try |
| 8221 | { |
| 8222 | gl::Context *context = gl::getNonLostContext(); |
| 8223 | |
| 8224 | if (context) |
| 8225 | { |
| 8226 | if (context->getClientVersion() < 3) |
| 8227 | { |
| 8228 | return gl::error(GL_INVALID_OPERATION); |
| 8229 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8230 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8231 | // glClearBufferiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8232 | UNIMPLEMENTED(); |
| 8233 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8234 | } |
| 8235 | catch(std::bad_alloc&) |
| 8236 | { |
| 8237 | return gl::error(GL_OUT_OF_MEMORY); |
| 8238 | } |
| 8239 | } |
| 8240 | |
| 8241 | void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) |
| 8242 | { |
| 8243 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)", |
| 8244 | buffer, drawbuffer, value); |
| 8245 | |
| 8246 | try |
| 8247 | { |
| 8248 | gl::Context *context = gl::getNonLostContext(); |
| 8249 | |
| 8250 | if (context) |
| 8251 | { |
| 8252 | if (context->getClientVersion() < 3) |
| 8253 | { |
| 8254 | return gl::error(GL_INVALID_OPERATION); |
| 8255 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8256 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8257 | // glClearBufferuiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8258 | UNIMPLEMENTED(); |
| 8259 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8260 | } |
| 8261 | catch(std::bad_alloc&) |
| 8262 | { |
| 8263 | return gl::error(GL_OUT_OF_MEMORY); |
| 8264 | } |
| 8265 | } |
| 8266 | |
| 8267 | void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) |
| 8268 | { |
| 8269 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)", |
| 8270 | buffer, drawbuffer, value); |
| 8271 | |
| 8272 | try |
| 8273 | { |
| 8274 | gl::Context *context = gl::getNonLostContext(); |
| 8275 | |
| 8276 | if (context) |
| 8277 | { |
| 8278 | if (context->getClientVersion() < 3) |
| 8279 | { |
| 8280 | return gl::error(GL_INVALID_OPERATION); |
| 8281 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8282 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8283 | // glClearBufferfv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8284 | UNIMPLEMENTED(); |
| 8285 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8286 | } |
| 8287 | catch(std::bad_alloc&) |
| 8288 | { |
| 8289 | return gl::error(GL_OUT_OF_MEMORY); |
| 8290 | } |
| 8291 | } |
| 8292 | |
| 8293 | void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 8294 | { |
| 8295 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)", |
| 8296 | buffer, drawbuffer, depth, stencil); |
| 8297 | |
| 8298 | try |
| 8299 | { |
| 8300 | gl::Context *context = gl::getNonLostContext(); |
| 8301 | |
| 8302 | if (context) |
| 8303 | { |
| 8304 | if (context->getClientVersion() < 3) |
| 8305 | { |
| 8306 | return gl::error(GL_INVALID_OPERATION); |
| 8307 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8308 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8309 | // glClearBufferfi |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8310 | UNIMPLEMENTED(); |
| 8311 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8312 | } |
| 8313 | catch(std::bad_alloc&) |
| 8314 | { |
| 8315 | return gl::error(GL_OUT_OF_MEMORY); |
| 8316 | } |
| 8317 | } |
| 8318 | |
| 8319 | const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) |
| 8320 | { |
| 8321 | EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index); |
| 8322 | |
| 8323 | try |
| 8324 | { |
| 8325 | gl::Context *context = gl::getNonLostContext(); |
| 8326 | |
| 8327 | if (context) |
| 8328 | { |
| 8329 | if (context->getClientVersion() < 3) |
| 8330 | { |
| 8331 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL)); |
| 8332 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8333 | |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 8334 | if (name != GL_EXTENSIONS) |
| 8335 | { |
| 8336 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL)); |
| 8337 | } |
| 8338 | |
| 8339 | if (index >= context->getNumExtensions()) |
| 8340 | { |
| 8341 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL)); |
| 8342 | } |
| 8343 | |
| 8344 | return reinterpret_cast<const GLubyte*>(context->getExtensionString(index)); |
| 8345 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8346 | } |
| 8347 | catch(std::bad_alloc&) |
| 8348 | { |
| 8349 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL)); |
| 8350 | } |
| 8351 | |
| 8352 | return NULL; |
| 8353 | } |
| 8354 | |
| 8355 | void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 8356 | { |
| 8357 | EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)", |
| 8358 | readTarget, writeTarget, readOffset, writeOffset, size); |
| 8359 | |
| 8360 | try |
| 8361 | { |
| 8362 | gl::Context *context = gl::getNonLostContext(); |
| 8363 | |
| 8364 | if (context) |
| 8365 | { |
| 8366 | if (context->getClientVersion() < 3) |
| 8367 | { |
| 8368 | return gl::error(GL_INVALID_OPERATION); |
| 8369 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8370 | |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 8371 | gl::Buffer *readBuffer = NULL; |
| 8372 | switch (readTarget) |
| 8373 | { |
| 8374 | case GL_ARRAY_BUFFER: |
| 8375 | readBuffer = context->getArrayBuffer(); |
| 8376 | break; |
| 8377 | case GL_COPY_READ_BUFFER: |
| 8378 | readBuffer = context->getCopyReadBuffer(); |
| 8379 | break; |
| 8380 | case GL_COPY_WRITE_BUFFER: |
| 8381 | readBuffer = context->getCopyWriteBuffer(); |
| 8382 | break; |
| 8383 | case GL_ELEMENT_ARRAY_BUFFER: |
| 8384 | readBuffer = context->getElementArrayBuffer(); |
| 8385 | break; |
| 8386 | case GL_PIXEL_PACK_BUFFER: |
| 8387 | readBuffer = context->getPixelPackBuffer(); |
| 8388 | break; |
| 8389 | case GL_PIXEL_UNPACK_BUFFER: |
| 8390 | readBuffer = context->getPixelUnpackBuffer(); |
| 8391 | break; |
| 8392 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 8393 | readBuffer = context->getGenericTransformFeedbackBuffer(); |
| 8394 | break; |
| 8395 | case GL_UNIFORM_BUFFER: |
| 8396 | readBuffer = context->getGenericUniformBuffer(); |
| 8397 | break; |
| 8398 | default: |
| 8399 | return gl::error(GL_INVALID_ENUM); |
| 8400 | } |
| 8401 | |
| 8402 | gl::Buffer *writeBuffer = NULL; |
| 8403 | switch (writeTarget) |
| 8404 | { |
| 8405 | case GL_ARRAY_BUFFER: |
| 8406 | writeBuffer = context->getArrayBuffer(); |
| 8407 | break; |
| 8408 | case GL_COPY_READ_BUFFER: |
| 8409 | writeBuffer = context->getCopyReadBuffer(); |
| 8410 | break; |
| 8411 | case GL_COPY_WRITE_BUFFER: |
| 8412 | writeBuffer = context->getCopyWriteBuffer(); |
| 8413 | break; |
| 8414 | case GL_ELEMENT_ARRAY_BUFFER: |
| 8415 | writeBuffer = context->getElementArrayBuffer(); |
| 8416 | break; |
| 8417 | case GL_PIXEL_PACK_BUFFER: |
| 8418 | writeBuffer = context->getPixelPackBuffer(); |
| 8419 | break; |
| 8420 | case GL_PIXEL_UNPACK_BUFFER: |
| 8421 | writeBuffer = context->getPixelUnpackBuffer(); |
| 8422 | break; |
| 8423 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 8424 | writeBuffer = context->getGenericTransformFeedbackBuffer(); |
| 8425 | break; |
| 8426 | case GL_UNIFORM_BUFFER: |
| 8427 | writeBuffer = context->getGenericUniformBuffer(); |
| 8428 | break; |
| 8429 | default: |
| 8430 | return gl::error(GL_INVALID_ENUM); |
| 8431 | } |
| 8432 | |
| 8433 | if (!readBuffer || !writeBuffer) |
| 8434 | { |
| 8435 | return gl::error(GL_INVALID_OPERATION); |
| 8436 | } |
| 8437 | |
| 8438 | if (readOffset < 0 || writeOffset < 0 || size < 0 || |
| 8439 | static_cast<unsigned int>(readOffset + size) > readBuffer->size() || |
| 8440 | static_cast<unsigned int>(writeOffset + size) > writeBuffer->size()) |
| 8441 | { |
| 8442 | return gl::error(GL_INVALID_VALUE); |
| 8443 | } |
| 8444 | |
| 8445 | if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size) |
| 8446 | { |
| 8447 | return gl::error(GL_INVALID_VALUE); |
| 8448 | } |
| 8449 | |
| 8450 | // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION) |
| 8451 | |
shannon.woods%transgaming.com@gtempaccount.com | c53376a | 2013-04-13 03:41:23 +0000 | [diff] [blame] | 8452 | // if size is zero, the copy is a successful no-op |
| 8453 | if (size > 0) |
| 8454 | { |
| 8455 | writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); |
| 8456 | } |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 8457 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8458 | } |
| 8459 | catch(std::bad_alloc&) |
| 8460 | { |
| 8461 | return gl::error(GL_OUT_OF_MEMORY); |
| 8462 | } |
| 8463 | } |
| 8464 | |
| 8465 | void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) |
| 8466 | { |
| 8467 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)", |
| 8468 | program, uniformCount, uniformNames, uniformIndices); |
| 8469 | |
| 8470 | try |
| 8471 | { |
| 8472 | gl::Context *context = gl::getNonLostContext(); |
| 8473 | |
| 8474 | if (context) |
| 8475 | { |
| 8476 | if (context->getClientVersion() < 3) |
| 8477 | { |
| 8478 | return gl::error(GL_INVALID_OPERATION); |
| 8479 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8480 | |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 8481 | if (uniformCount < 0) |
| 8482 | { |
| 8483 | return gl::error(GL_INVALID_VALUE); |
| 8484 | } |
| 8485 | |
| 8486 | gl::Program *programObject = context->getProgram(program); |
| 8487 | |
| 8488 | if (!programObject) |
| 8489 | { |
| 8490 | if (context->getShader(program)) |
| 8491 | { |
| 8492 | return gl::error(GL_INVALID_OPERATION); |
| 8493 | } |
| 8494 | else |
| 8495 | { |
| 8496 | return gl::error(GL_INVALID_VALUE); |
| 8497 | } |
| 8498 | } |
| 8499 | |
| 8500 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 8501 | if (!programObject->isLinked() || !programBinary) |
| 8502 | { |
| 8503 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 8504 | { |
| 8505 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 8506 | } |
| 8507 | } |
| 8508 | else |
| 8509 | { |
| 8510 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 8511 | { |
| 8512 | uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]); |
| 8513 | } |
| 8514 | } |
| 8515 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8516 | } |
| 8517 | catch(std::bad_alloc&) |
| 8518 | { |
| 8519 | return gl::error(GL_OUT_OF_MEMORY); |
| 8520 | } |
| 8521 | } |
| 8522 | |
| 8523 | void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) |
| 8524 | { |
| 8525 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 8526 | program, uniformCount, uniformIndices, pname, params); |
| 8527 | |
| 8528 | try |
| 8529 | { |
| 8530 | gl::Context *context = gl::getNonLostContext(); |
| 8531 | |
| 8532 | if (context) |
| 8533 | { |
| 8534 | if (context->getClientVersion() < 3) |
| 8535 | { |
| 8536 | return gl::error(GL_INVALID_OPERATION); |
| 8537 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8538 | |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 8539 | if (uniformCount < 0) |
| 8540 | { |
| 8541 | return gl::error(GL_INVALID_VALUE); |
| 8542 | } |
| 8543 | |
| 8544 | gl::Program *programObject = context->getProgram(program); |
| 8545 | |
| 8546 | if (!programObject) |
| 8547 | { |
| 8548 | if (context->getShader(program)) |
| 8549 | { |
| 8550 | return gl::error(GL_INVALID_OPERATION); |
| 8551 | } |
| 8552 | else |
| 8553 | { |
| 8554 | return gl::error(GL_INVALID_VALUE); |
| 8555 | } |
| 8556 | } |
| 8557 | |
| 8558 | switch (pname) |
| 8559 | { |
| 8560 | case GL_UNIFORM_TYPE: |
| 8561 | case GL_UNIFORM_SIZE: |
| 8562 | case GL_UNIFORM_NAME_LENGTH: |
| 8563 | case GL_UNIFORM_BLOCK_INDEX: |
| 8564 | case GL_UNIFORM_OFFSET: |
| 8565 | case GL_UNIFORM_ARRAY_STRIDE: |
| 8566 | case GL_UNIFORM_MATRIX_STRIDE: |
| 8567 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 8568 | break; |
| 8569 | default: |
| 8570 | return gl::error(GL_INVALID_ENUM); |
| 8571 | } |
| 8572 | |
| 8573 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 8574 | |
| 8575 | if (!programBinary && uniformCount > 0) |
| 8576 | { |
| 8577 | return gl::error(GL_INVALID_VALUE); |
| 8578 | } |
| 8579 | |
| 8580 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 8581 | { |
| 8582 | const GLuint index = uniformIndices[uniformId]; |
| 8583 | |
| 8584 | if (index >= (GLuint)programBinary->getActiveUniformCount()) |
| 8585 | { |
| 8586 | return gl::error(GL_INVALID_VALUE); |
| 8587 | } |
| 8588 | } |
| 8589 | |
| 8590 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 8591 | { |
| 8592 | const GLuint index = uniformIndices[uniformId]; |
| 8593 | params[uniformId] = programBinary->getActiveUniformi(index, pname); |
| 8594 | } |
| 8595 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8596 | } |
| 8597 | catch(std::bad_alloc&) |
| 8598 | { |
| 8599 | return gl::error(GL_OUT_OF_MEMORY); |
| 8600 | } |
| 8601 | } |
| 8602 | |
| 8603 | GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) |
| 8604 | { |
| 8605 | EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName); |
| 8606 | |
| 8607 | try |
| 8608 | { |
| 8609 | gl::Context *context = gl::getNonLostContext(); |
| 8610 | |
| 8611 | if (context) |
| 8612 | { |
| 8613 | if (context->getClientVersion() < 3) |
| 8614 | { |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 8615 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8616 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8617 | |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 8618 | gl::Program *programObject = context->getProgram(program); |
| 8619 | |
| 8620 | if (!programObject) |
| 8621 | { |
| 8622 | if (context->getShader(program)) |
| 8623 | { |
| 8624 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
| 8625 | } |
| 8626 | else |
| 8627 | { |
| 8628 | return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX); |
| 8629 | } |
| 8630 | } |
| 8631 | |
| 8632 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 8633 | if (!programBinary) |
| 8634 | { |
| 8635 | return GL_INVALID_INDEX; |
| 8636 | } |
| 8637 | |
| 8638 | return programBinary->getUniformBlockIndex(uniformBlockName); |
| 8639 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8640 | } |
| 8641 | catch(std::bad_alloc&) |
| 8642 | { |
| 8643 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 8644 | } |
| 8645 | |
| 8646 | return 0; |
| 8647 | } |
| 8648 | |
| 8649 | void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) |
| 8650 | { |
| 8651 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 8652 | program, uniformBlockIndex, pname, params); |
| 8653 | |
| 8654 | try |
| 8655 | { |
| 8656 | gl::Context *context = gl::getNonLostContext(); |
| 8657 | |
| 8658 | if (context) |
| 8659 | { |
| 8660 | if (context->getClientVersion() < 3) |
| 8661 | { |
| 8662 | return gl::error(GL_INVALID_OPERATION); |
| 8663 | } |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 8664 | gl::Program *programObject = context->getProgram(program); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8665 | |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 8666 | if (!programObject) |
| 8667 | { |
| 8668 | if (context->getShader(program)) |
| 8669 | { |
| 8670 | return gl::error(GL_INVALID_OPERATION); |
| 8671 | } |
| 8672 | else |
| 8673 | { |
| 8674 | return gl::error(GL_INVALID_VALUE); |
| 8675 | } |
| 8676 | } |
| 8677 | |
| 8678 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 8679 | |
| 8680 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 8681 | { |
| 8682 | return gl::error(GL_INVALID_VALUE); |
| 8683 | } |
| 8684 | |
| 8685 | switch (pname) |
| 8686 | { |
| 8687 | case GL_UNIFORM_BLOCK_BINDING: |
| 8688 | *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); |
| 8689 | break; |
| 8690 | |
| 8691 | case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 8692 | case GL_UNIFORM_BLOCK_NAME_LENGTH: |
| 8693 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 8694 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| 8695 | case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
| 8696 | case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
| 8697 | programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params); |
| 8698 | break; |
| 8699 | |
| 8700 | default: |
| 8701 | return gl::error(GL_INVALID_ENUM); |
| 8702 | } |
| 8703 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8704 | } |
| 8705 | catch(std::bad_alloc&) |
| 8706 | { |
| 8707 | return gl::error(GL_OUT_OF_MEMORY); |
| 8708 | } |
| 8709 | } |
| 8710 | |
| 8711 | void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) |
| 8712 | { |
| 8713 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)", |
| 8714 | program, uniformBlockIndex, bufSize, length, uniformBlockName); |
| 8715 | |
| 8716 | try |
| 8717 | { |
| 8718 | gl::Context *context = gl::getNonLostContext(); |
| 8719 | |
| 8720 | if (context) |
| 8721 | { |
| 8722 | if (context->getClientVersion() < 3) |
| 8723 | { |
| 8724 | return gl::error(GL_INVALID_OPERATION); |
| 8725 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8726 | |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 8727 | gl::Program *programObject = context->getProgram(program); |
| 8728 | |
| 8729 | if (!programObject) |
| 8730 | { |
| 8731 | if (context->getShader(program)) |
| 8732 | { |
| 8733 | return gl::error(GL_INVALID_OPERATION); |
| 8734 | } |
| 8735 | else |
| 8736 | { |
| 8737 | return gl::error(GL_INVALID_VALUE); |
| 8738 | } |
| 8739 | } |
| 8740 | |
| 8741 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 8742 | |
| 8743 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 8744 | { |
| 8745 | return gl::error(GL_INVALID_VALUE); |
| 8746 | } |
| 8747 | |
| 8748 | programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 8749 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8750 | } |
| 8751 | catch(std::bad_alloc&) |
| 8752 | { |
| 8753 | return gl::error(GL_OUT_OF_MEMORY); |
| 8754 | } |
| 8755 | } |
| 8756 | |
| 8757 | void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) |
| 8758 | { |
| 8759 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)", |
| 8760 | program, uniformBlockIndex, uniformBlockBinding); |
| 8761 | |
| 8762 | try |
| 8763 | { |
| 8764 | gl::Context *context = gl::getNonLostContext(); |
| 8765 | |
| 8766 | if (context) |
| 8767 | { |
| 8768 | if (context->getClientVersion() < 3) |
| 8769 | { |
| 8770 | return gl::error(GL_INVALID_OPERATION); |
| 8771 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8772 | |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 8773 | if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings()) |
| 8774 | { |
| 8775 | return gl::error(GL_INVALID_VALUE); |
| 8776 | } |
| 8777 | |
| 8778 | gl::Program *programObject = context->getProgram(program); |
| 8779 | |
| 8780 | if (!programObject) |
| 8781 | { |
| 8782 | if (context->getShader(program)) |
| 8783 | { |
| 8784 | return gl::error(GL_INVALID_OPERATION); |
| 8785 | } |
| 8786 | else |
| 8787 | { |
| 8788 | return gl::error(GL_INVALID_VALUE); |
| 8789 | } |
| 8790 | } |
| 8791 | |
| 8792 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 8793 | |
| 8794 | // if never linked, there won't be any uniform blocks |
| 8795 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 8796 | { |
| 8797 | return gl::error(GL_INVALID_VALUE); |
| 8798 | } |
| 8799 | |
| 8800 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
| 8801 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8802 | } |
| 8803 | catch(std::bad_alloc&) |
| 8804 | { |
| 8805 | return gl::error(GL_OUT_OF_MEMORY); |
| 8806 | } |
| 8807 | } |
| 8808 | |
| 8809 | void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 8810 | { |
| 8811 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)", |
| 8812 | mode, first, count, instanceCount); |
| 8813 | |
| 8814 | try |
| 8815 | { |
| 8816 | gl::Context *context = gl::getNonLostContext(); |
| 8817 | |
| 8818 | if (context) |
| 8819 | { |
| 8820 | if (context->getClientVersion() < 3) |
| 8821 | { |
| 8822 | return gl::error(GL_INVALID_OPERATION); |
| 8823 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8824 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8825 | // glDrawArraysInstanced |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8826 | UNIMPLEMENTED(); |
| 8827 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8828 | } |
| 8829 | catch(std::bad_alloc&) |
| 8830 | { |
| 8831 | return gl::error(GL_OUT_OF_MEMORY); |
| 8832 | } |
| 8833 | } |
| 8834 | |
| 8835 | void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) |
| 8836 | { |
| 8837 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)", |
| 8838 | mode, count, type, indices, instanceCount); |
| 8839 | |
| 8840 | try |
| 8841 | { |
| 8842 | gl::Context *context = gl::getNonLostContext(); |
| 8843 | |
| 8844 | if (context) |
| 8845 | { |
| 8846 | if (context->getClientVersion() < 3) |
| 8847 | { |
| 8848 | return gl::error(GL_INVALID_OPERATION); |
| 8849 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8850 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8851 | // glDrawElementsInstanced |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8852 | UNIMPLEMENTED(); |
| 8853 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8854 | } |
| 8855 | catch(std::bad_alloc&) |
| 8856 | { |
| 8857 | return gl::error(GL_OUT_OF_MEMORY); |
| 8858 | } |
| 8859 | } |
| 8860 | |
| 8861 | GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags) |
| 8862 | { |
| 8863 | EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags); |
| 8864 | |
| 8865 | try |
| 8866 | { |
| 8867 | gl::Context *context = gl::getNonLostContext(); |
| 8868 | |
| 8869 | if (context) |
| 8870 | { |
| 8871 | if (context->getClientVersion() < 3) |
| 8872 | { |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 8873 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(0)); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8874 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8875 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 8876 | if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE) |
| 8877 | { |
| 8878 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLsync>(0)); |
| 8879 | } |
| 8880 | |
| 8881 | if (flags != 0) |
| 8882 | { |
| 8883 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLsync>(0)); |
| 8884 | } |
| 8885 | |
| 8886 | return context->createFenceSync(condition); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8887 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8888 | } |
| 8889 | catch(std::bad_alloc&) |
| 8890 | { |
| 8891 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL)); |
| 8892 | } |
| 8893 | |
| 8894 | return NULL; |
| 8895 | } |
| 8896 | |
| 8897 | GLboolean __stdcall glIsSync(GLsync sync) |
| 8898 | { |
| 8899 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 8900 | |
| 8901 | try |
| 8902 | { |
| 8903 | gl::Context *context = gl::getNonLostContext(); |
| 8904 | |
| 8905 | if (context) |
| 8906 | { |
| 8907 | if (context->getClientVersion() < 3) |
| 8908 | { |
| 8909 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8910 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8911 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 8912 | return (context->getFenceSync(sync) != NULL); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8913 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8914 | } |
| 8915 | catch(std::bad_alloc&) |
| 8916 | { |
| 8917 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8918 | } |
| 8919 | |
| 8920 | return GL_FALSE; |
| 8921 | } |
| 8922 | |
| 8923 | void __stdcall glDeleteSync(GLsync sync) |
| 8924 | { |
| 8925 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 8926 | |
| 8927 | try |
| 8928 | { |
| 8929 | gl::Context *context = gl::getNonLostContext(); |
| 8930 | |
| 8931 | if (context) |
| 8932 | { |
| 8933 | if (context->getClientVersion() < 3) |
| 8934 | { |
| 8935 | return gl::error(GL_INVALID_OPERATION); |
| 8936 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8937 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 8938 | if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync)) |
| 8939 | { |
| 8940 | return gl::error(GL_INVALID_VALUE); |
| 8941 | } |
| 8942 | |
| 8943 | context->deleteFenceSync(sync); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8944 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8945 | } |
| 8946 | catch(std::bad_alloc&) |
| 8947 | { |
| 8948 | return gl::error(GL_OUT_OF_MEMORY); |
| 8949 | } |
| 8950 | } |
| 8951 | |
| 8952 | GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 8953 | { |
| 8954 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 8955 | sync, flags, timeout); |
| 8956 | |
| 8957 | try |
| 8958 | { |
| 8959 | gl::Context *context = gl::getNonLostContext(); |
| 8960 | |
| 8961 | if (context) |
| 8962 | { |
| 8963 | if (context->getClientVersion() < 3) |
| 8964 | { |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 8965 | return gl::error(GL_INVALID_OPERATION, GL_WAIT_FAILED); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8966 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8967 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 8968 | if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0) |
| 8969 | { |
| 8970 | return gl::error(GL_INVALID_VALUE, GL_WAIT_FAILED); |
| 8971 | } |
| 8972 | |
| 8973 | gl::FenceSync *fenceSync = context->getFenceSync(sync); |
| 8974 | |
| 8975 | if (!fenceSync) |
| 8976 | { |
| 8977 | return gl::error(GL_INVALID_VALUE, GL_WAIT_FAILED); |
| 8978 | } |
| 8979 | |
| 8980 | return fenceSync->clientWait(flags, timeout); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8981 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8982 | } |
| 8983 | catch(std::bad_alloc&) |
| 8984 | { |
| 8985 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8986 | } |
| 8987 | |
| 8988 | return GL_FALSE; |
| 8989 | } |
| 8990 | |
| 8991 | void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 8992 | { |
| 8993 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 8994 | sync, flags, timeout); |
| 8995 | |
| 8996 | try |
| 8997 | { |
| 8998 | gl::Context *context = gl::getNonLostContext(); |
| 8999 | |
| 9000 | if (context) |
| 9001 | { |
| 9002 | if (context->getClientVersion() < 3) |
| 9003 | { |
| 9004 | return gl::error(GL_INVALID_OPERATION); |
| 9005 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9006 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 9007 | if (flags != 0) |
| 9008 | { |
| 9009 | return gl::error(GL_INVALID_VALUE); |
| 9010 | } |
| 9011 | |
| 9012 | if (timeout != GL_TIMEOUT_IGNORED) |
| 9013 | { |
| 9014 | return gl::error(GL_INVALID_VALUE); |
| 9015 | } |
| 9016 | |
| 9017 | gl::FenceSync *fenceSync = context->getFenceSync(sync); |
| 9018 | |
| 9019 | if (!fenceSync) |
| 9020 | { |
| 9021 | return gl::error(GL_INVALID_VALUE); |
| 9022 | } |
| 9023 | |
| 9024 | fenceSync->serverWait(); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9025 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9026 | } |
| 9027 | catch(std::bad_alloc&) |
| 9028 | { |
| 9029 | return gl::error(GL_OUT_OF_MEMORY); |
| 9030 | } |
| 9031 | } |
| 9032 | |
| 9033 | void __stdcall glGetInteger64v(GLenum pname, GLint64* params) |
| 9034 | { |
| 9035 | EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 9036 | pname, params); |
| 9037 | |
| 9038 | try |
| 9039 | { |
| 9040 | gl::Context *context = gl::getNonLostContext(); |
| 9041 | |
| 9042 | if (context) |
| 9043 | { |
| 9044 | if (context->getClientVersion() < 3) |
| 9045 | { |
| 9046 | return gl::error(GL_INVALID_OPERATION); |
| 9047 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9048 | |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 9049 | if (!(context->getInteger64v(pname, params))) |
| 9050 | { |
| 9051 | GLenum nativeType; |
| 9052 | unsigned int numParams = 0; |
| 9053 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
| 9054 | return gl::error(GL_INVALID_ENUM); |
| 9055 | |
| 9056 | if (numParams == 0) |
| 9057 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 9058 | |
| 9059 | if (nativeType == GL_BOOL) |
| 9060 | { |
| 9061 | GLboolean *boolParams = NULL; |
| 9062 | boolParams = new GLboolean[numParams]; |
| 9063 | |
| 9064 | context->getBooleanv(pname, boolParams); |
| 9065 | |
| 9066 | for (unsigned int i = 0; i < numParams; ++i) |
| 9067 | { |
| 9068 | if (boolParams[i] == GL_FALSE) |
| 9069 | params[i] = 0; |
| 9070 | else |
| 9071 | params[i] = 1; |
| 9072 | } |
| 9073 | |
| 9074 | delete [] boolParams; |
| 9075 | } |
| 9076 | else if (nativeType == GL_INT) |
| 9077 | { |
| 9078 | GLint *intParams = NULL; |
| 9079 | intParams = new GLint[numParams]; |
| 9080 | |
| 9081 | context->getIntegerv(pname, intParams); |
| 9082 | |
| 9083 | for (unsigned int i = 0; i < numParams; ++i) |
| 9084 | { |
| 9085 | params[i] = static_cast<GLint64>(intParams[i]); |
| 9086 | } |
| 9087 | |
| 9088 | delete [] intParams; |
| 9089 | } |
| 9090 | else if (nativeType == GL_FLOAT) |
| 9091 | { |
| 9092 | GLfloat *floatParams = NULL; |
| 9093 | floatParams = new GLfloat[numParams]; |
| 9094 | |
| 9095 | context->getFloatv(pname, floatParams); |
| 9096 | |
| 9097 | for (unsigned int i = 0; i < numParams; ++i) |
| 9098 | { |
| 9099 | // RGBA color values and DepthRangeF values are converted to integer using Equation 2.4 from Table 4.5 |
| 9100 | if (pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE || pname == GL_BLEND_COLOR) |
| 9101 | { |
| 9102 | params[i] = static_cast<GLint64>((static_cast<GLfloat>(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f); |
| 9103 | } |
| 9104 | else |
| 9105 | { |
| 9106 | params[i] = gl::iround<GLint64>(floatParams[i]); |
| 9107 | } |
| 9108 | } |
| 9109 | |
| 9110 | delete [] floatParams; |
| 9111 | } |
| 9112 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9113 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9114 | } |
| 9115 | catch(std::bad_alloc&) |
| 9116 | { |
| 9117 | return gl::error(GL_OUT_OF_MEMORY); |
| 9118 | } |
| 9119 | } |
| 9120 | |
| 9121 | void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) |
| 9122 | { |
| 9123 | EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)", |
| 9124 | sync, pname, bufSize, length, values); |
| 9125 | |
| 9126 | try |
| 9127 | { |
| 9128 | gl::Context *context = gl::getNonLostContext(); |
| 9129 | |
| 9130 | if (context) |
| 9131 | { |
| 9132 | if (context->getClientVersion() < 3) |
| 9133 | { |
| 9134 | return gl::error(GL_INVALID_OPERATION); |
| 9135 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9136 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 9137 | if (bufSize < 0) |
| 9138 | { |
| 9139 | return gl::error(GL_INVALID_VALUE); |
| 9140 | } |
| 9141 | |
| 9142 | gl::FenceSync *fenceSync = context->getFenceSync(sync); |
| 9143 | |
| 9144 | if (!fenceSync) |
| 9145 | { |
| 9146 | return gl::error(GL_INVALID_VALUE); |
| 9147 | } |
| 9148 | |
| 9149 | switch (pname) |
| 9150 | { |
| 9151 | case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break; |
| 9152 | case GL_SYNC_STATUS: values[0] = static_cast<GLint>(fenceSync->getStatus()); break; |
| 9153 | case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break; |
| 9154 | case GL_SYNC_FLAGS: values[0] = 0; break; |
| 9155 | |
| 9156 | default: |
| 9157 | return gl::error(GL_INVALID_ENUM); |
| 9158 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9159 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9160 | } |
| 9161 | catch(std::bad_alloc&) |
| 9162 | { |
| 9163 | return gl::error(GL_OUT_OF_MEMORY); |
| 9164 | } |
| 9165 | } |
| 9166 | |
| 9167 | void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) |
| 9168 | { |
| 9169 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)", |
| 9170 | target, index, data); |
| 9171 | |
| 9172 | try |
| 9173 | { |
| 9174 | gl::Context *context = gl::getNonLostContext(); |
| 9175 | |
| 9176 | if (context) |
| 9177 | { |
| 9178 | if (context->getClientVersion() < 3) |
| 9179 | { |
| 9180 | return gl::error(GL_INVALID_OPERATION); |
| 9181 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9182 | |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame^] | 9183 | switch (target) |
| 9184 | { |
| 9185 | case GL_TRANSFORM_FEEDBACK_BUFFER_START: |
| 9186 | case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: |
| 9187 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 9188 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
| 9189 | return gl::error(GL_INVALID_VALUE); |
| 9190 | break; |
| 9191 | case GL_UNIFORM_BUFFER_START: |
| 9192 | case GL_UNIFORM_BUFFER_SIZE: |
| 9193 | case GL_UNIFORM_BUFFER_BINDING: |
| 9194 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 9195 | return gl::error(GL_INVALID_VALUE); |
| 9196 | break; |
| 9197 | default: |
| 9198 | return gl::error(GL_INVALID_ENUM); |
| 9199 | } |
| 9200 | |
| 9201 | if (!(context->getIndexedInteger64v(target, index, data))) |
| 9202 | { |
| 9203 | GLenum nativeType; |
| 9204 | unsigned int numParams = 0; |
| 9205 | if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams)) |
| 9206 | return gl::error(GL_INVALID_ENUM); |
| 9207 | |
| 9208 | if (numParams == 0) |
| 9209 | return; // it is known that pname is valid, but there are no parameters to return |
| 9210 | |
| 9211 | if (nativeType == GL_INT) |
| 9212 | { |
| 9213 | GLint *intParams = new GLint[numParams]; |
| 9214 | |
| 9215 | context->getIndexedIntegerv(target, index, intParams); |
| 9216 | |
| 9217 | for (unsigned int i = 0; i < numParams; ++i) |
| 9218 | { |
| 9219 | data[i] = static_cast<GLint64>(intParams[i]); |
| 9220 | } |
| 9221 | |
| 9222 | delete [] intParams; |
| 9223 | } |
| 9224 | else |
| 9225 | { |
| 9226 | UNREACHABLE(); |
| 9227 | } |
| 9228 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9229 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9230 | } |
| 9231 | catch(std::bad_alloc&) |
| 9232 | { |
| 9233 | return gl::error(GL_OUT_OF_MEMORY); |
| 9234 | } |
| 9235 | } |
| 9236 | |
| 9237 | void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) |
| 9238 | { |
| 9239 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 9240 | target, pname, params); |
| 9241 | |
| 9242 | try |
| 9243 | { |
| 9244 | gl::Context *context = gl::getNonLostContext(); |
| 9245 | |
| 9246 | if (context) |
| 9247 | { |
| 9248 | if (context->getClientVersion() < 3) |
| 9249 | { |
| 9250 | return gl::error(GL_INVALID_OPERATION); |
| 9251 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9252 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9253 | // glGetBufferParameteri64v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9254 | UNIMPLEMENTED(); |
| 9255 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9256 | } |
| 9257 | catch(std::bad_alloc&) |
| 9258 | { |
| 9259 | return gl::error(GL_OUT_OF_MEMORY); |
| 9260 | } |
| 9261 | } |
| 9262 | |
| 9263 | void __stdcall glGenSamplers(GLsizei count, GLuint* samplers) |
| 9264 | { |
| 9265 | EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers); |
| 9266 | |
| 9267 | try |
| 9268 | { |
| 9269 | gl::Context *context = gl::getNonLostContext(); |
| 9270 | |
| 9271 | if (context) |
| 9272 | { |
| 9273 | if (context->getClientVersion() < 3) |
| 9274 | { |
| 9275 | return gl::error(GL_INVALID_OPERATION); |
| 9276 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9277 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 9278 | if (count < 0) |
| 9279 | { |
| 9280 | return gl::error(GL_INVALID_VALUE); |
| 9281 | } |
| 9282 | |
| 9283 | for (int i = 0; i < count; i++) |
| 9284 | { |
| 9285 | samplers[i] = context->createSampler(); |
| 9286 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9287 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9288 | } |
| 9289 | catch(std::bad_alloc&) |
| 9290 | { |
| 9291 | return gl::error(GL_OUT_OF_MEMORY); |
| 9292 | } |
| 9293 | } |
| 9294 | |
| 9295 | void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers) |
| 9296 | { |
| 9297 | EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers); |
| 9298 | |
| 9299 | try |
| 9300 | { |
| 9301 | gl::Context *context = gl::getNonLostContext(); |
| 9302 | |
| 9303 | if (context) |
| 9304 | { |
| 9305 | if (context->getClientVersion() < 3) |
| 9306 | { |
| 9307 | return gl::error(GL_INVALID_OPERATION); |
| 9308 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9309 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 9310 | if (count < 0) |
| 9311 | { |
| 9312 | return gl::error(GL_INVALID_VALUE); |
| 9313 | } |
| 9314 | |
| 9315 | for (int i = 0; i < count; i++) |
| 9316 | { |
| 9317 | context->deleteSampler(samplers[i]); |
| 9318 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9319 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9320 | } |
| 9321 | catch(std::bad_alloc&) |
| 9322 | { |
| 9323 | return gl::error(GL_OUT_OF_MEMORY); |
| 9324 | } |
| 9325 | } |
| 9326 | |
| 9327 | GLboolean __stdcall glIsSampler(GLuint sampler) |
| 9328 | { |
| 9329 | EVENT("(GLuint sampler = %u)", sampler); |
| 9330 | |
| 9331 | try |
| 9332 | { |
| 9333 | gl::Context *context = gl::getNonLostContext(); |
| 9334 | |
| 9335 | if (context) |
| 9336 | { |
| 9337 | if (context->getClientVersion() < 3) |
| 9338 | { |
| 9339 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 9340 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9341 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 9342 | return context->isSampler(sampler); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9343 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9344 | } |
| 9345 | catch(std::bad_alloc&) |
| 9346 | { |
| 9347 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 9348 | } |
| 9349 | |
| 9350 | return GL_FALSE; |
| 9351 | } |
| 9352 | |
| 9353 | void __stdcall glBindSampler(GLuint unit, GLuint sampler) |
| 9354 | { |
| 9355 | EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler); |
| 9356 | |
| 9357 | try |
| 9358 | { |
| 9359 | gl::Context *context = gl::getNonLostContext(); |
| 9360 | |
| 9361 | if (context) |
| 9362 | { |
| 9363 | if (context->getClientVersion() < 3) |
| 9364 | { |
| 9365 | return gl::error(GL_INVALID_OPERATION); |
| 9366 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9367 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 9368 | if (sampler != 0 && !context->isSampler(sampler)) |
| 9369 | { |
| 9370 | return gl::error(GL_INVALID_OPERATION); |
| 9371 | } |
| 9372 | |
| 9373 | if (unit >= context->getMaximumCombinedTextureImageUnits()) |
| 9374 | { |
| 9375 | return gl::error(GL_INVALID_VALUE); |
| 9376 | } |
| 9377 | |
| 9378 | context->bindSampler(unit, sampler); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9379 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9380 | } |
| 9381 | catch(std::bad_alloc&) |
| 9382 | { |
| 9383 | return gl::error(GL_OUT_OF_MEMORY); |
| 9384 | } |
| 9385 | } |
| 9386 | |
| 9387 | void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 9388 | { |
| 9389 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param); |
| 9390 | |
| 9391 | try |
| 9392 | { |
| 9393 | gl::Context *context = gl::getNonLostContext(); |
| 9394 | |
| 9395 | if (context) |
| 9396 | { |
| 9397 | if (context->getClientVersion() < 3) |
| 9398 | { |
| 9399 | return gl::error(GL_INVALID_OPERATION); |
| 9400 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9401 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 9402 | if (!gl::ValidateSamplerObjectParameter(pname)) |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 9403 | { |
| 9404 | return; |
| 9405 | } |
| 9406 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 9407 | if (!gl::ValidateTexParamParameters(context, pname, param)) |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 9408 | { |
| 9409 | return; |
| 9410 | } |
| 9411 | |
| 9412 | if (!context->isSampler(sampler)) |
| 9413 | { |
| 9414 | return gl::error(GL_INVALID_OPERATION); |
| 9415 | } |
| 9416 | |
| 9417 | context->samplerParameteri(sampler, pname, param); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9418 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9419 | } |
| 9420 | catch(std::bad_alloc&) |
| 9421 | { |
| 9422 | return gl::error(GL_OUT_OF_MEMORY); |
| 9423 | } |
| 9424 | } |
| 9425 | |
| 9426 | void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) |
| 9427 | { |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 9428 | glSamplerParameteri(sampler, pname, *param); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9429 | } |
| 9430 | |
| 9431 | void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 9432 | { |
| 9433 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param); |
| 9434 | |
| 9435 | try |
| 9436 | { |
| 9437 | gl::Context *context = gl::getNonLostContext(); |
| 9438 | |
| 9439 | if (context) |
| 9440 | { |
| 9441 | if (context->getClientVersion() < 3) |
| 9442 | { |
| 9443 | return gl::error(GL_INVALID_OPERATION); |
| 9444 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9445 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 9446 | if (!gl::ValidateSamplerObjectParameter(pname)) |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 9447 | { |
| 9448 | return; |
| 9449 | } |
| 9450 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 9451 | if (!gl::ValidateTexParamParameters(context, pname, static_cast<GLint>(param))) |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 9452 | { |
| 9453 | return; |
| 9454 | } |
| 9455 | |
| 9456 | if (!context->isSampler(sampler)) |
| 9457 | { |
| 9458 | return gl::error(GL_INVALID_OPERATION); |
| 9459 | } |
| 9460 | |
| 9461 | context->samplerParameterf(sampler, pname, param); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9462 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9463 | } |
| 9464 | catch(std::bad_alloc&) |
| 9465 | { |
| 9466 | return gl::error(GL_OUT_OF_MEMORY); |
| 9467 | } |
| 9468 | } |
| 9469 | |
| 9470 | void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) |
| 9471 | { |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 9472 | glSamplerParameterf(sampler, pname, *param); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9473 | } |
| 9474 | |
| 9475 | void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) |
| 9476 | { |
| 9477 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); |
| 9478 | |
| 9479 | try |
| 9480 | { |
| 9481 | gl::Context *context = gl::getNonLostContext(); |
| 9482 | |
| 9483 | if (context) |
| 9484 | { |
| 9485 | if (context->getClientVersion() < 3) |
| 9486 | { |
| 9487 | return gl::error(GL_INVALID_OPERATION); |
| 9488 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9489 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 9490 | if (!gl::ValidateSamplerObjectParameter(pname)) |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 9491 | { |
| 9492 | return; |
| 9493 | } |
| 9494 | |
| 9495 | if (!context->isSampler(sampler)) |
| 9496 | { |
| 9497 | return gl::error(GL_INVALID_OPERATION); |
| 9498 | } |
| 9499 | |
| 9500 | *params = context->getSamplerParameteri(sampler, pname); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9501 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9502 | } |
| 9503 | catch(std::bad_alloc&) |
| 9504 | { |
| 9505 | return gl::error(GL_OUT_OF_MEMORY); |
| 9506 | } |
| 9507 | } |
| 9508 | |
| 9509 | void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) |
| 9510 | { |
| 9511 | EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params); |
| 9512 | |
| 9513 | try |
| 9514 | { |
| 9515 | gl::Context *context = gl::getNonLostContext(); |
| 9516 | |
| 9517 | if (context) |
| 9518 | { |
| 9519 | if (context->getClientVersion() < 3) |
| 9520 | { |
| 9521 | return gl::error(GL_INVALID_OPERATION); |
| 9522 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9523 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 9524 | if (!gl::ValidateSamplerObjectParameter(pname)) |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 9525 | { |
| 9526 | return; |
| 9527 | } |
| 9528 | |
| 9529 | if (!context->isSampler(sampler)) |
| 9530 | { |
| 9531 | return gl::error(GL_INVALID_OPERATION); |
| 9532 | } |
| 9533 | |
| 9534 | *params = context->getSamplerParameterf(sampler, pname); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9535 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9536 | } |
| 9537 | catch(std::bad_alloc&) |
| 9538 | { |
| 9539 | return gl::error(GL_OUT_OF_MEMORY); |
| 9540 | } |
| 9541 | } |
| 9542 | |
| 9543 | void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor) |
| 9544 | { |
| 9545 | EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor); |
| 9546 | |
| 9547 | try |
| 9548 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 9549 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9550 | { |
| 9551 | return gl::error(GL_INVALID_VALUE); |
| 9552 | } |
| 9553 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9554 | gl::Context *context = gl::getNonLostContext(); |
| 9555 | |
| 9556 | if (context) |
| 9557 | { |
| 9558 | if (context->getClientVersion() < 3) |
| 9559 | { |
| 9560 | return gl::error(GL_INVALID_OPERATION); |
| 9561 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9562 | |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 9563 | context->setVertexAttribDivisor(index, divisor); |
| 9564 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9565 | } |
| 9566 | catch(std::bad_alloc&) |
| 9567 | { |
| 9568 | return gl::error(GL_OUT_OF_MEMORY); |
| 9569 | } |
| 9570 | } |
| 9571 | |
| 9572 | void __stdcall glBindTransformFeedback(GLenum target, GLuint id) |
| 9573 | { |
| 9574 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 9575 | |
| 9576 | try |
| 9577 | { |
| 9578 | gl::Context *context = gl::getNonLostContext(); |
| 9579 | |
| 9580 | if (context) |
| 9581 | { |
| 9582 | if (context->getClientVersion() < 3) |
| 9583 | { |
| 9584 | return gl::error(GL_INVALID_OPERATION); |
| 9585 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9586 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9587 | // glBindTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9588 | UNIMPLEMENTED(); |
| 9589 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9590 | } |
| 9591 | catch(std::bad_alloc&) |
| 9592 | { |
| 9593 | return gl::error(GL_OUT_OF_MEMORY); |
| 9594 | } |
| 9595 | } |
| 9596 | |
| 9597 | void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) |
| 9598 | { |
| 9599 | EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids); |
| 9600 | |
| 9601 | try |
| 9602 | { |
| 9603 | gl::Context *context = gl::getNonLostContext(); |
| 9604 | |
| 9605 | if (context) |
| 9606 | { |
| 9607 | if (context->getClientVersion() < 3) |
| 9608 | { |
| 9609 | return gl::error(GL_INVALID_OPERATION); |
| 9610 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9611 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9612 | // glDeleteTransformFeedbacks |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9613 | UNIMPLEMENTED(); |
| 9614 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9615 | } |
| 9616 | catch(std::bad_alloc&) |
| 9617 | { |
| 9618 | return gl::error(GL_OUT_OF_MEMORY); |
| 9619 | } |
| 9620 | } |
| 9621 | |
| 9622 | void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids) |
| 9623 | { |
| 9624 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 9625 | |
| 9626 | try |
| 9627 | { |
| 9628 | gl::Context *context = gl::getNonLostContext(); |
| 9629 | |
| 9630 | if (context) |
| 9631 | { |
| 9632 | if (context->getClientVersion() < 3) |
| 9633 | { |
| 9634 | return gl::error(GL_INVALID_OPERATION); |
| 9635 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9636 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9637 | // glGenTransformFeedbacks |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9638 | UNIMPLEMENTED(); |
| 9639 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9640 | } |
| 9641 | catch(std::bad_alloc&) |
| 9642 | { |
| 9643 | return gl::error(GL_OUT_OF_MEMORY); |
| 9644 | } |
| 9645 | } |
| 9646 | |
| 9647 | GLboolean __stdcall glIsTransformFeedback(GLuint id) |
| 9648 | { |
| 9649 | EVENT("(GLuint id = %u)", id); |
| 9650 | |
| 9651 | try |
| 9652 | { |
| 9653 | gl::Context *context = gl::getNonLostContext(); |
| 9654 | |
| 9655 | if (context) |
| 9656 | { |
| 9657 | if (context->getClientVersion() < 3) |
| 9658 | { |
| 9659 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 9660 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9661 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9662 | // glIsTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9663 | UNIMPLEMENTED(); |
| 9664 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9665 | } |
| 9666 | catch(std::bad_alloc&) |
| 9667 | { |
| 9668 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 9669 | } |
| 9670 | |
| 9671 | return GL_FALSE; |
| 9672 | } |
| 9673 | |
| 9674 | void __stdcall glPauseTransformFeedback(void) |
| 9675 | { |
| 9676 | EVENT("(void)"); |
| 9677 | |
| 9678 | try |
| 9679 | { |
| 9680 | gl::Context *context = gl::getNonLostContext(); |
| 9681 | |
| 9682 | if (context) |
| 9683 | { |
| 9684 | if (context->getClientVersion() < 3) |
| 9685 | { |
| 9686 | return gl::error(GL_INVALID_OPERATION); |
| 9687 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9688 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9689 | // glPauseTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9690 | UNIMPLEMENTED(); |
| 9691 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9692 | } |
| 9693 | catch(std::bad_alloc&) |
| 9694 | { |
| 9695 | return gl::error(GL_OUT_OF_MEMORY); |
| 9696 | } |
| 9697 | } |
| 9698 | |
| 9699 | void __stdcall glResumeTransformFeedback(void) |
| 9700 | { |
| 9701 | EVENT("(void)"); |
| 9702 | |
| 9703 | try |
| 9704 | { |
| 9705 | gl::Context *context = gl::getNonLostContext(); |
| 9706 | |
| 9707 | if (context) |
| 9708 | { |
| 9709 | if (context->getClientVersion() < 3) |
| 9710 | { |
| 9711 | return gl::error(GL_INVALID_OPERATION); |
| 9712 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9713 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9714 | // glResumeTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9715 | UNIMPLEMENTED(); |
| 9716 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9717 | } |
| 9718 | catch(std::bad_alloc&) |
| 9719 | { |
| 9720 | return gl::error(GL_OUT_OF_MEMORY); |
| 9721 | } |
| 9722 | } |
| 9723 | |
| 9724 | void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) |
| 9725 | { |
| 9726 | EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)", |
| 9727 | program, bufSize, length, binaryFormat, binary); |
| 9728 | |
| 9729 | try |
| 9730 | { |
| 9731 | gl::Context *context = gl::getNonLostContext(); |
| 9732 | |
| 9733 | if (context) |
| 9734 | { |
| 9735 | if (context->getClientVersion() < 3) |
| 9736 | { |
| 9737 | return gl::error(GL_INVALID_OPERATION); |
| 9738 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9739 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9740 | // glGetProgramBinary |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9741 | UNIMPLEMENTED(); |
| 9742 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9743 | } |
| 9744 | catch(std::bad_alloc&) |
| 9745 | { |
| 9746 | return gl::error(GL_OUT_OF_MEMORY); |
| 9747 | } |
| 9748 | } |
| 9749 | |
| 9750 | void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) |
| 9751 | { |
| 9752 | EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
| 9753 | program, binaryFormat, binary, length); |
| 9754 | |
| 9755 | try |
| 9756 | { |
| 9757 | gl::Context *context = gl::getNonLostContext(); |
| 9758 | |
| 9759 | if (context) |
| 9760 | { |
| 9761 | if (context->getClientVersion() < 3) |
| 9762 | { |
| 9763 | return gl::error(GL_INVALID_OPERATION); |
| 9764 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9765 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9766 | // glProgramBinary |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9767 | UNIMPLEMENTED(); |
| 9768 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9769 | } |
| 9770 | catch(std::bad_alloc&) |
| 9771 | { |
| 9772 | return gl::error(GL_OUT_OF_MEMORY); |
| 9773 | } |
| 9774 | } |
| 9775 | |
| 9776 | void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value) |
| 9777 | { |
| 9778 | EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)", |
| 9779 | program, pname, value); |
| 9780 | |
| 9781 | try |
| 9782 | { |
| 9783 | gl::Context *context = gl::getNonLostContext(); |
| 9784 | |
| 9785 | if (context) |
| 9786 | { |
| 9787 | if (context->getClientVersion() < 3) |
| 9788 | { |
| 9789 | return gl::error(GL_INVALID_OPERATION); |
| 9790 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9791 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9792 | // glProgramParameteri |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9793 | UNIMPLEMENTED(); |
| 9794 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9795 | } |
| 9796 | catch(std::bad_alloc&) |
| 9797 | { |
| 9798 | return gl::error(GL_OUT_OF_MEMORY); |
| 9799 | } |
| 9800 | } |
| 9801 | |
| 9802 | void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) |
| 9803 | { |
| 9804 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)", |
| 9805 | target, numAttachments, attachments); |
| 9806 | |
| 9807 | try |
| 9808 | { |
| 9809 | gl::Context *context = gl::getNonLostContext(); |
| 9810 | |
| 9811 | if (context) |
| 9812 | { |
| 9813 | if (context->getClientVersion() < 3) |
| 9814 | { |
| 9815 | return gl::error(GL_INVALID_OPERATION); |
| 9816 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9817 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 9818 | if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 9819 | { |
| 9820 | return; |
| 9821 | } |
| 9822 | |
| 9823 | int maxDimension = context->getMaximumRenderbufferDimension(); |
| 9824 | context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension); |
| 9825 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9826 | } |
| 9827 | catch(std::bad_alloc&) |
| 9828 | { |
| 9829 | return gl::error(GL_OUT_OF_MEMORY); |
| 9830 | } |
| 9831 | } |
| 9832 | |
| 9833 | void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) |
| 9834 | { |
| 9835 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, " |
| 9836 | "GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 9837 | target, numAttachments, attachments, x, y, width, height); |
| 9838 | |
| 9839 | try |
| 9840 | { |
| 9841 | gl::Context *context = gl::getNonLostContext(); |
| 9842 | |
| 9843 | if (context) |
| 9844 | { |
| 9845 | if (context->getClientVersion() < 3) |
| 9846 | { |
| 9847 | return gl::error(GL_INVALID_OPERATION); |
| 9848 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9849 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 9850 | if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 9851 | { |
| 9852 | return; |
| 9853 | } |
| 9854 | |
| 9855 | context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height); |
| 9856 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9857 | } |
| 9858 | catch(std::bad_alloc&) |
| 9859 | { |
| 9860 | return gl::error(GL_OUT_OF_MEMORY); |
| 9861 | } |
| 9862 | } |
| 9863 | |
| 9864 | void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 9865 | { |
| 9866 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 9867 | target, levels, internalformat, width, height); |
| 9868 | |
| 9869 | try |
| 9870 | { |
| 9871 | gl::Context *context = gl::getNonLostContext(); |
| 9872 | |
| 9873 | if (context) |
| 9874 | { |
| 9875 | if (context->getClientVersion() < 3) |
| 9876 | { |
| 9877 | return gl::error(GL_INVALID_OPERATION); |
| 9878 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9879 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 9880 | if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 9881 | { |
| 9882 | return; |
| 9883 | } |
| 9884 | |
| 9885 | switch (target) |
| 9886 | { |
| 9887 | case GL_TEXTURE_2D: |
| 9888 | { |
| 9889 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 9890 | texture2d->storage(levels, internalformat, width, height); |
| 9891 | } |
| 9892 | break; |
| 9893 | |
| 9894 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 9895 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 9896 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 9897 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 9898 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 9899 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 9900 | { |
| 9901 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 9902 | textureCube->storage(levels, internalformat, width); |
| 9903 | } |
| 9904 | break; |
| 9905 | |
| 9906 | default: |
| 9907 | return gl::error(GL_INVALID_ENUM); |
| 9908 | } |
| 9909 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9910 | } |
| 9911 | catch(std::bad_alloc&) |
| 9912 | { |
| 9913 | return gl::error(GL_OUT_OF_MEMORY); |
| 9914 | } |
| 9915 | } |
| 9916 | |
| 9917 | void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
| 9918 | { |
| 9919 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 9920 | "GLsizei height = %d, GLsizei depth = %d)", |
| 9921 | target, levels, internalformat, width, height, depth); |
| 9922 | |
| 9923 | try |
| 9924 | { |
| 9925 | gl::Context *context = gl::getNonLostContext(); |
| 9926 | |
| 9927 | if (context) |
| 9928 | { |
| 9929 | if (context->getClientVersion() < 3) |
| 9930 | { |
| 9931 | return gl::error(GL_INVALID_OPERATION); |
| 9932 | } |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 9933 | |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 9934 | if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 9935 | { |
| 9936 | return; |
| 9937 | } |
| 9938 | |
| 9939 | switch (target) |
| 9940 | { |
| 9941 | case GL_TEXTURE_3D: |
| 9942 | { |
| 9943 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 9944 | texture3d->storage(levels, internalformat, width, height, depth); |
| 9945 | } |
| 9946 | break; |
| 9947 | |
| 9948 | case GL_TEXTURE_2D_ARRAY: |
| 9949 | { |
| 9950 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 9951 | texture2darray->storage(levels, internalformat, width, height, depth); |
| 9952 | } |
| 9953 | break; |
| 9954 | |
| 9955 | default: |
| 9956 | return gl::error(GL_INVALID_ENUM); |
| 9957 | } |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 9958 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9959 | } |
| 9960 | catch(std::bad_alloc&) |
| 9961 | { |
| 9962 | return gl::error(GL_OUT_OF_MEMORY); |
| 9963 | } |
| 9964 | } |
| 9965 | |
| 9966 | void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) |
| 9967 | { |
| 9968 | EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, " |
| 9969 | "GLint* params = 0x%0.8p)", |
| 9970 | target, internalformat, pname, bufSize, params); |
| 9971 | |
| 9972 | try |
| 9973 | { |
| 9974 | gl::Context *context = gl::getNonLostContext(); |
| 9975 | |
| 9976 | if (context) |
| 9977 | { |
| 9978 | if (context->getClientVersion() < 3) |
| 9979 | { |
| 9980 | return gl::error(GL_INVALID_OPERATION); |
| 9981 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9982 | |
Shannon Woods | 809d250 | 2013-07-08 10:32:18 -0400 | [diff] [blame] | 9983 | if (!gl::IsColorRenderingSupported(internalformat, context) && |
| 9984 | !gl::IsDepthRenderingSupported(internalformat, context) && |
| 9985 | !gl::IsStencilRenderingSupported(internalformat, context)) |
| 9986 | { |
| 9987 | return gl::error(GL_INVALID_ENUM); |
| 9988 | } |
| 9989 | |
| 9990 | if (target != GL_RENDERBUFFER) |
| 9991 | { |
| 9992 | return gl::error(GL_INVALID_ENUM); |
| 9993 | } |
| 9994 | |
| 9995 | if (bufSize < 0) |
| 9996 | { |
| 9997 | return gl::error(GL_INVALID_VALUE); |
| 9998 | } |
| 9999 | |
| 10000 | switch (pname) |
| 10001 | { |
| 10002 | case GL_NUM_SAMPLE_COUNTS: |
| 10003 | if (bufSize != 0) |
| 10004 | *params = context->getNumSampleCounts(internalformat); |
| 10005 | break; |
| 10006 | case GL_SAMPLES: |
| 10007 | context->getSampleCounts(internalformat, bufSize, params); |
| 10008 | break; |
| 10009 | default: |
| 10010 | return gl::error(GL_INVALID_ENUM); |
| 10011 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10012 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10013 | } |
| 10014 | catch(std::bad_alloc&) |
| 10015 | { |
| 10016 | return gl::error(GL_OUT_OF_MEMORY); |
| 10017 | } |
| 10018 | } |
| 10019 | |
| 10020 | // Extension functions |
| 10021 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 10022 | void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 10023 | GLbitfield mask, GLenum filter) |
| 10024 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 10025 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, " |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 10026 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, " |
| 10027 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 10028 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 10029 | |
| 10030 | try |
| 10031 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 10032 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 10033 | |
| 10034 | if (context) |
| 10035 | { |
Geoff Lang | 34dbb6f | 2013-08-05 15:05:47 -0400 | [diff] [blame] | 10036 | if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 10037 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 10038 | true)) |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 10039 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 10040 | return; |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 10041 | } |
| 10042 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 10043 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 10044 | mask, filter); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 10045 | } |
| 10046 | } |
| 10047 | catch(std::bad_alloc&) |
| 10048 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 10049 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 10050 | } |
| 10051 | } |
| 10052 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 10053 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, |
| 10054 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 10055 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 10056 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 10057 | "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] | 10058 | "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] | 10059 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 10060 | |
| 10061 | try |
| 10062 | { |
| 10063 | UNIMPLEMENTED(); // FIXME |
| 10064 | } |
| 10065 | catch(std::bad_alloc&) |
| 10066 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 10067 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 10068 | } |
| 10069 | } |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 10070 | |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 10071 | void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, |
| 10072 | GLenum *binaryFormat, void *binary) |
| 10073 | { |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 10074 | EVENT("(GLenum program = 0x%X, bufSize = %d, length = 0x%0.8p, binaryFormat = 0x%0.8p, binary = 0x%0.8p)", |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 10075 | program, bufSize, length, binaryFormat, binary); |
| 10076 | |
| 10077 | try |
| 10078 | { |
| 10079 | gl::Context *context = gl::getNonLostContext(); |
| 10080 | |
| 10081 | if (context) |
| 10082 | { |
| 10083 | gl::Program *programObject = context->getProgram(program); |
| 10084 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 10085 | if (!programObject || !programObject->isLinked()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 10086 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 10087 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 10088 | } |
| 10089 | |
| 10090 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10091 | |
| 10092 | if (!programBinary) |
| 10093 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 10094 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 10095 | } |
| 10096 | |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 10097 | if (!programBinary->save(binary, bufSize, length)) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 10098 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 10099 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 10100 | } |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 10101 | |
| 10102 | *binaryFormat = GL_PROGRAM_BINARY_ANGLE; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 10103 | } |
| 10104 | } |
| 10105 | catch(std::bad_alloc&) |
| 10106 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 10107 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 10108 | } |
| 10109 | } |
| 10110 | |
| 10111 | void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat, |
| 10112 | const void *binary, GLint length) |
| 10113 | { |
| 10114 | EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)", |
| 10115 | program, binaryFormat, binary, length); |
| 10116 | |
| 10117 | try |
| 10118 | { |
| 10119 | gl::Context *context = gl::getNonLostContext(); |
| 10120 | |
| 10121 | if (context) |
| 10122 | { |
| 10123 | if (binaryFormat != GL_PROGRAM_BINARY_ANGLE) |
| 10124 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 10125 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 10126 | } |
| 10127 | |
| 10128 | gl::Program *programObject = context->getProgram(program); |
| 10129 | |
| 10130 | if (!programObject) |
| 10131 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 10132 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 10133 | } |
| 10134 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 10135 | context->setProgramBinary(program, binary, length); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 10136 | } |
| 10137 | } |
| 10138 | catch(std::bad_alloc&) |
| 10139 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 10140 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 10141 | } |
| 10142 | } |
| 10143 | |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 10144 | void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) |
| 10145 | { |
| 10146 | EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs); |
| 10147 | |
| 10148 | try |
| 10149 | { |
| 10150 | gl::Context *context = gl::getNonLostContext(); |
| 10151 | |
| 10152 | if (context) |
| 10153 | { |
| 10154 | if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets()) |
| 10155 | { |
| 10156 | return gl::error(GL_INVALID_VALUE); |
| 10157 | } |
| 10158 | |
| 10159 | if (context->getDrawFramebufferHandle() == 0) |
| 10160 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 10161 | if (n != 1) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 10162 | { |
| 10163 | return gl::error(GL_INVALID_OPERATION); |
| 10164 | } |
| 10165 | |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 10166 | if (bufs[0] != GL_NONE && bufs[0] != GL_BACK) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 10167 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 10168 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 10169 | } |
| 10170 | } |
| 10171 | else |
| 10172 | { |
| 10173 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 10174 | { |
| 10175 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 10176 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment) |
| 10177 | { |
| 10178 | return gl::error(GL_INVALID_OPERATION); |
| 10179 | } |
| 10180 | } |
| 10181 | } |
| 10182 | |
| 10183 | gl::Framebuffer *framebuffer = context->getDrawFramebuffer(); |
| 10184 | |
| 10185 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 10186 | { |
| 10187 | framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]); |
| 10188 | } |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 10189 | |
| 10190 | for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++) |
| 10191 | { |
| 10192 | framebuffer->setDrawBufferState(colorAttachment, GL_NONE); |
| 10193 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 10194 | } |
| 10195 | } |
| 10196 | catch (std::bad_alloc&) |
| 10197 | { |
| 10198 | return gl::error(GL_OUT_OF_MEMORY); |
| 10199 | } |
| 10200 | } |
| 10201 | |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 10202 | __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) |
| 10203 | { |
| 10204 | struct Extension |
| 10205 | { |
| 10206 | const char *name; |
| 10207 | __eglMustCastToProperFunctionPointerType address; |
| 10208 | }; |
| 10209 | |
| 10210 | static const Extension glExtensions[] = |
| 10211 | { |
| 10212 | {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 10213 | {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, |
daniel@transgaming.com | 1fe96c9 | 2011-01-14 15:08:44 +0000 | [diff] [blame] | 10214 | {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 10215 | {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, |
| 10216 | {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, |
| 10217 | {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, |
| 10218 | {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, |
| 10219 | {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, |
| 10220 | {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, |
| 10221 | {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 10222 | {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE}, |
daniel@transgaming.com | 0bd1f2f | 2011-11-11 04:19:03 +0000 | [diff] [blame] | 10223 | {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT}, |
daniel@transgaming.com | 709ed11 | 2011-11-12 03:18:10 +0000 | [diff] [blame] | 10224 | {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT}, |
| 10225 | {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT}, |
| 10226 | {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT}, |
| 10227 | {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT}, |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 10228 | {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT}, |
| 10229 | {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT}, |
| 10230 | {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT}, |
| 10231 | {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT}, |
| 10232 | {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT}, |
| 10233 | {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT}, |
| 10234 | {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT}, |
shannon.woods%transgaming.com@gtempaccount.com | 77d9472 | 2013-04-13 03:34:22 +0000 | [diff] [blame] | 10235 | {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT}, |
daniel@transgaming.com | dce02fd | 2012-01-27 15:39:51 +0000 | [diff] [blame] | 10236 | {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE}, |
| 10237 | {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, |
| 10238 | {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 10239 | {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, |
| 10240 | {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, }; |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 10241 | |
shannon.woods@transgaming.com | d438fd4 | 2013-02-28 23:17:45 +0000 | [diff] [blame] | 10242 | for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 10243 | { |
| 10244 | if (strcmp(procname, glExtensions[ext].name) == 0) |
| 10245 | { |
| 10246 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address; |
| 10247 | } |
| 10248 | } |
| 10249 | |
| 10250 | return NULL; |
| 10251 | } |
| 10252 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 10253 | // Non-public functions used by EGL |
| 10254 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 10255 | bool __stdcall glBindTexImage(egl::Surface *surface) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 10256 | { |
| 10257 | EVENT("(egl::Surface* surface = 0x%0.8p)", |
| 10258 | surface); |
| 10259 | |
| 10260 | try |
| 10261 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 10262 | gl::Context *context = gl::getNonLostContext(); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 10263 | |
| 10264 | if (context) |
| 10265 | { |
| 10266 | gl::Texture2D *textureObject = context->getTexture2D(); |
| 10267 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 10268 | if (textureObject->isImmutable()) |
| 10269 | { |
| 10270 | return false; |
| 10271 | } |
| 10272 | |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 10273 | if (textureObject) |
| 10274 | { |
| 10275 | textureObject->bindTexImage(surface); |
| 10276 | } |
| 10277 | } |
| 10278 | } |
| 10279 | catch(std::bad_alloc&) |
| 10280 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 10281 | return gl::error(GL_OUT_OF_MEMORY, false); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 10282 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 10283 | |
| 10284 | return true; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 10285 | } |
| 10286 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 10287 | } |