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" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 24 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 25 | bool validImageSize(const gl::Context *context, GLint level, GLsizei width, GLsizei height, GLsizei depth) |
daniel@transgaming.com | 4f9ef0d | 2011-05-30 23:51:19 +0000 | [diff] [blame] | 26 | { |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 27 | if (level < 0 || width < 0 || height < 0 || depth < 0) |
daniel@transgaming.com | 4f9ef0d | 2011-05-30 23:51:19 +0000 | [diff] [blame] | 28 | { |
| 29 | return false; |
| 30 | } |
| 31 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 32 | if (context->supportsNonPower2Texture()) |
daniel@transgaming.com | 4f9ef0d | 2011-05-30 23:51:19 +0000 | [diff] [blame] | 33 | { |
| 34 | return true; |
| 35 | } |
| 36 | |
| 37 | if (level == 0) |
| 38 | { |
| 39 | return true; |
| 40 | } |
| 41 | |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 42 | if (gl::isPow2(width) && gl::isPow2(height) && gl::isPow2(depth)) |
daniel@transgaming.com | 4f9ef0d | 2011-05-30 23:51:19 +0000 | [diff] [blame] | 43 | { |
| 44 | return true; |
| 45 | } |
| 46 | |
| 47 | return false; |
| 48 | } |
| 49 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 50 | bool validCompressedImageSize(GLsizei width, GLsizei height) |
| 51 | { |
| 52 | if (width != 1 && width != 2 && width % 4 != 0) |
| 53 | { |
| 54 | return false; |
| 55 | } |
| 56 | |
| 57 | if (height != 1 && height != 2 && height % 4 != 0) |
| 58 | { |
| 59 | return false; |
| 60 | } |
| 61 | |
| 62 | return true; |
| 63 | } |
| 64 | |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 65 | // Verify that format/type are one of the combinations from table 3.4. |
| 66 | bool checkTextureFormatType(GLenum format, GLenum type) |
| 67 | { |
| 68 | // validate <format> by itself (used as secondary key below) |
| 69 | switch (format) |
| 70 | { |
| 71 | case GL_RGBA: |
| 72 | case GL_BGRA_EXT: |
| 73 | case GL_RGB: |
| 74 | case GL_ALPHA: |
| 75 | case GL_LUMINANCE: |
| 76 | case GL_LUMINANCE_ALPHA: |
| 77 | case GL_DEPTH_COMPONENT: |
| 78 | case GL_DEPTH_STENCIL_OES: |
| 79 | break; |
| 80 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 81 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | // invalid <type> -> sets INVALID_ENUM |
| 85 | // invalid <format>+<type> combination -> sets INVALID_OPERATION |
| 86 | switch (type) |
| 87 | { |
| 88 | case GL_UNSIGNED_BYTE: |
| 89 | switch (format) |
| 90 | { |
| 91 | case GL_RGBA: |
| 92 | case GL_BGRA_EXT: |
| 93 | case GL_RGB: |
| 94 | case GL_ALPHA: |
| 95 | case GL_LUMINANCE: |
| 96 | case GL_LUMINANCE_ALPHA: |
| 97 | return true; |
| 98 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 99 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | case GL_FLOAT: |
| 103 | case GL_HALF_FLOAT_OES: |
| 104 | switch (format) |
| 105 | { |
| 106 | case GL_RGBA: |
| 107 | case GL_RGB: |
| 108 | case GL_ALPHA: |
| 109 | case GL_LUMINANCE: |
| 110 | case GL_LUMINANCE_ALPHA: |
| 111 | return true; |
| 112 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 113 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 117 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 118 | switch (format) |
| 119 | { |
| 120 | case GL_RGBA: |
| 121 | return true; |
| 122 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 123 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | case GL_UNSIGNED_SHORT_5_6_5: |
| 127 | switch (format) |
| 128 | { |
| 129 | case GL_RGB: |
| 130 | return true; |
| 131 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 132 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | case GL_UNSIGNED_SHORT: |
| 136 | case GL_UNSIGNED_INT: |
| 137 | switch (format) |
| 138 | { |
| 139 | case GL_DEPTH_COMPONENT: |
| 140 | return true; |
| 141 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 142 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | case GL_UNSIGNED_INT_24_8_OES: |
| 146 | switch (format) |
| 147 | { |
| 148 | case GL_DEPTH_STENCIL_OES: |
| 149 | return true; |
| 150 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 151 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 155 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 156 | } |
| 157 | } |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 158 | |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 159 | bool validateSubImageParams2D(bool compressed, GLsizei width, GLsizei height, |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 160 | GLint xoffset, GLint yoffset, GLint level, GLenum format, GLenum type, |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 161 | gl::Texture2D *texture) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 162 | { |
| 163 | if (!texture) |
| 164 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 165 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 166 | } |
| 167 | |
daniel@transgaming.com | 92f4992 | 2012-05-09 15:49:19 +0000 | [diff] [blame] | 168 | if (compressed != texture->isCompressed(level)) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 169 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 170 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 171 | } |
| 172 | |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 173 | if (format != GL_NONE) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 174 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 175 | GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 176 | if (internalformat != texture->getInternalFormat(level)) |
| 177 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 178 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 179 | } |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | if (compressed) |
| 183 | { |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 184 | if ((width % 4 != 0 && width != texture->getWidth(0)) || |
| 185 | (height % 4 != 0 && height != texture->getHeight(0))) |
| 186 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 187 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 188 | } |
| 189 | } |
| 190 | |
| 191 | if (xoffset + width > texture->getWidth(level) || |
| 192 | yoffset + height > texture->getHeight(level)) |
| 193 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 194 | return gl::error(GL_INVALID_VALUE, false); |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | return true; |
| 198 | } |
| 199 | |
| 200 | bool validateSubImageParamsCube(bool compressed, GLsizei width, GLsizei height, |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 201 | GLint xoffset, GLint yoffset, GLenum target, GLint level, GLenum format, GLenum type, |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 202 | gl::TextureCubeMap *texture) |
| 203 | { |
| 204 | if (!texture) |
| 205 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 206 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 207 | } |
| 208 | |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 209 | if (compressed != texture->isCompressed(target, level)) |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 210 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 211 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 212 | } |
| 213 | |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 214 | if (format != GL_NONE) |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 215 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 216 | GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 217 | if (internalformat != texture->getInternalFormat(target, level)) |
| 218 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 219 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 220 | } |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | if (compressed) |
| 224 | { |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 225 | if ((width % 4 != 0 && width != texture->getWidth(target, 0)) || |
| 226 | (height % 4 != 0 && height != texture->getHeight(target, 0))) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 227 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 228 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 229 | } |
| 230 | } |
| 231 | |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 232 | if (xoffset + width > texture->getWidth(target, level) || |
| 233 | yoffset + height > texture->getHeight(target, level)) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 234 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 235 | return gl::error(GL_INVALID_VALUE, false); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | return true; |
| 239 | } |
| 240 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 241 | bool validateES2TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage, |
| 242 | GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 243 | GLint border, GLenum format, GLenum type, const GLvoid *pixels) |
| 244 | { |
| 245 | if (!validImageSize(context, level, width, height, 1)) |
| 246 | { |
| 247 | return gl::error(GL_INVALID_VALUE, false); |
| 248 | } |
| 249 | |
| 250 | if (isCompressed && !validCompressedImageSize(width, height)) |
| 251 | { |
| 252 | return gl::error(GL_INVALID_OPERATION, false); |
| 253 | } |
| 254 | |
| 255 | if (level < 0 || xoffset < 0 || |
| 256 | std::numeric_limits<GLsizei>::max() - xoffset < width || |
| 257 | std::numeric_limits<GLsizei>::max() - yoffset < height) |
| 258 | { |
| 259 | return gl::error(GL_INVALID_VALUE, false); |
| 260 | } |
| 261 | |
| 262 | if (!isSubImage && !isCompressed && internalformat != GLint(format)) |
| 263 | { |
| 264 | return gl::error(GL_INVALID_OPERATION, false); |
| 265 | } |
| 266 | |
| 267 | gl::Texture *texture = NULL; |
| 268 | bool textureCompressed = false; |
| 269 | GLenum textureInternalFormat = GL_NONE; |
| 270 | GLint textureLevelWidth = 0; |
| 271 | GLint textureLevelHeight = 0; |
| 272 | switch (target) |
| 273 | { |
| 274 | case GL_TEXTURE_2D: |
| 275 | { |
| 276 | if (width > (context->getMaximum2DTextureDimension() >> level) || |
| 277 | height > (context->getMaximum2DTextureDimension() >> level)) |
| 278 | { |
| 279 | return gl::error(GL_INVALID_VALUE, false); |
| 280 | } |
| 281 | |
| 282 | gl::Texture2D *tex2d = context->getTexture2D(); |
| 283 | if (tex2d) |
| 284 | { |
| 285 | textureCompressed = tex2d->isCompressed(level); |
| 286 | textureInternalFormat = tex2d->getInternalFormat(level); |
| 287 | textureLevelWidth = tex2d->getWidth(level); |
| 288 | textureLevelHeight = tex2d->getHeight(level); |
| 289 | texture = tex2d; |
| 290 | } |
| 291 | |
| 292 | if (isSubImage && !validateSubImageParams2D(isCompressed, width, height, xoffset, yoffset, |
| 293 | level, format, type, tex2d)) |
| 294 | { |
| 295 | return false; |
| 296 | } |
| 297 | |
| 298 | texture = tex2d; |
| 299 | } |
| 300 | break; |
| 301 | |
| 302 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 303 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 304 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 305 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 306 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 307 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 308 | { |
| 309 | if (!isSubImage && width != height) |
| 310 | { |
| 311 | return gl::error(GL_INVALID_VALUE, false); |
| 312 | } |
| 313 | |
| 314 | if (width > (context->getMaximumCubeTextureDimension() >> level) || |
| 315 | height > (context->getMaximumCubeTextureDimension() >> level)) |
| 316 | { |
| 317 | return gl::error(GL_INVALID_VALUE, false); |
| 318 | } |
| 319 | |
| 320 | gl::TextureCubeMap *texCube = context->getTextureCubeMap(); |
| 321 | if (texCube) |
| 322 | { |
| 323 | textureCompressed = texCube->isCompressed(target, level); |
| 324 | textureInternalFormat = texCube->getInternalFormat(target, level); |
| 325 | textureLevelWidth = texCube->getWidth(target, level); |
| 326 | textureLevelHeight = texCube->getHeight(target, level); |
| 327 | texture = texCube; |
| 328 | } |
| 329 | |
| 330 | if (isSubImage && !validateSubImageParamsCube(isCompressed, width, height, xoffset, yoffset, |
| 331 | target, level, format, type, texCube)) |
| 332 | { |
| 333 | return false; |
| 334 | } |
| 335 | } |
| 336 | break; |
| 337 | |
| 338 | default: |
| 339 | return gl::error(GL_INVALID_ENUM, false); |
| 340 | } |
| 341 | |
| 342 | if (!texture) |
| 343 | { |
| 344 | return gl::error(GL_INVALID_OPERATION, false); |
| 345 | } |
| 346 | |
| 347 | if (!isSubImage && texture->isImmutable()) |
| 348 | { |
| 349 | return gl::error(GL_INVALID_OPERATION, false); |
| 350 | } |
| 351 | |
| 352 | // Verify zero border |
| 353 | if (border != 0) |
| 354 | { |
| 355 | return gl::error(GL_INVALID_VALUE, false); |
| 356 | } |
| 357 | |
| 358 | // Verify texture is not requesting more mip levels than are available. |
| 359 | if (level > context->getMaximumTextureLevel()) |
| 360 | { |
| 361 | return gl::error(GL_INVALID_VALUE, false); |
| 362 | } |
| 363 | |
| 364 | GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat; |
| 365 | if (isCompressed) |
| 366 | { |
| 367 | switch (actualInternalFormat) |
| 368 | { |
| 369 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 370 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 371 | if (!context->supportsDXT1Textures()) |
| 372 | { |
| 373 | return gl::error(GL_INVALID_ENUM, false); |
| 374 | } |
| 375 | break; |
| 376 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 377 | if (!context->supportsDXT3Textures()) |
| 378 | { |
| 379 | return gl::error(GL_INVALID_ENUM, false); |
| 380 | } |
| 381 | break; |
| 382 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 383 | if (!context->supportsDXT5Textures()) |
| 384 | { |
| 385 | return gl::error(GL_INVALID_ENUM, false); |
| 386 | } |
| 387 | break; |
| 388 | default: |
| 389 | return gl::error(GL_INVALID_ENUM, false); |
| 390 | } |
| 391 | } |
| 392 | else |
| 393 | { |
| 394 | // validate <type> by itself (used as secondary key below) |
| 395 | switch (type) |
| 396 | { |
| 397 | case GL_UNSIGNED_BYTE: |
| 398 | case GL_UNSIGNED_SHORT_5_6_5: |
| 399 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 400 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 401 | case GL_UNSIGNED_SHORT: |
| 402 | case GL_UNSIGNED_INT: |
| 403 | case GL_UNSIGNED_INT_24_8_OES: |
| 404 | case GL_HALF_FLOAT_OES: |
| 405 | case GL_FLOAT: |
| 406 | break; |
| 407 | default: |
| 408 | return gl::error(GL_INVALID_ENUM, false); |
| 409 | } |
| 410 | |
| 411 | // validate <format> + <type> combinations |
| 412 | // - invalid <format> -> sets INVALID_ENUM |
| 413 | // - invalid <format>+<type> combination -> sets INVALID_OPERATION |
| 414 | switch (format) |
| 415 | { |
| 416 | case GL_ALPHA: |
| 417 | case GL_LUMINANCE: |
| 418 | case GL_LUMINANCE_ALPHA: |
| 419 | switch (type) |
| 420 | { |
| 421 | case GL_UNSIGNED_BYTE: |
| 422 | case GL_FLOAT: |
| 423 | case GL_HALF_FLOAT_OES: |
| 424 | break; |
| 425 | default: |
| 426 | return gl::error(GL_INVALID_OPERATION, false); |
| 427 | } |
| 428 | break; |
| 429 | case GL_RGB: |
| 430 | switch (type) |
| 431 | { |
| 432 | case GL_UNSIGNED_BYTE: |
| 433 | case GL_UNSIGNED_SHORT_5_6_5: |
| 434 | case GL_FLOAT: |
| 435 | case GL_HALF_FLOAT_OES: |
| 436 | break; |
| 437 | default: |
| 438 | return gl::error(GL_INVALID_OPERATION, false); |
| 439 | } |
| 440 | break; |
| 441 | case GL_RGBA: |
| 442 | switch (type) |
| 443 | { |
| 444 | case GL_UNSIGNED_BYTE: |
| 445 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 446 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 447 | case GL_FLOAT: |
| 448 | case GL_HALF_FLOAT_OES: |
| 449 | break; |
| 450 | default: |
| 451 | return gl::error(GL_INVALID_OPERATION, false); |
| 452 | } |
| 453 | break; |
| 454 | case GL_BGRA_EXT: |
| 455 | switch (type) |
| 456 | { |
| 457 | case GL_UNSIGNED_BYTE: |
| 458 | break; |
| 459 | default: |
| 460 | return gl::error(GL_INVALID_OPERATION, false); |
| 461 | } |
| 462 | break; |
| 463 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below |
| 464 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 465 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 466 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 467 | break; |
| 468 | case GL_DEPTH_COMPONENT: |
| 469 | switch (type) |
| 470 | { |
| 471 | case GL_UNSIGNED_SHORT: |
| 472 | case GL_UNSIGNED_INT: |
| 473 | break; |
| 474 | default: |
| 475 | return gl::error(GL_INVALID_OPERATION, false); |
| 476 | } |
| 477 | break; |
| 478 | case GL_DEPTH_STENCIL_OES: |
| 479 | switch (type) |
| 480 | { |
| 481 | case GL_UNSIGNED_INT_24_8_OES: |
| 482 | break; |
| 483 | default: |
| 484 | return gl::error(GL_INVALID_OPERATION, false); |
| 485 | } |
| 486 | break; |
| 487 | default: |
| 488 | return gl::error(GL_INVALID_ENUM, false); |
| 489 | } |
| 490 | |
| 491 | switch (format) |
| 492 | { |
| 493 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 494 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 495 | if (context->supportsDXT1Textures()) |
| 496 | { |
| 497 | return gl::error(GL_INVALID_OPERATION, false); |
| 498 | } |
| 499 | else |
| 500 | { |
| 501 | return gl::error(GL_INVALID_ENUM, false); |
| 502 | } |
| 503 | break; |
| 504 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 505 | if (context->supportsDXT3Textures()) |
| 506 | { |
| 507 | return gl::error(GL_INVALID_OPERATION, false); |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | return gl::error(GL_INVALID_ENUM, false); |
| 512 | } |
| 513 | break; |
| 514 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 515 | if (context->supportsDXT5Textures()) |
| 516 | { |
| 517 | return gl::error(GL_INVALID_OPERATION, false); |
| 518 | } |
| 519 | else |
| 520 | { |
| 521 | return gl::error(GL_INVALID_ENUM, false); |
| 522 | } |
| 523 | break; |
| 524 | case GL_DEPTH_COMPONENT: |
| 525 | case GL_DEPTH_STENCIL_OES: |
| 526 | if (!context->supportsDepthTextures()) |
| 527 | { |
| 528 | return gl::error(GL_INVALID_VALUE, false); |
| 529 | } |
| 530 | if (target != GL_TEXTURE_2D) |
| 531 | { |
| 532 | return gl::error(GL_INVALID_OPERATION, false); |
| 533 | } |
| 534 | // OES_depth_texture supports loading depth data and multiple levels, |
| 535 | // but ANGLE_depth_texture does not |
| 536 | if (pixels != NULL || level != 0) |
| 537 | { |
| 538 | return gl::error(GL_INVALID_OPERATION, false); |
| 539 | } |
| 540 | break; |
| 541 | default: |
| 542 | break; |
| 543 | } |
| 544 | |
| 545 | if (type == GL_FLOAT) |
| 546 | { |
| 547 | if (!context->supportsFloat32Textures()) |
| 548 | { |
| 549 | return gl::error(GL_INVALID_ENUM, false); |
| 550 | } |
| 551 | } |
| 552 | else if (type == GL_HALF_FLOAT_OES) |
| 553 | { |
| 554 | if (!context->supportsFloat16Textures()) |
| 555 | { |
| 556 | return gl::error(GL_INVALID_ENUM, false); |
| 557 | } |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | return true; |
| 562 | } |
| 563 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 564 | bool validateES3TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage, |
| 565 | GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, |
| 566 | GLint border, GLenum format, GLenum type) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 567 | { |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 568 | // Validate image size |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 569 | if (!validImageSize(context, level, width, height, depth)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 570 | { |
| 571 | return gl::error(GL_INVALID_VALUE, false); |
| 572 | } |
| 573 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 574 | if (isCompressed && !validCompressedImageSize(width, height)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 575 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 576 | return gl::error(GL_INVALID_OPERATION, false); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | // Verify zero border |
| 580 | if (border != 0) |
| 581 | { |
| 582 | return gl::error(GL_INVALID_VALUE, false); |
| 583 | } |
| 584 | |
| 585 | // Validate dimensions based on Context limits and validate the texture |
| 586 | if (level > context->getMaximumTextureLevel()) |
| 587 | { |
| 588 | return gl::error(GL_INVALID_VALUE, false); |
| 589 | } |
| 590 | |
| 591 | gl::Texture *texture = NULL; |
| 592 | bool textureCompressed = false; |
| 593 | GLenum textureInternalFormat = GL_NONE; |
| 594 | GLint textureLevelWidth = 0; |
| 595 | GLint textureLevelHeight = 0; |
| 596 | GLint textureLevelDepth = 0; |
| 597 | switch (target) |
| 598 | { |
| 599 | case GL_TEXTURE_2D: |
| 600 | { |
| 601 | if (width > (context->getMaximum2DTextureDimension() >> level) || |
| 602 | height > (context->getMaximum2DTextureDimension() >> level)) |
| 603 | { |
| 604 | return gl::error(GL_INVALID_VALUE, false); |
| 605 | } |
| 606 | |
| 607 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 608 | if (texture2d) |
| 609 | { |
| 610 | textureCompressed = texture2d->isCompressed(level); |
| 611 | textureInternalFormat = texture2d->getInternalFormat(level); |
| 612 | textureLevelWidth = texture2d->getWidth(level); |
| 613 | textureLevelHeight = texture2d->getHeight(level); |
| 614 | textureLevelDepth = 1; |
| 615 | texture = texture2d; |
| 616 | } |
| 617 | } |
| 618 | break; |
| 619 | |
| 620 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 621 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 622 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 623 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 624 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 625 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 626 | { |
shannonwoods@chromium.org | 92852cf | 2013-05-30 00:14:12 +0000 | [diff] [blame] | 627 | if (!isSubImage && width != height) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 628 | { |
| 629 | return gl::error(GL_INVALID_VALUE, false); |
| 630 | } |
| 631 | |
| 632 | if (width > (context->getMaximumCubeTextureDimension() >> level)) |
| 633 | { |
| 634 | return gl::error(GL_INVALID_VALUE, false); |
| 635 | } |
| 636 | |
| 637 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 638 | if (textureCube) |
| 639 | { |
| 640 | textureCompressed = textureCube->isCompressed(target, level); |
| 641 | textureInternalFormat = textureCube->getInternalFormat(target, level); |
| 642 | textureLevelWidth = textureCube->getWidth(target, level); |
| 643 | textureLevelHeight = textureCube->getHeight(target, level); |
| 644 | textureLevelDepth = 1; |
| 645 | texture = textureCube; |
| 646 | } |
| 647 | } |
| 648 | break; |
| 649 | |
| 650 | case GL_TEXTURE_3D: |
| 651 | { |
| 652 | if (width > (context->getMaximum3DTextureDimension() >> level) || |
| 653 | height > (context->getMaximum3DTextureDimension() >> level) || |
| 654 | depth > (context->getMaximum3DTextureDimension() >> level)) |
| 655 | { |
| 656 | return gl::error(GL_INVALID_VALUE, false); |
| 657 | } |
| 658 | |
| 659 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 660 | if (texture3d) |
| 661 | { |
| 662 | textureCompressed = texture3d->isCompressed(level); |
| 663 | textureInternalFormat = texture3d->getInternalFormat(level); |
| 664 | textureLevelWidth = texture3d->getWidth(level); |
| 665 | textureLevelHeight = texture3d->getHeight(level); |
| 666 | textureLevelDepth = texture3d->getDepth(level); |
| 667 | texture = texture3d; |
| 668 | } |
| 669 | } |
| 670 | break; |
| 671 | |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 672 | case GL_TEXTURE_2D_ARRAY: |
| 673 | { |
| 674 | if (width > (context->getMaximum2DTextureDimension() >> level) || |
| 675 | height > (context->getMaximum2DTextureDimension() >> level) || |
| 676 | depth > (context->getMaximum2DArrayTextureLayers() >> level)) |
| 677 | { |
| 678 | return gl::error(GL_INVALID_VALUE, false); |
| 679 | } |
| 680 | |
| 681 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 682 | if (texture2darray) |
| 683 | { |
| 684 | textureCompressed = texture2darray->isCompressed(level); |
| 685 | textureInternalFormat = texture2darray->getInternalFormat(level); |
| 686 | textureLevelWidth = texture2darray->getWidth(level); |
| 687 | textureLevelHeight = texture2darray->getHeight(level); |
| 688 | textureLevelDepth = texture2darray->getDepth(level); |
| 689 | texture = texture2darray; |
| 690 | } |
| 691 | } |
| 692 | break; |
| 693 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 694 | default: |
| 695 | return gl::error(GL_INVALID_ENUM, false); |
| 696 | } |
| 697 | |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 698 | if (!texture) |
| 699 | { |
| 700 | return gl::error(GL_INVALID_OPERATION, false); |
| 701 | } |
| 702 | |
shannonwoods@chromium.org | cf2533c | 2013-05-30 00:14:18 +0000 | [diff] [blame] | 703 | if (texture->isImmutable() && !isSubImage) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 704 | { |
| 705 | return gl::error(GL_INVALID_OPERATION, false); |
| 706 | } |
| 707 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 708 | // Validate texture formats |
| 709 | GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat; |
| 710 | if (isCompressed) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 711 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 712 | if (!gl::IsFormatCompressed(actualInternalFormat, context->getClientVersion())) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 713 | { |
| 714 | return gl::error(GL_INVALID_ENUM, false); |
| 715 | } |
| 716 | |
| 717 | if (target == GL_TEXTURE_3D) |
| 718 | { |
| 719 | return gl::error(GL_INVALID_OPERATION, false); |
| 720 | } |
| 721 | } |
| 722 | else |
| 723 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 724 | if (!gl::IsValidInternalFormat(actualInternalFormat, context) || |
| 725 | !gl::IsValidFormat(format, context->getClientVersion()) || |
| 726 | !gl::IsValidType(type, context->getClientVersion())) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 727 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 728 | return gl::error(GL_INVALID_ENUM, false); |
| 729 | } |
| 730 | |
| 731 | if (!gl::IsValidFormatCombination(actualInternalFormat, format, type, context->getClientVersion())) |
| 732 | { |
| 733 | return gl::error(GL_INVALID_OPERATION, false); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 734 | } |
| 735 | |
| 736 | if ((target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) && |
| 737 | (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL)) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 738 | { |
| 739 | return gl::error(GL_INVALID_OPERATION, false); |
| 740 | } |
| 741 | } |
| 742 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 743 | // Validate sub image parameters |
| 744 | if (isSubImage) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 745 | { |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 746 | if (isCompressed != textureCompressed) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 747 | { |
| 748 | return gl::error(GL_INVALID_OPERATION, false); |
| 749 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 750 | |
| 751 | if (format != GL_NONE) |
| 752 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 753 | GLenum internalformat = gl::GetSizedInternalFormat(format, type, context->getClientVersion()); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 754 | if (internalformat != textureInternalFormat) |
| 755 | { |
| 756 | return gl::error(GL_INVALID_OPERATION, false); |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | if (isCompressed) |
| 761 | { |
| 762 | if ((width % 4 != 0 && width != textureLevelWidth) || |
| 763 | (height % 4 != 0 && height != textureLevelHeight)) |
| 764 | { |
| 765 | return gl::error(GL_INVALID_OPERATION, false); |
| 766 | } |
| 767 | } |
| 768 | |
| 769 | if (width == 0 || height == 0 || depth == 0) |
| 770 | { |
| 771 | return false; |
| 772 | } |
| 773 | |
| 774 | if (xoffset < 0 || yoffset < 0 || zoffset < 0) |
| 775 | { |
| 776 | return gl::error(GL_INVALID_VALUE, false); |
| 777 | } |
| 778 | |
| 779 | if (std::numeric_limits<GLsizei>::max() - xoffset < width || |
| 780 | std::numeric_limits<GLsizei>::max() - yoffset < height || |
| 781 | std::numeric_limits<GLsizei>::max() - zoffset < depth) |
| 782 | { |
| 783 | return gl::error(GL_INVALID_VALUE, false); |
| 784 | } |
| 785 | |
| 786 | if (xoffset + width > textureLevelWidth || |
| 787 | yoffset + height > textureLevelHeight || |
| 788 | zoffset + depth > textureLevelDepth) |
| 789 | { |
| 790 | return gl::error(GL_INVALID_VALUE, false); |
| 791 | } |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 792 | } |
| 793 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 794 | return true; |
| 795 | } |
| 796 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 797 | |
| 798 | bool validateES2CopyTexImageParameters(gl::Context* context, GLenum target, GLint level, GLenum internalformat, bool isSubImage, |
| 799 | GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, |
| 800 | GLint border) |
| 801 | { |
| 802 | if (!gl::IsInternalTextureTarget(target)) |
| 803 | { |
| 804 | return gl::error(GL_INVALID_ENUM, false); |
| 805 | } |
| 806 | |
| 807 | if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0) |
| 808 | { |
| 809 | return gl::error(GL_INVALID_VALUE, false); |
| 810 | } |
| 811 | |
| 812 | if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height) |
| 813 | { |
| 814 | return gl::error(GL_INVALID_VALUE, false); |
| 815 | } |
| 816 | |
| 817 | if (width == 0 || height == 0) |
| 818 | { |
| 819 | return false; |
| 820 | } |
| 821 | |
| 822 | // Verify zero border |
| 823 | if (border != 0) |
| 824 | { |
| 825 | return gl::error(GL_INVALID_VALUE, false); |
| 826 | } |
| 827 | |
| 828 | // Validate dimensions based on Context limits and validate the texture |
| 829 | if (level > context->getMaximumTextureLevel()) |
| 830 | { |
| 831 | return gl::error(GL_INVALID_VALUE, false); |
| 832 | } |
| 833 | |
| 834 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 835 | |
| 836 | if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) |
| 837 | { |
| 838 | return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); |
| 839 | } |
| 840 | |
| 841 | if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0) |
| 842 | { |
| 843 | return gl::error(GL_INVALID_OPERATION, false); |
| 844 | } |
| 845 | |
| 846 | GLenum colorbufferFormat = framebuffer->getReadColorbuffer()->getInternalFormat(); |
| 847 | gl::Texture *texture = NULL; |
| 848 | GLenum textureFormat = GL_RGBA; |
| 849 | |
| 850 | switch (target) |
| 851 | { |
| 852 | case GL_TEXTURE_2D: |
| 853 | { |
| 854 | if (width > (context->getMaximum2DTextureDimension() >> level) || |
| 855 | height > (context->getMaximum2DTextureDimension() >> level)) |
| 856 | { |
| 857 | return gl::error(GL_INVALID_VALUE, false); |
| 858 | } |
| 859 | |
| 860 | gl::Texture2D *tex2d = context->getTexture2D(); |
| 861 | if (tex2d) |
| 862 | { |
| 863 | if (isSubImage && !validateSubImageParams2D(false, width, height, xoffset, yoffset, level, GL_NONE, GL_NONE, tex2d)) |
| 864 | { |
| 865 | return false; // error already registered by validateSubImageParams |
| 866 | } |
| 867 | texture = tex2d; |
| 868 | textureFormat = gl::GetFormat(tex2d->getInternalFormat(level), context->getClientVersion()); |
| 869 | } |
| 870 | } |
| 871 | break; |
| 872 | |
| 873 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 874 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 875 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 876 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 877 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 878 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 879 | { |
| 880 | if (!isSubImage && width != height) |
| 881 | { |
| 882 | return gl::error(GL_INVALID_VALUE, false); |
| 883 | } |
| 884 | |
| 885 | if (width > (context->getMaximumCubeTextureDimension() >> level) || |
| 886 | height > (context->getMaximumCubeTextureDimension() >> level)) |
| 887 | { |
| 888 | return gl::error(GL_INVALID_VALUE, false); |
| 889 | } |
| 890 | |
| 891 | gl::TextureCubeMap *texcube = context->getTextureCubeMap(); |
| 892 | if (texcube) |
| 893 | { |
| 894 | if (isSubImage && !validateSubImageParamsCube(false, width, height, xoffset, yoffset, target, level, GL_NONE, GL_NONE, texcube)) |
| 895 | { |
| 896 | return false; // error already registered by validateSubImageParams |
| 897 | } |
| 898 | texture = texcube; |
| 899 | textureFormat = gl::GetFormat(texcube->getInternalFormat(target, level), context->getClientVersion()); |
| 900 | } |
| 901 | } |
| 902 | break; |
| 903 | |
| 904 | default: |
| 905 | return gl::error(GL_INVALID_ENUM, false); |
| 906 | } |
| 907 | |
| 908 | if (!texture) |
| 909 | { |
| 910 | return gl::error(GL_INVALID_OPERATION, false); |
| 911 | } |
| 912 | |
| 913 | if (texture->isImmutable() && !isSubImage) |
| 914 | { |
| 915 | return gl::error(GL_INVALID_OPERATION, false); |
| 916 | } |
| 917 | |
| 918 | |
| 919 | // [OpenGL ES 2.0.24] table 3.9 |
| 920 | if (isSubImage) |
| 921 | { |
| 922 | switch (textureFormat) |
| 923 | { |
| 924 | case GL_ALPHA: |
| 925 | if (colorbufferFormat != GL_ALPHA8_EXT && |
| 926 | colorbufferFormat != GL_RGBA4 && |
| 927 | colorbufferFormat != GL_RGB5_A1 && |
| 928 | colorbufferFormat != GL_RGBA8_OES) |
| 929 | { |
| 930 | return gl::error(GL_INVALID_OPERATION, false); |
| 931 | } |
| 932 | break; |
| 933 | case GL_LUMINANCE: |
| 934 | case GL_RGB: |
| 935 | if (colorbufferFormat != GL_RGB565 && |
| 936 | colorbufferFormat != GL_RGB8_OES && |
| 937 | colorbufferFormat != GL_RGBA4 && |
| 938 | colorbufferFormat != GL_RGB5_A1 && |
| 939 | colorbufferFormat != GL_RGBA8_OES) |
| 940 | { |
| 941 | return gl::error(GL_INVALID_OPERATION, false); |
| 942 | } |
| 943 | break; |
| 944 | case GL_LUMINANCE_ALPHA: |
| 945 | case GL_RGBA: |
| 946 | if (colorbufferFormat != GL_RGBA4 && |
| 947 | colorbufferFormat != GL_RGB5_A1 && |
| 948 | colorbufferFormat != GL_RGBA8_OES) |
| 949 | { |
| 950 | return gl::error(GL_INVALID_OPERATION, false); |
| 951 | } |
| 952 | break; |
| 953 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 954 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 955 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 956 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 957 | return gl::error(GL_INVALID_OPERATION, false); |
| 958 | case GL_DEPTH_COMPONENT: |
| 959 | case GL_DEPTH_STENCIL_OES: |
| 960 | return gl::error(GL_INVALID_OPERATION, false); |
| 961 | default: |
| 962 | return gl::error(GL_INVALID_OPERATION, false); |
| 963 | } |
| 964 | } |
| 965 | else |
| 966 | { |
| 967 | switch (internalformat) |
| 968 | { |
| 969 | case GL_ALPHA: |
| 970 | if (colorbufferFormat != GL_ALPHA8_EXT && |
| 971 | colorbufferFormat != GL_RGBA4 && |
| 972 | colorbufferFormat != GL_RGB5_A1 && |
| 973 | colorbufferFormat != GL_BGRA8_EXT && |
| 974 | colorbufferFormat != GL_RGBA8_OES) |
| 975 | { |
| 976 | return gl::error(GL_INVALID_OPERATION, false); |
| 977 | } |
| 978 | break; |
| 979 | case GL_LUMINANCE: |
| 980 | case GL_RGB: |
| 981 | if (colorbufferFormat != GL_RGB565 && |
| 982 | colorbufferFormat != GL_RGB8_OES && |
| 983 | colorbufferFormat != GL_RGBA4 && |
| 984 | colorbufferFormat != GL_RGB5_A1 && |
| 985 | colorbufferFormat != GL_BGRA8_EXT && |
| 986 | colorbufferFormat != GL_RGBA8_OES) |
| 987 | { |
| 988 | return gl::error(GL_INVALID_OPERATION, false); |
| 989 | } |
| 990 | break; |
| 991 | case GL_LUMINANCE_ALPHA: |
| 992 | case GL_RGBA: |
| 993 | if (colorbufferFormat != GL_RGBA4 && |
| 994 | colorbufferFormat != GL_RGB5_A1 && |
| 995 | colorbufferFormat != GL_BGRA8_EXT && |
| 996 | colorbufferFormat != GL_RGBA8_OES) |
| 997 | { |
| 998 | return gl::error(GL_INVALID_OPERATION, false); |
| 999 | } |
| 1000 | break; |
| 1001 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 1002 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 1003 | if (context->supportsDXT1Textures()) |
| 1004 | { |
| 1005 | return gl::error(GL_INVALID_OPERATION, false); |
| 1006 | } |
| 1007 | else |
| 1008 | { |
| 1009 | return gl::error(GL_INVALID_ENUM, false); |
| 1010 | } |
| 1011 | break; |
| 1012 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 1013 | if (context->supportsDXT3Textures()) |
| 1014 | { |
| 1015 | return gl::error(GL_INVALID_OPERATION, false); |
| 1016 | } |
| 1017 | else |
| 1018 | { |
| 1019 | return gl::error(GL_INVALID_ENUM, false); |
| 1020 | } |
| 1021 | break; |
| 1022 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 1023 | if (context->supportsDXT5Textures()) |
| 1024 | { |
| 1025 | return gl::error(GL_INVALID_OPERATION, false); |
| 1026 | } |
| 1027 | else |
| 1028 | { |
| 1029 | return gl::error(GL_INVALID_ENUM, false); |
| 1030 | } |
| 1031 | break; |
| 1032 | case GL_DEPTH_COMPONENT: |
| 1033 | case GL_DEPTH_COMPONENT16: |
| 1034 | case GL_DEPTH_COMPONENT32_OES: |
| 1035 | case GL_DEPTH_STENCIL_OES: |
| 1036 | case GL_DEPTH24_STENCIL8_OES: |
| 1037 | if (context->supportsDepthTextures()) |
| 1038 | { |
| 1039 | return gl::error(GL_INVALID_OPERATION, false); |
| 1040 | } |
| 1041 | else |
| 1042 | { |
| 1043 | return gl::error(GL_INVALID_ENUM, false); |
| 1044 | } |
| 1045 | default: |
| 1046 | return gl::error(GL_INVALID_ENUM, false); |
| 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | return true; |
| 1051 | } |
| 1052 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 1053 | bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLint level, GLenum internalformat, |
| 1054 | bool isSubImage, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, |
| 1055 | GLsizei width, GLsizei height, GLint border) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1056 | { |
| 1057 | if (level < 0 || xoffset < 0 || yoffset < 0 || zoffset < 0 || width < 0 || height < 0) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 1058 | { |
| 1059 | return gl::error(GL_INVALID_VALUE, false); |
| 1060 | } |
| 1061 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1062 | if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height) |
| 1063 | { |
| 1064 | return gl::error(GL_INVALID_VALUE, false); |
| 1065 | } |
| 1066 | |
| 1067 | if (width == 0 || height == 0) |
| 1068 | { |
| 1069 | return false; |
| 1070 | } |
| 1071 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 1072 | if (border != 0) |
| 1073 | { |
| 1074 | return gl::error(GL_INVALID_VALUE, false); |
| 1075 | } |
| 1076 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1077 | if (level > context->getMaximumTextureLevel()) |
| 1078 | { |
| 1079 | return gl::error(GL_INVALID_VALUE, false); |
| 1080 | } |
| 1081 | |
| 1082 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 1083 | |
| 1084 | if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) |
| 1085 | { |
| 1086 | return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); |
| 1087 | } |
| 1088 | |
| 1089 | if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0) |
| 1090 | { |
| 1091 | return gl::error(GL_INVALID_OPERATION, false); |
| 1092 | } |
| 1093 | |
| 1094 | gl::Renderbuffer *source = framebuffer->getReadColorbuffer(); |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1095 | GLenum colorbufferInternalFormat = source->getInternalFormat(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1096 | gl::Texture *texture = NULL; |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1097 | GLenum textureInternalFormat = GL_NONE; |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1098 | bool textureCompressed = false; |
| 1099 | GLint textureLevelWidth = 0; |
| 1100 | GLint textureLevelHeight = 0; |
| 1101 | GLint textureLevelDepth = 0; |
| 1102 | switch (target) |
| 1103 | { |
| 1104 | case GL_TEXTURE_2D: |
| 1105 | { |
| 1106 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 1107 | if (texture2d) |
| 1108 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1109 | textureInternalFormat = texture2d->getInternalFormat(level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1110 | textureCompressed = texture2d->isCompressed(level); |
| 1111 | textureLevelWidth = texture2d->getWidth(level); |
| 1112 | textureLevelHeight = texture2d->getHeight(level); |
| 1113 | textureLevelDepth = 1; |
| 1114 | texture = texture2d; |
| 1115 | } |
| 1116 | } |
| 1117 | break; |
| 1118 | |
| 1119 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 1120 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 1121 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 1122 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 1123 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 1124 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 1125 | { |
| 1126 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 1127 | if (textureCube) |
| 1128 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1129 | textureInternalFormat = textureCube->getInternalFormat(target, level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1130 | textureCompressed = textureCube->isCompressed(target, level); |
| 1131 | textureLevelWidth = textureCube->getWidth(target, level); |
| 1132 | textureLevelHeight = textureCube->getHeight(target, level); |
| 1133 | textureLevelDepth = 1; |
| 1134 | texture = textureCube; |
| 1135 | } |
| 1136 | } |
| 1137 | break; |
| 1138 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1139 | case GL_TEXTURE_2D_ARRAY: |
| 1140 | { |
| 1141 | gl::Texture2DArray *texture2dArray = context->getTexture2DArray(); |
| 1142 | if (texture2dArray) |
| 1143 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1144 | textureInternalFormat = texture2dArray->getInternalFormat(level); |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1145 | textureCompressed = texture2dArray->isCompressed(level); |
| 1146 | textureLevelWidth = texture2dArray->getWidth(level); |
| 1147 | textureLevelHeight = texture2dArray->getHeight(level); |
| 1148 | textureLevelDepth = texture2dArray->getDepth(level); |
| 1149 | texture = texture2dArray; |
| 1150 | } |
| 1151 | } |
| 1152 | break; |
| 1153 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1154 | case GL_TEXTURE_3D: |
| 1155 | { |
| 1156 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 1157 | if (texture3d) |
| 1158 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1159 | textureInternalFormat = texture3d->getInternalFormat(level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1160 | textureCompressed = texture3d->isCompressed(level); |
| 1161 | textureLevelWidth = texture3d->getWidth(level); |
| 1162 | textureLevelHeight = texture3d->getHeight(level); |
| 1163 | textureLevelDepth = texture3d->getDepth(level); |
| 1164 | texture = texture3d; |
| 1165 | } |
| 1166 | } |
| 1167 | break; |
| 1168 | |
| 1169 | default: |
| 1170 | return gl::error(GL_INVALID_ENUM, false); |
| 1171 | } |
| 1172 | |
| 1173 | if (!texture) |
| 1174 | { |
| 1175 | return gl::error(GL_INVALID_OPERATION, false); |
| 1176 | } |
| 1177 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 1178 | if (texture->isImmutable() && !isSubImage) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1179 | { |
| 1180 | return gl::error(GL_INVALID_OPERATION, false); |
| 1181 | } |
| 1182 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 1183 | if (textureCompressed) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1184 | { |
| 1185 | if ((width % 4 != 0 && width != textureLevelWidth) || |
| 1186 | (height % 4 != 0 && height != textureLevelHeight)) |
| 1187 | { |
| 1188 | return gl::error(GL_INVALID_OPERATION, false); |
| 1189 | } |
| 1190 | } |
| 1191 | |
Geoff Lang | a4d1332 | 2013-06-05 14:57:51 -0400 | [diff] [blame^] | 1192 | if (isSubImage) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1193 | { |
Geoff Lang | a4d1332 | 2013-06-05 14:57:51 -0400 | [diff] [blame^] | 1194 | if (xoffset + width > textureLevelWidth || |
| 1195 | yoffset + height > textureLevelHeight || |
| 1196 | zoffset >= textureLevelDepth) |
| 1197 | { |
| 1198 | return gl::error(GL_INVALID_VALUE, false); |
| 1199 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1200 | |
Geoff Lang | a4d1332 | 2013-06-05 14:57:51 -0400 | [diff] [blame^] | 1201 | if (!gl::IsValidCopyTexImageCombination(textureInternalFormat, colorbufferInternalFormat, |
| 1202 | context->getClientVersion())) |
| 1203 | { |
| 1204 | return gl::error(GL_INVALID_OPERATION, false); |
| 1205 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1206 | } |
| 1207 | |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 1208 | return true; |
| 1209 | } |
| 1210 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 1211 | bool validateES2TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat, |
| 1212 | GLsizei width, GLsizei height) |
| 1213 | { |
| 1214 | if (target != GL_TEXTURE_2D && target != GL_TEXTURE_CUBE_MAP) |
| 1215 | { |
| 1216 | return gl::error(GL_INVALID_ENUM, false); |
| 1217 | } |
| 1218 | |
| 1219 | if (width < 1 || height < 1 || levels < 1) |
| 1220 | { |
| 1221 | return gl::error(GL_INVALID_VALUE, false); |
| 1222 | } |
| 1223 | |
| 1224 | if (target == GL_TEXTURE_CUBE_MAP && width != height) |
| 1225 | { |
| 1226 | return gl::error(GL_INVALID_VALUE, false); |
| 1227 | } |
| 1228 | |
| 1229 | if (levels != 1 && levels != gl::log2(std::max(width, height)) + 1) |
| 1230 | { |
| 1231 | return gl::error(GL_INVALID_OPERATION, false); |
| 1232 | } |
| 1233 | |
| 1234 | GLenum format = gl::GetFormat(internalformat, context->getClientVersion()); |
| 1235 | GLenum type = gl::GetType(internalformat, context->getClientVersion()); |
| 1236 | |
| 1237 | if (format == GL_NONE || type == GL_NONE) |
| 1238 | { |
| 1239 | return gl::error(GL_INVALID_ENUM, false); |
| 1240 | } |
| 1241 | |
| 1242 | switch (target) |
| 1243 | { |
| 1244 | case GL_TEXTURE_2D: |
| 1245 | if (width > context->getMaximum2DTextureDimension() || |
| 1246 | height > context->getMaximum2DTextureDimension()) |
| 1247 | { |
| 1248 | return gl::error(GL_INVALID_VALUE, false); |
| 1249 | } |
| 1250 | break; |
| 1251 | case GL_TEXTURE_CUBE_MAP: |
| 1252 | if (width > context->getMaximumCubeTextureDimension() || |
| 1253 | height > context->getMaximumCubeTextureDimension()) |
| 1254 | { |
| 1255 | return gl::error(GL_INVALID_VALUE, false); |
| 1256 | } |
| 1257 | break; |
| 1258 | default: |
| 1259 | return gl::error(GL_INVALID_ENUM, false); |
| 1260 | } |
| 1261 | |
| 1262 | if (levels != 1 && !context->supportsNonPower2Texture()) |
| 1263 | { |
| 1264 | if (!gl::isPow2(width) || !gl::isPow2(height)) |
| 1265 | { |
| 1266 | return gl::error(GL_INVALID_OPERATION, false); |
| 1267 | } |
| 1268 | } |
| 1269 | |
| 1270 | switch (internalformat) |
| 1271 | { |
| 1272 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 1273 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 1274 | if (!context->supportsDXT1Textures()) |
| 1275 | { |
| 1276 | return gl::error(GL_INVALID_ENUM, false); |
| 1277 | } |
| 1278 | break; |
| 1279 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 1280 | if (!context->supportsDXT3Textures()) |
| 1281 | { |
| 1282 | return gl::error(GL_INVALID_ENUM, false); |
| 1283 | } |
| 1284 | break; |
| 1285 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 1286 | if (!context->supportsDXT5Textures()) |
| 1287 | { |
| 1288 | return gl::error(GL_INVALID_ENUM, false); |
| 1289 | } |
| 1290 | break; |
| 1291 | case GL_RGBA32F_EXT: |
| 1292 | case GL_RGB32F_EXT: |
| 1293 | case GL_ALPHA32F_EXT: |
| 1294 | case GL_LUMINANCE32F_EXT: |
| 1295 | case GL_LUMINANCE_ALPHA32F_EXT: |
| 1296 | if (!context->supportsFloat32Textures()) |
| 1297 | { |
| 1298 | return gl::error(GL_INVALID_ENUM, false); |
| 1299 | } |
| 1300 | break; |
| 1301 | case GL_RGBA16F_EXT: |
| 1302 | case GL_RGB16F_EXT: |
| 1303 | case GL_ALPHA16F_EXT: |
| 1304 | case GL_LUMINANCE16F_EXT: |
| 1305 | case GL_LUMINANCE_ALPHA16F_EXT: |
| 1306 | if (!context->supportsFloat16Textures()) |
| 1307 | { |
| 1308 | return gl::error(GL_INVALID_ENUM, false); |
| 1309 | } |
| 1310 | break; |
| 1311 | case GL_DEPTH_COMPONENT16: |
| 1312 | case GL_DEPTH_COMPONENT32_OES: |
| 1313 | case GL_DEPTH24_STENCIL8_OES: |
| 1314 | if (!context->supportsDepthTextures()) |
| 1315 | { |
| 1316 | return gl::error(GL_INVALID_ENUM, false); |
| 1317 | } |
| 1318 | if (target != GL_TEXTURE_2D) |
| 1319 | { |
| 1320 | return gl::error(GL_INVALID_OPERATION, false); |
| 1321 | } |
| 1322 | // ANGLE_depth_texture only supports 1-level textures |
| 1323 | if (levels != 1) |
| 1324 | { |
| 1325 | return gl::error(GL_INVALID_OPERATION, false); |
| 1326 | } |
| 1327 | break; |
| 1328 | default: |
| 1329 | break; |
| 1330 | } |
| 1331 | |
| 1332 | gl::Texture *texture = NULL; |
| 1333 | switch(target) |
| 1334 | { |
| 1335 | case GL_TEXTURE_2D: |
| 1336 | texture = context->getTexture2D(); |
| 1337 | break; |
| 1338 | case GL_TEXTURE_CUBE_MAP: |
| 1339 | texture = context->getTextureCubeMap(); |
| 1340 | break; |
| 1341 | default: |
| 1342 | UNREACHABLE(); |
| 1343 | } |
| 1344 | |
| 1345 | if (!texture || texture->id() == 0) |
| 1346 | { |
| 1347 | return gl::error(GL_INVALID_OPERATION, false); |
| 1348 | } |
| 1349 | |
| 1350 | if (texture->isImmutable()) |
| 1351 | { |
| 1352 | return gl::error(GL_INVALID_OPERATION, false); |
| 1353 | } |
| 1354 | |
| 1355 | return true; |
| 1356 | } |
| 1357 | |
| 1358 | bool validateES3TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat, |
| 1359 | GLsizei width, GLsizei height, GLsizei depth) |
| 1360 | { |
| 1361 | if (width < 1 || height < 1 || depth < 1 || levels < 1) |
| 1362 | { |
| 1363 | return gl::error(GL_INVALID_VALUE, false); |
| 1364 | } |
| 1365 | |
| 1366 | if (levels > gl::log2(std::max(std::max(width, height), depth)) + 1) |
| 1367 | { |
| 1368 | return gl::error(GL_INVALID_OPERATION, false); |
| 1369 | } |
| 1370 | |
| 1371 | gl::Texture *texture = NULL; |
| 1372 | switch (target) |
| 1373 | { |
| 1374 | case GL_TEXTURE_2D: |
| 1375 | { |
| 1376 | texture = context->getTexture2D(); |
| 1377 | |
| 1378 | if (width > (context->getMaximum2DTextureDimension()) || |
| 1379 | height > (context->getMaximum2DTextureDimension())) |
| 1380 | { |
| 1381 | return gl::error(GL_INVALID_VALUE, false); |
| 1382 | } |
| 1383 | } |
| 1384 | break; |
| 1385 | |
| 1386 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 1387 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 1388 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 1389 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 1390 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 1391 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 1392 | { |
| 1393 | texture = context->getTextureCubeMap(); |
| 1394 | |
| 1395 | if (width != height) |
| 1396 | { |
| 1397 | return gl::error(GL_INVALID_VALUE, false); |
| 1398 | } |
| 1399 | |
| 1400 | if (width > (context->getMaximumCubeTextureDimension())) |
| 1401 | { |
| 1402 | return gl::error(GL_INVALID_VALUE, false); |
| 1403 | } |
| 1404 | } |
| 1405 | break; |
| 1406 | |
| 1407 | case GL_TEXTURE_3D: |
| 1408 | { |
| 1409 | texture = context->getTexture3D(); |
| 1410 | |
| 1411 | if (width > (context->getMaximum3DTextureDimension()) || |
| 1412 | height > (context->getMaximum3DTextureDimension()) || |
| 1413 | depth > (context->getMaximum3DTextureDimension())) |
| 1414 | { |
| 1415 | return gl::error(GL_INVALID_VALUE, false); |
| 1416 | } |
| 1417 | } |
| 1418 | break; |
| 1419 | |
| 1420 | case GL_TEXTURE_2D_ARRAY: |
| 1421 | { |
| 1422 | texture = context->getTexture2DArray(); |
| 1423 | |
| 1424 | if (width > (context->getMaximum2DTextureDimension()) || |
| 1425 | height > (context->getMaximum2DTextureDimension()) || |
| 1426 | depth > (context->getMaximum2DArrayTextureLayers())) |
| 1427 | { |
| 1428 | return gl::error(GL_INVALID_VALUE, false); |
| 1429 | } |
| 1430 | } |
| 1431 | break; |
| 1432 | |
| 1433 | default: |
| 1434 | return gl::error(GL_INVALID_ENUM, false); |
| 1435 | } |
| 1436 | |
| 1437 | if (!texture || texture->id() == 0) |
| 1438 | { |
| 1439 | return gl::error(GL_INVALID_OPERATION, false); |
| 1440 | } |
| 1441 | |
| 1442 | if (texture->isImmutable()) |
| 1443 | { |
| 1444 | return gl::error(GL_INVALID_OPERATION, false); |
| 1445 | } |
| 1446 | |
| 1447 | if (!gl::IsValidInternalFormat(internalformat, context)) |
| 1448 | { |
| 1449 | return gl::error(GL_INVALID_ENUM, false); |
| 1450 | } |
| 1451 | |
| 1452 | if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion())) |
| 1453 | { |
| 1454 | return gl::error(GL_INVALID_ENUM, false); |
| 1455 | } |
| 1456 | |
| 1457 | return true; |
| 1458 | } |
| 1459 | |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 1460 | bool validateRenderbufferStorageParameters(const gl::Context *context, GLenum target, GLsizei samples, |
| 1461 | GLenum internalformat, GLsizei width, GLsizei height, |
| 1462 | bool angleExtension) |
| 1463 | { |
| 1464 | switch (target) |
| 1465 | { |
| 1466 | case GL_RENDERBUFFER: |
| 1467 | break; |
| 1468 | default: |
| 1469 | return gl::error(GL_INVALID_ENUM, false); |
| 1470 | } |
| 1471 | |
| 1472 | if (width < 0 || height < 0 || samples < 0) |
| 1473 | { |
| 1474 | return gl::error(GL_INVALID_VALUE, false); |
| 1475 | } |
| 1476 | |
| 1477 | if (!gl::IsValidInternalFormat(internalformat, context)) |
| 1478 | { |
| 1479 | return gl::error(GL_INVALID_ENUM, false); |
| 1480 | } |
| 1481 | |
| 1482 | // ANGLE_framebuffer_multisample does not explicitly state that the internal format must be |
| 1483 | // sized but it does state that the format must be in the ES2.0 spec table 4.5 which contains |
| 1484 | // only sized internal formats. The ES3 spec (section 4.4.2) does, however, state that the |
| 1485 | // internal format must be sized and not an integer format if samples is greater than zero. |
| 1486 | if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion())) |
| 1487 | { |
| 1488 | return gl::error(GL_INVALID_ENUM, false); |
| 1489 | } |
| 1490 | |
| 1491 | if (gl::IsIntegerFormat(internalformat, context->getClientVersion()) && samples > 0) |
| 1492 | { |
| 1493 | return gl::error(GL_INVALID_OPERATION, false); |
| 1494 | } |
| 1495 | |
| 1496 | if (!gl::IsColorRenderingSupported(internalformat, context) && |
| 1497 | !gl::IsDepthRenderingSupported(internalformat, context) && |
| 1498 | !gl::IsStencilRenderingSupported(internalformat, context)) |
| 1499 | { |
| 1500 | return gl::error(GL_INVALID_ENUM, false); |
| 1501 | } |
| 1502 | |
| 1503 | if (std::max(width, height) > context->getMaximumRenderbufferDimension()) |
| 1504 | { |
| 1505 | return gl::error(GL_INVALID_VALUE, false); |
| 1506 | } |
| 1507 | |
| 1508 | // ANGLE_framebuffer_multisample states that the value of samples must be less than or equal |
| 1509 | // to MAX_SAMPLES_ANGLE (Context::getMaxSupportedSamples) while the ES3.0 spec (section 4.4.2) |
| 1510 | // states that samples must be less than or equal to the maximum samples for the specified |
| 1511 | // internal format. |
| 1512 | if (angleExtension) |
| 1513 | { |
| 1514 | if (samples > context->getMaxSupportedSamples()) |
| 1515 | { |
| 1516 | return gl::error(GL_INVALID_VALUE, false); |
| 1517 | } |
| 1518 | } |
| 1519 | else |
| 1520 | { |
| 1521 | if (samples > context->getMaxSupportedFormatSamples(internalformat)) |
| 1522 | { |
| 1523 | return gl::error(GL_INVALID_VALUE, false); |
| 1524 | } |
| 1525 | } |
| 1526 | |
| 1527 | GLuint handle = context->getRenderbufferHandle(); |
| 1528 | if (handle == 0) |
| 1529 | { |
| 1530 | return gl::error(GL_INVALID_OPERATION, false); |
| 1531 | } |
| 1532 | |
| 1533 | return true; |
| 1534 | } |
| 1535 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1536 | // check for combinations of format and type that are valid for ReadPixels |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 1537 | bool validES2ReadFormatType(GLenum format, GLenum type) |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1538 | { |
| 1539 | switch (format) |
| 1540 | { |
| 1541 | case GL_RGBA: |
| 1542 | switch (type) |
| 1543 | { |
| 1544 | case GL_UNSIGNED_BYTE: |
| 1545 | break; |
| 1546 | default: |
| 1547 | return false; |
| 1548 | } |
| 1549 | break; |
| 1550 | case GL_BGRA_EXT: |
| 1551 | switch (type) |
| 1552 | { |
| 1553 | case GL_UNSIGNED_BYTE: |
| 1554 | case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: |
| 1555 | case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: |
| 1556 | break; |
| 1557 | default: |
| 1558 | return false; |
| 1559 | } |
| 1560 | break; |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1561 | default: |
| 1562 | return false; |
| 1563 | } |
| 1564 | return true; |
| 1565 | } |
| 1566 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 1567 | bool validES3ReadFormatType(GLenum internalFormat, GLenum format, GLenum type) |
| 1568 | { |
| 1569 | switch (format) |
| 1570 | { |
| 1571 | case GL_RGBA: |
| 1572 | switch (type) |
| 1573 | { |
| 1574 | case GL_UNSIGNED_BYTE: |
| 1575 | break; |
| 1576 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 1577 | if (internalFormat != GL_RGB10_A2) |
| 1578 | { |
| 1579 | return false; |
| 1580 | } |
| 1581 | break; |
| 1582 | default: |
| 1583 | return false; |
| 1584 | } |
| 1585 | break; |
| 1586 | case GL_RGBA_INTEGER: |
| 1587 | switch (type) |
| 1588 | { |
| 1589 | case GL_INT: |
| 1590 | case GL_UNSIGNED_INT: |
| 1591 | break; |
| 1592 | default: |
| 1593 | return false; |
| 1594 | } |
| 1595 | break; |
| 1596 | case GL_BGRA_EXT: |
| 1597 | switch (type) |
| 1598 | { |
| 1599 | case GL_UNSIGNED_BYTE: |
| 1600 | case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: |
| 1601 | case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: |
| 1602 | break; |
| 1603 | default: |
| 1604 | return false; |
| 1605 | } |
| 1606 | break; |
| 1607 | default: |
| 1608 | return false; |
| 1609 | } |
| 1610 | return true; |
| 1611 | } |
| 1612 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 1613 | bool validateInvalidateFramebufferParameters(gl::Context *context, GLenum target, GLsizei numAttachments, |
| 1614 | const GLenum* attachments) |
| 1615 | { |
| 1616 | bool defaultFramebuffer = false; |
| 1617 | |
| 1618 | switch (target) |
| 1619 | { |
| 1620 | case GL_DRAW_FRAMEBUFFER: |
| 1621 | case GL_FRAMEBUFFER: |
| 1622 | defaultFramebuffer = context->getDrawFramebufferHandle() == 0; |
| 1623 | break; |
| 1624 | case GL_READ_FRAMEBUFFER: |
| 1625 | defaultFramebuffer = context->getReadFramebufferHandle() == 0; |
| 1626 | break; |
| 1627 | default: |
| 1628 | return gl::error(GL_INVALID_ENUM, false); |
| 1629 | } |
| 1630 | |
| 1631 | for (int i = 0; i < numAttachments; ++i) |
| 1632 | { |
| 1633 | if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15) |
| 1634 | { |
| 1635 | if (defaultFramebuffer) |
| 1636 | { |
| 1637 | return gl::error(GL_INVALID_ENUM, false); |
| 1638 | } |
| 1639 | |
| 1640 | if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getMaximumRenderTargets()) |
| 1641 | { |
| 1642 | return gl::error(GL_INVALID_OPERATION, false); |
| 1643 | } |
| 1644 | } |
| 1645 | else |
| 1646 | { |
| 1647 | switch (attachments[i]) |
| 1648 | { |
| 1649 | case GL_DEPTH_ATTACHMENT: |
| 1650 | case GL_STENCIL_ATTACHMENT: |
| 1651 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 1652 | if (defaultFramebuffer) |
| 1653 | { |
| 1654 | return gl::error(GL_INVALID_ENUM, false); |
| 1655 | } |
| 1656 | break; |
| 1657 | case GL_COLOR: |
| 1658 | case GL_DEPTH: |
| 1659 | case GL_STENCIL: |
| 1660 | if (!defaultFramebuffer) |
| 1661 | { |
| 1662 | return gl::error(GL_INVALID_ENUM, false); |
| 1663 | } |
| 1664 | break; |
| 1665 | default: |
| 1666 | return gl::error(GL_INVALID_ENUM, false); |
| 1667 | } |
| 1668 | } |
| 1669 | } |
| 1670 | |
| 1671 | return true; |
| 1672 | } |
| 1673 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1674 | extern "C" |
| 1675 | { |
| 1676 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 1677 | // OpenGL ES 2.0 functions |
| 1678 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1679 | void __stdcall glActiveTexture(GLenum texture) |
| 1680 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1681 | EVENT("(GLenum texture = 0x%X)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1682 | |
| 1683 | try |
| 1684 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1685 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1686 | |
| 1687 | if (context) |
| 1688 | { |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 1689 | if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1) |
| 1690 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1691 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 1692 | } |
| 1693 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 1694 | context->setActiveSampler(texture - GL_TEXTURE0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1695 | } |
| 1696 | } |
| 1697 | catch(std::bad_alloc&) |
| 1698 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1699 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1700 | } |
| 1701 | } |
| 1702 | |
| 1703 | void __stdcall glAttachShader(GLuint program, GLuint shader) |
| 1704 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1705 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1706 | |
| 1707 | try |
| 1708 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1709 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1710 | |
| 1711 | if (context) |
| 1712 | { |
| 1713 | gl::Program *programObject = context->getProgram(program); |
| 1714 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 1715 | |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1716 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1717 | { |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1718 | if (context->getShader(program)) |
| 1719 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1720 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1721 | } |
| 1722 | else |
| 1723 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1724 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1725 | } |
| 1726 | } |
| 1727 | |
| 1728 | if (!shaderObject) |
| 1729 | { |
| 1730 | if (context->getProgram(shader)) |
| 1731 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1732 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1733 | } |
| 1734 | else |
| 1735 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1736 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1737 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1738 | } |
| 1739 | |
| 1740 | if (!programObject->attachShader(shaderObject)) |
| 1741 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1742 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1743 | } |
| 1744 | } |
| 1745 | } |
| 1746 | catch(std::bad_alloc&) |
| 1747 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1748 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1749 | } |
| 1750 | } |
| 1751 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1752 | void __stdcall glBeginQueryEXT(GLenum target, GLuint id) |
| 1753 | { |
| 1754 | EVENT("(GLenum target = 0x%X, GLuint %d)", target, id); |
| 1755 | |
| 1756 | try |
| 1757 | { |
| 1758 | switch (target) |
| 1759 | { |
| 1760 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 1761 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 1762 | break; |
| 1763 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1764 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1765 | } |
| 1766 | |
| 1767 | if (id == 0) |
| 1768 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1769 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1770 | } |
| 1771 | |
| 1772 | gl::Context *context = gl::getNonLostContext(); |
| 1773 | |
| 1774 | if (context) |
| 1775 | { |
| 1776 | context->beginQuery(target, id); |
| 1777 | } |
| 1778 | } |
| 1779 | catch(std::bad_alloc&) |
| 1780 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1781 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1782 | } |
| 1783 | } |
| 1784 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 1785 | void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1786 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1787 | 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] | 1788 | |
| 1789 | try |
| 1790 | { |
| 1791 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 1792 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1793 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1794 | } |
| 1795 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1796 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1797 | |
| 1798 | if (context) |
| 1799 | { |
| 1800 | gl::Program *programObject = context->getProgram(program); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 1801 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1802 | if (!programObject) |
| 1803 | { |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 1804 | if (context->getShader(program)) |
| 1805 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1806 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 1807 | } |
| 1808 | else |
| 1809 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1810 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 1811 | } |
| 1812 | } |
| 1813 | |
| 1814 | if (strncmp(name, "gl_", 3) == 0) |
| 1815 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1816 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1817 | } |
| 1818 | |
| 1819 | programObject->bindAttributeLocation(index, name); |
| 1820 | } |
| 1821 | } |
| 1822 | catch(std::bad_alloc&) |
| 1823 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1824 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1825 | } |
| 1826 | } |
| 1827 | |
| 1828 | void __stdcall glBindBuffer(GLenum target, GLuint buffer) |
| 1829 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1830 | EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1831 | |
| 1832 | try |
| 1833 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1834 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1835 | |
| 1836 | if (context) |
| 1837 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1838 | // Check ES3 specific targets |
| 1839 | switch (target) |
| 1840 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 1841 | case GL_COPY_READ_BUFFER: |
| 1842 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1843 | case GL_PIXEL_PACK_BUFFER: |
| 1844 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1845 | case GL_UNIFORM_BUFFER: |
| 1846 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 1847 | if (context->getClientVersion() < 3) |
| 1848 | { |
| 1849 | return gl::error(GL_INVALID_ENUM); |
| 1850 | } |
| 1851 | } |
| 1852 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1853 | switch (target) |
| 1854 | { |
| 1855 | case GL_ARRAY_BUFFER: |
| 1856 | context->bindArrayBuffer(buffer); |
| 1857 | return; |
| 1858 | case GL_ELEMENT_ARRAY_BUFFER: |
| 1859 | context->bindElementArrayBuffer(buffer); |
| 1860 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 1861 | case GL_COPY_READ_BUFFER: |
| 1862 | context->bindCopyReadBuffer(buffer); |
| 1863 | return; |
| 1864 | case GL_COPY_WRITE_BUFFER: |
| 1865 | context->bindCopyWriteBuffer(buffer); |
| 1866 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1867 | case GL_PIXEL_PACK_BUFFER: |
| 1868 | context->bindPixelPackBuffer(buffer); |
| 1869 | return; |
| 1870 | case GL_PIXEL_UNPACK_BUFFER: |
| 1871 | context->bindPixelUnpackBuffer(buffer); |
| 1872 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1873 | case GL_UNIFORM_BUFFER: |
| 1874 | context->bindGenericUniformBuffer(buffer); |
| 1875 | return; |
| 1876 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 7a1ebad | 2013-05-30 00:05:20 +0000 | [diff] [blame] | 1877 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1878 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1879 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1880 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1881 | } |
| 1882 | } |
| 1883 | } |
| 1884 | catch(std::bad_alloc&) |
| 1885 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1886 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1887 | } |
| 1888 | } |
| 1889 | |
| 1890 | void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer) |
| 1891 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1892 | EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1893 | |
| 1894 | try |
| 1895 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 1896 | 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] | 1897 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1898 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1899 | } |
| 1900 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1901 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1902 | |
| 1903 | if (context) |
| 1904 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 1905 | if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 1906 | { |
| 1907 | context->bindReadFramebuffer(framebuffer); |
| 1908 | } |
| 1909 | |
| 1910 | if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 1911 | { |
| 1912 | context->bindDrawFramebuffer(framebuffer); |
| 1913 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1914 | } |
| 1915 | } |
| 1916 | catch(std::bad_alloc&) |
| 1917 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1918 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1919 | } |
| 1920 | } |
| 1921 | |
| 1922 | void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 1923 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1924 | EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1925 | |
| 1926 | try |
| 1927 | { |
| 1928 | if (target != GL_RENDERBUFFER) |
| 1929 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1930 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1931 | } |
| 1932 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1933 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1934 | |
| 1935 | if (context) |
| 1936 | { |
| 1937 | context->bindRenderbuffer(renderbuffer); |
| 1938 | } |
| 1939 | } |
| 1940 | catch(std::bad_alloc&) |
| 1941 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1942 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1943 | } |
| 1944 | } |
| 1945 | |
| 1946 | void __stdcall glBindTexture(GLenum target, GLuint texture) |
| 1947 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1948 | EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1949 | |
| 1950 | try |
| 1951 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1952 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1953 | |
| 1954 | if (context) |
| 1955 | { |
| 1956 | gl::Texture *textureObject = context->getTexture(texture); |
| 1957 | |
| 1958 | if (textureObject && textureObject->getTarget() != target && texture != 0) |
| 1959 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1960 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1961 | } |
| 1962 | |
| 1963 | switch (target) |
| 1964 | { |
| 1965 | case GL_TEXTURE_2D: |
| 1966 | context->bindTexture2D(texture); |
| 1967 | return; |
| 1968 | case GL_TEXTURE_CUBE_MAP: |
| 1969 | context->bindTextureCubeMap(texture); |
| 1970 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 1971 | case GL_TEXTURE_3D: |
| 1972 | if (context->getClientVersion() < 3) |
| 1973 | { |
| 1974 | return gl::error(GL_INVALID_ENUM); |
| 1975 | } |
| 1976 | context->bindTexture3D(texture); |
| 1977 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 1978 | case GL_TEXTURE_2D_ARRAY: |
| 1979 | if (context->getClientVersion() < 3) |
| 1980 | { |
| 1981 | return gl::error(GL_INVALID_ENUM); |
| 1982 | } |
| 1983 | context->bindTexture2DArray(texture); |
| 1984 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1985 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1986 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1987 | } |
| 1988 | } |
| 1989 | } |
| 1990 | catch(std::bad_alloc&) |
| 1991 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1992 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1993 | } |
| 1994 | } |
| 1995 | |
| 1996 | void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 1997 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1998 | 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] | 1999 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2000 | |
| 2001 | try |
| 2002 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2003 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2004 | |
| 2005 | if (context) |
| 2006 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2007 | 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] | 2008 | } |
| 2009 | } |
| 2010 | catch(std::bad_alloc&) |
| 2011 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2012 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2013 | } |
| 2014 | } |
| 2015 | |
| 2016 | void __stdcall glBlendEquation(GLenum mode) |
| 2017 | { |
| 2018 | glBlendEquationSeparate(mode, mode); |
| 2019 | } |
| 2020 | |
| 2021 | void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 2022 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2023 | EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2024 | |
| 2025 | try |
| 2026 | { |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2027 | gl::Context *context = gl::getNonLostContext(); |
| 2028 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2029 | switch (modeRGB) |
| 2030 | { |
| 2031 | case GL_FUNC_ADD: |
| 2032 | case GL_FUNC_SUBTRACT: |
| 2033 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2034 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2035 | |
| 2036 | case GL_MIN: |
| 2037 | case GL_MAX: |
| 2038 | if (context && context->getClientVersion() < 3) |
| 2039 | { |
| 2040 | return gl::error(GL_INVALID_ENUM); |
| 2041 | } |
| 2042 | break; |
| 2043 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2044 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2045 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2046 | } |
| 2047 | |
| 2048 | switch (modeAlpha) |
| 2049 | { |
| 2050 | case GL_FUNC_ADD: |
| 2051 | case GL_FUNC_SUBTRACT: |
| 2052 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2053 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2054 | |
| 2055 | case GL_MIN: |
| 2056 | case GL_MAX: |
| 2057 | if (context && context->getClientVersion() < 3) |
| 2058 | { |
| 2059 | return gl::error(GL_INVALID_ENUM); |
| 2060 | } |
| 2061 | break; |
| 2062 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2063 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2064 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2065 | } |
| 2066 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2067 | if (context) |
| 2068 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2069 | context->setBlendEquation(modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2070 | } |
| 2071 | } |
| 2072 | catch(std::bad_alloc&) |
| 2073 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2074 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2075 | } |
| 2076 | } |
| 2077 | |
| 2078 | void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor) |
| 2079 | { |
| 2080 | glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor); |
| 2081 | } |
| 2082 | |
| 2083 | void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 2084 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2085 | 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] | 2086 | srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2087 | |
| 2088 | try |
| 2089 | { |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2090 | gl::Context *context = gl::getNonLostContext(); |
| 2091 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2092 | switch (srcRGB) |
| 2093 | { |
| 2094 | case GL_ZERO: |
| 2095 | case GL_ONE: |
| 2096 | case GL_SRC_COLOR: |
| 2097 | case GL_ONE_MINUS_SRC_COLOR: |
| 2098 | case GL_DST_COLOR: |
| 2099 | case GL_ONE_MINUS_DST_COLOR: |
| 2100 | case GL_SRC_ALPHA: |
| 2101 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2102 | case GL_DST_ALPHA: |
| 2103 | case GL_ONE_MINUS_DST_ALPHA: |
| 2104 | case GL_CONSTANT_COLOR: |
| 2105 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2106 | case GL_CONSTANT_ALPHA: |
| 2107 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2108 | case GL_SRC_ALPHA_SATURATE: |
| 2109 | break; |
| 2110 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2111 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2112 | } |
| 2113 | |
| 2114 | switch (dstRGB) |
| 2115 | { |
| 2116 | case GL_ZERO: |
| 2117 | case GL_ONE: |
| 2118 | case GL_SRC_COLOR: |
| 2119 | case GL_ONE_MINUS_SRC_COLOR: |
| 2120 | case GL_DST_COLOR: |
| 2121 | case GL_ONE_MINUS_DST_COLOR: |
| 2122 | case GL_SRC_ALPHA: |
| 2123 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2124 | case GL_DST_ALPHA: |
| 2125 | case GL_ONE_MINUS_DST_ALPHA: |
| 2126 | case GL_CONSTANT_COLOR: |
| 2127 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2128 | case GL_CONSTANT_ALPHA: |
| 2129 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2130 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2131 | |
| 2132 | case GL_SRC_ALPHA_SATURATE: |
| 2133 | if (!context || context->getClientVersion() < 3) |
| 2134 | { |
| 2135 | return gl::error(GL_INVALID_ENUM); |
| 2136 | } |
| 2137 | break; |
| 2138 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2139 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2140 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2141 | } |
| 2142 | |
| 2143 | switch (srcAlpha) |
| 2144 | { |
| 2145 | case GL_ZERO: |
| 2146 | case GL_ONE: |
| 2147 | case GL_SRC_COLOR: |
| 2148 | case GL_ONE_MINUS_SRC_COLOR: |
| 2149 | case GL_DST_COLOR: |
| 2150 | case GL_ONE_MINUS_DST_COLOR: |
| 2151 | case GL_SRC_ALPHA: |
| 2152 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2153 | case GL_DST_ALPHA: |
| 2154 | case GL_ONE_MINUS_DST_ALPHA: |
| 2155 | case GL_CONSTANT_COLOR: |
| 2156 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2157 | case GL_CONSTANT_ALPHA: |
| 2158 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2159 | case GL_SRC_ALPHA_SATURATE: |
| 2160 | break; |
| 2161 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2162 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2163 | } |
| 2164 | |
| 2165 | switch (dstAlpha) |
| 2166 | { |
| 2167 | case GL_ZERO: |
| 2168 | case GL_ONE: |
| 2169 | case GL_SRC_COLOR: |
| 2170 | case GL_ONE_MINUS_SRC_COLOR: |
| 2171 | case GL_DST_COLOR: |
| 2172 | case GL_ONE_MINUS_DST_COLOR: |
| 2173 | case GL_SRC_ALPHA: |
| 2174 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2175 | case GL_DST_ALPHA: |
| 2176 | case GL_ONE_MINUS_DST_ALPHA: |
| 2177 | case GL_CONSTANT_COLOR: |
| 2178 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2179 | case GL_CONSTANT_ALPHA: |
| 2180 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2181 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2182 | |
| 2183 | case GL_SRC_ALPHA_SATURATE: |
| 2184 | if (!context || context->getClientVersion() < 3) |
| 2185 | { |
| 2186 | return gl::error(GL_INVALID_ENUM); |
| 2187 | } |
| 2188 | break; |
| 2189 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2190 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2191 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2192 | } |
| 2193 | |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2194 | bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR || |
| 2195 | dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR); |
| 2196 | |
| 2197 | bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA || |
| 2198 | dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA); |
| 2199 | |
| 2200 | if (constantColorUsed && constantAlphaUsed) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2201 | { |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2202 | 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] | 2203 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2204 | } |
| 2205 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2206 | if (context) |
| 2207 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2208 | context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2209 | } |
| 2210 | } |
| 2211 | catch(std::bad_alloc&) |
| 2212 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2213 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2214 | } |
| 2215 | } |
| 2216 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2217 | 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] | 2218 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2219 | 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] | 2220 | target, size, data, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2221 | |
| 2222 | try |
| 2223 | { |
| 2224 | if (size < 0) |
| 2225 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2226 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2227 | } |
| 2228 | |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2229 | gl::Context *context = gl::getNonLostContext(); |
| 2230 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2231 | switch (usage) |
| 2232 | { |
| 2233 | case GL_STREAM_DRAW: |
| 2234 | case GL_STATIC_DRAW: |
| 2235 | case GL_DYNAMIC_DRAW: |
| 2236 | break; |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2237 | |
| 2238 | case GL_STREAM_READ: |
| 2239 | case GL_STREAM_COPY: |
| 2240 | case GL_STATIC_READ: |
| 2241 | case GL_STATIC_COPY: |
| 2242 | case GL_DYNAMIC_READ: |
| 2243 | case GL_DYNAMIC_COPY: |
| 2244 | if (context && context->getClientVersion() < 3) |
| 2245 | { |
| 2246 | return gl::error(GL_INVALID_ENUM); |
| 2247 | } |
| 2248 | break; |
| 2249 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2250 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2251 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2252 | } |
| 2253 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2254 | if (context) |
| 2255 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2256 | // Check ES3 specific targets |
| 2257 | switch (target) |
| 2258 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2259 | case GL_COPY_READ_BUFFER: |
| 2260 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2261 | case GL_PIXEL_PACK_BUFFER: |
| 2262 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2263 | case GL_UNIFORM_BUFFER: |
| 2264 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2265 | if (context->getClientVersion() < 3) |
| 2266 | { |
| 2267 | return gl::error(GL_INVALID_ENUM); |
| 2268 | } |
| 2269 | } |
| 2270 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2271 | gl::Buffer *buffer; |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2272 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2273 | switch (target) |
| 2274 | { |
| 2275 | case GL_ARRAY_BUFFER: |
| 2276 | buffer = context->getArrayBuffer(); |
| 2277 | break; |
| 2278 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2279 | buffer = context->getElementArrayBuffer(); |
| 2280 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2281 | case GL_COPY_READ_BUFFER: |
| 2282 | buffer = context->getCopyReadBuffer(); |
| 2283 | break; |
| 2284 | case GL_COPY_WRITE_BUFFER: |
| 2285 | buffer = context->getCopyWriteBuffer(); |
| 2286 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2287 | case GL_PIXEL_PACK_BUFFER: |
| 2288 | buffer = context->getPixelPackBuffer(); |
| 2289 | break; |
| 2290 | case GL_PIXEL_UNPACK_BUFFER: |
| 2291 | buffer = context->getPixelUnpackBuffer(); |
| 2292 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2293 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2294 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2295 | break; |
| 2296 | case GL_UNIFORM_BUFFER: |
| 2297 | buffer = context->getGenericUniformBuffer(); |
| 2298 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2299 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2300 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2301 | } |
| 2302 | |
| 2303 | if (!buffer) |
| 2304 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2305 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2306 | } |
| 2307 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2308 | buffer->bufferData(data, size, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2309 | } |
| 2310 | } |
| 2311 | catch(std::bad_alloc&) |
| 2312 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2313 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2314 | } |
| 2315 | } |
| 2316 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2317 | 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] | 2318 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2319 | 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] | 2320 | target, offset, size, data); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2321 | |
| 2322 | try |
| 2323 | { |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2324 | if (size < 0 || offset < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 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 | d4620a3 | 2010-03-21 04:31:28 +0000 | [diff] [blame] | 2329 | if (data == NULL) |
| 2330 | { |
| 2331 | return; |
| 2332 | } |
| 2333 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2334 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2335 | |
| 2336 | if (context) |
| 2337 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2338 | // Check ES3 specific targets |
| 2339 | switch (target) |
| 2340 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2341 | case GL_COPY_READ_BUFFER: |
| 2342 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2343 | case GL_PIXEL_PACK_BUFFER: |
| 2344 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2345 | case GL_UNIFORM_BUFFER: |
| 2346 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2347 | if (context->getClientVersion() < 3) |
| 2348 | { |
| 2349 | return gl::error(GL_INVALID_ENUM); |
| 2350 | } |
| 2351 | } |
| 2352 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2353 | gl::Buffer *buffer; |
| 2354 | |
| 2355 | switch (target) |
| 2356 | { |
| 2357 | case GL_ARRAY_BUFFER: |
| 2358 | buffer = context->getArrayBuffer(); |
| 2359 | break; |
| 2360 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2361 | buffer = context->getElementArrayBuffer(); |
| 2362 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2363 | case GL_COPY_READ_BUFFER: |
| 2364 | buffer = context->getCopyReadBuffer(); |
| 2365 | break; |
| 2366 | case GL_COPY_WRITE_BUFFER: |
| 2367 | buffer = context->getCopyWriteBuffer(); |
| 2368 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2369 | case GL_PIXEL_PACK_BUFFER: |
| 2370 | buffer = context->getPixelPackBuffer(); |
| 2371 | break; |
| 2372 | case GL_PIXEL_UNPACK_BUFFER: |
| 2373 | buffer = context->getPixelUnpackBuffer(); |
| 2374 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2375 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2376 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2377 | break; |
| 2378 | case GL_UNIFORM_BUFFER: |
| 2379 | buffer = context->getGenericUniformBuffer(); |
| 2380 | break; |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2381 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2382 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2383 | } |
| 2384 | |
| 2385 | if (!buffer) |
| 2386 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2387 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2388 | } |
| 2389 | |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2390 | if ((size_t)size + offset > buffer->size()) |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2391 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2392 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2393 | } |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2394 | |
| 2395 | buffer->bufferSubData(data, size, offset); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2396 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2397 | } |
| 2398 | catch(std::bad_alloc&) |
| 2399 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2400 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2401 | } |
| 2402 | } |
| 2403 | |
| 2404 | GLenum __stdcall glCheckFramebufferStatus(GLenum target) |
| 2405 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2406 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2407 | |
| 2408 | try |
| 2409 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2410 | 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] | 2411 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2412 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2413 | } |
| 2414 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2415 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2416 | |
| 2417 | if (context) |
| 2418 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2419 | gl::Framebuffer *framebuffer = NULL; |
| 2420 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 2421 | { |
| 2422 | framebuffer = context->getReadFramebuffer(); |
| 2423 | } |
| 2424 | else |
| 2425 | { |
| 2426 | framebuffer = context->getDrawFramebuffer(); |
| 2427 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2428 | |
| 2429 | return framebuffer->completeness(); |
| 2430 | } |
| 2431 | } |
| 2432 | catch(std::bad_alloc&) |
| 2433 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2434 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2435 | } |
| 2436 | |
| 2437 | return 0; |
| 2438 | } |
| 2439 | |
| 2440 | void __stdcall glClear(GLbitfield mask) |
| 2441 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2442 | EVENT("(GLbitfield mask = 0x%X)", mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2443 | |
| 2444 | try |
| 2445 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2446 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2447 | |
| 2448 | if (context) |
| 2449 | { |
| 2450 | context->clear(mask); |
| 2451 | } |
| 2452 | } |
| 2453 | catch(std::bad_alloc&) |
| 2454 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2455 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2456 | } |
| 2457 | } |
| 2458 | |
| 2459 | void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2460 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2461 | 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] | 2462 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2463 | |
| 2464 | try |
| 2465 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2466 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2467 | |
| 2468 | if (context) |
| 2469 | { |
| 2470 | context->setClearColor(red, green, blue, alpha); |
| 2471 | } |
| 2472 | } |
| 2473 | catch(std::bad_alloc&) |
| 2474 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2475 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2476 | } |
| 2477 | } |
| 2478 | |
| 2479 | void __stdcall glClearDepthf(GLclampf depth) |
| 2480 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2481 | EVENT("(GLclampf depth = %f)", depth); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2482 | |
| 2483 | try |
| 2484 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2485 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2486 | |
| 2487 | if (context) |
| 2488 | { |
| 2489 | context->setClearDepth(depth); |
| 2490 | } |
| 2491 | } |
| 2492 | catch(std::bad_alloc&) |
| 2493 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2494 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2495 | } |
| 2496 | } |
| 2497 | |
| 2498 | void __stdcall glClearStencil(GLint s) |
| 2499 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2500 | EVENT("(GLint s = %d)", s); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2501 | |
| 2502 | try |
| 2503 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2504 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2505 | |
| 2506 | if (context) |
| 2507 | { |
| 2508 | context->setClearStencil(s); |
| 2509 | } |
| 2510 | } |
| 2511 | catch(std::bad_alloc&) |
| 2512 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2513 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2514 | } |
| 2515 | } |
| 2516 | |
| 2517 | void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 2518 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2519 | 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] | 2520 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2521 | |
| 2522 | try |
| 2523 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2524 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2525 | |
| 2526 | if (context) |
| 2527 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 2528 | 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] | 2529 | } |
| 2530 | } |
| 2531 | catch(std::bad_alloc&) |
| 2532 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2533 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2534 | } |
| 2535 | } |
| 2536 | |
| 2537 | void __stdcall glCompileShader(GLuint shader) |
| 2538 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2539 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2540 | |
| 2541 | try |
| 2542 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2543 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2544 | |
| 2545 | if (context) |
| 2546 | { |
| 2547 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2548 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2549 | if (!shaderObject) |
| 2550 | { |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2551 | if (context->getProgram(shader)) |
| 2552 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2553 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2554 | } |
| 2555 | else |
| 2556 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2557 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2558 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2559 | } |
| 2560 | |
| 2561 | shaderObject->compile(); |
| 2562 | } |
| 2563 | } |
| 2564 | catch(std::bad_alloc&) |
| 2565 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2566 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2567 | } |
| 2568 | } |
| 2569 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2570 | void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, |
| 2571 | GLint border, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2572 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2573 | 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] | 2574 | "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] | 2575 | target, level, internalformat, width, height, border, imageSize, data); |
| 2576 | |
| 2577 | try |
| 2578 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2579 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2580 | |
| 2581 | if (context) |
| 2582 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2583 | if (context->getClientVersion() < 3 && |
| 2584 | !validateES2TexImageParameters(context, target, level, internalformat, true, false, |
| 2585 | 0, 0, width, height, 0, GL_NONE, GL_NONE, data)) |
| 2586 | { |
| 2587 | return; |
| 2588 | } |
| 2589 | |
| 2590 | if (context->getClientVersion() >= 3 && |
| 2591 | !validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 2592 | 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 2593 | { |
| 2594 | return; |
| 2595 | } |
| 2596 | |
| 2597 | if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2598 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2599 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2600 | } |
| 2601 | |
| 2602 | switch (target) |
| 2603 | { |
| 2604 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2605 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2606 | gl::Texture2D *texture = context->getTexture2D(); |
| 2607 | texture->setCompressedImage(level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2608 | } |
| 2609 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2610 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2611 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2612 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2613 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2614 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2615 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2616 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2617 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2618 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 2619 | texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2620 | } |
| 2621 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2622 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2623 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2624 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2625 | } |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2626 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2627 | } |
| 2628 | catch(std::bad_alloc&) |
| 2629 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2630 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2631 | } |
| 2632 | } |
| 2633 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2634 | void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 2635 | GLenum format, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2636 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2637 | 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] | 2638 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2639 | "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2640 | target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 2641 | |
| 2642 | try |
| 2643 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2644 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2645 | |
| 2646 | if (context) |
| 2647 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2648 | if (context->getClientVersion() < 3 && |
| 2649 | !validateES2TexImageParameters(context, target, level, GL_NONE, true, true, |
| 2650 | xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data)) |
| 2651 | { |
| 2652 | return; |
| 2653 | } |
| 2654 | |
| 2655 | if (context->getClientVersion() >= 3 && |
| 2656 | !validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 2657 | xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 2658 | { |
| 2659 | return; |
| 2660 | } |
| 2661 | |
| 2662 | if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2663 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2664 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2665 | } |
| 2666 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2667 | switch (target) |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2668 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2669 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2670 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2671 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 2672 | texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2673 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2674 | break; |
| 2675 | |
| 2676 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2677 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2678 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2679 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2680 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2681 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2682 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2683 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 2684 | texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2685 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2686 | break; |
| 2687 | |
| 2688 | default: |
| 2689 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2690 | } |
| 2691 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2692 | } |
| 2693 | catch(std::bad_alloc&) |
| 2694 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2695 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2696 | } |
| 2697 | } |
| 2698 | |
| 2699 | void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) |
| 2700 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2701 | 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] | 2702 | "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] | 2703 | target, level, internalformat, x, y, width, height, border); |
| 2704 | |
| 2705 | try |
| 2706 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2707 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2708 | |
| 2709 | if (context) |
| 2710 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2711 | if (context->getClientVersion() < 3 && |
| 2712 | !validateES2CopyTexImageParameters(context, target, level, internalformat, false, |
| 2713 | 0, 0, x, y, width, height, border)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 2714 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2715 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 2716 | } |
| 2717 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2718 | if (context->getClientVersion() >= 3 && |
| 2719 | !validateES3CopyTexImageParameters(context, target, level, internalformat, false, |
| 2720 | 0, 0, 0, x, y, width, height, border)) |
| 2721 | { |
| 2722 | return; |
| 2723 | } |
| 2724 | |
| 2725 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 2726 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2727 | switch (target) |
| 2728 | { |
| 2729 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2730 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2731 | gl::Texture2D *texture = context->getTexture2D(); |
| 2732 | texture->copyImage(level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2733 | } |
| 2734 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2735 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2736 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2737 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2738 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2739 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2740 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2741 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2742 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2743 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 2744 | texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2745 | } |
| 2746 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2747 | |
| 2748 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2749 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2750 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2751 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2752 | } |
| 2753 | catch(std::bad_alloc&) |
| 2754 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2755 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2756 | } |
| 2757 | } |
| 2758 | |
| 2759 | void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 2760 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2761 | 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] | 2762 | "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] | 2763 | target, level, xoffset, yoffset, x, y, width, height); |
| 2764 | |
| 2765 | try |
| 2766 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2767 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2768 | |
| 2769 | if (context) |
| 2770 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2771 | if (context->getClientVersion() < 3 && |
| 2772 | !validateES2CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 2773 | xoffset, yoffset, x, y, width, height, 0)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2774 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2775 | return; |
| 2776 | } |
| 2777 | |
| 2778 | if (context->getClientVersion() >= 3 && |
| 2779 | !validateES3CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 2780 | xoffset, yoffset, 0, x, y, width, height, 0)) |
| 2781 | { |
| 2782 | return; |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2783 | } |
| 2784 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2785 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 2786 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2787 | switch (target) |
daniel@transgaming.com | bbc5779 | 2010-07-28 19:21:05 +0000 | [diff] [blame] | 2788 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2789 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 2790 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2791 | gl::Texture2D *texture = context->getTexture2D(); |
| 2792 | 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] | 2793 | } |
| 2794 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2795 | |
| 2796 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2797 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2798 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2799 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2800 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2801 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 2802 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2803 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 2804 | 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] | 2805 | } |
| 2806 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2807 | |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 2808 | default: |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2809 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 2810 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2811 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2812 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2813 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2814 | catch(std::bad_alloc&) |
| 2815 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2816 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2817 | } |
| 2818 | } |
| 2819 | |
| 2820 | GLuint __stdcall glCreateProgram(void) |
| 2821 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2822 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2823 | |
| 2824 | try |
| 2825 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2826 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2827 | |
| 2828 | if (context) |
| 2829 | { |
| 2830 | return context->createProgram(); |
| 2831 | } |
| 2832 | } |
| 2833 | catch(std::bad_alloc&) |
| 2834 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2835 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2836 | } |
| 2837 | |
| 2838 | return 0; |
| 2839 | } |
| 2840 | |
| 2841 | GLuint __stdcall glCreateShader(GLenum type) |
| 2842 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2843 | EVENT("(GLenum type = 0x%X)", type); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2844 | |
| 2845 | try |
| 2846 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2847 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2848 | |
| 2849 | if (context) |
| 2850 | { |
| 2851 | switch (type) |
| 2852 | { |
| 2853 | case GL_FRAGMENT_SHADER: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2854 | case GL_VERTEX_SHADER: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2855 | return context->createShader(type); |
| 2856 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2857 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2858 | } |
| 2859 | } |
| 2860 | } |
| 2861 | catch(std::bad_alloc&) |
| 2862 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2863 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2864 | } |
| 2865 | |
| 2866 | return 0; |
| 2867 | } |
| 2868 | |
| 2869 | void __stdcall glCullFace(GLenum mode) |
| 2870 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2871 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2872 | |
| 2873 | try |
| 2874 | { |
| 2875 | switch (mode) |
| 2876 | { |
| 2877 | case GL_FRONT: |
| 2878 | case GL_BACK: |
| 2879 | case GL_FRONT_AND_BACK: |
| 2880 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2881 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2882 | |
| 2883 | if (context) |
| 2884 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2885 | context->setCullMode(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2886 | } |
| 2887 | } |
| 2888 | break; |
| 2889 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2890 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2891 | } |
| 2892 | } |
| 2893 | catch(std::bad_alloc&) |
| 2894 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2895 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2896 | } |
| 2897 | } |
| 2898 | |
| 2899 | void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers) |
| 2900 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2901 | 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] | 2902 | |
| 2903 | try |
| 2904 | { |
| 2905 | if (n < 0) |
| 2906 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2907 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2908 | } |
| 2909 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2910 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2911 | |
| 2912 | if (context) |
| 2913 | { |
| 2914 | for (int i = 0; i < n; i++) |
| 2915 | { |
| 2916 | context->deleteBuffer(buffers[i]); |
| 2917 | } |
| 2918 | } |
| 2919 | } |
| 2920 | catch(std::bad_alloc&) |
| 2921 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2922 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2923 | } |
| 2924 | } |
| 2925 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2926 | void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences) |
| 2927 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2928 | 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] | 2929 | |
| 2930 | try |
| 2931 | { |
| 2932 | if (n < 0) |
| 2933 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2934 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2935 | } |
| 2936 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2937 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2938 | |
| 2939 | if (context) |
| 2940 | { |
| 2941 | for (int i = 0; i < n; i++) |
| 2942 | { |
| 2943 | context->deleteFence(fences[i]); |
| 2944 | } |
| 2945 | } |
| 2946 | } |
| 2947 | catch(std::bad_alloc&) |
| 2948 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2949 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2950 | } |
| 2951 | } |
| 2952 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2953 | void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) |
| 2954 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2955 | 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] | 2956 | |
| 2957 | try |
| 2958 | { |
| 2959 | if (n < 0) |
| 2960 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2961 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2962 | } |
| 2963 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2964 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2965 | |
| 2966 | if (context) |
| 2967 | { |
| 2968 | for (int i = 0; i < n; i++) |
| 2969 | { |
| 2970 | if (framebuffers[i] != 0) |
| 2971 | { |
| 2972 | context->deleteFramebuffer(framebuffers[i]); |
| 2973 | } |
| 2974 | } |
| 2975 | } |
| 2976 | } |
| 2977 | catch(std::bad_alloc&) |
| 2978 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2979 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2980 | } |
| 2981 | } |
| 2982 | |
| 2983 | void __stdcall glDeleteProgram(GLuint program) |
| 2984 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2985 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2986 | |
| 2987 | try |
| 2988 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 2989 | if (program == 0) |
| 2990 | { |
| 2991 | return; |
| 2992 | } |
| 2993 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2994 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2995 | |
| 2996 | if (context) |
| 2997 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 2998 | if (!context->getProgram(program)) |
| 2999 | { |
| 3000 | if(context->getShader(program)) |
| 3001 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3002 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3003 | } |
| 3004 | else |
| 3005 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3006 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3007 | } |
| 3008 | } |
| 3009 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3010 | context->deleteProgram(program); |
| 3011 | } |
| 3012 | } |
| 3013 | catch(std::bad_alloc&) |
| 3014 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3015 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3016 | } |
| 3017 | } |
| 3018 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3019 | void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids) |
| 3020 | { |
| 3021 | EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids); |
| 3022 | |
| 3023 | try |
| 3024 | { |
| 3025 | if (n < 0) |
| 3026 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3027 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3028 | } |
| 3029 | |
| 3030 | gl::Context *context = gl::getNonLostContext(); |
| 3031 | |
| 3032 | if (context) |
| 3033 | { |
| 3034 | for (int i = 0; i < n; i++) |
| 3035 | { |
| 3036 | context->deleteQuery(ids[i]); |
| 3037 | } |
| 3038 | } |
| 3039 | } |
| 3040 | catch(std::bad_alloc&) |
| 3041 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3042 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3043 | } |
| 3044 | } |
| 3045 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3046 | void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) |
| 3047 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3048 | 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] | 3049 | |
| 3050 | try |
| 3051 | { |
| 3052 | if (n < 0) |
| 3053 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3054 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3055 | } |
| 3056 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3057 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3058 | |
| 3059 | if (context) |
| 3060 | { |
daniel@transgaming.com | e2b2212 | 2010-03-11 19:22:14 +0000 | [diff] [blame] | 3061 | for (int i = 0; i < n; i++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3062 | { |
| 3063 | context->deleteRenderbuffer(renderbuffers[i]); |
| 3064 | } |
| 3065 | } |
| 3066 | } |
| 3067 | catch(std::bad_alloc&) |
| 3068 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3069 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3070 | } |
| 3071 | } |
| 3072 | |
| 3073 | void __stdcall glDeleteShader(GLuint shader) |
| 3074 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3075 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3076 | |
| 3077 | try |
| 3078 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3079 | if (shader == 0) |
| 3080 | { |
| 3081 | return; |
| 3082 | } |
| 3083 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3084 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3085 | |
| 3086 | if (context) |
| 3087 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3088 | if (!context->getShader(shader)) |
| 3089 | { |
| 3090 | if(context->getProgram(shader)) |
| 3091 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3092 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3093 | } |
| 3094 | else |
| 3095 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3096 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3097 | } |
| 3098 | } |
| 3099 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3100 | context->deleteShader(shader); |
| 3101 | } |
| 3102 | } |
| 3103 | catch(std::bad_alloc&) |
| 3104 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3105 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3106 | } |
| 3107 | } |
| 3108 | |
| 3109 | void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures) |
| 3110 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3111 | 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] | 3112 | |
| 3113 | try |
| 3114 | { |
| 3115 | if (n < 0) |
| 3116 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3117 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3118 | } |
| 3119 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3120 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3121 | |
| 3122 | if (context) |
| 3123 | { |
| 3124 | for (int i = 0; i < n; i++) |
| 3125 | { |
| 3126 | if (textures[i] != 0) |
| 3127 | { |
| 3128 | context->deleteTexture(textures[i]); |
| 3129 | } |
| 3130 | } |
| 3131 | } |
| 3132 | } |
| 3133 | catch(std::bad_alloc&) |
| 3134 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3135 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3136 | } |
| 3137 | } |
| 3138 | |
| 3139 | void __stdcall glDepthFunc(GLenum func) |
| 3140 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3141 | EVENT("(GLenum func = 0x%X)", func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3142 | |
| 3143 | try |
| 3144 | { |
| 3145 | switch (func) |
| 3146 | { |
| 3147 | case GL_NEVER: |
| 3148 | case GL_ALWAYS: |
| 3149 | case GL_LESS: |
| 3150 | case GL_LEQUAL: |
| 3151 | case GL_EQUAL: |
| 3152 | case GL_GREATER: |
| 3153 | case GL_GEQUAL: |
| 3154 | case GL_NOTEQUAL: |
| 3155 | break; |
| 3156 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3157 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3158 | } |
| 3159 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3160 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3161 | |
| 3162 | if (context) |
| 3163 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3164 | context->setDepthFunc(func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3165 | } |
| 3166 | } |
| 3167 | catch(std::bad_alloc&) |
| 3168 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3169 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3170 | } |
| 3171 | } |
| 3172 | |
| 3173 | void __stdcall glDepthMask(GLboolean flag) |
| 3174 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 3175 | EVENT("(GLboolean flag = %u)", flag); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3176 | |
| 3177 | try |
| 3178 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3179 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3180 | |
| 3181 | if (context) |
| 3182 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3183 | context->setDepthMask(flag != GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3184 | } |
| 3185 | } |
| 3186 | catch(std::bad_alloc&) |
| 3187 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3188 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3189 | } |
| 3190 | } |
| 3191 | |
| 3192 | void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar) |
| 3193 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3194 | EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3195 | |
| 3196 | try |
| 3197 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3198 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3199 | |
| 3200 | if (context) |
| 3201 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3202 | context->setDepthRange(zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3203 | } |
| 3204 | } |
| 3205 | catch(std::bad_alloc&) |
| 3206 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3207 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3208 | } |
| 3209 | } |
| 3210 | |
| 3211 | void __stdcall glDetachShader(GLuint program, GLuint shader) |
| 3212 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3213 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3214 | |
| 3215 | try |
| 3216 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3217 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3218 | |
| 3219 | if (context) |
| 3220 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3221 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3222 | gl::Program *programObject = context->getProgram(program); |
| 3223 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3224 | |
| 3225 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3226 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3227 | gl::Shader *shaderByProgramHandle; |
| 3228 | shaderByProgramHandle = context->getShader(program); |
| 3229 | if (!shaderByProgramHandle) |
| 3230 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3231 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3232 | } |
| 3233 | else |
| 3234 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3235 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3236 | } |
| 3237 | } |
| 3238 | |
| 3239 | if (!shaderObject) |
| 3240 | { |
| 3241 | gl::Program *programByShaderHandle = context->getProgram(shader); |
| 3242 | if (!programByShaderHandle) |
| 3243 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3244 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3245 | } |
| 3246 | else |
| 3247 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3248 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3249 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3250 | } |
| 3251 | |
| 3252 | if (!programObject->detachShader(shaderObject)) |
| 3253 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3254 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3255 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 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 | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3261 | } |
| 3262 | } |
| 3263 | |
| 3264 | void __stdcall glDisable(GLenum cap) |
| 3265 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3266 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3267 | |
| 3268 | try |
| 3269 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3270 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3271 | |
| 3272 | if (context) |
| 3273 | { |
| 3274 | switch (cap) |
| 3275 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3276 | case GL_CULL_FACE: context->setCullFace(false); break; |
| 3277 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break; |
| 3278 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break; |
| 3279 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break; |
| 3280 | case GL_SCISSOR_TEST: context->setScissorTest(false); break; |
| 3281 | case GL_STENCIL_TEST: context->setStencilTest(false); break; |
| 3282 | case GL_DEPTH_TEST: context->setDepthTest(false); break; |
| 3283 | case GL_BLEND: context->setBlend(false); break; |
| 3284 | case GL_DITHER: context->setDither(false); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 3285 | |
| 3286 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 3287 | case GL_RASTERIZER_DISCARD: |
| 3288 | if (context->getClientVersion() < 3) |
| 3289 | { |
| 3290 | return gl::error(GL_INVALID_ENUM); |
| 3291 | } |
| 3292 | UNIMPLEMENTED(); |
| 3293 | break; |
| 3294 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3295 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3296 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3297 | } |
| 3298 | } |
| 3299 | } |
| 3300 | catch(std::bad_alloc&) |
| 3301 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3302 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3303 | } |
| 3304 | } |
| 3305 | |
| 3306 | void __stdcall glDisableVertexAttribArray(GLuint index) |
| 3307 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3308 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3309 | |
| 3310 | try |
| 3311 | { |
| 3312 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3313 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3314 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3315 | } |
| 3316 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3317 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3318 | |
| 3319 | if (context) |
| 3320 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3321 | context->setEnableVertexAttribArray(index, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3322 | } |
| 3323 | } |
| 3324 | catch(std::bad_alloc&) |
| 3325 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3326 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3327 | } |
| 3328 | } |
| 3329 | |
| 3330 | void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count) |
| 3331 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3332 | 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] | 3333 | |
| 3334 | try |
| 3335 | { |
| 3336 | if (count < 0 || first < 0) |
| 3337 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3338 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3339 | } |
| 3340 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3341 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3342 | |
| 3343 | if (context) |
| 3344 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3345 | context->drawArrays(mode, first, count, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3346 | } |
| 3347 | } |
| 3348 | catch(std::bad_alloc&) |
| 3349 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3350 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3351 | } |
| 3352 | } |
| 3353 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3354 | void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
| 3355 | { |
| 3356 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount); |
| 3357 | |
| 3358 | try |
| 3359 | { |
| 3360 | if (count < 0 || first < 0 || primcount < 0) |
| 3361 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3362 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3363 | } |
| 3364 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3365 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3366 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3367 | gl::Context *context = gl::getNonLostContext(); |
| 3368 | |
| 3369 | if (context) |
| 3370 | { |
| 3371 | context->drawArrays(mode, first, count, primcount); |
| 3372 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3373 | } |
| 3374 | } |
| 3375 | catch(std::bad_alloc&) |
| 3376 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3377 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3378 | } |
| 3379 | } |
| 3380 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3381 | 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] | 3382 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3383 | 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] | 3384 | mode, count, type, indices); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3385 | |
| 3386 | try |
| 3387 | { |
| 3388 | if (count < 0) |
| 3389 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3390 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3391 | } |
| 3392 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3393 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3394 | |
| 3395 | if (context) |
| 3396 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3397 | switch (type) |
| 3398 | { |
| 3399 | case GL_UNSIGNED_BYTE: |
| 3400 | case GL_UNSIGNED_SHORT: |
| 3401 | break; |
| 3402 | case GL_UNSIGNED_INT: |
| 3403 | if (!context->supports32bitIndices()) |
| 3404 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3405 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3406 | } |
| 3407 | break; |
| 3408 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3409 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3410 | } |
| 3411 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3412 | context->drawElements(mode, count, type, indices, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3413 | } |
| 3414 | } |
| 3415 | catch(std::bad_alloc&) |
| 3416 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3417 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3418 | } |
| 3419 | } |
| 3420 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3421 | void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount) |
| 3422 | { |
| 3423 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)", |
| 3424 | mode, count, type, indices, primcount); |
| 3425 | |
| 3426 | try |
| 3427 | { |
| 3428 | if (count < 0 || primcount < 0) |
| 3429 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3430 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3431 | } |
| 3432 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3433 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3434 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3435 | gl::Context *context = gl::getNonLostContext(); |
| 3436 | |
| 3437 | if (context) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3438 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3439 | switch (type) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3440 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3441 | case GL_UNSIGNED_BYTE: |
| 3442 | case GL_UNSIGNED_SHORT: |
| 3443 | break; |
| 3444 | case GL_UNSIGNED_INT: |
| 3445 | if (!context->supports32bitIndices()) |
| 3446 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3447 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3448 | } |
| 3449 | break; |
| 3450 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3451 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3452 | } |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3453 | |
| 3454 | context->drawElements(mode, count, type, indices, primcount); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3455 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3456 | } |
| 3457 | } |
| 3458 | catch(std::bad_alloc&) |
| 3459 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3460 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3461 | } |
| 3462 | } |
| 3463 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3464 | void __stdcall glEnable(GLenum cap) |
| 3465 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3466 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3467 | |
| 3468 | try |
| 3469 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3470 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3471 | |
| 3472 | if (context) |
| 3473 | { |
| 3474 | switch (cap) |
| 3475 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3476 | case GL_CULL_FACE: context->setCullFace(true); break; |
| 3477 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break; |
| 3478 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break; |
| 3479 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break; |
| 3480 | case GL_SCISSOR_TEST: context->setScissorTest(true); break; |
| 3481 | case GL_STENCIL_TEST: context->setStencilTest(true); break; |
| 3482 | case GL_DEPTH_TEST: context->setDepthTest(true); break; |
| 3483 | case GL_BLEND: context->setBlend(true); break; |
| 3484 | case GL_DITHER: context->setDither(true); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3485 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3486 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3487 | } |
| 3488 | } |
| 3489 | } |
| 3490 | catch(std::bad_alloc&) |
| 3491 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3492 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3493 | } |
| 3494 | } |
| 3495 | |
| 3496 | void __stdcall glEnableVertexAttribArray(GLuint index) |
| 3497 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3498 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3499 | |
| 3500 | try |
| 3501 | { |
| 3502 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3503 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3504 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3505 | } |
| 3506 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3507 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3508 | |
| 3509 | if (context) |
| 3510 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3511 | context->setEnableVertexAttribArray(index, true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3512 | } |
| 3513 | } |
| 3514 | catch(std::bad_alloc&) |
| 3515 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3516 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3517 | } |
| 3518 | } |
| 3519 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3520 | void __stdcall glEndQueryEXT(GLenum target) |
| 3521 | { |
| 3522 | EVENT("GLenum target = 0x%X)", target); |
| 3523 | |
| 3524 | try |
| 3525 | { |
| 3526 | switch (target) |
| 3527 | { |
| 3528 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 3529 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 3530 | break; |
| 3531 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3532 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3533 | } |
| 3534 | |
| 3535 | gl::Context *context = gl::getNonLostContext(); |
| 3536 | |
| 3537 | if (context) |
| 3538 | { |
| 3539 | context->endQuery(target); |
| 3540 | } |
| 3541 | } |
| 3542 | catch(std::bad_alloc&) |
| 3543 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3544 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3545 | } |
| 3546 | } |
| 3547 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3548 | void __stdcall glFinishFenceNV(GLuint fence) |
| 3549 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3550 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3551 | |
| 3552 | try |
| 3553 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3554 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3555 | |
| 3556 | if (context) |
| 3557 | { |
| 3558 | gl::Fence* fenceObject = context->getFence(fence); |
| 3559 | |
| 3560 | if (fenceObject == NULL) |
| 3561 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3562 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3563 | } |
| 3564 | |
| 3565 | fenceObject->finishFence(); |
| 3566 | } |
| 3567 | } |
| 3568 | catch(std::bad_alloc&) |
| 3569 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3570 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3571 | } |
| 3572 | } |
| 3573 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3574 | void __stdcall glFinish(void) |
| 3575 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3576 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3577 | |
| 3578 | try |
| 3579 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3580 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3581 | |
| 3582 | if (context) |
| 3583 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 3584 | context->sync(true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3585 | } |
| 3586 | } |
| 3587 | catch(std::bad_alloc&) |
| 3588 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3589 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3590 | } |
| 3591 | } |
| 3592 | |
| 3593 | void __stdcall glFlush(void) |
| 3594 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3595 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3596 | |
| 3597 | try |
| 3598 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3599 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3600 | |
| 3601 | if (context) |
| 3602 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 3603 | context->sync(false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3604 | } |
| 3605 | } |
| 3606 | catch(std::bad_alloc&) |
| 3607 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3608 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3609 | } |
| 3610 | } |
| 3611 | |
| 3612 | void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) |
| 3613 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3614 | 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] | 3615 | "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3616 | |
| 3617 | try |
| 3618 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3619 | 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] | 3620 | || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3621 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3622 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3623 | } |
| 3624 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3625 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3626 | |
| 3627 | if (context) |
| 3628 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3629 | gl::Framebuffer *framebuffer = NULL; |
| 3630 | GLuint framebufferHandle = 0; |
| 3631 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 3632 | { |
| 3633 | framebuffer = context->getReadFramebuffer(); |
| 3634 | framebufferHandle = context->getReadFramebufferHandle(); |
| 3635 | } |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 3636 | else |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3637 | { |
| 3638 | framebuffer = context->getDrawFramebuffer(); |
| 3639 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 3640 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3641 | |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 3642 | if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3643 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3644 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3645 | } |
| 3646 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3647 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3648 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3649 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 3650 | |
| 3651 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 3652 | { |
| 3653 | return gl::error(GL_INVALID_VALUE); |
| 3654 | } |
| 3655 | |
| 3656 | framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer); |
| 3657 | } |
| 3658 | else |
| 3659 | { |
| 3660 | switch (attachment) |
| 3661 | { |
| 3662 | case GL_DEPTH_ATTACHMENT: |
| 3663 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer); |
| 3664 | break; |
| 3665 | case GL_STENCIL_ATTACHMENT: |
| 3666 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer); |
| 3667 | break; |
| 3668 | default: |
| 3669 | return gl::error(GL_INVALID_ENUM); |
| 3670 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3671 | } |
| 3672 | } |
| 3673 | } |
| 3674 | catch(std::bad_alloc&) |
| 3675 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3676 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3677 | } |
| 3678 | } |
| 3679 | |
| 3680 | void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) |
| 3681 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3682 | 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] | 3683 | "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3684 | |
| 3685 | try |
| 3686 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3687 | 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] | 3688 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3689 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3690 | } |
| 3691 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3692 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3693 | |
| 3694 | if (context) |
| 3695 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3696 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 3697 | { |
| 3698 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 3699 | |
| 3700 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 3701 | { |
| 3702 | return gl::error(GL_INVALID_VALUE); |
| 3703 | } |
| 3704 | } |
| 3705 | else |
| 3706 | { |
| 3707 | switch (attachment) |
| 3708 | { |
| 3709 | case GL_DEPTH_ATTACHMENT: |
| 3710 | case GL_STENCIL_ATTACHMENT: |
| 3711 | break; |
| 3712 | default: |
| 3713 | return gl::error(GL_INVALID_ENUM); |
| 3714 | } |
| 3715 | } |
| 3716 | |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3717 | if (texture == 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3718 | { |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3719 | textarget = GL_NONE; |
| 3720 | } |
| 3721 | else |
| 3722 | { |
| 3723 | gl::Texture *tex = context->getTexture(texture); |
| 3724 | |
| 3725 | if (tex == NULL) |
| 3726 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3727 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3728 | } |
| 3729 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3730 | switch (textarget) |
| 3731 | { |
| 3732 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3733 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3734 | if (tex->getTarget() != GL_TEXTURE_2D) |
| 3735 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3736 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3737 | } |
| 3738 | gl::Texture2D *tex2d = static_cast<gl::Texture2D *>(tex); |
daniel@transgaming.com | 92f4992 | 2012-05-09 15:49:19 +0000 | [diff] [blame] | 3739 | if (tex2d->isCompressed(0)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3740 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3741 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3742 | } |
| 3743 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3744 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3745 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3746 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3747 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3748 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3749 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3750 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3751 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3752 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3753 | if (tex->getTarget() != GL_TEXTURE_CUBE_MAP) |
| 3754 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3755 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3756 | } |
| 3757 | gl::TextureCubeMap *texcube = static_cast<gl::TextureCubeMap *>(tex); |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 3758 | if (texcube->isCompressed(textarget, level)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3759 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3760 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3761 | } |
| 3762 | break; |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3763 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3764 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3765 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3766 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3767 | } |
| 3768 | |
| 3769 | if (level != 0) |
| 3770 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3771 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3772 | } |
| 3773 | } |
| 3774 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3775 | gl::Framebuffer *framebuffer = NULL; |
| 3776 | GLuint framebufferHandle = 0; |
| 3777 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 3778 | { |
| 3779 | framebuffer = context->getReadFramebuffer(); |
| 3780 | framebufferHandle = context->getReadFramebufferHandle(); |
| 3781 | } |
| 3782 | else |
| 3783 | { |
| 3784 | framebuffer = context->getDrawFramebuffer(); |
| 3785 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 3786 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3787 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3788 | if (framebufferHandle == 0 || !framebuffer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3789 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3790 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3791 | } |
| 3792 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3793 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 3794 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3795 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 3796 | |
| 3797 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 3798 | { |
| 3799 | return gl::error(GL_INVALID_VALUE); |
| 3800 | } |
| 3801 | |
| 3802 | framebuffer->setColorbuffer(colorAttachment, textarget, texture); |
| 3803 | } |
| 3804 | else |
| 3805 | { |
| 3806 | switch (attachment) |
| 3807 | { |
| 3808 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break; |
| 3809 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break; |
| 3810 | } |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 3811 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3812 | } |
| 3813 | } |
| 3814 | catch(std::bad_alloc&) |
| 3815 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3816 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3817 | } |
| 3818 | } |
| 3819 | |
| 3820 | void __stdcall glFrontFace(GLenum mode) |
| 3821 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3822 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3823 | |
| 3824 | try |
| 3825 | { |
| 3826 | switch (mode) |
| 3827 | { |
| 3828 | case GL_CW: |
| 3829 | case GL_CCW: |
| 3830 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3831 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3832 | |
| 3833 | if (context) |
| 3834 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3835 | context->setFrontFace(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3836 | } |
| 3837 | } |
| 3838 | break; |
| 3839 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3840 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3841 | } |
| 3842 | } |
| 3843 | catch(std::bad_alloc&) |
| 3844 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3845 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3846 | } |
| 3847 | } |
| 3848 | |
| 3849 | void __stdcall glGenBuffers(GLsizei n, GLuint* buffers) |
| 3850 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3851 | EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3852 | |
| 3853 | try |
| 3854 | { |
| 3855 | if (n < 0) |
| 3856 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3857 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3858 | } |
| 3859 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3860 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3861 | |
| 3862 | if (context) |
| 3863 | { |
| 3864 | for (int i = 0; i < n; i++) |
| 3865 | { |
| 3866 | buffers[i] = context->createBuffer(); |
| 3867 | } |
| 3868 | } |
| 3869 | } |
| 3870 | catch(std::bad_alloc&) |
| 3871 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3872 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3873 | } |
| 3874 | } |
| 3875 | |
| 3876 | void __stdcall glGenerateMipmap(GLenum target) |
| 3877 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3878 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3879 | |
| 3880 | try |
| 3881 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3882 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3883 | |
| 3884 | if (context) |
| 3885 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3886 | gl::Texture *texture = NULL; |
| 3887 | GLint internalFormat = GL_NONE; |
| 3888 | bool isCompressed = false; |
| 3889 | bool isDepth = false; |
| 3890 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3891 | switch (target) |
| 3892 | { |
| 3893 | case GL_TEXTURE_2D: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3894 | { |
| 3895 | gl::Texture2D *tex2d = context->getTexture2D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3896 | if (tex2d) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3897 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3898 | internalFormat = tex2d->getInternalFormat(0); |
| 3899 | isCompressed = tex2d->isCompressed(0); |
| 3900 | isDepth = tex2d->isDepth(0); |
| 3901 | texture = tex2d; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3902 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3903 | break; |
| 3904 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3905 | |
| 3906 | case GL_TEXTURE_CUBE_MAP: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3907 | { |
| 3908 | gl::TextureCubeMap *texcube = context->getTextureCubeMap(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3909 | if (texcube) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3910 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3911 | internalFormat = texcube->getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 3912 | isCompressed = texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 3913 | isDepth = false; |
| 3914 | texture = texcube; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3915 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3916 | break; |
| 3917 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3918 | |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 3919 | case GL_TEXTURE_3D: |
| 3920 | { |
| 3921 | if (context->getClientVersion() < 3) |
| 3922 | { |
| 3923 | return gl::error(GL_INVALID_ENUM); |
| 3924 | } |
| 3925 | |
| 3926 | gl::Texture3D *tex3D = context->getTexture3D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3927 | if (tex3D) |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 3928 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3929 | internalFormat = tex3D->getInternalFormat(0); |
| 3930 | isCompressed = tex3D->isCompressed(0); |
| 3931 | isDepth = tex3D->isDepth(0); |
| 3932 | texture = tex3D; |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 3933 | } |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 3934 | break; |
| 3935 | } |
| 3936 | |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 3937 | case GL_TEXTURE_2D_ARRAY: |
| 3938 | { |
| 3939 | if (context->getClientVersion() < 3) |
| 3940 | { |
| 3941 | return gl::error(GL_INVALID_ENUM); |
| 3942 | } |
| 3943 | |
| 3944 | gl::Texture2DArray *tex2darr = context->getTexture2DArray(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3945 | if (tex2darr) |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 3946 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3947 | internalFormat = tex2darr->getInternalFormat(0); |
| 3948 | isCompressed = tex2darr->isCompressed(0); |
| 3949 | isDepth = tex2darr->isDepth(0); |
| 3950 | texture = tex2darr; |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 3951 | } |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 3952 | break; |
| 3953 | } |
| 3954 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3955 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3956 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3957 | } |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3958 | |
| 3959 | if (!texture) |
| 3960 | { |
| 3961 | return gl::error(GL_INVALID_OPERATION); |
| 3962 | } |
| 3963 | |
| 3964 | // Internally, all texture formats are sized so checking if the format |
| 3965 | // is color renderable and filterable will not fail. |
| 3966 | if (isDepth || isCompressed || |
| 3967 | !gl::IsColorRenderingSupported(internalFormat, context) || |
| 3968 | !gl::IsTextureFilteringSupported(internalFormat, context)) |
| 3969 | { |
| 3970 | return gl::error(GL_INVALID_OPERATION); |
| 3971 | } |
| 3972 | |
| 3973 | texture->generateMipmaps(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3974 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3975 | } |
| 3976 | catch(std::bad_alloc&) |
| 3977 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3978 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3979 | } |
| 3980 | } |
| 3981 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3982 | void __stdcall glGenFencesNV(GLsizei n, GLuint* fences) |
| 3983 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3984 | EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3985 | |
| 3986 | try |
| 3987 | { |
| 3988 | if (n < 0) |
| 3989 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3990 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3991 | } |
| 3992 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3993 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3994 | |
| 3995 | if (context) |
| 3996 | { |
| 3997 | for (int i = 0; i < n; i++) |
| 3998 | { |
| 3999 | fences[i] = context->createFence(); |
| 4000 | } |
| 4001 | } |
| 4002 | } |
| 4003 | catch(std::bad_alloc&) |
| 4004 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4005 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4006 | } |
| 4007 | } |
| 4008 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4009 | void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers) |
| 4010 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4011 | EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4012 | |
| 4013 | try |
| 4014 | { |
| 4015 | if (n < 0) |
| 4016 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4017 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4018 | } |
| 4019 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4020 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4021 | |
| 4022 | if (context) |
| 4023 | { |
| 4024 | for (int i = 0; i < n; i++) |
| 4025 | { |
| 4026 | framebuffers[i] = context->createFramebuffer(); |
| 4027 | } |
| 4028 | } |
| 4029 | } |
| 4030 | catch(std::bad_alloc&) |
| 4031 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4032 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4033 | } |
| 4034 | } |
| 4035 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4036 | void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids) |
| 4037 | { |
| 4038 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 4039 | |
| 4040 | try |
| 4041 | { |
| 4042 | if (n < 0) |
| 4043 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4044 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4045 | } |
| 4046 | |
| 4047 | gl::Context *context = gl::getNonLostContext(); |
| 4048 | |
| 4049 | if (context) |
| 4050 | { |
| 4051 | for (int i = 0; i < n; i++) |
| 4052 | { |
| 4053 | ids[i] = context->createQuery(); |
| 4054 | } |
| 4055 | } |
| 4056 | } |
| 4057 | catch(std::bad_alloc&) |
| 4058 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4059 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4060 | } |
| 4061 | } |
| 4062 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4063 | void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) |
| 4064 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4065 | EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4066 | |
| 4067 | try |
| 4068 | { |
| 4069 | if (n < 0) |
| 4070 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4071 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4072 | } |
| 4073 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4074 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4075 | |
| 4076 | if (context) |
| 4077 | { |
| 4078 | for (int i = 0; i < n; i++) |
| 4079 | { |
| 4080 | renderbuffers[i] = context->createRenderbuffer(); |
| 4081 | } |
| 4082 | } |
| 4083 | } |
| 4084 | catch(std::bad_alloc&) |
| 4085 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4086 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4087 | } |
| 4088 | } |
| 4089 | |
| 4090 | void __stdcall glGenTextures(GLsizei n, GLuint* textures) |
| 4091 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4092 | EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4093 | |
| 4094 | try |
| 4095 | { |
| 4096 | if (n < 0) |
| 4097 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4098 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4099 | } |
| 4100 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4101 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4102 | |
| 4103 | if (context) |
| 4104 | { |
| 4105 | for (int i = 0; i < n; i++) |
| 4106 | { |
| 4107 | textures[i] = context->createTexture(); |
| 4108 | } |
| 4109 | } |
| 4110 | } |
| 4111 | catch(std::bad_alloc&) |
| 4112 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4113 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4114 | } |
| 4115 | } |
| 4116 | |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4117 | 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] | 4118 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4119 | 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] | 4120 | "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] | 4121 | program, index, bufsize, length, size, type, name); |
| 4122 | |
| 4123 | try |
| 4124 | { |
| 4125 | if (bufsize < 0) |
| 4126 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4127 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4128 | } |
| 4129 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4130 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4131 | |
| 4132 | if (context) |
| 4133 | { |
| 4134 | gl::Program *programObject = context->getProgram(program); |
| 4135 | |
| 4136 | if (!programObject) |
| 4137 | { |
| 4138 | if (context->getShader(program)) |
| 4139 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4140 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4141 | } |
| 4142 | else |
| 4143 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4144 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4145 | } |
| 4146 | } |
| 4147 | |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4148 | if (index >= (GLuint)programObject->getActiveAttributeCount()) |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4149 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4150 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4151 | } |
| 4152 | |
| 4153 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 4154 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4155 | } |
| 4156 | catch(std::bad_alloc&) |
| 4157 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4158 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4159 | } |
| 4160 | } |
| 4161 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4162 | 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] | 4163 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4164 | EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4165 | "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] | 4166 | program, index, bufsize, length, size, type, name); |
| 4167 | |
| 4168 | try |
| 4169 | { |
| 4170 | if (bufsize < 0) |
| 4171 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4172 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4173 | } |
| 4174 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4175 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4176 | |
| 4177 | if (context) |
| 4178 | { |
| 4179 | gl::Program *programObject = context->getProgram(program); |
| 4180 | |
| 4181 | if (!programObject) |
| 4182 | { |
| 4183 | if (context->getShader(program)) |
| 4184 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4185 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4186 | } |
| 4187 | else |
| 4188 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4189 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4190 | } |
| 4191 | } |
| 4192 | |
| 4193 | if (index >= (GLuint)programObject->getActiveUniformCount()) |
| 4194 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4195 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4196 | } |
| 4197 | |
| 4198 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 4199 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4200 | } |
| 4201 | catch(std::bad_alloc&) |
| 4202 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4203 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4204 | } |
| 4205 | } |
| 4206 | |
| 4207 | void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) |
| 4208 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4209 | 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] | 4210 | program, maxcount, count, shaders); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4211 | |
| 4212 | try |
| 4213 | { |
| 4214 | if (maxcount < 0) |
| 4215 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4216 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4217 | } |
| 4218 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4219 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4220 | |
| 4221 | if (context) |
| 4222 | { |
| 4223 | gl::Program *programObject = context->getProgram(program); |
| 4224 | |
| 4225 | if (!programObject) |
| 4226 | { |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4227 | if (context->getShader(program)) |
| 4228 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4229 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4230 | } |
| 4231 | else |
| 4232 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4233 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4234 | } |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4235 | } |
| 4236 | |
| 4237 | return programObject->getAttachedShaders(maxcount, count, shaders); |
| 4238 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 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); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4243 | } |
| 4244 | } |
| 4245 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4246 | int __stdcall glGetAttribLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4247 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4248 | EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4249 | |
| 4250 | try |
| 4251 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4252 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4253 | |
| 4254 | if (context) |
| 4255 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4256 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4257 | gl::Program *programObject = context->getProgram(program); |
| 4258 | |
| 4259 | if (!programObject) |
| 4260 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4261 | if (context->getShader(program)) |
| 4262 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4263 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4264 | } |
| 4265 | else |
| 4266 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4267 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4268 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4269 | } |
| 4270 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4271 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 4272 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4273 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4274 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4275 | } |
| 4276 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4277 | return programBinary->getAttributeLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4278 | } |
| 4279 | } |
| 4280 | catch(std::bad_alloc&) |
| 4281 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4282 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4283 | } |
| 4284 | |
| 4285 | return -1; |
| 4286 | } |
| 4287 | |
| 4288 | void __stdcall glGetBooleanv(GLenum pname, GLboolean* params) |
| 4289 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4290 | 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] | 4291 | |
| 4292 | try |
| 4293 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4294 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4295 | |
| 4296 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4297 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4298 | if (!(context->getBooleanv(pname, params))) |
| 4299 | { |
| 4300 | GLenum nativeType; |
| 4301 | unsigned int numParams = 0; |
| 4302 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4303 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4304 | |
| 4305 | if (numParams == 0) |
| 4306 | return; // it is known that the pname is valid, but there are no parameters to return |
| 4307 | |
| 4308 | if (nativeType == GL_FLOAT) |
| 4309 | { |
| 4310 | GLfloat *floatParams = NULL; |
| 4311 | floatParams = new GLfloat[numParams]; |
| 4312 | |
| 4313 | context->getFloatv(pname, floatParams); |
| 4314 | |
| 4315 | for (unsigned int i = 0; i < numParams; ++i) |
| 4316 | { |
| 4317 | if (floatParams[i] == 0.0f) |
| 4318 | params[i] = GL_FALSE; |
| 4319 | else |
| 4320 | params[i] = GL_TRUE; |
| 4321 | } |
| 4322 | |
| 4323 | delete [] floatParams; |
| 4324 | } |
| 4325 | else if (nativeType == GL_INT) |
| 4326 | { |
| 4327 | GLint *intParams = NULL; |
| 4328 | intParams = new GLint[numParams]; |
| 4329 | |
| 4330 | context->getIntegerv(pname, intParams); |
| 4331 | |
| 4332 | for (unsigned int i = 0; i < numParams; ++i) |
| 4333 | { |
| 4334 | if (intParams[i] == 0) |
| 4335 | params[i] = GL_FALSE; |
| 4336 | else |
| 4337 | params[i] = GL_TRUE; |
| 4338 | } |
| 4339 | |
| 4340 | delete [] intParams; |
| 4341 | } |
| 4342 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4343 | } |
| 4344 | } |
| 4345 | catch(std::bad_alloc&) |
| 4346 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4347 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4348 | } |
| 4349 | } |
| 4350 | |
| 4351 | void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 4352 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4353 | 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] | 4354 | |
| 4355 | try |
| 4356 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4357 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4358 | |
| 4359 | if (context) |
| 4360 | { |
| 4361 | gl::Buffer *buffer; |
| 4362 | |
| 4363 | switch (target) |
| 4364 | { |
| 4365 | case GL_ARRAY_BUFFER: |
| 4366 | buffer = context->getArrayBuffer(); |
| 4367 | break; |
| 4368 | case GL_ELEMENT_ARRAY_BUFFER: |
| 4369 | buffer = context->getElementArrayBuffer(); |
| 4370 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4371 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4372 | } |
| 4373 | |
| 4374 | if (!buffer) |
| 4375 | { |
| 4376 | // 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] | 4377 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4378 | } |
| 4379 | |
| 4380 | switch (pname) |
| 4381 | { |
| 4382 | case GL_BUFFER_USAGE: |
| 4383 | *params = buffer->usage(); |
| 4384 | break; |
| 4385 | case GL_BUFFER_SIZE: |
| 4386 | *params = buffer->size(); |
| 4387 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4388 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4389 | } |
| 4390 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4391 | } |
| 4392 | catch(std::bad_alloc&) |
| 4393 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4394 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4395 | } |
| 4396 | } |
| 4397 | |
| 4398 | GLenum __stdcall glGetError(void) |
| 4399 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4400 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4401 | |
| 4402 | gl::Context *context = gl::getContext(); |
| 4403 | |
| 4404 | if (context) |
| 4405 | { |
daniel@transgaming.com | 82b2891 | 2011-12-12 21:01:35 +0000 | [diff] [blame] | 4406 | return context->getError(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4407 | } |
| 4408 | |
| 4409 | return GL_NO_ERROR; |
| 4410 | } |
| 4411 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4412 | void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 4413 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4414 | 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] | 4415 | |
| 4416 | try |
| 4417 | { |
| 4418 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4419 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4420 | |
| 4421 | if (context) |
| 4422 | { |
| 4423 | gl::Fence *fenceObject = context->getFence(fence); |
| 4424 | |
| 4425 | if (fenceObject == NULL) |
| 4426 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4427 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4428 | } |
| 4429 | |
| 4430 | fenceObject->getFenceiv(pname, params); |
| 4431 | } |
| 4432 | } |
| 4433 | catch(std::bad_alloc&) |
| 4434 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4435 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4436 | } |
| 4437 | } |
| 4438 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4439 | void __stdcall glGetFloatv(GLenum pname, GLfloat* params) |
| 4440 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4441 | 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] | 4442 | |
| 4443 | try |
| 4444 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4445 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4446 | |
| 4447 | if (context) |
| 4448 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4449 | if (!(context->getFloatv(pname, params))) |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4450 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4451 | GLenum nativeType; |
| 4452 | unsigned int numParams = 0; |
| 4453 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4454 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4455 | |
| 4456 | if (numParams == 0) |
| 4457 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 4458 | |
| 4459 | if (nativeType == GL_BOOL) |
| 4460 | { |
| 4461 | GLboolean *boolParams = NULL; |
| 4462 | boolParams = new GLboolean[numParams]; |
| 4463 | |
| 4464 | context->getBooleanv(pname, boolParams); |
| 4465 | |
| 4466 | for (unsigned int i = 0; i < numParams; ++i) |
| 4467 | { |
| 4468 | if (boolParams[i] == GL_FALSE) |
| 4469 | params[i] = 0.0f; |
| 4470 | else |
| 4471 | params[i] = 1.0f; |
| 4472 | } |
| 4473 | |
| 4474 | delete [] boolParams; |
| 4475 | } |
| 4476 | else if (nativeType == GL_INT) |
| 4477 | { |
| 4478 | GLint *intParams = NULL; |
| 4479 | intParams = new GLint[numParams]; |
| 4480 | |
| 4481 | context->getIntegerv(pname, intParams); |
| 4482 | |
| 4483 | for (unsigned int i = 0; i < numParams; ++i) |
| 4484 | { |
| 4485 | params[i] = (GLfloat)intParams[i]; |
| 4486 | } |
| 4487 | |
| 4488 | delete [] intParams; |
| 4489 | } |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4490 | } |
| 4491 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4492 | } |
| 4493 | catch(std::bad_alloc&) |
| 4494 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4495 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4496 | } |
| 4497 | } |
| 4498 | |
| 4499 | void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) |
| 4500 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4501 | 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] | 4502 | target, attachment, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4503 | |
| 4504 | try |
| 4505 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4506 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4507 | |
| 4508 | if (context) |
| 4509 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4510 | 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] | 4511 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4512 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4513 | } |
| 4514 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4515 | gl::Framebuffer *framebuffer = NULL; |
| 4516 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4517 | { |
| 4518 | if(context->getReadFramebufferHandle() == 0) |
| 4519 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4520 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4521 | } |
| 4522 | |
| 4523 | framebuffer = context->getReadFramebuffer(); |
| 4524 | } |
| 4525 | else |
| 4526 | { |
| 4527 | if (context->getDrawFramebufferHandle() == 0) |
| 4528 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4529 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4530 | } |
| 4531 | |
| 4532 | framebuffer = context->getDrawFramebuffer(); |
| 4533 | } |
| 4534 | |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4535 | GLenum attachmentType; |
| 4536 | GLuint attachmentHandle; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4537 | |
| 4538 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4539 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4540 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4541 | |
| 4542 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4543 | { |
| 4544 | return gl::error(GL_INVALID_ENUM); |
| 4545 | } |
| 4546 | |
| 4547 | attachmentType = framebuffer->getColorbufferType(colorAttachment); |
| 4548 | attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment); |
| 4549 | } |
| 4550 | else |
| 4551 | { |
| 4552 | switch (attachment) |
| 4553 | { |
| 4554 | case GL_DEPTH_ATTACHMENT: |
| 4555 | attachmentType = framebuffer->getDepthbufferType(); |
| 4556 | attachmentHandle = framebuffer->getDepthbufferHandle(); |
| 4557 | break; |
| 4558 | case GL_STENCIL_ATTACHMENT: |
| 4559 | attachmentType = framebuffer->getStencilbufferType(); |
| 4560 | attachmentHandle = framebuffer->getStencilbufferHandle(); |
| 4561 | break; |
| 4562 | default: return gl::error(GL_INVALID_ENUM); |
| 4563 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4564 | } |
| 4565 | |
| 4566 | GLenum attachmentObjectType; // Type category |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4567 | if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4568 | { |
| 4569 | attachmentObjectType = attachmentType; |
| 4570 | } |
apatrick@chromium.org | 551022e | 2012-01-23 19:56:54 +0000 | [diff] [blame] | 4571 | else if (gl::IsInternalTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4572 | { |
| 4573 | attachmentObjectType = GL_TEXTURE; |
| 4574 | } |
apatrick@chromium.org | a1d8059 | 2012-01-25 21:52:10 +0000 | [diff] [blame] | 4575 | else |
| 4576 | { |
| 4577 | UNREACHABLE(); |
| 4578 | return; |
| 4579 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4580 | |
| 4581 | switch (pname) |
| 4582 | { |
| 4583 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 4584 | *params = attachmentObjectType; |
| 4585 | break; |
| 4586 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 4587 | if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE) |
| 4588 | { |
| 4589 | *params = attachmentHandle; |
| 4590 | } |
| 4591 | else |
| 4592 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4593 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4594 | } |
| 4595 | break; |
| 4596 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 4597 | if (attachmentObjectType == GL_TEXTURE) |
| 4598 | { |
| 4599 | *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0 |
| 4600 | } |
| 4601 | else |
| 4602 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4603 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4604 | } |
| 4605 | break; |
| 4606 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 4607 | if (attachmentObjectType == GL_TEXTURE) |
| 4608 | { |
daniel@transgaming.com | 19ffc24 | 2010-05-04 03:35:21 +0000 | [diff] [blame] | 4609 | if (gl::IsCubemapTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4610 | { |
| 4611 | *params = attachmentType; |
| 4612 | } |
| 4613 | else |
| 4614 | { |
| 4615 | *params = 0; |
| 4616 | } |
| 4617 | } |
| 4618 | else |
| 4619 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4620 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4621 | } |
| 4622 | break; |
| 4623 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4624 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4625 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4626 | } |
| 4627 | } |
| 4628 | catch(std::bad_alloc&) |
| 4629 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4630 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4631 | } |
| 4632 | } |
| 4633 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 4634 | GLenum __stdcall glGetGraphicsResetStatusEXT(void) |
| 4635 | { |
| 4636 | EVENT("()"); |
| 4637 | |
| 4638 | try |
| 4639 | { |
| 4640 | gl::Context *context = gl::getContext(); |
| 4641 | |
| 4642 | if (context) |
| 4643 | { |
| 4644 | return context->getResetStatus(); |
| 4645 | } |
| 4646 | |
| 4647 | return GL_NO_ERROR; |
| 4648 | } |
| 4649 | catch(std::bad_alloc&) |
| 4650 | { |
| 4651 | return GL_OUT_OF_MEMORY; |
| 4652 | } |
| 4653 | } |
| 4654 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4655 | void __stdcall glGetIntegerv(GLenum pname, GLint* params) |
| 4656 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4657 | 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] | 4658 | |
| 4659 | try |
| 4660 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4661 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4662 | |
| 4663 | if (context) |
| 4664 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4665 | if (!(context->getIntegerv(pname, params))) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4666 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4667 | GLenum nativeType; |
| 4668 | unsigned int numParams = 0; |
| 4669 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4670 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4671 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4672 | if (numParams == 0) |
| 4673 | return; // it is known that pname is valid, but there are no parameters to return |
| 4674 | |
| 4675 | if (nativeType == GL_BOOL) |
| 4676 | { |
| 4677 | GLboolean *boolParams = NULL; |
| 4678 | boolParams = new GLboolean[numParams]; |
| 4679 | |
| 4680 | context->getBooleanv(pname, boolParams); |
| 4681 | |
| 4682 | for (unsigned int i = 0; i < numParams; ++i) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4683 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4684 | if (boolParams[i] == GL_FALSE) |
| 4685 | params[i] = 0; |
| 4686 | else |
| 4687 | params[i] = 1; |
| 4688 | } |
| 4689 | |
| 4690 | delete [] boolParams; |
| 4691 | } |
| 4692 | else if (nativeType == GL_FLOAT) |
| 4693 | { |
| 4694 | GLfloat *floatParams = NULL; |
| 4695 | floatParams = new GLfloat[numParams]; |
| 4696 | |
| 4697 | context->getFloatv(pname, floatParams); |
| 4698 | |
| 4699 | for (unsigned int i = 0; i < numParams; ++i) |
| 4700 | { |
daniel@transgaming.com | c164135 | 2010-04-26 15:33:36 +0000 | [diff] [blame] | 4701 | 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] | 4702 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4703 | params[i] = (GLint)(((GLfloat)(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4704 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4705 | else |
| 4706 | params[i] = (GLint)(floatParams[i] > 0.0f ? floor(floatParams[i] + 0.5) : ceil(floatParams[i] - 0.5)); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4707 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4708 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4709 | delete [] floatParams; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4710 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4711 | } |
| 4712 | } |
| 4713 | } |
| 4714 | catch(std::bad_alloc&) |
| 4715 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4716 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4717 | } |
| 4718 | } |
| 4719 | |
| 4720 | void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params) |
| 4721 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4722 | 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] | 4723 | |
| 4724 | try |
| 4725 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4726 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4727 | |
| 4728 | if (context) |
| 4729 | { |
| 4730 | gl::Program *programObject = context->getProgram(program); |
| 4731 | |
| 4732 | if (!programObject) |
| 4733 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4734 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4735 | } |
| 4736 | |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 4737 | if (context->getClientVersion() < 3) |
| 4738 | { |
| 4739 | switch (pname) |
| 4740 | { |
| 4741 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 4742 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 4743 | return gl::error(GL_INVALID_ENUM); |
| 4744 | } |
| 4745 | } |
| 4746 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4747 | switch (pname) |
| 4748 | { |
| 4749 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4750 | *params = programObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4751 | return; |
| 4752 | case GL_LINK_STATUS: |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 4753 | *params = programObject->isLinked(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4754 | return; |
| 4755 | case GL_VALIDATE_STATUS: |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 4756 | *params = programObject->isValidated(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4757 | return; |
| 4758 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4759 | *params = programObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4760 | return; |
| 4761 | case GL_ATTACHED_SHADERS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4762 | *params = programObject->getAttachedShadersCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4763 | return; |
| 4764 | case GL_ACTIVE_ATTRIBUTES: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4765 | *params = programObject->getActiveAttributeCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4766 | return; |
| 4767 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4768 | *params = programObject->getActiveAttributeMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4769 | return; |
| 4770 | case GL_ACTIVE_UNIFORMS: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4771 | *params = programObject->getActiveUniformCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4772 | return; |
| 4773 | case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4774 | *params = programObject->getActiveUniformMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4775 | return; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 4776 | case GL_PROGRAM_BINARY_LENGTH_OES: |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 4777 | *params = programObject->getProgramBinaryLength(); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 4778 | return; |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 4779 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 4780 | *params = programObject->getActiveUniformBlockCount(); |
| 4781 | return; |
| 4782 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 4783 | *params = programObject->getActiveUniformBlockMaxLength(); |
| 4784 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4785 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4786 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4787 | } |
| 4788 | } |
| 4789 | } |
| 4790 | catch(std::bad_alloc&) |
| 4791 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4792 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4793 | } |
| 4794 | } |
| 4795 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4796 | void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4797 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4798 | 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] | 4799 | program, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4800 | |
| 4801 | try |
| 4802 | { |
| 4803 | if (bufsize < 0) |
| 4804 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4805 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4806 | } |
| 4807 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4808 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4809 | |
| 4810 | if (context) |
| 4811 | { |
| 4812 | gl::Program *programObject = context->getProgram(program); |
| 4813 | |
| 4814 | if (!programObject) |
| 4815 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4816 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4817 | } |
| 4818 | |
| 4819 | programObject->getInfoLog(bufsize, length, infolog); |
| 4820 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4821 | } |
| 4822 | catch(std::bad_alloc&) |
| 4823 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4824 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4825 | } |
| 4826 | } |
| 4827 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4828 | void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params) |
| 4829 | { |
| 4830 | EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params); |
| 4831 | |
| 4832 | try |
| 4833 | { |
| 4834 | switch (pname) |
| 4835 | { |
| 4836 | case GL_CURRENT_QUERY_EXT: |
| 4837 | break; |
| 4838 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4839 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4840 | } |
| 4841 | |
| 4842 | gl::Context *context = gl::getNonLostContext(); |
| 4843 | |
| 4844 | if (context) |
| 4845 | { |
| 4846 | params[0] = context->getActiveQuery(target); |
| 4847 | } |
| 4848 | } |
| 4849 | catch(std::bad_alloc&) |
| 4850 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4851 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4852 | } |
| 4853 | } |
| 4854 | |
| 4855 | void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) |
| 4856 | { |
| 4857 | EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params); |
| 4858 | |
| 4859 | try |
| 4860 | { |
| 4861 | switch (pname) |
| 4862 | { |
| 4863 | case GL_QUERY_RESULT_EXT: |
| 4864 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 4865 | break; |
| 4866 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4867 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4868 | } |
| 4869 | gl::Context *context = gl::getNonLostContext(); |
| 4870 | |
| 4871 | if (context) |
| 4872 | { |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4873 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 4874 | |
| 4875 | if (!queryObject) |
| 4876 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4877 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4878 | } |
| 4879 | |
| 4880 | if (context->getActiveQuery(queryObject->getType()) == id) |
| 4881 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4882 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4883 | } |
| 4884 | |
| 4885 | switch(pname) |
| 4886 | { |
| 4887 | case GL_QUERY_RESULT_EXT: |
| 4888 | params[0] = queryObject->getResult(); |
| 4889 | break; |
| 4890 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 4891 | params[0] = queryObject->isResultAvailable(); |
| 4892 | break; |
| 4893 | default: |
| 4894 | ASSERT(false); |
| 4895 | } |
| 4896 | } |
| 4897 | } |
| 4898 | catch(std::bad_alloc&) |
| 4899 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4900 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4901 | } |
| 4902 | } |
| 4903 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4904 | void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 4905 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4906 | 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] | 4907 | |
| 4908 | try |
| 4909 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4910 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4911 | |
| 4912 | if (context) |
| 4913 | { |
| 4914 | if (target != GL_RENDERBUFFER) |
| 4915 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4916 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4917 | } |
| 4918 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4919 | if (context->getRenderbufferHandle() == 0) |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4920 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4921 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4922 | } |
| 4923 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4924 | gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle()); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4925 | |
| 4926 | switch (pname) |
| 4927 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 4928 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break; |
| 4929 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break; |
| 4930 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break; |
| 4931 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break; |
| 4932 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break; |
| 4933 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break; |
| 4934 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break; |
| 4935 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break; |
| 4936 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break; |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 4937 | case GL_RENDERBUFFER_SAMPLES_ANGLE: |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 4938 | if (context->getMaxSupportedSamples() != 0) |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 4939 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 4940 | *params = renderbuffer->getSamples(); |
| 4941 | } |
| 4942 | else |
| 4943 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4944 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 4945 | } |
| 4946 | break; |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4947 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4948 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4949 | } |
| 4950 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4951 | } |
| 4952 | catch(std::bad_alloc&) |
| 4953 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4954 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4955 | } |
| 4956 | } |
| 4957 | |
| 4958 | void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params) |
| 4959 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4960 | 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] | 4961 | |
| 4962 | try |
| 4963 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4964 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4965 | |
| 4966 | if (context) |
| 4967 | { |
| 4968 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 4969 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4970 | if (!shaderObject) |
| 4971 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4972 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4973 | } |
| 4974 | |
| 4975 | switch (pname) |
| 4976 | { |
| 4977 | case GL_SHADER_TYPE: |
| 4978 | *params = shaderObject->getType(); |
| 4979 | return; |
| 4980 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4981 | *params = shaderObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4982 | return; |
| 4983 | case GL_COMPILE_STATUS: |
| 4984 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; |
| 4985 | return; |
| 4986 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4987 | *params = shaderObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4988 | return; |
| 4989 | case GL_SHADER_SOURCE_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4990 | *params = shaderObject->getSourceLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4991 | return; |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 4992 | case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: |
| 4993 | *params = shaderObject->getTranslatedSourceLength(); |
| 4994 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4995 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4996 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4997 | } |
| 4998 | } |
| 4999 | } |
| 5000 | catch(std::bad_alloc&) |
| 5001 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5002 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5003 | } |
| 5004 | } |
| 5005 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5006 | void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5007 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5008 | 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] | 5009 | shader, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5010 | |
| 5011 | try |
| 5012 | { |
| 5013 | if (bufsize < 0) |
| 5014 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5015 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5016 | } |
| 5017 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5018 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5019 | |
| 5020 | if (context) |
| 5021 | { |
| 5022 | gl::Shader *shaderObject = context->getShader(shader); |
| 5023 | |
| 5024 | if (!shaderObject) |
| 5025 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5026 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5027 | } |
| 5028 | |
| 5029 | shaderObject->getInfoLog(bufsize, length, infolog); |
| 5030 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5031 | } |
| 5032 | catch(std::bad_alloc&) |
| 5033 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5034 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5035 | } |
| 5036 | } |
| 5037 | |
| 5038 | void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) |
| 5039 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5040 | 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] | 5041 | shadertype, precisiontype, range, precision); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5042 | |
| 5043 | try |
| 5044 | { |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5045 | switch (shadertype) |
| 5046 | { |
| 5047 | case GL_VERTEX_SHADER: |
| 5048 | case GL_FRAGMENT_SHADER: |
| 5049 | break; |
| 5050 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5051 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5052 | } |
| 5053 | |
| 5054 | switch (precisiontype) |
| 5055 | { |
| 5056 | case GL_LOW_FLOAT: |
| 5057 | case GL_MEDIUM_FLOAT: |
| 5058 | case GL_HIGH_FLOAT: |
| 5059 | // Assume IEEE 754 precision |
| 5060 | range[0] = 127; |
| 5061 | range[1] = 127; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5062 | *precision = 23; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5063 | break; |
| 5064 | case GL_LOW_INT: |
| 5065 | case GL_MEDIUM_INT: |
| 5066 | case GL_HIGH_INT: |
| 5067 | // Some (most) hardware only supports single-precision floating-point numbers, |
| 5068 | // which can accurately represent integers up to +/-16777216 |
| 5069 | range[0] = 24; |
| 5070 | range[1] = 24; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5071 | *precision = 0; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5072 | break; |
| 5073 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5074 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5075 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5076 | } |
| 5077 | catch(std::bad_alloc&) |
| 5078 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5079 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5080 | } |
| 5081 | } |
| 5082 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5083 | void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5084 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5085 | 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] | 5086 | shader, bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5087 | |
| 5088 | try |
| 5089 | { |
| 5090 | if (bufsize < 0) |
| 5091 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5092 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5093 | } |
| 5094 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5095 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5096 | |
| 5097 | if (context) |
| 5098 | { |
| 5099 | gl::Shader *shaderObject = context->getShader(shader); |
| 5100 | |
| 5101 | if (!shaderObject) |
| 5102 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5103 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5104 | } |
| 5105 | |
| 5106 | shaderObject->getSource(bufsize, length, source); |
| 5107 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5108 | } |
| 5109 | catch(std::bad_alloc&) |
| 5110 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5111 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5112 | } |
| 5113 | } |
| 5114 | |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5115 | void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
| 5116 | { |
| 5117 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)", |
| 5118 | shader, bufsize, length, source); |
| 5119 | |
| 5120 | try |
| 5121 | { |
| 5122 | if (bufsize < 0) |
| 5123 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5124 | return gl::error(GL_INVALID_VALUE); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5125 | } |
| 5126 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5127 | gl::Context *context = gl::getNonLostContext(); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5128 | |
| 5129 | if (context) |
| 5130 | { |
| 5131 | gl::Shader *shaderObject = context->getShader(shader); |
| 5132 | |
| 5133 | if (!shaderObject) |
| 5134 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5135 | return gl::error(GL_INVALID_OPERATION); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5136 | } |
| 5137 | |
| 5138 | shaderObject->getTranslatedSource(bufsize, length, source); |
| 5139 | } |
| 5140 | } |
| 5141 | catch(std::bad_alloc&) |
| 5142 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5143 | return gl::error(GL_OUT_OF_MEMORY); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5144 | } |
| 5145 | } |
| 5146 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5147 | const GLubyte* __stdcall glGetString(GLenum name) |
| 5148 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5149 | EVENT("(GLenum name = 0x%X)", name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5150 | |
| 5151 | try |
| 5152 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5153 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3e4c600 | 2010-05-05 18:50:13 +0000 | [diff] [blame] | 5154 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5155 | switch (name) |
| 5156 | { |
| 5157 | case GL_VENDOR: |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 5158 | return (GLubyte*)"Google Inc."; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5159 | case GL_RENDERER: |
daniel@transgaming.com | c23ff64 | 2011-08-16 20:28:45 +0000 | [diff] [blame] | 5160 | return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5161 | case GL_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5162 | if (context->getClientVersion() == 2) |
| 5163 | { |
| 5164 | return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")"; |
| 5165 | } |
| 5166 | else |
| 5167 | { |
| 5168 | return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")"; |
| 5169 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5170 | case GL_SHADING_LANGUAGE_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5171 | if (context->getClientVersion() == 2) |
| 5172 | { |
| 5173 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")"; |
| 5174 | } |
| 5175 | else |
| 5176 | { |
| 5177 | return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")"; |
| 5178 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5179 | case GL_EXTENSIONS: |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 5180 | return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : ""); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5181 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5182 | return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5183 | } |
| 5184 | } |
| 5185 | catch(std::bad_alloc&) |
| 5186 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5187 | return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5188 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5189 | } |
| 5190 | |
| 5191 | void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) |
| 5192 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5193 | 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] | 5194 | |
| 5195 | try |
| 5196 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5197 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5198 | |
| 5199 | if (context) |
| 5200 | { |
| 5201 | gl::Texture *texture; |
| 5202 | |
| 5203 | switch (target) |
| 5204 | { |
| 5205 | case GL_TEXTURE_2D: |
| 5206 | texture = context->getTexture2D(); |
| 5207 | break; |
| 5208 | case GL_TEXTURE_CUBE_MAP: |
| 5209 | texture = context->getTextureCubeMap(); |
| 5210 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5211 | case GL_TEXTURE_3D: |
| 5212 | if (context->getClientVersion() < 3) |
| 5213 | { |
| 5214 | return gl::error(GL_INVALID_ENUM); |
| 5215 | } |
| 5216 | texture = context->getTexture3D(); |
| 5217 | break; |
shannonwoods@chromium.org | 0c611d1 | 2013-05-30 00:15:05 +0000 | [diff] [blame] | 5218 | case GL_TEXTURE_2D_ARRAY: |
| 5219 | if (context->getClientVersion() < 3) |
| 5220 | { |
| 5221 | return gl::error(GL_INVALID_ENUM); |
| 5222 | } |
| 5223 | texture = context->getTexture2DArray(); |
| 5224 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5225 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5226 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5227 | } |
| 5228 | |
| 5229 | switch (pname) |
| 5230 | { |
| 5231 | case GL_TEXTURE_MAG_FILTER: |
| 5232 | *params = (GLfloat)texture->getMagFilter(); |
| 5233 | break; |
| 5234 | case GL_TEXTURE_MIN_FILTER: |
| 5235 | *params = (GLfloat)texture->getMinFilter(); |
| 5236 | break; |
| 5237 | case GL_TEXTURE_WRAP_S: |
| 5238 | *params = (GLfloat)texture->getWrapS(); |
| 5239 | break; |
| 5240 | case GL_TEXTURE_WRAP_T: |
| 5241 | *params = (GLfloat)texture->getWrapT(); |
| 5242 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5243 | case GL_TEXTURE_WRAP_R: |
| 5244 | if (context->getClientVersion() < 3) |
| 5245 | { |
| 5246 | return gl::error(GL_INVALID_ENUM); |
| 5247 | } |
| 5248 | *params = (GLfloat)texture->getWrapR(); |
| 5249 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5250 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5251 | // 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] | 5252 | *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE); |
| 5253 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5254 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5255 | if (context->getClientVersion() < 3) |
| 5256 | { |
| 5257 | return gl::error(GL_INVALID_ENUM); |
| 5258 | } |
| 5259 | *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0); |
| 5260 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5261 | case GL_TEXTURE_USAGE_ANGLE: |
| 5262 | *params = (GLfloat)texture->getUsage(); |
| 5263 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5264 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5265 | if (!context->supportsTextureFilterAnisotropy()) |
| 5266 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5267 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5268 | } |
| 5269 | *params = (GLfloat)texture->getMaxAnisotropy(); |
| 5270 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5271 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5272 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5273 | } |
| 5274 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5275 | } |
| 5276 | catch(std::bad_alloc&) |
| 5277 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5278 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5279 | } |
| 5280 | } |
| 5281 | |
| 5282 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5283 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5284 | 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] | 5285 | |
| 5286 | try |
| 5287 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5288 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5289 | |
| 5290 | if (context) |
| 5291 | { |
| 5292 | gl::Texture *texture; |
| 5293 | |
| 5294 | switch (target) |
| 5295 | { |
| 5296 | case GL_TEXTURE_2D: |
| 5297 | texture = context->getTexture2D(); |
| 5298 | break; |
| 5299 | case GL_TEXTURE_CUBE_MAP: |
| 5300 | texture = context->getTextureCubeMap(); |
| 5301 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5302 | case GL_TEXTURE_3D: |
| 5303 | if (context->getClientVersion() < 3) |
| 5304 | { |
| 5305 | return gl::error(GL_INVALID_ENUM); |
| 5306 | } |
| 5307 | texture = context->getTexture3D(); |
| 5308 | break; |
shannonwoods@chromium.org | 0c611d1 | 2013-05-30 00:15:05 +0000 | [diff] [blame] | 5309 | case GL_TEXTURE_2D_ARRAY: |
| 5310 | if (context->getClientVersion() < 3) |
| 5311 | { |
| 5312 | return gl::error(GL_INVALID_ENUM); |
| 5313 | } |
| 5314 | texture = context->getTexture2DArray(); |
| 5315 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5316 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5317 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5318 | } |
| 5319 | |
| 5320 | switch (pname) |
| 5321 | { |
| 5322 | case GL_TEXTURE_MAG_FILTER: |
| 5323 | *params = texture->getMagFilter(); |
| 5324 | break; |
| 5325 | case GL_TEXTURE_MIN_FILTER: |
| 5326 | *params = texture->getMinFilter(); |
| 5327 | break; |
| 5328 | case GL_TEXTURE_WRAP_S: |
| 5329 | *params = texture->getWrapS(); |
| 5330 | break; |
| 5331 | case GL_TEXTURE_WRAP_T: |
| 5332 | *params = texture->getWrapT(); |
| 5333 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5334 | case GL_TEXTURE_WRAP_R: |
| 5335 | if (context->getClientVersion() < 3) |
| 5336 | { |
| 5337 | return gl::error(GL_INVALID_ENUM); |
| 5338 | } |
| 5339 | *params = texture->getWrapR(); |
| 5340 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5341 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5342 | // 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] | 5343 | *params = texture->isImmutable() ? GL_TRUE : GL_FALSE; |
| 5344 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5345 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5346 | if (context->getClientVersion() < 3) |
| 5347 | { |
| 5348 | return gl::error(GL_INVALID_ENUM); |
| 5349 | } |
| 5350 | *params = texture->isImmutable() ? texture->levelCount() : 0; |
| 5351 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5352 | case GL_TEXTURE_USAGE_ANGLE: |
| 5353 | *params = texture->getUsage(); |
| 5354 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5355 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5356 | if (!context->supportsTextureFilterAnisotropy()) |
| 5357 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5358 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5359 | } |
| 5360 | *params = (GLint)texture->getMaxAnisotropy(); |
| 5361 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 5362 | |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5363 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5364 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5365 | } |
| 5366 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5367 | } |
| 5368 | catch(std::bad_alloc&) |
| 5369 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5370 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5371 | } |
| 5372 | } |
| 5373 | |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5374 | void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
| 5375 | { |
| 5376 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)", |
| 5377 | program, location, bufSize, params); |
| 5378 | |
| 5379 | try |
| 5380 | { |
| 5381 | if (bufSize < 0) |
| 5382 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5383 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5384 | } |
| 5385 | |
| 5386 | gl::Context *context = gl::getNonLostContext(); |
| 5387 | |
| 5388 | if (context) |
| 5389 | { |
| 5390 | if (program == 0) |
| 5391 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5392 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5393 | } |
| 5394 | |
| 5395 | gl::Program *programObject = context->getProgram(program); |
| 5396 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5397 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5398 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5399 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5400 | } |
| 5401 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5402 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5403 | if (!programBinary) |
| 5404 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5405 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5406 | } |
| 5407 | |
| 5408 | if (!programBinary->getUniformfv(location, &bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5409 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5410 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5411 | } |
| 5412 | } |
| 5413 | } |
| 5414 | catch(std::bad_alloc&) |
| 5415 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5416 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5417 | } |
| 5418 | } |
| 5419 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5420 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 5421 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5422 | 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] | 5423 | |
| 5424 | try |
| 5425 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5426 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5427 | |
| 5428 | if (context) |
| 5429 | { |
| 5430 | if (program == 0) |
| 5431 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5432 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5433 | } |
| 5434 | |
| 5435 | gl::Program *programObject = context->getProgram(program); |
| 5436 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5437 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5438 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5439 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5440 | } |
| 5441 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5442 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5443 | if (!programBinary) |
| 5444 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5445 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5446 | } |
| 5447 | |
| 5448 | if (!programBinary->getUniformfv(location, NULL, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5449 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5450 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5451 | } |
| 5452 | } |
| 5453 | } |
| 5454 | catch(std::bad_alloc&) |
| 5455 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5456 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5457 | } |
| 5458 | } |
| 5459 | |
| 5460 | void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) |
| 5461 | { |
| 5462 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)", |
| 5463 | program, location, bufSize, params); |
| 5464 | |
| 5465 | try |
| 5466 | { |
| 5467 | if (bufSize < 0) |
| 5468 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5469 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5470 | } |
| 5471 | |
| 5472 | gl::Context *context = gl::getNonLostContext(); |
| 5473 | |
| 5474 | if (context) |
| 5475 | { |
| 5476 | if (program == 0) |
| 5477 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5478 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5479 | } |
| 5480 | |
| 5481 | gl::Program *programObject = context->getProgram(program); |
| 5482 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5483 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5484 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5485 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5486 | } |
| 5487 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5488 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5489 | if (!programBinary) |
| 5490 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5491 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5492 | } |
| 5493 | |
| 5494 | if (!programBinary->getUniformiv(location, &bufSize, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5495 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5496 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5497 | } |
| 5498 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5499 | } |
| 5500 | catch(std::bad_alloc&) |
| 5501 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5502 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5503 | } |
| 5504 | } |
| 5505 | |
| 5506 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 5507 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5508 | 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] | 5509 | |
| 5510 | try |
| 5511 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5512 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5513 | |
| 5514 | if (context) |
| 5515 | { |
| 5516 | if (program == 0) |
| 5517 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5518 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5519 | } |
| 5520 | |
| 5521 | gl::Program *programObject = context->getProgram(program); |
| 5522 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5523 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5524 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5525 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5526 | } |
| 5527 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5528 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5529 | if (!programBinary) |
| 5530 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5531 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5532 | } |
| 5533 | |
| 5534 | if (!programBinary->getUniformiv(location, NULL, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5535 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5536 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5537 | } |
| 5538 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5539 | } |
| 5540 | catch(std::bad_alloc&) |
| 5541 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5542 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5543 | } |
| 5544 | } |
| 5545 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5546 | int __stdcall glGetUniformLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5547 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5548 | 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] | 5549 | |
| 5550 | try |
| 5551 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5552 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5553 | |
| 5554 | if (strstr(name, "gl_") == name) |
| 5555 | { |
| 5556 | return -1; |
| 5557 | } |
| 5558 | |
| 5559 | if (context) |
| 5560 | { |
| 5561 | gl::Program *programObject = context->getProgram(program); |
| 5562 | |
| 5563 | if (!programObject) |
| 5564 | { |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5565 | if (context->getShader(program)) |
| 5566 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5567 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5568 | } |
| 5569 | else |
| 5570 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5571 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5572 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5573 | } |
| 5574 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5575 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5576 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5577 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5578 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5579 | } |
| 5580 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5581 | return programBinary->getUniformLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5582 | } |
| 5583 | } |
| 5584 | catch(std::bad_alloc&) |
| 5585 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5586 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5587 | } |
| 5588 | |
| 5589 | return -1; |
| 5590 | } |
| 5591 | |
| 5592 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 5593 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5594 | 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] | 5595 | |
| 5596 | try |
| 5597 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5598 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5599 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5600 | if (context) |
| 5601 | { |
| 5602 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5603 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5604 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5605 | } |
| 5606 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5607 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5608 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5609 | switch (pname) |
| 5610 | { |
| 5611 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5612 | *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5613 | break; |
| 5614 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5615 | *params = (GLfloat)attribState.mSize; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5616 | break; |
| 5617 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5618 | *params = (GLfloat)attribState.mStride; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5619 | break; |
| 5620 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5621 | *params = (GLfloat)attribState.mType; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5622 | break; |
| 5623 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5624 | *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5625 | break; |
| 5626 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 5627 | *params = (GLfloat)attribState.mBoundBuffer.id(); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5628 | break; |
| 5629 | case GL_CURRENT_VERTEX_ATTRIB: |
| 5630 | for (int i = 0; i < 4; ++i) |
| 5631 | { |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame] | 5632 | params[i] = attribState.mCurrentValue.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5633 | } |
| 5634 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 5635 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 5636 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 5637 | // the same constant. |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 5638 | *params = (GLfloat)attribState.mDivisor; |
| 5639 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5640 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5641 | } |
| 5642 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5643 | } |
| 5644 | catch(std::bad_alloc&) |
| 5645 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5646 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5647 | } |
| 5648 | } |
| 5649 | |
| 5650 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 5651 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5652 | 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] | 5653 | |
| 5654 | try |
| 5655 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5656 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5657 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5658 | if (context) |
| 5659 | { |
| 5660 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5661 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5662 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5663 | } |
| 5664 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5665 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5666 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5667 | switch (pname) |
| 5668 | { |
| 5669 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5670 | *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5671 | break; |
| 5672 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5673 | *params = attribState.mSize; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5674 | break; |
| 5675 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5676 | *params = attribState.mStride; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5677 | break; |
| 5678 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5679 | *params = attribState.mType; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5680 | break; |
| 5681 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5682 | *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5683 | break; |
| 5684 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 5685 | *params = attribState.mBoundBuffer.id(); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5686 | break; |
| 5687 | case GL_CURRENT_VERTEX_ATTRIB: |
| 5688 | for (int i = 0; i < 4; ++i) |
| 5689 | { |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame] | 5690 | float currentValue = attribState.mCurrentValue.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5691 | params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f)); |
| 5692 | } |
| 5693 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 5694 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 5695 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 5696 | // the same constant. |
| 5697 | META_ASSERT(GL_VERTEX_ATTRIB_ARRAY_DIVISOR == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 5698 | *params = (GLint)attribState.mDivisor; |
| 5699 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5700 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5701 | } |
| 5702 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5703 | } |
| 5704 | catch(std::bad_alloc&) |
| 5705 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5706 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5707 | } |
| 5708 | } |
| 5709 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5710 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5711 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5712 | 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] | 5713 | |
| 5714 | try |
| 5715 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5716 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5717 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5718 | if (context) |
| 5719 | { |
| 5720 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5721 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5722 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5723 | } |
| 5724 | |
| 5725 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) |
| 5726 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5727 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5728 | } |
| 5729 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5730 | *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index)); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5731 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5732 | } |
| 5733 | catch(std::bad_alloc&) |
| 5734 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5735 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5736 | } |
| 5737 | } |
| 5738 | |
| 5739 | void __stdcall glHint(GLenum target, GLenum mode) |
| 5740 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5741 | EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5742 | |
| 5743 | try |
| 5744 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5745 | switch (mode) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5746 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5747 | case GL_FASTEST: |
| 5748 | case GL_NICEST: |
| 5749 | case GL_DONT_CARE: |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5750 | break; |
| 5751 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5752 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5753 | } |
| 5754 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5755 | gl::Context *context = gl::getNonLostContext(); |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5756 | switch (target) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5757 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5758 | case GL_GENERATE_MIPMAP_HINT: |
| 5759 | if (context) context->setGenerateMipmapHint(mode); |
| 5760 | break; |
| 5761 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 5762 | if (context) context->setFragmentShaderDerivativeHint(mode); |
| 5763 | break; |
| 5764 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5765 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5766 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5767 | } |
| 5768 | catch(std::bad_alloc&) |
| 5769 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5770 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5771 | } |
| 5772 | } |
| 5773 | |
| 5774 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 5775 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5776 | EVENT("(GLuint buffer = %d)", buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5777 | |
| 5778 | try |
| 5779 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5780 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5781 | |
| 5782 | if (context && buffer) |
| 5783 | { |
| 5784 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 5785 | |
| 5786 | if (bufferObject) |
| 5787 | { |
| 5788 | return GL_TRUE; |
| 5789 | } |
| 5790 | } |
| 5791 | } |
| 5792 | catch(std::bad_alloc&) |
| 5793 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5794 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5795 | } |
| 5796 | |
| 5797 | return GL_FALSE; |
| 5798 | } |
| 5799 | |
| 5800 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 5801 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5802 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5803 | |
| 5804 | try |
| 5805 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5806 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5807 | |
| 5808 | if (context) |
| 5809 | { |
| 5810 | switch (cap) |
| 5811 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5812 | case GL_CULL_FACE: return context->isCullFaceEnabled(); |
| 5813 | case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled(); |
| 5814 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled(); |
| 5815 | case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled(); |
| 5816 | case GL_SCISSOR_TEST: return context->isScissorTestEnabled(); |
| 5817 | case GL_STENCIL_TEST: return context->isStencilTestEnabled(); |
| 5818 | case GL_DEPTH_TEST: return context->isDepthTestEnabled(); |
| 5819 | case GL_BLEND: return context->isBlendEnabled(); |
| 5820 | case GL_DITHER: return context->isDitherEnabled(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5821 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5822 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5823 | } |
| 5824 | } |
| 5825 | } |
| 5826 | catch(std::bad_alloc&) |
| 5827 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5828 | return gl::error(GL_OUT_OF_MEMORY, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5829 | } |
| 5830 | |
| 5831 | return false; |
| 5832 | } |
| 5833 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 5834 | GLboolean __stdcall glIsFenceNV(GLuint fence) |
| 5835 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5836 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5837 | |
| 5838 | try |
| 5839 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5840 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5841 | |
| 5842 | if (context) |
| 5843 | { |
| 5844 | gl::Fence *fenceObject = context->getFence(fence); |
| 5845 | |
| 5846 | if (fenceObject == NULL) |
| 5847 | { |
| 5848 | return GL_FALSE; |
| 5849 | } |
| 5850 | |
| 5851 | return fenceObject->isFence(); |
| 5852 | } |
| 5853 | } |
| 5854 | catch(std::bad_alloc&) |
| 5855 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5856 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5857 | } |
| 5858 | |
| 5859 | return GL_FALSE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 5860 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5861 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5862 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 5863 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5864 | EVENT("(GLuint framebuffer = %d)", framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5865 | |
| 5866 | try |
| 5867 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5868 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5869 | |
| 5870 | if (context && framebuffer) |
| 5871 | { |
| 5872 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 5873 | |
| 5874 | if (framebufferObject) |
| 5875 | { |
| 5876 | return GL_TRUE; |
| 5877 | } |
| 5878 | } |
| 5879 | } |
| 5880 | catch(std::bad_alloc&) |
| 5881 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5882 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5883 | } |
| 5884 | |
| 5885 | return GL_FALSE; |
| 5886 | } |
| 5887 | |
| 5888 | GLboolean __stdcall glIsProgram(GLuint program) |
| 5889 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5890 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5891 | |
| 5892 | try |
| 5893 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5894 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5895 | |
| 5896 | if (context && program) |
| 5897 | { |
| 5898 | gl::Program *programObject = context->getProgram(program); |
| 5899 | |
| 5900 | if (programObject) |
| 5901 | { |
| 5902 | return GL_TRUE; |
| 5903 | } |
| 5904 | } |
| 5905 | } |
| 5906 | catch(std::bad_alloc&) |
| 5907 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5908 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5909 | } |
| 5910 | |
| 5911 | return GL_FALSE; |
| 5912 | } |
| 5913 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5914 | GLboolean __stdcall glIsQueryEXT(GLuint id) |
| 5915 | { |
| 5916 | EVENT("(GLuint id = %d)", id); |
| 5917 | |
| 5918 | try |
| 5919 | { |
| 5920 | if (id == 0) |
| 5921 | { |
| 5922 | return GL_FALSE; |
| 5923 | } |
| 5924 | |
| 5925 | gl::Context *context = gl::getNonLostContext(); |
| 5926 | |
| 5927 | if (context) |
| 5928 | { |
| 5929 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 5930 | |
| 5931 | if (queryObject) |
| 5932 | { |
| 5933 | return GL_TRUE; |
| 5934 | } |
| 5935 | } |
| 5936 | } |
| 5937 | catch(std::bad_alloc&) |
| 5938 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5939 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5940 | } |
| 5941 | |
| 5942 | return GL_FALSE; |
| 5943 | } |
| 5944 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5945 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 5946 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5947 | EVENT("(GLuint renderbuffer = %d)", renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5948 | |
| 5949 | try |
| 5950 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5951 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5952 | |
| 5953 | if (context && renderbuffer) |
| 5954 | { |
| 5955 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 5956 | |
| 5957 | if (renderbufferObject) |
| 5958 | { |
| 5959 | return GL_TRUE; |
| 5960 | } |
| 5961 | } |
| 5962 | } |
| 5963 | catch(std::bad_alloc&) |
| 5964 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5965 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5966 | } |
| 5967 | |
| 5968 | return GL_FALSE; |
| 5969 | } |
| 5970 | |
| 5971 | GLboolean __stdcall glIsShader(GLuint shader) |
| 5972 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5973 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5974 | |
| 5975 | try |
| 5976 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5977 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5978 | |
| 5979 | if (context && shader) |
| 5980 | { |
| 5981 | gl::Shader *shaderObject = context->getShader(shader); |
| 5982 | |
| 5983 | if (shaderObject) |
| 5984 | { |
| 5985 | return GL_TRUE; |
| 5986 | } |
| 5987 | } |
| 5988 | } |
| 5989 | catch(std::bad_alloc&) |
| 5990 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5991 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5992 | } |
| 5993 | |
| 5994 | return GL_FALSE; |
| 5995 | } |
| 5996 | |
| 5997 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 5998 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5999 | EVENT("(GLuint texture = %d)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6000 | |
| 6001 | try |
| 6002 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6003 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6004 | |
| 6005 | if (context && texture) |
| 6006 | { |
| 6007 | gl::Texture *textureObject = context->getTexture(texture); |
| 6008 | |
| 6009 | if (textureObject) |
| 6010 | { |
| 6011 | return GL_TRUE; |
| 6012 | } |
| 6013 | } |
| 6014 | } |
| 6015 | catch(std::bad_alloc&) |
| 6016 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6017 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6018 | } |
| 6019 | |
| 6020 | return GL_FALSE; |
| 6021 | } |
| 6022 | |
| 6023 | void __stdcall glLineWidth(GLfloat width) |
| 6024 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6025 | EVENT("(GLfloat width = %f)", width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6026 | |
| 6027 | try |
| 6028 | { |
| 6029 | if (width <= 0.0f) |
| 6030 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6031 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6032 | } |
| 6033 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6034 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 6035 | |
| 6036 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6037 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6038 | context->setLineWidth(width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6039 | } |
| 6040 | } |
| 6041 | catch(std::bad_alloc&) |
| 6042 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6043 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6044 | } |
| 6045 | } |
| 6046 | |
| 6047 | void __stdcall glLinkProgram(GLuint program) |
| 6048 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6049 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6050 | |
| 6051 | try |
| 6052 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6053 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6054 | |
| 6055 | if (context) |
| 6056 | { |
| 6057 | gl::Program *programObject = context->getProgram(program); |
| 6058 | |
| 6059 | if (!programObject) |
| 6060 | { |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6061 | if (context->getShader(program)) |
| 6062 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6063 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6064 | } |
| 6065 | else |
| 6066 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6067 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6068 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6069 | } |
| 6070 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 6071 | context->linkProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6072 | } |
| 6073 | } |
| 6074 | catch(std::bad_alloc&) |
| 6075 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6076 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6077 | } |
| 6078 | } |
| 6079 | |
| 6080 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 6081 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6082 | EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6083 | |
| 6084 | try |
| 6085 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6086 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6087 | |
| 6088 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6089 | { |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6090 | switch (pname) |
| 6091 | { |
| 6092 | case GL_UNPACK_ALIGNMENT: |
| 6093 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6094 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6095 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6096 | } |
| 6097 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6098 | context->setUnpackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6099 | break; |
| 6100 | |
| 6101 | case GL_PACK_ALIGNMENT: |
| 6102 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6103 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6104 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6105 | } |
| 6106 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6107 | context->setPackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6108 | break; |
| 6109 | |
bsalomon@google.com | 56d46ab | 2011-11-23 14:53:10 +0000 | [diff] [blame] | 6110 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 6111 | context->setPackReverseRowOrder(param != 0); |
| 6112 | break; |
| 6113 | |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6114 | case GL_UNPACK_IMAGE_HEIGHT: |
| 6115 | case GL_UNPACK_SKIP_IMAGES: |
| 6116 | case GL_UNPACK_ROW_LENGTH: |
| 6117 | case GL_UNPACK_SKIP_ROWS: |
| 6118 | case GL_UNPACK_SKIP_PIXELS: |
| 6119 | case GL_PACK_ROW_LENGTH: |
| 6120 | case GL_PACK_SKIP_ROWS: |
| 6121 | case GL_PACK_SKIP_PIXELS: |
| 6122 | if (context->getClientVersion() < 3) |
| 6123 | { |
| 6124 | return gl::error(GL_INVALID_ENUM); |
| 6125 | } |
| 6126 | UNIMPLEMENTED(); |
| 6127 | break; |
| 6128 | |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6129 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6130 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6131 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6132 | } |
| 6133 | } |
| 6134 | catch(std::bad_alloc&) |
| 6135 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6136 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6137 | } |
| 6138 | } |
| 6139 | |
| 6140 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 6141 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6142 | EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6143 | |
| 6144 | try |
| 6145 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6146 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aede630 | 2010-04-29 03:35:48 +0000 | [diff] [blame] | 6147 | |
| 6148 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6149 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6150 | context->setPolygonOffsetParams(factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6151 | } |
| 6152 | } |
| 6153 | catch(std::bad_alloc&) |
| 6154 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6155 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6156 | } |
| 6157 | } |
| 6158 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6159 | void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6160 | GLenum format, GLenum type, GLsizei bufSize, |
| 6161 | GLvoid *data) |
| 6162 | { |
| 6163 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
| 6164 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)", |
| 6165 | x, y, width, height, format, type, bufSize, data); |
| 6166 | |
| 6167 | try |
| 6168 | { |
| 6169 | if (width < 0 || height < 0 || bufSize < 0) |
| 6170 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6171 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6172 | } |
| 6173 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6174 | gl::Context *context = gl::getNonLostContext(); |
| 6175 | |
| 6176 | if (context) |
| 6177 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6178 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6179 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6180 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6181 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6182 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6183 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6184 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6185 | return; |
| 6186 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6187 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6188 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6189 | |
| 6190 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6191 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6192 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6193 | } |
| 6194 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6195 | context->readPixels(x, y, width, height, format, type, &bufSize, data); |
| 6196 | } |
| 6197 | } |
| 6198 | catch(std::bad_alloc&) |
| 6199 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6200 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6201 | } |
| 6202 | } |
| 6203 | |
| 6204 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6205 | GLenum format, GLenum type, GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6206 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6207 | 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] | 6208 | "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] | 6209 | x, y, width, height, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6210 | |
| 6211 | try |
| 6212 | { |
| 6213 | if (width < 0 || height < 0) |
| 6214 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6215 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6216 | } |
| 6217 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6218 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6219 | |
| 6220 | if (context) |
| 6221 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6222 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6223 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6224 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6225 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6226 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6227 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6228 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6229 | return; |
| 6230 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6231 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6232 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6233 | |
| 6234 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6235 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6236 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6237 | } |
| 6238 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6239 | context->readPixels(x, y, width, height, format, type, NULL, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6240 | } |
| 6241 | } |
| 6242 | catch(std::bad_alloc&) |
| 6243 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6244 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6245 | } |
| 6246 | } |
| 6247 | |
| 6248 | void __stdcall glReleaseShaderCompiler(void) |
| 6249 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6250 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6251 | |
| 6252 | try |
| 6253 | { |
| 6254 | gl::Shader::releaseCompiler(); |
| 6255 | } |
| 6256 | catch(std::bad_alloc&) |
| 6257 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6258 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6259 | } |
| 6260 | } |
| 6261 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6262 | 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] | 6263 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6264 | 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] | 6265 | target, samples, internalformat, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6266 | |
| 6267 | try |
| 6268 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6269 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6270 | |
| 6271 | if (context) |
| 6272 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6273 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 6274 | width, height, true)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6275 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6276 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6277 | } |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 6278 | |
| 6279 | context->setRenderbufferStorage(width, height, internalformat, samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6280 | } |
| 6281 | } |
| 6282 | catch(std::bad_alloc&) |
| 6283 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6284 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6285 | } |
| 6286 | } |
| 6287 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6288 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 6289 | { |
| 6290 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height); |
| 6291 | } |
| 6292 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6293 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 6294 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6295 | EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6296 | |
| 6297 | try |
| 6298 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6299 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6300 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6301 | if (context) |
| 6302 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 6303 | context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6304 | } |
| 6305 | } |
| 6306 | catch(std::bad_alloc&) |
| 6307 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6308 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6309 | } |
| 6310 | } |
| 6311 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6312 | void __stdcall glSetFenceNV(GLuint fence, GLenum condition) |
| 6313 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6314 | EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6315 | |
| 6316 | try |
| 6317 | { |
| 6318 | if (condition != GL_ALL_COMPLETED_NV) |
| 6319 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6320 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6321 | } |
| 6322 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6323 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6324 | |
| 6325 | if (context) |
| 6326 | { |
| 6327 | gl::Fence *fenceObject = context->getFence(fence); |
| 6328 | |
| 6329 | if (fenceObject == NULL) |
| 6330 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6331 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6332 | } |
| 6333 | |
| 6334 | fenceObject->setFence(condition); |
| 6335 | } |
| 6336 | } |
| 6337 | catch(std::bad_alloc&) |
| 6338 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6339 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6340 | } |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6341 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6342 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6343 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 6344 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6345 | 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] | 6346 | |
| 6347 | try |
| 6348 | { |
| 6349 | if (width < 0 || height < 0) |
| 6350 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6351 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6352 | } |
| 6353 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6354 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6355 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6356 | if (context) |
| 6357 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6358 | context->setScissorParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6359 | } |
| 6360 | } |
| 6361 | catch(std::bad_alloc&) |
| 6362 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6363 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6364 | } |
| 6365 | } |
| 6366 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6367 | 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] | 6368 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6369 | 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] | 6370 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 6371 | n, shaders, binaryformat, binary, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6372 | |
| 6373 | try |
| 6374 | { |
daniel@transgaming.com | d1f667f | 2010-04-29 03:38:52 +0000 | [diff] [blame] | 6375 | // No binary shader formats are supported. |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6376 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6377 | } |
| 6378 | catch(std::bad_alloc&) |
| 6379 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6380 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6381 | } |
| 6382 | } |
| 6383 | |
shannon.woods%transgaming.com@gtempaccount.com | 5f33933 | 2013-04-13 03:29:02 +0000 | [diff] [blame] | 6384 | 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] | 6385 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6386 | 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] | 6387 | shader, count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6388 | |
| 6389 | try |
| 6390 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6391 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6392 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6393 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6394 | } |
| 6395 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6396 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6397 | |
| 6398 | if (context) |
| 6399 | { |
| 6400 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6401 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6402 | if (!shaderObject) |
| 6403 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6404 | if (context->getProgram(shader)) |
| 6405 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6406 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6407 | } |
| 6408 | else |
| 6409 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6410 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6411 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6412 | } |
| 6413 | |
| 6414 | shaderObject->setSource(count, string, length); |
| 6415 | } |
| 6416 | } |
| 6417 | catch(std::bad_alloc&) |
| 6418 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6419 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6420 | } |
| 6421 | } |
| 6422 | |
| 6423 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 6424 | { |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6425 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6426 | } |
| 6427 | |
| 6428 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 6429 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6430 | 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] | 6431 | |
| 6432 | try |
| 6433 | { |
| 6434 | switch (face) |
| 6435 | { |
| 6436 | case GL_FRONT: |
| 6437 | case GL_BACK: |
| 6438 | case GL_FRONT_AND_BACK: |
| 6439 | break; |
| 6440 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6441 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6442 | } |
| 6443 | |
| 6444 | switch (func) |
| 6445 | { |
| 6446 | case GL_NEVER: |
| 6447 | case GL_ALWAYS: |
| 6448 | case GL_LESS: |
| 6449 | case GL_LEQUAL: |
| 6450 | case GL_EQUAL: |
| 6451 | case GL_GEQUAL: |
| 6452 | case GL_GREATER: |
| 6453 | case GL_NOTEQUAL: |
| 6454 | break; |
| 6455 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6456 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6457 | } |
| 6458 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6459 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6460 | |
| 6461 | if (context) |
| 6462 | { |
| 6463 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6464 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6465 | context->setStencilParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6466 | } |
| 6467 | |
| 6468 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6469 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6470 | context->setStencilBackParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6471 | } |
| 6472 | } |
| 6473 | } |
| 6474 | catch(std::bad_alloc&) |
| 6475 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6476 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6477 | } |
| 6478 | } |
| 6479 | |
| 6480 | void __stdcall glStencilMask(GLuint mask) |
| 6481 | { |
| 6482 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 6483 | } |
| 6484 | |
| 6485 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 6486 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6487 | EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6488 | |
| 6489 | try |
| 6490 | { |
| 6491 | switch (face) |
| 6492 | { |
| 6493 | case GL_FRONT: |
| 6494 | case GL_BACK: |
| 6495 | case GL_FRONT_AND_BACK: |
| 6496 | break; |
| 6497 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6498 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6499 | } |
| 6500 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6501 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6502 | |
| 6503 | if (context) |
| 6504 | { |
| 6505 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6506 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6507 | context->setStencilWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6508 | } |
| 6509 | |
| 6510 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6511 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6512 | context->setStencilBackWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6513 | } |
| 6514 | } |
| 6515 | } |
| 6516 | catch(std::bad_alloc&) |
| 6517 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6518 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6519 | } |
| 6520 | } |
| 6521 | |
| 6522 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 6523 | { |
| 6524 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 6525 | } |
| 6526 | |
| 6527 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 6528 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6529 | 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] | 6530 | face, fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6531 | |
| 6532 | try |
| 6533 | { |
| 6534 | switch (face) |
| 6535 | { |
| 6536 | case GL_FRONT: |
| 6537 | case GL_BACK: |
| 6538 | case GL_FRONT_AND_BACK: |
| 6539 | break; |
| 6540 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6541 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6542 | } |
| 6543 | |
| 6544 | switch (fail) |
| 6545 | { |
| 6546 | case GL_ZERO: |
| 6547 | case GL_KEEP: |
| 6548 | case GL_REPLACE: |
| 6549 | case GL_INCR: |
| 6550 | case GL_DECR: |
| 6551 | case GL_INVERT: |
| 6552 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6553 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6554 | break; |
| 6555 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6556 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6557 | } |
| 6558 | |
| 6559 | switch (zfail) |
| 6560 | { |
| 6561 | case GL_ZERO: |
| 6562 | case GL_KEEP: |
| 6563 | case GL_REPLACE: |
| 6564 | case GL_INCR: |
| 6565 | case GL_DECR: |
| 6566 | case GL_INVERT: |
| 6567 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6568 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6569 | break; |
| 6570 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6571 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6572 | } |
| 6573 | |
| 6574 | switch (zpass) |
| 6575 | { |
| 6576 | case GL_ZERO: |
| 6577 | case GL_KEEP: |
| 6578 | case GL_REPLACE: |
| 6579 | case GL_INCR: |
| 6580 | case GL_DECR: |
| 6581 | case GL_INVERT: |
| 6582 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6583 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6584 | break; |
| 6585 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6586 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6587 | } |
| 6588 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6589 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6590 | |
| 6591 | if (context) |
| 6592 | { |
| 6593 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6594 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6595 | context->setStencilOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6596 | } |
| 6597 | |
| 6598 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6599 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6600 | context->setStencilBackOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6601 | } |
| 6602 | } |
| 6603 | } |
| 6604 | catch(std::bad_alloc&) |
| 6605 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6606 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6607 | } |
| 6608 | } |
| 6609 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6610 | GLboolean __stdcall glTestFenceNV(GLuint fence) |
| 6611 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6612 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6613 | |
| 6614 | try |
| 6615 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6616 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6617 | |
| 6618 | if (context) |
| 6619 | { |
| 6620 | gl::Fence *fenceObject = context->getFence(fence); |
| 6621 | |
| 6622 | if (fenceObject == NULL) |
| 6623 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6624 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6625 | } |
| 6626 | |
| 6627 | return fenceObject->testFence(); |
| 6628 | } |
| 6629 | } |
| 6630 | catch(std::bad_alloc&) |
| 6631 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6632 | gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6633 | } |
| 6634 | |
| 6635 | return GL_TRUE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6636 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6637 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6638 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, |
| 6639 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6640 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6641 | 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] | 6642 | "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] | 6643 | target, level, internalformat, width, height, border, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6644 | |
| 6645 | try |
| 6646 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6647 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6648 | |
| 6649 | if (context) |
| 6650 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6651 | if (context->getClientVersion() < 3 && |
| 6652 | !validateES2TexImageParameters(context, target, level, internalformat, false, false, |
| 6653 | 0, 0, width, height, border, format, type, pixels)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 6654 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6655 | return; |
| 6656 | } |
| 6657 | |
| 6658 | if (context->getClientVersion() >= 3 && |
| 6659 | !validateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 6660 | 0, 0, 0, width, height, 1, border, format, type)) |
| 6661 | { |
| 6662 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 6663 | } |
| 6664 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6665 | switch (target) |
| 6666 | { |
| 6667 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6668 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6669 | gl::Texture2D *texture = context->getTexture2D(); |
| 6670 | texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6671 | } |
| 6672 | break; |
| 6673 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6674 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6675 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 6676 | texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6677 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6678 | break; |
| 6679 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 6680 | { |
| 6681 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6682 | texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6683 | } |
| 6684 | break; |
| 6685 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 6686 | { |
| 6687 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6688 | texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6689 | } |
| 6690 | break; |
| 6691 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 6692 | { |
| 6693 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6694 | texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6695 | } |
| 6696 | break; |
| 6697 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 6698 | { |
| 6699 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6700 | texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6701 | } |
| 6702 | break; |
| 6703 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 6704 | { |
| 6705 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6706 | texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6707 | } |
| 6708 | break; |
| 6709 | default: UNREACHABLE(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6710 | } |
| 6711 | } |
| 6712 | } |
| 6713 | catch(std::bad_alloc&) |
| 6714 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6715 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6716 | } |
| 6717 | } |
| 6718 | |
| 6719 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 6720 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6721 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param); |
| 6722 | |
| 6723 | try |
| 6724 | { |
| 6725 | gl::Context *context = gl::getNonLostContext(); |
| 6726 | |
| 6727 | if (context) |
| 6728 | { |
| 6729 | gl::Texture *texture; |
| 6730 | |
| 6731 | switch (target) |
| 6732 | { |
| 6733 | case GL_TEXTURE_2D: |
| 6734 | texture = context->getTexture2D(); |
| 6735 | break; |
| 6736 | case GL_TEXTURE_CUBE_MAP: |
| 6737 | texture = context->getTextureCubeMap(); |
| 6738 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 6739 | case GL_TEXTURE_3D: |
| 6740 | if (context->getClientVersion() < 3) |
| 6741 | { |
| 6742 | return gl::error(GL_INVALID_ENUM); |
| 6743 | } |
| 6744 | texture = context->getTexture3D(); |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 6745 | case GL_TEXTURE_2D_ARRAY: |
| 6746 | if (context->getClientVersion() < 3) |
| 6747 | { |
| 6748 | return gl::error(GL_INVALID_ENUM); |
| 6749 | } |
| 6750 | texture = context->getTexture2DArray(); |
| 6751 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6752 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6753 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6754 | } |
| 6755 | |
| 6756 | switch (pname) |
| 6757 | { |
| 6758 | case GL_TEXTURE_WRAP_S: |
| 6759 | if (!texture->setWrapS((GLenum)param)) |
| 6760 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6761 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6762 | } |
| 6763 | break; |
| 6764 | case GL_TEXTURE_WRAP_T: |
| 6765 | if (!texture->setWrapT((GLenum)param)) |
| 6766 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6767 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6768 | } |
| 6769 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 6770 | case GL_TEXTURE_WRAP_R: |
| 6771 | if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param)) |
| 6772 | { |
| 6773 | return gl::error(GL_INVALID_ENUM); |
| 6774 | } |
| 6775 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6776 | case GL_TEXTURE_MIN_FILTER: |
| 6777 | if (!texture->setMinFilter((GLenum)param)) |
| 6778 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6779 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6780 | } |
| 6781 | break; |
| 6782 | case GL_TEXTURE_MAG_FILTER: |
| 6783 | if (!texture->setMagFilter((GLenum)param)) |
| 6784 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6785 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6786 | } |
| 6787 | break; |
| 6788 | case GL_TEXTURE_USAGE_ANGLE: |
| 6789 | if (!texture->setUsage((GLenum)param)) |
| 6790 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6791 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6792 | } |
| 6793 | break; |
| 6794 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 6795 | if (!context->supportsTextureFilterAnisotropy()) |
| 6796 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6797 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6798 | } |
| 6799 | if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy())) |
| 6800 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6801 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6802 | } |
| 6803 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6804 | |
| 6805 | case GL_TEXTURE_MIN_LOD: |
| 6806 | case GL_TEXTURE_MAX_LOD: |
| 6807 | if (context->getClientVersion() < 3) |
| 6808 | { |
| 6809 | return gl::error(GL_INVALID_ENUM); |
| 6810 | } |
| 6811 | UNIMPLEMENTED(); |
| 6812 | break; |
| 6813 | |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6814 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6815 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6816 | } |
| 6817 | } |
| 6818 | } |
| 6819 | catch(std::bad_alloc&) |
| 6820 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6821 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6822 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6823 | } |
| 6824 | |
| 6825 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 6826 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6827 | glTexParameterf(target, pname, (GLfloat)*params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6828 | } |
| 6829 | |
| 6830 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 6831 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6832 | 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] | 6833 | |
| 6834 | try |
| 6835 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6836 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6837 | |
| 6838 | if (context) |
| 6839 | { |
| 6840 | gl::Texture *texture; |
| 6841 | |
| 6842 | switch (target) |
| 6843 | { |
| 6844 | case GL_TEXTURE_2D: |
| 6845 | texture = context->getTexture2D(); |
| 6846 | break; |
| 6847 | case GL_TEXTURE_CUBE_MAP: |
| 6848 | texture = context->getTextureCubeMap(); |
| 6849 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 6850 | case GL_TEXTURE_3D: |
| 6851 | if (context->getClientVersion() < 3) |
| 6852 | { |
| 6853 | return gl::error(GL_INVALID_ENUM); |
| 6854 | } |
| 6855 | texture = context->getTexture3D(); |
| 6856 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 6857 | case GL_TEXTURE_2D_ARRAY: |
| 6858 | if (context->getClientVersion() < 3) |
| 6859 | { |
| 6860 | return gl::error(GL_INVALID_ENUM); |
| 6861 | } |
| 6862 | texture = context->getTexture2DArray(); |
| 6863 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6864 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6865 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6866 | } |
| 6867 | |
| 6868 | switch (pname) |
| 6869 | { |
| 6870 | case GL_TEXTURE_WRAP_S: |
| 6871 | if (!texture->setWrapS((GLenum)param)) |
| 6872 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6873 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6874 | } |
| 6875 | break; |
| 6876 | case GL_TEXTURE_WRAP_T: |
| 6877 | if (!texture->setWrapT((GLenum)param)) |
| 6878 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6879 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6880 | } |
| 6881 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 6882 | case GL_TEXTURE_WRAP_R: |
| 6883 | if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param)) |
| 6884 | { |
| 6885 | return gl::error(GL_INVALID_ENUM); |
| 6886 | } |
| 6887 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6888 | case GL_TEXTURE_MIN_FILTER: |
| 6889 | if (!texture->setMinFilter((GLenum)param)) |
| 6890 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6891 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6892 | } |
| 6893 | break; |
| 6894 | case GL_TEXTURE_MAG_FILTER: |
| 6895 | if (!texture->setMagFilter((GLenum)param)) |
| 6896 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6897 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6898 | } |
| 6899 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 6900 | case GL_TEXTURE_USAGE_ANGLE: |
| 6901 | if (!texture->setUsage((GLenum)param)) |
| 6902 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6903 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 6904 | } |
| 6905 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6906 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 6907 | if (!context->supportsTextureFilterAnisotropy()) |
| 6908 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6909 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6910 | } |
| 6911 | if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy())) |
| 6912 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6913 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6914 | } |
| 6915 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6916 | |
| 6917 | case GL_TEXTURE_SWIZZLE_R: |
| 6918 | case GL_TEXTURE_SWIZZLE_G: |
| 6919 | case GL_TEXTURE_SWIZZLE_B: |
| 6920 | case GL_TEXTURE_SWIZZLE_A: |
| 6921 | case GL_TEXTURE_BASE_LEVEL: |
| 6922 | case GL_TEXTURE_MAX_LEVEL: |
| 6923 | case GL_TEXTURE_COMPARE_MODE: |
| 6924 | case GL_TEXTURE_COMPARE_FUNC: |
| 6925 | if (context->getClientVersion() < 3) |
| 6926 | { |
| 6927 | return gl::error(GL_INVALID_ENUM); |
| 6928 | } |
| 6929 | UNIMPLEMENTED(); |
| 6930 | break; |
| 6931 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6932 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6933 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6934 | } |
| 6935 | } |
| 6936 | } |
| 6937 | catch(std::bad_alloc&) |
| 6938 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6939 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6940 | } |
| 6941 | } |
| 6942 | |
| 6943 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 6944 | { |
| 6945 | glTexParameteri(target, pname, *params); |
| 6946 | } |
| 6947 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6948 | void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 6949 | { |
| 6950 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 6951 | target, levels, internalformat, width, height); |
| 6952 | |
| 6953 | try |
| 6954 | { |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6955 | gl::Context *context = gl::getNonLostContext(); |
| 6956 | |
| 6957 | if (context) |
| 6958 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6959 | if (context->getClientVersion() < 3 && |
| 6960 | !validateES2TexStorageParameters(context, target, levels, internalformat, width, height)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6961 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6962 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6963 | } |
| 6964 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6965 | if (context->getClientVersion() >= 3 && |
| 6966 | !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6967 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6968 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6969 | } |
| 6970 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6971 | switch (target) |
| 6972 | { |
| 6973 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6974 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6975 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 6976 | texture2d->storage(levels, internalformat, width, height); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6977 | } |
| 6978 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6979 | |
| 6980 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 6981 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 6982 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 6983 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 6984 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 6985 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6986 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6987 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 6988 | textureCube->storage(levels, internalformat, width); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6989 | } |
| 6990 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6991 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6992 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6993 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6994 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6995 | } |
| 6996 | } |
| 6997 | catch(std::bad_alloc&) |
| 6998 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6999 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7000 | } |
| 7001 | } |
| 7002 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7003 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 7004 | GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7005 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7006 | 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] | 7007 | "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] | 7008 | "const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7009 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 7010 | |
| 7011 | try |
| 7012 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7013 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7014 | |
| 7015 | if (context) |
| 7016 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7017 | if (context->getClientVersion() < 3 && |
| 7018 | !validateES2TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7019 | 0, 0, width, height, 0, format, type, pixels)) |
daniel@transgaming.com | 1d2d3c4 | 2012-05-31 01:14:15 +0000 | [diff] [blame] | 7020 | { |
| 7021 | return; |
| 7022 | } |
| 7023 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7024 | if (context->getClientVersion() >= 3 && |
| 7025 | !validateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7026 | 0, 0, 0, width, height, 1, 0, format, type)) |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7027 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7028 | return; |
| 7029 | } |
| 7030 | |
| 7031 | switch (target) |
| 7032 | { |
| 7033 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7034 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7035 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7036 | 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] | 7037 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7038 | break; |
| 7039 | |
| 7040 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7041 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7042 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7043 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7044 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7045 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7046 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7047 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7048 | 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] | 7049 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7050 | break; |
| 7051 | |
| 7052 | default: |
| 7053 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7054 | } |
| 7055 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7056 | } |
| 7057 | catch(std::bad_alloc&) |
| 7058 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7059 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7060 | } |
| 7061 | } |
| 7062 | |
| 7063 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 7064 | { |
| 7065 | glUniform1fv(location, 1, &x); |
| 7066 | } |
| 7067 | |
| 7068 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 7069 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7070 | 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] | 7071 | |
| 7072 | try |
| 7073 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7074 | if (count < 0) |
| 7075 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7076 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7077 | } |
| 7078 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7079 | if (location == -1) |
| 7080 | { |
| 7081 | return; |
| 7082 | } |
| 7083 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7084 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7085 | |
| 7086 | if (context) |
| 7087 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7088 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7089 | if (!programBinary) |
| 7090 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7091 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7092 | } |
| 7093 | |
| 7094 | if (!programBinary->setUniform1fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7095 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7096 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7097 | } |
| 7098 | } |
| 7099 | } |
| 7100 | catch(std::bad_alloc&) |
| 7101 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7102 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7103 | } |
| 7104 | } |
| 7105 | |
| 7106 | void __stdcall glUniform1i(GLint location, GLint x) |
| 7107 | { |
| 7108 | glUniform1iv(location, 1, &x); |
| 7109 | } |
| 7110 | |
| 7111 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 7112 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7113 | 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] | 7114 | |
| 7115 | try |
| 7116 | { |
| 7117 | if (count < 0) |
| 7118 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7119 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7120 | } |
| 7121 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7122 | if (location == -1) |
| 7123 | { |
| 7124 | return; |
| 7125 | } |
| 7126 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7127 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7128 | |
| 7129 | if (context) |
| 7130 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7131 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7132 | if (!programBinary) |
| 7133 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7134 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7135 | } |
| 7136 | |
| 7137 | if (!programBinary->setUniform1iv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7138 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7139 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7140 | } |
| 7141 | } |
| 7142 | } |
| 7143 | catch(std::bad_alloc&) |
| 7144 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7145 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7146 | } |
| 7147 | } |
| 7148 | |
| 7149 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 7150 | { |
| 7151 | GLfloat xy[2] = {x, y}; |
| 7152 | |
| 7153 | glUniform2fv(location, 1, (GLfloat*)&xy); |
| 7154 | } |
| 7155 | |
| 7156 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 7157 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7158 | 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] | 7159 | |
| 7160 | try |
| 7161 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7162 | if (count < 0) |
| 7163 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7164 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7165 | } |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7166 | |
| 7167 | if (location == -1) |
| 7168 | { |
| 7169 | return; |
| 7170 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7171 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7172 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7173 | |
| 7174 | if (context) |
| 7175 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7176 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7177 | if (!programBinary) |
| 7178 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7179 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7180 | } |
| 7181 | |
| 7182 | if (!programBinary->setUniform2fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7183 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7184 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7185 | } |
| 7186 | } |
| 7187 | } |
| 7188 | catch(std::bad_alloc&) |
| 7189 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7190 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7191 | } |
| 7192 | } |
| 7193 | |
| 7194 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 7195 | { |
| 7196 | GLint xy[4] = {x, y}; |
| 7197 | |
| 7198 | glUniform2iv(location, 1, (GLint*)&xy); |
| 7199 | } |
| 7200 | |
| 7201 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 7202 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7203 | 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] | 7204 | |
| 7205 | try |
| 7206 | { |
| 7207 | if (count < 0) |
| 7208 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7209 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7210 | } |
| 7211 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7212 | if (location == -1) |
| 7213 | { |
| 7214 | return; |
| 7215 | } |
| 7216 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7217 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7218 | |
| 7219 | if (context) |
| 7220 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7221 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7222 | if (!programBinary) |
| 7223 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7224 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7225 | } |
| 7226 | |
| 7227 | if (!programBinary->setUniform2iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7228 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7229 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7230 | } |
| 7231 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7232 | } |
| 7233 | catch(std::bad_alloc&) |
| 7234 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7235 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7236 | } |
| 7237 | } |
| 7238 | |
| 7239 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 7240 | { |
| 7241 | GLfloat xyz[3] = {x, y, z}; |
| 7242 | |
| 7243 | glUniform3fv(location, 1, (GLfloat*)&xyz); |
| 7244 | } |
| 7245 | |
| 7246 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 7247 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7248 | 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] | 7249 | |
| 7250 | try |
| 7251 | { |
| 7252 | if (count < 0) |
| 7253 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7254 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7255 | } |
| 7256 | |
| 7257 | if (location == -1) |
| 7258 | { |
| 7259 | return; |
| 7260 | } |
| 7261 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7262 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7263 | |
| 7264 | if (context) |
| 7265 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7266 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7267 | if (!programBinary) |
| 7268 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7269 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7270 | } |
| 7271 | |
| 7272 | if (!programBinary->setUniform3fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7273 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7274 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7275 | } |
| 7276 | } |
| 7277 | } |
| 7278 | catch(std::bad_alloc&) |
| 7279 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7280 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7281 | } |
| 7282 | } |
| 7283 | |
| 7284 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 7285 | { |
| 7286 | GLint xyz[3] = {x, y, z}; |
| 7287 | |
| 7288 | glUniform3iv(location, 1, (GLint*)&xyz); |
| 7289 | } |
| 7290 | |
| 7291 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 7292 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7293 | 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] | 7294 | |
| 7295 | try |
| 7296 | { |
| 7297 | if (count < 0) |
| 7298 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7299 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7300 | } |
| 7301 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7302 | if (location == -1) |
| 7303 | { |
| 7304 | return; |
| 7305 | } |
| 7306 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7307 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7308 | |
| 7309 | if (context) |
| 7310 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7311 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7312 | if (!programBinary) |
| 7313 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7314 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7315 | } |
| 7316 | |
| 7317 | if (!programBinary->setUniform3iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7318 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7319 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7320 | } |
| 7321 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7322 | } |
| 7323 | catch(std::bad_alloc&) |
| 7324 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7325 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7326 | } |
| 7327 | } |
| 7328 | |
| 7329 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7330 | { |
| 7331 | GLfloat xyzw[4] = {x, y, z, w}; |
| 7332 | |
| 7333 | glUniform4fv(location, 1, (GLfloat*)&xyzw); |
| 7334 | } |
| 7335 | |
| 7336 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 7337 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7338 | 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] | 7339 | |
| 7340 | try |
| 7341 | { |
| 7342 | if (count < 0) |
| 7343 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7344 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7345 | } |
| 7346 | |
| 7347 | if (location == -1) |
| 7348 | { |
| 7349 | return; |
| 7350 | } |
| 7351 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7352 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7353 | |
| 7354 | if (context) |
| 7355 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7356 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7357 | if (!programBinary) |
| 7358 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7359 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7360 | } |
| 7361 | |
| 7362 | if (!programBinary->setUniform4fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7363 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7364 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7365 | } |
| 7366 | } |
| 7367 | } |
| 7368 | catch(std::bad_alloc&) |
| 7369 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7370 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7371 | } |
| 7372 | } |
| 7373 | |
| 7374 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 7375 | { |
| 7376 | GLint xyzw[4] = {x, y, z, w}; |
| 7377 | |
| 7378 | glUniform4iv(location, 1, (GLint*)&xyzw); |
| 7379 | } |
| 7380 | |
| 7381 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 7382 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7383 | 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] | 7384 | |
| 7385 | try |
| 7386 | { |
| 7387 | if (count < 0) |
| 7388 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7389 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7390 | } |
| 7391 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7392 | if (location == -1) |
| 7393 | { |
| 7394 | return; |
| 7395 | } |
| 7396 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7397 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7398 | |
| 7399 | if (context) |
| 7400 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7401 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7402 | if (!programBinary) |
| 7403 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7404 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7405 | } |
| 7406 | |
| 7407 | if (!programBinary->setUniform4iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7408 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7409 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7410 | } |
| 7411 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7412 | } |
| 7413 | catch(std::bad_alloc&) |
| 7414 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7415 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7416 | } |
| 7417 | } |
| 7418 | |
| 7419 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7420 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7421 | 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] | 7422 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7423 | |
| 7424 | try |
| 7425 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7426 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7427 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7428 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7429 | } |
| 7430 | |
| 7431 | if (location == -1) |
| 7432 | { |
| 7433 | return; |
| 7434 | } |
| 7435 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7436 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7437 | |
| 7438 | if (context) |
| 7439 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7440 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7441 | { |
| 7442 | return gl::error(GL_INVALID_VALUE); |
| 7443 | } |
| 7444 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7445 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7446 | if (!programBinary) |
| 7447 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7448 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7449 | } |
| 7450 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7451 | if (!programBinary->setUniformMatrix2fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7452 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7453 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7454 | } |
| 7455 | } |
| 7456 | } |
| 7457 | catch(std::bad_alloc&) |
| 7458 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7459 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7460 | } |
| 7461 | } |
| 7462 | |
| 7463 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7464 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7465 | 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] | 7466 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7467 | |
| 7468 | try |
| 7469 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7470 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7471 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7472 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7473 | } |
| 7474 | |
| 7475 | if (location == -1) |
| 7476 | { |
| 7477 | return; |
| 7478 | } |
| 7479 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7480 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7481 | |
| 7482 | if (context) |
| 7483 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7484 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7485 | { |
| 7486 | return gl::error(GL_INVALID_VALUE); |
| 7487 | } |
| 7488 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7489 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7490 | if (!programBinary) |
| 7491 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7492 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7493 | } |
| 7494 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7495 | if (!programBinary->setUniformMatrix3fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7496 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7497 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7498 | } |
| 7499 | } |
| 7500 | } |
| 7501 | catch(std::bad_alloc&) |
| 7502 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7503 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7504 | } |
| 7505 | } |
| 7506 | |
| 7507 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7508 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7509 | 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] | 7510 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7511 | |
| 7512 | try |
| 7513 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7514 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7515 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7516 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7517 | } |
| 7518 | |
| 7519 | if (location == -1) |
| 7520 | { |
| 7521 | return; |
| 7522 | } |
| 7523 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7524 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7525 | |
| 7526 | if (context) |
| 7527 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7528 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7529 | { |
| 7530 | return gl::error(GL_INVALID_VALUE); |
| 7531 | } |
| 7532 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7533 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7534 | if (!programBinary) |
| 7535 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7536 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7537 | } |
| 7538 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7539 | if (!programBinary->setUniformMatrix4fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7540 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7541 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7542 | } |
| 7543 | } |
| 7544 | } |
| 7545 | catch(std::bad_alloc&) |
| 7546 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7547 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7548 | } |
| 7549 | } |
| 7550 | |
| 7551 | void __stdcall glUseProgram(GLuint program) |
| 7552 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7553 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7554 | |
| 7555 | try |
| 7556 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7557 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7558 | |
| 7559 | if (context) |
| 7560 | { |
| 7561 | gl::Program *programObject = context->getProgram(program); |
| 7562 | |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7563 | if (!programObject && program != 0) |
| 7564 | { |
| 7565 | if (context->getShader(program)) |
| 7566 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7567 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7568 | } |
| 7569 | else |
| 7570 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7571 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7572 | } |
| 7573 | } |
| 7574 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 7575 | if (program != 0 && !programObject->isLinked()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7576 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7577 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7578 | } |
| 7579 | |
| 7580 | context->useProgram(program); |
| 7581 | } |
| 7582 | } |
| 7583 | catch(std::bad_alloc&) |
| 7584 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7585 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7586 | } |
| 7587 | } |
| 7588 | |
| 7589 | void __stdcall glValidateProgram(GLuint program) |
| 7590 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7591 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7592 | |
| 7593 | try |
| 7594 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7595 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7596 | |
| 7597 | if (context) |
| 7598 | { |
| 7599 | gl::Program *programObject = context->getProgram(program); |
| 7600 | |
| 7601 | if (!programObject) |
| 7602 | { |
| 7603 | if (context->getShader(program)) |
| 7604 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7605 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7606 | } |
| 7607 | else |
| 7608 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7609 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7610 | } |
| 7611 | } |
| 7612 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 7613 | programObject->validate(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7614 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7615 | } |
| 7616 | catch(std::bad_alloc&) |
| 7617 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7618 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7619 | } |
| 7620 | } |
| 7621 | |
| 7622 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 7623 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7624 | EVENT("(GLuint index = %d, GLfloat x = %f)", index, x); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7625 | |
| 7626 | try |
| 7627 | { |
| 7628 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7629 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7630 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7631 | } |
| 7632 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7633 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7634 | |
| 7635 | if (context) |
| 7636 | { |
| 7637 | GLfloat vals[4] = { x, 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7638 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7639 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7640 | } |
| 7641 | catch(std::bad_alloc&) |
| 7642 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7643 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7644 | } |
| 7645 | } |
| 7646 | |
| 7647 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 7648 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7649 | 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] | 7650 | |
| 7651 | try |
| 7652 | { |
| 7653 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7654 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7655 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7656 | } |
| 7657 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7658 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7659 | |
| 7660 | if (context) |
| 7661 | { |
| 7662 | GLfloat vals[4] = { values[0], 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7663 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7664 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7665 | } |
| 7666 | catch(std::bad_alloc&) |
| 7667 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7668 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7669 | } |
| 7670 | } |
| 7671 | |
| 7672 | void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 7673 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7674 | 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] | 7675 | |
| 7676 | try |
| 7677 | { |
| 7678 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7679 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7680 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7681 | } |
| 7682 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7683 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7684 | |
| 7685 | if (context) |
| 7686 | { |
| 7687 | GLfloat vals[4] = { x, y, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7688 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7689 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7690 | } |
| 7691 | catch(std::bad_alloc&) |
| 7692 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7693 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7694 | } |
| 7695 | } |
| 7696 | |
| 7697 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 7698 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7699 | 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] | 7700 | |
| 7701 | try |
| 7702 | { |
| 7703 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7704 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7705 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7706 | } |
| 7707 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7708 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7709 | |
| 7710 | if (context) |
| 7711 | { |
| 7712 | 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] | 7713 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7714 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7715 | } |
| 7716 | catch(std::bad_alloc&) |
| 7717 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7718 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7719 | } |
| 7720 | } |
| 7721 | |
| 7722 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 7723 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7724 | 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] | 7725 | |
| 7726 | try |
| 7727 | { |
| 7728 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7729 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7730 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7731 | } |
| 7732 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7733 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7734 | |
| 7735 | if (context) |
| 7736 | { |
| 7737 | GLfloat vals[4] = { x, y, z, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7738 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7739 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7740 | } |
| 7741 | catch(std::bad_alloc&) |
| 7742 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7743 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7744 | } |
| 7745 | } |
| 7746 | |
| 7747 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 7748 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7749 | 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] | 7750 | |
| 7751 | try |
| 7752 | { |
| 7753 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7754 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7755 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7756 | } |
| 7757 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7758 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7759 | |
| 7760 | if (context) |
| 7761 | { |
| 7762 | 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] | 7763 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7764 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7765 | } |
| 7766 | catch(std::bad_alloc&) |
| 7767 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7768 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7769 | } |
| 7770 | } |
| 7771 | |
| 7772 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7773 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7774 | 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] | 7775 | |
| 7776 | try |
| 7777 | { |
| 7778 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7779 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7780 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7781 | } |
| 7782 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7783 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7784 | |
| 7785 | if (context) |
| 7786 | { |
| 7787 | GLfloat vals[4] = { x, y, z, w }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7788 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7789 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7790 | } |
| 7791 | catch(std::bad_alloc&) |
| 7792 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7793 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7794 | } |
| 7795 | } |
| 7796 | |
| 7797 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 7798 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7799 | 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] | 7800 | |
| 7801 | try |
| 7802 | { |
| 7803 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7804 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7805 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7806 | } |
| 7807 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7808 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7809 | |
| 7810 | if (context) |
| 7811 | { |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7812 | context->setVertexAttribf(index, values); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7813 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7814 | } |
| 7815 | catch(std::bad_alloc&) |
| 7816 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7817 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7818 | } |
| 7819 | } |
| 7820 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 7821 | void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
| 7822 | { |
| 7823 | EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor); |
| 7824 | |
| 7825 | try |
| 7826 | { |
| 7827 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7828 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7829 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 7830 | } |
| 7831 | |
| 7832 | gl::Context *context = gl::getNonLostContext(); |
| 7833 | |
| 7834 | if (context) |
| 7835 | { |
| 7836 | context->setVertexAttribDivisor(index, divisor); |
| 7837 | } |
| 7838 | } |
| 7839 | catch(std::bad_alloc&) |
| 7840 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7841 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 7842 | } |
| 7843 | } |
| 7844 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7845 | 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] | 7846 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7847 | 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] | 7848 | "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] | 7849 | index, size, type, normalized, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7850 | |
| 7851 | try |
| 7852 | { |
| 7853 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7854 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7855 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7856 | } |
| 7857 | |
| 7858 | if (size < 1 || size > 4) |
| 7859 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7860 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7861 | } |
| 7862 | |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 7863 | gl::Context *context = gl::getNonLostContext(); |
| 7864 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7865 | switch (type) |
| 7866 | { |
| 7867 | case GL_BYTE: |
| 7868 | case GL_UNSIGNED_BYTE: |
| 7869 | case GL_SHORT: |
| 7870 | case GL_UNSIGNED_SHORT: |
| 7871 | case GL_FIXED: |
| 7872 | case GL_FLOAT: |
| 7873 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 7874 | case GL_HALF_FLOAT: |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7875 | case GL_INT: |
| 7876 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 7877 | case GL_INT_2_10_10_10_REV: |
| 7878 | 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] | 7879 | if (context && context->getClientVersion() < 3) |
| 7880 | { |
| 7881 | return gl::error(GL_INVALID_ENUM); |
| 7882 | } |
| 7883 | else |
| 7884 | { |
| 7885 | break; |
| 7886 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7887 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7888 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7889 | } |
| 7890 | |
| 7891 | if (stride < 0) |
| 7892 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7893 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7894 | } |
| 7895 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 7896 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 7897 | { |
| 7898 | return gl::error(GL_INVALID_OPERATION); |
| 7899 | } |
| 7900 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7901 | if (context) |
| 7902 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8de4e6a | 2013-04-13 03:37:44 +0000 | [diff] [blame] | 7903 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, |
| 7904 | normalized == GL_TRUE, false, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7905 | } |
| 7906 | } |
| 7907 | catch(std::bad_alloc&) |
| 7908 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7909 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7910 | } |
| 7911 | } |
| 7912 | |
| 7913 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 7914 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7915 | 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] | 7916 | |
| 7917 | try |
| 7918 | { |
| 7919 | if (width < 0 || height < 0) |
| 7920 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7921 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7922 | } |
| 7923 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7924 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7925 | |
| 7926 | if (context) |
| 7927 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7928 | context->setViewportParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7929 | } |
| 7930 | } |
| 7931 | catch(std::bad_alloc&) |
| 7932 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7933 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7934 | } |
| 7935 | } |
| 7936 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7937 | // OpenGL ES 3.0 functions |
| 7938 | |
| 7939 | void __stdcall glReadBuffer(GLenum mode) |
| 7940 | { |
| 7941 | EVENT("(GLenum mode = 0x%X)", mode); |
| 7942 | |
| 7943 | try |
| 7944 | { |
| 7945 | gl::Context *context = gl::getNonLostContext(); |
| 7946 | |
| 7947 | if (context) |
| 7948 | { |
| 7949 | if (context->getClientVersion() < 3) |
| 7950 | { |
| 7951 | return gl::error(GL_INVALID_OPERATION); |
| 7952 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7953 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7954 | UNIMPLEMENTED(); |
| 7955 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7956 | } |
| 7957 | catch(std::bad_alloc&) |
| 7958 | { |
| 7959 | return gl::error(GL_OUT_OF_MEMORY); |
| 7960 | } |
| 7961 | } |
| 7962 | |
| 7963 | void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) |
| 7964 | { |
| 7965 | EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, " |
| 7966 | "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices); |
| 7967 | |
| 7968 | try |
| 7969 | { |
| 7970 | gl::Context *context = gl::getNonLostContext(); |
| 7971 | |
| 7972 | if (context) |
| 7973 | { |
| 7974 | if (context->getClientVersion() < 3) |
| 7975 | { |
| 7976 | return gl::error(GL_INVALID_OPERATION); |
| 7977 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7978 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7979 | UNIMPLEMENTED(); |
| 7980 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7981 | } |
| 7982 | catch(std::bad_alloc&) |
| 7983 | { |
| 7984 | return gl::error(GL_OUT_OF_MEMORY); |
| 7985 | } |
| 7986 | } |
| 7987 | |
| 7988 | void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
| 7989 | { |
| 7990 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 7991 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " |
| 7992 | "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 7993 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 7994 | |
| 7995 | try |
| 7996 | { |
| 7997 | gl::Context *context = gl::getNonLostContext(); |
| 7998 | |
| 7999 | if (context) |
| 8000 | { |
| 8001 | if (context->getClientVersion() < 3) |
| 8002 | { |
| 8003 | return gl::error(GL_INVALID_OPERATION); |
| 8004 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8005 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8006 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8007 | if (!validateES3TexImageParameters(context, target, level, internalformat, false, false, |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8008 | 0, 0, 0, width, height, depth, border, format, type)) |
| 8009 | { |
| 8010 | return; |
| 8011 | } |
| 8012 | |
| 8013 | switch(target) |
| 8014 | { |
| 8015 | case GL_TEXTURE_3D: |
| 8016 | { |
| 8017 | gl::Texture3D *texture = context->getTexture3D(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8018 | 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] | 8019 | } |
| 8020 | break; |
| 8021 | |
| 8022 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8023 | { |
| 8024 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8025 | 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] | 8026 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8027 | break; |
| 8028 | |
| 8029 | default: |
| 8030 | return gl::error(GL_INVALID_ENUM); |
| 8031 | } |
| 8032 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8033 | } |
| 8034 | catch(std::bad_alloc&) |
| 8035 | { |
| 8036 | return gl::error(GL_OUT_OF_MEMORY); |
| 8037 | } |
| 8038 | } |
| 8039 | |
| 8040 | 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) |
| 8041 | { |
| 8042 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8043 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8044 | "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8045 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); |
| 8046 | |
| 8047 | try |
| 8048 | { |
| 8049 | gl::Context *context = gl::getNonLostContext(); |
| 8050 | |
| 8051 | if (context) |
| 8052 | { |
| 8053 | if (context->getClientVersion() < 3) |
| 8054 | { |
| 8055 | return gl::error(GL_INVALID_OPERATION); |
| 8056 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8057 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8058 | if (!pixels) |
| 8059 | { |
| 8060 | return gl::error(GL_INVALID_VALUE); |
| 8061 | } |
| 8062 | |
| 8063 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8064 | 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] | 8065 | xoffset, yoffset, zoffset, width, height, depth, 0, |
| 8066 | format, type)) |
| 8067 | { |
| 8068 | return; |
| 8069 | } |
| 8070 | |
| 8071 | switch(target) |
| 8072 | { |
| 8073 | case GL_TEXTURE_3D: |
| 8074 | { |
| 8075 | gl::Texture3D *texture = context->getTexture3D(); |
| 8076 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8077 | } |
| 8078 | break; |
| 8079 | |
| 8080 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8081 | { |
| 8082 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8083 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8084 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8085 | break; |
| 8086 | |
| 8087 | default: |
| 8088 | return gl::error(GL_INVALID_ENUM); |
| 8089 | } |
| 8090 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8091 | } |
| 8092 | catch(std::bad_alloc&) |
| 8093 | { |
| 8094 | return gl::error(GL_OUT_OF_MEMORY); |
| 8095 | } |
| 8096 | } |
| 8097 | |
| 8098 | void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 8099 | { |
| 8100 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8101 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 8102 | target, level, xoffset, yoffset, zoffset, x, y, width, height); |
| 8103 | |
| 8104 | try |
| 8105 | { |
| 8106 | gl::Context *context = gl::getNonLostContext(); |
| 8107 | |
| 8108 | if (context) |
| 8109 | { |
| 8110 | if (context->getClientVersion() < 3) |
| 8111 | { |
| 8112 | return gl::error(GL_INVALID_OPERATION); |
| 8113 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8114 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8115 | if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset, |
| 8116 | x, y, width, height, 0)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8117 | { |
| 8118 | return; |
| 8119 | } |
| 8120 | |
| 8121 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 8122 | gl::Texture *texture = NULL; |
| 8123 | switch (target) |
| 8124 | { |
| 8125 | case GL_TEXTURE_3D: |
| 8126 | texture = context->getTexture3D(); |
| 8127 | break; |
| 8128 | |
| 8129 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8130 | texture = context->getTexture2DArray(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8131 | break; |
| 8132 | |
| 8133 | default: |
| 8134 | return gl::error(GL_INVALID_ENUM); |
| 8135 | } |
| 8136 | |
| 8137 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer); |
| 8138 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8139 | } |
| 8140 | catch(std::bad_alloc&) |
| 8141 | { |
| 8142 | return gl::error(GL_OUT_OF_MEMORY); |
| 8143 | } |
| 8144 | } |
| 8145 | |
| 8146 | void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) |
| 8147 | { |
| 8148 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8149 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, " |
| 8150 | "const GLvoid* data = 0x%0.8p)", |
| 8151 | target, level, internalformat, width, height, depth, border, imageSize, data); |
| 8152 | |
| 8153 | try |
| 8154 | { |
| 8155 | gl::Context *context = gl::getNonLostContext(); |
| 8156 | |
| 8157 | if (context) |
| 8158 | { |
| 8159 | if (context->getClientVersion() < 3) |
| 8160 | { |
| 8161 | return gl::error(GL_INVALID_OPERATION); |
| 8162 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8163 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8164 | 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] | 8165 | { |
| 8166 | return gl::error(GL_INVALID_VALUE); |
| 8167 | } |
| 8168 | |
| 8169 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8170 | if (!validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 8171 | 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8172 | { |
| 8173 | return; |
| 8174 | } |
| 8175 | |
| 8176 | switch(target) |
| 8177 | { |
| 8178 | case GL_TEXTURE_3D: |
| 8179 | { |
| 8180 | gl::Texture3D *texture = context->getTexture3D(); |
| 8181 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8182 | } |
| 8183 | break; |
| 8184 | |
| 8185 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8186 | { |
| 8187 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8188 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8189 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8190 | break; |
| 8191 | |
| 8192 | default: |
| 8193 | return gl::error(GL_INVALID_ENUM); |
| 8194 | } |
| 8195 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8196 | } |
| 8197 | catch(std::bad_alloc&) |
| 8198 | { |
| 8199 | return gl::error(GL_OUT_OF_MEMORY); |
| 8200 | } |
| 8201 | } |
| 8202 | |
| 8203 | 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) |
| 8204 | { |
| 8205 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8206 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8207 | "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 8208 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); |
| 8209 | |
| 8210 | try |
| 8211 | { |
| 8212 | gl::Context *context = gl::getNonLostContext(); |
| 8213 | |
| 8214 | if (context) |
| 8215 | { |
| 8216 | if (context->getClientVersion() < 3) |
| 8217 | { |
| 8218 | return gl::error(GL_INVALID_OPERATION); |
| 8219 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8220 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8221 | 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] | 8222 | { |
| 8223 | return gl::error(GL_INVALID_VALUE); |
| 8224 | } |
| 8225 | |
| 8226 | if (!data) |
| 8227 | { |
| 8228 | return gl::error(GL_INVALID_VALUE); |
| 8229 | } |
| 8230 | |
| 8231 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8232 | if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 8233 | 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8234 | { |
| 8235 | return; |
| 8236 | } |
| 8237 | |
| 8238 | switch(target) |
| 8239 | { |
| 8240 | case GL_TEXTURE_3D: |
| 8241 | { |
| 8242 | gl::Texture3D *texture = context->getTexture3D(); |
| 8243 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8244 | format, imageSize, data); |
| 8245 | } |
| 8246 | break; |
| 8247 | |
| 8248 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8249 | { |
| 8250 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8251 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8252 | format, imageSize, data); |
| 8253 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8254 | break; |
| 8255 | |
| 8256 | default: |
| 8257 | return gl::error(GL_INVALID_ENUM); |
| 8258 | } |
| 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 glGenQueries(GLsizei n, GLuint* ids) |
| 8268 | { |
| 8269 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8270 | |
| 8271 | try |
| 8272 | { |
| 8273 | gl::Context *context = gl::getNonLostContext(); |
| 8274 | |
| 8275 | if (context) |
| 8276 | { |
| 8277 | if (context->getClientVersion() < 3) |
| 8278 | { |
| 8279 | return gl::error(GL_INVALID_OPERATION); |
| 8280 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8281 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8282 | UNIMPLEMENTED(); |
| 8283 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8284 | } |
| 8285 | catch(std::bad_alloc&) |
| 8286 | { |
| 8287 | return gl::error(GL_OUT_OF_MEMORY); |
| 8288 | } |
| 8289 | } |
| 8290 | |
| 8291 | void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids) |
| 8292 | { |
| 8293 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8294 | |
| 8295 | try |
| 8296 | { |
| 8297 | gl::Context *context = gl::getNonLostContext(); |
| 8298 | |
| 8299 | if (context) |
| 8300 | { |
| 8301 | if (context->getClientVersion() < 3) |
| 8302 | { |
| 8303 | return gl::error(GL_INVALID_OPERATION); |
| 8304 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8305 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8306 | UNIMPLEMENTED(); |
| 8307 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8308 | } |
| 8309 | catch(std::bad_alloc&) |
| 8310 | { |
| 8311 | return gl::error(GL_OUT_OF_MEMORY); |
| 8312 | } |
| 8313 | } |
| 8314 | |
| 8315 | GLboolean __stdcall glIsQuery(GLuint id) |
| 8316 | { |
| 8317 | EVENT("(GLuint id = %u)", id); |
| 8318 | |
| 8319 | try |
| 8320 | { |
| 8321 | gl::Context *context = gl::getNonLostContext(); |
| 8322 | |
| 8323 | if (context) |
| 8324 | { |
| 8325 | if (context->getClientVersion() < 3) |
| 8326 | { |
| 8327 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8328 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8329 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8330 | UNIMPLEMENTED(); |
| 8331 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8332 | } |
| 8333 | catch(std::bad_alloc&) |
| 8334 | { |
| 8335 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8336 | } |
| 8337 | |
| 8338 | return GL_FALSE; |
| 8339 | } |
| 8340 | |
| 8341 | void __stdcall glBeginQuery(GLenum target, GLuint id) |
| 8342 | { |
| 8343 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 8344 | |
| 8345 | try |
| 8346 | { |
| 8347 | gl::Context *context = gl::getNonLostContext(); |
| 8348 | |
| 8349 | if (context) |
| 8350 | { |
| 8351 | if (context->getClientVersion() < 3) |
| 8352 | { |
| 8353 | return gl::error(GL_INVALID_OPERATION); |
| 8354 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8355 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8356 | UNIMPLEMENTED(); |
| 8357 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8358 | } |
| 8359 | catch(std::bad_alloc&) |
| 8360 | { |
| 8361 | return gl::error(GL_OUT_OF_MEMORY); |
| 8362 | } |
| 8363 | } |
| 8364 | |
| 8365 | void __stdcall glEndQuery(GLenum target) |
| 8366 | { |
| 8367 | EVENT("(GLenum target = 0x%X)", target); |
| 8368 | |
| 8369 | try |
| 8370 | { |
| 8371 | gl::Context *context = gl::getNonLostContext(); |
| 8372 | |
| 8373 | if (context) |
| 8374 | { |
| 8375 | if (context->getClientVersion() < 3) |
| 8376 | { |
| 8377 | return gl::error(GL_INVALID_OPERATION); |
| 8378 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8379 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8380 | UNIMPLEMENTED(); |
| 8381 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8382 | } |
| 8383 | catch(std::bad_alloc&) |
| 8384 | { |
| 8385 | return gl::error(GL_OUT_OF_MEMORY); |
| 8386 | } |
| 8387 | } |
| 8388 | |
| 8389 | void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params) |
| 8390 | { |
| 8391 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
| 8392 | |
| 8393 | try |
| 8394 | { |
| 8395 | gl::Context *context = gl::getNonLostContext(); |
| 8396 | |
| 8397 | if (context) |
| 8398 | { |
| 8399 | if (context->getClientVersion() < 3) |
| 8400 | { |
| 8401 | return gl::error(GL_INVALID_OPERATION); |
| 8402 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8403 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8404 | UNIMPLEMENTED(); |
| 8405 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8406 | } |
| 8407 | catch(std::bad_alloc&) |
| 8408 | { |
| 8409 | return gl::error(GL_OUT_OF_MEMORY); |
| 8410 | } |
| 8411 | } |
| 8412 | |
| 8413 | void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) |
| 8414 | { |
| 8415 | EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params); |
| 8416 | |
| 8417 | try |
| 8418 | { |
| 8419 | gl::Context *context = gl::getNonLostContext(); |
| 8420 | |
| 8421 | if (context) |
| 8422 | { |
| 8423 | if (context->getClientVersion() < 3) |
| 8424 | { |
| 8425 | return gl::error(GL_INVALID_OPERATION); |
| 8426 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8427 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8428 | UNIMPLEMENTED(); |
| 8429 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8430 | } |
| 8431 | catch(std::bad_alloc&) |
| 8432 | { |
| 8433 | return gl::error(GL_OUT_OF_MEMORY); |
| 8434 | } |
| 8435 | } |
| 8436 | |
| 8437 | GLboolean __stdcall glUnmapBuffer(GLenum target) |
| 8438 | { |
| 8439 | EVENT("(GLenum target = 0x%X)", target); |
| 8440 | |
| 8441 | try |
| 8442 | { |
| 8443 | gl::Context *context = gl::getNonLostContext(); |
| 8444 | |
| 8445 | if (context) |
| 8446 | { |
| 8447 | if (context->getClientVersion() < 3) |
| 8448 | { |
| 8449 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8450 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8451 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8452 | UNIMPLEMENTED(); |
| 8453 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8454 | } |
| 8455 | catch(std::bad_alloc&) |
| 8456 | { |
| 8457 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8458 | } |
| 8459 | |
| 8460 | return GL_FALSE; |
| 8461 | } |
| 8462 | |
| 8463 | void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) |
| 8464 | { |
| 8465 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 8466 | |
| 8467 | try |
| 8468 | { |
| 8469 | gl::Context *context = gl::getNonLostContext(); |
| 8470 | |
| 8471 | if (context) |
| 8472 | { |
| 8473 | if (context->getClientVersion() < 3) |
| 8474 | { |
| 8475 | return gl::error(GL_INVALID_OPERATION); |
| 8476 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8477 | |
shannonwoods@chromium.org | 2d2190a | 2013-05-30 00:17:35 +0000 | [diff] [blame] | 8478 | UNIMPLEMENTED(); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8479 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8480 | } |
| 8481 | catch(std::bad_alloc&) |
| 8482 | { |
| 8483 | return gl::error(GL_OUT_OF_MEMORY); |
| 8484 | } |
| 8485 | } |
| 8486 | |
| 8487 | void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs) |
| 8488 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8489 | try |
| 8490 | { |
| 8491 | gl::Context *context = gl::getNonLostContext(); |
| 8492 | |
| 8493 | if (context) |
| 8494 | { |
| 8495 | if (context->getClientVersion() < 3) |
| 8496 | { |
| 8497 | return gl::error(GL_INVALID_OPERATION); |
| 8498 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8499 | |
shannon.woods%transgaming.com@gtempaccount.com | 7948c5f | 2013-04-13 03:38:58 +0000 | [diff] [blame] | 8500 | glDrawBuffersEXT(n, bufs); |
| 8501 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8502 | } |
| 8503 | catch(std::bad_alloc&) |
| 8504 | { |
| 8505 | return gl::error(GL_OUT_OF_MEMORY); |
| 8506 | } |
| 8507 | } |
| 8508 | |
| 8509 | void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8510 | { |
| 8511 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8512 | location, count, transpose, value); |
| 8513 | |
| 8514 | try |
| 8515 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8516 | if (count < 0) |
| 8517 | { |
| 8518 | return gl::error(GL_INVALID_VALUE); |
| 8519 | } |
| 8520 | |
| 8521 | if (location == -1) |
| 8522 | { |
| 8523 | return; |
| 8524 | } |
| 8525 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8526 | gl::Context *context = gl::getNonLostContext(); |
| 8527 | |
| 8528 | if (context) |
| 8529 | { |
| 8530 | if (context->getClientVersion() < 3) |
| 8531 | { |
| 8532 | return gl::error(GL_INVALID_OPERATION); |
| 8533 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8534 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8535 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8536 | if (!programBinary) |
| 8537 | { |
| 8538 | return gl::error(GL_INVALID_OPERATION); |
| 8539 | } |
| 8540 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8541 | if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8542 | { |
| 8543 | return gl::error(GL_INVALID_OPERATION); |
| 8544 | } |
| 8545 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8546 | } |
| 8547 | catch(std::bad_alloc&) |
| 8548 | { |
| 8549 | return gl::error(GL_OUT_OF_MEMORY); |
| 8550 | } |
| 8551 | } |
| 8552 | |
| 8553 | void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8554 | { |
| 8555 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8556 | location, count, transpose, value); |
| 8557 | |
| 8558 | try |
| 8559 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8560 | if (count < 0) |
| 8561 | { |
| 8562 | return gl::error(GL_INVALID_VALUE); |
| 8563 | } |
| 8564 | |
| 8565 | if (location == -1) |
| 8566 | { |
| 8567 | return; |
| 8568 | } |
| 8569 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8570 | gl::Context *context = gl::getNonLostContext(); |
| 8571 | |
| 8572 | if (context) |
| 8573 | { |
| 8574 | if (context->getClientVersion() < 3) |
| 8575 | { |
| 8576 | return gl::error(GL_INVALID_OPERATION); |
| 8577 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8578 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8579 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8580 | if (!programBinary) |
| 8581 | { |
| 8582 | return gl::error(GL_INVALID_OPERATION); |
| 8583 | } |
| 8584 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8585 | if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8586 | { |
| 8587 | return gl::error(GL_INVALID_OPERATION); |
| 8588 | } |
| 8589 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8590 | } |
| 8591 | catch(std::bad_alloc&) |
| 8592 | { |
| 8593 | return gl::error(GL_OUT_OF_MEMORY); |
| 8594 | } |
| 8595 | } |
| 8596 | |
| 8597 | void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8598 | { |
| 8599 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8600 | location, count, transpose, value); |
| 8601 | |
| 8602 | try |
| 8603 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8604 | if (count < 0) |
| 8605 | { |
| 8606 | return gl::error(GL_INVALID_VALUE); |
| 8607 | } |
| 8608 | |
| 8609 | if (location == -1) |
| 8610 | { |
| 8611 | return; |
| 8612 | } |
| 8613 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8614 | gl::Context *context = gl::getNonLostContext(); |
| 8615 | |
| 8616 | if (context) |
| 8617 | { |
| 8618 | if (context->getClientVersion() < 3) |
| 8619 | { |
| 8620 | return gl::error(GL_INVALID_OPERATION); |
| 8621 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8622 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8623 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8624 | if (!programBinary) |
| 8625 | { |
| 8626 | return gl::error(GL_INVALID_OPERATION); |
| 8627 | } |
| 8628 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8629 | if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8630 | { |
| 8631 | return gl::error(GL_INVALID_OPERATION); |
| 8632 | } |
| 8633 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8634 | } |
| 8635 | catch(std::bad_alloc&) |
| 8636 | { |
| 8637 | return gl::error(GL_OUT_OF_MEMORY); |
| 8638 | } |
| 8639 | } |
| 8640 | |
| 8641 | void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8642 | { |
| 8643 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8644 | location, count, transpose, value); |
| 8645 | |
| 8646 | try |
| 8647 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8648 | if (count < 0) |
| 8649 | { |
| 8650 | return gl::error(GL_INVALID_VALUE); |
| 8651 | } |
| 8652 | |
| 8653 | if (location == -1) |
| 8654 | { |
| 8655 | return; |
| 8656 | } |
| 8657 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8658 | gl::Context *context = gl::getNonLostContext(); |
| 8659 | |
| 8660 | if (context) |
| 8661 | { |
| 8662 | if (context->getClientVersion() < 3) |
| 8663 | { |
| 8664 | return gl::error(GL_INVALID_OPERATION); |
| 8665 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8666 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8667 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8668 | if (!programBinary) |
| 8669 | { |
| 8670 | return gl::error(GL_INVALID_OPERATION); |
| 8671 | } |
| 8672 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8673 | if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8674 | { |
| 8675 | return gl::error(GL_INVALID_OPERATION); |
| 8676 | } |
| 8677 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8678 | } |
| 8679 | catch(std::bad_alloc&) |
| 8680 | { |
| 8681 | return gl::error(GL_OUT_OF_MEMORY); |
| 8682 | } |
| 8683 | } |
| 8684 | |
| 8685 | void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8686 | { |
| 8687 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8688 | location, count, transpose, value); |
| 8689 | |
| 8690 | try |
| 8691 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8692 | if (count < 0) |
| 8693 | { |
| 8694 | return gl::error(GL_INVALID_VALUE); |
| 8695 | } |
| 8696 | |
| 8697 | if (location == -1) |
| 8698 | { |
| 8699 | return; |
| 8700 | } |
| 8701 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8702 | gl::Context *context = gl::getNonLostContext(); |
| 8703 | |
| 8704 | if (context) |
| 8705 | { |
| 8706 | if (context->getClientVersion() < 3) |
| 8707 | { |
| 8708 | return gl::error(GL_INVALID_OPERATION); |
| 8709 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8710 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8711 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8712 | if (!programBinary) |
| 8713 | { |
| 8714 | return gl::error(GL_INVALID_OPERATION); |
| 8715 | } |
| 8716 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8717 | if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8718 | { |
| 8719 | return gl::error(GL_INVALID_OPERATION); |
| 8720 | } |
| 8721 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8722 | } |
| 8723 | catch(std::bad_alloc&) |
| 8724 | { |
| 8725 | return gl::error(GL_OUT_OF_MEMORY); |
| 8726 | } |
| 8727 | } |
| 8728 | |
| 8729 | void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8730 | { |
| 8731 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8732 | location, count, transpose, value); |
| 8733 | |
| 8734 | try |
| 8735 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8736 | if (count < 0) |
| 8737 | { |
| 8738 | return gl::error(GL_INVALID_VALUE); |
| 8739 | } |
| 8740 | |
| 8741 | if (location == -1) |
| 8742 | { |
| 8743 | return; |
| 8744 | } |
| 8745 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8746 | gl::Context *context = gl::getNonLostContext(); |
| 8747 | |
| 8748 | if (context) |
| 8749 | { |
| 8750 | if (context->getClientVersion() < 3) |
| 8751 | { |
| 8752 | return gl::error(GL_INVALID_OPERATION); |
| 8753 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8754 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8755 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8756 | if (!programBinary) |
| 8757 | { |
| 8758 | return gl::error(GL_INVALID_OPERATION); |
| 8759 | } |
| 8760 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8761 | if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8762 | { |
| 8763 | return gl::error(GL_INVALID_OPERATION); |
| 8764 | } |
| 8765 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8766 | } |
| 8767 | catch(std::bad_alloc&) |
| 8768 | { |
| 8769 | return gl::error(GL_OUT_OF_MEMORY); |
| 8770 | } |
| 8771 | } |
| 8772 | |
| 8773 | void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) |
| 8774 | { |
| 8775 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, " |
| 8776 | "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 8777 | srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 8778 | |
| 8779 | try |
| 8780 | { |
| 8781 | gl::Context *context = gl::getNonLostContext(); |
| 8782 | |
| 8783 | if (context) |
| 8784 | { |
| 8785 | if (context->getClientVersion() < 3) |
| 8786 | { |
| 8787 | return gl::error(GL_INVALID_OPERATION); |
| 8788 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8789 | |
shannonwoods@chromium.org | ee14856 | 2013-05-30 00:17:21 +0000 | [diff] [blame] | 8790 | glBlitFramebufferANGLE(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8791 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8792 | } |
| 8793 | catch(std::bad_alloc&) |
| 8794 | { |
| 8795 | return gl::error(GL_OUT_OF_MEMORY); |
| 8796 | } |
| 8797 | } |
| 8798 | |
| 8799 | void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| 8800 | { |
| 8801 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 8802 | target, samples, internalformat, width, height); |
| 8803 | |
| 8804 | try |
| 8805 | { |
| 8806 | gl::Context *context = gl::getNonLostContext(); |
| 8807 | |
| 8808 | if (context) |
| 8809 | { |
| 8810 | if (context->getClientVersion() < 3) |
| 8811 | { |
| 8812 | return gl::error(GL_INVALID_OPERATION); |
| 8813 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8814 | |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 8815 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 8816 | width, height, false)) |
| 8817 | { |
| 8818 | return; |
| 8819 | } |
| 8820 | |
| 8821 | context->setRenderbufferStorage(width, height, internalformat, samples); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8822 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8823 | } |
| 8824 | catch(std::bad_alloc&) |
| 8825 | { |
| 8826 | return gl::error(GL_OUT_OF_MEMORY); |
| 8827 | } |
| 8828 | } |
| 8829 | |
| 8830 | void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) |
| 8831 | { |
| 8832 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)", |
| 8833 | target, attachment, texture, level, layer); |
| 8834 | |
| 8835 | try |
| 8836 | { |
| 8837 | gl::Context *context = gl::getNonLostContext(); |
| 8838 | |
| 8839 | if (context) |
| 8840 | { |
| 8841 | if (context->getClientVersion() < 3) |
| 8842 | { |
| 8843 | return gl::error(GL_INVALID_OPERATION); |
| 8844 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8845 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8846 | UNIMPLEMENTED(); |
| 8847 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8848 | } |
| 8849 | catch(std::bad_alloc&) |
| 8850 | { |
| 8851 | return gl::error(GL_OUT_OF_MEMORY); |
| 8852 | } |
| 8853 | } |
| 8854 | |
| 8855 | GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 8856 | { |
| 8857 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 8858 | target, offset, length, access); |
| 8859 | |
| 8860 | try |
| 8861 | { |
| 8862 | gl::Context *context = gl::getNonLostContext(); |
| 8863 | |
| 8864 | if (context) |
| 8865 | { |
| 8866 | if (context->getClientVersion() < 3) |
| 8867 | { |
| 8868 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 8869 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8870 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8871 | UNIMPLEMENTED(); |
| 8872 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8873 | } |
| 8874 | catch(std::bad_alloc&) |
| 8875 | { |
| 8876 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL)); |
| 8877 | } |
| 8878 | |
| 8879 | return NULL; |
| 8880 | } |
| 8881 | |
| 8882 | void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) |
| 8883 | { |
| 8884 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 8885 | |
| 8886 | try |
| 8887 | { |
| 8888 | gl::Context *context = gl::getNonLostContext(); |
| 8889 | |
| 8890 | if (context) |
| 8891 | { |
| 8892 | if (context->getClientVersion() < 3) |
| 8893 | { |
| 8894 | return gl::error(GL_INVALID_OPERATION); |
| 8895 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8896 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8897 | UNIMPLEMENTED(); |
| 8898 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8899 | } |
| 8900 | catch(std::bad_alloc&) |
| 8901 | { |
| 8902 | return gl::error(GL_OUT_OF_MEMORY); |
| 8903 | } |
| 8904 | } |
| 8905 | |
| 8906 | void __stdcall glBindVertexArray(GLuint array) |
| 8907 | { |
| 8908 | EVENT("(GLuint array = %u)", array); |
| 8909 | |
| 8910 | try |
| 8911 | { |
| 8912 | gl::Context *context = gl::getNonLostContext(); |
| 8913 | |
| 8914 | if (context) |
| 8915 | { |
| 8916 | if (context->getClientVersion() < 3) |
| 8917 | { |
| 8918 | return gl::error(GL_INVALID_OPERATION); |
| 8919 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8920 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8921 | UNIMPLEMENTED(); |
| 8922 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8923 | } |
| 8924 | catch(std::bad_alloc&) |
| 8925 | { |
| 8926 | return gl::error(GL_OUT_OF_MEMORY); |
| 8927 | } |
| 8928 | } |
| 8929 | |
| 8930 | void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) |
| 8931 | { |
| 8932 | EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays); |
| 8933 | |
| 8934 | try |
| 8935 | { |
| 8936 | gl::Context *context = gl::getNonLostContext(); |
| 8937 | |
| 8938 | if (context) |
| 8939 | { |
| 8940 | if (context->getClientVersion() < 3) |
| 8941 | { |
| 8942 | return gl::error(GL_INVALID_OPERATION); |
| 8943 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8944 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8945 | UNIMPLEMENTED(); |
| 8946 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8947 | } |
| 8948 | catch(std::bad_alloc&) |
| 8949 | { |
| 8950 | return gl::error(GL_OUT_OF_MEMORY); |
| 8951 | } |
| 8952 | } |
| 8953 | |
| 8954 | void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) |
| 8955 | { |
| 8956 | EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays); |
| 8957 | |
| 8958 | try |
| 8959 | { |
| 8960 | gl::Context *context = gl::getNonLostContext(); |
| 8961 | |
| 8962 | if (context) |
| 8963 | { |
| 8964 | if (context->getClientVersion() < 3) |
| 8965 | { |
| 8966 | return gl::error(GL_INVALID_OPERATION); |
| 8967 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8968 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8969 | UNIMPLEMENTED(); |
| 8970 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8971 | } |
| 8972 | catch(std::bad_alloc&) |
| 8973 | { |
| 8974 | return gl::error(GL_OUT_OF_MEMORY); |
| 8975 | } |
| 8976 | } |
| 8977 | |
| 8978 | GLboolean __stdcall glIsVertexArray(GLuint array) |
| 8979 | { |
| 8980 | EVENT("(GLuint array = %u)", array); |
| 8981 | |
| 8982 | try |
| 8983 | { |
| 8984 | gl::Context *context = gl::getNonLostContext(); |
| 8985 | |
| 8986 | if (context) |
| 8987 | { |
| 8988 | if (context->getClientVersion() < 3) |
| 8989 | { |
| 8990 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8991 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8992 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8993 | UNIMPLEMENTED(); |
| 8994 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8995 | } |
| 8996 | catch(std::bad_alloc&) |
| 8997 | { |
| 8998 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8999 | } |
| 9000 | |
| 9001 | return GL_FALSE; |
| 9002 | } |
| 9003 | |
| 9004 | void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data) |
| 9005 | { |
| 9006 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)", |
| 9007 | target, index, data); |
| 9008 | |
| 9009 | try |
| 9010 | { |
| 9011 | gl::Context *context = gl::getNonLostContext(); |
| 9012 | |
| 9013 | if (context) |
| 9014 | { |
| 9015 | if (context->getClientVersion() < 3) |
| 9016 | { |
| 9017 | return gl::error(GL_INVALID_OPERATION); |
| 9018 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9019 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9020 | UNIMPLEMENTED(); |
| 9021 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9022 | } |
| 9023 | catch(std::bad_alloc&) |
| 9024 | { |
| 9025 | return gl::error(GL_OUT_OF_MEMORY); |
| 9026 | } |
| 9027 | } |
| 9028 | |
| 9029 | void __stdcall glBeginTransformFeedback(GLenum primitiveMode) |
| 9030 | { |
| 9031 | EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode); |
| 9032 | |
| 9033 | try |
| 9034 | { |
| 9035 | gl::Context *context = gl::getNonLostContext(); |
| 9036 | |
| 9037 | if (context) |
| 9038 | { |
| 9039 | if (context->getClientVersion() < 3) |
| 9040 | { |
| 9041 | return gl::error(GL_INVALID_OPERATION); |
| 9042 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9043 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9044 | UNIMPLEMENTED(); |
| 9045 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9046 | } |
| 9047 | catch(std::bad_alloc&) |
| 9048 | { |
| 9049 | return gl::error(GL_OUT_OF_MEMORY); |
| 9050 | } |
| 9051 | } |
| 9052 | |
| 9053 | void __stdcall glEndTransformFeedback(void) |
| 9054 | { |
| 9055 | EVENT("(void)"); |
| 9056 | |
| 9057 | try |
| 9058 | { |
| 9059 | gl::Context *context = gl::getNonLostContext(); |
| 9060 | |
| 9061 | if (context) |
| 9062 | { |
| 9063 | if (context->getClientVersion() < 3) |
| 9064 | { |
| 9065 | return gl::error(GL_INVALID_OPERATION); |
| 9066 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9067 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9068 | UNIMPLEMENTED(); |
| 9069 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9070 | } |
| 9071 | catch(std::bad_alloc&) |
| 9072 | { |
| 9073 | return gl::error(GL_OUT_OF_MEMORY); |
| 9074 | } |
| 9075 | } |
| 9076 | |
| 9077 | void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
| 9078 | { |
| 9079 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)", |
| 9080 | target, index, buffer, offset, size); |
| 9081 | |
| 9082 | try |
| 9083 | { |
| 9084 | gl::Context *context = gl::getNonLostContext(); |
| 9085 | |
| 9086 | if (context) |
| 9087 | { |
| 9088 | if (context->getClientVersion() < 3) |
| 9089 | { |
| 9090 | return gl::error(GL_INVALID_OPERATION); |
| 9091 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9092 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9093 | switch (target) |
| 9094 | { |
| 9095 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9096 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9097 | { |
| 9098 | return gl::error(GL_INVALID_VALUE); |
| 9099 | } |
| 9100 | break; |
| 9101 | |
| 9102 | case GL_UNIFORM_BUFFER: |
| 9103 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 9104 | { |
| 9105 | return gl::error(GL_INVALID_VALUE); |
| 9106 | } |
| 9107 | break; |
| 9108 | |
| 9109 | default: |
| 9110 | return gl::error(GL_INVALID_ENUM); |
| 9111 | } |
| 9112 | |
shannonwoods@chromium.org | e6e0079 | 2013-05-30 00:06:07 +0000 | [diff] [blame] | 9113 | if (buffer != 0 && size <= 0) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9114 | { |
| 9115 | return gl::error(GL_INVALID_VALUE); |
| 9116 | } |
| 9117 | |
| 9118 | switch (target) |
| 9119 | { |
| 9120 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | a26aeaf | 2013-05-30 00:06:13 +0000 | [diff] [blame] | 9121 | |
| 9122 | // size and offset must be a multiple of 4 |
| 9123 | if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) |
| 9124 | { |
| 9125 | return gl::error(GL_INVALID_VALUE); |
| 9126 | } |
| 9127 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9128 | context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 9129 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9130 | break; |
| 9131 | |
| 9132 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 97c3d50 | 2013-05-30 00:04:34 +0000 | [diff] [blame] | 9133 | |
| 9134 | // it is an error to bind an offset not a multiple of the alignment |
| 9135 | if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0) |
| 9136 | { |
| 9137 | return gl::error(GL_INVALID_VALUE); |
| 9138 | } |
| 9139 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9140 | context->bindIndexedUniformBuffer(buffer, index, offset, size); |
| 9141 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9142 | break; |
| 9143 | |
| 9144 | default: |
| 9145 | UNREACHABLE(); |
| 9146 | } |
| 9147 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9148 | } |
| 9149 | catch(std::bad_alloc&) |
| 9150 | { |
| 9151 | return gl::error(GL_OUT_OF_MEMORY); |
| 9152 | } |
| 9153 | } |
| 9154 | |
| 9155 | void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 9156 | { |
| 9157 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)", |
| 9158 | target, index, buffer); |
| 9159 | |
| 9160 | try |
| 9161 | { |
| 9162 | gl::Context *context = gl::getNonLostContext(); |
| 9163 | |
| 9164 | if (context) |
| 9165 | { |
| 9166 | if (context->getClientVersion() < 3) |
| 9167 | { |
| 9168 | return gl::error(GL_INVALID_OPERATION); |
| 9169 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9170 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9171 | switch (target) |
| 9172 | { |
| 9173 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9174 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9175 | { |
| 9176 | return gl::error(GL_INVALID_VALUE); |
| 9177 | } |
| 9178 | break; |
| 9179 | |
| 9180 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9181 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9182 | { |
| 9183 | return gl::error(GL_INVALID_VALUE); |
| 9184 | } |
| 9185 | break; |
| 9186 | |
| 9187 | default: |
| 9188 | return gl::error(GL_INVALID_ENUM); |
| 9189 | } |
| 9190 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9191 | switch (target) |
| 9192 | { |
| 9193 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9194 | context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9195 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9196 | break; |
| 9197 | |
| 9198 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9199 | context->bindIndexedUniformBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9200 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9201 | break; |
| 9202 | |
| 9203 | default: |
| 9204 | UNREACHABLE(); |
| 9205 | } |
| 9206 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9207 | } |
| 9208 | catch(std::bad_alloc&) |
| 9209 | { |
| 9210 | return gl::error(GL_OUT_OF_MEMORY); |
| 9211 | } |
| 9212 | } |
| 9213 | |
| 9214 | void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
| 9215 | { |
| 9216 | EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)", |
| 9217 | program, count, varyings, bufferMode); |
| 9218 | |
| 9219 | try |
| 9220 | { |
| 9221 | gl::Context *context = gl::getNonLostContext(); |
| 9222 | |
| 9223 | if (context) |
| 9224 | { |
| 9225 | if (context->getClientVersion() < 3) |
| 9226 | { |
| 9227 | return gl::error(GL_INVALID_OPERATION); |
| 9228 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9229 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9230 | UNIMPLEMENTED(); |
| 9231 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9232 | } |
| 9233 | catch(std::bad_alloc&) |
| 9234 | { |
| 9235 | return gl::error(GL_OUT_OF_MEMORY); |
| 9236 | } |
| 9237 | } |
| 9238 | |
| 9239 | void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
| 9240 | { |
| 9241 | EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, " |
| 9242 | "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
| 9243 | program, index, bufSize, length, size, type, name); |
| 9244 | |
| 9245 | try |
| 9246 | { |
| 9247 | gl::Context *context = gl::getNonLostContext(); |
| 9248 | |
| 9249 | if (context) |
| 9250 | { |
| 9251 | if (context->getClientVersion() < 3) |
| 9252 | { |
| 9253 | return gl::error(GL_INVALID_OPERATION); |
| 9254 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9255 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9256 | UNIMPLEMENTED(); |
| 9257 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9258 | } |
| 9259 | catch(std::bad_alloc&) |
| 9260 | { |
| 9261 | return gl::error(GL_OUT_OF_MEMORY); |
| 9262 | } |
| 9263 | } |
| 9264 | |
| 9265 | void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) |
| 9266 | { |
| 9267 | EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)", |
| 9268 | index, size, type, stride, pointer); |
| 9269 | |
| 9270 | try |
| 9271 | { |
| 9272 | gl::Context *context = gl::getNonLostContext(); |
| 9273 | |
| 9274 | if (context) |
| 9275 | { |
| 9276 | if (context->getClientVersion() < 3) |
| 9277 | { |
| 9278 | return gl::error(GL_INVALID_OPERATION); |
| 9279 | } |
| 9280 | } |
| 9281 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9282 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9283 | { |
| 9284 | return gl::error(GL_INVALID_VALUE); |
| 9285 | } |
| 9286 | |
| 9287 | if (size < 1 || size > 4) |
| 9288 | { |
| 9289 | return gl::error(GL_INVALID_VALUE); |
| 9290 | } |
| 9291 | |
| 9292 | switch (type) |
| 9293 | { |
| 9294 | case GL_BYTE: |
| 9295 | case GL_UNSIGNED_BYTE: |
| 9296 | case GL_SHORT: |
| 9297 | case GL_UNSIGNED_SHORT: |
| 9298 | case GL_INT: |
| 9299 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9300 | case GL_INT_2_10_10_10_REV: |
| 9301 | 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] | 9302 | break; |
| 9303 | default: |
| 9304 | return gl::error(GL_INVALID_ENUM); |
| 9305 | } |
| 9306 | |
| 9307 | if (stride < 0) |
| 9308 | { |
| 9309 | return gl::error(GL_INVALID_VALUE); |
| 9310 | } |
| 9311 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9312 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 9313 | { |
| 9314 | return gl::error(GL_INVALID_OPERATION); |
| 9315 | } |
| 9316 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9317 | if (context) |
| 9318 | { |
| 9319 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true, |
| 9320 | stride, pointer); |
| 9321 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9322 | } |
| 9323 | catch(std::bad_alloc&) |
| 9324 | { |
| 9325 | return gl::error(GL_OUT_OF_MEMORY); |
| 9326 | } |
| 9327 | } |
| 9328 | |
| 9329 | void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) |
| 9330 | { |
| 9331 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 9332 | index, pname, params); |
| 9333 | |
| 9334 | try |
| 9335 | { |
| 9336 | gl::Context *context = gl::getNonLostContext(); |
| 9337 | |
| 9338 | if (context) |
| 9339 | { |
| 9340 | if (context->getClientVersion() < 3) |
| 9341 | { |
| 9342 | return gl::error(GL_INVALID_OPERATION); |
| 9343 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9344 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9345 | UNIMPLEMENTED(); |
| 9346 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9347 | } |
| 9348 | catch(std::bad_alloc&) |
| 9349 | { |
| 9350 | return gl::error(GL_OUT_OF_MEMORY); |
| 9351 | } |
| 9352 | } |
| 9353 | |
| 9354 | void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) |
| 9355 | { |
| 9356 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)", |
| 9357 | index, pname, params); |
| 9358 | |
| 9359 | try |
| 9360 | { |
| 9361 | gl::Context *context = gl::getNonLostContext(); |
| 9362 | |
| 9363 | if (context) |
| 9364 | { |
| 9365 | if (context->getClientVersion() < 3) |
| 9366 | { |
| 9367 | return gl::error(GL_INVALID_OPERATION); |
| 9368 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9369 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9370 | UNIMPLEMENTED(); |
| 9371 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9372 | } |
| 9373 | catch(std::bad_alloc&) |
| 9374 | { |
| 9375 | return gl::error(GL_OUT_OF_MEMORY); |
| 9376 | } |
| 9377 | } |
| 9378 | |
| 9379 | void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 9380 | { |
| 9381 | EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)", |
| 9382 | index, x, y, z, w); |
| 9383 | |
| 9384 | try |
| 9385 | { |
| 9386 | gl::Context *context = gl::getNonLostContext(); |
| 9387 | |
| 9388 | if (context) |
| 9389 | { |
| 9390 | if (context->getClientVersion() < 3) |
| 9391 | { |
| 9392 | return gl::error(GL_INVALID_OPERATION); |
| 9393 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9394 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9395 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9396 | { |
| 9397 | return gl::error(GL_INVALID_VALUE); |
| 9398 | } |
| 9399 | |
| 9400 | GLint vals[4] = { x, y, z, w }; |
| 9401 | context->setVertexAttribi(index, vals); |
| 9402 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9403 | } |
| 9404 | catch(std::bad_alloc&) |
| 9405 | { |
| 9406 | return gl::error(GL_OUT_OF_MEMORY); |
| 9407 | } |
| 9408 | } |
| 9409 | |
| 9410 | void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 9411 | { |
| 9412 | EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)", |
| 9413 | index, x, y, z, w); |
| 9414 | |
| 9415 | try |
| 9416 | { |
| 9417 | gl::Context *context = gl::getNonLostContext(); |
| 9418 | |
| 9419 | if (context) |
| 9420 | { |
| 9421 | if (context->getClientVersion() < 3) |
| 9422 | { |
| 9423 | return gl::error(GL_INVALID_OPERATION); |
| 9424 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9425 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9426 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9427 | { |
| 9428 | return gl::error(GL_INVALID_VALUE); |
| 9429 | } |
| 9430 | |
| 9431 | GLuint vals[4] = { x, y, z, w }; |
| 9432 | context->setVertexAttribu(index, vals); |
| 9433 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9434 | } |
| 9435 | catch(std::bad_alloc&) |
| 9436 | { |
| 9437 | return gl::error(GL_OUT_OF_MEMORY); |
| 9438 | } |
| 9439 | } |
| 9440 | |
| 9441 | void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) |
| 9442 | { |
| 9443 | EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v); |
| 9444 | |
| 9445 | try |
| 9446 | { |
| 9447 | gl::Context *context = gl::getNonLostContext(); |
| 9448 | |
| 9449 | if (context) |
| 9450 | { |
| 9451 | if (context->getClientVersion() < 3) |
| 9452 | { |
| 9453 | return gl::error(GL_INVALID_OPERATION); |
| 9454 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9455 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9456 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9457 | { |
| 9458 | return gl::error(GL_INVALID_VALUE); |
| 9459 | } |
| 9460 | |
| 9461 | context->setVertexAttribi(index, v); |
| 9462 | } |
shannon.woods%transgaming.com@gtempaccount.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 glVertexAttribI4uiv(GLuint index, const GLuint* v) |
| 9471 | { |
| 9472 | EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v); |
| 9473 | |
| 9474 | try |
| 9475 | { |
| 9476 | gl::Context *context = gl::getNonLostContext(); |
| 9477 | |
| 9478 | if (context) |
| 9479 | { |
| 9480 | if (context->getClientVersion() < 3) |
| 9481 | { |
| 9482 | return gl::error(GL_INVALID_OPERATION); |
| 9483 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9484 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9485 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9486 | { |
| 9487 | return gl::error(GL_INVALID_VALUE); |
| 9488 | } |
| 9489 | |
| 9490 | context->setVertexAttribu(index, v); |
| 9491 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9492 | } |
| 9493 | catch(std::bad_alloc&) |
| 9494 | { |
| 9495 | return gl::error(GL_OUT_OF_MEMORY); |
| 9496 | } |
| 9497 | } |
| 9498 | |
| 9499 | void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) |
| 9500 | { |
| 9501 | EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)", |
| 9502 | program, location, params); |
| 9503 | |
| 9504 | try |
| 9505 | { |
| 9506 | gl::Context *context = gl::getNonLostContext(); |
| 9507 | |
| 9508 | if (context) |
| 9509 | { |
| 9510 | if (context->getClientVersion() < 3) |
| 9511 | { |
| 9512 | return gl::error(GL_INVALID_OPERATION); |
| 9513 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9514 | |
shannon.woods%transgaming.com@gtempaccount.com | e229012 | 2013-04-13 03:41:07 +0000 | [diff] [blame] | 9515 | if (program == 0) |
| 9516 | { |
| 9517 | return gl::error(GL_INVALID_VALUE); |
| 9518 | } |
| 9519 | |
| 9520 | gl::Program *programObject = context->getProgram(program); |
| 9521 | |
| 9522 | if (!programObject || !programObject->isLinked()) |
| 9523 | { |
| 9524 | return gl::error(GL_INVALID_OPERATION); |
| 9525 | } |
| 9526 | |
| 9527 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9528 | if (!programBinary) |
| 9529 | { |
| 9530 | return gl::error(GL_INVALID_OPERATION); |
| 9531 | } |
| 9532 | |
| 9533 | if (!programBinary->getUniformuiv(location, NULL, params)) |
| 9534 | { |
| 9535 | return gl::error(GL_INVALID_OPERATION); |
| 9536 | } |
| 9537 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9538 | } |
| 9539 | catch(std::bad_alloc&) |
| 9540 | { |
| 9541 | return gl::error(GL_OUT_OF_MEMORY); |
| 9542 | } |
| 9543 | } |
| 9544 | |
| 9545 | GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) |
| 9546 | { |
| 9547 | EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)", |
| 9548 | program, name); |
| 9549 | |
| 9550 | try |
| 9551 | { |
| 9552 | gl::Context *context = gl::getNonLostContext(); |
| 9553 | |
| 9554 | if (context) |
| 9555 | { |
| 9556 | if (context->getClientVersion() < 3) |
| 9557 | { |
| 9558 | return gl::error(GL_INVALID_OPERATION, 0); |
| 9559 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9560 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9561 | UNIMPLEMENTED(); |
| 9562 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9563 | } |
| 9564 | catch(std::bad_alloc&) |
| 9565 | { |
| 9566 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 9567 | } |
| 9568 | |
| 9569 | return 0; |
| 9570 | } |
| 9571 | |
| 9572 | void __stdcall glUniform1ui(GLint location, GLuint v0) |
| 9573 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9574 | glUniform1uiv(location, 1, &v0); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9575 | } |
| 9576 | |
| 9577 | void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1) |
| 9578 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9579 | const GLuint xy[] = { v0, v1 }; |
| 9580 | glUniform2uiv(location, 1, xy); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9581 | } |
| 9582 | |
| 9583 | void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 9584 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9585 | const GLuint xyz[] = { v0, v1, v2 }; |
| 9586 | glUniform3uiv(location, 1, xyz); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9587 | } |
| 9588 | |
| 9589 | void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 9590 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9591 | const GLuint xyzw[] = { v0, v1, v2, v3 }; |
| 9592 | glUniform4uiv(location, 1, xyzw); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9593 | } |
| 9594 | |
| 9595 | void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) |
| 9596 | { |
| 9597 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9598 | location, count, value); |
| 9599 | |
| 9600 | try |
| 9601 | { |
| 9602 | gl::Context *context = gl::getNonLostContext(); |
| 9603 | |
| 9604 | if (context) |
| 9605 | { |
| 9606 | if (context->getClientVersion() < 3) |
| 9607 | { |
| 9608 | return gl::error(GL_INVALID_OPERATION); |
| 9609 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9610 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9611 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9612 | if (!programBinary) |
| 9613 | { |
| 9614 | return gl::error(GL_INVALID_OPERATION); |
| 9615 | } |
| 9616 | |
| 9617 | if (!programBinary->setUniform1uiv(location, count, value)) |
| 9618 | { |
| 9619 | return gl::error(GL_INVALID_OPERATION); |
| 9620 | } |
| 9621 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9622 | } |
| 9623 | catch(std::bad_alloc&) |
| 9624 | { |
| 9625 | return gl::error(GL_OUT_OF_MEMORY); |
| 9626 | } |
| 9627 | } |
| 9628 | |
| 9629 | void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) |
| 9630 | { |
| 9631 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9632 | location, count, value); |
| 9633 | |
| 9634 | try |
| 9635 | { |
| 9636 | gl::Context *context = gl::getNonLostContext(); |
| 9637 | |
| 9638 | if (context) |
| 9639 | { |
| 9640 | if (context->getClientVersion() < 3) |
| 9641 | { |
| 9642 | return gl::error(GL_INVALID_OPERATION); |
| 9643 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9644 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9645 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9646 | if (!programBinary) |
| 9647 | { |
| 9648 | return gl::error(GL_INVALID_OPERATION); |
| 9649 | } |
| 9650 | |
| 9651 | if (!programBinary->setUniform2uiv(location, count, value)) |
| 9652 | { |
| 9653 | return gl::error(GL_INVALID_OPERATION); |
| 9654 | } |
| 9655 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9656 | } |
| 9657 | catch(std::bad_alloc&) |
| 9658 | { |
| 9659 | return gl::error(GL_OUT_OF_MEMORY); |
| 9660 | } |
| 9661 | } |
| 9662 | |
| 9663 | void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) |
| 9664 | { |
| 9665 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)", |
| 9666 | location, count, value); |
| 9667 | |
| 9668 | try |
| 9669 | { |
| 9670 | gl::Context *context = gl::getNonLostContext(); |
| 9671 | |
| 9672 | if (context) |
| 9673 | { |
| 9674 | if (context->getClientVersion() < 3) |
| 9675 | { |
| 9676 | return gl::error(GL_INVALID_OPERATION); |
| 9677 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9678 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9679 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9680 | if (!programBinary) |
| 9681 | { |
| 9682 | return gl::error(GL_INVALID_OPERATION); |
| 9683 | } |
| 9684 | |
| 9685 | if (!programBinary->setUniform3uiv(location, count, value)) |
| 9686 | { |
| 9687 | return gl::error(GL_INVALID_OPERATION); |
| 9688 | } |
| 9689 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9690 | } |
| 9691 | catch(std::bad_alloc&) |
| 9692 | { |
| 9693 | return gl::error(GL_OUT_OF_MEMORY); |
| 9694 | } |
| 9695 | } |
| 9696 | |
| 9697 | void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) |
| 9698 | { |
| 9699 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9700 | location, count, value); |
| 9701 | |
| 9702 | try |
| 9703 | { |
| 9704 | gl::Context *context = gl::getNonLostContext(); |
| 9705 | |
| 9706 | if (context) |
| 9707 | { |
| 9708 | if (context->getClientVersion() < 3) |
| 9709 | { |
| 9710 | return gl::error(GL_INVALID_OPERATION); |
| 9711 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9712 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9713 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9714 | if (!programBinary) |
| 9715 | { |
| 9716 | return gl::error(GL_INVALID_OPERATION); |
| 9717 | } |
| 9718 | |
| 9719 | if (!programBinary->setUniform4uiv(location, count, value)) |
| 9720 | { |
| 9721 | return gl::error(GL_INVALID_OPERATION); |
| 9722 | } |
| 9723 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9724 | } |
| 9725 | catch(std::bad_alloc&) |
| 9726 | { |
| 9727 | return gl::error(GL_OUT_OF_MEMORY); |
| 9728 | } |
| 9729 | } |
| 9730 | |
| 9731 | void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) |
| 9732 | { |
| 9733 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)", |
| 9734 | buffer, drawbuffer, value); |
| 9735 | |
| 9736 | try |
| 9737 | { |
| 9738 | gl::Context *context = gl::getNonLostContext(); |
| 9739 | |
| 9740 | if (context) |
| 9741 | { |
| 9742 | if (context->getClientVersion() < 3) |
| 9743 | { |
| 9744 | return gl::error(GL_INVALID_OPERATION); |
| 9745 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9746 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9747 | UNIMPLEMENTED(); |
| 9748 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9749 | } |
| 9750 | catch(std::bad_alloc&) |
| 9751 | { |
| 9752 | return gl::error(GL_OUT_OF_MEMORY); |
| 9753 | } |
| 9754 | } |
| 9755 | |
| 9756 | void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) |
| 9757 | { |
| 9758 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)", |
| 9759 | buffer, drawbuffer, value); |
| 9760 | |
| 9761 | try |
| 9762 | { |
| 9763 | gl::Context *context = gl::getNonLostContext(); |
| 9764 | |
| 9765 | if (context) |
| 9766 | { |
| 9767 | if (context->getClientVersion() < 3) |
| 9768 | { |
| 9769 | return gl::error(GL_INVALID_OPERATION); |
| 9770 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9771 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9772 | UNIMPLEMENTED(); |
| 9773 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9774 | } |
| 9775 | catch(std::bad_alloc&) |
| 9776 | { |
| 9777 | return gl::error(GL_OUT_OF_MEMORY); |
| 9778 | } |
| 9779 | } |
| 9780 | |
| 9781 | void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) |
| 9782 | { |
| 9783 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)", |
| 9784 | buffer, drawbuffer, value); |
| 9785 | |
| 9786 | try |
| 9787 | { |
| 9788 | gl::Context *context = gl::getNonLostContext(); |
| 9789 | |
| 9790 | if (context) |
| 9791 | { |
| 9792 | if (context->getClientVersion() < 3) |
| 9793 | { |
| 9794 | return gl::error(GL_INVALID_OPERATION); |
| 9795 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9796 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9797 | UNIMPLEMENTED(); |
| 9798 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9799 | } |
| 9800 | catch(std::bad_alloc&) |
| 9801 | { |
| 9802 | return gl::error(GL_OUT_OF_MEMORY); |
| 9803 | } |
| 9804 | } |
| 9805 | |
| 9806 | void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 9807 | { |
| 9808 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)", |
| 9809 | buffer, drawbuffer, depth, stencil); |
| 9810 | |
| 9811 | try |
| 9812 | { |
| 9813 | gl::Context *context = gl::getNonLostContext(); |
| 9814 | |
| 9815 | if (context) |
| 9816 | { |
| 9817 | if (context->getClientVersion() < 3) |
| 9818 | { |
| 9819 | return gl::error(GL_INVALID_OPERATION); |
| 9820 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9821 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9822 | UNIMPLEMENTED(); |
| 9823 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9824 | } |
| 9825 | catch(std::bad_alloc&) |
| 9826 | { |
| 9827 | return gl::error(GL_OUT_OF_MEMORY); |
| 9828 | } |
| 9829 | } |
| 9830 | |
| 9831 | const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) |
| 9832 | { |
| 9833 | EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index); |
| 9834 | |
| 9835 | try |
| 9836 | { |
| 9837 | gl::Context *context = gl::getNonLostContext(); |
| 9838 | |
| 9839 | if (context) |
| 9840 | { |
| 9841 | if (context->getClientVersion() < 3) |
| 9842 | { |
| 9843 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL)); |
| 9844 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9845 | |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 9846 | if (name != GL_EXTENSIONS) |
| 9847 | { |
| 9848 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL)); |
| 9849 | } |
| 9850 | |
| 9851 | if (index >= context->getNumExtensions()) |
| 9852 | { |
| 9853 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL)); |
| 9854 | } |
| 9855 | |
| 9856 | return reinterpret_cast<const GLubyte*>(context->getExtensionString(index)); |
| 9857 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9858 | } |
| 9859 | catch(std::bad_alloc&) |
| 9860 | { |
| 9861 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL)); |
| 9862 | } |
| 9863 | |
| 9864 | return NULL; |
| 9865 | } |
| 9866 | |
| 9867 | void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 9868 | { |
| 9869 | EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)", |
| 9870 | readTarget, writeTarget, readOffset, writeOffset, size); |
| 9871 | |
| 9872 | try |
| 9873 | { |
| 9874 | gl::Context *context = gl::getNonLostContext(); |
| 9875 | |
| 9876 | if (context) |
| 9877 | { |
| 9878 | if (context->getClientVersion() < 3) |
| 9879 | { |
| 9880 | return gl::error(GL_INVALID_OPERATION); |
| 9881 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9882 | |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 9883 | gl::Buffer *readBuffer = NULL; |
| 9884 | switch (readTarget) |
| 9885 | { |
| 9886 | case GL_ARRAY_BUFFER: |
| 9887 | readBuffer = context->getArrayBuffer(); |
| 9888 | break; |
| 9889 | case GL_COPY_READ_BUFFER: |
| 9890 | readBuffer = context->getCopyReadBuffer(); |
| 9891 | break; |
| 9892 | case GL_COPY_WRITE_BUFFER: |
| 9893 | readBuffer = context->getCopyWriteBuffer(); |
| 9894 | break; |
| 9895 | case GL_ELEMENT_ARRAY_BUFFER: |
| 9896 | readBuffer = context->getElementArrayBuffer(); |
| 9897 | break; |
| 9898 | case GL_PIXEL_PACK_BUFFER: |
| 9899 | readBuffer = context->getPixelPackBuffer(); |
| 9900 | break; |
| 9901 | case GL_PIXEL_UNPACK_BUFFER: |
| 9902 | readBuffer = context->getPixelUnpackBuffer(); |
| 9903 | break; |
| 9904 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 9905 | readBuffer = context->getGenericTransformFeedbackBuffer(); |
| 9906 | break; |
| 9907 | case GL_UNIFORM_BUFFER: |
| 9908 | readBuffer = context->getGenericUniformBuffer(); |
| 9909 | break; |
| 9910 | default: |
| 9911 | return gl::error(GL_INVALID_ENUM); |
| 9912 | } |
| 9913 | |
| 9914 | gl::Buffer *writeBuffer = NULL; |
| 9915 | switch (writeTarget) |
| 9916 | { |
| 9917 | case GL_ARRAY_BUFFER: |
| 9918 | writeBuffer = context->getArrayBuffer(); |
| 9919 | break; |
| 9920 | case GL_COPY_READ_BUFFER: |
| 9921 | writeBuffer = context->getCopyReadBuffer(); |
| 9922 | break; |
| 9923 | case GL_COPY_WRITE_BUFFER: |
| 9924 | writeBuffer = context->getCopyWriteBuffer(); |
| 9925 | break; |
| 9926 | case GL_ELEMENT_ARRAY_BUFFER: |
| 9927 | writeBuffer = context->getElementArrayBuffer(); |
| 9928 | break; |
| 9929 | case GL_PIXEL_PACK_BUFFER: |
| 9930 | writeBuffer = context->getPixelPackBuffer(); |
| 9931 | break; |
| 9932 | case GL_PIXEL_UNPACK_BUFFER: |
| 9933 | writeBuffer = context->getPixelUnpackBuffer(); |
| 9934 | break; |
| 9935 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 9936 | writeBuffer = context->getGenericTransformFeedbackBuffer(); |
| 9937 | break; |
| 9938 | case GL_UNIFORM_BUFFER: |
| 9939 | writeBuffer = context->getGenericUniformBuffer(); |
| 9940 | break; |
| 9941 | default: |
| 9942 | return gl::error(GL_INVALID_ENUM); |
| 9943 | } |
| 9944 | |
| 9945 | if (!readBuffer || !writeBuffer) |
| 9946 | { |
| 9947 | return gl::error(GL_INVALID_OPERATION); |
| 9948 | } |
| 9949 | |
| 9950 | if (readOffset < 0 || writeOffset < 0 || size < 0 || |
| 9951 | static_cast<unsigned int>(readOffset + size) > readBuffer->size() || |
| 9952 | static_cast<unsigned int>(writeOffset + size) > writeBuffer->size()) |
| 9953 | { |
| 9954 | return gl::error(GL_INVALID_VALUE); |
| 9955 | } |
| 9956 | |
| 9957 | if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size) |
| 9958 | { |
| 9959 | return gl::error(GL_INVALID_VALUE); |
| 9960 | } |
| 9961 | |
| 9962 | // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION) |
| 9963 | |
shannon.woods%transgaming.com@gtempaccount.com | c53376a | 2013-04-13 03:41:23 +0000 | [diff] [blame] | 9964 | // if size is zero, the copy is a successful no-op |
| 9965 | if (size > 0) |
| 9966 | { |
| 9967 | writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); |
| 9968 | } |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 9969 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9970 | } |
| 9971 | catch(std::bad_alloc&) |
| 9972 | { |
| 9973 | return gl::error(GL_OUT_OF_MEMORY); |
| 9974 | } |
| 9975 | } |
| 9976 | |
| 9977 | void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) |
| 9978 | { |
| 9979 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)", |
| 9980 | program, uniformCount, uniformNames, uniformIndices); |
| 9981 | |
| 9982 | try |
| 9983 | { |
| 9984 | gl::Context *context = gl::getNonLostContext(); |
| 9985 | |
| 9986 | if (context) |
| 9987 | { |
| 9988 | if (context->getClientVersion() < 3) |
| 9989 | { |
| 9990 | return gl::error(GL_INVALID_OPERATION); |
| 9991 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9992 | |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 9993 | if (uniformCount < 0) |
| 9994 | { |
| 9995 | return gl::error(GL_INVALID_VALUE); |
| 9996 | } |
| 9997 | |
| 9998 | gl::Program *programObject = context->getProgram(program); |
| 9999 | |
| 10000 | if (!programObject) |
| 10001 | { |
| 10002 | if (context->getShader(program)) |
| 10003 | { |
| 10004 | return gl::error(GL_INVALID_OPERATION); |
| 10005 | } |
| 10006 | else |
| 10007 | { |
| 10008 | return gl::error(GL_INVALID_VALUE); |
| 10009 | } |
| 10010 | } |
| 10011 | |
| 10012 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10013 | if (!programObject->isLinked() || !programBinary) |
| 10014 | { |
| 10015 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10016 | { |
| 10017 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 10018 | } |
| 10019 | } |
| 10020 | else |
| 10021 | { |
| 10022 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10023 | { |
| 10024 | uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]); |
| 10025 | } |
| 10026 | } |
| 10027 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10028 | } |
| 10029 | catch(std::bad_alloc&) |
| 10030 | { |
| 10031 | return gl::error(GL_OUT_OF_MEMORY); |
| 10032 | } |
| 10033 | } |
| 10034 | |
| 10035 | void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) |
| 10036 | { |
| 10037 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10038 | program, uniformCount, uniformIndices, pname, params); |
| 10039 | |
| 10040 | try |
| 10041 | { |
| 10042 | gl::Context *context = gl::getNonLostContext(); |
| 10043 | |
| 10044 | if (context) |
| 10045 | { |
| 10046 | if (context->getClientVersion() < 3) |
| 10047 | { |
| 10048 | return gl::error(GL_INVALID_OPERATION); |
| 10049 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10050 | |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 10051 | if (uniformCount < 0) |
| 10052 | { |
| 10053 | return gl::error(GL_INVALID_VALUE); |
| 10054 | } |
| 10055 | |
| 10056 | gl::Program *programObject = context->getProgram(program); |
| 10057 | |
| 10058 | if (!programObject) |
| 10059 | { |
| 10060 | if (context->getShader(program)) |
| 10061 | { |
| 10062 | return gl::error(GL_INVALID_OPERATION); |
| 10063 | } |
| 10064 | else |
| 10065 | { |
| 10066 | return gl::error(GL_INVALID_VALUE); |
| 10067 | } |
| 10068 | } |
| 10069 | |
| 10070 | switch (pname) |
| 10071 | { |
| 10072 | case GL_UNIFORM_TYPE: |
| 10073 | case GL_UNIFORM_SIZE: |
| 10074 | case GL_UNIFORM_NAME_LENGTH: |
| 10075 | case GL_UNIFORM_BLOCK_INDEX: |
| 10076 | case GL_UNIFORM_OFFSET: |
| 10077 | case GL_UNIFORM_ARRAY_STRIDE: |
| 10078 | case GL_UNIFORM_MATRIX_STRIDE: |
| 10079 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 10080 | break; |
| 10081 | default: |
| 10082 | return gl::error(GL_INVALID_ENUM); |
| 10083 | } |
| 10084 | |
| 10085 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10086 | |
| 10087 | if (!programBinary && uniformCount > 0) |
| 10088 | { |
| 10089 | return gl::error(GL_INVALID_VALUE); |
| 10090 | } |
| 10091 | |
| 10092 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10093 | { |
| 10094 | const GLuint index = uniformIndices[uniformId]; |
| 10095 | |
| 10096 | if (index >= (GLuint)programBinary->getActiveUniformCount()) |
| 10097 | { |
| 10098 | return gl::error(GL_INVALID_VALUE); |
| 10099 | } |
| 10100 | } |
| 10101 | |
| 10102 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10103 | { |
| 10104 | const GLuint index = uniformIndices[uniformId]; |
| 10105 | params[uniformId] = programBinary->getActiveUniformi(index, pname); |
| 10106 | } |
| 10107 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10108 | } |
| 10109 | catch(std::bad_alloc&) |
| 10110 | { |
| 10111 | return gl::error(GL_OUT_OF_MEMORY); |
| 10112 | } |
| 10113 | } |
| 10114 | |
| 10115 | GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) |
| 10116 | { |
| 10117 | EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName); |
| 10118 | |
| 10119 | try |
| 10120 | { |
| 10121 | gl::Context *context = gl::getNonLostContext(); |
| 10122 | |
| 10123 | if (context) |
| 10124 | { |
| 10125 | if (context->getClientVersion() < 3) |
| 10126 | { |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10127 | 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] | 10128 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10129 | |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10130 | gl::Program *programObject = context->getProgram(program); |
| 10131 | |
| 10132 | if (!programObject) |
| 10133 | { |
| 10134 | if (context->getShader(program)) |
| 10135 | { |
| 10136 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
| 10137 | } |
| 10138 | else |
| 10139 | { |
| 10140 | return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX); |
| 10141 | } |
| 10142 | } |
| 10143 | |
| 10144 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10145 | if (!programBinary) |
| 10146 | { |
| 10147 | return GL_INVALID_INDEX; |
| 10148 | } |
| 10149 | |
| 10150 | return programBinary->getUniformBlockIndex(uniformBlockName); |
| 10151 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10152 | } |
| 10153 | catch(std::bad_alloc&) |
| 10154 | { |
| 10155 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10156 | } |
| 10157 | |
| 10158 | return 0; |
| 10159 | } |
| 10160 | |
| 10161 | void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) |
| 10162 | { |
| 10163 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10164 | program, uniformBlockIndex, pname, params); |
| 10165 | |
| 10166 | try |
| 10167 | { |
| 10168 | gl::Context *context = gl::getNonLostContext(); |
| 10169 | |
| 10170 | if (context) |
| 10171 | { |
| 10172 | if (context->getClientVersion() < 3) |
| 10173 | { |
| 10174 | return gl::error(GL_INVALID_OPERATION); |
| 10175 | } |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10176 | gl::Program *programObject = context->getProgram(program); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10177 | |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10178 | if (!programObject) |
| 10179 | { |
| 10180 | if (context->getShader(program)) |
| 10181 | { |
| 10182 | return gl::error(GL_INVALID_OPERATION); |
| 10183 | } |
| 10184 | else |
| 10185 | { |
| 10186 | return gl::error(GL_INVALID_VALUE); |
| 10187 | } |
| 10188 | } |
| 10189 | |
| 10190 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10191 | |
| 10192 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10193 | { |
| 10194 | return gl::error(GL_INVALID_VALUE); |
| 10195 | } |
| 10196 | |
| 10197 | switch (pname) |
| 10198 | { |
| 10199 | case GL_UNIFORM_BLOCK_BINDING: |
| 10200 | *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); |
| 10201 | break; |
| 10202 | |
| 10203 | case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 10204 | case GL_UNIFORM_BLOCK_NAME_LENGTH: |
| 10205 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 10206 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| 10207 | case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
| 10208 | case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
| 10209 | programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params); |
| 10210 | break; |
| 10211 | |
| 10212 | default: |
| 10213 | return gl::error(GL_INVALID_ENUM); |
| 10214 | } |
| 10215 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10216 | } |
| 10217 | catch(std::bad_alloc&) |
| 10218 | { |
| 10219 | return gl::error(GL_OUT_OF_MEMORY); |
| 10220 | } |
| 10221 | } |
| 10222 | |
| 10223 | void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) |
| 10224 | { |
| 10225 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)", |
| 10226 | program, uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10227 | |
| 10228 | try |
| 10229 | { |
| 10230 | gl::Context *context = gl::getNonLostContext(); |
| 10231 | |
| 10232 | if (context) |
| 10233 | { |
| 10234 | if (context->getClientVersion() < 3) |
| 10235 | { |
| 10236 | return gl::error(GL_INVALID_OPERATION); |
| 10237 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10238 | |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 10239 | gl::Program *programObject = context->getProgram(program); |
| 10240 | |
| 10241 | if (!programObject) |
| 10242 | { |
| 10243 | if (context->getShader(program)) |
| 10244 | { |
| 10245 | return gl::error(GL_INVALID_OPERATION); |
| 10246 | } |
| 10247 | else |
| 10248 | { |
| 10249 | return gl::error(GL_INVALID_VALUE); |
| 10250 | } |
| 10251 | } |
| 10252 | |
| 10253 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10254 | |
| 10255 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10256 | { |
| 10257 | return gl::error(GL_INVALID_VALUE); |
| 10258 | } |
| 10259 | |
| 10260 | programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10261 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10262 | } |
| 10263 | catch(std::bad_alloc&) |
| 10264 | { |
| 10265 | return gl::error(GL_OUT_OF_MEMORY); |
| 10266 | } |
| 10267 | } |
| 10268 | |
| 10269 | void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) |
| 10270 | { |
| 10271 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)", |
| 10272 | program, uniformBlockIndex, uniformBlockBinding); |
| 10273 | |
| 10274 | try |
| 10275 | { |
| 10276 | gl::Context *context = gl::getNonLostContext(); |
| 10277 | |
| 10278 | if (context) |
| 10279 | { |
| 10280 | if (context->getClientVersion() < 3) |
| 10281 | { |
| 10282 | return gl::error(GL_INVALID_OPERATION); |
| 10283 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10284 | |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 10285 | if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings()) |
| 10286 | { |
| 10287 | return gl::error(GL_INVALID_VALUE); |
| 10288 | } |
| 10289 | |
| 10290 | gl::Program *programObject = context->getProgram(program); |
| 10291 | |
| 10292 | if (!programObject) |
| 10293 | { |
| 10294 | if (context->getShader(program)) |
| 10295 | { |
| 10296 | return gl::error(GL_INVALID_OPERATION); |
| 10297 | } |
| 10298 | else |
| 10299 | { |
| 10300 | return gl::error(GL_INVALID_VALUE); |
| 10301 | } |
| 10302 | } |
| 10303 | |
| 10304 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10305 | |
| 10306 | // if never linked, there won't be any uniform blocks |
| 10307 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10308 | { |
| 10309 | return gl::error(GL_INVALID_VALUE); |
| 10310 | } |
| 10311 | |
| 10312 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
| 10313 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10314 | } |
| 10315 | catch(std::bad_alloc&) |
| 10316 | { |
| 10317 | return gl::error(GL_OUT_OF_MEMORY); |
| 10318 | } |
| 10319 | } |
| 10320 | |
| 10321 | void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 10322 | { |
| 10323 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)", |
| 10324 | mode, first, count, instanceCount); |
| 10325 | |
| 10326 | try |
| 10327 | { |
| 10328 | gl::Context *context = gl::getNonLostContext(); |
| 10329 | |
| 10330 | if (context) |
| 10331 | { |
| 10332 | if (context->getClientVersion() < 3) |
| 10333 | { |
| 10334 | return gl::error(GL_INVALID_OPERATION); |
| 10335 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10336 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10337 | UNIMPLEMENTED(); |
| 10338 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10339 | } |
| 10340 | catch(std::bad_alloc&) |
| 10341 | { |
| 10342 | return gl::error(GL_OUT_OF_MEMORY); |
| 10343 | } |
| 10344 | } |
| 10345 | |
| 10346 | void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) |
| 10347 | { |
| 10348 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)", |
| 10349 | mode, count, type, indices, instanceCount); |
| 10350 | |
| 10351 | try |
| 10352 | { |
| 10353 | gl::Context *context = gl::getNonLostContext(); |
| 10354 | |
| 10355 | if (context) |
| 10356 | { |
| 10357 | if (context->getClientVersion() < 3) |
| 10358 | { |
| 10359 | return gl::error(GL_INVALID_OPERATION); |
| 10360 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10361 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10362 | UNIMPLEMENTED(); |
| 10363 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10364 | } |
| 10365 | catch(std::bad_alloc&) |
| 10366 | { |
| 10367 | return gl::error(GL_OUT_OF_MEMORY); |
| 10368 | } |
| 10369 | } |
| 10370 | |
| 10371 | GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags) |
| 10372 | { |
| 10373 | EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags); |
| 10374 | |
| 10375 | try |
| 10376 | { |
| 10377 | gl::Context *context = gl::getNonLostContext(); |
| 10378 | |
| 10379 | if (context) |
| 10380 | { |
| 10381 | if (context->getClientVersion() < 3) |
| 10382 | { |
| 10383 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(NULL)); |
| 10384 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10385 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10386 | UNIMPLEMENTED(); |
| 10387 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10388 | } |
| 10389 | catch(std::bad_alloc&) |
| 10390 | { |
| 10391 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL)); |
| 10392 | } |
| 10393 | |
| 10394 | return NULL; |
| 10395 | } |
| 10396 | |
| 10397 | GLboolean __stdcall glIsSync(GLsync sync) |
| 10398 | { |
| 10399 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10400 | |
| 10401 | try |
| 10402 | { |
| 10403 | gl::Context *context = gl::getNonLostContext(); |
| 10404 | |
| 10405 | if (context) |
| 10406 | { |
| 10407 | if (context->getClientVersion() < 3) |
| 10408 | { |
| 10409 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10410 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10411 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10412 | UNIMPLEMENTED(); |
| 10413 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10414 | } |
| 10415 | catch(std::bad_alloc&) |
| 10416 | { |
| 10417 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10418 | } |
| 10419 | |
| 10420 | return GL_FALSE; |
| 10421 | } |
| 10422 | |
| 10423 | void __stdcall glDeleteSync(GLsync sync) |
| 10424 | { |
| 10425 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10426 | |
| 10427 | try |
| 10428 | { |
| 10429 | gl::Context *context = gl::getNonLostContext(); |
| 10430 | |
| 10431 | if (context) |
| 10432 | { |
| 10433 | if (context->getClientVersion() < 3) |
| 10434 | { |
| 10435 | return gl::error(GL_INVALID_OPERATION); |
| 10436 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10437 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10438 | UNIMPLEMENTED(); |
| 10439 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10440 | } |
| 10441 | catch(std::bad_alloc&) |
| 10442 | { |
| 10443 | return gl::error(GL_OUT_OF_MEMORY); |
| 10444 | } |
| 10445 | } |
| 10446 | |
| 10447 | GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10448 | { |
| 10449 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10450 | sync, flags, timeout); |
| 10451 | |
| 10452 | try |
| 10453 | { |
| 10454 | gl::Context *context = gl::getNonLostContext(); |
| 10455 | |
| 10456 | if (context) |
| 10457 | { |
| 10458 | if (context->getClientVersion() < 3) |
| 10459 | { |
| 10460 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10461 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10462 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10463 | UNIMPLEMENTED(); |
| 10464 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10465 | } |
| 10466 | catch(std::bad_alloc&) |
| 10467 | { |
| 10468 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10469 | } |
| 10470 | |
| 10471 | return GL_FALSE; |
| 10472 | } |
| 10473 | |
| 10474 | void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10475 | { |
| 10476 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10477 | sync, flags, timeout); |
| 10478 | |
| 10479 | try |
| 10480 | { |
| 10481 | gl::Context *context = gl::getNonLostContext(); |
| 10482 | |
| 10483 | if (context) |
| 10484 | { |
| 10485 | if (context->getClientVersion() < 3) |
| 10486 | { |
| 10487 | return gl::error(GL_INVALID_OPERATION); |
| 10488 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10489 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10490 | UNIMPLEMENTED(); |
| 10491 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10492 | } |
| 10493 | catch(std::bad_alloc&) |
| 10494 | { |
| 10495 | return gl::error(GL_OUT_OF_MEMORY); |
| 10496 | } |
| 10497 | } |
| 10498 | |
| 10499 | void __stdcall glGetInteger64v(GLenum pname, GLint64* params) |
| 10500 | { |
| 10501 | EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10502 | pname, params); |
| 10503 | |
| 10504 | try |
| 10505 | { |
| 10506 | gl::Context *context = gl::getNonLostContext(); |
| 10507 | |
| 10508 | if (context) |
| 10509 | { |
| 10510 | if (context->getClientVersion() < 3) |
| 10511 | { |
| 10512 | return gl::error(GL_INVALID_OPERATION); |
| 10513 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10514 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10515 | UNIMPLEMENTED(); |
| 10516 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10517 | } |
| 10518 | catch(std::bad_alloc&) |
| 10519 | { |
| 10520 | return gl::error(GL_OUT_OF_MEMORY); |
| 10521 | } |
| 10522 | } |
| 10523 | |
| 10524 | void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) |
| 10525 | { |
| 10526 | EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)", |
| 10527 | sync, pname, bufSize, length, values); |
| 10528 | |
| 10529 | try |
| 10530 | { |
| 10531 | gl::Context *context = gl::getNonLostContext(); |
| 10532 | |
| 10533 | if (context) |
| 10534 | { |
| 10535 | if (context->getClientVersion() < 3) |
| 10536 | { |
| 10537 | return gl::error(GL_INVALID_OPERATION); |
| 10538 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10539 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10540 | UNIMPLEMENTED(); |
| 10541 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10542 | } |
| 10543 | catch(std::bad_alloc&) |
| 10544 | { |
| 10545 | return gl::error(GL_OUT_OF_MEMORY); |
| 10546 | } |
| 10547 | } |
| 10548 | |
| 10549 | void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) |
| 10550 | { |
| 10551 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)", |
| 10552 | target, index, data); |
| 10553 | |
| 10554 | try |
| 10555 | { |
| 10556 | gl::Context *context = gl::getNonLostContext(); |
| 10557 | |
| 10558 | if (context) |
| 10559 | { |
| 10560 | if (context->getClientVersion() < 3) |
| 10561 | { |
| 10562 | return gl::error(GL_INVALID_OPERATION); |
| 10563 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10564 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10565 | UNIMPLEMENTED(); |
| 10566 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10567 | } |
| 10568 | catch(std::bad_alloc&) |
| 10569 | { |
| 10570 | return gl::error(GL_OUT_OF_MEMORY); |
| 10571 | } |
| 10572 | } |
| 10573 | |
| 10574 | void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) |
| 10575 | { |
| 10576 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10577 | target, pname, params); |
| 10578 | |
| 10579 | try |
| 10580 | { |
| 10581 | gl::Context *context = gl::getNonLostContext(); |
| 10582 | |
| 10583 | if (context) |
| 10584 | { |
| 10585 | if (context->getClientVersion() < 3) |
| 10586 | { |
| 10587 | return gl::error(GL_INVALID_OPERATION); |
| 10588 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10589 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10590 | UNIMPLEMENTED(); |
| 10591 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10592 | } |
| 10593 | catch(std::bad_alloc&) |
| 10594 | { |
| 10595 | return gl::error(GL_OUT_OF_MEMORY); |
| 10596 | } |
| 10597 | } |
| 10598 | |
| 10599 | void __stdcall glGenSamplers(GLsizei count, GLuint* samplers) |
| 10600 | { |
| 10601 | EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers); |
| 10602 | |
| 10603 | try |
| 10604 | { |
| 10605 | gl::Context *context = gl::getNonLostContext(); |
| 10606 | |
| 10607 | if (context) |
| 10608 | { |
| 10609 | if (context->getClientVersion() < 3) |
| 10610 | { |
| 10611 | return gl::error(GL_INVALID_OPERATION); |
| 10612 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10613 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10614 | UNIMPLEMENTED(); |
| 10615 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10616 | } |
| 10617 | catch(std::bad_alloc&) |
| 10618 | { |
| 10619 | return gl::error(GL_OUT_OF_MEMORY); |
| 10620 | } |
| 10621 | } |
| 10622 | |
| 10623 | void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers) |
| 10624 | { |
| 10625 | EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers); |
| 10626 | |
| 10627 | try |
| 10628 | { |
| 10629 | gl::Context *context = gl::getNonLostContext(); |
| 10630 | |
| 10631 | if (context) |
| 10632 | { |
| 10633 | if (context->getClientVersion() < 3) |
| 10634 | { |
| 10635 | return gl::error(GL_INVALID_OPERATION); |
| 10636 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10637 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10638 | UNIMPLEMENTED(); |
| 10639 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10640 | } |
| 10641 | catch(std::bad_alloc&) |
| 10642 | { |
| 10643 | return gl::error(GL_OUT_OF_MEMORY); |
| 10644 | } |
| 10645 | } |
| 10646 | |
| 10647 | GLboolean __stdcall glIsSampler(GLuint sampler) |
| 10648 | { |
| 10649 | EVENT("(GLuint sampler = %u)", sampler); |
| 10650 | |
| 10651 | try |
| 10652 | { |
| 10653 | gl::Context *context = gl::getNonLostContext(); |
| 10654 | |
| 10655 | if (context) |
| 10656 | { |
| 10657 | if (context->getClientVersion() < 3) |
| 10658 | { |
| 10659 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10660 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10661 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10662 | UNIMPLEMENTED(); |
| 10663 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10664 | } |
| 10665 | catch(std::bad_alloc&) |
| 10666 | { |
| 10667 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10668 | } |
| 10669 | |
| 10670 | return GL_FALSE; |
| 10671 | } |
| 10672 | |
| 10673 | void __stdcall glBindSampler(GLuint unit, GLuint sampler) |
| 10674 | { |
| 10675 | EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler); |
| 10676 | |
| 10677 | try |
| 10678 | { |
| 10679 | gl::Context *context = gl::getNonLostContext(); |
| 10680 | |
| 10681 | if (context) |
| 10682 | { |
| 10683 | if (context->getClientVersion() < 3) |
| 10684 | { |
| 10685 | return gl::error(GL_INVALID_OPERATION); |
| 10686 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10687 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10688 | UNIMPLEMENTED(); |
| 10689 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10690 | } |
| 10691 | catch(std::bad_alloc&) |
| 10692 | { |
| 10693 | return gl::error(GL_OUT_OF_MEMORY); |
| 10694 | } |
| 10695 | } |
| 10696 | |
| 10697 | void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 10698 | { |
| 10699 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param); |
| 10700 | |
| 10701 | try |
| 10702 | { |
| 10703 | gl::Context *context = gl::getNonLostContext(); |
| 10704 | |
| 10705 | if (context) |
| 10706 | { |
| 10707 | if (context->getClientVersion() < 3) |
| 10708 | { |
| 10709 | return gl::error(GL_INVALID_OPERATION); |
| 10710 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10711 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10712 | UNIMPLEMENTED(); |
| 10713 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10714 | } |
| 10715 | catch(std::bad_alloc&) |
| 10716 | { |
| 10717 | return gl::error(GL_OUT_OF_MEMORY); |
| 10718 | } |
| 10719 | } |
| 10720 | |
| 10721 | void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) |
| 10722 | { |
| 10723 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLint* param = 0x%0.8p)", |
| 10724 | sampler, pname, param); |
| 10725 | |
| 10726 | try |
| 10727 | { |
| 10728 | gl::Context *context = gl::getNonLostContext(); |
| 10729 | |
| 10730 | if (context) |
| 10731 | { |
| 10732 | if (context->getClientVersion() < 3) |
| 10733 | { |
| 10734 | return gl::error(GL_INVALID_OPERATION); |
| 10735 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10736 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10737 | UNIMPLEMENTED(); |
| 10738 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10739 | } |
| 10740 | catch(std::bad_alloc&) |
| 10741 | { |
| 10742 | return gl::error(GL_OUT_OF_MEMORY); |
| 10743 | } |
| 10744 | } |
| 10745 | |
| 10746 | void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 10747 | { |
| 10748 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param); |
| 10749 | |
| 10750 | try |
| 10751 | { |
| 10752 | gl::Context *context = gl::getNonLostContext(); |
| 10753 | |
| 10754 | if (context) |
| 10755 | { |
| 10756 | if (context->getClientVersion() < 3) |
| 10757 | { |
| 10758 | return gl::error(GL_INVALID_OPERATION); |
| 10759 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10760 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10761 | UNIMPLEMENTED(); |
| 10762 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10763 | } |
| 10764 | catch(std::bad_alloc&) |
| 10765 | { |
| 10766 | return gl::error(GL_OUT_OF_MEMORY); |
| 10767 | } |
| 10768 | } |
| 10769 | |
| 10770 | void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) |
| 10771 | { |
| 10772 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLfloat* param = 0x%0.8p)", sampler, pname, param); |
| 10773 | |
| 10774 | try |
| 10775 | { |
| 10776 | gl::Context *context = gl::getNonLostContext(); |
| 10777 | |
| 10778 | if (context) |
| 10779 | { |
| 10780 | if (context->getClientVersion() < 3) |
| 10781 | { |
| 10782 | return gl::error(GL_INVALID_OPERATION); |
| 10783 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10784 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10785 | UNIMPLEMENTED(); |
| 10786 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10787 | } |
| 10788 | catch(std::bad_alloc&) |
| 10789 | { |
| 10790 | return gl::error(GL_OUT_OF_MEMORY); |
| 10791 | } |
| 10792 | } |
| 10793 | |
| 10794 | void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) |
| 10795 | { |
| 10796 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); |
| 10797 | |
| 10798 | try |
| 10799 | { |
| 10800 | gl::Context *context = gl::getNonLostContext(); |
| 10801 | |
| 10802 | if (context) |
| 10803 | { |
| 10804 | if (context->getClientVersion() < 3) |
| 10805 | { |
| 10806 | return gl::error(GL_INVALID_OPERATION); |
| 10807 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10808 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10809 | UNIMPLEMENTED(); |
| 10810 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10811 | } |
| 10812 | catch(std::bad_alloc&) |
| 10813 | { |
| 10814 | return gl::error(GL_OUT_OF_MEMORY); |
| 10815 | } |
| 10816 | } |
| 10817 | |
| 10818 | void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) |
| 10819 | { |
| 10820 | EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params); |
| 10821 | |
| 10822 | try |
| 10823 | { |
| 10824 | gl::Context *context = gl::getNonLostContext(); |
| 10825 | |
| 10826 | if (context) |
| 10827 | { |
| 10828 | if (context->getClientVersion() < 3) |
| 10829 | { |
| 10830 | return gl::error(GL_INVALID_OPERATION); |
| 10831 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10832 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10833 | UNIMPLEMENTED(); |
| 10834 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10835 | } |
| 10836 | catch(std::bad_alloc&) |
| 10837 | { |
| 10838 | return gl::error(GL_OUT_OF_MEMORY); |
| 10839 | } |
| 10840 | } |
| 10841 | |
| 10842 | void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor) |
| 10843 | { |
| 10844 | EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor); |
| 10845 | |
| 10846 | try |
| 10847 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 10848 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 10849 | { |
| 10850 | return gl::error(GL_INVALID_VALUE); |
| 10851 | } |
| 10852 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10853 | gl::Context *context = gl::getNonLostContext(); |
| 10854 | |
| 10855 | if (context) |
| 10856 | { |
| 10857 | if (context->getClientVersion() < 3) |
| 10858 | { |
| 10859 | return gl::error(GL_INVALID_OPERATION); |
| 10860 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10861 | |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 10862 | context->setVertexAttribDivisor(index, divisor); |
| 10863 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10864 | } |
| 10865 | catch(std::bad_alloc&) |
| 10866 | { |
| 10867 | return gl::error(GL_OUT_OF_MEMORY); |
| 10868 | } |
| 10869 | } |
| 10870 | |
| 10871 | void __stdcall glBindTransformFeedback(GLenum target, GLuint id) |
| 10872 | { |
| 10873 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 10874 | |
| 10875 | try |
| 10876 | { |
| 10877 | gl::Context *context = gl::getNonLostContext(); |
| 10878 | |
| 10879 | if (context) |
| 10880 | { |
| 10881 | if (context->getClientVersion() < 3) |
| 10882 | { |
| 10883 | return gl::error(GL_INVALID_OPERATION); |
| 10884 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10885 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10886 | UNIMPLEMENTED(); |
| 10887 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10888 | } |
| 10889 | catch(std::bad_alloc&) |
| 10890 | { |
| 10891 | return gl::error(GL_OUT_OF_MEMORY); |
| 10892 | } |
| 10893 | } |
| 10894 | |
| 10895 | void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) |
| 10896 | { |
| 10897 | EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids); |
| 10898 | |
| 10899 | try |
| 10900 | { |
| 10901 | gl::Context *context = gl::getNonLostContext(); |
| 10902 | |
| 10903 | if (context) |
| 10904 | { |
| 10905 | if (context->getClientVersion() < 3) |
| 10906 | { |
| 10907 | return gl::error(GL_INVALID_OPERATION); |
| 10908 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10909 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10910 | UNIMPLEMENTED(); |
| 10911 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10912 | } |
| 10913 | catch(std::bad_alloc&) |
| 10914 | { |
| 10915 | return gl::error(GL_OUT_OF_MEMORY); |
| 10916 | } |
| 10917 | } |
| 10918 | |
| 10919 | void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids) |
| 10920 | { |
| 10921 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 10922 | |
| 10923 | try |
| 10924 | { |
| 10925 | gl::Context *context = gl::getNonLostContext(); |
| 10926 | |
| 10927 | if (context) |
| 10928 | { |
| 10929 | if (context->getClientVersion() < 3) |
| 10930 | { |
| 10931 | return gl::error(GL_INVALID_OPERATION); |
| 10932 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10933 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10934 | UNIMPLEMENTED(); |
| 10935 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10936 | } |
| 10937 | catch(std::bad_alloc&) |
| 10938 | { |
| 10939 | return gl::error(GL_OUT_OF_MEMORY); |
| 10940 | } |
| 10941 | } |
| 10942 | |
| 10943 | GLboolean __stdcall glIsTransformFeedback(GLuint id) |
| 10944 | { |
| 10945 | EVENT("(GLuint id = %u)", id); |
| 10946 | |
| 10947 | try |
| 10948 | { |
| 10949 | gl::Context *context = gl::getNonLostContext(); |
| 10950 | |
| 10951 | if (context) |
| 10952 | { |
| 10953 | if (context->getClientVersion() < 3) |
| 10954 | { |
| 10955 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10956 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10957 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10958 | UNIMPLEMENTED(); |
| 10959 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10960 | } |
| 10961 | catch(std::bad_alloc&) |
| 10962 | { |
| 10963 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10964 | } |
| 10965 | |
| 10966 | return GL_FALSE; |
| 10967 | } |
| 10968 | |
| 10969 | void __stdcall glPauseTransformFeedback(void) |
| 10970 | { |
| 10971 | EVENT("(void)"); |
| 10972 | |
| 10973 | try |
| 10974 | { |
| 10975 | gl::Context *context = gl::getNonLostContext(); |
| 10976 | |
| 10977 | if (context) |
| 10978 | { |
| 10979 | if (context->getClientVersion() < 3) |
| 10980 | { |
| 10981 | return gl::error(GL_INVALID_OPERATION); |
| 10982 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10983 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10984 | UNIMPLEMENTED(); |
| 10985 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10986 | } |
| 10987 | catch(std::bad_alloc&) |
| 10988 | { |
| 10989 | return gl::error(GL_OUT_OF_MEMORY); |
| 10990 | } |
| 10991 | } |
| 10992 | |
| 10993 | void __stdcall glResumeTransformFeedback(void) |
| 10994 | { |
| 10995 | EVENT("(void)"); |
| 10996 | |
| 10997 | try |
| 10998 | { |
| 10999 | gl::Context *context = gl::getNonLostContext(); |
| 11000 | |
| 11001 | if (context) |
| 11002 | { |
| 11003 | if (context->getClientVersion() < 3) |
| 11004 | { |
| 11005 | return gl::error(GL_INVALID_OPERATION); |
| 11006 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11007 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11008 | UNIMPLEMENTED(); |
| 11009 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11010 | } |
| 11011 | catch(std::bad_alloc&) |
| 11012 | { |
| 11013 | return gl::error(GL_OUT_OF_MEMORY); |
| 11014 | } |
| 11015 | } |
| 11016 | |
| 11017 | void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) |
| 11018 | { |
| 11019 | EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)", |
| 11020 | program, bufSize, length, binaryFormat, binary); |
| 11021 | |
| 11022 | try |
| 11023 | { |
| 11024 | gl::Context *context = gl::getNonLostContext(); |
| 11025 | |
| 11026 | if (context) |
| 11027 | { |
| 11028 | if (context->getClientVersion() < 3) |
| 11029 | { |
| 11030 | return gl::error(GL_INVALID_OPERATION); |
| 11031 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11032 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11033 | UNIMPLEMENTED(); |
| 11034 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11035 | } |
| 11036 | catch(std::bad_alloc&) |
| 11037 | { |
| 11038 | return gl::error(GL_OUT_OF_MEMORY); |
| 11039 | } |
| 11040 | } |
| 11041 | |
| 11042 | void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) |
| 11043 | { |
| 11044 | EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
| 11045 | program, binaryFormat, binary, length); |
| 11046 | |
| 11047 | try |
| 11048 | { |
| 11049 | gl::Context *context = gl::getNonLostContext(); |
| 11050 | |
| 11051 | if (context) |
| 11052 | { |
| 11053 | if (context->getClientVersion() < 3) |
| 11054 | { |
| 11055 | return gl::error(GL_INVALID_OPERATION); |
| 11056 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11057 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11058 | UNIMPLEMENTED(); |
| 11059 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11060 | } |
| 11061 | catch(std::bad_alloc&) |
| 11062 | { |
| 11063 | return gl::error(GL_OUT_OF_MEMORY); |
| 11064 | } |
| 11065 | } |
| 11066 | |
| 11067 | void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value) |
| 11068 | { |
| 11069 | EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)", |
| 11070 | program, pname, value); |
| 11071 | |
| 11072 | try |
| 11073 | { |
| 11074 | gl::Context *context = gl::getNonLostContext(); |
| 11075 | |
| 11076 | if (context) |
| 11077 | { |
| 11078 | if (context->getClientVersion() < 3) |
| 11079 | { |
| 11080 | return gl::error(GL_INVALID_OPERATION); |
| 11081 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11082 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11083 | UNIMPLEMENTED(); |
| 11084 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11085 | } |
| 11086 | catch(std::bad_alloc&) |
| 11087 | { |
| 11088 | return gl::error(GL_OUT_OF_MEMORY); |
| 11089 | } |
| 11090 | } |
| 11091 | |
| 11092 | void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) |
| 11093 | { |
| 11094 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)", |
| 11095 | target, numAttachments, attachments); |
| 11096 | |
| 11097 | try |
| 11098 | { |
| 11099 | gl::Context *context = gl::getNonLostContext(); |
| 11100 | |
| 11101 | if (context) |
| 11102 | { |
| 11103 | if (context->getClientVersion() < 3) |
| 11104 | { |
| 11105 | return gl::error(GL_INVALID_OPERATION); |
| 11106 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11107 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11108 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11109 | { |
| 11110 | return; |
| 11111 | } |
| 11112 | |
| 11113 | int maxDimension = context->getMaximumRenderbufferDimension(); |
| 11114 | context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension); |
| 11115 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11116 | } |
| 11117 | catch(std::bad_alloc&) |
| 11118 | { |
| 11119 | return gl::error(GL_OUT_OF_MEMORY); |
| 11120 | } |
| 11121 | } |
| 11122 | |
| 11123 | void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) |
| 11124 | { |
| 11125 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, " |
| 11126 | "GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 11127 | target, numAttachments, attachments, x, y, width, height); |
| 11128 | |
| 11129 | try |
| 11130 | { |
| 11131 | gl::Context *context = gl::getNonLostContext(); |
| 11132 | |
| 11133 | if (context) |
| 11134 | { |
| 11135 | if (context->getClientVersion() < 3) |
| 11136 | { |
| 11137 | return gl::error(GL_INVALID_OPERATION); |
| 11138 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11139 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11140 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11141 | { |
| 11142 | return; |
| 11143 | } |
| 11144 | |
| 11145 | context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height); |
| 11146 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11147 | } |
| 11148 | catch(std::bad_alloc&) |
| 11149 | { |
| 11150 | return gl::error(GL_OUT_OF_MEMORY); |
| 11151 | } |
| 11152 | } |
| 11153 | |
| 11154 | void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 11155 | { |
| 11156 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 11157 | target, levels, internalformat, width, height); |
| 11158 | |
| 11159 | try |
| 11160 | { |
| 11161 | gl::Context *context = gl::getNonLostContext(); |
| 11162 | |
| 11163 | if (context) |
| 11164 | { |
| 11165 | if (context->getClientVersion() < 3) |
| 11166 | { |
| 11167 | return gl::error(GL_INVALID_OPERATION); |
| 11168 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11169 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11170 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 11171 | { |
| 11172 | return; |
| 11173 | } |
| 11174 | |
| 11175 | switch (target) |
| 11176 | { |
| 11177 | case GL_TEXTURE_2D: |
| 11178 | { |
| 11179 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 11180 | texture2d->storage(levels, internalformat, width, height); |
| 11181 | } |
| 11182 | break; |
| 11183 | |
| 11184 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 11185 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 11186 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 11187 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 11188 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 11189 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 11190 | { |
| 11191 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 11192 | textureCube->storage(levels, internalformat, width); |
| 11193 | } |
| 11194 | break; |
| 11195 | |
| 11196 | default: |
| 11197 | return gl::error(GL_INVALID_ENUM); |
| 11198 | } |
| 11199 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11200 | } |
| 11201 | catch(std::bad_alloc&) |
| 11202 | { |
| 11203 | return gl::error(GL_OUT_OF_MEMORY); |
| 11204 | } |
| 11205 | } |
| 11206 | |
| 11207 | void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
| 11208 | { |
| 11209 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 11210 | "GLsizei height = %d, GLsizei depth = %d)", |
| 11211 | target, levels, internalformat, width, height, depth); |
| 11212 | |
| 11213 | try |
| 11214 | { |
| 11215 | gl::Context *context = gl::getNonLostContext(); |
| 11216 | |
| 11217 | if (context) |
| 11218 | { |
| 11219 | if (context->getClientVersion() < 3) |
| 11220 | { |
| 11221 | return gl::error(GL_INVALID_OPERATION); |
| 11222 | } |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11223 | |
| 11224 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) |
| 11225 | { |
| 11226 | return; |
| 11227 | } |
| 11228 | |
| 11229 | switch (target) |
| 11230 | { |
| 11231 | case GL_TEXTURE_3D: |
| 11232 | { |
| 11233 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 11234 | texture3d->storage(levels, internalformat, width, height, depth); |
| 11235 | } |
| 11236 | break; |
| 11237 | |
| 11238 | case GL_TEXTURE_2D_ARRAY: |
| 11239 | { |
| 11240 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 11241 | texture2darray->storage(levels, internalformat, width, height, depth); |
| 11242 | } |
| 11243 | break; |
| 11244 | |
| 11245 | default: |
| 11246 | return gl::error(GL_INVALID_ENUM); |
| 11247 | } |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 11248 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11249 | } |
| 11250 | catch(std::bad_alloc&) |
| 11251 | { |
| 11252 | return gl::error(GL_OUT_OF_MEMORY); |
| 11253 | } |
| 11254 | } |
| 11255 | |
| 11256 | void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) |
| 11257 | { |
| 11258 | EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, " |
| 11259 | "GLint* params = 0x%0.8p)", |
| 11260 | target, internalformat, pname, bufSize, params); |
| 11261 | |
| 11262 | try |
| 11263 | { |
| 11264 | gl::Context *context = gl::getNonLostContext(); |
| 11265 | |
| 11266 | if (context) |
| 11267 | { |
| 11268 | if (context->getClientVersion() < 3) |
| 11269 | { |
| 11270 | return gl::error(GL_INVALID_OPERATION); |
| 11271 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11272 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11273 | UNIMPLEMENTED(); |
| 11274 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11275 | } |
| 11276 | catch(std::bad_alloc&) |
| 11277 | { |
| 11278 | return gl::error(GL_OUT_OF_MEMORY); |
| 11279 | } |
| 11280 | } |
| 11281 | |
| 11282 | // Extension functions |
| 11283 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11284 | void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 11285 | GLbitfield mask, GLenum filter) |
| 11286 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11287 | 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] | 11288 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, " |
| 11289 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 11290 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 11291 | |
| 11292 | try |
| 11293 | { |
| 11294 | switch (filter) |
| 11295 | { |
| 11296 | case GL_NEAREST: |
| 11297 | break; |
| 11298 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11299 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11300 | } |
| 11301 | |
| 11302 | if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0) |
| 11303 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11304 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11305 | } |
| 11306 | |
| 11307 | if (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0) |
| 11308 | { |
| 11309 | ERR("Scaling and flipping in BlitFramebufferANGLE not supported by this implementation"); |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11310 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11311 | } |
| 11312 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11313 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11314 | |
| 11315 | if (context) |
| 11316 | { |
| 11317 | if (context->getReadFramebufferHandle() == context->getDrawFramebufferHandle()) |
| 11318 | { |
| 11319 | ERR("Blits with the same source and destination framebuffer are not supported by this implementation."); |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11320 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11321 | } |
| 11322 | |
| 11323 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask); |
| 11324 | } |
| 11325 | } |
| 11326 | catch(std::bad_alloc&) |
| 11327 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11328 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11329 | } |
| 11330 | } |
| 11331 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 11332 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, |
| 11333 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11334 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11335 | 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] | 11336 | "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] | 11337 | "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] | 11338 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 11339 | |
| 11340 | try |
| 11341 | { |
| 11342 | UNIMPLEMENTED(); // FIXME |
| 11343 | } |
| 11344 | catch(std::bad_alloc&) |
| 11345 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11346 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11347 | } |
| 11348 | } |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11349 | |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11350 | void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, |
| 11351 | GLenum *binaryFormat, void *binary) |
| 11352 | { |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11353 | 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] | 11354 | program, bufSize, length, binaryFormat, binary); |
| 11355 | |
| 11356 | try |
| 11357 | { |
| 11358 | gl::Context *context = gl::getNonLostContext(); |
| 11359 | |
| 11360 | if (context) |
| 11361 | { |
| 11362 | gl::Program *programObject = context->getProgram(program); |
| 11363 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 11364 | if (!programObject || !programObject->isLinked()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11365 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11366 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11367 | } |
| 11368 | |
| 11369 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 11370 | |
| 11371 | if (!programBinary) |
| 11372 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11373 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11374 | } |
| 11375 | |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11376 | if (!programBinary->save(binary, bufSize, length)) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11377 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11378 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11379 | } |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11380 | |
| 11381 | *binaryFormat = GL_PROGRAM_BINARY_ANGLE; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11382 | } |
| 11383 | } |
| 11384 | catch(std::bad_alloc&) |
| 11385 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11386 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11387 | } |
| 11388 | } |
| 11389 | |
| 11390 | void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat, |
| 11391 | const void *binary, GLint length) |
| 11392 | { |
| 11393 | EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)", |
| 11394 | program, binaryFormat, binary, length); |
| 11395 | |
| 11396 | try |
| 11397 | { |
| 11398 | gl::Context *context = gl::getNonLostContext(); |
| 11399 | |
| 11400 | if (context) |
| 11401 | { |
| 11402 | if (binaryFormat != GL_PROGRAM_BINARY_ANGLE) |
| 11403 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11404 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11405 | } |
| 11406 | |
| 11407 | gl::Program *programObject = context->getProgram(program); |
| 11408 | |
| 11409 | if (!programObject) |
| 11410 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11411 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11412 | } |
| 11413 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 11414 | context->setProgramBinary(program, binary, length); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11415 | } |
| 11416 | } |
| 11417 | catch(std::bad_alloc&) |
| 11418 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11419 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11420 | } |
| 11421 | } |
| 11422 | |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11423 | void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) |
| 11424 | { |
| 11425 | EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs); |
| 11426 | |
| 11427 | try |
| 11428 | { |
| 11429 | gl::Context *context = gl::getNonLostContext(); |
| 11430 | |
| 11431 | if (context) |
| 11432 | { |
| 11433 | if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets()) |
| 11434 | { |
| 11435 | return gl::error(GL_INVALID_VALUE); |
| 11436 | } |
| 11437 | |
| 11438 | if (context->getDrawFramebufferHandle() == 0) |
| 11439 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11440 | if (n != 1) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11441 | { |
| 11442 | return gl::error(GL_INVALID_OPERATION); |
| 11443 | } |
| 11444 | |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11445 | 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] | 11446 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11447 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11448 | } |
| 11449 | } |
| 11450 | else |
| 11451 | { |
| 11452 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 11453 | { |
| 11454 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 11455 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment) |
| 11456 | { |
| 11457 | return gl::error(GL_INVALID_OPERATION); |
| 11458 | } |
| 11459 | } |
| 11460 | } |
| 11461 | |
| 11462 | gl::Framebuffer *framebuffer = context->getDrawFramebuffer(); |
| 11463 | |
| 11464 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 11465 | { |
| 11466 | framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]); |
| 11467 | } |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11468 | |
| 11469 | for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++) |
| 11470 | { |
| 11471 | framebuffer->setDrawBufferState(colorAttachment, GL_NONE); |
| 11472 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11473 | } |
| 11474 | } |
| 11475 | catch (std::bad_alloc&) |
| 11476 | { |
| 11477 | return gl::error(GL_OUT_OF_MEMORY); |
| 11478 | } |
| 11479 | } |
| 11480 | |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11481 | __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) |
| 11482 | { |
| 11483 | struct Extension |
| 11484 | { |
| 11485 | const char *name; |
| 11486 | __eglMustCastToProperFunctionPointerType address; |
| 11487 | }; |
| 11488 | |
| 11489 | static const Extension glExtensions[] = |
| 11490 | { |
| 11491 | {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 11492 | {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, |
daniel@transgaming.com | 1fe96c9 | 2011-01-14 15:08:44 +0000 | [diff] [blame] | 11493 | {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 11494 | {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, |
| 11495 | {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, |
| 11496 | {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, |
| 11497 | {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, |
| 11498 | {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, |
| 11499 | {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, |
| 11500 | {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 11501 | {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE}, |
daniel@transgaming.com | 0bd1f2f | 2011-11-11 04:19:03 +0000 | [diff] [blame] | 11502 | {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT}, |
daniel@transgaming.com | 709ed11 | 2011-11-12 03:18:10 +0000 | [diff] [blame] | 11503 | {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT}, |
| 11504 | {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT}, |
| 11505 | {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT}, |
| 11506 | {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT}, |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 11507 | {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT}, |
| 11508 | {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT}, |
| 11509 | {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT}, |
| 11510 | {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT}, |
| 11511 | {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT}, |
| 11512 | {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT}, |
| 11513 | {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT}, |
shannon.woods%transgaming.com@gtempaccount.com | 77d9472 | 2013-04-13 03:34:22 +0000 | [diff] [blame] | 11514 | {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT}, |
daniel@transgaming.com | dce02fd | 2012-01-27 15:39:51 +0000 | [diff] [blame] | 11515 | {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE}, |
| 11516 | {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, |
| 11517 | {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11518 | {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, |
| 11519 | {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, }; |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11520 | |
shannon.woods@transgaming.com | d438fd4 | 2013-02-28 23:17:45 +0000 | [diff] [blame] | 11521 | for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11522 | { |
| 11523 | if (strcmp(procname, glExtensions[ext].name) == 0) |
| 11524 | { |
| 11525 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address; |
| 11526 | } |
| 11527 | } |
| 11528 | |
| 11529 | return NULL; |
| 11530 | } |
| 11531 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 11532 | // Non-public functions used by EGL |
| 11533 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11534 | bool __stdcall glBindTexImage(egl::Surface *surface) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11535 | { |
| 11536 | EVENT("(egl::Surface* surface = 0x%0.8p)", |
| 11537 | surface); |
| 11538 | |
| 11539 | try |
| 11540 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11541 | gl::Context *context = gl::getNonLostContext(); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11542 | |
| 11543 | if (context) |
| 11544 | { |
| 11545 | gl::Texture2D *textureObject = context->getTexture2D(); |
| 11546 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11547 | if (textureObject->isImmutable()) |
| 11548 | { |
| 11549 | return false; |
| 11550 | } |
| 11551 | |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11552 | if (textureObject) |
| 11553 | { |
| 11554 | textureObject->bindTexImage(surface); |
| 11555 | } |
| 11556 | } |
| 11557 | } |
| 11558 | catch(std::bad_alloc&) |
| 11559 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11560 | return gl::error(GL_OUT_OF_MEMORY, false); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11561 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11562 | |
| 11563 | return true; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11564 | } |
| 11565 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11566 | } |