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: |
Geoff Lang | d384a94 | 2013-06-05 15:00:10 -0400 | [diff] [blame] | 1590 | if (!gl::IsSignedIntegerFormat(internalFormat, 3)) |
| 1591 | { |
| 1592 | return false; |
| 1593 | } |
| 1594 | break; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 1595 | case GL_UNSIGNED_INT: |
Geoff Lang | d384a94 | 2013-06-05 15:00:10 -0400 | [diff] [blame] | 1596 | if (!gl::IsUnsignedIntegerFormat(internalFormat, 3)) |
| 1597 | { |
| 1598 | return false; |
| 1599 | } |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 1600 | break; |
| 1601 | default: |
| 1602 | return false; |
| 1603 | } |
| 1604 | break; |
| 1605 | case GL_BGRA_EXT: |
| 1606 | switch (type) |
| 1607 | { |
| 1608 | case GL_UNSIGNED_BYTE: |
| 1609 | case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: |
| 1610 | case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: |
| 1611 | break; |
| 1612 | default: |
| 1613 | return false; |
| 1614 | } |
| 1615 | break; |
| 1616 | default: |
| 1617 | return false; |
| 1618 | } |
| 1619 | return true; |
| 1620 | } |
| 1621 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 1622 | bool validateInvalidateFramebufferParameters(gl::Context *context, GLenum target, GLsizei numAttachments, |
| 1623 | const GLenum* attachments) |
| 1624 | { |
| 1625 | bool defaultFramebuffer = false; |
| 1626 | |
| 1627 | switch (target) |
| 1628 | { |
| 1629 | case GL_DRAW_FRAMEBUFFER: |
| 1630 | case GL_FRAMEBUFFER: |
| 1631 | defaultFramebuffer = context->getDrawFramebufferHandle() == 0; |
| 1632 | break; |
| 1633 | case GL_READ_FRAMEBUFFER: |
| 1634 | defaultFramebuffer = context->getReadFramebufferHandle() == 0; |
| 1635 | break; |
| 1636 | default: |
| 1637 | return gl::error(GL_INVALID_ENUM, false); |
| 1638 | } |
| 1639 | |
| 1640 | for (int i = 0; i < numAttachments; ++i) |
| 1641 | { |
| 1642 | if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15) |
| 1643 | { |
| 1644 | if (defaultFramebuffer) |
| 1645 | { |
| 1646 | return gl::error(GL_INVALID_ENUM, false); |
| 1647 | } |
| 1648 | |
| 1649 | if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getMaximumRenderTargets()) |
| 1650 | { |
| 1651 | return gl::error(GL_INVALID_OPERATION, false); |
| 1652 | } |
| 1653 | } |
| 1654 | else |
| 1655 | { |
| 1656 | switch (attachments[i]) |
| 1657 | { |
| 1658 | case GL_DEPTH_ATTACHMENT: |
| 1659 | case GL_STENCIL_ATTACHMENT: |
| 1660 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 1661 | if (defaultFramebuffer) |
| 1662 | { |
| 1663 | return gl::error(GL_INVALID_ENUM, false); |
| 1664 | } |
| 1665 | break; |
| 1666 | case GL_COLOR: |
| 1667 | case GL_DEPTH: |
| 1668 | case GL_STENCIL: |
| 1669 | if (!defaultFramebuffer) |
| 1670 | { |
| 1671 | return gl::error(GL_INVALID_ENUM, false); |
| 1672 | } |
| 1673 | break; |
| 1674 | default: |
| 1675 | return gl::error(GL_INVALID_ENUM, false); |
| 1676 | } |
| 1677 | } |
| 1678 | } |
| 1679 | |
| 1680 | return true; |
| 1681 | } |
| 1682 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 1683 | bool validateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, |
| 1684 | GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, |
| 1685 | GLenum filter, bool fromAngleExtension) |
| 1686 | { |
| 1687 | switch (filter) |
| 1688 | { |
| 1689 | case GL_NEAREST: |
| 1690 | break; |
| 1691 | case GL_LINEAR: |
| 1692 | if (fromAngleExtension) |
| 1693 | { |
| 1694 | return gl::error(GL_INVALID_ENUM, false); |
| 1695 | } |
| 1696 | break; |
| 1697 | default: |
| 1698 | return gl::error(GL_INVALID_ENUM, false); |
| 1699 | } |
| 1700 | |
| 1701 | if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0) |
| 1702 | { |
| 1703 | return gl::error(GL_INVALID_VALUE, false); |
| 1704 | } |
| 1705 | |
| 1706 | if (mask == 0) |
| 1707 | { |
| 1708 | // ES3.0 spec, section 4.3.2 specifies that a mask of zero is valid and no |
| 1709 | // buffers are copied. |
| 1710 | return false; |
| 1711 | } |
| 1712 | |
| 1713 | if (fromAngleExtension && (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0)) |
| 1714 | { |
| 1715 | ERR("Scaling and flipping in BlitFramebufferANGLE not supported by this implementation."); |
| 1716 | return gl::error(GL_INVALID_OPERATION, false); |
| 1717 | } |
| 1718 | |
| 1719 | // ES3.0 spec, section 4.3.2 states that linear filtering is only available for the |
| 1720 | // color buffer, leaving only nearest being unfiltered from above |
| 1721 | if ((mask & ~GL_COLOR_BUFFER_BIT) != 0 && filter != GL_NEAREST) |
| 1722 | { |
| 1723 | return gl::error(GL_INVALID_OPERATION, false); |
| 1724 | } |
| 1725 | |
| 1726 | if (context->getReadFramebufferHandle() == context->getDrawFramebufferHandle()) |
| 1727 | { |
| 1728 | if (fromAngleExtension) |
| 1729 | { |
| 1730 | ERR("Blits with the same source and destination framebuffer are not supported by this " |
| 1731 | "implementation."); |
| 1732 | } |
| 1733 | return gl::error(GL_INVALID_OPERATION, false); |
| 1734 | } |
| 1735 | |
| 1736 | gl::Framebuffer *readFramebuffer = context->getReadFramebuffer(); |
| 1737 | gl::Framebuffer *drawFramebuffer = context->getDrawFramebuffer(); |
| 1738 | if (!readFramebuffer || readFramebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE || |
| 1739 | !drawFramebuffer || drawFramebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) |
| 1740 | { |
| 1741 | return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); |
| 1742 | } |
| 1743 | |
| 1744 | if (drawFramebuffer->getSamples() != 0) |
| 1745 | { |
| 1746 | return gl::error(GL_INVALID_OPERATION, false); |
| 1747 | } |
| 1748 | |
| 1749 | gl::Rectangle sourceClippedRect, destClippedRect; |
| 1750 | bool partialCopy; |
| 1751 | if (!context->clipBlitFramebufferCoordinates(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 1752 | &sourceClippedRect, &destClippedRect, &partialCopy)) |
| 1753 | { |
| 1754 | return gl::error(GL_INVALID_OPERATION, false); |
| 1755 | } |
| 1756 | |
| 1757 | bool sameBounds = srcX0 == dstX0 && srcY0 == dstY0 && srcX1 == dstX1 && srcY1 == dstY1; |
| 1758 | |
| 1759 | GLuint clientVersion = context->getClientVersion(); |
| 1760 | |
| 1761 | if (mask & GL_COLOR_BUFFER_BIT) |
| 1762 | { |
| 1763 | gl::Renderbuffer *readColorBuffer = readFramebuffer->getReadColorbuffer(); |
| 1764 | gl::Renderbuffer *drawColorBuffer = drawFramebuffer->getFirstColorbuffer(); |
| 1765 | |
| 1766 | if (readColorBuffer && drawColorBuffer) |
| 1767 | { |
| 1768 | GLint readInternalFormat = readColorBuffer->getActualFormat(); |
| 1769 | GLint drawInternalFormat = drawColorBuffer->getActualFormat(); |
| 1770 | |
| 1771 | for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; i++) |
| 1772 | { |
| 1773 | if (drawFramebuffer->isEnabledColorAttachment(i)) |
| 1774 | { |
| 1775 | GLint drawbufferAttachmentFormat = drawFramebuffer->getColorbuffer(i)->getActualFormat(); |
| 1776 | |
| 1777 | if (gl::IsNormalizedFixedPointFormat(readInternalFormat, clientVersion) && |
| 1778 | !gl::IsNormalizedFixedPointFormat(drawbufferAttachmentFormat, clientVersion)) |
| 1779 | { |
| 1780 | return gl::error(GL_INVALID_OPERATION, false); |
| 1781 | } |
| 1782 | |
| 1783 | if (gl::IsUnsignedIntegerFormat(readInternalFormat, clientVersion) && |
| 1784 | !gl::IsUnsignedIntegerFormat(drawbufferAttachmentFormat, clientVersion)) |
| 1785 | { |
| 1786 | return gl::error(GL_INVALID_OPERATION, false); |
| 1787 | } |
| 1788 | |
| 1789 | if (gl::IsSignedIntegerFormat(readInternalFormat, clientVersion) && |
| 1790 | !gl::IsSignedIntegerFormat(drawbufferAttachmentFormat, clientVersion)) |
| 1791 | { |
| 1792 | return gl::error(GL_INVALID_OPERATION, false); |
| 1793 | } |
| 1794 | |
| 1795 | if (readColorBuffer->getSamples() > 0 && (readInternalFormat != drawbufferAttachmentFormat || !sameBounds)) |
| 1796 | { |
| 1797 | return gl::error(GL_INVALID_OPERATION, false); |
| 1798 | } |
| 1799 | } |
| 1800 | } |
| 1801 | |
| 1802 | if (gl::IsIntegerFormat(readInternalFormat, clientVersion) && filter == GL_LINEAR) |
| 1803 | { |
| 1804 | return gl::error(GL_INVALID_OPERATION, false); |
| 1805 | } |
| 1806 | |
| 1807 | if (fromAngleExtension) |
| 1808 | { |
| 1809 | const GLenum readColorbufferType = readFramebuffer->getReadColorbufferType(); |
| 1810 | if (readColorbufferType != GL_TEXTURE_2D && readColorbufferType != GL_RENDERBUFFER) |
| 1811 | { |
| 1812 | return gl::error(GL_INVALID_OPERATION, false); |
| 1813 | } |
| 1814 | |
| 1815 | for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) |
| 1816 | { |
| 1817 | if (drawFramebuffer->isEnabledColorAttachment(colorAttachment)) |
| 1818 | { |
| 1819 | if (drawFramebuffer->getColorbufferType(colorAttachment) != GL_TEXTURE_2D && |
| 1820 | drawFramebuffer->getColorbufferType(colorAttachment) != GL_RENDERBUFFER) |
| 1821 | { |
| 1822 | return gl::error(GL_INVALID_OPERATION, false); |
| 1823 | } |
| 1824 | |
| 1825 | if (drawFramebuffer->getColorbuffer(colorAttachment)->getActualFormat() != readColorBuffer->getActualFormat()) |
| 1826 | { |
| 1827 | return gl::error(GL_INVALID_OPERATION, false); |
| 1828 | } |
| 1829 | } |
| 1830 | } |
| 1831 | |
| 1832 | if (partialCopy && readFramebuffer->getSamples() != 0) |
| 1833 | { |
| 1834 | return gl::error(GL_INVALID_OPERATION, false); |
| 1835 | } |
| 1836 | } |
| 1837 | } |
| 1838 | } |
| 1839 | |
| 1840 | if (mask & GL_DEPTH_BUFFER_BIT) |
| 1841 | { |
| 1842 | gl::Renderbuffer *readDepthBuffer = readFramebuffer->getDepthbuffer(); |
| 1843 | gl::Renderbuffer *drawDepthBuffer = drawFramebuffer->getDepthbuffer(); |
| 1844 | |
| 1845 | if (readDepthBuffer && drawDepthBuffer) |
| 1846 | { |
| 1847 | if (readDepthBuffer->getActualFormat() != drawDepthBuffer->getActualFormat()) |
| 1848 | { |
| 1849 | return gl::error(GL_INVALID_OPERATION, false); |
| 1850 | } |
| 1851 | |
| 1852 | if (readDepthBuffer->getSamples() > 0 && !sameBounds) |
| 1853 | { |
| 1854 | return gl::error(GL_INVALID_OPERATION, false); |
| 1855 | } |
| 1856 | |
| 1857 | if (fromAngleExtension) |
| 1858 | { |
| 1859 | if (partialCopy) |
| 1860 | { |
| 1861 | ERR("Only whole-buffer depth and stencil blits are supported by this implementation."); |
| 1862 | return gl::error(GL_INVALID_OPERATION, false); // only whole-buffer copies are permitted |
| 1863 | } |
| 1864 | |
| 1865 | if (readDepthBuffer->getSamples() != 0 || drawDepthBuffer->getSamples() != 0) |
| 1866 | { |
| 1867 | return gl::error(GL_INVALID_OPERATION, false); |
| 1868 | } |
| 1869 | } |
| 1870 | } |
| 1871 | } |
| 1872 | |
| 1873 | if (mask & GL_STENCIL_BUFFER_BIT) |
| 1874 | { |
| 1875 | gl::Renderbuffer *readStencilBuffer = readFramebuffer->getStencilbuffer(); |
| 1876 | gl::Renderbuffer *drawStencilBuffer = drawFramebuffer->getStencilbuffer(); |
| 1877 | |
| 1878 | if (fromAngleExtension && partialCopy) |
| 1879 | { |
| 1880 | ERR("Only whole-buffer depth and stencil blits are supported by this implementation."); |
| 1881 | return gl::error(GL_INVALID_OPERATION, false); // only whole-buffer copies are permitted |
| 1882 | } |
| 1883 | |
| 1884 | if (readStencilBuffer && drawStencilBuffer) |
| 1885 | { |
| 1886 | if (readStencilBuffer->getActualFormat() != drawStencilBuffer->getActualFormat()) |
| 1887 | { |
| 1888 | return gl::error(GL_INVALID_OPERATION, false); |
| 1889 | } |
| 1890 | |
| 1891 | if (readStencilBuffer->getSamples() > 0 && !sameBounds) |
| 1892 | { |
| 1893 | return gl::error(GL_INVALID_OPERATION, false); |
| 1894 | } |
| 1895 | |
| 1896 | if (fromAngleExtension) |
| 1897 | { |
| 1898 | if (partialCopy) |
| 1899 | { |
| 1900 | ERR("Only whole-buffer depth and stencil blits are supported by this implementation."); |
| 1901 | return gl::error(GL_INVALID_OPERATION, false); // only whole-buffer copies are permitted |
| 1902 | } |
| 1903 | |
| 1904 | if (readStencilBuffer->getSamples() != 0 || drawStencilBuffer->getSamples() != 0) |
| 1905 | { |
| 1906 | return gl::error(GL_INVALID_OPERATION, false); |
| 1907 | } |
| 1908 | } |
| 1909 | } |
| 1910 | } |
| 1911 | |
| 1912 | return true; |
| 1913 | } |
| 1914 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1915 | extern "C" |
| 1916 | { |
| 1917 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 1918 | // OpenGL ES 2.0 functions |
| 1919 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1920 | void __stdcall glActiveTexture(GLenum texture) |
| 1921 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1922 | EVENT("(GLenum texture = 0x%X)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1923 | |
| 1924 | try |
| 1925 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1926 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1927 | |
| 1928 | if (context) |
| 1929 | { |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 1930 | if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1) |
| 1931 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1932 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 1933 | } |
| 1934 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 1935 | context->setActiveSampler(texture - GL_TEXTURE0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1936 | } |
| 1937 | } |
| 1938 | catch(std::bad_alloc&) |
| 1939 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1940 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1941 | } |
| 1942 | } |
| 1943 | |
| 1944 | void __stdcall glAttachShader(GLuint program, GLuint shader) |
| 1945 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1946 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1947 | |
| 1948 | try |
| 1949 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1950 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1951 | |
| 1952 | if (context) |
| 1953 | { |
| 1954 | gl::Program *programObject = context->getProgram(program); |
| 1955 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 1956 | |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1957 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1958 | { |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1959 | if (context->getShader(program)) |
| 1960 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1961 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1962 | } |
| 1963 | else |
| 1964 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1965 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1966 | } |
| 1967 | } |
| 1968 | |
| 1969 | if (!shaderObject) |
| 1970 | { |
| 1971 | if (context->getProgram(shader)) |
| 1972 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1973 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1974 | } |
| 1975 | else |
| 1976 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1977 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1978 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1979 | } |
| 1980 | |
| 1981 | if (!programObject->attachShader(shaderObject)) |
| 1982 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1983 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1984 | } |
| 1985 | } |
| 1986 | } |
| 1987 | catch(std::bad_alloc&) |
| 1988 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1989 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1990 | } |
| 1991 | } |
| 1992 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1993 | void __stdcall glBeginQueryEXT(GLenum target, GLuint id) |
| 1994 | { |
| 1995 | EVENT("(GLenum target = 0x%X, GLuint %d)", target, id); |
| 1996 | |
| 1997 | try |
| 1998 | { |
| 1999 | switch (target) |
| 2000 | { |
| 2001 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 2002 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 2003 | break; |
| 2004 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2005 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2006 | } |
| 2007 | |
| 2008 | if (id == 0) |
| 2009 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2010 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2011 | } |
| 2012 | |
| 2013 | gl::Context *context = gl::getNonLostContext(); |
| 2014 | |
| 2015 | if (context) |
| 2016 | { |
| 2017 | context->beginQuery(target, id); |
| 2018 | } |
| 2019 | } |
| 2020 | catch(std::bad_alloc&) |
| 2021 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2022 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2023 | } |
| 2024 | } |
| 2025 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2026 | void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2027 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2028 | 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] | 2029 | |
| 2030 | try |
| 2031 | { |
| 2032 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 2033 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2034 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2035 | } |
| 2036 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2037 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2038 | |
| 2039 | if (context) |
| 2040 | { |
| 2041 | gl::Program *programObject = context->getProgram(program); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2042 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2043 | if (!programObject) |
| 2044 | { |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2045 | if (context->getShader(program)) |
| 2046 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2047 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2048 | } |
| 2049 | else |
| 2050 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2051 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2052 | } |
| 2053 | } |
| 2054 | |
| 2055 | if (strncmp(name, "gl_", 3) == 0) |
| 2056 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2057 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2058 | } |
| 2059 | |
| 2060 | programObject->bindAttributeLocation(index, name); |
| 2061 | } |
| 2062 | } |
| 2063 | catch(std::bad_alloc&) |
| 2064 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2065 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2066 | } |
| 2067 | } |
| 2068 | |
| 2069 | void __stdcall glBindBuffer(GLenum target, GLuint buffer) |
| 2070 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2071 | EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2072 | |
| 2073 | try |
| 2074 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2075 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2076 | |
| 2077 | if (context) |
| 2078 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2079 | // Check ES3 specific targets |
| 2080 | switch (target) |
| 2081 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2082 | case GL_COPY_READ_BUFFER: |
| 2083 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2084 | case GL_PIXEL_PACK_BUFFER: |
| 2085 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2086 | case GL_UNIFORM_BUFFER: |
| 2087 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2088 | if (context->getClientVersion() < 3) |
| 2089 | { |
| 2090 | return gl::error(GL_INVALID_ENUM); |
| 2091 | } |
| 2092 | } |
| 2093 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2094 | switch (target) |
| 2095 | { |
| 2096 | case GL_ARRAY_BUFFER: |
| 2097 | context->bindArrayBuffer(buffer); |
| 2098 | return; |
| 2099 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2100 | context->bindElementArrayBuffer(buffer); |
| 2101 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2102 | case GL_COPY_READ_BUFFER: |
| 2103 | context->bindCopyReadBuffer(buffer); |
| 2104 | return; |
| 2105 | case GL_COPY_WRITE_BUFFER: |
| 2106 | context->bindCopyWriteBuffer(buffer); |
| 2107 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2108 | case GL_PIXEL_PACK_BUFFER: |
| 2109 | context->bindPixelPackBuffer(buffer); |
| 2110 | return; |
| 2111 | case GL_PIXEL_UNPACK_BUFFER: |
| 2112 | context->bindPixelUnpackBuffer(buffer); |
| 2113 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2114 | case GL_UNIFORM_BUFFER: |
| 2115 | context->bindGenericUniformBuffer(buffer); |
| 2116 | return; |
| 2117 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 7a1ebad | 2013-05-30 00:05:20 +0000 | [diff] [blame] | 2118 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2119 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2120 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2121 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2122 | } |
| 2123 | } |
| 2124 | } |
| 2125 | catch(std::bad_alloc&) |
| 2126 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2127 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2128 | } |
| 2129 | } |
| 2130 | |
| 2131 | void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer) |
| 2132 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2133 | EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2134 | |
| 2135 | try |
| 2136 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2137 | 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] | 2138 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2139 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2140 | } |
| 2141 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2142 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2143 | |
| 2144 | if (context) |
| 2145 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2146 | if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 2147 | { |
| 2148 | context->bindReadFramebuffer(framebuffer); |
| 2149 | } |
| 2150 | |
| 2151 | if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 2152 | { |
| 2153 | context->bindDrawFramebuffer(framebuffer); |
| 2154 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2155 | } |
| 2156 | } |
| 2157 | catch(std::bad_alloc&) |
| 2158 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2159 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2160 | } |
| 2161 | } |
| 2162 | |
| 2163 | void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 2164 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2165 | EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2166 | |
| 2167 | try |
| 2168 | { |
| 2169 | if (target != GL_RENDERBUFFER) |
| 2170 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2171 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2172 | } |
| 2173 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2174 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2175 | |
| 2176 | if (context) |
| 2177 | { |
| 2178 | context->bindRenderbuffer(renderbuffer); |
| 2179 | } |
| 2180 | } |
| 2181 | catch(std::bad_alloc&) |
| 2182 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2183 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2184 | } |
| 2185 | } |
| 2186 | |
| 2187 | void __stdcall glBindTexture(GLenum target, GLuint texture) |
| 2188 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2189 | EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2190 | |
| 2191 | try |
| 2192 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2193 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2194 | |
| 2195 | if (context) |
| 2196 | { |
| 2197 | gl::Texture *textureObject = context->getTexture(texture); |
| 2198 | |
| 2199 | if (textureObject && textureObject->getTarget() != target && texture != 0) |
| 2200 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2201 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2202 | } |
| 2203 | |
| 2204 | switch (target) |
| 2205 | { |
| 2206 | case GL_TEXTURE_2D: |
| 2207 | context->bindTexture2D(texture); |
| 2208 | return; |
| 2209 | case GL_TEXTURE_CUBE_MAP: |
| 2210 | context->bindTextureCubeMap(texture); |
| 2211 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 2212 | case GL_TEXTURE_3D: |
| 2213 | if (context->getClientVersion() < 3) |
| 2214 | { |
| 2215 | return gl::error(GL_INVALID_ENUM); |
| 2216 | } |
| 2217 | context->bindTexture3D(texture); |
| 2218 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 2219 | case GL_TEXTURE_2D_ARRAY: |
| 2220 | if (context->getClientVersion() < 3) |
| 2221 | { |
| 2222 | return gl::error(GL_INVALID_ENUM); |
| 2223 | } |
| 2224 | context->bindTexture2DArray(texture); |
| 2225 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2226 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2227 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2228 | } |
| 2229 | } |
| 2230 | } |
| 2231 | catch(std::bad_alloc&) |
| 2232 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2233 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2234 | } |
| 2235 | } |
| 2236 | |
| 2237 | void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2238 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2239 | 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] | 2240 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2241 | |
| 2242 | try |
| 2243 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2244 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2245 | |
| 2246 | if (context) |
| 2247 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2248 | 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] | 2249 | } |
| 2250 | } |
| 2251 | catch(std::bad_alloc&) |
| 2252 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2253 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2254 | } |
| 2255 | } |
| 2256 | |
| 2257 | void __stdcall glBlendEquation(GLenum mode) |
| 2258 | { |
| 2259 | glBlendEquationSeparate(mode, mode); |
| 2260 | } |
| 2261 | |
| 2262 | void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 2263 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2264 | EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2265 | |
| 2266 | try |
| 2267 | { |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2268 | gl::Context *context = gl::getNonLostContext(); |
| 2269 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2270 | switch (modeRGB) |
| 2271 | { |
| 2272 | case GL_FUNC_ADD: |
| 2273 | case GL_FUNC_SUBTRACT: |
| 2274 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2275 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2276 | |
| 2277 | case GL_MIN: |
| 2278 | case GL_MAX: |
| 2279 | if (context && context->getClientVersion() < 3) |
| 2280 | { |
| 2281 | return gl::error(GL_INVALID_ENUM); |
| 2282 | } |
| 2283 | break; |
| 2284 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2285 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2286 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2287 | } |
| 2288 | |
| 2289 | switch (modeAlpha) |
| 2290 | { |
| 2291 | case GL_FUNC_ADD: |
| 2292 | case GL_FUNC_SUBTRACT: |
| 2293 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2294 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2295 | |
| 2296 | case GL_MIN: |
| 2297 | case GL_MAX: |
| 2298 | if (context && context->getClientVersion() < 3) |
| 2299 | { |
| 2300 | return gl::error(GL_INVALID_ENUM); |
| 2301 | } |
| 2302 | break; |
| 2303 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2304 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2305 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2306 | } |
| 2307 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2308 | if (context) |
| 2309 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2310 | context->setBlendEquation(modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2311 | } |
| 2312 | } |
| 2313 | catch(std::bad_alloc&) |
| 2314 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2315 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2316 | } |
| 2317 | } |
| 2318 | |
| 2319 | void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor) |
| 2320 | { |
| 2321 | glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor); |
| 2322 | } |
| 2323 | |
| 2324 | void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 2325 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2326 | 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] | 2327 | srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2328 | |
| 2329 | try |
| 2330 | { |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2331 | gl::Context *context = gl::getNonLostContext(); |
| 2332 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2333 | switch (srcRGB) |
| 2334 | { |
| 2335 | case GL_ZERO: |
| 2336 | case GL_ONE: |
| 2337 | case GL_SRC_COLOR: |
| 2338 | case GL_ONE_MINUS_SRC_COLOR: |
| 2339 | case GL_DST_COLOR: |
| 2340 | case GL_ONE_MINUS_DST_COLOR: |
| 2341 | case GL_SRC_ALPHA: |
| 2342 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2343 | case GL_DST_ALPHA: |
| 2344 | case GL_ONE_MINUS_DST_ALPHA: |
| 2345 | case GL_CONSTANT_COLOR: |
| 2346 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2347 | case GL_CONSTANT_ALPHA: |
| 2348 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2349 | case GL_SRC_ALPHA_SATURATE: |
| 2350 | break; |
| 2351 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2352 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2353 | } |
| 2354 | |
| 2355 | switch (dstRGB) |
| 2356 | { |
| 2357 | case GL_ZERO: |
| 2358 | case GL_ONE: |
| 2359 | case GL_SRC_COLOR: |
| 2360 | case GL_ONE_MINUS_SRC_COLOR: |
| 2361 | case GL_DST_COLOR: |
| 2362 | case GL_ONE_MINUS_DST_COLOR: |
| 2363 | case GL_SRC_ALPHA: |
| 2364 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2365 | case GL_DST_ALPHA: |
| 2366 | case GL_ONE_MINUS_DST_ALPHA: |
| 2367 | case GL_CONSTANT_COLOR: |
| 2368 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2369 | case GL_CONSTANT_ALPHA: |
| 2370 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2371 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2372 | |
| 2373 | case GL_SRC_ALPHA_SATURATE: |
| 2374 | if (!context || context->getClientVersion() < 3) |
| 2375 | { |
| 2376 | return gl::error(GL_INVALID_ENUM); |
| 2377 | } |
| 2378 | break; |
| 2379 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2380 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2381 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2382 | } |
| 2383 | |
| 2384 | switch (srcAlpha) |
| 2385 | { |
| 2386 | case GL_ZERO: |
| 2387 | case GL_ONE: |
| 2388 | case GL_SRC_COLOR: |
| 2389 | case GL_ONE_MINUS_SRC_COLOR: |
| 2390 | case GL_DST_COLOR: |
| 2391 | case GL_ONE_MINUS_DST_COLOR: |
| 2392 | case GL_SRC_ALPHA: |
| 2393 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2394 | case GL_DST_ALPHA: |
| 2395 | case GL_ONE_MINUS_DST_ALPHA: |
| 2396 | case GL_CONSTANT_COLOR: |
| 2397 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2398 | case GL_CONSTANT_ALPHA: |
| 2399 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2400 | case GL_SRC_ALPHA_SATURATE: |
| 2401 | break; |
| 2402 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2403 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2404 | } |
| 2405 | |
| 2406 | switch (dstAlpha) |
| 2407 | { |
| 2408 | case GL_ZERO: |
| 2409 | case GL_ONE: |
| 2410 | case GL_SRC_COLOR: |
| 2411 | case GL_ONE_MINUS_SRC_COLOR: |
| 2412 | case GL_DST_COLOR: |
| 2413 | case GL_ONE_MINUS_DST_COLOR: |
| 2414 | case GL_SRC_ALPHA: |
| 2415 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2416 | case GL_DST_ALPHA: |
| 2417 | case GL_ONE_MINUS_DST_ALPHA: |
| 2418 | case GL_CONSTANT_COLOR: |
| 2419 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2420 | case GL_CONSTANT_ALPHA: |
| 2421 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2422 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2423 | |
| 2424 | case GL_SRC_ALPHA_SATURATE: |
| 2425 | if (!context || context->getClientVersion() < 3) |
| 2426 | { |
| 2427 | return gl::error(GL_INVALID_ENUM); |
| 2428 | } |
| 2429 | break; |
| 2430 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2431 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2432 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2433 | } |
| 2434 | |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2435 | bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR || |
| 2436 | dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR); |
| 2437 | |
| 2438 | bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA || |
| 2439 | dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA); |
| 2440 | |
| 2441 | if (constantColorUsed && constantAlphaUsed) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2442 | { |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2443 | 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] | 2444 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2445 | } |
| 2446 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2447 | if (context) |
| 2448 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2449 | context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2450 | } |
| 2451 | } |
| 2452 | catch(std::bad_alloc&) |
| 2453 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2454 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2455 | } |
| 2456 | } |
| 2457 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2458 | 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] | 2459 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2460 | 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] | 2461 | target, size, data, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2462 | |
| 2463 | try |
| 2464 | { |
| 2465 | if (size < 0) |
| 2466 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2467 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2468 | } |
| 2469 | |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2470 | gl::Context *context = gl::getNonLostContext(); |
| 2471 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2472 | switch (usage) |
| 2473 | { |
| 2474 | case GL_STREAM_DRAW: |
| 2475 | case GL_STATIC_DRAW: |
| 2476 | case GL_DYNAMIC_DRAW: |
| 2477 | break; |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2478 | |
| 2479 | case GL_STREAM_READ: |
| 2480 | case GL_STREAM_COPY: |
| 2481 | case GL_STATIC_READ: |
| 2482 | case GL_STATIC_COPY: |
| 2483 | case GL_DYNAMIC_READ: |
| 2484 | case GL_DYNAMIC_COPY: |
| 2485 | if (context && context->getClientVersion() < 3) |
| 2486 | { |
| 2487 | return gl::error(GL_INVALID_ENUM); |
| 2488 | } |
| 2489 | break; |
| 2490 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2491 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2492 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2493 | } |
| 2494 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2495 | if (context) |
| 2496 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2497 | // Check ES3 specific targets |
| 2498 | switch (target) |
| 2499 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2500 | case GL_COPY_READ_BUFFER: |
| 2501 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2502 | case GL_PIXEL_PACK_BUFFER: |
| 2503 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2504 | case GL_UNIFORM_BUFFER: |
| 2505 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2506 | if (context->getClientVersion() < 3) |
| 2507 | { |
| 2508 | return gl::error(GL_INVALID_ENUM); |
| 2509 | } |
| 2510 | } |
| 2511 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2512 | gl::Buffer *buffer; |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2513 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2514 | switch (target) |
| 2515 | { |
| 2516 | case GL_ARRAY_BUFFER: |
| 2517 | buffer = context->getArrayBuffer(); |
| 2518 | break; |
| 2519 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2520 | buffer = context->getElementArrayBuffer(); |
| 2521 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2522 | case GL_COPY_READ_BUFFER: |
| 2523 | buffer = context->getCopyReadBuffer(); |
| 2524 | break; |
| 2525 | case GL_COPY_WRITE_BUFFER: |
| 2526 | buffer = context->getCopyWriteBuffer(); |
| 2527 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2528 | case GL_PIXEL_PACK_BUFFER: |
| 2529 | buffer = context->getPixelPackBuffer(); |
| 2530 | break; |
| 2531 | case GL_PIXEL_UNPACK_BUFFER: |
| 2532 | buffer = context->getPixelUnpackBuffer(); |
| 2533 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2534 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2535 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2536 | break; |
| 2537 | case GL_UNIFORM_BUFFER: |
| 2538 | buffer = context->getGenericUniformBuffer(); |
| 2539 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2540 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2541 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2542 | } |
| 2543 | |
| 2544 | if (!buffer) |
| 2545 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2546 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2547 | } |
| 2548 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2549 | buffer->bufferData(data, size, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2550 | } |
| 2551 | } |
| 2552 | catch(std::bad_alloc&) |
| 2553 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2554 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2555 | } |
| 2556 | } |
| 2557 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2558 | 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] | 2559 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2560 | 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] | 2561 | target, offset, size, data); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2562 | |
| 2563 | try |
| 2564 | { |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2565 | if (size < 0 || offset < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2566 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2567 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2568 | } |
| 2569 | |
daniel@transgaming.com | d4620a3 | 2010-03-21 04:31:28 +0000 | [diff] [blame] | 2570 | if (data == NULL) |
| 2571 | { |
| 2572 | return; |
| 2573 | } |
| 2574 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2575 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2576 | |
| 2577 | if (context) |
| 2578 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2579 | // Check ES3 specific targets |
| 2580 | switch (target) |
| 2581 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2582 | case GL_COPY_READ_BUFFER: |
| 2583 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2584 | case GL_PIXEL_PACK_BUFFER: |
| 2585 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2586 | case GL_UNIFORM_BUFFER: |
| 2587 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2588 | if (context->getClientVersion() < 3) |
| 2589 | { |
| 2590 | return gl::error(GL_INVALID_ENUM); |
| 2591 | } |
| 2592 | } |
| 2593 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2594 | gl::Buffer *buffer; |
| 2595 | |
| 2596 | switch (target) |
| 2597 | { |
| 2598 | case GL_ARRAY_BUFFER: |
| 2599 | buffer = context->getArrayBuffer(); |
| 2600 | break; |
| 2601 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2602 | buffer = context->getElementArrayBuffer(); |
| 2603 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2604 | case GL_COPY_READ_BUFFER: |
| 2605 | buffer = context->getCopyReadBuffer(); |
| 2606 | break; |
| 2607 | case GL_COPY_WRITE_BUFFER: |
| 2608 | buffer = context->getCopyWriteBuffer(); |
| 2609 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2610 | case GL_PIXEL_PACK_BUFFER: |
| 2611 | buffer = context->getPixelPackBuffer(); |
| 2612 | break; |
| 2613 | case GL_PIXEL_UNPACK_BUFFER: |
| 2614 | buffer = context->getPixelUnpackBuffer(); |
| 2615 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2616 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2617 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2618 | break; |
| 2619 | case GL_UNIFORM_BUFFER: |
| 2620 | buffer = context->getGenericUniformBuffer(); |
| 2621 | break; |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2622 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2623 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2624 | } |
| 2625 | |
| 2626 | if (!buffer) |
| 2627 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2628 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2629 | } |
| 2630 | |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2631 | if ((size_t)size + offset > buffer->size()) |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2632 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2633 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2634 | } |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2635 | |
| 2636 | buffer->bufferSubData(data, size, offset); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2637 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2638 | } |
| 2639 | catch(std::bad_alloc&) |
| 2640 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2641 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2642 | } |
| 2643 | } |
| 2644 | |
| 2645 | GLenum __stdcall glCheckFramebufferStatus(GLenum target) |
| 2646 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2647 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2648 | |
| 2649 | try |
| 2650 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2651 | 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] | 2652 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2653 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2654 | } |
| 2655 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2656 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2657 | |
| 2658 | if (context) |
| 2659 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2660 | gl::Framebuffer *framebuffer = NULL; |
| 2661 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 2662 | { |
| 2663 | framebuffer = context->getReadFramebuffer(); |
| 2664 | } |
| 2665 | else |
| 2666 | { |
| 2667 | framebuffer = context->getDrawFramebuffer(); |
| 2668 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2669 | |
| 2670 | return framebuffer->completeness(); |
| 2671 | } |
| 2672 | } |
| 2673 | catch(std::bad_alloc&) |
| 2674 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2675 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2676 | } |
| 2677 | |
| 2678 | return 0; |
| 2679 | } |
| 2680 | |
| 2681 | void __stdcall glClear(GLbitfield mask) |
| 2682 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2683 | EVENT("(GLbitfield mask = 0x%X)", mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2684 | |
| 2685 | try |
| 2686 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2687 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2688 | |
| 2689 | if (context) |
| 2690 | { |
| 2691 | context->clear(mask); |
| 2692 | } |
| 2693 | } |
| 2694 | catch(std::bad_alloc&) |
| 2695 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2696 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2697 | } |
| 2698 | } |
| 2699 | |
| 2700 | void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2701 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2702 | 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] | 2703 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 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 | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2708 | |
| 2709 | if (context) |
| 2710 | { |
| 2711 | context->setClearColor(red, green, blue, alpha); |
| 2712 | } |
| 2713 | } |
| 2714 | catch(std::bad_alloc&) |
| 2715 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2716 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2717 | } |
| 2718 | } |
| 2719 | |
| 2720 | void __stdcall glClearDepthf(GLclampf depth) |
| 2721 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2722 | EVENT("(GLclampf depth = %f)", depth); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2723 | |
| 2724 | try |
| 2725 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2726 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2727 | |
| 2728 | if (context) |
| 2729 | { |
| 2730 | context->setClearDepth(depth); |
| 2731 | } |
| 2732 | } |
| 2733 | catch(std::bad_alloc&) |
| 2734 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2735 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2736 | } |
| 2737 | } |
| 2738 | |
| 2739 | void __stdcall glClearStencil(GLint s) |
| 2740 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2741 | EVENT("(GLint s = %d)", s); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2742 | |
| 2743 | try |
| 2744 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2745 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2746 | |
| 2747 | if (context) |
| 2748 | { |
| 2749 | context->setClearStencil(s); |
| 2750 | } |
| 2751 | } |
| 2752 | catch(std::bad_alloc&) |
| 2753 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2754 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2755 | } |
| 2756 | } |
| 2757 | |
| 2758 | void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 2759 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2760 | 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] | 2761 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2762 | |
| 2763 | try |
| 2764 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2765 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2766 | |
| 2767 | if (context) |
| 2768 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 2769 | 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] | 2770 | } |
| 2771 | } |
| 2772 | catch(std::bad_alloc&) |
| 2773 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2774 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2775 | } |
| 2776 | } |
| 2777 | |
| 2778 | void __stdcall glCompileShader(GLuint shader) |
| 2779 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2780 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2781 | |
| 2782 | try |
| 2783 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2784 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2785 | |
| 2786 | if (context) |
| 2787 | { |
| 2788 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2789 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2790 | if (!shaderObject) |
| 2791 | { |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2792 | if (context->getProgram(shader)) |
| 2793 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2794 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2795 | } |
| 2796 | else |
| 2797 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2798 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2799 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2800 | } |
| 2801 | |
| 2802 | shaderObject->compile(); |
| 2803 | } |
| 2804 | } |
| 2805 | catch(std::bad_alloc&) |
| 2806 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2807 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2808 | } |
| 2809 | } |
| 2810 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2811 | void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, |
| 2812 | GLint border, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2813 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2814 | 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] | 2815 | "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] | 2816 | target, level, internalformat, width, height, border, imageSize, data); |
| 2817 | |
| 2818 | try |
| 2819 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2820 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2821 | |
| 2822 | if (context) |
| 2823 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2824 | if (context->getClientVersion() < 3 && |
| 2825 | !validateES2TexImageParameters(context, target, level, internalformat, true, false, |
| 2826 | 0, 0, width, height, 0, GL_NONE, GL_NONE, data)) |
| 2827 | { |
| 2828 | return; |
| 2829 | } |
| 2830 | |
| 2831 | if (context->getClientVersion() >= 3 && |
| 2832 | !validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 2833 | 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 2834 | { |
| 2835 | return; |
| 2836 | } |
| 2837 | |
| 2838 | 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] | 2839 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2840 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2841 | } |
| 2842 | |
| 2843 | switch (target) |
| 2844 | { |
| 2845 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2846 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2847 | gl::Texture2D *texture = context->getTexture2D(); |
| 2848 | texture->setCompressedImage(level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2849 | } |
| 2850 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2851 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2852 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2853 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2854 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2855 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2856 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2857 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2858 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2859 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 2860 | texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2861 | } |
| 2862 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2863 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2864 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2865 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2866 | } |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2867 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2868 | } |
| 2869 | catch(std::bad_alloc&) |
| 2870 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2871 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2872 | } |
| 2873 | } |
| 2874 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2875 | void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 2876 | GLenum format, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2877 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2878 | 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] | 2879 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2880 | "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2881 | target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 2882 | |
| 2883 | try |
| 2884 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2885 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2886 | |
| 2887 | if (context) |
| 2888 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2889 | if (context->getClientVersion() < 3 && |
| 2890 | !validateES2TexImageParameters(context, target, level, GL_NONE, true, true, |
| 2891 | xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data)) |
| 2892 | { |
| 2893 | return; |
| 2894 | } |
| 2895 | |
| 2896 | if (context->getClientVersion() >= 3 && |
| 2897 | !validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 2898 | xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 2899 | { |
| 2900 | return; |
| 2901 | } |
| 2902 | |
| 2903 | 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] | 2904 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2905 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2906 | } |
| 2907 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2908 | switch (target) |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2909 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2910 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2911 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2912 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 2913 | texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2914 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2915 | break; |
| 2916 | |
| 2917 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2918 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2919 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2920 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2921 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2922 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2923 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2924 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 2925 | texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2926 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2927 | break; |
| 2928 | |
| 2929 | default: |
| 2930 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2931 | } |
| 2932 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2933 | } |
| 2934 | catch(std::bad_alloc&) |
| 2935 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2936 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2937 | } |
| 2938 | } |
| 2939 | |
| 2940 | void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) |
| 2941 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2942 | 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] | 2943 | "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] | 2944 | target, level, internalformat, x, y, width, height, border); |
| 2945 | |
| 2946 | try |
| 2947 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2948 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2949 | |
| 2950 | if (context) |
| 2951 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2952 | if (context->getClientVersion() < 3 && |
| 2953 | !validateES2CopyTexImageParameters(context, target, level, internalformat, false, |
| 2954 | 0, 0, x, y, width, height, border)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 2955 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2956 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 2957 | } |
| 2958 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2959 | if (context->getClientVersion() >= 3 && |
| 2960 | !validateES3CopyTexImageParameters(context, target, level, internalformat, false, |
| 2961 | 0, 0, 0, x, y, width, height, border)) |
| 2962 | { |
| 2963 | return; |
| 2964 | } |
| 2965 | |
| 2966 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 2967 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2968 | switch (target) |
| 2969 | { |
| 2970 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2971 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2972 | gl::Texture2D *texture = context->getTexture2D(); |
| 2973 | texture->copyImage(level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2974 | } |
| 2975 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2976 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2977 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2978 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2979 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2980 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2981 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2982 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2983 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2984 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 2985 | texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2986 | } |
| 2987 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2988 | |
| 2989 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2990 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2991 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2992 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2993 | } |
| 2994 | catch(std::bad_alloc&) |
| 2995 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2996 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2997 | } |
| 2998 | } |
| 2999 | |
| 3000 | void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 3001 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3002 | 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] | 3003 | "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] | 3004 | target, level, xoffset, yoffset, x, y, width, height); |
| 3005 | |
| 3006 | try |
| 3007 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3008 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3009 | |
| 3010 | if (context) |
| 3011 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3012 | if (context->getClientVersion() < 3 && |
| 3013 | !validateES2CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 3014 | xoffset, yoffset, x, y, width, height, 0)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3015 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3016 | return; |
| 3017 | } |
| 3018 | |
| 3019 | if (context->getClientVersion() >= 3 && |
| 3020 | !validateES3CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 3021 | xoffset, yoffset, 0, x, y, width, height, 0)) |
| 3022 | { |
| 3023 | return; |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3024 | } |
| 3025 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3026 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3027 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3028 | switch (target) |
daniel@transgaming.com | bbc5779 | 2010-07-28 19:21:05 +0000 | [diff] [blame] | 3029 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3030 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 3031 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3032 | gl::Texture2D *texture = context->getTexture2D(); |
| 3033 | 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] | 3034 | } |
| 3035 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3036 | |
| 3037 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3038 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3039 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3040 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3041 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3042 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 3043 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3044 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3045 | 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] | 3046 | } |
| 3047 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3048 | |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3049 | default: |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3050 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3051 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3052 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3053 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3054 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3055 | catch(std::bad_alloc&) |
| 3056 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3057 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3058 | } |
| 3059 | } |
| 3060 | |
| 3061 | GLuint __stdcall glCreateProgram(void) |
| 3062 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3063 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3064 | |
| 3065 | try |
| 3066 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3067 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3068 | |
| 3069 | if (context) |
| 3070 | { |
| 3071 | return context->createProgram(); |
| 3072 | } |
| 3073 | } |
| 3074 | catch(std::bad_alloc&) |
| 3075 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3076 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3077 | } |
| 3078 | |
| 3079 | return 0; |
| 3080 | } |
| 3081 | |
| 3082 | GLuint __stdcall glCreateShader(GLenum type) |
| 3083 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3084 | EVENT("(GLenum type = 0x%X)", type); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3085 | |
| 3086 | try |
| 3087 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3088 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3089 | |
| 3090 | if (context) |
| 3091 | { |
| 3092 | switch (type) |
| 3093 | { |
| 3094 | case GL_FRAGMENT_SHADER: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 3095 | case GL_VERTEX_SHADER: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3096 | return context->createShader(type); |
| 3097 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3098 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3099 | } |
| 3100 | } |
| 3101 | } |
| 3102 | catch(std::bad_alloc&) |
| 3103 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3104 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3105 | } |
| 3106 | |
| 3107 | return 0; |
| 3108 | } |
| 3109 | |
| 3110 | void __stdcall glCullFace(GLenum mode) |
| 3111 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3112 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3113 | |
| 3114 | try |
| 3115 | { |
| 3116 | switch (mode) |
| 3117 | { |
| 3118 | case GL_FRONT: |
| 3119 | case GL_BACK: |
| 3120 | case GL_FRONT_AND_BACK: |
| 3121 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3122 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3123 | |
| 3124 | if (context) |
| 3125 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3126 | context->setCullMode(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3127 | } |
| 3128 | } |
| 3129 | break; |
| 3130 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3131 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3132 | } |
| 3133 | } |
| 3134 | catch(std::bad_alloc&) |
| 3135 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3136 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3137 | } |
| 3138 | } |
| 3139 | |
| 3140 | void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers) |
| 3141 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3142 | 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] | 3143 | |
| 3144 | try |
| 3145 | { |
| 3146 | if (n < 0) |
| 3147 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3148 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3149 | } |
| 3150 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3151 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3152 | |
| 3153 | if (context) |
| 3154 | { |
| 3155 | for (int i = 0; i < n; i++) |
| 3156 | { |
| 3157 | context->deleteBuffer(buffers[i]); |
| 3158 | } |
| 3159 | } |
| 3160 | } |
| 3161 | catch(std::bad_alloc&) |
| 3162 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3163 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3164 | } |
| 3165 | } |
| 3166 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3167 | void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences) |
| 3168 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3169 | 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] | 3170 | |
| 3171 | try |
| 3172 | { |
| 3173 | if (n < 0) |
| 3174 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3175 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3176 | } |
| 3177 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3178 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3179 | |
| 3180 | if (context) |
| 3181 | { |
| 3182 | for (int i = 0; i < n; i++) |
| 3183 | { |
| 3184 | context->deleteFence(fences[i]); |
| 3185 | } |
| 3186 | } |
| 3187 | } |
| 3188 | catch(std::bad_alloc&) |
| 3189 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3190 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3191 | } |
| 3192 | } |
| 3193 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3194 | void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) |
| 3195 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3196 | 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] | 3197 | |
| 3198 | try |
| 3199 | { |
| 3200 | if (n < 0) |
| 3201 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3202 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3203 | } |
| 3204 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3205 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3206 | |
| 3207 | if (context) |
| 3208 | { |
| 3209 | for (int i = 0; i < n; i++) |
| 3210 | { |
| 3211 | if (framebuffers[i] != 0) |
| 3212 | { |
| 3213 | context->deleteFramebuffer(framebuffers[i]); |
| 3214 | } |
| 3215 | } |
| 3216 | } |
| 3217 | } |
| 3218 | catch(std::bad_alloc&) |
| 3219 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3220 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3221 | } |
| 3222 | } |
| 3223 | |
| 3224 | void __stdcall glDeleteProgram(GLuint program) |
| 3225 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3226 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3227 | |
| 3228 | try |
| 3229 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3230 | if (program == 0) |
| 3231 | { |
| 3232 | return; |
| 3233 | } |
| 3234 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3235 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3236 | |
| 3237 | if (context) |
| 3238 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3239 | if (!context->getProgram(program)) |
| 3240 | { |
| 3241 | if(context->getShader(program)) |
| 3242 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3243 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3244 | } |
| 3245 | else |
| 3246 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3247 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3248 | } |
| 3249 | } |
| 3250 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3251 | context->deleteProgram(program); |
| 3252 | } |
| 3253 | } |
| 3254 | catch(std::bad_alloc&) |
| 3255 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3256 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3257 | } |
| 3258 | } |
| 3259 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3260 | void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids) |
| 3261 | { |
| 3262 | EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids); |
| 3263 | |
| 3264 | try |
| 3265 | { |
| 3266 | if (n < 0) |
| 3267 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3268 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3269 | } |
| 3270 | |
| 3271 | gl::Context *context = gl::getNonLostContext(); |
| 3272 | |
| 3273 | if (context) |
| 3274 | { |
| 3275 | for (int i = 0; i < n; i++) |
| 3276 | { |
| 3277 | context->deleteQuery(ids[i]); |
| 3278 | } |
| 3279 | } |
| 3280 | } |
| 3281 | catch(std::bad_alloc&) |
| 3282 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3283 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3284 | } |
| 3285 | } |
| 3286 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3287 | void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) |
| 3288 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3289 | 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] | 3290 | |
| 3291 | try |
| 3292 | { |
| 3293 | if (n < 0) |
| 3294 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3295 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3296 | } |
| 3297 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3298 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3299 | |
| 3300 | if (context) |
| 3301 | { |
daniel@transgaming.com | e2b2212 | 2010-03-11 19:22:14 +0000 | [diff] [blame] | 3302 | for (int i = 0; i < n; i++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3303 | { |
| 3304 | context->deleteRenderbuffer(renderbuffers[i]); |
| 3305 | } |
| 3306 | } |
| 3307 | } |
| 3308 | catch(std::bad_alloc&) |
| 3309 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3310 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3311 | } |
| 3312 | } |
| 3313 | |
| 3314 | void __stdcall glDeleteShader(GLuint shader) |
| 3315 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3316 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3317 | |
| 3318 | try |
| 3319 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3320 | if (shader == 0) |
| 3321 | { |
| 3322 | return; |
| 3323 | } |
| 3324 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3325 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3326 | |
| 3327 | if (context) |
| 3328 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3329 | if (!context->getShader(shader)) |
| 3330 | { |
| 3331 | if(context->getProgram(shader)) |
| 3332 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3333 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3334 | } |
| 3335 | else |
| 3336 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3337 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3338 | } |
| 3339 | } |
| 3340 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3341 | context->deleteShader(shader); |
| 3342 | } |
| 3343 | } |
| 3344 | catch(std::bad_alloc&) |
| 3345 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3346 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3347 | } |
| 3348 | } |
| 3349 | |
| 3350 | void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures) |
| 3351 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3352 | 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] | 3353 | |
| 3354 | try |
| 3355 | { |
| 3356 | if (n < 0) |
| 3357 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3358 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3359 | } |
| 3360 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3361 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3362 | |
| 3363 | if (context) |
| 3364 | { |
| 3365 | for (int i = 0; i < n; i++) |
| 3366 | { |
| 3367 | if (textures[i] != 0) |
| 3368 | { |
| 3369 | context->deleteTexture(textures[i]); |
| 3370 | } |
| 3371 | } |
| 3372 | } |
| 3373 | } |
| 3374 | catch(std::bad_alloc&) |
| 3375 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3376 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3377 | } |
| 3378 | } |
| 3379 | |
| 3380 | void __stdcall glDepthFunc(GLenum func) |
| 3381 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3382 | EVENT("(GLenum func = 0x%X)", func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3383 | |
| 3384 | try |
| 3385 | { |
| 3386 | switch (func) |
| 3387 | { |
| 3388 | case GL_NEVER: |
| 3389 | case GL_ALWAYS: |
| 3390 | case GL_LESS: |
| 3391 | case GL_LEQUAL: |
| 3392 | case GL_EQUAL: |
| 3393 | case GL_GREATER: |
| 3394 | case GL_GEQUAL: |
| 3395 | case GL_NOTEQUAL: |
| 3396 | break; |
| 3397 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3398 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3399 | } |
| 3400 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3401 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3402 | |
| 3403 | if (context) |
| 3404 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3405 | context->setDepthFunc(func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3406 | } |
| 3407 | } |
| 3408 | catch(std::bad_alloc&) |
| 3409 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3410 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3411 | } |
| 3412 | } |
| 3413 | |
| 3414 | void __stdcall glDepthMask(GLboolean flag) |
| 3415 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 3416 | EVENT("(GLboolean flag = %u)", flag); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3417 | |
| 3418 | try |
| 3419 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3420 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3421 | |
| 3422 | if (context) |
| 3423 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3424 | context->setDepthMask(flag != GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3425 | } |
| 3426 | } |
| 3427 | catch(std::bad_alloc&) |
| 3428 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3429 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3430 | } |
| 3431 | } |
| 3432 | |
| 3433 | void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar) |
| 3434 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3435 | EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3436 | |
| 3437 | try |
| 3438 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3439 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3440 | |
| 3441 | if (context) |
| 3442 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3443 | context->setDepthRange(zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3444 | } |
| 3445 | } |
| 3446 | catch(std::bad_alloc&) |
| 3447 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3448 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3449 | } |
| 3450 | } |
| 3451 | |
| 3452 | void __stdcall glDetachShader(GLuint program, GLuint shader) |
| 3453 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3454 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3455 | |
| 3456 | try |
| 3457 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3458 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3459 | |
| 3460 | if (context) |
| 3461 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3462 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3463 | gl::Program *programObject = context->getProgram(program); |
| 3464 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3465 | |
| 3466 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3467 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3468 | gl::Shader *shaderByProgramHandle; |
| 3469 | shaderByProgramHandle = context->getShader(program); |
| 3470 | if (!shaderByProgramHandle) |
| 3471 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3472 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3473 | } |
| 3474 | else |
| 3475 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3476 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3477 | } |
| 3478 | } |
| 3479 | |
| 3480 | if (!shaderObject) |
| 3481 | { |
| 3482 | gl::Program *programByShaderHandle = context->getProgram(shader); |
| 3483 | if (!programByShaderHandle) |
| 3484 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3485 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3486 | } |
| 3487 | else |
| 3488 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3489 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3490 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3491 | } |
| 3492 | |
| 3493 | if (!programObject->detachShader(shaderObject)) |
| 3494 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3495 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3496 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3497 | } |
| 3498 | } |
| 3499 | catch(std::bad_alloc&) |
| 3500 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3501 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3502 | } |
| 3503 | } |
| 3504 | |
| 3505 | void __stdcall glDisable(GLenum cap) |
| 3506 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3507 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3508 | |
| 3509 | try |
| 3510 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3511 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3512 | |
| 3513 | if (context) |
| 3514 | { |
| 3515 | switch (cap) |
| 3516 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3517 | case GL_CULL_FACE: context->setCullFace(false); break; |
| 3518 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break; |
| 3519 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break; |
| 3520 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break; |
| 3521 | case GL_SCISSOR_TEST: context->setScissorTest(false); break; |
| 3522 | case GL_STENCIL_TEST: context->setStencilTest(false); break; |
| 3523 | case GL_DEPTH_TEST: context->setDepthTest(false); break; |
| 3524 | case GL_BLEND: context->setBlend(false); break; |
| 3525 | case GL_DITHER: context->setDither(false); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 3526 | |
| 3527 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 3528 | case GL_RASTERIZER_DISCARD: |
| 3529 | if (context->getClientVersion() < 3) |
| 3530 | { |
| 3531 | return gl::error(GL_INVALID_ENUM); |
| 3532 | } |
| 3533 | UNIMPLEMENTED(); |
| 3534 | break; |
| 3535 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3536 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3537 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3538 | } |
| 3539 | } |
| 3540 | } |
| 3541 | catch(std::bad_alloc&) |
| 3542 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3543 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3544 | } |
| 3545 | } |
| 3546 | |
| 3547 | void __stdcall glDisableVertexAttribArray(GLuint index) |
| 3548 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3549 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3550 | |
| 3551 | try |
| 3552 | { |
| 3553 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3554 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3555 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3556 | } |
| 3557 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3558 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3559 | |
| 3560 | if (context) |
| 3561 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3562 | context->setEnableVertexAttribArray(index, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3563 | } |
| 3564 | } |
| 3565 | catch(std::bad_alloc&) |
| 3566 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3567 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3568 | } |
| 3569 | } |
| 3570 | |
| 3571 | void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count) |
| 3572 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3573 | 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] | 3574 | |
| 3575 | try |
| 3576 | { |
| 3577 | if (count < 0 || first < 0) |
| 3578 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3579 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3580 | } |
| 3581 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3582 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3583 | |
| 3584 | if (context) |
| 3585 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3586 | context->drawArrays(mode, first, count, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3587 | } |
| 3588 | } |
| 3589 | catch(std::bad_alloc&) |
| 3590 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3591 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3592 | } |
| 3593 | } |
| 3594 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3595 | void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
| 3596 | { |
| 3597 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount); |
| 3598 | |
| 3599 | try |
| 3600 | { |
| 3601 | if (count < 0 || first < 0 || primcount < 0) |
| 3602 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3603 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3604 | } |
| 3605 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3606 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3607 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3608 | gl::Context *context = gl::getNonLostContext(); |
| 3609 | |
| 3610 | if (context) |
| 3611 | { |
| 3612 | context->drawArrays(mode, first, count, primcount); |
| 3613 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3614 | } |
| 3615 | } |
| 3616 | catch(std::bad_alloc&) |
| 3617 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3618 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3619 | } |
| 3620 | } |
| 3621 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3622 | 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] | 3623 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3624 | 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] | 3625 | mode, count, type, indices); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3626 | |
| 3627 | try |
| 3628 | { |
| 3629 | if (count < 0) |
| 3630 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3631 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3632 | } |
| 3633 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3634 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3635 | |
| 3636 | if (context) |
| 3637 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3638 | switch (type) |
| 3639 | { |
| 3640 | case GL_UNSIGNED_BYTE: |
| 3641 | case GL_UNSIGNED_SHORT: |
| 3642 | break; |
| 3643 | case GL_UNSIGNED_INT: |
| 3644 | if (!context->supports32bitIndices()) |
| 3645 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3646 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3647 | } |
| 3648 | break; |
| 3649 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3650 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3651 | } |
| 3652 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3653 | context->drawElements(mode, count, type, indices, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3654 | } |
| 3655 | } |
| 3656 | catch(std::bad_alloc&) |
| 3657 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3658 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3659 | } |
| 3660 | } |
| 3661 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3662 | void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount) |
| 3663 | { |
| 3664 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)", |
| 3665 | mode, count, type, indices, primcount); |
| 3666 | |
| 3667 | try |
| 3668 | { |
| 3669 | if (count < 0 || primcount < 0) |
| 3670 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3671 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3672 | } |
| 3673 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3674 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3675 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3676 | gl::Context *context = gl::getNonLostContext(); |
| 3677 | |
| 3678 | if (context) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3679 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3680 | switch (type) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3681 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3682 | case GL_UNSIGNED_BYTE: |
| 3683 | case GL_UNSIGNED_SHORT: |
| 3684 | break; |
| 3685 | case GL_UNSIGNED_INT: |
| 3686 | if (!context->supports32bitIndices()) |
| 3687 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3688 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3689 | } |
| 3690 | break; |
| 3691 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3692 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3693 | } |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3694 | |
| 3695 | context->drawElements(mode, count, type, indices, primcount); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3696 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3697 | } |
| 3698 | } |
| 3699 | catch(std::bad_alloc&) |
| 3700 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3701 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3702 | } |
| 3703 | } |
| 3704 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3705 | void __stdcall glEnable(GLenum cap) |
| 3706 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3707 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3708 | |
| 3709 | try |
| 3710 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3711 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3712 | |
| 3713 | if (context) |
| 3714 | { |
| 3715 | switch (cap) |
| 3716 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3717 | case GL_CULL_FACE: context->setCullFace(true); break; |
| 3718 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break; |
| 3719 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break; |
| 3720 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break; |
| 3721 | case GL_SCISSOR_TEST: context->setScissorTest(true); break; |
| 3722 | case GL_STENCIL_TEST: context->setStencilTest(true); break; |
| 3723 | case GL_DEPTH_TEST: context->setDepthTest(true); break; |
| 3724 | case GL_BLEND: context->setBlend(true); break; |
| 3725 | case GL_DITHER: context->setDither(true); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3726 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3727 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3728 | } |
| 3729 | } |
| 3730 | } |
| 3731 | catch(std::bad_alloc&) |
| 3732 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3733 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3734 | } |
| 3735 | } |
| 3736 | |
| 3737 | void __stdcall glEnableVertexAttribArray(GLuint index) |
| 3738 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3739 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3740 | |
| 3741 | try |
| 3742 | { |
| 3743 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3744 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3745 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3746 | } |
| 3747 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3748 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3749 | |
| 3750 | if (context) |
| 3751 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3752 | context->setEnableVertexAttribArray(index, true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3753 | } |
| 3754 | } |
| 3755 | catch(std::bad_alloc&) |
| 3756 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3757 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3758 | } |
| 3759 | } |
| 3760 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3761 | void __stdcall glEndQueryEXT(GLenum target) |
| 3762 | { |
| 3763 | EVENT("GLenum target = 0x%X)", target); |
| 3764 | |
| 3765 | try |
| 3766 | { |
| 3767 | switch (target) |
| 3768 | { |
| 3769 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 3770 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 3771 | break; |
| 3772 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3773 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3774 | } |
| 3775 | |
| 3776 | gl::Context *context = gl::getNonLostContext(); |
| 3777 | |
| 3778 | if (context) |
| 3779 | { |
| 3780 | context->endQuery(target); |
| 3781 | } |
| 3782 | } |
| 3783 | catch(std::bad_alloc&) |
| 3784 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3785 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3786 | } |
| 3787 | } |
| 3788 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3789 | void __stdcall glFinishFenceNV(GLuint fence) |
| 3790 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3791 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3792 | |
| 3793 | try |
| 3794 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3795 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3796 | |
| 3797 | if (context) |
| 3798 | { |
| 3799 | gl::Fence* fenceObject = context->getFence(fence); |
| 3800 | |
| 3801 | if (fenceObject == NULL) |
| 3802 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3803 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3804 | } |
| 3805 | |
| 3806 | fenceObject->finishFence(); |
| 3807 | } |
| 3808 | } |
| 3809 | catch(std::bad_alloc&) |
| 3810 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3811 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3812 | } |
| 3813 | } |
| 3814 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3815 | void __stdcall glFinish(void) |
| 3816 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3817 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3818 | |
| 3819 | try |
| 3820 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3821 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3822 | |
| 3823 | if (context) |
| 3824 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 3825 | context->sync(true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3826 | } |
| 3827 | } |
| 3828 | catch(std::bad_alloc&) |
| 3829 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3830 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3831 | } |
| 3832 | } |
| 3833 | |
| 3834 | void __stdcall glFlush(void) |
| 3835 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3836 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3837 | |
| 3838 | try |
| 3839 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3840 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3841 | |
| 3842 | if (context) |
| 3843 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 3844 | context->sync(false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3845 | } |
| 3846 | } |
| 3847 | catch(std::bad_alloc&) |
| 3848 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3849 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3850 | } |
| 3851 | } |
| 3852 | |
| 3853 | void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) |
| 3854 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3855 | 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] | 3856 | "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3857 | |
| 3858 | try |
| 3859 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3860 | 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] | 3861 | || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3862 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3863 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3864 | } |
| 3865 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3866 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3867 | |
| 3868 | if (context) |
| 3869 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3870 | gl::Framebuffer *framebuffer = NULL; |
| 3871 | GLuint framebufferHandle = 0; |
| 3872 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 3873 | { |
| 3874 | framebuffer = context->getReadFramebuffer(); |
| 3875 | framebufferHandle = context->getReadFramebufferHandle(); |
| 3876 | } |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 3877 | else |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3878 | { |
| 3879 | framebuffer = context->getDrawFramebuffer(); |
| 3880 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 3881 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3882 | |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 3883 | if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3884 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3885 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3886 | } |
| 3887 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3888 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3889 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3890 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 3891 | |
| 3892 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 3893 | { |
| 3894 | return gl::error(GL_INVALID_VALUE); |
| 3895 | } |
| 3896 | |
| 3897 | framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer); |
| 3898 | } |
| 3899 | else |
| 3900 | { |
| 3901 | switch (attachment) |
| 3902 | { |
| 3903 | case GL_DEPTH_ATTACHMENT: |
| 3904 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer); |
| 3905 | break; |
| 3906 | case GL_STENCIL_ATTACHMENT: |
| 3907 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer); |
| 3908 | break; |
| 3909 | default: |
| 3910 | return gl::error(GL_INVALID_ENUM); |
| 3911 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3912 | } |
| 3913 | } |
| 3914 | } |
| 3915 | catch(std::bad_alloc&) |
| 3916 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3917 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3918 | } |
| 3919 | } |
| 3920 | |
| 3921 | void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) |
| 3922 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3923 | 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] | 3924 | "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3925 | |
| 3926 | try |
| 3927 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3928 | 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] | 3929 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3930 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3931 | } |
| 3932 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3933 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3934 | |
| 3935 | if (context) |
| 3936 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3937 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 3938 | { |
| 3939 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 3940 | |
| 3941 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 3942 | { |
| 3943 | return gl::error(GL_INVALID_VALUE); |
| 3944 | } |
| 3945 | } |
| 3946 | else |
| 3947 | { |
| 3948 | switch (attachment) |
| 3949 | { |
| 3950 | case GL_DEPTH_ATTACHMENT: |
| 3951 | case GL_STENCIL_ATTACHMENT: |
| 3952 | break; |
| 3953 | default: |
| 3954 | return gl::error(GL_INVALID_ENUM); |
| 3955 | } |
| 3956 | } |
| 3957 | |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3958 | if (texture == 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3959 | { |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3960 | textarget = GL_NONE; |
| 3961 | } |
| 3962 | else |
| 3963 | { |
| 3964 | gl::Texture *tex = context->getTexture(texture); |
| 3965 | |
| 3966 | if (tex == NULL) |
| 3967 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3968 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3969 | } |
| 3970 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3971 | switch (textarget) |
| 3972 | { |
| 3973 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3974 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3975 | if (tex->getTarget() != GL_TEXTURE_2D) |
| 3976 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3977 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3978 | } |
| 3979 | gl::Texture2D *tex2d = static_cast<gl::Texture2D *>(tex); |
daniel@transgaming.com | 92f4992 | 2012-05-09 15:49:19 +0000 | [diff] [blame] | 3980 | if (tex2d->isCompressed(0)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3981 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3982 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3983 | } |
| 3984 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3985 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3986 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3987 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3988 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3989 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3990 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3991 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3992 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3993 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3994 | if (tex->getTarget() != GL_TEXTURE_CUBE_MAP) |
| 3995 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3996 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3997 | } |
| 3998 | gl::TextureCubeMap *texcube = static_cast<gl::TextureCubeMap *>(tex); |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 3999 | if (texcube->isCompressed(textarget, level)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4000 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4001 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4002 | } |
| 4003 | break; |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4004 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4005 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4006 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4007 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4008 | } |
| 4009 | |
| 4010 | if (level != 0) |
| 4011 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4012 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4013 | } |
| 4014 | } |
| 4015 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4016 | gl::Framebuffer *framebuffer = NULL; |
| 4017 | GLuint framebufferHandle = 0; |
| 4018 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4019 | { |
| 4020 | framebuffer = context->getReadFramebuffer(); |
| 4021 | framebufferHandle = context->getReadFramebufferHandle(); |
| 4022 | } |
| 4023 | else |
| 4024 | { |
| 4025 | framebuffer = context->getDrawFramebuffer(); |
| 4026 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 4027 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4028 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4029 | if (framebufferHandle == 0 || !framebuffer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4030 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4031 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4032 | } |
| 4033 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4034 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4035 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4036 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4037 | |
| 4038 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4039 | { |
| 4040 | return gl::error(GL_INVALID_VALUE); |
| 4041 | } |
| 4042 | |
| 4043 | framebuffer->setColorbuffer(colorAttachment, textarget, texture); |
| 4044 | } |
| 4045 | else |
| 4046 | { |
| 4047 | switch (attachment) |
| 4048 | { |
| 4049 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break; |
| 4050 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break; |
| 4051 | } |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4052 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4053 | } |
| 4054 | } |
| 4055 | catch(std::bad_alloc&) |
| 4056 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4057 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4058 | } |
| 4059 | } |
| 4060 | |
| 4061 | void __stdcall glFrontFace(GLenum mode) |
| 4062 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4063 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4064 | |
| 4065 | try |
| 4066 | { |
| 4067 | switch (mode) |
| 4068 | { |
| 4069 | case GL_CW: |
| 4070 | case GL_CCW: |
| 4071 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4072 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4073 | |
| 4074 | if (context) |
| 4075 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4076 | context->setFrontFace(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4077 | } |
| 4078 | } |
| 4079 | break; |
| 4080 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4081 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 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 glGenBuffers(GLsizei n, GLuint* buffers) |
| 4091 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4092 | EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers); |
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 | buffers[i] = context->createBuffer(); |
| 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 | |
| 4117 | void __stdcall glGenerateMipmap(GLenum target) |
| 4118 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4119 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4120 | |
| 4121 | try |
| 4122 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4123 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4124 | |
| 4125 | if (context) |
| 4126 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4127 | gl::Texture *texture = NULL; |
| 4128 | GLint internalFormat = GL_NONE; |
| 4129 | bool isCompressed = false; |
| 4130 | bool isDepth = false; |
| 4131 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4132 | switch (target) |
| 4133 | { |
| 4134 | case GL_TEXTURE_2D: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4135 | { |
| 4136 | gl::Texture2D *tex2d = context->getTexture2D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4137 | if (tex2d) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4138 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4139 | internalFormat = tex2d->getInternalFormat(0); |
| 4140 | isCompressed = tex2d->isCompressed(0); |
| 4141 | isDepth = tex2d->isDepth(0); |
| 4142 | texture = tex2d; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4143 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4144 | break; |
| 4145 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4146 | |
| 4147 | case GL_TEXTURE_CUBE_MAP: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4148 | { |
| 4149 | gl::TextureCubeMap *texcube = context->getTextureCubeMap(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4150 | if (texcube) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4151 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4152 | internalFormat = texcube->getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 4153 | isCompressed = texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 4154 | isDepth = false; |
| 4155 | texture = texcube; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4156 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4157 | break; |
| 4158 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4159 | |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4160 | case GL_TEXTURE_3D: |
| 4161 | { |
| 4162 | if (context->getClientVersion() < 3) |
| 4163 | { |
| 4164 | return gl::error(GL_INVALID_ENUM); |
| 4165 | } |
| 4166 | |
| 4167 | gl::Texture3D *tex3D = context->getTexture3D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4168 | if (tex3D) |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4169 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4170 | internalFormat = tex3D->getInternalFormat(0); |
| 4171 | isCompressed = tex3D->isCompressed(0); |
| 4172 | isDepth = tex3D->isDepth(0); |
| 4173 | texture = tex3D; |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4174 | } |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4175 | break; |
| 4176 | } |
| 4177 | |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4178 | case GL_TEXTURE_2D_ARRAY: |
| 4179 | { |
| 4180 | if (context->getClientVersion() < 3) |
| 4181 | { |
| 4182 | return gl::error(GL_INVALID_ENUM); |
| 4183 | } |
| 4184 | |
| 4185 | gl::Texture2DArray *tex2darr = context->getTexture2DArray(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4186 | if (tex2darr) |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4187 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4188 | internalFormat = tex2darr->getInternalFormat(0); |
| 4189 | isCompressed = tex2darr->isCompressed(0); |
| 4190 | isDepth = tex2darr->isDepth(0); |
| 4191 | texture = tex2darr; |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4192 | } |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4193 | break; |
| 4194 | } |
| 4195 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4196 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4197 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4198 | } |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4199 | |
| 4200 | if (!texture) |
| 4201 | { |
| 4202 | return gl::error(GL_INVALID_OPERATION); |
| 4203 | } |
| 4204 | |
| 4205 | // Internally, all texture formats are sized so checking if the format |
| 4206 | // is color renderable and filterable will not fail. |
| 4207 | if (isDepth || isCompressed || |
| 4208 | !gl::IsColorRenderingSupported(internalFormat, context) || |
| 4209 | !gl::IsTextureFilteringSupported(internalFormat, context)) |
| 4210 | { |
| 4211 | return gl::error(GL_INVALID_OPERATION); |
| 4212 | } |
| 4213 | |
| 4214 | texture->generateMipmaps(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4215 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4216 | } |
| 4217 | catch(std::bad_alloc&) |
| 4218 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4219 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4220 | } |
| 4221 | } |
| 4222 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4223 | void __stdcall glGenFencesNV(GLsizei n, GLuint* fences) |
| 4224 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4225 | EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4226 | |
| 4227 | try |
| 4228 | { |
| 4229 | if (n < 0) |
| 4230 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4231 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4232 | } |
| 4233 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4234 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4235 | |
| 4236 | if (context) |
| 4237 | { |
| 4238 | for (int i = 0; i < n; i++) |
| 4239 | { |
| 4240 | fences[i] = context->createFence(); |
| 4241 | } |
| 4242 | } |
| 4243 | } |
| 4244 | catch(std::bad_alloc&) |
| 4245 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4246 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4247 | } |
| 4248 | } |
| 4249 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4250 | void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers) |
| 4251 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4252 | EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4253 | |
| 4254 | try |
| 4255 | { |
| 4256 | if (n < 0) |
| 4257 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4258 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4259 | } |
| 4260 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4261 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4262 | |
| 4263 | if (context) |
| 4264 | { |
| 4265 | for (int i = 0; i < n; i++) |
| 4266 | { |
| 4267 | framebuffers[i] = context->createFramebuffer(); |
| 4268 | } |
| 4269 | } |
| 4270 | } |
| 4271 | catch(std::bad_alloc&) |
| 4272 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4273 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4274 | } |
| 4275 | } |
| 4276 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4277 | void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids) |
| 4278 | { |
| 4279 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 4280 | |
| 4281 | try |
| 4282 | { |
| 4283 | if (n < 0) |
| 4284 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4285 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4286 | } |
| 4287 | |
| 4288 | gl::Context *context = gl::getNonLostContext(); |
| 4289 | |
| 4290 | if (context) |
| 4291 | { |
| 4292 | for (int i = 0; i < n; i++) |
| 4293 | { |
| 4294 | ids[i] = context->createQuery(); |
| 4295 | } |
| 4296 | } |
| 4297 | } |
| 4298 | catch(std::bad_alloc&) |
| 4299 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4300 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4301 | } |
| 4302 | } |
| 4303 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4304 | void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) |
| 4305 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4306 | EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4307 | |
| 4308 | try |
| 4309 | { |
| 4310 | if (n < 0) |
| 4311 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4312 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4313 | } |
| 4314 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4315 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4316 | |
| 4317 | if (context) |
| 4318 | { |
| 4319 | for (int i = 0; i < n; i++) |
| 4320 | { |
| 4321 | renderbuffers[i] = context->createRenderbuffer(); |
| 4322 | } |
| 4323 | } |
| 4324 | } |
| 4325 | catch(std::bad_alloc&) |
| 4326 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4327 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4328 | } |
| 4329 | } |
| 4330 | |
| 4331 | void __stdcall glGenTextures(GLsizei n, GLuint* textures) |
| 4332 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4333 | EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4334 | |
| 4335 | try |
| 4336 | { |
| 4337 | if (n < 0) |
| 4338 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4339 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4340 | } |
| 4341 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4342 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4343 | |
| 4344 | if (context) |
| 4345 | { |
| 4346 | for (int i = 0; i < n; i++) |
| 4347 | { |
| 4348 | textures[i] = context->createTexture(); |
| 4349 | } |
| 4350 | } |
| 4351 | } |
| 4352 | catch(std::bad_alloc&) |
| 4353 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4354 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4355 | } |
| 4356 | } |
| 4357 | |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4358 | 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] | 4359 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4360 | 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] | 4361 | "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] | 4362 | program, index, bufsize, length, size, type, name); |
| 4363 | |
| 4364 | try |
| 4365 | { |
| 4366 | if (bufsize < 0) |
| 4367 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4368 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4369 | } |
| 4370 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4371 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4372 | |
| 4373 | if (context) |
| 4374 | { |
| 4375 | gl::Program *programObject = context->getProgram(program); |
| 4376 | |
| 4377 | if (!programObject) |
| 4378 | { |
| 4379 | if (context->getShader(program)) |
| 4380 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4381 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4382 | } |
| 4383 | else |
| 4384 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4385 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4386 | } |
| 4387 | } |
| 4388 | |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4389 | if (index >= (GLuint)programObject->getActiveAttributeCount()) |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4390 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4391 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4392 | } |
| 4393 | |
| 4394 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 4395 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4396 | } |
| 4397 | catch(std::bad_alloc&) |
| 4398 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4399 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4400 | } |
| 4401 | } |
| 4402 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4403 | 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] | 4404 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4405 | EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4406 | "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] | 4407 | program, index, bufsize, length, size, type, name); |
| 4408 | |
| 4409 | try |
| 4410 | { |
| 4411 | if (bufsize < 0) |
| 4412 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4413 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4414 | } |
| 4415 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4416 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4417 | |
| 4418 | if (context) |
| 4419 | { |
| 4420 | gl::Program *programObject = context->getProgram(program); |
| 4421 | |
| 4422 | if (!programObject) |
| 4423 | { |
| 4424 | if (context->getShader(program)) |
| 4425 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4426 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4427 | } |
| 4428 | else |
| 4429 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4430 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4431 | } |
| 4432 | } |
| 4433 | |
| 4434 | if (index >= (GLuint)programObject->getActiveUniformCount()) |
| 4435 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4436 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4437 | } |
| 4438 | |
| 4439 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 4440 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4441 | } |
| 4442 | catch(std::bad_alloc&) |
| 4443 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4444 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4445 | } |
| 4446 | } |
| 4447 | |
| 4448 | void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) |
| 4449 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4450 | 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] | 4451 | program, maxcount, count, shaders); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4452 | |
| 4453 | try |
| 4454 | { |
| 4455 | if (maxcount < 0) |
| 4456 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4457 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4458 | } |
| 4459 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4460 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4461 | |
| 4462 | if (context) |
| 4463 | { |
| 4464 | gl::Program *programObject = context->getProgram(program); |
| 4465 | |
| 4466 | if (!programObject) |
| 4467 | { |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4468 | if (context->getShader(program)) |
| 4469 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4470 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4471 | } |
| 4472 | else |
| 4473 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4474 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4475 | } |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4476 | } |
| 4477 | |
| 4478 | return programObject->getAttachedShaders(maxcount, count, shaders); |
| 4479 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4480 | } |
| 4481 | catch(std::bad_alloc&) |
| 4482 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4483 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4484 | } |
| 4485 | } |
| 4486 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4487 | int __stdcall glGetAttribLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4488 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4489 | EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4490 | |
| 4491 | try |
| 4492 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4493 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4494 | |
| 4495 | if (context) |
| 4496 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4497 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4498 | gl::Program *programObject = context->getProgram(program); |
| 4499 | |
| 4500 | if (!programObject) |
| 4501 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4502 | if (context->getShader(program)) |
| 4503 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4504 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4505 | } |
| 4506 | else |
| 4507 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4508 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4509 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4510 | } |
| 4511 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4512 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 4513 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4514 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4515 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4516 | } |
| 4517 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4518 | return programBinary->getAttributeLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4519 | } |
| 4520 | } |
| 4521 | catch(std::bad_alloc&) |
| 4522 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4523 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4524 | } |
| 4525 | |
| 4526 | return -1; |
| 4527 | } |
| 4528 | |
| 4529 | void __stdcall glGetBooleanv(GLenum pname, GLboolean* params) |
| 4530 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4531 | 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] | 4532 | |
| 4533 | try |
| 4534 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4535 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4536 | |
| 4537 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4538 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4539 | if (!(context->getBooleanv(pname, params))) |
| 4540 | { |
| 4541 | GLenum nativeType; |
| 4542 | unsigned int numParams = 0; |
| 4543 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4544 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4545 | |
| 4546 | if (numParams == 0) |
| 4547 | return; // it is known that the pname is valid, but there are no parameters to return |
| 4548 | |
| 4549 | if (nativeType == GL_FLOAT) |
| 4550 | { |
| 4551 | GLfloat *floatParams = NULL; |
| 4552 | floatParams = new GLfloat[numParams]; |
| 4553 | |
| 4554 | context->getFloatv(pname, floatParams); |
| 4555 | |
| 4556 | for (unsigned int i = 0; i < numParams; ++i) |
| 4557 | { |
| 4558 | if (floatParams[i] == 0.0f) |
| 4559 | params[i] = GL_FALSE; |
| 4560 | else |
| 4561 | params[i] = GL_TRUE; |
| 4562 | } |
| 4563 | |
| 4564 | delete [] floatParams; |
| 4565 | } |
| 4566 | else if (nativeType == GL_INT) |
| 4567 | { |
| 4568 | GLint *intParams = NULL; |
| 4569 | intParams = new GLint[numParams]; |
| 4570 | |
| 4571 | context->getIntegerv(pname, intParams); |
| 4572 | |
| 4573 | for (unsigned int i = 0; i < numParams; ++i) |
| 4574 | { |
| 4575 | if (intParams[i] == 0) |
| 4576 | params[i] = GL_FALSE; |
| 4577 | else |
| 4578 | params[i] = GL_TRUE; |
| 4579 | } |
| 4580 | |
| 4581 | delete [] intParams; |
| 4582 | } |
| 4583 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4584 | } |
| 4585 | } |
| 4586 | catch(std::bad_alloc&) |
| 4587 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4588 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4589 | } |
| 4590 | } |
| 4591 | |
| 4592 | void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 4593 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4594 | 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] | 4595 | |
| 4596 | try |
| 4597 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4598 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4599 | |
| 4600 | if (context) |
| 4601 | { |
| 4602 | gl::Buffer *buffer; |
| 4603 | |
| 4604 | switch (target) |
| 4605 | { |
| 4606 | case GL_ARRAY_BUFFER: |
| 4607 | buffer = context->getArrayBuffer(); |
| 4608 | break; |
| 4609 | case GL_ELEMENT_ARRAY_BUFFER: |
| 4610 | buffer = context->getElementArrayBuffer(); |
| 4611 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4612 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4613 | } |
| 4614 | |
| 4615 | if (!buffer) |
| 4616 | { |
| 4617 | // 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] | 4618 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4619 | } |
| 4620 | |
| 4621 | switch (pname) |
| 4622 | { |
| 4623 | case GL_BUFFER_USAGE: |
| 4624 | *params = buffer->usage(); |
| 4625 | break; |
| 4626 | case GL_BUFFER_SIZE: |
| 4627 | *params = buffer->size(); |
| 4628 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4629 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4630 | } |
| 4631 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4632 | } |
| 4633 | catch(std::bad_alloc&) |
| 4634 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4635 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4636 | } |
| 4637 | } |
| 4638 | |
| 4639 | GLenum __stdcall glGetError(void) |
| 4640 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4641 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4642 | |
| 4643 | gl::Context *context = gl::getContext(); |
| 4644 | |
| 4645 | if (context) |
| 4646 | { |
daniel@transgaming.com | 82b2891 | 2011-12-12 21:01:35 +0000 | [diff] [blame] | 4647 | return context->getError(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4648 | } |
| 4649 | |
| 4650 | return GL_NO_ERROR; |
| 4651 | } |
| 4652 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4653 | void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 4654 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4655 | 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] | 4656 | |
| 4657 | try |
| 4658 | { |
| 4659 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4660 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4661 | |
| 4662 | if (context) |
| 4663 | { |
| 4664 | gl::Fence *fenceObject = context->getFence(fence); |
| 4665 | |
| 4666 | if (fenceObject == NULL) |
| 4667 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4668 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4669 | } |
| 4670 | |
| 4671 | fenceObject->getFenceiv(pname, params); |
| 4672 | } |
| 4673 | } |
| 4674 | catch(std::bad_alloc&) |
| 4675 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4676 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4677 | } |
| 4678 | } |
| 4679 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4680 | void __stdcall glGetFloatv(GLenum pname, GLfloat* params) |
| 4681 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4682 | 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] | 4683 | |
| 4684 | try |
| 4685 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4686 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4687 | |
| 4688 | if (context) |
| 4689 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4690 | if (!(context->getFloatv(pname, params))) |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4691 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4692 | GLenum nativeType; |
| 4693 | unsigned int numParams = 0; |
| 4694 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4695 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4696 | |
| 4697 | if (numParams == 0) |
| 4698 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 4699 | |
| 4700 | if (nativeType == GL_BOOL) |
| 4701 | { |
| 4702 | GLboolean *boolParams = NULL; |
| 4703 | boolParams = new GLboolean[numParams]; |
| 4704 | |
| 4705 | context->getBooleanv(pname, boolParams); |
| 4706 | |
| 4707 | for (unsigned int i = 0; i < numParams; ++i) |
| 4708 | { |
| 4709 | if (boolParams[i] == GL_FALSE) |
| 4710 | params[i] = 0.0f; |
| 4711 | else |
| 4712 | params[i] = 1.0f; |
| 4713 | } |
| 4714 | |
| 4715 | delete [] boolParams; |
| 4716 | } |
| 4717 | else if (nativeType == GL_INT) |
| 4718 | { |
| 4719 | GLint *intParams = NULL; |
| 4720 | intParams = new GLint[numParams]; |
| 4721 | |
| 4722 | context->getIntegerv(pname, intParams); |
| 4723 | |
| 4724 | for (unsigned int i = 0; i < numParams; ++i) |
| 4725 | { |
| 4726 | params[i] = (GLfloat)intParams[i]; |
| 4727 | } |
| 4728 | |
| 4729 | delete [] intParams; |
| 4730 | } |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4731 | } |
| 4732 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4733 | } |
| 4734 | catch(std::bad_alloc&) |
| 4735 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4736 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4737 | } |
| 4738 | } |
| 4739 | |
| 4740 | void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) |
| 4741 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4742 | 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] | 4743 | target, attachment, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4744 | |
| 4745 | try |
| 4746 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4747 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4748 | |
| 4749 | if (context) |
| 4750 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4751 | 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] | 4752 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4753 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4754 | } |
| 4755 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4756 | gl::Framebuffer *framebuffer = NULL; |
| 4757 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4758 | { |
| 4759 | if(context->getReadFramebufferHandle() == 0) |
| 4760 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4761 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4762 | } |
| 4763 | |
| 4764 | framebuffer = context->getReadFramebuffer(); |
| 4765 | } |
| 4766 | else |
| 4767 | { |
| 4768 | if (context->getDrawFramebufferHandle() == 0) |
| 4769 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4770 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4771 | } |
| 4772 | |
| 4773 | framebuffer = context->getDrawFramebuffer(); |
| 4774 | } |
| 4775 | |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4776 | GLenum attachmentType; |
| 4777 | GLuint attachmentHandle; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4778 | |
| 4779 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4780 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4781 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4782 | |
| 4783 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4784 | { |
| 4785 | return gl::error(GL_INVALID_ENUM); |
| 4786 | } |
| 4787 | |
| 4788 | attachmentType = framebuffer->getColorbufferType(colorAttachment); |
| 4789 | attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment); |
| 4790 | } |
| 4791 | else |
| 4792 | { |
| 4793 | switch (attachment) |
| 4794 | { |
| 4795 | case GL_DEPTH_ATTACHMENT: |
| 4796 | attachmentType = framebuffer->getDepthbufferType(); |
| 4797 | attachmentHandle = framebuffer->getDepthbufferHandle(); |
| 4798 | break; |
| 4799 | case GL_STENCIL_ATTACHMENT: |
| 4800 | attachmentType = framebuffer->getStencilbufferType(); |
| 4801 | attachmentHandle = framebuffer->getStencilbufferHandle(); |
| 4802 | break; |
| 4803 | default: return gl::error(GL_INVALID_ENUM); |
| 4804 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4805 | } |
| 4806 | |
| 4807 | GLenum attachmentObjectType; // Type category |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4808 | if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4809 | { |
| 4810 | attachmentObjectType = attachmentType; |
| 4811 | } |
apatrick@chromium.org | 551022e | 2012-01-23 19:56:54 +0000 | [diff] [blame] | 4812 | else if (gl::IsInternalTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4813 | { |
| 4814 | attachmentObjectType = GL_TEXTURE; |
| 4815 | } |
apatrick@chromium.org | a1d8059 | 2012-01-25 21:52:10 +0000 | [diff] [blame] | 4816 | else |
| 4817 | { |
| 4818 | UNREACHABLE(); |
| 4819 | return; |
| 4820 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4821 | |
| 4822 | switch (pname) |
| 4823 | { |
| 4824 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 4825 | *params = attachmentObjectType; |
| 4826 | break; |
| 4827 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 4828 | if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE) |
| 4829 | { |
| 4830 | *params = attachmentHandle; |
| 4831 | } |
| 4832 | else |
| 4833 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4834 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4835 | } |
| 4836 | break; |
| 4837 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 4838 | if (attachmentObjectType == GL_TEXTURE) |
| 4839 | { |
| 4840 | *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0 |
| 4841 | } |
| 4842 | else |
| 4843 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4844 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4845 | } |
| 4846 | break; |
| 4847 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 4848 | if (attachmentObjectType == GL_TEXTURE) |
| 4849 | { |
daniel@transgaming.com | 19ffc24 | 2010-05-04 03:35:21 +0000 | [diff] [blame] | 4850 | if (gl::IsCubemapTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4851 | { |
| 4852 | *params = attachmentType; |
| 4853 | } |
| 4854 | else |
| 4855 | { |
| 4856 | *params = 0; |
| 4857 | } |
| 4858 | } |
| 4859 | else |
| 4860 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4861 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4862 | } |
| 4863 | break; |
| 4864 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4865 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4866 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4867 | } |
| 4868 | } |
| 4869 | catch(std::bad_alloc&) |
| 4870 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4871 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4872 | } |
| 4873 | } |
| 4874 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 4875 | GLenum __stdcall glGetGraphicsResetStatusEXT(void) |
| 4876 | { |
| 4877 | EVENT("()"); |
| 4878 | |
| 4879 | try |
| 4880 | { |
| 4881 | gl::Context *context = gl::getContext(); |
| 4882 | |
| 4883 | if (context) |
| 4884 | { |
| 4885 | return context->getResetStatus(); |
| 4886 | } |
| 4887 | |
| 4888 | return GL_NO_ERROR; |
| 4889 | } |
| 4890 | catch(std::bad_alloc&) |
| 4891 | { |
| 4892 | return GL_OUT_OF_MEMORY; |
| 4893 | } |
| 4894 | } |
| 4895 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4896 | void __stdcall glGetIntegerv(GLenum pname, GLint* params) |
| 4897 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4898 | 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] | 4899 | |
| 4900 | try |
| 4901 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4902 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4903 | |
| 4904 | if (context) |
| 4905 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4906 | if (!(context->getIntegerv(pname, params))) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4907 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4908 | GLenum nativeType; |
| 4909 | unsigned int numParams = 0; |
| 4910 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4911 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4912 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4913 | if (numParams == 0) |
| 4914 | return; // it is known that pname is valid, but there are no parameters to return |
| 4915 | |
| 4916 | if (nativeType == GL_BOOL) |
| 4917 | { |
| 4918 | GLboolean *boolParams = NULL; |
| 4919 | boolParams = new GLboolean[numParams]; |
| 4920 | |
| 4921 | context->getBooleanv(pname, boolParams); |
| 4922 | |
| 4923 | for (unsigned int i = 0; i < numParams; ++i) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4924 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4925 | if (boolParams[i] == GL_FALSE) |
| 4926 | params[i] = 0; |
| 4927 | else |
| 4928 | params[i] = 1; |
| 4929 | } |
| 4930 | |
| 4931 | delete [] boolParams; |
| 4932 | } |
| 4933 | else if (nativeType == GL_FLOAT) |
| 4934 | { |
| 4935 | GLfloat *floatParams = NULL; |
| 4936 | floatParams = new GLfloat[numParams]; |
| 4937 | |
| 4938 | context->getFloatv(pname, floatParams); |
| 4939 | |
| 4940 | for (unsigned int i = 0; i < numParams; ++i) |
| 4941 | { |
daniel@transgaming.com | c164135 | 2010-04-26 15:33:36 +0000 | [diff] [blame] | 4942 | 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] | 4943 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4944 | params[i] = (GLint)(((GLfloat)(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4945 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4946 | else |
| 4947 | 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] | 4948 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4949 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4950 | delete [] floatParams; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4951 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4952 | } |
| 4953 | } |
| 4954 | } |
| 4955 | catch(std::bad_alloc&) |
| 4956 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4957 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4958 | } |
| 4959 | } |
| 4960 | |
| 4961 | void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params) |
| 4962 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4963 | 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] | 4964 | |
| 4965 | try |
| 4966 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4967 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4968 | |
| 4969 | if (context) |
| 4970 | { |
| 4971 | gl::Program *programObject = context->getProgram(program); |
| 4972 | |
| 4973 | if (!programObject) |
| 4974 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4975 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4976 | } |
| 4977 | |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 4978 | if (context->getClientVersion() < 3) |
| 4979 | { |
| 4980 | switch (pname) |
| 4981 | { |
| 4982 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 4983 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 4984 | return gl::error(GL_INVALID_ENUM); |
| 4985 | } |
| 4986 | } |
| 4987 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4988 | switch (pname) |
| 4989 | { |
| 4990 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4991 | *params = programObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4992 | return; |
| 4993 | case GL_LINK_STATUS: |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 4994 | *params = programObject->isLinked(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4995 | return; |
| 4996 | case GL_VALIDATE_STATUS: |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 4997 | *params = programObject->isValidated(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4998 | return; |
| 4999 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5000 | *params = programObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5001 | return; |
| 5002 | case GL_ATTACHED_SHADERS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5003 | *params = programObject->getAttachedShadersCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5004 | return; |
| 5005 | case GL_ACTIVE_ATTRIBUTES: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 5006 | *params = programObject->getActiveAttributeCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5007 | return; |
| 5008 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 5009 | *params = programObject->getActiveAttributeMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5010 | return; |
| 5011 | case GL_ACTIVE_UNIFORMS: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 5012 | *params = programObject->getActiveUniformCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5013 | return; |
| 5014 | case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 5015 | *params = programObject->getActiveUniformMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5016 | return; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 5017 | case GL_PROGRAM_BINARY_LENGTH_OES: |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 5018 | *params = programObject->getProgramBinaryLength(); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 5019 | return; |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 5020 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 5021 | *params = programObject->getActiveUniformBlockCount(); |
| 5022 | return; |
| 5023 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 5024 | *params = programObject->getActiveUniformBlockMaxLength(); |
| 5025 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5026 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5027 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5028 | } |
| 5029 | } |
| 5030 | } |
| 5031 | catch(std::bad_alloc&) |
| 5032 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5033 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5034 | } |
| 5035 | } |
| 5036 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5037 | void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5038 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5039 | 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] | 5040 | program, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5041 | |
| 5042 | try |
| 5043 | { |
| 5044 | if (bufsize < 0) |
| 5045 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5046 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5047 | } |
| 5048 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5049 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5050 | |
| 5051 | if (context) |
| 5052 | { |
| 5053 | gl::Program *programObject = context->getProgram(program); |
| 5054 | |
| 5055 | if (!programObject) |
| 5056 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5057 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5058 | } |
| 5059 | |
| 5060 | programObject->getInfoLog(bufsize, length, infolog); |
| 5061 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5062 | } |
| 5063 | catch(std::bad_alloc&) |
| 5064 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5065 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5066 | } |
| 5067 | } |
| 5068 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5069 | void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params) |
| 5070 | { |
| 5071 | EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params); |
| 5072 | |
| 5073 | try |
| 5074 | { |
| 5075 | switch (pname) |
| 5076 | { |
| 5077 | case GL_CURRENT_QUERY_EXT: |
| 5078 | break; |
| 5079 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5080 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5081 | } |
| 5082 | |
| 5083 | gl::Context *context = gl::getNonLostContext(); |
| 5084 | |
| 5085 | if (context) |
| 5086 | { |
| 5087 | params[0] = context->getActiveQuery(target); |
| 5088 | } |
| 5089 | } |
| 5090 | catch(std::bad_alloc&) |
| 5091 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5092 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5093 | } |
| 5094 | } |
| 5095 | |
| 5096 | void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) |
| 5097 | { |
| 5098 | EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params); |
| 5099 | |
| 5100 | try |
| 5101 | { |
| 5102 | switch (pname) |
| 5103 | { |
| 5104 | case GL_QUERY_RESULT_EXT: |
| 5105 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5106 | break; |
| 5107 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5108 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5109 | } |
| 5110 | gl::Context *context = gl::getNonLostContext(); |
| 5111 | |
| 5112 | if (context) |
| 5113 | { |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5114 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 5115 | |
| 5116 | if (!queryObject) |
| 5117 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5118 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5119 | } |
| 5120 | |
| 5121 | if (context->getActiveQuery(queryObject->getType()) == id) |
| 5122 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5123 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5124 | } |
| 5125 | |
| 5126 | switch(pname) |
| 5127 | { |
| 5128 | case GL_QUERY_RESULT_EXT: |
| 5129 | params[0] = queryObject->getResult(); |
| 5130 | break; |
| 5131 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5132 | params[0] = queryObject->isResultAvailable(); |
| 5133 | break; |
| 5134 | default: |
| 5135 | ASSERT(false); |
| 5136 | } |
| 5137 | } |
| 5138 | } |
| 5139 | catch(std::bad_alloc&) |
| 5140 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5141 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5142 | } |
| 5143 | } |
| 5144 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5145 | void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5146 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5147 | 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] | 5148 | |
| 5149 | try |
| 5150 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5151 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5152 | |
| 5153 | if (context) |
| 5154 | { |
| 5155 | if (target != GL_RENDERBUFFER) |
| 5156 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5157 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5158 | } |
| 5159 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5160 | if (context->getRenderbufferHandle() == 0) |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5161 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5162 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5163 | } |
| 5164 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5165 | gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle()); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5166 | |
| 5167 | switch (pname) |
| 5168 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5169 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break; |
| 5170 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break; |
| 5171 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break; |
| 5172 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break; |
| 5173 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break; |
| 5174 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break; |
| 5175 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break; |
| 5176 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break; |
| 5177 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break; |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5178 | case GL_RENDERBUFFER_SAMPLES_ANGLE: |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5179 | if (context->getMaxSupportedSamples() != 0) |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5180 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5181 | *params = renderbuffer->getSamples(); |
| 5182 | } |
| 5183 | else |
| 5184 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5185 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5186 | } |
| 5187 | break; |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5188 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5189 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5190 | } |
| 5191 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5192 | } |
| 5193 | catch(std::bad_alloc&) |
| 5194 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5195 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5196 | } |
| 5197 | } |
| 5198 | |
| 5199 | void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params) |
| 5200 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5201 | 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] | 5202 | |
| 5203 | try |
| 5204 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5205 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5206 | |
| 5207 | if (context) |
| 5208 | { |
| 5209 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 5210 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5211 | if (!shaderObject) |
| 5212 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5213 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5214 | } |
| 5215 | |
| 5216 | switch (pname) |
| 5217 | { |
| 5218 | case GL_SHADER_TYPE: |
| 5219 | *params = shaderObject->getType(); |
| 5220 | return; |
| 5221 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5222 | *params = shaderObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5223 | return; |
| 5224 | case GL_COMPILE_STATUS: |
| 5225 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; |
| 5226 | return; |
| 5227 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5228 | *params = shaderObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5229 | return; |
| 5230 | case GL_SHADER_SOURCE_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5231 | *params = shaderObject->getSourceLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5232 | return; |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5233 | case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: |
| 5234 | *params = shaderObject->getTranslatedSourceLength(); |
| 5235 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5236 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5237 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5238 | } |
| 5239 | } |
| 5240 | } |
| 5241 | catch(std::bad_alloc&) |
| 5242 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5243 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5244 | } |
| 5245 | } |
| 5246 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5247 | void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5248 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5249 | 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] | 5250 | shader, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5251 | |
| 5252 | try |
| 5253 | { |
| 5254 | if (bufsize < 0) |
| 5255 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5256 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5257 | } |
| 5258 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5259 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5260 | |
| 5261 | if (context) |
| 5262 | { |
| 5263 | gl::Shader *shaderObject = context->getShader(shader); |
| 5264 | |
| 5265 | if (!shaderObject) |
| 5266 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5267 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5268 | } |
| 5269 | |
| 5270 | shaderObject->getInfoLog(bufsize, length, infolog); |
| 5271 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5272 | } |
| 5273 | catch(std::bad_alloc&) |
| 5274 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5275 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5276 | } |
| 5277 | } |
| 5278 | |
| 5279 | void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) |
| 5280 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5281 | 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] | 5282 | shadertype, precisiontype, range, precision); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5283 | |
| 5284 | try |
| 5285 | { |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5286 | switch (shadertype) |
| 5287 | { |
| 5288 | case GL_VERTEX_SHADER: |
| 5289 | case GL_FRAGMENT_SHADER: |
| 5290 | break; |
| 5291 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5292 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5293 | } |
| 5294 | |
| 5295 | switch (precisiontype) |
| 5296 | { |
| 5297 | case GL_LOW_FLOAT: |
| 5298 | case GL_MEDIUM_FLOAT: |
| 5299 | case GL_HIGH_FLOAT: |
| 5300 | // Assume IEEE 754 precision |
| 5301 | range[0] = 127; |
| 5302 | range[1] = 127; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5303 | *precision = 23; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5304 | break; |
| 5305 | case GL_LOW_INT: |
| 5306 | case GL_MEDIUM_INT: |
| 5307 | case GL_HIGH_INT: |
| 5308 | // Some (most) hardware only supports single-precision floating-point numbers, |
| 5309 | // which can accurately represent integers up to +/-16777216 |
| 5310 | range[0] = 24; |
| 5311 | range[1] = 24; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5312 | *precision = 0; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5313 | break; |
| 5314 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5315 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5316 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5317 | } |
| 5318 | catch(std::bad_alloc&) |
| 5319 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5320 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5321 | } |
| 5322 | } |
| 5323 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5324 | void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5325 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5326 | 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] | 5327 | shader, bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5328 | |
| 5329 | try |
| 5330 | { |
| 5331 | if (bufsize < 0) |
| 5332 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5333 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5334 | } |
| 5335 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5336 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5337 | |
| 5338 | if (context) |
| 5339 | { |
| 5340 | gl::Shader *shaderObject = context->getShader(shader); |
| 5341 | |
| 5342 | if (!shaderObject) |
| 5343 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5344 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5345 | } |
| 5346 | |
| 5347 | shaderObject->getSource(bufsize, length, source); |
| 5348 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5349 | } |
| 5350 | catch(std::bad_alloc&) |
| 5351 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5352 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5353 | } |
| 5354 | } |
| 5355 | |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5356 | void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
| 5357 | { |
| 5358 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)", |
| 5359 | shader, bufsize, length, source); |
| 5360 | |
| 5361 | try |
| 5362 | { |
| 5363 | if (bufsize < 0) |
| 5364 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5365 | return gl::error(GL_INVALID_VALUE); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5366 | } |
| 5367 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5368 | gl::Context *context = gl::getNonLostContext(); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5369 | |
| 5370 | if (context) |
| 5371 | { |
| 5372 | gl::Shader *shaderObject = context->getShader(shader); |
| 5373 | |
| 5374 | if (!shaderObject) |
| 5375 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5376 | return gl::error(GL_INVALID_OPERATION); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5377 | } |
| 5378 | |
| 5379 | shaderObject->getTranslatedSource(bufsize, length, source); |
| 5380 | } |
| 5381 | } |
| 5382 | catch(std::bad_alloc&) |
| 5383 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5384 | return gl::error(GL_OUT_OF_MEMORY); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5385 | } |
| 5386 | } |
| 5387 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5388 | const GLubyte* __stdcall glGetString(GLenum name) |
| 5389 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5390 | EVENT("(GLenum name = 0x%X)", name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5391 | |
| 5392 | try |
| 5393 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5394 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3e4c600 | 2010-05-05 18:50:13 +0000 | [diff] [blame] | 5395 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5396 | switch (name) |
| 5397 | { |
| 5398 | case GL_VENDOR: |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 5399 | return (GLubyte*)"Google Inc."; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5400 | case GL_RENDERER: |
daniel@transgaming.com | c23ff64 | 2011-08-16 20:28:45 +0000 | [diff] [blame] | 5401 | return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5402 | case GL_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5403 | if (context->getClientVersion() == 2) |
| 5404 | { |
| 5405 | return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")"; |
| 5406 | } |
| 5407 | else |
| 5408 | { |
| 5409 | return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")"; |
| 5410 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5411 | case GL_SHADING_LANGUAGE_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5412 | if (context->getClientVersion() == 2) |
| 5413 | { |
| 5414 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")"; |
| 5415 | } |
| 5416 | else |
| 5417 | { |
| 5418 | return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")"; |
| 5419 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5420 | case GL_EXTENSIONS: |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 5421 | return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : ""); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5422 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5423 | return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5424 | } |
| 5425 | } |
| 5426 | catch(std::bad_alloc&) |
| 5427 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5428 | return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5429 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5430 | } |
| 5431 | |
| 5432 | void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) |
| 5433 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5434 | 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] | 5435 | |
| 5436 | try |
| 5437 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5438 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5439 | |
| 5440 | if (context) |
| 5441 | { |
| 5442 | gl::Texture *texture; |
| 5443 | |
| 5444 | switch (target) |
| 5445 | { |
| 5446 | case GL_TEXTURE_2D: |
| 5447 | texture = context->getTexture2D(); |
| 5448 | break; |
| 5449 | case GL_TEXTURE_CUBE_MAP: |
| 5450 | texture = context->getTextureCubeMap(); |
| 5451 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5452 | case GL_TEXTURE_3D: |
| 5453 | if (context->getClientVersion() < 3) |
| 5454 | { |
| 5455 | return gl::error(GL_INVALID_ENUM); |
| 5456 | } |
| 5457 | texture = context->getTexture3D(); |
| 5458 | break; |
shannonwoods@chromium.org | 0c611d1 | 2013-05-30 00:15:05 +0000 | [diff] [blame] | 5459 | case GL_TEXTURE_2D_ARRAY: |
| 5460 | if (context->getClientVersion() < 3) |
| 5461 | { |
| 5462 | return gl::error(GL_INVALID_ENUM); |
| 5463 | } |
| 5464 | texture = context->getTexture2DArray(); |
| 5465 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5466 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5467 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5468 | } |
| 5469 | |
| 5470 | switch (pname) |
| 5471 | { |
| 5472 | case GL_TEXTURE_MAG_FILTER: |
| 5473 | *params = (GLfloat)texture->getMagFilter(); |
| 5474 | break; |
| 5475 | case GL_TEXTURE_MIN_FILTER: |
| 5476 | *params = (GLfloat)texture->getMinFilter(); |
| 5477 | break; |
| 5478 | case GL_TEXTURE_WRAP_S: |
| 5479 | *params = (GLfloat)texture->getWrapS(); |
| 5480 | break; |
| 5481 | case GL_TEXTURE_WRAP_T: |
| 5482 | *params = (GLfloat)texture->getWrapT(); |
| 5483 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5484 | case GL_TEXTURE_WRAP_R: |
| 5485 | if (context->getClientVersion() < 3) |
| 5486 | { |
| 5487 | return gl::error(GL_INVALID_ENUM); |
| 5488 | } |
| 5489 | *params = (GLfloat)texture->getWrapR(); |
| 5490 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5491 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5492 | // 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] | 5493 | *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE); |
| 5494 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5495 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5496 | if (context->getClientVersion() < 3) |
| 5497 | { |
| 5498 | return gl::error(GL_INVALID_ENUM); |
| 5499 | } |
| 5500 | *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0); |
| 5501 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5502 | case GL_TEXTURE_USAGE_ANGLE: |
| 5503 | *params = (GLfloat)texture->getUsage(); |
| 5504 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5505 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5506 | if (!context->supportsTextureFilterAnisotropy()) |
| 5507 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5508 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5509 | } |
| 5510 | *params = (GLfloat)texture->getMaxAnisotropy(); |
| 5511 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5512 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5513 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5514 | } |
| 5515 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5516 | } |
| 5517 | catch(std::bad_alloc&) |
| 5518 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5519 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5520 | } |
| 5521 | } |
| 5522 | |
| 5523 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5524 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5525 | 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] | 5526 | |
| 5527 | try |
| 5528 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5529 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5530 | |
| 5531 | if (context) |
| 5532 | { |
| 5533 | gl::Texture *texture; |
| 5534 | |
| 5535 | switch (target) |
| 5536 | { |
| 5537 | case GL_TEXTURE_2D: |
| 5538 | texture = context->getTexture2D(); |
| 5539 | break; |
| 5540 | case GL_TEXTURE_CUBE_MAP: |
| 5541 | texture = context->getTextureCubeMap(); |
| 5542 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5543 | case GL_TEXTURE_3D: |
| 5544 | if (context->getClientVersion() < 3) |
| 5545 | { |
| 5546 | return gl::error(GL_INVALID_ENUM); |
| 5547 | } |
| 5548 | texture = context->getTexture3D(); |
| 5549 | break; |
shannonwoods@chromium.org | 0c611d1 | 2013-05-30 00:15:05 +0000 | [diff] [blame] | 5550 | case GL_TEXTURE_2D_ARRAY: |
| 5551 | if (context->getClientVersion() < 3) |
| 5552 | { |
| 5553 | return gl::error(GL_INVALID_ENUM); |
| 5554 | } |
| 5555 | texture = context->getTexture2DArray(); |
| 5556 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5557 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5558 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5559 | } |
| 5560 | |
| 5561 | switch (pname) |
| 5562 | { |
| 5563 | case GL_TEXTURE_MAG_FILTER: |
| 5564 | *params = texture->getMagFilter(); |
| 5565 | break; |
| 5566 | case GL_TEXTURE_MIN_FILTER: |
| 5567 | *params = texture->getMinFilter(); |
| 5568 | break; |
| 5569 | case GL_TEXTURE_WRAP_S: |
| 5570 | *params = texture->getWrapS(); |
| 5571 | break; |
| 5572 | case GL_TEXTURE_WRAP_T: |
| 5573 | *params = texture->getWrapT(); |
| 5574 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5575 | case GL_TEXTURE_WRAP_R: |
| 5576 | if (context->getClientVersion() < 3) |
| 5577 | { |
| 5578 | return gl::error(GL_INVALID_ENUM); |
| 5579 | } |
| 5580 | *params = texture->getWrapR(); |
| 5581 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5582 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5583 | // 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] | 5584 | *params = texture->isImmutable() ? GL_TRUE : GL_FALSE; |
| 5585 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5586 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5587 | if (context->getClientVersion() < 3) |
| 5588 | { |
| 5589 | return gl::error(GL_INVALID_ENUM); |
| 5590 | } |
| 5591 | *params = texture->isImmutable() ? texture->levelCount() : 0; |
| 5592 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5593 | case GL_TEXTURE_USAGE_ANGLE: |
| 5594 | *params = texture->getUsage(); |
| 5595 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5596 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5597 | if (!context->supportsTextureFilterAnisotropy()) |
| 5598 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5599 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5600 | } |
| 5601 | *params = (GLint)texture->getMaxAnisotropy(); |
| 5602 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 5603 | |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5604 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5605 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5606 | } |
| 5607 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5608 | } |
| 5609 | catch(std::bad_alloc&) |
| 5610 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5611 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5612 | } |
| 5613 | } |
| 5614 | |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5615 | void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
| 5616 | { |
| 5617 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)", |
| 5618 | program, location, bufSize, params); |
| 5619 | |
| 5620 | try |
| 5621 | { |
| 5622 | if (bufSize < 0) |
| 5623 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5624 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5625 | } |
| 5626 | |
| 5627 | gl::Context *context = gl::getNonLostContext(); |
| 5628 | |
| 5629 | if (context) |
| 5630 | { |
| 5631 | if (program == 0) |
| 5632 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5633 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5634 | } |
| 5635 | |
| 5636 | gl::Program *programObject = context->getProgram(program); |
| 5637 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5638 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5639 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5640 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5641 | } |
| 5642 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5643 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5644 | if (!programBinary) |
| 5645 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5646 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5647 | } |
| 5648 | |
| 5649 | if (!programBinary->getUniformfv(location, &bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5650 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5651 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5652 | } |
| 5653 | } |
| 5654 | } |
| 5655 | catch(std::bad_alloc&) |
| 5656 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5657 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5658 | } |
| 5659 | } |
| 5660 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5661 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 5662 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5663 | 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] | 5664 | |
| 5665 | try |
| 5666 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5667 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5668 | |
| 5669 | if (context) |
| 5670 | { |
| 5671 | if (program == 0) |
| 5672 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5673 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5674 | } |
| 5675 | |
| 5676 | gl::Program *programObject = context->getProgram(program); |
| 5677 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5678 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5679 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5680 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5681 | } |
| 5682 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5683 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5684 | if (!programBinary) |
| 5685 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5686 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5687 | } |
| 5688 | |
| 5689 | if (!programBinary->getUniformfv(location, NULL, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5690 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5691 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5692 | } |
| 5693 | } |
| 5694 | } |
| 5695 | catch(std::bad_alloc&) |
| 5696 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5697 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5698 | } |
| 5699 | } |
| 5700 | |
| 5701 | void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) |
| 5702 | { |
| 5703 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)", |
| 5704 | program, location, bufSize, params); |
| 5705 | |
| 5706 | try |
| 5707 | { |
| 5708 | if (bufSize < 0) |
| 5709 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5710 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5711 | } |
| 5712 | |
| 5713 | gl::Context *context = gl::getNonLostContext(); |
| 5714 | |
| 5715 | if (context) |
| 5716 | { |
| 5717 | if (program == 0) |
| 5718 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5719 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5720 | } |
| 5721 | |
| 5722 | gl::Program *programObject = context->getProgram(program); |
| 5723 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5724 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5725 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5726 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5727 | } |
| 5728 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5729 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5730 | if (!programBinary) |
| 5731 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5732 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5733 | } |
| 5734 | |
| 5735 | if (!programBinary->getUniformiv(location, &bufSize, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5736 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5737 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5738 | } |
| 5739 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5740 | } |
| 5741 | catch(std::bad_alloc&) |
| 5742 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5743 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5744 | } |
| 5745 | } |
| 5746 | |
| 5747 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 5748 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5749 | 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] | 5750 | |
| 5751 | try |
| 5752 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5753 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5754 | |
| 5755 | if (context) |
| 5756 | { |
| 5757 | if (program == 0) |
| 5758 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5759 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5760 | } |
| 5761 | |
| 5762 | gl::Program *programObject = context->getProgram(program); |
| 5763 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5764 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5765 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5766 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5767 | } |
| 5768 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5769 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5770 | if (!programBinary) |
| 5771 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5772 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5773 | } |
| 5774 | |
| 5775 | if (!programBinary->getUniformiv(location, NULL, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5776 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5777 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5778 | } |
| 5779 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5780 | } |
| 5781 | catch(std::bad_alloc&) |
| 5782 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5783 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5784 | } |
| 5785 | } |
| 5786 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5787 | int __stdcall glGetUniformLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5788 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5789 | 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] | 5790 | |
| 5791 | try |
| 5792 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5793 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5794 | |
| 5795 | if (strstr(name, "gl_") == name) |
| 5796 | { |
| 5797 | return -1; |
| 5798 | } |
| 5799 | |
| 5800 | if (context) |
| 5801 | { |
| 5802 | gl::Program *programObject = context->getProgram(program); |
| 5803 | |
| 5804 | if (!programObject) |
| 5805 | { |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5806 | if (context->getShader(program)) |
| 5807 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5808 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5809 | } |
| 5810 | else |
| 5811 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5812 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5813 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5814 | } |
| 5815 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5816 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5817 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5818 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5819 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5820 | } |
| 5821 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5822 | return programBinary->getUniformLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5823 | } |
| 5824 | } |
| 5825 | catch(std::bad_alloc&) |
| 5826 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5827 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5828 | } |
| 5829 | |
| 5830 | return -1; |
| 5831 | } |
| 5832 | |
| 5833 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 5834 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5835 | 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] | 5836 | |
| 5837 | try |
| 5838 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5839 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5840 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5841 | if (context) |
| 5842 | { |
| 5843 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5844 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5845 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5846 | } |
| 5847 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5848 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5849 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5850 | switch (pname) |
| 5851 | { |
| 5852 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5853 | *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5854 | break; |
| 5855 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5856 | *params = (GLfloat)attribState.mSize; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5857 | break; |
| 5858 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5859 | *params = (GLfloat)attribState.mStride; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5860 | break; |
| 5861 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5862 | *params = (GLfloat)attribState.mType; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5863 | break; |
| 5864 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5865 | *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5866 | break; |
| 5867 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 5868 | *params = (GLfloat)attribState.mBoundBuffer.id(); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5869 | break; |
| 5870 | case GL_CURRENT_VERTEX_ATTRIB: |
| 5871 | for (int i = 0; i < 4; ++i) |
| 5872 | { |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame] | 5873 | params[i] = attribState.mCurrentValue.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5874 | } |
| 5875 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 5876 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 5877 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 5878 | // the same constant. |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 5879 | *params = (GLfloat)attribState.mDivisor; |
| 5880 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5881 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5882 | } |
| 5883 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5884 | } |
| 5885 | catch(std::bad_alloc&) |
| 5886 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5887 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5888 | } |
| 5889 | } |
| 5890 | |
| 5891 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 5892 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5893 | 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] | 5894 | |
| 5895 | try |
| 5896 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5897 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5898 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5899 | if (context) |
| 5900 | { |
| 5901 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5902 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5903 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5904 | } |
| 5905 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5906 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5907 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5908 | switch (pname) |
| 5909 | { |
| 5910 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5911 | *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5912 | break; |
| 5913 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5914 | *params = attribState.mSize; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5915 | break; |
| 5916 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5917 | *params = attribState.mStride; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5918 | break; |
| 5919 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5920 | *params = attribState.mType; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5921 | break; |
| 5922 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5923 | *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5924 | break; |
| 5925 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 5926 | *params = attribState.mBoundBuffer.id(); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5927 | break; |
| 5928 | case GL_CURRENT_VERTEX_ATTRIB: |
| 5929 | for (int i = 0; i < 4; ++i) |
| 5930 | { |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame] | 5931 | float currentValue = attribState.mCurrentValue.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5932 | params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f)); |
| 5933 | } |
| 5934 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 5935 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 5936 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 5937 | // the same constant. |
| 5938 | 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] | 5939 | *params = (GLint)attribState.mDivisor; |
| 5940 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5941 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5942 | } |
| 5943 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5944 | } |
| 5945 | catch(std::bad_alloc&) |
| 5946 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5947 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5948 | } |
| 5949 | } |
| 5950 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5951 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5952 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5953 | 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] | 5954 | |
| 5955 | try |
| 5956 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5957 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5958 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5959 | if (context) |
| 5960 | { |
| 5961 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5962 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5963 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5964 | } |
| 5965 | |
| 5966 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) |
| 5967 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5968 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5969 | } |
| 5970 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5971 | *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index)); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5972 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5973 | } |
| 5974 | catch(std::bad_alloc&) |
| 5975 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5976 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5977 | } |
| 5978 | } |
| 5979 | |
| 5980 | void __stdcall glHint(GLenum target, GLenum mode) |
| 5981 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5982 | EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5983 | |
| 5984 | try |
| 5985 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5986 | switch (mode) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5987 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5988 | case GL_FASTEST: |
| 5989 | case GL_NICEST: |
| 5990 | case GL_DONT_CARE: |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5991 | break; |
| 5992 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5993 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5994 | } |
| 5995 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5996 | gl::Context *context = gl::getNonLostContext(); |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5997 | switch (target) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5998 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5999 | case GL_GENERATE_MIPMAP_HINT: |
| 6000 | if (context) context->setGenerateMipmapHint(mode); |
| 6001 | break; |
| 6002 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 6003 | if (context) context->setFragmentShaderDerivativeHint(mode); |
| 6004 | break; |
| 6005 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6006 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6007 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6008 | } |
| 6009 | catch(std::bad_alloc&) |
| 6010 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6011 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6012 | } |
| 6013 | } |
| 6014 | |
| 6015 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 6016 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6017 | EVENT("(GLuint buffer = %d)", buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6018 | |
| 6019 | try |
| 6020 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6021 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6022 | |
| 6023 | if (context && buffer) |
| 6024 | { |
| 6025 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 6026 | |
| 6027 | if (bufferObject) |
| 6028 | { |
| 6029 | return GL_TRUE; |
| 6030 | } |
| 6031 | } |
| 6032 | } |
| 6033 | catch(std::bad_alloc&) |
| 6034 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6035 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6036 | } |
| 6037 | |
| 6038 | return GL_FALSE; |
| 6039 | } |
| 6040 | |
| 6041 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 6042 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6043 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6044 | |
| 6045 | try |
| 6046 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6047 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6048 | |
| 6049 | if (context) |
| 6050 | { |
| 6051 | switch (cap) |
| 6052 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6053 | case GL_CULL_FACE: return context->isCullFaceEnabled(); |
| 6054 | case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled(); |
| 6055 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled(); |
| 6056 | case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled(); |
| 6057 | case GL_SCISSOR_TEST: return context->isScissorTestEnabled(); |
| 6058 | case GL_STENCIL_TEST: return context->isStencilTestEnabled(); |
| 6059 | case GL_DEPTH_TEST: return context->isDepthTestEnabled(); |
| 6060 | case GL_BLEND: return context->isBlendEnabled(); |
| 6061 | case GL_DITHER: return context->isDitherEnabled(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6062 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6063 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6064 | } |
| 6065 | } |
| 6066 | } |
| 6067 | catch(std::bad_alloc&) |
| 6068 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6069 | return gl::error(GL_OUT_OF_MEMORY, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6070 | } |
| 6071 | |
| 6072 | return false; |
| 6073 | } |
| 6074 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6075 | GLboolean __stdcall glIsFenceNV(GLuint fence) |
| 6076 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6077 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6078 | |
| 6079 | try |
| 6080 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6081 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6082 | |
| 6083 | if (context) |
| 6084 | { |
| 6085 | gl::Fence *fenceObject = context->getFence(fence); |
| 6086 | |
| 6087 | if (fenceObject == NULL) |
| 6088 | { |
| 6089 | return GL_FALSE; |
| 6090 | } |
| 6091 | |
| 6092 | return fenceObject->isFence(); |
| 6093 | } |
| 6094 | } |
| 6095 | catch(std::bad_alloc&) |
| 6096 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6097 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6098 | } |
| 6099 | |
| 6100 | return GL_FALSE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6101 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6102 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6103 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 6104 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6105 | EVENT("(GLuint framebuffer = %d)", framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6106 | |
| 6107 | try |
| 6108 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6109 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6110 | |
| 6111 | if (context && framebuffer) |
| 6112 | { |
| 6113 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 6114 | |
| 6115 | if (framebufferObject) |
| 6116 | { |
| 6117 | return GL_TRUE; |
| 6118 | } |
| 6119 | } |
| 6120 | } |
| 6121 | catch(std::bad_alloc&) |
| 6122 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6123 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6124 | } |
| 6125 | |
| 6126 | return GL_FALSE; |
| 6127 | } |
| 6128 | |
| 6129 | GLboolean __stdcall glIsProgram(GLuint program) |
| 6130 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6131 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6132 | |
| 6133 | try |
| 6134 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6135 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6136 | |
| 6137 | if (context && program) |
| 6138 | { |
| 6139 | gl::Program *programObject = context->getProgram(program); |
| 6140 | |
| 6141 | if (programObject) |
| 6142 | { |
| 6143 | return GL_TRUE; |
| 6144 | } |
| 6145 | } |
| 6146 | } |
| 6147 | catch(std::bad_alloc&) |
| 6148 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6149 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6150 | } |
| 6151 | |
| 6152 | return GL_FALSE; |
| 6153 | } |
| 6154 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 6155 | GLboolean __stdcall glIsQueryEXT(GLuint id) |
| 6156 | { |
| 6157 | EVENT("(GLuint id = %d)", id); |
| 6158 | |
| 6159 | try |
| 6160 | { |
| 6161 | if (id == 0) |
| 6162 | { |
| 6163 | return GL_FALSE; |
| 6164 | } |
| 6165 | |
| 6166 | gl::Context *context = gl::getNonLostContext(); |
| 6167 | |
| 6168 | if (context) |
| 6169 | { |
| 6170 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 6171 | |
| 6172 | if (queryObject) |
| 6173 | { |
| 6174 | return GL_TRUE; |
| 6175 | } |
| 6176 | } |
| 6177 | } |
| 6178 | catch(std::bad_alloc&) |
| 6179 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6180 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 6181 | } |
| 6182 | |
| 6183 | return GL_FALSE; |
| 6184 | } |
| 6185 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6186 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 6187 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6188 | EVENT("(GLuint renderbuffer = %d)", renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6189 | |
| 6190 | try |
| 6191 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6192 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6193 | |
| 6194 | if (context && renderbuffer) |
| 6195 | { |
| 6196 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 6197 | |
| 6198 | if (renderbufferObject) |
| 6199 | { |
| 6200 | return GL_TRUE; |
| 6201 | } |
| 6202 | } |
| 6203 | } |
| 6204 | catch(std::bad_alloc&) |
| 6205 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6206 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6207 | } |
| 6208 | |
| 6209 | return GL_FALSE; |
| 6210 | } |
| 6211 | |
| 6212 | GLboolean __stdcall glIsShader(GLuint shader) |
| 6213 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6214 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6215 | |
| 6216 | try |
| 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 && shader) |
| 6221 | { |
| 6222 | gl::Shader *shaderObject = context->getShader(shader); |
| 6223 | |
| 6224 | if (shaderObject) |
| 6225 | { |
| 6226 | return GL_TRUE; |
| 6227 | } |
| 6228 | } |
| 6229 | } |
| 6230 | catch(std::bad_alloc&) |
| 6231 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6232 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6233 | } |
| 6234 | |
| 6235 | return GL_FALSE; |
| 6236 | } |
| 6237 | |
| 6238 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 6239 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6240 | EVENT("(GLuint texture = %d)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6241 | |
| 6242 | try |
| 6243 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6244 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6245 | |
| 6246 | if (context && texture) |
| 6247 | { |
| 6248 | gl::Texture *textureObject = context->getTexture(texture); |
| 6249 | |
| 6250 | if (textureObject) |
| 6251 | { |
| 6252 | return GL_TRUE; |
| 6253 | } |
| 6254 | } |
| 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, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6259 | } |
| 6260 | |
| 6261 | return GL_FALSE; |
| 6262 | } |
| 6263 | |
| 6264 | void __stdcall glLineWidth(GLfloat width) |
| 6265 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6266 | EVENT("(GLfloat width = %f)", width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6267 | |
| 6268 | try |
| 6269 | { |
| 6270 | if (width <= 0.0f) |
| 6271 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6272 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6273 | } |
| 6274 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6275 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 6276 | |
| 6277 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6278 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6279 | context->setLineWidth(width); |
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 | |
| 6288 | void __stdcall glLinkProgram(GLuint program) |
| 6289 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6290 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6291 | |
| 6292 | try |
| 6293 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6294 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6295 | |
| 6296 | if (context) |
| 6297 | { |
| 6298 | gl::Program *programObject = context->getProgram(program); |
| 6299 | |
| 6300 | if (!programObject) |
| 6301 | { |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6302 | if (context->getShader(program)) |
| 6303 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6304 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6305 | } |
| 6306 | else |
| 6307 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6308 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6309 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6310 | } |
| 6311 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 6312 | context->linkProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6313 | } |
| 6314 | } |
| 6315 | catch(std::bad_alloc&) |
| 6316 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6317 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6318 | } |
| 6319 | } |
| 6320 | |
| 6321 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 6322 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6323 | EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6324 | |
| 6325 | try |
| 6326 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6327 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6328 | |
| 6329 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6330 | { |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6331 | switch (pname) |
| 6332 | { |
| 6333 | case GL_UNPACK_ALIGNMENT: |
| 6334 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6335 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6336 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6337 | } |
| 6338 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6339 | context->setUnpackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6340 | break; |
| 6341 | |
| 6342 | case GL_PACK_ALIGNMENT: |
| 6343 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6344 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6345 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6346 | } |
| 6347 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6348 | context->setPackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6349 | break; |
| 6350 | |
bsalomon@google.com | 56d46ab | 2011-11-23 14:53:10 +0000 | [diff] [blame] | 6351 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 6352 | context->setPackReverseRowOrder(param != 0); |
| 6353 | break; |
| 6354 | |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6355 | case GL_UNPACK_IMAGE_HEIGHT: |
| 6356 | case GL_UNPACK_SKIP_IMAGES: |
| 6357 | case GL_UNPACK_ROW_LENGTH: |
| 6358 | case GL_UNPACK_SKIP_ROWS: |
| 6359 | case GL_UNPACK_SKIP_PIXELS: |
| 6360 | case GL_PACK_ROW_LENGTH: |
| 6361 | case GL_PACK_SKIP_ROWS: |
| 6362 | case GL_PACK_SKIP_PIXELS: |
| 6363 | if (context->getClientVersion() < 3) |
| 6364 | { |
| 6365 | return gl::error(GL_INVALID_ENUM); |
| 6366 | } |
| 6367 | UNIMPLEMENTED(); |
| 6368 | break; |
| 6369 | |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6370 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6371 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6372 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6373 | } |
| 6374 | } |
| 6375 | catch(std::bad_alloc&) |
| 6376 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6377 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6378 | } |
| 6379 | } |
| 6380 | |
| 6381 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 6382 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6383 | EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6384 | |
| 6385 | try |
| 6386 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6387 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aede630 | 2010-04-29 03:35:48 +0000 | [diff] [blame] | 6388 | |
| 6389 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6390 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6391 | context->setPolygonOffsetParams(factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6392 | } |
| 6393 | } |
| 6394 | catch(std::bad_alloc&) |
| 6395 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6396 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6397 | } |
| 6398 | } |
| 6399 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6400 | void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6401 | GLenum format, GLenum type, GLsizei bufSize, |
| 6402 | GLvoid *data) |
| 6403 | { |
| 6404 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
| 6405 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)", |
| 6406 | x, y, width, height, format, type, bufSize, data); |
| 6407 | |
| 6408 | try |
| 6409 | { |
| 6410 | if (width < 0 || height < 0 || bufSize < 0) |
| 6411 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6412 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6413 | } |
| 6414 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6415 | gl::Context *context = gl::getNonLostContext(); |
| 6416 | |
| 6417 | if (context) |
| 6418 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6419 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6420 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6421 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6422 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6423 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6424 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6425 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6426 | return; |
| 6427 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6428 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6429 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6430 | |
| 6431 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6432 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6433 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6434 | } |
| 6435 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6436 | context->readPixels(x, y, width, height, format, type, &bufSize, data); |
| 6437 | } |
| 6438 | } |
| 6439 | catch(std::bad_alloc&) |
| 6440 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6441 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6442 | } |
| 6443 | } |
| 6444 | |
| 6445 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6446 | GLenum format, GLenum type, GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6447 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6448 | 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] | 6449 | "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] | 6450 | x, y, width, height, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6451 | |
| 6452 | try |
| 6453 | { |
| 6454 | if (width < 0 || height < 0) |
| 6455 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6456 | return gl::error(GL_INVALID_VALUE); |
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 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6463 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6464 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6465 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6466 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6467 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6468 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6469 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6470 | return; |
| 6471 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6472 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6473 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6474 | |
| 6475 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6476 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6477 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6478 | } |
| 6479 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6480 | context->readPixels(x, y, width, height, format, type, NULL, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6481 | } |
| 6482 | } |
| 6483 | catch(std::bad_alloc&) |
| 6484 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6485 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6486 | } |
| 6487 | } |
| 6488 | |
| 6489 | void __stdcall glReleaseShaderCompiler(void) |
| 6490 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6491 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6492 | |
| 6493 | try |
| 6494 | { |
| 6495 | gl::Shader::releaseCompiler(); |
| 6496 | } |
| 6497 | catch(std::bad_alloc&) |
| 6498 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6499 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6500 | } |
| 6501 | } |
| 6502 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6503 | 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] | 6504 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6505 | 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] | 6506 | target, samples, internalformat, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6507 | |
| 6508 | try |
| 6509 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6510 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6511 | |
| 6512 | if (context) |
| 6513 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6514 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 6515 | width, height, true)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6516 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6517 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6518 | } |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 6519 | |
| 6520 | context->setRenderbufferStorage(width, height, internalformat, samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6521 | } |
| 6522 | } |
| 6523 | catch(std::bad_alloc&) |
| 6524 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6525 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6526 | } |
| 6527 | } |
| 6528 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6529 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 6530 | { |
| 6531 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height); |
| 6532 | } |
| 6533 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6534 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 6535 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6536 | EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6537 | |
| 6538 | try |
| 6539 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6540 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6541 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6542 | if (context) |
| 6543 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 6544 | context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6545 | } |
| 6546 | } |
| 6547 | catch(std::bad_alloc&) |
| 6548 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6549 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6550 | } |
| 6551 | } |
| 6552 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6553 | void __stdcall glSetFenceNV(GLuint fence, GLenum condition) |
| 6554 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6555 | EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6556 | |
| 6557 | try |
| 6558 | { |
| 6559 | if (condition != GL_ALL_COMPLETED_NV) |
| 6560 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6561 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6562 | } |
| 6563 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6564 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6565 | |
| 6566 | if (context) |
| 6567 | { |
| 6568 | gl::Fence *fenceObject = context->getFence(fence); |
| 6569 | |
| 6570 | if (fenceObject == NULL) |
| 6571 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6572 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6573 | } |
| 6574 | |
| 6575 | fenceObject->setFence(condition); |
| 6576 | } |
| 6577 | } |
| 6578 | catch(std::bad_alloc&) |
| 6579 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6580 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6581 | } |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6582 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6583 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6584 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 6585 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6586 | 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] | 6587 | |
| 6588 | try |
| 6589 | { |
| 6590 | if (width < 0 || height < 0) |
| 6591 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6592 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6593 | } |
| 6594 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6595 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6596 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6597 | if (context) |
| 6598 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6599 | context->setScissorParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6600 | } |
| 6601 | } |
| 6602 | catch(std::bad_alloc&) |
| 6603 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6604 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6605 | } |
| 6606 | } |
| 6607 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6608 | 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] | 6609 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6610 | 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] | 6611 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 6612 | n, shaders, binaryformat, binary, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6613 | |
| 6614 | try |
| 6615 | { |
daniel@transgaming.com | d1f667f | 2010-04-29 03:38:52 +0000 | [diff] [blame] | 6616 | // No binary shader formats are supported. |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6617 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6618 | } |
| 6619 | catch(std::bad_alloc&) |
| 6620 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6621 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6622 | } |
| 6623 | } |
| 6624 | |
shannon.woods%transgaming.com@gtempaccount.com | 5f33933 | 2013-04-13 03:29:02 +0000 | [diff] [blame] | 6625 | 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] | 6626 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6627 | 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] | 6628 | shader, count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6629 | |
| 6630 | try |
| 6631 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6632 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6633 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6634 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6635 | } |
| 6636 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6637 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6638 | |
| 6639 | if (context) |
| 6640 | { |
| 6641 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6642 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6643 | if (!shaderObject) |
| 6644 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6645 | if (context->getProgram(shader)) |
| 6646 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6647 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6648 | } |
| 6649 | else |
| 6650 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6651 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6652 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6653 | } |
| 6654 | |
| 6655 | shaderObject->setSource(count, string, length); |
| 6656 | } |
| 6657 | } |
| 6658 | catch(std::bad_alloc&) |
| 6659 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6660 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6661 | } |
| 6662 | } |
| 6663 | |
| 6664 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 6665 | { |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6666 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6667 | } |
| 6668 | |
| 6669 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 6670 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6671 | 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] | 6672 | |
| 6673 | try |
| 6674 | { |
| 6675 | switch (face) |
| 6676 | { |
| 6677 | case GL_FRONT: |
| 6678 | case GL_BACK: |
| 6679 | case GL_FRONT_AND_BACK: |
| 6680 | break; |
| 6681 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6682 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6683 | } |
| 6684 | |
| 6685 | switch (func) |
| 6686 | { |
| 6687 | case GL_NEVER: |
| 6688 | case GL_ALWAYS: |
| 6689 | case GL_LESS: |
| 6690 | case GL_LEQUAL: |
| 6691 | case GL_EQUAL: |
| 6692 | case GL_GEQUAL: |
| 6693 | case GL_GREATER: |
| 6694 | case GL_NOTEQUAL: |
| 6695 | break; |
| 6696 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6697 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6698 | } |
| 6699 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6700 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6701 | |
| 6702 | if (context) |
| 6703 | { |
| 6704 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6705 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6706 | context->setStencilParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6707 | } |
| 6708 | |
| 6709 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6710 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6711 | context->setStencilBackParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6712 | } |
| 6713 | } |
| 6714 | } |
| 6715 | catch(std::bad_alloc&) |
| 6716 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6717 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6718 | } |
| 6719 | } |
| 6720 | |
| 6721 | void __stdcall glStencilMask(GLuint mask) |
| 6722 | { |
| 6723 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 6724 | } |
| 6725 | |
| 6726 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 6727 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6728 | EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6729 | |
| 6730 | try |
| 6731 | { |
| 6732 | switch (face) |
| 6733 | { |
| 6734 | case GL_FRONT: |
| 6735 | case GL_BACK: |
| 6736 | case GL_FRONT_AND_BACK: |
| 6737 | break; |
| 6738 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6739 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6740 | } |
| 6741 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6742 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6743 | |
| 6744 | if (context) |
| 6745 | { |
| 6746 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6747 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6748 | context->setStencilWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6749 | } |
| 6750 | |
| 6751 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6752 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6753 | context->setStencilBackWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6754 | } |
| 6755 | } |
| 6756 | } |
| 6757 | catch(std::bad_alloc&) |
| 6758 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6759 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6760 | } |
| 6761 | } |
| 6762 | |
| 6763 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 6764 | { |
| 6765 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 6766 | } |
| 6767 | |
| 6768 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 6769 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6770 | 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] | 6771 | face, fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6772 | |
| 6773 | try |
| 6774 | { |
| 6775 | switch (face) |
| 6776 | { |
| 6777 | case GL_FRONT: |
| 6778 | case GL_BACK: |
| 6779 | case GL_FRONT_AND_BACK: |
| 6780 | break; |
| 6781 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6782 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6783 | } |
| 6784 | |
| 6785 | switch (fail) |
| 6786 | { |
| 6787 | case GL_ZERO: |
| 6788 | case GL_KEEP: |
| 6789 | case GL_REPLACE: |
| 6790 | case GL_INCR: |
| 6791 | case GL_DECR: |
| 6792 | case GL_INVERT: |
| 6793 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6794 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6795 | break; |
| 6796 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6797 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6798 | } |
| 6799 | |
| 6800 | switch (zfail) |
| 6801 | { |
| 6802 | case GL_ZERO: |
| 6803 | case GL_KEEP: |
| 6804 | case GL_REPLACE: |
| 6805 | case GL_INCR: |
| 6806 | case GL_DECR: |
| 6807 | case GL_INVERT: |
| 6808 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6809 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6810 | break; |
| 6811 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6812 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6813 | } |
| 6814 | |
| 6815 | switch (zpass) |
| 6816 | { |
| 6817 | case GL_ZERO: |
| 6818 | case GL_KEEP: |
| 6819 | case GL_REPLACE: |
| 6820 | case GL_INCR: |
| 6821 | case GL_DECR: |
| 6822 | case GL_INVERT: |
| 6823 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6824 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6825 | break; |
| 6826 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6827 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6828 | } |
| 6829 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6830 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6831 | |
| 6832 | if (context) |
| 6833 | { |
| 6834 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6835 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6836 | context->setStencilOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6837 | } |
| 6838 | |
| 6839 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6840 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6841 | context->setStencilBackOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6842 | } |
| 6843 | } |
| 6844 | } |
| 6845 | catch(std::bad_alloc&) |
| 6846 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6847 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6848 | } |
| 6849 | } |
| 6850 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6851 | GLboolean __stdcall glTestFenceNV(GLuint fence) |
| 6852 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6853 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6854 | |
| 6855 | try |
| 6856 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6857 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6858 | |
| 6859 | if (context) |
| 6860 | { |
| 6861 | gl::Fence *fenceObject = context->getFence(fence); |
| 6862 | |
| 6863 | if (fenceObject == NULL) |
| 6864 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6865 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6866 | } |
| 6867 | |
| 6868 | return fenceObject->testFence(); |
| 6869 | } |
| 6870 | } |
| 6871 | catch(std::bad_alloc&) |
| 6872 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6873 | gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6874 | } |
| 6875 | |
| 6876 | return GL_TRUE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6877 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6878 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6879 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, |
| 6880 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6881 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6882 | 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] | 6883 | "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] | 6884 | target, level, internalformat, width, height, border, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6885 | |
| 6886 | try |
| 6887 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6888 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6889 | |
| 6890 | if (context) |
| 6891 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6892 | if (context->getClientVersion() < 3 && |
| 6893 | !validateES2TexImageParameters(context, target, level, internalformat, false, false, |
| 6894 | 0, 0, width, height, border, format, type, pixels)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 6895 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6896 | return; |
| 6897 | } |
| 6898 | |
| 6899 | if (context->getClientVersion() >= 3 && |
| 6900 | !validateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 6901 | 0, 0, 0, width, height, 1, border, format, type)) |
| 6902 | { |
| 6903 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 6904 | } |
| 6905 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6906 | switch (target) |
| 6907 | { |
| 6908 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6909 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6910 | gl::Texture2D *texture = context->getTexture2D(); |
| 6911 | texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6912 | } |
| 6913 | break; |
| 6914 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6915 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6916 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 6917 | texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6918 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6919 | break; |
| 6920 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 6921 | { |
| 6922 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6923 | texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6924 | } |
| 6925 | break; |
| 6926 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 6927 | { |
| 6928 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6929 | texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6930 | } |
| 6931 | break; |
| 6932 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 6933 | { |
| 6934 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6935 | texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6936 | } |
| 6937 | break; |
| 6938 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 6939 | { |
| 6940 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6941 | texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6942 | } |
| 6943 | break; |
| 6944 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 6945 | { |
| 6946 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6947 | texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6948 | } |
| 6949 | break; |
| 6950 | default: UNREACHABLE(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6951 | } |
| 6952 | } |
| 6953 | } |
| 6954 | catch(std::bad_alloc&) |
| 6955 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6956 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6957 | } |
| 6958 | } |
| 6959 | |
| 6960 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 6961 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6962 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param); |
| 6963 | |
| 6964 | try |
| 6965 | { |
| 6966 | gl::Context *context = gl::getNonLostContext(); |
| 6967 | |
| 6968 | if (context) |
| 6969 | { |
| 6970 | gl::Texture *texture; |
| 6971 | |
| 6972 | switch (target) |
| 6973 | { |
| 6974 | case GL_TEXTURE_2D: |
| 6975 | texture = context->getTexture2D(); |
| 6976 | break; |
| 6977 | case GL_TEXTURE_CUBE_MAP: |
| 6978 | texture = context->getTextureCubeMap(); |
| 6979 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 6980 | case GL_TEXTURE_3D: |
| 6981 | if (context->getClientVersion() < 3) |
| 6982 | { |
| 6983 | return gl::error(GL_INVALID_ENUM); |
| 6984 | } |
| 6985 | texture = context->getTexture3D(); |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 6986 | case GL_TEXTURE_2D_ARRAY: |
| 6987 | if (context->getClientVersion() < 3) |
| 6988 | { |
| 6989 | return gl::error(GL_INVALID_ENUM); |
| 6990 | } |
| 6991 | texture = context->getTexture2DArray(); |
| 6992 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6993 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6994 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6995 | } |
| 6996 | |
| 6997 | switch (pname) |
| 6998 | { |
| 6999 | case GL_TEXTURE_WRAP_S: |
| 7000 | if (!texture->setWrapS((GLenum)param)) |
| 7001 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7002 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7003 | } |
| 7004 | break; |
| 7005 | case GL_TEXTURE_WRAP_T: |
| 7006 | if (!texture->setWrapT((GLenum)param)) |
| 7007 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7008 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7009 | } |
| 7010 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 7011 | case GL_TEXTURE_WRAP_R: |
| 7012 | if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param)) |
| 7013 | { |
| 7014 | return gl::error(GL_INVALID_ENUM); |
| 7015 | } |
| 7016 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7017 | case GL_TEXTURE_MIN_FILTER: |
| 7018 | if (!texture->setMinFilter((GLenum)param)) |
| 7019 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7020 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7021 | } |
| 7022 | break; |
| 7023 | case GL_TEXTURE_MAG_FILTER: |
| 7024 | if (!texture->setMagFilter((GLenum)param)) |
| 7025 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7026 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7027 | } |
| 7028 | break; |
| 7029 | case GL_TEXTURE_USAGE_ANGLE: |
| 7030 | if (!texture->setUsage((GLenum)param)) |
| 7031 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7032 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7033 | } |
| 7034 | break; |
| 7035 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 7036 | if (!context->supportsTextureFilterAnisotropy()) |
| 7037 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7038 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7039 | } |
| 7040 | if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy())) |
| 7041 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7042 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7043 | } |
| 7044 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7045 | |
| 7046 | case GL_TEXTURE_MIN_LOD: |
| 7047 | case GL_TEXTURE_MAX_LOD: |
| 7048 | if (context->getClientVersion() < 3) |
| 7049 | { |
| 7050 | return gl::error(GL_INVALID_ENUM); |
| 7051 | } |
| 7052 | UNIMPLEMENTED(); |
| 7053 | break; |
| 7054 | |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7055 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7056 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7057 | } |
| 7058 | } |
| 7059 | } |
| 7060 | catch(std::bad_alloc&) |
| 7061 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7062 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7063 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7064 | } |
| 7065 | |
| 7066 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 7067 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7068 | glTexParameterf(target, pname, (GLfloat)*params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7069 | } |
| 7070 | |
| 7071 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 7072 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7073 | 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] | 7074 | |
| 7075 | try |
| 7076 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7077 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7078 | |
| 7079 | if (context) |
| 7080 | { |
| 7081 | gl::Texture *texture; |
| 7082 | |
| 7083 | switch (target) |
| 7084 | { |
| 7085 | case GL_TEXTURE_2D: |
| 7086 | texture = context->getTexture2D(); |
| 7087 | break; |
| 7088 | case GL_TEXTURE_CUBE_MAP: |
| 7089 | texture = context->getTextureCubeMap(); |
| 7090 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 7091 | case GL_TEXTURE_3D: |
| 7092 | if (context->getClientVersion() < 3) |
| 7093 | { |
| 7094 | return gl::error(GL_INVALID_ENUM); |
| 7095 | } |
| 7096 | texture = context->getTexture3D(); |
| 7097 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 7098 | case GL_TEXTURE_2D_ARRAY: |
| 7099 | if (context->getClientVersion() < 3) |
| 7100 | { |
| 7101 | return gl::error(GL_INVALID_ENUM); |
| 7102 | } |
| 7103 | texture = context->getTexture2DArray(); |
| 7104 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7105 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7106 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7107 | } |
| 7108 | |
| 7109 | switch (pname) |
| 7110 | { |
| 7111 | case GL_TEXTURE_WRAP_S: |
| 7112 | if (!texture->setWrapS((GLenum)param)) |
| 7113 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7114 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7115 | } |
| 7116 | break; |
| 7117 | case GL_TEXTURE_WRAP_T: |
| 7118 | if (!texture->setWrapT((GLenum)param)) |
| 7119 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7120 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7121 | } |
| 7122 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 7123 | case GL_TEXTURE_WRAP_R: |
| 7124 | if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param)) |
| 7125 | { |
| 7126 | return gl::error(GL_INVALID_ENUM); |
| 7127 | } |
| 7128 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7129 | case GL_TEXTURE_MIN_FILTER: |
| 7130 | if (!texture->setMinFilter((GLenum)param)) |
| 7131 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7132 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7133 | } |
| 7134 | break; |
| 7135 | case GL_TEXTURE_MAG_FILTER: |
| 7136 | if (!texture->setMagFilter((GLenum)param)) |
| 7137 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7138 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7139 | } |
| 7140 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 7141 | case GL_TEXTURE_USAGE_ANGLE: |
| 7142 | if (!texture->setUsage((GLenum)param)) |
| 7143 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7144 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 7145 | } |
| 7146 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7147 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 7148 | if (!context->supportsTextureFilterAnisotropy()) |
| 7149 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7150 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7151 | } |
| 7152 | if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy())) |
| 7153 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7154 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7155 | } |
| 7156 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7157 | |
| 7158 | case GL_TEXTURE_SWIZZLE_R: |
| 7159 | case GL_TEXTURE_SWIZZLE_G: |
| 7160 | case GL_TEXTURE_SWIZZLE_B: |
| 7161 | case GL_TEXTURE_SWIZZLE_A: |
| 7162 | case GL_TEXTURE_BASE_LEVEL: |
| 7163 | case GL_TEXTURE_MAX_LEVEL: |
| 7164 | case GL_TEXTURE_COMPARE_MODE: |
| 7165 | case GL_TEXTURE_COMPARE_FUNC: |
| 7166 | if (context->getClientVersion() < 3) |
| 7167 | { |
| 7168 | return gl::error(GL_INVALID_ENUM); |
| 7169 | } |
| 7170 | UNIMPLEMENTED(); |
| 7171 | break; |
| 7172 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7173 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7174 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7175 | } |
| 7176 | } |
| 7177 | } |
| 7178 | catch(std::bad_alloc&) |
| 7179 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7180 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7181 | } |
| 7182 | } |
| 7183 | |
| 7184 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 7185 | { |
| 7186 | glTexParameteri(target, pname, *params); |
| 7187 | } |
| 7188 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7189 | void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 7190 | { |
| 7191 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 7192 | target, levels, internalformat, width, height); |
| 7193 | |
| 7194 | try |
| 7195 | { |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7196 | gl::Context *context = gl::getNonLostContext(); |
| 7197 | |
| 7198 | if (context) |
| 7199 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7200 | if (context->getClientVersion() < 3 && |
| 7201 | !validateES2TexStorageParameters(context, target, levels, internalformat, width, height)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7202 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7203 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7204 | } |
| 7205 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7206 | if (context->getClientVersion() >= 3 && |
| 7207 | !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7208 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7209 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7210 | } |
| 7211 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7212 | switch (target) |
| 7213 | { |
| 7214 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7215 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7216 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 7217 | texture2d->storage(levels, internalformat, width, height); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7218 | } |
| 7219 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7220 | |
| 7221 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7222 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7223 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7224 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7225 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7226 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7227 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7228 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 7229 | textureCube->storage(levels, internalformat, width); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7230 | } |
| 7231 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7232 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7233 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7234 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7235 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7236 | } |
| 7237 | } |
| 7238 | catch(std::bad_alloc&) |
| 7239 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7240 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7241 | } |
| 7242 | } |
| 7243 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7244 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 7245 | GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7246 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7247 | 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] | 7248 | "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] | 7249 | "const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7250 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 7251 | |
| 7252 | try |
| 7253 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7254 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7255 | |
| 7256 | if (context) |
| 7257 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7258 | if (context->getClientVersion() < 3 && |
| 7259 | !validateES2TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7260 | 0, 0, width, height, 0, format, type, pixels)) |
daniel@transgaming.com | 1d2d3c4 | 2012-05-31 01:14:15 +0000 | [diff] [blame] | 7261 | { |
| 7262 | return; |
| 7263 | } |
| 7264 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7265 | if (context->getClientVersion() >= 3 && |
| 7266 | !validateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7267 | 0, 0, 0, width, height, 1, 0, format, type)) |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7268 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7269 | return; |
| 7270 | } |
| 7271 | |
| 7272 | switch (target) |
| 7273 | { |
| 7274 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7275 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7276 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7277 | 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] | 7278 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7279 | break; |
| 7280 | |
| 7281 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7282 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7283 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7284 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7285 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7286 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7287 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7288 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7289 | 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] | 7290 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7291 | break; |
| 7292 | |
| 7293 | default: |
| 7294 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7295 | } |
| 7296 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7297 | } |
| 7298 | catch(std::bad_alloc&) |
| 7299 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7300 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7301 | } |
| 7302 | } |
| 7303 | |
| 7304 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 7305 | { |
| 7306 | glUniform1fv(location, 1, &x); |
| 7307 | } |
| 7308 | |
| 7309 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 7310 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7311 | 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] | 7312 | |
| 7313 | try |
| 7314 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7315 | if (count < 0) |
| 7316 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7317 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7318 | } |
| 7319 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7320 | if (location == -1) |
| 7321 | { |
| 7322 | return; |
| 7323 | } |
| 7324 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7325 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7326 | |
| 7327 | if (context) |
| 7328 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7329 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7330 | if (!programBinary) |
| 7331 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7332 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7333 | } |
| 7334 | |
| 7335 | if (!programBinary->setUniform1fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7336 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7337 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7338 | } |
| 7339 | } |
| 7340 | } |
| 7341 | catch(std::bad_alloc&) |
| 7342 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7343 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7344 | } |
| 7345 | } |
| 7346 | |
| 7347 | void __stdcall glUniform1i(GLint location, GLint x) |
| 7348 | { |
| 7349 | glUniform1iv(location, 1, &x); |
| 7350 | } |
| 7351 | |
| 7352 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 7353 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7354 | 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] | 7355 | |
| 7356 | try |
| 7357 | { |
| 7358 | if (count < 0) |
| 7359 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7360 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7361 | } |
| 7362 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7363 | if (location == -1) |
| 7364 | { |
| 7365 | return; |
| 7366 | } |
| 7367 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7368 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7369 | |
| 7370 | if (context) |
| 7371 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7372 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7373 | if (!programBinary) |
| 7374 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7375 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7376 | } |
| 7377 | |
| 7378 | if (!programBinary->setUniform1iv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7379 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7380 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7381 | } |
| 7382 | } |
| 7383 | } |
| 7384 | catch(std::bad_alloc&) |
| 7385 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7386 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7387 | } |
| 7388 | } |
| 7389 | |
| 7390 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 7391 | { |
| 7392 | GLfloat xy[2] = {x, y}; |
| 7393 | |
| 7394 | glUniform2fv(location, 1, (GLfloat*)&xy); |
| 7395 | } |
| 7396 | |
| 7397 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 7398 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7399 | 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] | 7400 | |
| 7401 | try |
| 7402 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7403 | if (count < 0) |
| 7404 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7405 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7406 | } |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7407 | |
| 7408 | if (location == -1) |
| 7409 | { |
| 7410 | return; |
| 7411 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7412 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7413 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7414 | |
| 7415 | if (context) |
| 7416 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7417 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7418 | if (!programBinary) |
| 7419 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7420 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7421 | } |
| 7422 | |
| 7423 | if (!programBinary->setUniform2fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7424 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7425 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7426 | } |
| 7427 | } |
| 7428 | } |
| 7429 | catch(std::bad_alloc&) |
| 7430 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7431 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7432 | } |
| 7433 | } |
| 7434 | |
| 7435 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 7436 | { |
| 7437 | GLint xy[4] = {x, y}; |
| 7438 | |
| 7439 | glUniform2iv(location, 1, (GLint*)&xy); |
| 7440 | } |
| 7441 | |
| 7442 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 7443 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7444 | 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] | 7445 | |
| 7446 | try |
| 7447 | { |
| 7448 | if (count < 0) |
| 7449 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7450 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7451 | } |
| 7452 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7453 | if (location == -1) |
| 7454 | { |
| 7455 | return; |
| 7456 | } |
| 7457 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7458 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7459 | |
| 7460 | if (context) |
| 7461 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7462 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7463 | if (!programBinary) |
| 7464 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7465 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7466 | } |
| 7467 | |
| 7468 | if (!programBinary->setUniform2iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7469 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7470 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7471 | } |
| 7472 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7473 | } |
| 7474 | catch(std::bad_alloc&) |
| 7475 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7476 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7477 | } |
| 7478 | } |
| 7479 | |
| 7480 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 7481 | { |
| 7482 | GLfloat xyz[3] = {x, y, z}; |
| 7483 | |
| 7484 | glUniform3fv(location, 1, (GLfloat*)&xyz); |
| 7485 | } |
| 7486 | |
| 7487 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 7488 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7489 | 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] | 7490 | |
| 7491 | try |
| 7492 | { |
| 7493 | if (count < 0) |
| 7494 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7495 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7496 | } |
| 7497 | |
| 7498 | if (location == -1) |
| 7499 | { |
| 7500 | return; |
| 7501 | } |
| 7502 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7503 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7504 | |
| 7505 | if (context) |
| 7506 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7507 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7508 | if (!programBinary) |
| 7509 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7510 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7511 | } |
| 7512 | |
| 7513 | if (!programBinary->setUniform3fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7514 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7515 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7516 | } |
| 7517 | } |
| 7518 | } |
| 7519 | catch(std::bad_alloc&) |
| 7520 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7521 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7522 | } |
| 7523 | } |
| 7524 | |
| 7525 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 7526 | { |
| 7527 | GLint xyz[3] = {x, y, z}; |
| 7528 | |
| 7529 | glUniform3iv(location, 1, (GLint*)&xyz); |
| 7530 | } |
| 7531 | |
| 7532 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 7533 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7534 | 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] | 7535 | |
| 7536 | try |
| 7537 | { |
| 7538 | if (count < 0) |
| 7539 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7540 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7541 | } |
| 7542 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7543 | if (location == -1) |
| 7544 | { |
| 7545 | return; |
| 7546 | } |
| 7547 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7548 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7549 | |
| 7550 | if (context) |
| 7551 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7552 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7553 | if (!programBinary) |
| 7554 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7555 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7556 | } |
| 7557 | |
| 7558 | if (!programBinary->setUniform3iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7559 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7560 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7561 | } |
| 7562 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7563 | } |
| 7564 | catch(std::bad_alloc&) |
| 7565 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7566 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7567 | } |
| 7568 | } |
| 7569 | |
| 7570 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7571 | { |
| 7572 | GLfloat xyzw[4] = {x, y, z, w}; |
| 7573 | |
| 7574 | glUniform4fv(location, 1, (GLfloat*)&xyzw); |
| 7575 | } |
| 7576 | |
| 7577 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 7578 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7579 | 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] | 7580 | |
| 7581 | try |
| 7582 | { |
| 7583 | if (count < 0) |
| 7584 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7585 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7586 | } |
| 7587 | |
| 7588 | if (location == -1) |
| 7589 | { |
| 7590 | return; |
| 7591 | } |
| 7592 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7593 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7594 | |
| 7595 | if (context) |
| 7596 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7597 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7598 | if (!programBinary) |
| 7599 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7600 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7601 | } |
| 7602 | |
| 7603 | if (!programBinary->setUniform4fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 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 | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7606 | } |
| 7607 | } |
| 7608 | } |
| 7609 | catch(std::bad_alloc&) |
| 7610 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7611 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7612 | } |
| 7613 | } |
| 7614 | |
| 7615 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 7616 | { |
| 7617 | GLint xyzw[4] = {x, y, z, w}; |
| 7618 | |
| 7619 | glUniform4iv(location, 1, (GLint*)&xyzw); |
| 7620 | } |
| 7621 | |
| 7622 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 7623 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7624 | 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] | 7625 | |
| 7626 | try |
| 7627 | { |
| 7628 | if (count < 0) |
| 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 | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7633 | if (location == -1) |
| 7634 | { |
| 7635 | return; |
| 7636 | } |
| 7637 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7638 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7639 | |
| 7640 | if (context) |
| 7641 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7642 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7643 | if (!programBinary) |
| 7644 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7645 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7646 | } |
| 7647 | |
| 7648 | if (!programBinary->setUniform4iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7649 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7650 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7651 | } |
| 7652 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7653 | } |
| 7654 | catch(std::bad_alloc&) |
| 7655 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7656 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7657 | } |
| 7658 | } |
| 7659 | |
| 7660 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7661 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7662 | 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] | 7663 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7664 | |
| 7665 | try |
| 7666 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7667 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7668 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7669 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7670 | } |
| 7671 | |
| 7672 | if (location == -1) |
| 7673 | { |
| 7674 | return; |
| 7675 | } |
| 7676 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7677 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7678 | |
| 7679 | if (context) |
| 7680 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7681 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7682 | { |
| 7683 | return gl::error(GL_INVALID_VALUE); |
| 7684 | } |
| 7685 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7686 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7687 | if (!programBinary) |
| 7688 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7689 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7690 | } |
| 7691 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7692 | if (!programBinary->setUniformMatrix2fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7693 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7694 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7695 | } |
| 7696 | } |
| 7697 | } |
| 7698 | catch(std::bad_alloc&) |
| 7699 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7700 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7701 | } |
| 7702 | } |
| 7703 | |
| 7704 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7705 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7706 | 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] | 7707 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7708 | |
| 7709 | try |
| 7710 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7711 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7712 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7713 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7714 | } |
| 7715 | |
| 7716 | if (location == -1) |
| 7717 | { |
| 7718 | return; |
| 7719 | } |
| 7720 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7721 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7722 | |
| 7723 | if (context) |
| 7724 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7725 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7726 | { |
| 7727 | return gl::error(GL_INVALID_VALUE); |
| 7728 | } |
| 7729 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7730 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7731 | if (!programBinary) |
| 7732 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7733 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7734 | } |
| 7735 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7736 | if (!programBinary->setUniformMatrix3fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7737 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7738 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7739 | } |
| 7740 | } |
| 7741 | } |
| 7742 | catch(std::bad_alloc&) |
| 7743 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7744 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7745 | } |
| 7746 | } |
| 7747 | |
| 7748 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7749 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7750 | 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] | 7751 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7752 | |
| 7753 | try |
| 7754 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7755 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7756 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7757 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7758 | } |
| 7759 | |
| 7760 | if (location == -1) |
| 7761 | { |
| 7762 | return; |
| 7763 | } |
| 7764 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7765 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7766 | |
| 7767 | if (context) |
| 7768 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7769 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7770 | { |
| 7771 | return gl::error(GL_INVALID_VALUE); |
| 7772 | } |
| 7773 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7774 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7775 | if (!programBinary) |
| 7776 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7777 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7778 | } |
| 7779 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7780 | if (!programBinary->setUniformMatrix4fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7781 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7782 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7783 | } |
| 7784 | } |
| 7785 | } |
| 7786 | catch(std::bad_alloc&) |
| 7787 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7788 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7789 | } |
| 7790 | } |
| 7791 | |
| 7792 | void __stdcall glUseProgram(GLuint program) |
| 7793 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7794 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7795 | |
| 7796 | try |
| 7797 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7798 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7799 | |
| 7800 | if (context) |
| 7801 | { |
| 7802 | gl::Program *programObject = context->getProgram(program); |
| 7803 | |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7804 | if (!programObject && program != 0) |
| 7805 | { |
| 7806 | if (context->getShader(program)) |
| 7807 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7808 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7809 | } |
| 7810 | else |
| 7811 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7812 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7813 | } |
| 7814 | } |
| 7815 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 7816 | if (program != 0 && !programObject->isLinked()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7817 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7818 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7819 | } |
| 7820 | |
| 7821 | context->useProgram(program); |
| 7822 | } |
| 7823 | } |
| 7824 | catch(std::bad_alloc&) |
| 7825 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7826 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7827 | } |
| 7828 | } |
| 7829 | |
| 7830 | void __stdcall glValidateProgram(GLuint program) |
| 7831 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7832 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7833 | |
| 7834 | try |
| 7835 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7836 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7837 | |
| 7838 | if (context) |
| 7839 | { |
| 7840 | gl::Program *programObject = context->getProgram(program); |
| 7841 | |
| 7842 | if (!programObject) |
| 7843 | { |
| 7844 | if (context->getShader(program)) |
| 7845 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7846 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7847 | } |
| 7848 | else |
| 7849 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7850 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7851 | } |
| 7852 | } |
| 7853 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 7854 | programObject->validate(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7855 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7856 | } |
| 7857 | catch(std::bad_alloc&) |
| 7858 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7859 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7860 | } |
| 7861 | } |
| 7862 | |
| 7863 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 7864 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7865 | EVENT("(GLuint index = %d, GLfloat x = %f)", index, x); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7866 | |
| 7867 | try |
| 7868 | { |
| 7869 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7870 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7871 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7872 | } |
| 7873 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7874 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7875 | |
| 7876 | if (context) |
| 7877 | { |
| 7878 | GLfloat vals[4] = { x, 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7879 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7880 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7881 | } |
| 7882 | catch(std::bad_alloc&) |
| 7883 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7884 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7885 | } |
| 7886 | } |
| 7887 | |
| 7888 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 7889 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7890 | 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] | 7891 | |
| 7892 | try |
| 7893 | { |
| 7894 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7895 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7896 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7897 | } |
| 7898 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7899 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7900 | |
| 7901 | if (context) |
| 7902 | { |
| 7903 | GLfloat vals[4] = { values[0], 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7904 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7905 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 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 glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 7914 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7915 | 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] | 7916 | |
| 7917 | try |
| 7918 | { |
| 7919 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 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 | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7925 | |
| 7926 | if (context) |
| 7927 | { |
| 7928 | GLfloat vals[4] = { x, y, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7929 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7930 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7931 | } |
| 7932 | catch(std::bad_alloc&) |
| 7933 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7934 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7935 | } |
| 7936 | } |
| 7937 | |
| 7938 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 7939 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7940 | 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] | 7941 | |
| 7942 | try |
| 7943 | { |
| 7944 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7945 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7946 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7947 | } |
| 7948 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7949 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7950 | |
| 7951 | if (context) |
| 7952 | { |
| 7953 | 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] | 7954 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7955 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7956 | } |
| 7957 | catch(std::bad_alloc&) |
| 7958 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7959 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7960 | } |
| 7961 | } |
| 7962 | |
| 7963 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 7964 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7965 | 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] | 7966 | |
| 7967 | try |
| 7968 | { |
| 7969 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7970 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7971 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7972 | } |
| 7973 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7974 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7975 | |
| 7976 | if (context) |
| 7977 | { |
| 7978 | GLfloat vals[4] = { x, y, z, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7979 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7980 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7981 | } |
| 7982 | catch(std::bad_alloc&) |
| 7983 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7984 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7985 | } |
| 7986 | } |
| 7987 | |
| 7988 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 7989 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7990 | 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] | 7991 | |
| 7992 | try |
| 7993 | { |
| 7994 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7995 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7996 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7997 | } |
| 7998 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7999 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8000 | |
| 8001 | if (context) |
| 8002 | { |
| 8003 | 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] | 8004 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8005 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8006 | } |
| 8007 | catch(std::bad_alloc&) |
| 8008 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8009 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8010 | } |
| 8011 | } |
| 8012 | |
| 8013 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 8014 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8015 | 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] | 8016 | |
| 8017 | try |
| 8018 | { |
| 8019 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8020 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8021 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8022 | } |
| 8023 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8024 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8025 | |
| 8026 | if (context) |
| 8027 | { |
| 8028 | GLfloat vals[4] = { x, y, z, w }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8029 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8030 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8031 | } |
| 8032 | catch(std::bad_alloc&) |
| 8033 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8034 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8035 | } |
| 8036 | } |
| 8037 | |
| 8038 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 8039 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8040 | 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] | 8041 | |
| 8042 | try |
| 8043 | { |
| 8044 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8045 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8046 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8047 | } |
| 8048 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8049 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8050 | |
| 8051 | if (context) |
| 8052 | { |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8053 | context->setVertexAttribf(index, values); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8054 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8055 | } |
| 8056 | catch(std::bad_alloc&) |
| 8057 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8058 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8059 | } |
| 8060 | } |
| 8061 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8062 | void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
| 8063 | { |
| 8064 | EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor); |
| 8065 | |
| 8066 | try |
| 8067 | { |
| 8068 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8069 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8070 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8071 | } |
| 8072 | |
| 8073 | gl::Context *context = gl::getNonLostContext(); |
| 8074 | |
| 8075 | if (context) |
| 8076 | { |
| 8077 | context->setVertexAttribDivisor(index, divisor); |
| 8078 | } |
| 8079 | } |
| 8080 | catch(std::bad_alloc&) |
| 8081 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8082 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8083 | } |
| 8084 | } |
| 8085 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 8086 | 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] | 8087 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8088 | 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] | 8089 | "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] | 8090 | index, size, type, normalized, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8091 | |
| 8092 | try |
| 8093 | { |
| 8094 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8095 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8096 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8097 | } |
| 8098 | |
| 8099 | if (size < 1 || size > 4) |
| 8100 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8101 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8102 | } |
| 8103 | |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 8104 | gl::Context *context = gl::getNonLostContext(); |
| 8105 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8106 | switch (type) |
| 8107 | { |
| 8108 | case GL_BYTE: |
| 8109 | case GL_UNSIGNED_BYTE: |
| 8110 | case GL_SHORT: |
| 8111 | case GL_UNSIGNED_SHORT: |
| 8112 | case GL_FIXED: |
| 8113 | case GL_FLOAT: |
| 8114 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 8115 | case GL_HALF_FLOAT: |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8116 | case GL_INT: |
| 8117 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 8118 | case GL_INT_2_10_10_10_REV: |
| 8119 | 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] | 8120 | if (context && context->getClientVersion() < 3) |
| 8121 | { |
| 8122 | return gl::error(GL_INVALID_ENUM); |
| 8123 | } |
| 8124 | else |
| 8125 | { |
| 8126 | break; |
| 8127 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8128 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8129 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8130 | } |
| 8131 | |
| 8132 | if (stride < 0) |
| 8133 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8134 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8135 | } |
| 8136 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 8137 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 8138 | { |
| 8139 | return gl::error(GL_INVALID_OPERATION); |
| 8140 | } |
| 8141 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8142 | if (context) |
| 8143 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8de4e6a | 2013-04-13 03:37:44 +0000 | [diff] [blame] | 8144 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, |
| 8145 | normalized == GL_TRUE, false, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8146 | } |
| 8147 | } |
| 8148 | catch(std::bad_alloc&) |
| 8149 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8150 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8151 | } |
| 8152 | } |
| 8153 | |
| 8154 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 8155 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8156 | 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] | 8157 | |
| 8158 | try |
| 8159 | { |
| 8160 | if (width < 0 || height < 0) |
| 8161 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8162 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8163 | } |
| 8164 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8165 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8166 | |
| 8167 | if (context) |
| 8168 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 8169 | context->setViewportParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8170 | } |
| 8171 | } |
| 8172 | catch(std::bad_alloc&) |
| 8173 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8174 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8175 | } |
| 8176 | } |
| 8177 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8178 | // OpenGL ES 3.0 functions |
| 8179 | |
| 8180 | void __stdcall glReadBuffer(GLenum mode) |
| 8181 | { |
| 8182 | EVENT("(GLenum mode = 0x%X)", mode); |
| 8183 | |
| 8184 | try |
| 8185 | { |
| 8186 | gl::Context *context = gl::getNonLostContext(); |
| 8187 | |
| 8188 | if (context) |
| 8189 | { |
| 8190 | if (context->getClientVersion() < 3) |
| 8191 | { |
| 8192 | return gl::error(GL_INVALID_OPERATION); |
| 8193 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8194 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8195 | UNIMPLEMENTED(); |
| 8196 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8197 | } |
| 8198 | catch(std::bad_alloc&) |
| 8199 | { |
| 8200 | return gl::error(GL_OUT_OF_MEMORY); |
| 8201 | } |
| 8202 | } |
| 8203 | |
| 8204 | void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) |
| 8205 | { |
| 8206 | EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, " |
| 8207 | "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices); |
| 8208 | |
| 8209 | try |
| 8210 | { |
| 8211 | gl::Context *context = gl::getNonLostContext(); |
| 8212 | |
| 8213 | if (context) |
| 8214 | { |
| 8215 | if (context->getClientVersion() < 3) |
| 8216 | { |
| 8217 | return gl::error(GL_INVALID_OPERATION); |
| 8218 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8219 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8220 | UNIMPLEMENTED(); |
| 8221 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8222 | } |
| 8223 | catch(std::bad_alloc&) |
| 8224 | { |
| 8225 | return gl::error(GL_OUT_OF_MEMORY); |
| 8226 | } |
| 8227 | } |
| 8228 | |
| 8229 | void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
| 8230 | { |
| 8231 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8232 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " |
| 8233 | "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8234 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 8235 | |
| 8236 | try |
| 8237 | { |
| 8238 | gl::Context *context = gl::getNonLostContext(); |
| 8239 | |
| 8240 | if (context) |
| 8241 | { |
| 8242 | if (context->getClientVersion() < 3) |
| 8243 | { |
| 8244 | return gl::error(GL_INVALID_OPERATION); |
| 8245 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8246 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8247 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8248 | if (!validateES3TexImageParameters(context, target, level, internalformat, false, false, |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8249 | 0, 0, 0, width, height, depth, border, format, type)) |
| 8250 | { |
| 8251 | return; |
| 8252 | } |
| 8253 | |
| 8254 | switch(target) |
| 8255 | { |
| 8256 | case GL_TEXTURE_3D: |
| 8257 | { |
| 8258 | gl::Texture3D *texture = context->getTexture3D(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8259 | 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] | 8260 | } |
| 8261 | break; |
| 8262 | |
| 8263 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8264 | { |
| 8265 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8266 | 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] | 8267 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8268 | break; |
| 8269 | |
| 8270 | default: |
| 8271 | return gl::error(GL_INVALID_ENUM); |
| 8272 | } |
| 8273 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8274 | } |
| 8275 | catch(std::bad_alloc&) |
| 8276 | { |
| 8277 | return gl::error(GL_OUT_OF_MEMORY); |
| 8278 | } |
| 8279 | } |
| 8280 | |
| 8281 | 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) |
| 8282 | { |
| 8283 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8284 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8285 | "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8286 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); |
| 8287 | |
| 8288 | try |
| 8289 | { |
| 8290 | gl::Context *context = gl::getNonLostContext(); |
| 8291 | |
| 8292 | if (context) |
| 8293 | { |
| 8294 | if (context->getClientVersion() < 3) |
| 8295 | { |
| 8296 | return gl::error(GL_INVALID_OPERATION); |
| 8297 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8298 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8299 | if (!pixels) |
| 8300 | { |
| 8301 | return gl::error(GL_INVALID_VALUE); |
| 8302 | } |
| 8303 | |
| 8304 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8305 | 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] | 8306 | xoffset, yoffset, zoffset, width, height, depth, 0, |
| 8307 | format, type)) |
| 8308 | { |
| 8309 | return; |
| 8310 | } |
| 8311 | |
| 8312 | switch(target) |
| 8313 | { |
| 8314 | case GL_TEXTURE_3D: |
| 8315 | { |
| 8316 | gl::Texture3D *texture = context->getTexture3D(); |
| 8317 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8318 | } |
| 8319 | break; |
| 8320 | |
| 8321 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8322 | { |
| 8323 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8324 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8325 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8326 | break; |
| 8327 | |
| 8328 | default: |
| 8329 | return gl::error(GL_INVALID_ENUM); |
| 8330 | } |
| 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); |
| 8336 | } |
| 8337 | } |
| 8338 | |
| 8339 | void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 8340 | { |
| 8341 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8342 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 8343 | target, level, xoffset, yoffset, zoffset, x, y, width, height); |
| 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 | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8356 | if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset, |
| 8357 | x, y, width, height, 0)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8358 | { |
| 8359 | return; |
| 8360 | } |
| 8361 | |
| 8362 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 8363 | gl::Texture *texture = NULL; |
| 8364 | switch (target) |
| 8365 | { |
| 8366 | case GL_TEXTURE_3D: |
| 8367 | texture = context->getTexture3D(); |
| 8368 | break; |
| 8369 | |
| 8370 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8371 | texture = context->getTexture2DArray(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8372 | break; |
| 8373 | |
| 8374 | default: |
| 8375 | return gl::error(GL_INVALID_ENUM); |
| 8376 | } |
| 8377 | |
| 8378 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer); |
| 8379 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8380 | } |
| 8381 | catch(std::bad_alloc&) |
| 8382 | { |
| 8383 | return gl::error(GL_OUT_OF_MEMORY); |
| 8384 | } |
| 8385 | } |
| 8386 | |
| 8387 | void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) |
| 8388 | { |
| 8389 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8390 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, " |
| 8391 | "const GLvoid* data = 0x%0.8p)", |
| 8392 | target, level, internalformat, width, height, depth, border, imageSize, data); |
| 8393 | |
| 8394 | try |
| 8395 | { |
| 8396 | gl::Context *context = gl::getNonLostContext(); |
| 8397 | |
| 8398 | if (context) |
| 8399 | { |
| 8400 | if (context->getClientVersion() < 3) |
| 8401 | { |
| 8402 | return gl::error(GL_INVALID_OPERATION); |
| 8403 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8404 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8405 | 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] | 8406 | { |
| 8407 | return gl::error(GL_INVALID_VALUE); |
| 8408 | } |
| 8409 | |
| 8410 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8411 | if (!validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 8412 | 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] | 8413 | { |
| 8414 | return; |
| 8415 | } |
| 8416 | |
| 8417 | switch(target) |
| 8418 | { |
| 8419 | case GL_TEXTURE_3D: |
| 8420 | { |
| 8421 | gl::Texture3D *texture = context->getTexture3D(); |
| 8422 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8423 | } |
| 8424 | break; |
| 8425 | |
| 8426 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8427 | { |
| 8428 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8429 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8430 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8431 | break; |
| 8432 | |
| 8433 | default: |
| 8434 | return gl::error(GL_INVALID_ENUM); |
| 8435 | } |
| 8436 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8437 | } |
| 8438 | catch(std::bad_alloc&) |
| 8439 | { |
| 8440 | return gl::error(GL_OUT_OF_MEMORY); |
| 8441 | } |
| 8442 | } |
| 8443 | |
| 8444 | 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) |
| 8445 | { |
| 8446 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8447 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8448 | "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 8449 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); |
| 8450 | |
| 8451 | try |
| 8452 | { |
| 8453 | gl::Context *context = gl::getNonLostContext(); |
| 8454 | |
| 8455 | if (context) |
| 8456 | { |
| 8457 | if (context->getClientVersion() < 3) |
| 8458 | { |
| 8459 | return gl::error(GL_INVALID_OPERATION); |
| 8460 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8461 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8462 | 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] | 8463 | { |
| 8464 | return gl::error(GL_INVALID_VALUE); |
| 8465 | } |
| 8466 | |
| 8467 | if (!data) |
| 8468 | { |
| 8469 | return gl::error(GL_INVALID_VALUE); |
| 8470 | } |
| 8471 | |
| 8472 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8473 | if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 8474 | 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] | 8475 | { |
| 8476 | return; |
| 8477 | } |
| 8478 | |
| 8479 | switch(target) |
| 8480 | { |
| 8481 | case GL_TEXTURE_3D: |
| 8482 | { |
| 8483 | gl::Texture3D *texture = context->getTexture3D(); |
| 8484 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8485 | format, imageSize, data); |
| 8486 | } |
| 8487 | break; |
| 8488 | |
| 8489 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8490 | { |
| 8491 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8492 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8493 | format, imageSize, data); |
| 8494 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8495 | break; |
| 8496 | |
| 8497 | default: |
| 8498 | return gl::error(GL_INVALID_ENUM); |
| 8499 | } |
| 8500 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8501 | } |
| 8502 | catch(std::bad_alloc&) |
| 8503 | { |
| 8504 | return gl::error(GL_OUT_OF_MEMORY); |
| 8505 | } |
| 8506 | } |
| 8507 | |
| 8508 | void __stdcall glGenQueries(GLsizei n, GLuint* ids) |
| 8509 | { |
| 8510 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8511 | |
| 8512 | try |
| 8513 | { |
| 8514 | gl::Context *context = gl::getNonLostContext(); |
| 8515 | |
| 8516 | if (context) |
| 8517 | { |
| 8518 | if (context->getClientVersion() < 3) |
| 8519 | { |
| 8520 | return gl::error(GL_INVALID_OPERATION); |
| 8521 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8522 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8523 | UNIMPLEMENTED(); |
| 8524 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8525 | } |
| 8526 | catch(std::bad_alloc&) |
| 8527 | { |
| 8528 | return gl::error(GL_OUT_OF_MEMORY); |
| 8529 | } |
| 8530 | } |
| 8531 | |
| 8532 | void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids) |
| 8533 | { |
| 8534 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8535 | |
| 8536 | try |
| 8537 | { |
| 8538 | gl::Context *context = gl::getNonLostContext(); |
| 8539 | |
| 8540 | if (context) |
| 8541 | { |
| 8542 | if (context->getClientVersion() < 3) |
| 8543 | { |
| 8544 | return gl::error(GL_INVALID_OPERATION); |
| 8545 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8546 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8547 | UNIMPLEMENTED(); |
| 8548 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8549 | } |
| 8550 | catch(std::bad_alloc&) |
| 8551 | { |
| 8552 | return gl::error(GL_OUT_OF_MEMORY); |
| 8553 | } |
| 8554 | } |
| 8555 | |
| 8556 | GLboolean __stdcall glIsQuery(GLuint id) |
| 8557 | { |
| 8558 | EVENT("(GLuint id = %u)", id); |
| 8559 | |
| 8560 | try |
| 8561 | { |
| 8562 | gl::Context *context = gl::getNonLostContext(); |
| 8563 | |
| 8564 | if (context) |
| 8565 | { |
| 8566 | if (context->getClientVersion() < 3) |
| 8567 | { |
| 8568 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8569 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8570 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8571 | UNIMPLEMENTED(); |
| 8572 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8573 | } |
| 8574 | catch(std::bad_alloc&) |
| 8575 | { |
| 8576 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8577 | } |
| 8578 | |
| 8579 | return GL_FALSE; |
| 8580 | } |
| 8581 | |
| 8582 | void __stdcall glBeginQuery(GLenum target, GLuint id) |
| 8583 | { |
| 8584 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 8585 | |
| 8586 | try |
| 8587 | { |
| 8588 | gl::Context *context = gl::getNonLostContext(); |
| 8589 | |
| 8590 | if (context) |
| 8591 | { |
| 8592 | if (context->getClientVersion() < 3) |
| 8593 | { |
| 8594 | return gl::error(GL_INVALID_OPERATION); |
| 8595 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8596 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8597 | UNIMPLEMENTED(); |
| 8598 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8599 | } |
| 8600 | catch(std::bad_alloc&) |
| 8601 | { |
| 8602 | return gl::error(GL_OUT_OF_MEMORY); |
| 8603 | } |
| 8604 | } |
| 8605 | |
| 8606 | void __stdcall glEndQuery(GLenum target) |
| 8607 | { |
| 8608 | EVENT("(GLenum target = 0x%X)", target); |
| 8609 | |
| 8610 | try |
| 8611 | { |
| 8612 | gl::Context *context = gl::getNonLostContext(); |
| 8613 | |
| 8614 | if (context) |
| 8615 | { |
| 8616 | if (context->getClientVersion() < 3) |
| 8617 | { |
| 8618 | return gl::error(GL_INVALID_OPERATION); |
| 8619 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8620 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8621 | UNIMPLEMENTED(); |
| 8622 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8623 | } |
| 8624 | catch(std::bad_alloc&) |
| 8625 | { |
| 8626 | return gl::error(GL_OUT_OF_MEMORY); |
| 8627 | } |
| 8628 | } |
| 8629 | |
| 8630 | void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params) |
| 8631 | { |
| 8632 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
| 8633 | |
| 8634 | try |
| 8635 | { |
| 8636 | gl::Context *context = gl::getNonLostContext(); |
| 8637 | |
| 8638 | if (context) |
| 8639 | { |
| 8640 | if (context->getClientVersion() < 3) |
| 8641 | { |
| 8642 | return gl::error(GL_INVALID_OPERATION); |
| 8643 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8644 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8645 | UNIMPLEMENTED(); |
| 8646 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8647 | } |
| 8648 | catch(std::bad_alloc&) |
| 8649 | { |
| 8650 | return gl::error(GL_OUT_OF_MEMORY); |
| 8651 | } |
| 8652 | } |
| 8653 | |
| 8654 | void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) |
| 8655 | { |
| 8656 | EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params); |
| 8657 | |
| 8658 | try |
| 8659 | { |
| 8660 | gl::Context *context = gl::getNonLostContext(); |
| 8661 | |
| 8662 | if (context) |
| 8663 | { |
| 8664 | if (context->getClientVersion() < 3) |
| 8665 | { |
| 8666 | return gl::error(GL_INVALID_OPERATION); |
| 8667 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8668 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8669 | UNIMPLEMENTED(); |
| 8670 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8671 | } |
| 8672 | catch(std::bad_alloc&) |
| 8673 | { |
| 8674 | return gl::error(GL_OUT_OF_MEMORY); |
| 8675 | } |
| 8676 | } |
| 8677 | |
| 8678 | GLboolean __stdcall glUnmapBuffer(GLenum target) |
| 8679 | { |
| 8680 | EVENT("(GLenum target = 0x%X)", target); |
| 8681 | |
| 8682 | try |
| 8683 | { |
| 8684 | gl::Context *context = gl::getNonLostContext(); |
| 8685 | |
| 8686 | if (context) |
| 8687 | { |
| 8688 | if (context->getClientVersion() < 3) |
| 8689 | { |
| 8690 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8691 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8692 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8693 | UNIMPLEMENTED(); |
| 8694 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8695 | } |
| 8696 | catch(std::bad_alloc&) |
| 8697 | { |
| 8698 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8699 | } |
| 8700 | |
| 8701 | return GL_FALSE; |
| 8702 | } |
| 8703 | |
| 8704 | void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) |
| 8705 | { |
| 8706 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 8707 | |
| 8708 | try |
| 8709 | { |
| 8710 | gl::Context *context = gl::getNonLostContext(); |
| 8711 | |
| 8712 | if (context) |
| 8713 | { |
| 8714 | if (context->getClientVersion() < 3) |
| 8715 | { |
| 8716 | return gl::error(GL_INVALID_OPERATION); |
| 8717 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8718 | |
shannonwoods@chromium.org | 2d2190a | 2013-05-30 00:17:35 +0000 | [diff] [blame] | 8719 | UNIMPLEMENTED(); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8720 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8721 | } |
| 8722 | catch(std::bad_alloc&) |
| 8723 | { |
| 8724 | return gl::error(GL_OUT_OF_MEMORY); |
| 8725 | } |
| 8726 | } |
| 8727 | |
| 8728 | void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs) |
| 8729 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8730 | try |
| 8731 | { |
| 8732 | gl::Context *context = gl::getNonLostContext(); |
| 8733 | |
| 8734 | if (context) |
| 8735 | { |
| 8736 | if (context->getClientVersion() < 3) |
| 8737 | { |
| 8738 | return gl::error(GL_INVALID_OPERATION); |
| 8739 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8740 | |
shannon.woods%transgaming.com@gtempaccount.com | 7948c5f | 2013-04-13 03:38:58 +0000 | [diff] [blame] | 8741 | glDrawBuffersEXT(n, bufs); |
| 8742 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8743 | } |
| 8744 | catch(std::bad_alloc&) |
| 8745 | { |
| 8746 | return gl::error(GL_OUT_OF_MEMORY); |
| 8747 | } |
| 8748 | } |
| 8749 | |
| 8750 | void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8751 | { |
| 8752 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8753 | location, count, transpose, value); |
| 8754 | |
| 8755 | try |
| 8756 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8757 | if (count < 0) |
| 8758 | { |
| 8759 | return gl::error(GL_INVALID_VALUE); |
| 8760 | } |
| 8761 | |
| 8762 | if (location == -1) |
| 8763 | { |
| 8764 | return; |
| 8765 | } |
| 8766 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8767 | gl::Context *context = gl::getNonLostContext(); |
| 8768 | |
| 8769 | if (context) |
| 8770 | { |
| 8771 | if (context->getClientVersion() < 3) |
| 8772 | { |
| 8773 | return gl::error(GL_INVALID_OPERATION); |
| 8774 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8775 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8776 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8777 | if (!programBinary) |
| 8778 | { |
| 8779 | return gl::error(GL_INVALID_OPERATION); |
| 8780 | } |
| 8781 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8782 | if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8783 | { |
| 8784 | return gl::error(GL_INVALID_OPERATION); |
| 8785 | } |
| 8786 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8787 | } |
| 8788 | catch(std::bad_alloc&) |
| 8789 | { |
| 8790 | return gl::error(GL_OUT_OF_MEMORY); |
| 8791 | } |
| 8792 | } |
| 8793 | |
| 8794 | void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8795 | { |
| 8796 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8797 | location, count, transpose, value); |
| 8798 | |
| 8799 | try |
| 8800 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8801 | if (count < 0) |
| 8802 | { |
| 8803 | return gl::error(GL_INVALID_VALUE); |
| 8804 | } |
| 8805 | |
| 8806 | if (location == -1) |
| 8807 | { |
| 8808 | return; |
| 8809 | } |
| 8810 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8811 | gl::Context *context = gl::getNonLostContext(); |
| 8812 | |
| 8813 | if (context) |
| 8814 | { |
| 8815 | if (context->getClientVersion() < 3) |
| 8816 | { |
| 8817 | return gl::error(GL_INVALID_OPERATION); |
| 8818 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8819 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8820 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8821 | if (!programBinary) |
| 8822 | { |
| 8823 | return gl::error(GL_INVALID_OPERATION); |
| 8824 | } |
| 8825 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8826 | if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8827 | { |
| 8828 | return gl::error(GL_INVALID_OPERATION); |
| 8829 | } |
| 8830 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8831 | } |
| 8832 | catch(std::bad_alloc&) |
| 8833 | { |
| 8834 | return gl::error(GL_OUT_OF_MEMORY); |
| 8835 | } |
| 8836 | } |
| 8837 | |
| 8838 | void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8839 | { |
| 8840 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8841 | location, count, transpose, value); |
| 8842 | |
| 8843 | try |
| 8844 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8845 | if (count < 0) |
| 8846 | { |
| 8847 | return gl::error(GL_INVALID_VALUE); |
| 8848 | } |
| 8849 | |
| 8850 | if (location == -1) |
| 8851 | { |
| 8852 | return; |
| 8853 | } |
| 8854 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8855 | gl::Context *context = gl::getNonLostContext(); |
| 8856 | |
| 8857 | if (context) |
| 8858 | { |
| 8859 | if (context->getClientVersion() < 3) |
| 8860 | { |
| 8861 | return gl::error(GL_INVALID_OPERATION); |
| 8862 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8863 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8864 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8865 | if (!programBinary) |
| 8866 | { |
| 8867 | return gl::error(GL_INVALID_OPERATION); |
| 8868 | } |
| 8869 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8870 | if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8871 | { |
| 8872 | return gl::error(GL_INVALID_OPERATION); |
| 8873 | } |
| 8874 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8875 | } |
| 8876 | catch(std::bad_alloc&) |
| 8877 | { |
| 8878 | return gl::error(GL_OUT_OF_MEMORY); |
| 8879 | } |
| 8880 | } |
| 8881 | |
| 8882 | void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8883 | { |
| 8884 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8885 | location, count, transpose, value); |
| 8886 | |
| 8887 | try |
| 8888 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8889 | if (count < 0) |
| 8890 | { |
| 8891 | return gl::error(GL_INVALID_VALUE); |
| 8892 | } |
| 8893 | |
| 8894 | if (location == -1) |
| 8895 | { |
| 8896 | return; |
| 8897 | } |
| 8898 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8899 | gl::Context *context = gl::getNonLostContext(); |
| 8900 | |
| 8901 | if (context) |
| 8902 | { |
| 8903 | if (context->getClientVersion() < 3) |
| 8904 | { |
| 8905 | return gl::error(GL_INVALID_OPERATION); |
| 8906 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8907 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8908 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8909 | if (!programBinary) |
| 8910 | { |
| 8911 | return gl::error(GL_INVALID_OPERATION); |
| 8912 | } |
| 8913 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8914 | if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8915 | { |
| 8916 | return gl::error(GL_INVALID_OPERATION); |
| 8917 | } |
| 8918 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8919 | } |
| 8920 | catch(std::bad_alloc&) |
| 8921 | { |
| 8922 | return gl::error(GL_OUT_OF_MEMORY); |
| 8923 | } |
| 8924 | } |
| 8925 | |
| 8926 | void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8927 | { |
| 8928 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8929 | location, count, transpose, value); |
| 8930 | |
| 8931 | try |
| 8932 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8933 | if (count < 0) |
| 8934 | { |
| 8935 | return gl::error(GL_INVALID_VALUE); |
| 8936 | } |
| 8937 | |
| 8938 | if (location == -1) |
| 8939 | { |
| 8940 | return; |
| 8941 | } |
| 8942 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8943 | gl::Context *context = gl::getNonLostContext(); |
| 8944 | |
| 8945 | if (context) |
| 8946 | { |
| 8947 | if (context->getClientVersion() < 3) |
| 8948 | { |
| 8949 | return gl::error(GL_INVALID_OPERATION); |
| 8950 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8951 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8952 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8953 | if (!programBinary) |
| 8954 | { |
| 8955 | return gl::error(GL_INVALID_OPERATION); |
| 8956 | } |
| 8957 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8958 | if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8959 | { |
| 8960 | return gl::error(GL_INVALID_OPERATION); |
| 8961 | } |
| 8962 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8963 | } |
| 8964 | catch(std::bad_alloc&) |
| 8965 | { |
| 8966 | return gl::error(GL_OUT_OF_MEMORY); |
| 8967 | } |
| 8968 | } |
| 8969 | |
| 8970 | void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8971 | { |
| 8972 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8973 | location, count, transpose, value); |
| 8974 | |
| 8975 | try |
| 8976 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8977 | if (count < 0) |
| 8978 | { |
| 8979 | return gl::error(GL_INVALID_VALUE); |
| 8980 | } |
| 8981 | |
| 8982 | if (location == -1) |
| 8983 | { |
| 8984 | return; |
| 8985 | } |
| 8986 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8987 | gl::Context *context = gl::getNonLostContext(); |
| 8988 | |
| 8989 | if (context) |
| 8990 | { |
| 8991 | if (context->getClientVersion() < 3) |
| 8992 | { |
| 8993 | return gl::error(GL_INVALID_OPERATION); |
| 8994 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8995 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8996 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8997 | if (!programBinary) |
| 8998 | { |
| 8999 | return gl::error(GL_INVALID_OPERATION); |
| 9000 | } |
| 9001 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9002 | if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9003 | { |
| 9004 | return gl::error(GL_INVALID_OPERATION); |
| 9005 | } |
| 9006 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9007 | } |
| 9008 | catch(std::bad_alloc&) |
| 9009 | { |
| 9010 | return gl::error(GL_OUT_OF_MEMORY); |
| 9011 | } |
| 9012 | } |
| 9013 | |
| 9014 | void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) |
| 9015 | { |
| 9016 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, " |
| 9017 | "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 9018 | srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 9019 | |
| 9020 | try |
| 9021 | { |
| 9022 | gl::Context *context = gl::getNonLostContext(); |
| 9023 | |
| 9024 | if (context) |
| 9025 | { |
| 9026 | if (context->getClientVersion() < 3) |
| 9027 | { |
| 9028 | return gl::error(GL_INVALID_OPERATION); |
| 9029 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9030 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 9031 | if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 9032 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 9033 | false)) |
| 9034 | { |
| 9035 | return; |
| 9036 | } |
| 9037 | |
| 9038 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 9039 | mask, filter); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9040 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9041 | } |
| 9042 | catch(std::bad_alloc&) |
| 9043 | { |
| 9044 | return gl::error(GL_OUT_OF_MEMORY); |
| 9045 | } |
| 9046 | } |
| 9047 | |
| 9048 | void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| 9049 | { |
| 9050 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 9051 | target, samples, internalformat, width, height); |
| 9052 | |
| 9053 | try |
| 9054 | { |
| 9055 | gl::Context *context = gl::getNonLostContext(); |
| 9056 | |
| 9057 | if (context) |
| 9058 | { |
| 9059 | if (context->getClientVersion() < 3) |
| 9060 | { |
| 9061 | return gl::error(GL_INVALID_OPERATION); |
| 9062 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9063 | |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 9064 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 9065 | width, height, false)) |
| 9066 | { |
| 9067 | return; |
| 9068 | } |
| 9069 | |
| 9070 | context->setRenderbufferStorage(width, height, internalformat, samples); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9071 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9072 | } |
| 9073 | catch(std::bad_alloc&) |
| 9074 | { |
| 9075 | return gl::error(GL_OUT_OF_MEMORY); |
| 9076 | } |
| 9077 | } |
| 9078 | |
| 9079 | void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) |
| 9080 | { |
| 9081 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)", |
| 9082 | target, attachment, texture, level, layer); |
| 9083 | |
| 9084 | try |
| 9085 | { |
| 9086 | gl::Context *context = gl::getNonLostContext(); |
| 9087 | |
| 9088 | if (context) |
| 9089 | { |
| 9090 | if (context->getClientVersion() < 3) |
| 9091 | { |
| 9092 | return gl::error(GL_INVALID_OPERATION); |
| 9093 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9094 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9095 | UNIMPLEMENTED(); |
| 9096 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9097 | } |
| 9098 | catch(std::bad_alloc&) |
| 9099 | { |
| 9100 | return gl::error(GL_OUT_OF_MEMORY); |
| 9101 | } |
| 9102 | } |
| 9103 | |
| 9104 | GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 9105 | { |
| 9106 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 9107 | target, offset, length, access); |
| 9108 | |
| 9109 | try |
| 9110 | { |
| 9111 | gl::Context *context = gl::getNonLostContext(); |
| 9112 | |
| 9113 | if (context) |
| 9114 | { |
| 9115 | if (context->getClientVersion() < 3) |
| 9116 | { |
| 9117 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 9118 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9119 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9120 | UNIMPLEMENTED(); |
| 9121 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9122 | } |
| 9123 | catch(std::bad_alloc&) |
| 9124 | { |
| 9125 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL)); |
| 9126 | } |
| 9127 | |
| 9128 | return NULL; |
| 9129 | } |
| 9130 | |
| 9131 | void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) |
| 9132 | { |
| 9133 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 9134 | |
| 9135 | try |
| 9136 | { |
| 9137 | gl::Context *context = gl::getNonLostContext(); |
| 9138 | |
| 9139 | if (context) |
| 9140 | { |
| 9141 | if (context->getClientVersion() < 3) |
| 9142 | { |
| 9143 | return gl::error(GL_INVALID_OPERATION); |
| 9144 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9145 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9146 | UNIMPLEMENTED(); |
| 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 glBindVertexArray(GLuint array) |
| 9156 | { |
| 9157 | EVENT("(GLuint array = %u)", array); |
| 9158 | |
| 9159 | try |
| 9160 | { |
| 9161 | gl::Context *context = gl::getNonLostContext(); |
| 9162 | |
| 9163 | if (context) |
| 9164 | { |
| 9165 | if (context->getClientVersion() < 3) |
| 9166 | { |
| 9167 | return gl::error(GL_INVALID_OPERATION); |
| 9168 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9169 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9170 | UNIMPLEMENTED(); |
| 9171 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9172 | } |
| 9173 | catch(std::bad_alloc&) |
| 9174 | { |
| 9175 | return gl::error(GL_OUT_OF_MEMORY); |
| 9176 | } |
| 9177 | } |
| 9178 | |
| 9179 | void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) |
| 9180 | { |
| 9181 | EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays); |
| 9182 | |
| 9183 | try |
| 9184 | { |
| 9185 | gl::Context *context = gl::getNonLostContext(); |
| 9186 | |
| 9187 | if (context) |
| 9188 | { |
| 9189 | if (context->getClientVersion() < 3) |
| 9190 | { |
| 9191 | return gl::error(GL_INVALID_OPERATION); |
| 9192 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9193 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9194 | UNIMPLEMENTED(); |
| 9195 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9196 | } |
| 9197 | catch(std::bad_alloc&) |
| 9198 | { |
| 9199 | return gl::error(GL_OUT_OF_MEMORY); |
| 9200 | } |
| 9201 | } |
| 9202 | |
| 9203 | void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) |
| 9204 | { |
| 9205 | EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays); |
| 9206 | |
| 9207 | try |
| 9208 | { |
| 9209 | gl::Context *context = gl::getNonLostContext(); |
| 9210 | |
| 9211 | if (context) |
| 9212 | { |
| 9213 | if (context->getClientVersion() < 3) |
| 9214 | { |
| 9215 | return gl::error(GL_INVALID_OPERATION); |
| 9216 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9217 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9218 | UNIMPLEMENTED(); |
| 9219 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9220 | } |
| 9221 | catch(std::bad_alloc&) |
| 9222 | { |
| 9223 | return gl::error(GL_OUT_OF_MEMORY); |
| 9224 | } |
| 9225 | } |
| 9226 | |
| 9227 | GLboolean __stdcall glIsVertexArray(GLuint array) |
| 9228 | { |
| 9229 | EVENT("(GLuint array = %u)", array); |
| 9230 | |
| 9231 | try |
| 9232 | { |
| 9233 | gl::Context *context = gl::getNonLostContext(); |
| 9234 | |
| 9235 | if (context) |
| 9236 | { |
| 9237 | if (context->getClientVersion() < 3) |
| 9238 | { |
| 9239 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 9240 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9241 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9242 | UNIMPLEMENTED(); |
| 9243 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9244 | } |
| 9245 | catch(std::bad_alloc&) |
| 9246 | { |
| 9247 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 9248 | } |
| 9249 | |
| 9250 | return GL_FALSE; |
| 9251 | } |
| 9252 | |
| 9253 | void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data) |
| 9254 | { |
| 9255 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)", |
| 9256 | target, index, data); |
| 9257 | |
| 9258 | try |
| 9259 | { |
| 9260 | gl::Context *context = gl::getNonLostContext(); |
| 9261 | |
| 9262 | if (context) |
| 9263 | { |
| 9264 | if (context->getClientVersion() < 3) |
| 9265 | { |
| 9266 | return gl::error(GL_INVALID_OPERATION); |
| 9267 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9268 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9269 | UNIMPLEMENTED(); |
| 9270 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9271 | } |
| 9272 | catch(std::bad_alloc&) |
| 9273 | { |
| 9274 | return gl::error(GL_OUT_OF_MEMORY); |
| 9275 | } |
| 9276 | } |
| 9277 | |
| 9278 | void __stdcall glBeginTransformFeedback(GLenum primitiveMode) |
| 9279 | { |
| 9280 | EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode); |
| 9281 | |
| 9282 | try |
| 9283 | { |
| 9284 | gl::Context *context = gl::getNonLostContext(); |
| 9285 | |
| 9286 | if (context) |
| 9287 | { |
| 9288 | if (context->getClientVersion() < 3) |
| 9289 | { |
| 9290 | return gl::error(GL_INVALID_OPERATION); |
| 9291 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9292 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9293 | UNIMPLEMENTED(); |
| 9294 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9295 | } |
| 9296 | catch(std::bad_alloc&) |
| 9297 | { |
| 9298 | return gl::error(GL_OUT_OF_MEMORY); |
| 9299 | } |
| 9300 | } |
| 9301 | |
| 9302 | void __stdcall glEndTransformFeedback(void) |
| 9303 | { |
| 9304 | EVENT("(void)"); |
| 9305 | |
| 9306 | try |
| 9307 | { |
| 9308 | gl::Context *context = gl::getNonLostContext(); |
| 9309 | |
| 9310 | if (context) |
| 9311 | { |
| 9312 | if (context->getClientVersion() < 3) |
| 9313 | { |
| 9314 | return gl::error(GL_INVALID_OPERATION); |
| 9315 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9316 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9317 | UNIMPLEMENTED(); |
| 9318 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9319 | } |
| 9320 | catch(std::bad_alloc&) |
| 9321 | { |
| 9322 | return gl::error(GL_OUT_OF_MEMORY); |
| 9323 | } |
| 9324 | } |
| 9325 | |
| 9326 | void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
| 9327 | { |
| 9328 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)", |
| 9329 | target, index, buffer, offset, size); |
| 9330 | |
| 9331 | try |
| 9332 | { |
| 9333 | gl::Context *context = gl::getNonLostContext(); |
| 9334 | |
| 9335 | if (context) |
| 9336 | { |
| 9337 | if (context->getClientVersion() < 3) |
| 9338 | { |
| 9339 | return gl::error(GL_INVALID_OPERATION); |
| 9340 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9341 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9342 | switch (target) |
| 9343 | { |
| 9344 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9345 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9346 | { |
| 9347 | return gl::error(GL_INVALID_VALUE); |
| 9348 | } |
| 9349 | break; |
| 9350 | |
| 9351 | case GL_UNIFORM_BUFFER: |
| 9352 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 9353 | { |
| 9354 | return gl::error(GL_INVALID_VALUE); |
| 9355 | } |
| 9356 | break; |
| 9357 | |
| 9358 | default: |
| 9359 | return gl::error(GL_INVALID_ENUM); |
| 9360 | } |
| 9361 | |
shannonwoods@chromium.org | e6e0079 | 2013-05-30 00:06:07 +0000 | [diff] [blame] | 9362 | if (buffer != 0 && size <= 0) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9363 | { |
| 9364 | return gl::error(GL_INVALID_VALUE); |
| 9365 | } |
| 9366 | |
| 9367 | switch (target) |
| 9368 | { |
| 9369 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | a26aeaf | 2013-05-30 00:06:13 +0000 | [diff] [blame] | 9370 | |
| 9371 | // size and offset must be a multiple of 4 |
| 9372 | if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) |
| 9373 | { |
| 9374 | return gl::error(GL_INVALID_VALUE); |
| 9375 | } |
| 9376 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9377 | context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 9378 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9379 | break; |
| 9380 | |
| 9381 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 97c3d50 | 2013-05-30 00:04:34 +0000 | [diff] [blame] | 9382 | |
| 9383 | // it is an error to bind an offset not a multiple of the alignment |
| 9384 | if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0) |
| 9385 | { |
| 9386 | return gl::error(GL_INVALID_VALUE); |
| 9387 | } |
| 9388 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9389 | context->bindIndexedUniformBuffer(buffer, index, offset, size); |
| 9390 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9391 | break; |
| 9392 | |
| 9393 | default: |
| 9394 | UNREACHABLE(); |
| 9395 | } |
| 9396 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9397 | } |
| 9398 | catch(std::bad_alloc&) |
| 9399 | { |
| 9400 | return gl::error(GL_OUT_OF_MEMORY); |
| 9401 | } |
| 9402 | } |
| 9403 | |
| 9404 | void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 9405 | { |
| 9406 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)", |
| 9407 | target, index, buffer); |
| 9408 | |
| 9409 | try |
| 9410 | { |
| 9411 | gl::Context *context = gl::getNonLostContext(); |
| 9412 | |
| 9413 | if (context) |
| 9414 | { |
| 9415 | if (context->getClientVersion() < 3) |
| 9416 | { |
| 9417 | return gl::error(GL_INVALID_OPERATION); |
| 9418 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9419 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9420 | switch (target) |
| 9421 | { |
| 9422 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9423 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9424 | { |
| 9425 | return gl::error(GL_INVALID_VALUE); |
| 9426 | } |
| 9427 | break; |
| 9428 | |
| 9429 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9430 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9431 | { |
| 9432 | return gl::error(GL_INVALID_VALUE); |
| 9433 | } |
| 9434 | break; |
| 9435 | |
| 9436 | default: |
| 9437 | return gl::error(GL_INVALID_ENUM); |
| 9438 | } |
| 9439 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9440 | switch (target) |
| 9441 | { |
| 9442 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9443 | context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9444 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9445 | break; |
| 9446 | |
| 9447 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9448 | context->bindIndexedUniformBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9449 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9450 | break; |
| 9451 | |
| 9452 | default: |
| 9453 | UNREACHABLE(); |
| 9454 | } |
| 9455 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9456 | } |
| 9457 | catch(std::bad_alloc&) |
| 9458 | { |
| 9459 | return gl::error(GL_OUT_OF_MEMORY); |
| 9460 | } |
| 9461 | } |
| 9462 | |
| 9463 | void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
| 9464 | { |
| 9465 | EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)", |
| 9466 | program, count, varyings, bufferMode); |
| 9467 | |
| 9468 | try |
| 9469 | { |
| 9470 | gl::Context *context = gl::getNonLostContext(); |
| 9471 | |
| 9472 | if (context) |
| 9473 | { |
| 9474 | if (context->getClientVersion() < 3) |
| 9475 | { |
| 9476 | return gl::error(GL_INVALID_OPERATION); |
| 9477 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9478 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9479 | UNIMPLEMENTED(); |
| 9480 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9481 | } |
| 9482 | catch(std::bad_alloc&) |
| 9483 | { |
| 9484 | return gl::error(GL_OUT_OF_MEMORY); |
| 9485 | } |
| 9486 | } |
| 9487 | |
| 9488 | void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
| 9489 | { |
| 9490 | EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, " |
| 9491 | "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
| 9492 | program, index, bufSize, length, size, type, name); |
| 9493 | |
| 9494 | try |
| 9495 | { |
| 9496 | gl::Context *context = gl::getNonLostContext(); |
| 9497 | |
| 9498 | if (context) |
| 9499 | { |
| 9500 | if (context->getClientVersion() < 3) |
| 9501 | { |
| 9502 | return gl::error(GL_INVALID_OPERATION); |
| 9503 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9504 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9505 | UNIMPLEMENTED(); |
| 9506 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9507 | } |
| 9508 | catch(std::bad_alloc&) |
| 9509 | { |
| 9510 | return gl::error(GL_OUT_OF_MEMORY); |
| 9511 | } |
| 9512 | } |
| 9513 | |
| 9514 | void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) |
| 9515 | { |
| 9516 | EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)", |
| 9517 | index, size, type, stride, pointer); |
| 9518 | |
| 9519 | try |
| 9520 | { |
| 9521 | gl::Context *context = gl::getNonLostContext(); |
| 9522 | |
| 9523 | if (context) |
| 9524 | { |
| 9525 | if (context->getClientVersion() < 3) |
| 9526 | { |
| 9527 | return gl::error(GL_INVALID_OPERATION); |
| 9528 | } |
| 9529 | } |
| 9530 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9531 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9532 | { |
| 9533 | return gl::error(GL_INVALID_VALUE); |
| 9534 | } |
| 9535 | |
| 9536 | if (size < 1 || size > 4) |
| 9537 | { |
| 9538 | return gl::error(GL_INVALID_VALUE); |
| 9539 | } |
| 9540 | |
| 9541 | switch (type) |
| 9542 | { |
| 9543 | case GL_BYTE: |
| 9544 | case GL_UNSIGNED_BYTE: |
| 9545 | case GL_SHORT: |
| 9546 | case GL_UNSIGNED_SHORT: |
| 9547 | case GL_INT: |
| 9548 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9549 | case GL_INT_2_10_10_10_REV: |
| 9550 | 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] | 9551 | break; |
| 9552 | default: |
| 9553 | return gl::error(GL_INVALID_ENUM); |
| 9554 | } |
| 9555 | |
| 9556 | if (stride < 0) |
| 9557 | { |
| 9558 | return gl::error(GL_INVALID_VALUE); |
| 9559 | } |
| 9560 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9561 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 9562 | { |
| 9563 | return gl::error(GL_INVALID_OPERATION); |
| 9564 | } |
| 9565 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9566 | if (context) |
| 9567 | { |
| 9568 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true, |
| 9569 | stride, pointer); |
| 9570 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9571 | } |
| 9572 | catch(std::bad_alloc&) |
| 9573 | { |
| 9574 | return gl::error(GL_OUT_OF_MEMORY); |
| 9575 | } |
| 9576 | } |
| 9577 | |
| 9578 | void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) |
| 9579 | { |
| 9580 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 9581 | index, pname, params); |
| 9582 | |
| 9583 | try |
| 9584 | { |
| 9585 | gl::Context *context = gl::getNonLostContext(); |
| 9586 | |
| 9587 | if (context) |
| 9588 | { |
| 9589 | if (context->getClientVersion() < 3) |
| 9590 | { |
| 9591 | return gl::error(GL_INVALID_OPERATION); |
| 9592 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9593 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9594 | UNIMPLEMENTED(); |
| 9595 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9596 | } |
| 9597 | catch(std::bad_alloc&) |
| 9598 | { |
| 9599 | return gl::error(GL_OUT_OF_MEMORY); |
| 9600 | } |
| 9601 | } |
| 9602 | |
| 9603 | void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) |
| 9604 | { |
| 9605 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)", |
| 9606 | index, pname, params); |
| 9607 | |
| 9608 | try |
| 9609 | { |
| 9610 | gl::Context *context = gl::getNonLostContext(); |
| 9611 | |
| 9612 | if (context) |
| 9613 | { |
| 9614 | if (context->getClientVersion() < 3) |
| 9615 | { |
| 9616 | return gl::error(GL_INVALID_OPERATION); |
| 9617 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9618 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9619 | UNIMPLEMENTED(); |
| 9620 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9621 | } |
| 9622 | catch(std::bad_alloc&) |
| 9623 | { |
| 9624 | return gl::error(GL_OUT_OF_MEMORY); |
| 9625 | } |
| 9626 | } |
| 9627 | |
| 9628 | void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 9629 | { |
| 9630 | EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)", |
| 9631 | index, x, y, z, w); |
| 9632 | |
| 9633 | try |
| 9634 | { |
| 9635 | gl::Context *context = gl::getNonLostContext(); |
| 9636 | |
| 9637 | if (context) |
| 9638 | { |
| 9639 | if (context->getClientVersion() < 3) |
| 9640 | { |
| 9641 | return gl::error(GL_INVALID_OPERATION); |
| 9642 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9643 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9644 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9645 | { |
| 9646 | return gl::error(GL_INVALID_VALUE); |
| 9647 | } |
| 9648 | |
| 9649 | GLint vals[4] = { x, y, z, w }; |
| 9650 | context->setVertexAttribi(index, vals); |
| 9651 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9652 | } |
| 9653 | catch(std::bad_alloc&) |
| 9654 | { |
| 9655 | return gl::error(GL_OUT_OF_MEMORY); |
| 9656 | } |
| 9657 | } |
| 9658 | |
| 9659 | void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 9660 | { |
| 9661 | EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)", |
| 9662 | index, x, y, z, w); |
| 9663 | |
| 9664 | try |
| 9665 | { |
| 9666 | gl::Context *context = gl::getNonLostContext(); |
| 9667 | |
| 9668 | if (context) |
| 9669 | { |
| 9670 | if (context->getClientVersion() < 3) |
| 9671 | { |
| 9672 | return gl::error(GL_INVALID_OPERATION); |
| 9673 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9674 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9675 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9676 | { |
| 9677 | return gl::error(GL_INVALID_VALUE); |
| 9678 | } |
| 9679 | |
| 9680 | GLuint vals[4] = { x, y, z, w }; |
| 9681 | context->setVertexAttribu(index, vals); |
| 9682 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9683 | } |
| 9684 | catch(std::bad_alloc&) |
| 9685 | { |
| 9686 | return gl::error(GL_OUT_OF_MEMORY); |
| 9687 | } |
| 9688 | } |
| 9689 | |
| 9690 | void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) |
| 9691 | { |
| 9692 | EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v); |
| 9693 | |
| 9694 | try |
| 9695 | { |
| 9696 | gl::Context *context = gl::getNonLostContext(); |
| 9697 | |
| 9698 | if (context) |
| 9699 | { |
| 9700 | if (context->getClientVersion() < 3) |
| 9701 | { |
| 9702 | return gl::error(GL_INVALID_OPERATION); |
| 9703 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9704 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9705 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9706 | { |
| 9707 | return gl::error(GL_INVALID_VALUE); |
| 9708 | } |
| 9709 | |
| 9710 | context->setVertexAttribi(index, v); |
| 9711 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9712 | } |
| 9713 | catch(std::bad_alloc&) |
| 9714 | { |
| 9715 | return gl::error(GL_OUT_OF_MEMORY); |
| 9716 | } |
| 9717 | } |
| 9718 | |
| 9719 | void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v) |
| 9720 | { |
| 9721 | EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v); |
| 9722 | |
| 9723 | try |
| 9724 | { |
| 9725 | gl::Context *context = gl::getNonLostContext(); |
| 9726 | |
| 9727 | if (context) |
| 9728 | { |
| 9729 | if (context->getClientVersion() < 3) |
| 9730 | { |
| 9731 | return gl::error(GL_INVALID_OPERATION); |
| 9732 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9733 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9734 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9735 | { |
| 9736 | return gl::error(GL_INVALID_VALUE); |
| 9737 | } |
| 9738 | |
| 9739 | context->setVertexAttribu(index, v); |
| 9740 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9741 | } |
| 9742 | catch(std::bad_alloc&) |
| 9743 | { |
| 9744 | return gl::error(GL_OUT_OF_MEMORY); |
| 9745 | } |
| 9746 | } |
| 9747 | |
| 9748 | void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) |
| 9749 | { |
| 9750 | EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)", |
| 9751 | program, location, params); |
| 9752 | |
| 9753 | try |
| 9754 | { |
| 9755 | gl::Context *context = gl::getNonLostContext(); |
| 9756 | |
| 9757 | if (context) |
| 9758 | { |
| 9759 | if (context->getClientVersion() < 3) |
| 9760 | { |
| 9761 | return gl::error(GL_INVALID_OPERATION); |
| 9762 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9763 | |
shannon.woods%transgaming.com@gtempaccount.com | e229012 | 2013-04-13 03:41:07 +0000 | [diff] [blame] | 9764 | if (program == 0) |
| 9765 | { |
| 9766 | return gl::error(GL_INVALID_VALUE); |
| 9767 | } |
| 9768 | |
| 9769 | gl::Program *programObject = context->getProgram(program); |
| 9770 | |
| 9771 | if (!programObject || !programObject->isLinked()) |
| 9772 | { |
| 9773 | return gl::error(GL_INVALID_OPERATION); |
| 9774 | } |
| 9775 | |
| 9776 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9777 | if (!programBinary) |
| 9778 | { |
| 9779 | return gl::error(GL_INVALID_OPERATION); |
| 9780 | } |
| 9781 | |
| 9782 | if (!programBinary->getUniformuiv(location, NULL, params)) |
| 9783 | { |
| 9784 | return gl::error(GL_INVALID_OPERATION); |
| 9785 | } |
| 9786 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9787 | } |
| 9788 | catch(std::bad_alloc&) |
| 9789 | { |
| 9790 | return gl::error(GL_OUT_OF_MEMORY); |
| 9791 | } |
| 9792 | } |
| 9793 | |
| 9794 | GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) |
| 9795 | { |
| 9796 | EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)", |
| 9797 | program, name); |
| 9798 | |
| 9799 | try |
| 9800 | { |
| 9801 | gl::Context *context = gl::getNonLostContext(); |
| 9802 | |
| 9803 | if (context) |
| 9804 | { |
| 9805 | if (context->getClientVersion() < 3) |
| 9806 | { |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame^] | 9807 | return gl::error(GL_INVALID_OPERATION, -1); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9808 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9809 | |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame^] | 9810 | if (program == 0) |
| 9811 | { |
| 9812 | return gl::error(GL_INVALID_VALUE, -1); |
| 9813 | } |
| 9814 | |
| 9815 | gl::Program *programObject = context->getProgram(program); |
| 9816 | |
| 9817 | if (!programObject || !programObject->isLinked()) |
| 9818 | { |
| 9819 | return gl::error(GL_INVALID_OPERATION, -1); |
| 9820 | } |
| 9821 | |
| 9822 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9823 | if (!programBinary) |
| 9824 | { |
| 9825 | return gl::error(GL_INVALID_OPERATION, -1); |
| 9826 | } |
| 9827 | |
| 9828 | return programBinary->getFragDataLocation(name); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9829 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9830 | } |
| 9831 | catch(std::bad_alloc&) |
| 9832 | { |
| 9833 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 9834 | } |
| 9835 | |
| 9836 | return 0; |
| 9837 | } |
| 9838 | |
| 9839 | void __stdcall glUniform1ui(GLint location, GLuint v0) |
| 9840 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9841 | glUniform1uiv(location, 1, &v0); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9842 | } |
| 9843 | |
| 9844 | void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1) |
| 9845 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9846 | const GLuint xy[] = { v0, v1 }; |
| 9847 | glUniform2uiv(location, 1, xy); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9848 | } |
| 9849 | |
| 9850 | void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 9851 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9852 | const GLuint xyz[] = { v0, v1, v2 }; |
| 9853 | glUniform3uiv(location, 1, xyz); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9854 | } |
| 9855 | |
| 9856 | void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 9857 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9858 | const GLuint xyzw[] = { v0, v1, v2, v3 }; |
| 9859 | glUniform4uiv(location, 1, xyzw); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9860 | } |
| 9861 | |
| 9862 | void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) |
| 9863 | { |
| 9864 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9865 | location, count, value); |
| 9866 | |
| 9867 | try |
| 9868 | { |
| 9869 | gl::Context *context = gl::getNonLostContext(); |
| 9870 | |
| 9871 | if (context) |
| 9872 | { |
| 9873 | if (context->getClientVersion() < 3) |
| 9874 | { |
| 9875 | return gl::error(GL_INVALID_OPERATION); |
| 9876 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9877 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9878 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9879 | if (!programBinary) |
| 9880 | { |
| 9881 | return gl::error(GL_INVALID_OPERATION); |
| 9882 | } |
| 9883 | |
| 9884 | if (!programBinary->setUniform1uiv(location, count, value)) |
| 9885 | { |
| 9886 | return gl::error(GL_INVALID_OPERATION); |
| 9887 | } |
| 9888 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9889 | } |
| 9890 | catch(std::bad_alloc&) |
| 9891 | { |
| 9892 | return gl::error(GL_OUT_OF_MEMORY); |
| 9893 | } |
| 9894 | } |
| 9895 | |
| 9896 | void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) |
| 9897 | { |
| 9898 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9899 | location, count, value); |
| 9900 | |
| 9901 | try |
| 9902 | { |
| 9903 | gl::Context *context = gl::getNonLostContext(); |
| 9904 | |
| 9905 | if (context) |
| 9906 | { |
| 9907 | if (context->getClientVersion() < 3) |
| 9908 | { |
| 9909 | return gl::error(GL_INVALID_OPERATION); |
| 9910 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9911 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9912 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9913 | if (!programBinary) |
| 9914 | { |
| 9915 | return gl::error(GL_INVALID_OPERATION); |
| 9916 | } |
| 9917 | |
| 9918 | if (!programBinary->setUniform2uiv(location, count, value)) |
| 9919 | { |
| 9920 | return gl::error(GL_INVALID_OPERATION); |
| 9921 | } |
| 9922 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9923 | } |
| 9924 | catch(std::bad_alloc&) |
| 9925 | { |
| 9926 | return gl::error(GL_OUT_OF_MEMORY); |
| 9927 | } |
| 9928 | } |
| 9929 | |
| 9930 | void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) |
| 9931 | { |
| 9932 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)", |
| 9933 | location, count, value); |
| 9934 | |
| 9935 | try |
| 9936 | { |
| 9937 | gl::Context *context = gl::getNonLostContext(); |
| 9938 | |
| 9939 | if (context) |
| 9940 | { |
| 9941 | if (context->getClientVersion() < 3) |
| 9942 | { |
| 9943 | return gl::error(GL_INVALID_OPERATION); |
| 9944 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9945 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9946 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9947 | if (!programBinary) |
| 9948 | { |
| 9949 | return gl::error(GL_INVALID_OPERATION); |
| 9950 | } |
| 9951 | |
| 9952 | if (!programBinary->setUniform3uiv(location, count, value)) |
| 9953 | { |
| 9954 | return gl::error(GL_INVALID_OPERATION); |
| 9955 | } |
| 9956 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9957 | } |
| 9958 | catch(std::bad_alloc&) |
| 9959 | { |
| 9960 | return gl::error(GL_OUT_OF_MEMORY); |
| 9961 | } |
| 9962 | } |
| 9963 | |
| 9964 | void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) |
| 9965 | { |
| 9966 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9967 | location, count, value); |
| 9968 | |
| 9969 | try |
| 9970 | { |
| 9971 | gl::Context *context = gl::getNonLostContext(); |
| 9972 | |
| 9973 | if (context) |
| 9974 | { |
| 9975 | if (context->getClientVersion() < 3) |
| 9976 | { |
| 9977 | return gl::error(GL_INVALID_OPERATION); |
| 9978 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9979 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9980 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9981 | if (!programBinary) |
| 9982 | { |
| 9983 | return gl::error(GL_INVALID_OPERATION); |
| 9984 | } |
| 9985 | |
| 9986 | if (!programBinary->setUniform4uiv(location, count, value)) |
| 9987 | { |
| 9988 | return gl::error(GL_INVALID_OPERATION); |
| 9989 | } |
| 9990 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9991 | } |
| 9992 | catch(std::bad_alloc&) |
| 9993 | { |
| 9994 | return gl::error(GL_OUT_OF_MEMORY); |
| 9995 | } |
| 9996 | } |
| 9997 | |
| 9998 | void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) |
| 9999 | { |
| 10000 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)", |
| 10001 | buffer, drawbuffer, value); |
| 10002 | |
| 10003 | try |
| 10004 | { |
| 10005 | gl::Context *context = gl::getNonLostContext(); |
| 10006 | |
| 10007 | if (context) |
| 10008 | { |
| 10009 | if (context->getClientVersion() < 3) |
| 10010 | { |
| 10011 | return gl::error(GL_INVALID_OPERATION); |
| 10012 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10013 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10014 | UNIMPLEMENTED(); |
| 10015 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10016 | } |
| 10017 | catch(std::bad_alloc&) |
| 10018 | { |
| 10019 | return gl::error(GL_OUT_OF_MEMORY); |
| 10020 | } |
| 10021 | } |
| 10022 | |
| 10023 | void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) |
| 10024 | { |
| 10025 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)", |
| 10026 | buffer, drawbuffer, value); |
| 10027 | |
| 10028 | try |
| 10029 | { |
| 10030 | gl::Context *context = gl::getNonLostContext(); |
| 10031 | |
| 10032 | if (context) |
| 10033 | { |
| 10034 | if (context->getClientVersion() < 3) |
| 10035 | { |
| 10036 | return gl::error(GL_INVALID_OPERATION); |
| 10037 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10038 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10039 | UNIMPLEMENTED(); |
| 10040 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10041 | } |
| 10042 | catch(std::bad_alloc&) |
| 10043 | { |
| 10044 | return gl::error(GL_OUT_OF_MEMORY); |
| 10045 | } |
| 10046 | } |
| 10047 | |
| 10048 | void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) |
| 10049 | { |
| 10050 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)", |
| 10051 | buffer, drawbuffer, value); |
| 10052 | |
| 10053 | try |
| 10054 | { |
| 10055 | gl::Context *context = gl::getNonLostContext(); |
| 10056 | |
| 10057 | if (context) |
| 10058 | { |
| 10059 | if (context->getClientVersion() < 3) |
| 10060 | { |
| 10061 | return gl::error(GL_INVALID_OPERATION); |
| 10062 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10063 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10064 | UNIMPLEMENTED(); |
| 10065 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10066 | } |
| 10067 | catch(std::bad_alloc&) |
| 10068 | { |
| 10069 | return gl::error(GL_OUT_OF_MEMORY); |
| 10070 | } |
| 10071 | } |
| 10072 | |
| 10073 | void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 10074 | { |
| 10075 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)", |
| 10076 | buffer, drawbuffer, depth, stencil); |
| 10077 | |
| 10078 | try |
| 10079 | { |
| 10080 | gl::Context *context = gl::getNonLostContext(); |
| 10081 | |
| 10082 | if (context) |
| 10083 | { |
| 10084 | if (context->getClientVersion() < 3) |
| 10085 | { |
| 10086 | return gl::error(GL_INVALID_OPERATION); |
| 10087 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10088 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10089 | UNIMPLEMENTED(); |
| 10090 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10091 | } |
| 10092 | catch(std::bad_alloc&) |
| 10093 | { |
| 10094 | return gl::error(GL_OUT_OF_MEMORY); |
| 10095 | } |
| 10096 | } |
| 10097 | |
| 10098 | const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) |
| 10099 | { |
| 10100 | EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index); |
| 10101 | |
| 10102 | try |
| 10103 | { |
| 10104 | gl::Context *context = gl::getNonLostContext(); |
| 10105 | |
| 10106 | if (context) |
| 10107 | { |
| 10108 | if (context->getClientVersion() < 3) |
| 10109 | { |
| 10110 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL)); |
| 10111 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10112 | |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 10113 | if (name != GL_EXTENSIONS) |
| 10114 | { |
| 10115 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL)); |
| 10116 | } |
| 10117 | |
| 10118 | if (index >= context->getNumExtensions()) |
| 10119 | { |
| 10120 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL)); |
| 10121 | } |
| 10122 | |
| 10123 | return reinterpret_cast<const GLubyte*>(context->getExtensionString(index)); |
| 10124 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10125 | } |
| 10126 | catch(std::bad_alloc&) |
| 10127 | { |
| 10128 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL)); |
| 10129 | } |
| 10130 | |
| 10131 | return NULL; |
| 10132 | } |
| 10133 | |
| 10134 | void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 10135 | { |
| 10136 | EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)", |
| 10137 | readTarget, writeTarget, readOffset, writeOffset, size); |
| 10138 | |
| 10139 | try |
| 10140 | { |
| 10141 | gl::Context *context = gl::getNonLostContext(); |
| 10142 | |
| 10143 | if (context) |
| 10144 | { |
| 10145 | if (context->getClientVersion() < 3) |
| 10146 | { |
| 10147 | return gl::error(GL_INVALID_OPERATION); |
| 10148 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10149 | |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 10150 | gl::Buffer *readBuffer = NULL; |
| 10151 | switch (readTarget) |
| 10152 | { |
| 10153 | case GL_ARRAY_BUFFER: |
| 10154 | readBuffer = context->getArrayBuffer(); |
| 10155 | break; |
| 10156 | case GL_COPY_READ_BUFFER: |
| 10157 | readBuffer = context->getCopyReadBuffer(); |
| 10158 | break; |
| 10159 | case GL_COPY_WRITE_BUFFER: |
| 10160 | readBuffer = context->getCopyWriteBuffer(); |
| 10161 | break; |
| 10162 | case GL_ELEMENT_ARRAY_BUFFER: |
| 10163 | readBuffer = context->getElementArrayBuffer(); |
| 10164 | break; |
| 10165 | case GL_PIXEL_PACK_BUFFER: |
| 10166 | readBuffer = context->getPixelPackBuffer(); |
| 10167 | break; |
| 10168 | case GL_PIXEL_UNPACK_BUFFER: |
| 10169 | readBuffer = context->getPixelUnpackBuffer(); |
| 10170 | break; |
| 10171 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 10172 | readBuffer = context->getGenericTransformFeedbackBuffer(); |
| 10173 | break; |
| 10174 | case GL_UNIFORM_BUFFER: |
| 10175 | readBuffer = context->getGenericUniformBuffer(); |
| 10176 | break; |
| 10177 | default: |
| 10178 | return gl::error(GL_INVALID_ENUM); |
| 10179 | } |
| 10180 | |
| 10181 | gl::Buffer *writeBuffer = NULL; |
| 10182 | switch (writeTarget) |
| 10183 | { |
| 10184 | case GL_ARRAY_BUFFER: |
| 10185 | writeBuffer = context->getArrayBuffer(); |
| 10186 | break; |
| 10187 | case GL_COPY_READ_BUFFER: |
| 10188 | writeBuffer = context->getCopyReadBuffer(); |
| 10189 | break; |
| 10190 | case GL_COPY_WRITE_BUFFER: |
| 10191 | writeBuffer = context->getCopyWriteBuffer(); |
| 10192 | break; |
| 10193 | case GL_ELEMENT_ARRAY_BUFFER: |
| 10194 | writeBuffer = context->getElementArrayBuffer(); |
| 10195 | break; |
| 10196 | case GL_PIXEL_PACK_BUFFER: |
| 10197 | writeBuffer = context->getPixelPackBuffer(); |
| 10198 | break; |
| 10199 | case GL_PIXEL_UNPACK_BUFFER: |
| 10200 | writeBuffer = context->getPixelUnpackBuffer(); |
| 10201 | break; |
| 10202 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 10203 | writeBuffer = context->getGenericTransformFeedbackBuffer(); |
| 10204 | break; |
| 10205 | case GL_UNIFORM_BUFFER: |
| 10206 | writeBuffer = context->getGenericUniformBuffer(); |
| 10207 | break; |
| 10208 | default: |
| 10209 | return gl::error(GL_INVALID_ENUM); |
| 10210 | } |
| 10211 | |
| 10212 | if (!readBuffer || !writeBuffer) |
| 10213 | { |
| 10214 | return gl::error(GL_INVALID_OPERATION); |
| 10215 | } |
| 10216 | |
| 10217 | if (readOffset < 0 || writeOffset < 0 || size < 0 || |
| 10218 | static_cast<unsigned int>(readOffset + size) > readBuffer->size() || |
| 10219 | static_cast<unsigned int>(writeOffset + size) > writeBuffer->size()) |
| 10220 | { |
| 10221 | return gl::error(GL_INVALID_VALUE); |
| 10222 | } |
| 10223 | |
| 10224 | if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size) |
| 10225 | { |
| 10226 | return gl::error(GL_INVALID_VALUE); |
| 10227 | } |
| 10228 | |
| 10229 | // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION) |
| 10230 | |
shannon.woods%transgaming.com@gtempaccount.com | c53376a | 2013-04-13 03:41:23 +0000 | [diff] [blame] | 10231 | // if size is zero, the copy is a successful no-op |
| 10232 | if (size > 0) |
| 10233 | { |
| 10234 | writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); |
| 10235 | } |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 10236 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10237 | } |
| 10238 | catch(std::bad_alloc&) |
| 10239 | { |
| 10240 | return gl::error(GL_OUT_OF_MEMORY); |
| 10241 | } |
| 10242 | } |
| 10243 | |
| 10244 | void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) |
| 10245 | { |
| 10246 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)", |
| 10247 | program, uniformCount, uniformNames, uniformIndices); |
| 10248 | |
| 10249 | try |
| 10250 | { |
| 10251 | gl::Context *context = gl::getNonLostContext(); |
| 10252 | |
| 10253 | if (context) |
| 10254 | { |
| 10255 | if (context->getClientVersion() < 3) |
| 10256 | { |
| 10257 | return gl::error(GL_INVALID_OPERATION); |
| 10258 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10259 | |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 10260 | if (uniformCount < 0) |
| 10261 | { |
| 10262 | return gl::error(GL_INVALID_VALUE); |
| 10263 | } |
| 10264 | |
| 10265 | gl::Program *programObject = context->getProgram(program); |
| 10266 | |
| 10267 | if (!programObject) |
| 10268 | { |
| 10269 | if (context->getShader(program)) |
| 10270 | { |
| 10271 | return gl::error(GL_INVALID_OPERATION); |
| 10272 | } |
| 10273 | else |
| 10274 | { |
| 10275 | return gl::error(GL_INVALID_VALUE); |
| 10276 | } |
| 10277 | } |
| 10278 | |
| 10279 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10280 | if (!programObject->isLinked() || !programBinary) |
| 10281 | { |
| 10282 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10283 | { |
| 10284 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 10285 | } |
| 10286 | } |
| 10287 | else |
| 10288 | { |
| 10289 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10290 | { |
| 10291 | uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]); |
| 10292 | } |
| 10293 | } |
| 10294 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10295 | } |
| 10296 | catch(std::bad_alloc&) |
| 10297 | { |
| 10298 | return gl::error(GL_OUT_OF_MEMORY); |
| 10299 | } |
| 10300 | } |
| 10301 | |
| 10302 | void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) |
| 10303 | { |
| 10304 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10305 | program, uniformCount, uniformIndices, pname, params); |
| 10306 | |
| 10307 | try |
| 10308 | { |
| 10309 | gl::Context *context = gl::getNonLostContext(); |
| 10310 | |
| 10311 | if (context) |
| 10312 | { |
| 10313 | if (context->getClientVersion() < 3) |
| 10314 | { |
| 10315 | return gl::error(GL_INVALID_OPERATION); |
| 10316 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10317 | |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 10318 | if (uniformCount < 0) |
| 10319 | { |
| 10320 | return gl::error(GL_INVALID_VALUE); |
| 10321 | } |
| 10322 | |
| 10323 | gl::Program *programObject = context->getProgram(program); |
| 10324 | |
| 10325 | if (!programObject) |
| 10326 | { |
| 10327 | if (context->getShader(program)) |
| 10328 | { |
| 10329 | return gl::error(GL_INVALID_OPERATION); |
| 10330 | } |
| 10331 | else |
| 10332 | { |
| 10333 | return gl::error(GL_INVALID_VALUE); |
| 10334 | } |
| 10335 | } |
| 10336 | |
| 10337 | switch (pname) |
| 10338 | { |
| 10339 | case GL_UNIFORM_TYPE: |
| 10340 | case GL_UNIFORM_SIZE: |
| 10341 | case GL_UNIFORM_NAME_LENGTH: |
| 10342 | case GL_UNIFORM_BLOCK_INDEX: |
| 10343 | case GL_UNIFORM_OFFSET: |
| 10344 | case GL_UNIFORM_ARRAY_STRIDE: |
| 10345 | case GL_UNIFORM_MATRIX_STRIDE: |
| 10346 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 10347 | break; |
| 10348 | default: |
| 10349 | return gl::error(GL_INVALID_ENUM); |
| 10350 | } |
| 10351 | |
| 10352 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10353 | |
| 10354 | if (!programBinary && uniformCount > 0) |
| 10355 | { |
| 10356 | return gl::error(GL_INVALID_VALUE); |
| 10357 | } |
| 10358 | |
| 10359 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10360 | { |
| 10361 | const GLuint index = uniformIndices[uniformId]; |
| 10362 | |
| 10363 | if (index >= (GLuint)programBinary->getActiveUniformCount()) |
| 10364 | { |
| 10365 | return gl::error(GL_INVALID_VALUE); |
| 10366 | } |
| 10367 | } |
| 10368 | |
| 10369 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10370 | { |
| 10371 | const GLuint index = uniformIndices[uniformId]; |
| 10372 | params[uniformId] = programBinary->getActiveUniformi(index, pname); |
| 10373 | } |
| 10374 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10375 | } |
| 10376 | catch(std::bad_alloc&) |
| 10377 | { |
| 10378 | return gl::error(GL_OUT_OF_MEMORY); |
| 10379 | } |
| 10380 | } |
| 10381 | |
| 10382 | GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) |
| 10383 | { |
| 10384 | EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName); |
| 10385 | |
| 10386 | try |
| 10387 | { |
| 10388 | gl::Context *context = gl::getNonLostContext(); |
| 10389 | |
| 10390 | if (context) |
| 10391 | { |
| 10392 | if (context->getClientVersion() < 3) |
| 10393 | { |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10394 | 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] | 10395 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10396 | |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10397 | gl::Program *programObject = context->getProgram(program); |
| 10398 | |
| 10399 | if (!programObject) |
| 10400 | { |
| 10401 | if (context->getShader(program)) |
| 10402 | { |
| 10403 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
| 10404 | } |
| 10405 | else |
| 10406 | { |
| 10407 | return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX); |
| 10408 | } |
| 10409 | } |
| 10410 | |
| 10411 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10412 | if (!programBinary) |
| 10413 | { |
| 10414 | return GL_INVALID_INDEX; |
| 10415 | } |
| 10416 | |
| 10417 | return programBinary->getUniformBlockIndex(uniformBlockName); |
| 10418 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10419 | } |
| 10420 | catch(std::bad_alloc&) |
| 10421 | { |
| 10422 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10423 | } |
| 10424 | |
| 10425 | return 0; |
| 10426 | } |
| 10427 | |
| 10428 | void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) |
| 10429 | { |
| 10430 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10431 | program, uniformBlockIndex, pname, params); |
| 10432 | |
| 10433 | try |
| 10434 | { |
| 10435 | gl::Context *context = gl::getNonLostContext(); |
| 10436 | |
| 10437 | if (context) |
| 10438 | { |
| 10439 | if (context->getClientVersion() < 3) |
| 10440 | { |
| 10441 | return gl::error(GL_INVALID_OPERATION); |
| 10442 | } |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10443 | gl::Program *programObject = context->getProgram(program); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10444 | |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10445 | if (!programObject) |
| 10446 | { |
| 10447 | if (context->getShader(program)) |
| 10448 | { |
| 10449 | return gl::error(GL_INVALID_OPERATION); |
| 10450 | } |
| 10451 | else |
| 10452 | { |
| 10453 | return gl::error(GL_INVALID_VALUE); |
| 10454 | } |
| 10455 | } |
| 10456 | |
| 10457 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10458 | |
| 10459 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10460 | { |
| 10461 | return gl::error(GL_INVALID_VALUE); |
| 10462 | } |
| 10463 | |
| 10464 | switch (pname) |
| 10465 | { |
| 10466 | case GL_UNIFORM_BLOCK_BINDING: |
| 10467 | *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); |
| 10468 | break; |
| 10469 | |
| 10470 | case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 10471 | case GL_UNIFORM_BLOCK_NAME_LENGTH: |
| 10472 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 10473 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| 10474 | case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
| 10475 | case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
| 10476 | programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params); |
| 10477 | break; |
| 10478 | |
| 10479 | default: |
| 10480 | return gl::error(GL_INVALID_ENUM); |
| 10481 | } |
| 10482 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10483 | } |
| 10484 | catch(std::bad_alloc&) |
| 10485 | { |
| 10486 | return gl::error(GL_OUT_OF_MEMORY); |
| 10487 | } |
| 10488 | } |
| 10489 | |
| 10490 | void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) |
| 10491 | { |
| 10492 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)", |
| 10493 | program, uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10494 | |
| 10495 | try |
| 10496 | { |
| 10497 | gl::Context *context = gl::getNonLostContext(); |
| 10498 | |
| 10499 | if (context) |
| 10500 | { |
| 10501 | if (context->getClientVersion() < 3) |
| 10502 | { |
| 10503 | return gl::error(GL_INVALID_OPERATION); |
| 10504 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10505 | |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 10506 | gl::Program *programObject = context->getProgram(program); |
| 10507 | |
| 10508 | if (!programObject) |
| 10509 | { |
| 10510 | if (context->getShader(program)) |
| 10511 | { |
| 10512 | return gl::error(GL_INVALID_OPERATION); |
| 10513 | } |
| 10514 | else |
| 10515 | { |
| 10516 | return gl::error(GL_INVALID_VALUE); |
| 10517 | } |
| 10518 | } |
| 10519 | |
| 10520 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10521 | |
| 10522 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10523 | { |
| 10524 | return gl::error(GL_INVALID_VALUE); |
| 10525 | } |
| 10526 | |
| 10527 | programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10528 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10529 | } |
| 10530 | catch(std::bad_alloc&) |
| 10531 | { |
| 10532 | return gl::error(GL_OUT_OF_MEMORY); |
| 10533 | } |
| 10534 | } |
| 10535 | |
| 10536 | void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) |
| 10537 | { |
| 10538 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)", |
| 10539 | program, uniformBlockIndex, uniformBlockBinding); |
| 10540 | |
| 10541 | try |
| 10542 | { |
| 10543 | gl::Context *context = gl::getNonLostContext(); |
| 10544 | |
| 10545 | if (context) |
| 10546 | { |
| 10547 | if (context->getClientVersion() < 3) |
| 10548 | { |
| 10549 | return gl::error(GL_INVALID_OPERATION); |
| 10550 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10551 | |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 10552 | if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings()) |
| 10553 | { |
| 10554 | return gl::error(GL_INVALID_VALUE); |
| 10555 | } |
| 10556 | |
| 10557 | gl::Program *programObject = context->getProgram(program); |
| 10558 | |
| 10559 | if (!programObject) |
| 10560 | { |
| 10561 | if (context->getShader(program)) |
| 10562 | { |
| 10563 | return gl::error(GL_INVALID_OPERATION); |
| 10564 | } |
| 10565 | else |
| 10566 | { |
| 10567 | return gl::error(GL_INVALID_VALUE); |
| 10568 | } |
| 10569 | } |
| 10570 | |
| 10571 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10572 | |
| 10573 | // if never linked, there won't be any uniform blocks |
| 10574 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10575 | { |
| 10576 | return gl::error(GL_INVALID_VALUE); |
| 10577 | } |
| 10578 | |
| 10579 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
| 10580 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10581 | } |
| 10582 | catch(std::bad_alloc&) |
| 10583 | { |
| 10584 | return gl::error(GL_OUT_OF_MEMORY); |
| 10585 | } |
| 10586 | } |
| 10587 | |
| 10588 | void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 10589 | { |
| 10590 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)", |
| 10591 | mode, first, count, instanceCount); |
| 10592 | |
| 10593 | try |
| 10594 | { |
| 10595 | gl::Context *context = gl::getNonLostContext(); |
| 10596 | |
| 10597 | if (context) |
| 10598 | { |
| 10599 | if (context->getClientVersion() < 3) |
| 10600 | { |
| 10601 | return gl::error(GL_INVALID_OPERATION); |
| 10602 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10603 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10604 | UNIMPLEMENTED(); |
| 10605 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10606 | } |
| 10607 | catch(std::bad_alloc&) |
| 10608 | { |
| 10609 | return gl::error(GL_OUT_OF_MEMORY); |
| 10610 | } |
| 10611 | } |
| 10612 | |
| 10613 | void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) |
| 10614 | { |
| 10615 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)", |
| 10616 | mode, count, type, indices, instanceCount); |
| 10617 | |
| 10618 | try |
| 10619 | { |
| 10620 | gl::Context *context = gl::getNonLostContext(); |
| 10621 | |
| 10622 | if (context) |
| 10623 | { |
| 10624 | if (context->getClientVersion() < 3) |
| 10625 | { |
| 10626 | return gl::error(GL_INVALID_OPERATION); |
| 10627 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10628 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10629 | UNIMPLEMENTED(); |
| 10630 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10631 | } |
| 10632 | catch(std::bad_alloc&) |
| 10633 | { |
| 10634 | return gl::error(GL_OUT_OF_MEMORY); |
| 10635 | } |
| 10636 | } |
| 10637 | |
| 10638 | GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags) |
| 10639 | { |
| 10640 | EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags); |
| 10641 | |
| 10642 | try |
| 10643 | { |
| 10644 | gl::Context *context = gl::getNonLostContext(); |
| 10645 | |
| 10646 | if (context) |
| 10647 | { |
| 10648 | if (context->getClientVersion() < 3) |
| 10649 | { |
| 10650 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(NULL)); |
| 10651 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10652 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10653 | UNIMPLEMENTED(); |
| 10654 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10655 | } |
| 10656 | catch(std::bad_alloc&) |
| 10657 | { |
| 10658 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL)); |
| 10659 | } |
| 10660 | |
| 10661 | return NULL; |
| 10662 | } |
| 10663 | |
| 10664 | GLboolean __stdcall glIsSync(GLsync sync) |
| 10665 | { |
| 10666 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10667 | |
| 10668 | try |
| 10669 | { |
| 10670 | gl::Context *context = gl::getNonLostContext(); |
| 10671 | |
| 10672 | if (context) |
| 10673 | { |
| 10674 | if (context->getClientVersion() < 3) |
| 10675 | { |
| 10676 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10677 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10678 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10679 | UNIMPLEMENTED(); |
| 10680 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10681 | } |
| 10682 | catch(std::bad_alloc&) |
| 10683 | { |
| 10684 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10685 | } |
| 10686 | |
| 10687 | return GL_FALSE; |
| 10688 | } |
| 10689 | |
| 10690 | void __stdcall glDeleteSync(GLsync sync) |
| 10691 | { |
| 10692 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10693 | |
| 10694 | try |
| 10695 | { |
| 10696 | gl::Context *context = gl::getNonLostContext(); |
| 10697 | |
| 10698 | if (context) |
| 10699 | { |
| 10700 | if (context->getClientVersion() < 3) |
| 10701 | { |
| 10702 | return gl::error(GL_INVALID_OPERATION); |
| 10703 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10704 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10705 | UNIMPLEMENTED(); |
| 10706 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10707 | } |
| 10708 | catch(std::bad_alloc&) |
| 10709 | { |
| 10710 | return gl::error(GL_OUT_OF_MEMORY); |
| 10711 | } |
| 10712 | } |
| 10713 | |
| 10714 | GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10715 | { |
| 10716 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10717 | sync, flags, timeout); |
| 10718 | |
| 10719 | try |
| 10720 | { |
| 10721 | gl::Context *context = gl::getNonLostContext(); |
| 10722 | |
| 10723 | if (context) |
| 10724 | { |
| 10725 | if (context->getClientVersion() < 3) |
| 10726 | { |
| 10727 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10728 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10729 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10730 | UNIMPLEMENTED(); |
| 10731 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10732 | } |
| 10733 | catch(std::bad_alloc&) |
| 10734 | { |
| 10735 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10736 | } |
| 10737 | |
| 10738 | return GL_FALSE; |
| 10739 | } |
| 10740 | |
| 10741 | void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10742 | { |
| 10743 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10744 | sync, flags, timeout); |
| 10745 | |
| 10746 | try |
| 10747 | { |
| 10748 | gl::Context *context = gl::getNonLostContext(); |
| 10749 | |
| 10750 | if (context) |
| 10751 | { |
| 10752 | if (context->getClientVersion() < 3) |
| 10753 | { |
| 10754 | return gl::error(GL_INVALID_OPERATION); |
| 10755 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10756 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10757 | UNIMPLEMENTED(); |
| 10758 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10759 | } |
| 10760 | catch(std::bad_alloc&) |
| 10761 | { |
| 10762 | return gl::error(GL_OUT_OF_MEMORY); |
| 10763 | } |
| 10764 | } |
| 10765 | |
| 10766 | void __stdcall glGetInteger64v(GLenum pname, GLint64* params) |
| 10767 | { |
| 10768 | EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10769 | pname, params); |
| 10770 | |
| 10771 | try |
| 10772 | { |
| 10773 | gl::Context *context = gl::getNonLostContext(); |
| 10774 | |
| 10775 | if (context) |
| 10776 | { |
| 10777 | if (context->getClientVersion() < 3) |
| 10778 | { |
| 10779 | return gl::error(GL_INVALID_OPERATION); |
| 10780 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10781 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10782 | UNIMPLEMENTED(); |
| 10783 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10784 | } |
| 10785 | catch(std::bad_alloc&) |
| 10786 | { |
| 10787 | return gl::error(GL_OUT_OF_MEMORY); |
| 10788 | } |
| 10789 | } |
| 10790 | |
| 10791 | void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) |
| 10792 | { |
| 10793 | EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)", |
| 10794 | sync, pname, bufSize, length, values); |
| 10795 | |
| 10796 | try |
| 10797 | { |
| 10798 | gl::Context *context = gl::getNonLostContext(); |
| 10799 | |
| 10800 | if (context) |
| 10801 | { |
| 10802 | if (context->getClientVersion() < 3) |
| 10803 | { |
| 10804 | return gl::error(GL_INVALID_OPERATION); |
| 10805 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10806 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10807 | UNIMPLEMENTED(); |
| 10808 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10809 | } |
| 10810 | catch(std::bad_alloc&) |
| 10811 | { |
| 10812 | return gl::error(GL_OUT_OF_MEMORY); |
| 10813 | } |
| 10814 | } |
| 10815 | |
| 10816 | void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) |
| 10817 | { |
| 10818 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)", |
| 10819 | target, index, data); |
| 10820 | |
| 10821 | try |
| 10822 | { |
| 10823 | gl::Context *context = gl::getNonLostContext(); |
| 10824 | |
| 10825 | if (context) |
| 10826 | { |
| 10827 | if (context->getClientVersion() < 3) |
| 10828 | { |
| 10829 | return gl::error(GL_INVALID_OPERATION); |
| 10830 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10831 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10832 | UNIMPLEMENTED(); |
| 10833 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10834 | } |
| 10835 | catch(std::bad_alloc&) |
| 10836 | { |
| 10837 | return gl::error(GL_OUT_OF_MEMORY); |
| 10838 | } |
| 10839 | } |
| 10840 | |
| 10841 | void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) |
| 10842 | { |
| 10843 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10844 | target, pname, params); |
| 10845 | |
| 10846 | try |
| 10847 | { |
| 10848 | gl::Context *context = gl::getNonLostContext(); |
| 10849 | |
| 10850 | if (context) |
| 10851 | { |
| 10852 | if (context->getClientVersion() < 3) |
| 10853 | { |
| 10854 | return gl::error(GL_INVALID_OPERATION); |
| 10855 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10856 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10857 | UNIMPLEMENTED(); |
| 10858 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10859 | } |
| 10860 | catch(std::bad_alloc&) |
| 10861 | { |
| 10862 | return gl::error(GL_OUT_OF_MEMORY); |
| 10863 | } |
| 10864 | } |
| 10865 | |
| 10866 | void __stdcall glGenSamplers(GLsizei count, GLuint* samplers) |
| 10867 | { |
| 10868 | EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers); |
| 10869 | |
| 10870 | try |
| 10871 | { |
| 10872 | gl::Context *context = gl::getNonLostContext(); |
| 10873 | |
| 10874 | if (context) |
| 10875 | { |
| 10876 | if (context->getClientVersion() < 3) |
| 10877 | { |
| 10878 | return gl::error(GL_INVALID_OPERATION); |
| 10879 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10880 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10881 | UNIMPLEMENTED(); |
| 10882 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10883 | } |
| 10884 | catch(std::bad_alloc&) |
| 10885 | { |
| 10886 | return gl::error(GL_OUT_OF_MEMORY); |
| 10887 | } |
| 10888 | } |
| 10889 | |
| 10890 | void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers) |
| 10891 | { |
| 10892 | EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers); |
| 10893 | |
| 10894 | try |
| 10895 | { |
| 10896 | gl::Context *context = gl::getNonLostContext(); |
| 10897 | |
| 10898 | if (context) |
| 10899 | { |
| 10900 | if (context->getClientVersion() < 3) |
| 10901 | { |
| 10902 | return gl::error(GL_INVALID_OPERATION); |
| 10903 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10904 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10905 | UNIMPLEMENTED(); |
| 10906 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10907 | } |
| 10908 | catch(std::bad_alloc&) |
| 10909 | { |
| 10910 | return gl::error(GL_OUT_OF_MEMORY); |
| 10911 | } |
| 10912 | } |
| 10913 | |
| 10914 | GLboolean __stdcall glIsSampler(GLuint sampler) |
| 10915 | { |
| 10916 | EVENT("(GLuint sampler = %u)", sampler); |
| 10917 | |
| 10918 | try |
| 10919 | { |
| 10920 | gl::Context *context = gl::getNonLostContext(); |
| 10921 | |
| 10922 | if (context) |
| 10923 | { |
| 10924 | if (context->getClientVersion() < 3) |
| 10925 | { |
| 10926 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10927 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10928 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10929 | UNIMPLEMENTED(); |
| 10930 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10931 | } |
| 10932 | catch(std::bad_alloc&) |
| 10933 | { |
| 10934 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10935 | } |
| 10936 | |
| 10937 | return GL_FALSE; |
| 10938 | } |
| 10939 | |
| 10940 | void __stdcall glBindSampler(GLuint unit, GLuint sampler) |
| 10941 | { |
| 10942 | EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler); |
| 10943 | |
| 10944 | try |
| 10945 | { |
| 10946 | gl::Context *context = gl::getNonLostContext(); |
| 10947 | |
| 10948 | if (context) |
| 10949 | { |
| 10950 | if (context->getClientVersion() < 3) |
| 10951 | { |
| 10952 | return gl::error(GL_INVALID_OPERATION); |
| 10953 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10954 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10955 | UNIMPLEMENTED(); |
| 10956 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10957 | } |
| 10958 | catch(std::bad_alloc&) |
| 10959 | { |
| 10960 | return gl::error(GL_OUT_OF_MEMORY); |
| 10961 | } |
| 10962 | } |
| 10963 | |
| 10964 | void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 10965 | { |
| 10966 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param); |
| 10967 | |
| 10968 | try |
| 10969 | { |
| 10970 | gl::Context *context = gl::getNonLostContext(); |
| 10971 | |
| 10972 | if (context) |
| 10973 | { |
| 10974 | if (context->getClientVersion() < 3) |
| 10975 | { |
| 10976 | return gl::error(GL_INVALID_OPERATION); |
| 10977 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10978 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10979 | UNIMPLEMENTED(); |
| 10980 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10981 | } |
| 10982 | catch(std::bad_alloc&) |
| 10983 | { |
| 10984 | return gl::error(GL_OUT_OF_MEMORY); |
| 10985 | } |
| 10986 | } |
| 10987 | |
| 10988 | void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) |
| 10989 | { |
| 10990 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLint* param = 0x%0.8p)", |
| 10991 | sampler, pname, param); |
| 10992 | |
| 10993 | try |
| 10994 | { |
| 10995 | gl::Context *context = gl::getNonLostContext(); |
| 10996 | |
| 10997 | if (context) |
| 10998 | { |
| 10999 | if (context->getClientVersion() < 3) |
| 11000 | { |
| 11001 | return gl::error(GL_INVALID_OPERATION); |
| 11002 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11003 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11004 | UNIMPLEMENTED(); |
| 11005 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11006 | } |
| 11007 | catch(std::bad_alloc&) |
| 11008 | { |
| 11009 | return gl::error(GL_OUT_OF_MEMORY); |
| 11010 | } |
| 11011 | } |
| 11012 | |
| 11013 | void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 11014 | { |
| 11015 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param); |
| 11016 | |
| 11017 | try |
| 11018 | { |
| 11019 | gl::Context *context = gl::getNonLostContext(); |
| 11020 | |
| 11021 | if (context) |
| 11022 | { |
| 11023 | if (context->getClientVersion() < 3) |
| 11024 | { |
| 11025 | return gl::error(GL_INVALID_OPERATION); |
| 11026 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11027 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11028 | UNIMPLEMENTED(); |
| 11029 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11030 | } |
| 11031 | catch(std::bad_alloc&) |
| 11032 | { |
| 11033 | return gl::error(GL_OUT_OF_MEMORY); |
| 11034 | } |
| 11035 | } |
| 11036 | |
| 11037 | void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) |
| 11038 | { |
| 11039 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLfloat* param = 0x%0.8p)", sampler, pname, param); |
| 11040 | |
| 11041 | try |
| 11042 | { |
| 11043 | gl::Context *context = gl::getNonLostContext(); |
| 11044 | |
| 11045 | if (context) |
| 11046 | { |
| 11047 | if (context->getClientVersion() < 3) |
| 11048 | { |
| 11049 | return gl::error(GL_INVALID_OPERATION); |
| 11050 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11051 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11052 | UNIMPLEMENTED(); |
| 11053 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11054 | } |
| 11055 | catch(std::bad_alloc&) |
| 11056 | { |
| 11057 | return gl::error(GL_OUT_OF_MEMORY); |
| 11058 | } |
| 11059 | } |
| 11060 | |
| 11061 | void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) |
| 11062 | { |
| 11063 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); |
| 11064 | |
| 11065 | try |
| 11066 | { |
| 11067 | gl::Context *context = gl::getNonLostContext(); |
| 11068 | |
| 11069 | if (context) |
| 11070 | { |
| 11071 | if (context->getClientVersion() < 3) |
| 11072 | { |
| 11073 | return gl::error(GL_INVALID_OPERATION); |
| 11074 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11075 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11076 | UNIMPLEMENTED(); |
| 11077 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11078 | } |
| 11079 | catch(std::bad_alloc&) |
| 11080 | { |
| 11081 | return gl::error(GL_OUT_OF_MEMORY); |
| 11082 | } |
| 11083 | } |
| 11084 | |
| 11085 | void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) |
| 11086 | { |
| 11087 | EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params); |
| 11088 | |
| 11089 | try |
| 11090 | { |
| 11091 | gl::Context *context = gl::getNonLostContext(); |
| 11092 | |
| 11093 | if (context) |
| 11094 | { |
| 11095 | if (context->getClientVersion() < 3) |
| 11096 | { |
| 11097 | return gl::error(GL_INVALID_OPERATION); |
| 11098 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11099 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11100 | UNIMPLEMENTED(); |
| 11101 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11102 | } |
| 11103 | catch(std::bad_alloc&) |
| 11104 | { |
| 11105 | return gl::error(GL_OUT_OF_MEMORY); |
| 11106 | } |
| 11107 | } |
| 11108 | |
| 11109 | void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor) |
| 11110 | { |
| 11111 | EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor); |
| 11112 | |
| 11113 | try |
| 11114 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 11115 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 11116 | { |
| 11117 | return gl::error(GL_INVALID_VALUE); |
| 11118 | } |
| 11119 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11120 | gl::Context *context = gl::getNonLostContext(); |
| 11121 | |
| 11122 | if (context) |
| 11123 | { |
| 11124 | if (context->getClientVersion() < 3) |
| 11125 | { |
| 11126 | return gl::error(GL_INVALID_OPERATION); |
| 11127 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11128 | |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 11129 | context->setVertexAttribDivisor(index, divisor); |
| 11130 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11131 | } |
| 11132 | catch(std::bad_alloc&) |
| 11133 | { |
| 11134 | return gl::error(GL_OUT_OF_MEMORY); |
| 11135 | } |
| 11136 | } |
| 11137 | |
| 11138 | void __stdcall glBindTransformFeedback(GLenum target, GLuint id) |
| 11139 | { |
| 11140 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 11141 | |
| 11142 | try |
| 11143 | { |
| 11144 | gl::Context *context = gl::getNonLostContext(); |
| 11145 | |
| 11146 | if (context) |
| 11147 | { |
| 11148 | if (context->getClientVersion() < 3) |
| 11149 | { |
| 11150 | return gl::error(GL_INVALID_OPERATION); |
| 11151 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11152 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11153 | UNIMPLEMENTED(); |
| 11154 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11155 | } |
| 11156 | catch(std::bad_alloc&) |
| 11157 | { |
| 11158 | return gl::error(GL_OUT_OF_MEMORY); |
| 11159 | } |
| 11160 | } |
| 11161 | |
| 11162 | void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) |
| 11163 | { |
| 11164 | EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids); |
| 11165 | |
| 11166 | try |
| 11167 | { |
| 11168 | gl::Context *context = gl::getNonLostContext(); |
| 11169 | |
| 11170 | if (context) |
| 11171 | { |
| 11172 | if (context->getClientVersion() < 3) |
| 11173 | { |
| 11174 | return gl::error(GL_INVALID_OPERATION); |
| 11175 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11176 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11177 | UNIMPLEMENTED(); |
| 11178 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11179 | } |
| 11180 | catch(std::bad_alloc&) |
| 11181 | { |
| 11182 | return gl::error(GL_OUT_OF_MEMORY); |
| 11183 | } |
| 11184 | } |
| 11185 | |
| 11186 | void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids) |
| 11187 | { |
| 11188 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 11189 | |
| 11190 | try |
| 11191 | { |
| 11192 | gl::Context *context = gl::getNonLostContext(); |
| 11193 | |
| 11194 | if (context) |
| 11195 | { |
| 11196 | if (context->getClientVersion() < 3) |
| 11197 | { |
| 11198 | return gl::error(GL_INVALID_OPERATION); |
| 11199 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11200 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11201 | UNIMPLEMENTED(); |
| 11202 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11203 | } |
| 11204 | catch(std::bad_alloc&) |
| 11205 | { |
| 11206 | return gl::error(GL_OUT_OF_MEMORY); |
| 11207 | } |
| 11208 | } |
| 11209 | |
| 11210 | GLboolean __stdcall glIsTransformFeedback(GLuint id) |
| 11211 | { |
| 11212 | EVENT("(GLuint id = %u)", id); |
| 11213 | |
| 11214 | try |
| 11215 | { |
| 11216 | gl::Context *context = gl::getNonLostContext(); |
| 11217 | |
| 11218 | if (context) |
| 11219 | { |
| 11220 | if (context->getClientVersion() < 3) |
| 11221 | { |
| 11222 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 11223 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11224 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11225 | UNIMPLEMENTED(); |
| 11226 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11227 | } |
| 11228 | catch(std::bad_alloc&) |
| 11229 | { |
| 11230 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 11231 | } |
| 11232 | |
| 11233 | return GL_FALSE; |
| 11234 | } |
| 11235 | |
| 11236 | void __stdcall glPauseTransformFeedback(void) |
| 11237 | { |
| 11238 | EVENT("(void)"); |
| 11239 | |
| 11240 | try |
| 11241 | { |
| 11242 | gl::Context *context = gl::getNonLostContext(); |
| 11243 | |
| 11244 | if (context) |
| 11245 | { |
| 11246 | if (context->getClientVersion() < 3) |
| 11247 | { |
| 11248 | return gl::error(GL_INVALID_OPERATION); |
| 11249 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11250 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11251 | UNIMPLEMENTED(); |
| 11252 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11253 | } |
| 11254 | catch(std::bad_alloc&) |
| 11255 | { |
| 11256 | return gl::error(GL_OUT_OF_MEMORY); |
| 11257 | } |
| 11258 | } |
| 11259 | |
| 11260 | void __stdcall glResumeTransformFeedback(void) |
| 11261 | { |
| 11262 | EVENT("(void)"); |
| 11263 | |
| 11264 | try |
| 11265 | { |
| 11266 | gl::Context *context = gl::getNonLostContext(); |
| 11267 | |
| 11268 | if (context) |
| 11269 | { |
| 11270 | if (context->getClientVersion() < 3) |
| 11271 | { |
| 11272 | return gl::error(GL_INVALID_OPERATION); |
| 11273 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11274 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11275 | UNIMPLEMENTED(); |
| 11276 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11277 | } |
| 11278 | catch(std::bad_alloc&) |
| 11279 | { |
| 11280 | return gl::error(GL_OUT_OF_MEMORY); |
| 11281 | } |
| 11282 | } |
| 11283 | |
| 11284 | void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) |
| 11285 | { |
| 11286 | EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)", |
| 11287 | program, bufSize, length, binaryFormat, binary); |
| 11288 | |
| 11289 | try |
| 11290 | { |
| 11291 | gl::Context *context = gl::getNonLostContext(); |
| 11292 | |
| 11293 | if (context) |
| 11294 | { |
| 11295 | if (context->getClientVersion() < 3) |
| 11296 | { |
| 11297 | return gl::error(GL_INVALID_OPERATION); |
| 11298 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11299 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11300 | UNIMPLEMENTED(); |
| 11301 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11302 | } |
| 11303 | catch(std::bad_alloc&) |
| 11304 | { |
| 11305 | return gl::error(GL_OUT_OF_MEMORY); |
| 11306 | } |
| 11307 | } |
| 11308 | |
| 11309 | void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) |
| 11310 | { |
| 11311 | EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
| 11312 | program, binaryFormat, binary, length); |
| 11313 | |
| 11314 | try |
| 11315 | { |
| 11316 | gl::Context *context = gl::getNonLostContext(); |
| 11317 | |
| 11318 | if (context) |
| 11319 | { |
| 11320 | if (context->getClientVersion() < 3) |
| 11321 | { |
| 11322 | return gl::error(GL_INVALID_OPERATION); |
| 11323 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11324 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11325 | UNIMPLEMENTED(); |
| 11326 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11327 | } |
| 11328 | catch(std::bad_alloc&) |
| 11329 | { |
| 11330 | return gl::error(GL_OUT_OF_MEMORY); |
| 11331 | } |
| 11332 | } |
| 11333 | |
| 11334 | void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value) |
| 11335 | { |
| 11336 | EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)", |
| 11337 | program, pname, value); |
| 11338 | |
| 11339 | try |
| 11340 | { |
| 11341 | gl::Context *context = gl::getNonLostContext(); |
| 11342 | |
| 11343 | if (context) |
| 11344 | { |
| 11345 | if (context->getClientVersion() < 3) |
| 11346 | { |
| 11347 | return gl::error(GL_INVALID_OPERATION); |
| 11348 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11349 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11350 | UNIMPLEMENTED(); |
| 11351 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11352 | } |
| 11353 | catch(std::bad_alloc&) |
| 11354 | { |
| 11355 | return gl::error(GL_OUT_OF_MEMORY); |
| 11356 | } |
| 11357 | } |
| 11358 | |
| 11359 | void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) |
| 11360 | { |
| 11361 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)", |
| 11362 | target, numAttachments, attachments); |
| 11363 | |
| 11364 | try |
| 11365 | { |
| 11366 | gl::Context *context = gl::getNonLostContext(); |
| 11367 | |
| 11368 | if (context) |
| 11369 | { |
| 11370 | if (context->getClientVersion() < 3) |
| 11371 | { |
| 11372 | return gl::error(GL_INVALID_OPERATION); |
| 11373 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11374 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11375 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11376 | { |
| 11377 | return; |
| 11378 | } |
| 11379 | |
| 11380 | int maxDimension = context->getMaximumRenderbufferDimension(); |
| 11381 | context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension); |
| 11382 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11383 | } |
| 11384 | catch(std::bad_alloc&) |
| 11385 | { |
| 11386 | return gl::error(GL_OUT_OF_MEMORY); |
| 11387 | } |
| 11388 | } |
| 11389 | |
| 11390 | void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) |
| 11391 | { |
| 11392 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, " |
| 11393 | "GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 11394 | target, numAttachments, attachments, x, y, width, height); |
| 11395 | |
| 11396 | try |
| 11397 | { |
| 11398 | gl::Context *context = gl::getNonLostContext(); |
| 11399 | |
| 11400 | if (context) |
| 11401 | { |
| 11402 | if (context->getClientVersion() < 3) |
| 11403 | { |
| 11404 | return gl::error(GL_INVALID_OPERATION); |
| 11405 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11406 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11407 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11408 | { |
| 11409 | return; |
| 11410 | } |
| 11411 | |
| 11412 | context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height); |
| 11413 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11414 | } |
| 11415 | catch(std::bad_alloc&) |
| 11416 | { |
| 11417 | return gl::error(GL_OUT_OF_MEMORY); |
| 11418 | } |
| 11419 | } |
| 11420 | |
| 11421 | void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 11422 | { |
| 11423 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 11424 | target, levels, internalformat, width, height); |
| 11425 | |
| 11426 | try |
| 11427 | { |
| 11428 | gl::Context *context = gl::getNonLostContext(); |
| 11429 | |
| 11430 | if (context) |
| 11431 | { |
| 11432 | if (context->getClientVersion() < 3) |
| 11433 | { |
| 11434 | return gl::error(GL_INVALID_OPERATION); |
| 11435 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11436 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11437 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 11438 | { |
| 11439 | return; |
| 11440 | } |
| 11441 | |
| 11442 | switch (target) |
| 11443 | { |
| 11444 | case GL_TEXTURE_2D: |
| 11445 | { |
| 11446 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 11447 | texture2d->storage(levels, internalformat, width, height); |
| 11448 | } |
| 11449 | break; |
| 11450 | |
| 11451 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 11452 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 11453 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 11454 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 11455 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 11456 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 11457 | { |
| 11458 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 11459 | textureCube->storage(levels, internalformat, width); |
| 11460 | } |
| 11461 | break; |
| 11462 | |
| 11463 | default: |
| 11464 | return gl::error(GL_INVALID_ENUM); |
| 11465 | } |
| 11466 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11467 | } |
| 11468 | catch(std::bad_alloc&) |
| 11469 | { |
| 11470 | return gl::error(GL_OUT_OF_MEMORY); |
| 11471 | } |
| 11472 | } |
| 11473 | |
| 11474 | void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
| 11475 | { |
| 11476 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 11477 | "GLsizei height = %d, GLsizei depth = %d)", |
| 11478 | target, levels, internalformat, width, height, depth); |
| 11479 | |
| 11480 | try |
| 11481 | { |
| 11482 | gl::Context *context = gl::getNonLostContext(); |
| 11483 | |
| 11484 | if (context) |
| 11485 | { |
| 11486 | if (context->getClientVersion() < 3) |
| 11487 | { |
| 11488 | return gl::error(GL_INVALID_OPERATION); |
| 11489 | } |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11490 | |
| 11491 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) |
| 11492 | { |
| 11493 | return; |
| 11494 | } |
| 11495 | |
| 11496 | switch (target) |
| 11497 | { |
| 11498 | case GL_TEXTURE_3D: |
| 11499 | { |
| 11500 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 11501 | texture3d->storage(levels, internalformat, width, height, depth); |
| 11502 | } |
| 11503 | break; |
| 11504 | |
| 11505 | case GL_TEXTURE_2D_ARRAY: |
| 11506 | { |
| 11507 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 11508 | texture2darray->storage(levels, internalformat, width, height, depth); |
| 11509 | } |
| 11510 | break; |
| 11511 | |
| 11512 | default: |
| 11513 | return gl::error(GL_INVALID_ENUM); |
| 11514 | } |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 11515 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11516 | } |
| 11517 | catch(std::bad_alloc&) |
| 11518 | { |
| 11519 | return gl::error(GL_OUT_OF_MEMORY); |
| 11520 | } |
| 11521 | } |
| 11522 | |
| 11523 | void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) |
| 11524 | { |
| 11525 | EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, " |
| 11526 | "GLint* params = 0x%0.8p)", |
| 11527 | target, internalformat, pname, bufSize, params); |
| 11528 | |
| 11529 | try |
| 11530 | { |
| 11531 | gl::Context *context = gl::getNonLostContext(); |
| 11532 | |
| 11533 | if (context) |
| 11534 | { |
| 11535 | if (context->getClientVersion() < 3) |
| 11536 | { |
| 11537 | return gl::error(GL_INVALID_OPERATION); |
| 11538 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11539 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11540 | UNIMPLEMENTED(); |
| 11541 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11542 | } |
| 11543 | catch(std::bad_alloc&) |
| 11544 | { |
| 11545 | return gl::error(GL_OUT_OF_MEMORY); |
| 11546 | } |
| 11547 | } |
| 11548 | |
| 11549 | // Extension functions |
| 11550 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11551 | void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 11552 | GLbitfield mask, GLenum filter) |
| 11553 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11554 | 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] | 11555 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, " |
| 11556 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 11557 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 11558 | |
| 11559 | try |
| 11560 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11561 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11562 | |
| 11563 | if (context) |
| 11564 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11565 | if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 11566 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 11567 | true)) |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11568 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11569 | return; |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11570 | } |
| 11571 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11572 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 11573 | mask, filter); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11574 | } |
| 11575 | } |
| 11576 | catch(std::bad_alloc&) |
| 11577 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11578 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11579 | } |
| 11580 | } |
| 11581 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 11582 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, |
| 11583 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11584 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11585 | 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] | 11586 | "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] | 11587 | "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] | 11588 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 11589 | |
| 11590 | try |
| 11591 | { |
| 11592 | UNIMPLEMENTED(); // FIXME |
| 11593 | } |
| 11594 | catch(std::bad_alloc&) |
| 11595 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11596 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11597 | } |
| 11598 | } |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11599 | |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11600 | void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, |
| 11601 | GLenum *binaryFormat, void *binary) |
| 11602 | { |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11603 | 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] | 11604 | program, bufSize, length, binaryFormat, binary); |
| 11605 | |
| 11606 | try |
| 11607 | { |
| 11608 | gl::Context *context = gl::getNonLostContext(); |
| 11609 | |
| 11610 | if (context) |
| 11611 | { |
| 11612 | gl::Program *programObject = context->getProgram(program); |
| 11613 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 11614 | if (!programObject || !programObject->isLinked()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11615 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11616 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11617 | } |
| 11618 | |
| 11619 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 11620 | |
| 11621 | if (!programBinary) |
| 11622 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11623 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11624 | } |
| 11625 | |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11626 | if (!programBinary->save(binary, bufSize, length)) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11627 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11628 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11629 | } |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11630 | |
| 11631 | *binaryFormat = GL_PROGRAM_BINARY_ANGLE; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11632 | } |
| 11633 | } |
| 11634 | catch(std::bad_alloc&) |
| 11635 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11636 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11637 | } |
| 11638 | } |
| 11639 | |
| 11640 | void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat, |
| 11641 | const void *binary, GLint length) |
| 11642 | { |
| 11643 | EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)", |
| 11644 | program, binaryFormat, binary, length); |
| 11645 | |
| 11646 | try |
| 11647 | { |
| 11648 | gl::Context *context = gl::getNonLostContext(); |
| 11649 | |
| 11650 | if (context) |
| 11651 | { |
| 11652 | if (binaryFormat != GL_PROGRAM_BINARY_ANGLE) |
| 11653 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11654 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11655 | } |
| 11656 | |
| 11657 | gl::Program *programObject = context->getProgram(program); |
| 11658 | |
| 11659 | if (!programObject) |
| 11660 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11661 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11662 | } |
| 11663 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 11664 | context->setProgramBinary(program, binary, length); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11665 | } |
| 11666 | } |
| 11667 | catch(std::bad_alloc&) |
| 11668 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11669 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11670 | } |
| 11671 | } |
| 11672 | |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11673 | void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) |
| 11674 | { |
| 11675 | EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs); |
| 11676 | |
| 11677 | try |
| 11678 | { |
| 11679 | gl::Context *context = gl::getNonLostContext(); |
| 11680 | |
| 11681 | if (context) |
| 11682 | { |
| 11683 | if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets()) |
| 11684 | { |
| 11685 | return gl::error(GL_INVALID_VALUE); |
| 11686 | } |
| 11687 | |
| 11688 | if (context->getDrawFramebufferHandle() == 0) |
| 11689 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11690 | if (n != 1) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11691 | { |
| 11692 | return gl::error(GL_INVALID_OPERATION); |
| 11693 | } |
| 11694 | |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11695 | 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] | 11696 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11697 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11698 | } |
| 11699 | } |
| 11700 | else |
| 11701 | { |
| 11702 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 11703 | { |
| 11704 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 11705 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment) |
| 11706 | { |
| 11707 | return gl::error(GL_INVALID_OPERATION); |
| 11708 | } |
| 11709 | } |
| 11710 | } |
| 11711 | |
| 11712 | gl::Framebuffer *framebuffer = context->getDrawFramebuffer(); |
| 11713 | |
| 11714 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 11715 | { |
| 11716 | framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]); |
| 11717 | } |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11718 | |
| 11719 | for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++) |
| 11720 | { |
| 11721 | framebuffer->setDrawBufferState(colorAttachment, GL_NONE); |
| 11722 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11723 | } |
| 11724 | } |
| 11725 | catch (std::bad_alloc&) |
| 11726 | { |
| 11727 | return gl::error(GL_OUT_OF_MEMORY); |
| 11728 | } |
| 11729 | } |
| 11730 | |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11731 | __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) |
| 11732 | { |
| 11733 | struct Extension |
| 11734 | { |
| 11735 | const char *name; |
| 11736 | __eglMustCastToProperFunctionPointerType address; |
| 11737 | }; |
| 11738 | |
| 11739 | static const Extension glExtensions[] = |
| 11740 | { |
| 11741 | {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 11742 | {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, |
daniel@transgaming.com | 1fe96c9 | 2011-01-14 15:08:44 +0000 | [diff] [blame] | 11743 | {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 11744 | {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, |
| 11745 | {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, |
| 11746 | {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, |
| 11747 | {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, |
| 11748 | {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, |
| 11749 | {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, |
| 11750 | {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 11751 | {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE}, |
daniel@transgaming.com | 0bd1f2f | 2011-11-11 04:19:03 +0000 | [diff] [blame] | 11752 | {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT}, |
daniel@transgaming.com | 709ed11 | 2011-11-12 03:18:10 +0000 | [diff] [blame] | 11753 | {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT}, |
| 11754 | {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT}, |
| 11755 | {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT}, |
| 11756 | {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT}, |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 11757 | {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT}, |
| 11758 | {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT}, |
| 11759 | {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT}, |
| 11760 | {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT}, |
| 11761 | {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT}, |
| 11762 | {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT}, |
| 11763 | {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT}, |
shannon.woods%transgaming.com@gtempaccount.com | 77d9472 | 2013-04-13 03:34:22 +0000 | [diff] [blame] | 11764 | {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT}, |
daniel@transgaming.com | dce02fd | 2012-01-27 15:39:51 +0000 | [diff] [blame] | 11765 | {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE}, |
| 11766 | {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, |
| 11767 | {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11768 | {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, |
| 11769 | {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, }; |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11770 | |
shannon.woods@transgaming.com | d438fd4 | 2013-02-28 23:17:45 +0000 | [diff] [blame] | 11771 | for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11772 | { |
| 11773 | if (strcmp(procname, glExtensions[ext].name) == 0) |
| 11774 | { |
| 11775 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address; |
| 11776 | } |
| 11777 | } |
| 11778 | |
| 11779 | return NULL; |
| 11780 | } |
| 11781 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 11782 | // Non-public functions used by EGL |
| 11783 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11784 | bool __stdcall glBindTexImage(egl::Surface *surface) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11785 | { |
| 11786 | EVENT("(egl::Surface* surface = 0x%0.8p)", |
| 11787 | surface); |
| 11788 | |
| 11789 | try |
| 11790 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11791 | gl::Context *context = gl::getNonLostContext(); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11792 | |
| 11793 | if (context) |
| 11794 | { |
| 11795 | gl::Texture2D *textureObject = context->getTexture2D(); |
| 11796 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11797 | if (textureObject->isImmutable()) |
| 11798 | { |
| 11799 | return false; |
| 11800 | } |
| 11801 | |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11802 | if (textureObject) |
| 11803 | { |
| 11804 | textureObject->bindTexImage(surface); |
| 11805 | } |
| 11806 | } |
| 11807 | } |
| 11808 | catch(std::bad_alloc&) |
| 11809 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11810 | return gl::error(GL_OUT_OF_MEMORY, false); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11811 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11812 | |
| 11813 | return true; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11814 | } |
| 11815 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11816 | } |