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 | |
| 1192 | if (xoffset + width > textureLevelWidth || |
| 1193 | yoffset + height > textureLevelHeight || |
| 1194 | zoffset >= textureLevelDepth) |
| 1195 | { |
| 1196 | return gl::error(GL_INVALID_VALUE, false); |
| 1197 | } |
| 1198 | |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1199 | if (!gl::IsValidCopyTexImageCombination(textureInternalFormat, colorbufferInternalFormat, |
| 1200 | context->getClientVersion())) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1201 | { |
| 1202 | return gl::error(GL_INVALID_OPERATION, false); |
| 1203 | } |
| 1204 | |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 1205 | return true; |
| 1206 | } |
| 1207 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 1208 | bool validateES2TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat, |
| 1209 | GLsizei width, GLsizei height) |
| 1210 | { |
| 1211 | if (target != GL_TEXTURE_2D && target != GL_TEXTURE_CUBE_MAP) |
| 1212 | { |
| 1213 | return gl::error(GL_INVALID_ENUM, false); |
| 1214 | } |
| 1215 | |
| 1216 | if (width < 1 || height < 1 || levels < 1) |
| 1217 | { |
| 1218 | return gl::error(GL_INVALID_VALUE, false); |
| 1219 | } |
| 1220 | |
| 1221 | if (target == GL_TEXTURE_CUBE_MAP && width != height) |
| 1222 | { |
| 1223 | return gl::error(GL_INVALID_VALUE, false); |
| 1224 | } |
| 1225 | |
| 1226 | if (levels != 1 && levels != gl::log2(std::max(width, height)) + 1) |
| 1227 | { |
| 1228 | return gl::error(GL_INVALID_OPERATION, false); |
| 1229 | } |
| 1230 | |
| 1231 | GLenum format = gl::GetFormat(internalformat, context->getClientVersion()); |
| 1232 | GLenum type = gl::GetType(internalformat, context->getClientVersion()); |
| 1233 | |
| 1234 | if (format == GL_NONE || type == GL_NONE) |
| 1235 | { |
| 1236 | return gl::error(GL_INVALID_ENUM, false); |
| 1237 | } |
| 1238 | |
| 1239 | switch (target) |
| 1240 | { |
| 1241 | case GL_TEXTURE_2D: |
| 1242 | if (width > context->getMaximum2DTextureDimension() || |
| 1243 | height > context->getMaximum2DTextureDimension()) |
| 1244 | { |
| 1245 | return gl::error(GL_INVALID_VALUE, false); |
| 1246 | } |
| 1247 | break; |
| 1248 | case GL_TEXTURE_CUBE_MAP: |
| 1249 | if (width > context->getMaximumCubeTextureDimension() || |
| 1250 | height > context->getMaximumCubeTextureDimension()) |
| 1251 | { |
| 1252 | return gl::error(GL_INVALID_VALUE, false); |
| 1253 | } |
| 1254 | break; |
| 1255 | default: |
| 1256 | return gl::error(GL_INVALID_ENUM, false); |
| 1257 | } |
| 1258 | |
| 1259 | if (levels != 1 && !context->supportsNonPower2Texture()) |
| 1260 | { |
| 1261 | if (!gl::isPow2(width) || !gl::isPow2(height)) |
| 1262 | { |
| 1263 | return gl::error(GL_INVALID_OPERATION, false); |
| 1264 | } |
| 1265 | } |
| 1266 | |
| 1267 | switch (internalformat) |
| 1268 | { |
| 1269 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 1270 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 1271 | if (!context->supportsDXT1Textures()) |
| 1272 | { |
| 1273 | return gl::error(GL_INVALID_ENUM, false); |
| 1274 | } |
| 1275 | break; |
| 1276 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 1277 | if (!context->supportsDXT3Textures()) |
| 1278 | { |
| 1279 | return gl::error(GL_INVALID_ENUM, false); |
| 1280 | } |
| 1281 | break; |
| 1282 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 1283 | if (!context->supportsDXT5Textures()) |
| 1284 | { |
| 1285 | return gl::error(GL_INVALID_ENUM, false); |
| 1286 | } |
| 1287 | break; |
| 1288 | case GL_RGBA32F_EXT: |
| 1289 | case GL_RGB32F_EXT: |
| 1290 | case GL_ALPHA32F_EXT: |
| 1291 | case GL_LUMINANCE32F_EXT: |
| 1292 | case GL_LUMINANCE_ALPHA32F_EXT: |
| 1293 | if (!context->supportsFloat32Textures()) |
| 1294 | { |
| 1295 | return gl::error(GL_INVALID_ENUM, false); |
| 1296 | } |
| 1297 | break; |
| 1298 | case GL_RGBA16F_EXT: |
| 1299 | case GL_RGB16F_EXT: |
| 1300 | case GL_ALPHA16F_EXT: |
| 1301 | case GL_LUMINANCE16F_EXT: |
| 1302 | case GL_LUMINANCE_ALPHA16F_EXT: |
| 1303 | if (!context->supportsFloat16Textures()) |
| 1304 | { |
| 1305 | return gl::error(GL_INVALID_ENUM, false); |
| 1306 | } |
| 1307 | break; |
| 1308 | case GL_DEPTH_COMPONENT16: |
| 1309 | case GL_DEPTH_COMPONENT32_OES: |
| 1310 | case GL_DEPTH24_STENCIL8_OES: |
| 1311 | if (!context->supportsDepthTextures()) |
| 1312 | { |
| 1313 | return gl::error(GL_INVALID_ENUM, false); |
| 1314 | } |
| 1315 | if (target != GL_TEXTURE_2D) |
| 1316 | { |
| 1317 | return gl::error(GL_INVALID_OPERATION, false); |
| 1318 | } |
| 1319 | // ANGLE_depth_texture only supports 1-level textures |
| 1320 | if (levels != 1) |
| 1321 | { |
| 1322 | return gl::error(GL_INVALID_OPERATION, false); |
| 1323 | } |
| 1324 | break; |
| 1325 | default: |
| 1326 | break; |
| 1327 | } |
| 1328 | |
| 1329 | gl::Texture *texture = NULL; |
| 1330 | switch(target) |
| 1331 | { |
| 1332 | case GL_TEXTURE_2D: |
| 1333 | texture = context->getTexture2D(); |
| 1334 | break; |
| 1335 | case GL_TEXTURE_CUBE_MAP: |
| 1336 | texture = context->getTextureCubeMap(); |
| 1337 | break; |
| 1338 | default: |
| 1339 | UNREACHABLE(); |
| 1340 | } |
| 1341 | |
| 1342 | if (!texture || texture->id() == 0) |
| 1343 | { |
| 1344 | return gl::error(GL_INVALID_OPERATION, false); |
| 1345 | } |
| 1346 | |
| 1347 | if (texture->isImmutable()) |
| 1348 | { |
| 1349 | return gl::error(GL_INVALID_OPERATION, false); |
| 1350 | } |
| 1351 | |
| 1352 | return true; |
| 1353 | } |
| 1354 | |
| 1355 | bool validateES3TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat, |
| 1356 | GLsizei width, GLsizei height, GLsizei depth) |
| 1357 | { |
| 1358 | if (width < 1 || height < 1 || depth < 1 || levels < 1) |
| 1359 | { |
| 1360 | return gl::error(GL_INVALID_VALUE, false); |
| 1361 | } |
| 1362 | |
| 1363 | if (levels > gl::log2(std::max(std::max(width, height), depth)) + 1) |
| 1364 | { |
| 1365 | return gl::error(GL_INVALID_OPERATION, false); |
| 1366 | } |
| 1367 | |
| 1368 | gl::Texture *texture = NULL; |
| 1369 | switch (target) |
| 1370 | { |
| 1371 | case GL_TEXTURE_2D: |
| 1372 | { |
| 1373 | texture = context->getTexture2D(); |
| 1374 | |
| 1375 | if (width > (context->getMaximum2DTextureDimension()) || |
| 1376 | height > (context->getMaximum2DTextureDimension())) |
| 1377 | { |
| 1378 | return gl::error(GL_INVALID_VALUE, false); |
| 1379 | } |
| 1380 | } |
| 1381 | break; |
| 1382 | |
| 1383 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 1384 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 1385 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 1386 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 1387 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 1388 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 1389 | { |
| 1390 | texture = context->getTextureCubeMap(); |
| 1391 | |
| 1392 | if (width != height) |
| 1393 | { |
| 1394 | return gl::error(GL_INVALID_VALUE, false); |
| 1395 | } |
| 1396 | |
| 1397 | if (width > (context->getMaximumCubeTextureDimension())) |
| 1398 | { |
| 1399 | return gl::error(GL_INVALID_VALUE, false); |
| 1400 | } |
| 1401 | } |
| 1402 | break; |
| 1403 | |
| 1404 | case GL_TEXTURE_3D: |
| 1405 | { |
| 1406 | texture = context->getTexture3D(); |
| 1407 | |
| 1408 | if (width > (context->getMaximum3DTextureDimension()) || |
| 1409 | height > (context->getMaximum3DTextureDimension()) || |
| 1410 | depth > (context->getMaximum3DTextureDimension())) |
| 1411 | { |
| 1412 | return gl::error(GL_INVALID_VALUE, false); |
| 1413 | } |
| 1414 | } |
| 1415 | break; |
| 1416 | |
| 1417 | case GL_TEXTURE_2D_ARRAY: |
| 1418 | { |
| 1419 | texture = context->getTexture2DArray(); |
| 1420 | |
| 1421 | if (width > (context->getMaximum2DTextureDimension()) || |
| 1422 | height > (context->getMaximum2DTextureDimension()) || |
| 1423 | depth > (context->getMaximum2DArrayTextureLayers())) |
| 1424 | { |
| 1425 | return gl::error(GL_INVALID_VALUE, false); |
| 1426 | } |
| 1427 | } |
| 1428 | break; |
| 1429 | |
| 1430 | default: |
| 1431 | return gl::error(GL_INVALID_ENUM, false); |
| 1432 | } |
| 1433 | |
| 1434 | if (!texture || texture->id() == 0) |
| 1435 | { |
| 1436 | return gl::error(GL_INVALID_OPERATION, false); |
| 1437 | } |
| 1438 | |
| 1439 | if (texture->isImmutable()) |
| 1440 | { |
| 1441 | return gl::error(GL_INVALID_OPERATION, false); |
| 1442 | } |
| 1443 | |
| 1444 | if (!gl::IsValidInternalFormat(internalformat, context)) |
| 1445 | { |
| 1446 | return gl::error(GL_INVALID_ENUM, false); |
| 1447 | } |
| 1448 | |
| 1449 | if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion())) |
| 1450 | { |
| 1451 | return gl::error(GL_INVALID_ENUM, false); |
| 1452 | } |
| 1453 | |
| 1454 | return true; |
| 1455 | } |
| 1456 | |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 1457 | bool validateRenderbufferStorageParameters(const gl::Context *context, GLenum target, GLsizei samples, |
| 1458 | GLenum internalformat, GLsizei width, GLsizei height, |
| 1459 | bool angleExtension) |
| 1460 | { |
| 1461 | switch (target) |
| 1462 | { |
| 1463 | case GL_RENDERBUFFER: |
| 1464 | break; |
| 1465 | default: |
| 1466 | return gl::error(GL_INVALID_ENUM, false); |
| 1467 | } |
| 1468 | |
| 1469 | if (width < 0 || height < 0 || samples < 0) |
| 1470 | { |
| 1471 | return gl::error(GL_INVALID_VALUE, false); |
| 1472 | } |
| 1473 | |
| 1474 | if (!gl::IsValidInternalFormat(internalformat, context)) |
| 1475 | { |
| 1476 | return gl::error(GL_INVALID_ENUM, false); |
| 1477 | } |
| 1478 | |
| 1479 | // ANGLE_framebuffer_multisample does not explicitly state that the internal format must be |
| 1480 | // sized but it does state that the format must be in the ES2.0 spec table 4.5 which contains |
| 1481 | // only sized internal formats. The ES3 spec (section 4.4.2) does, however, state that the |
| 1482 | // internal format must be sized and not an integer format if samples is greater than zero. |
| 1483 | if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion())) |
| 1484 | { |
| 1485 | return gl::error(GL_INVALID_ENUM, false); |
| 1486 | } |
| 1487 | |
| 1488 | if (gl::IsIntegerFormat(internalformat, context->getClientVersion()) && samples > 0) |
| 1489 | { |
| 1490 | return gl::error(GL_INVALID_OPERATION, false); |
| 1491 | } |
| 1492 | |
| 1493 | if (!gl::IsColorRenderingSupported(internalformat, context) && |
| 1494 | !gl::IsDepthRenderingSupported(internalformat, context) && |
| 1495 | !gl::IsStencilRenderingSupported(internalformat, context)) |
| 1496 | { |
| 1497 | return gl::error(GL_INVALID_ENUM, false); |
| 1498 | } |
| 1499 | |
| 1500 | if (std::max(width, height) > context->getMaximumRenderbufferDimension()) |
| 1501 | { |
| 1502 | return gl::error(GL_INVALID_VALUE, false); |
| 1503 | } |
| 1504 | |
| 1505 | // ANGLE_framebuffer_multisample states that the value of samples must be less than or equal |
| 1506 | // to MAX_SAMPLES_ANGLE (Context::getMaxSupportedSamples) while the ES3.0 spec (section 4.4.2) |
| 1507 | // states that samples must be less than or equal to the maximum samples for the specified |
| 1508 | // internal format. |
| 1509 | if (angleExtension) |
| 1510 | { |
| 1511 | if (samples > context->getMaxSupportedSamples()) |
| 1512 | { |
| 1513 | return gl::error(GL_INVALID_VALUE, false); |
| 1514 | } |
| 1515 | } |
| 1516 | else |
| 1517 | { |
| 1518 | if (samples > context->getMaxSupportedFormatSamples(internalformat)) |
| 1519 | { |
| 1520 | return gl::error(GL_INVALID_VALUE, false); |
| 1521 | } |
| 1522 | } |
| 1523 | |
| 1524 | GLuint handle = context->getRenderbufferHandle(); |
| 1525 | if (handle == 0) |
| 1526 | { |
| 1527 | return gl::error(GL_INVALID_OPERATION, false); |
| 1528 | } |
| 1529 | |
| 1530 | return true; |
| 1531 | } |
| 1532 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1533 | // 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] | 1534 | bool validES2ReadFormatType(GLenum format, GLenum type) |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1535 | { |
| 1536 | switch (format) |
| 1537 | { |
| 1538 | case GL_RGBA: |
| 1539 | switch (type) |
| 1540 | { |
| 1541 | case GL_UNSIGNED_BYTE: |
| 1542 | break; |
| 1543 | default: |
| 1544 | return false; |
| 1545 | } |
| 1546 | break; |
| 1547 | case GL_BGRA_EXT: |
| 1548 | switch (type) |
| 1549 | { |
| 1550 | case GL_UNSIGNED_BYTE: |
| 1551 | case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: |
| 1552 | case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: |
| 1553 | break; |
| 1554 | default: |
| 1555 | return false; |
| 1556 | } |
| 1557 | break; |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1558 | default: |
| 1559 | return false; |
| 1560 | } |
| 1561 | return true; |
| 1562 | } |
| 1563 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 1564 | bool validES3ReadFormatType(GLenum internalFormat, GLenum format, GLenum type) |
| 1565 | { |
| 1566 | switch (format) |
| 1567 | { |
| 1568 | case GL_RGBA: |
| 1569 | switch (type) |
| 1570 | { |
| 1571 | case GL_UNSIGNED_BYTE: |
| 1572 | break; |
| 1573 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 1574 | if (internalFormat != GL_RGB10_A2) |
| 1575 | { |
| 1576 | return false; |
| 1577 | } |
| 1578 | break; |
| 1579 | default: |
| 1580 | return false; |
| 1581 | } |
| 1582 | break; |
| 1583 | case GL_RGBA_INTEGER: |
| 1584 | switch (type) |
| 1585 | { |
| 1586 | case GL_INT: |
| 1587 | case GL_UNSIGNED_INT: |
| 1588 | break; |
| 1589 | default: |
| 1590 | return false; |
| 1591 | } |
| 1592 | break; |
| 1593 | case GL_BGRA_EXT: |
| 1594 | switch (type) |
| 1595 | { |
| 1596 | case GL_UNSIGNED_BYTE: |
| 1597 | case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: |
| 1598 | case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: |
| 1599 | break; |
| 1600 | default: |
| 1601 | return false; |
| 1602 | } |
| 1603 | break; |
| 1604 | default: |
| 1605 | return false; |
| 1606 | } |
| 1607 | return true; |
| 1608 | } |
| 1609 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 1610 | bool validateInvalidateFramebufferParameters(gl::Context *context, GLenum target, GLsizei numAttachments, |
| 1611 | const GLenum* attachments) |
| 1612 | { |
| 1613 | bool defaultFramebuffer = false; |
| 1614 | |
| 1615 | switch (target) |
| 1616 | { |
| 1617 | case GL_DRAW_FRAMEBUFFER: |
| 1618 | case GL_FRAMEBUFFER: |
| 1619 | defaultFramebuffer = context->getDrawFramebufferHandle() == 0; |
| 1620 | break; |
| 1621 | case GL_READ_FRAMEBUFFER: |
| 1622 | defaultFramebuffer = context->getReadFramebufferHandle() == 0; |
| 1623 | break; |
| 1624 | default: |
| 1625 | return gl::error(GL_INVALID_ENUM, false); |
| 1626 | } |
| 1627 | |
| 1628 | for (int i = 0; i < numAttachments; ++i) |
| 1629 | { |
| 1630 | if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15) |
| 1631 | { |
| 1632 | if (defaultFramebuffer) |
| 1633 | { |
| 1634 | return gl::error(GL_INVALID_ENUM, false); |
| 1635 | } |
| 1636 | |
| 1637 | if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getMaximumRenderTargets()) |
| 1638 | { |
| 1639 | return gl::error(GL_INVALID_OPERATION, false); |
| 1640 | } |
| 1641 | } |
| 1642 | else |
| 1643 | { |
| 1644 | switch (attachments[i]) |
| 1645 | { |
| 1646 | case GL_DEPTH_ATTACHMENT: |
| 1647 | case GL_STENCIL_ATTACHMENT: |
| 1648 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 1649 | if (defaultFramebuffer) |
| 1650 | { |
| 1651 | return gl::error(GL_INVALID_ENUM, false); |
| 1652 | } |
| 1653 | break; |
| 1654 | case GL_COLOR: |
| 1655 | case GL_DEPTH: |
| 1656 | case GL_STENCIL: |
| 1657 | if (!defaultFramebuffer) |
| 1658 | { |
| 1659 | return gl::error(GL_INVALID_ENUM, false); |
| 1660 | } |
| 1661 | break; |
| 1662 | default: |
| 1663 | return gl::error(GL_INVALID_ENUM, false); |
| 1664 | } |
| 1665 | } |
| 1666 | } |
| 1667 | |
| 1668 | return true; |
| 1669 | } |
| 1670 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1671 | extern "C" |
| 1672 | { |
| 1673 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 1674 | // OpenGL ES 2.0 functions |
| 1675 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1676 | void __stdcall glActiveTexture(GLenum texture) |
| 1677 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1678 | EVENT("(GLenum texture = 0x%X)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1679 | |
| 1680 | try |
| 1681 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1682 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1683 | |
| 1684 | if (context) |
| 1685 | { |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 1686 | if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1) |
| 1687 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1688 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 1689 | } |
| 1690 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 1691 | context->setActiveSampler(texture - GL_TEXTURE0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1692 | } |
| 1693 | } |
| 1694 | catch(std::bad_alloc&) |
| 1695 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1696 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1697 | } |
| 1698 | } |
| 1699 | |
| 1700 | void __stdcall glAttachShader(GLuint program, GLuint shader) |
| 1701 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1702 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1703 | |
| 1704 | try |
| 1705 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1706 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1707 | |
| 1708 | if (context) |
| 1709 | { |
| 1710 | gl::Program *programObject = context->getProgram(program); |
| 1711 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 1712 | |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1713 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1714 | { |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1715 | if (context->getShader(program)) |
| 1716 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1717 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1718 | } |
| 1719 | else |
| 1720 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1721 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1722 | } |
| 1723 | } |
| 1724 | |
| 1725 | if (!shaderObject) |
| 1726 | { |
| 1727 | if (context->getProgram(shader)) |
| 1728 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1729 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1730 | } |
| 1731 | else |
| 1732 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1733 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1734 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1735 | } |
| 1736 | |
| 1737 | if (!programObject->attachShader(shaderObject)) |
| 1738 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1739 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1740 | } |
| 1741 | } |
| 1742 | } |
| 1743 | catch(std::bad_alloc&) |
| 1744 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1745 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1746 | } |
| 1747 | } |
| 1748 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1749 | void __stdcall glBeginQueryEXT(GLenum target, GLuint id) |
| 1750 | { |
| 1751 | EVENT("(GLenum target = 0x%X, GLuint %d)", target, id); |
| 1752 | |
| 1753 | try |
| 1754 | { |
| 1755 | switch (target) |
| 1756 | { |
| 1757 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 1758 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 1759 | break; |
| 1760 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1761 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1762 | } |
| 1763 | |
| 1764 | if (id == 0) |
| 1765 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1766 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1767 | } |
| 1768 | |
| 1769 | gl::Context *context = gl::getNonLostContext(); |
| 1770 | |
| 1771 | if (context) |
| 1772 | { |
| 1773 | context->beginQuery(target, id); |
| 1774 | } |
| 1775 | } |
| 1776 | catch(std::bad_alloc&) |
| 1777 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1778 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1779 | } |
| 1780 | } |
| 1781 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 1782 | void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1783 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1784 | 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] | 1785 | |
| 1786 | try |
| 1787 | { |
| 1788 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 1789 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1790 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1791 | } |
| 1792 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1793 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1794 | |
| 1795 | if (context) |
| 1796 | { |
| 1797 | gl::Program *programObject = context->getProgram(program); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 1798 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1799 | if (!programObject) |
| 1800 | { |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 1801 | if (context->getShader(program)) |
| 1802 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1803 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 1804 | } |
| 1805 | else |
| 1806 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1807 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 1808 | } |
| 1809 | } |
| 1810 | |
| 1811 | if (strncmp(name, "gl_", 3) == 0) |
| 1812 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1813 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1814 | } |
| 1815 | |
| 1816 | programObject->bindAttributeLocation(index, name); |
| 1817 | } |
| 1818 | } |
| 1819 | catch(std::bad_alloc&) |
| 1820 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1821 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1822 | } |
| 1823 | } |
| 1824 | |
| 1825 | void __stdcall glBindBuffer(GLenum target, GLuint buffer) |
| 1826 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1827 | EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1828 | |
| 1829 | try |
| 1830 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1831 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1832 | |
| 1833 | if (context) |
| 1834 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1835 | // Check ES3 specific targets |
| 1836 | switch (target) |
| 1837 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 1838 | case GL_COPY_READ_BUFFER: |
| 1839 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1840 | case GL_PIXEL_PACK_BUFFER: |
| 1841 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1842 | case GL_UNIFORM_BUFFER: |
| 1843 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 1844 | if (context->getClientVersion() < 3) |
| 1845 | { |
| 1846 | return gl::error(GL_INVALID_ENUM); |
| 1847 | } |
| 1848 | } |
| 1849 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1850 | switch (target) |
| 1851 | { |
| 1852 | case GL_ARRAY_BUFFER: |
| 1853 | context->bindArrayBuffer(buffer); |
| 1854 | return; |
| 1855 | case GL_ELEMENT_ARRAY_BUFFER: |
| 1856 | context->bindElementArrayBuffer(buffer); |
| 1857 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 1858 | case GL_COPY_READ_BUFFER: |
| 1859 | context->bindCopyReadBuffer(buffer); |
| 1860 | return; |
| 1861 | case GL_COPY_WRITE_BUFFER: |
| 1862 | context->bindCopyWriteBuffer(buffer); |
| 1863 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1864 | case GL_PIXEL_PACK_BUFFER: |
| 1865 | context->bindPixelPackBuffer(buffer); |
| 1866 | return; |
| 1867 | case GL_PIXEL_UNPACK_BUFFER: |
| 1868 | context->bindPixelUnpackBuffer(buffer); |
| 1869 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1870 | case GL_UNIFORM_BUFFER: |
| 1871 | context->bindGenericUniformBuffer(buffer); |
| 1872 | return; |
| 1873 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 7a1ebad | 2013-05-30 00:05:20 +0000 | [diff] [blame] | 1874 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1875 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1876 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1877 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1878 | } |
| 1879 | } |
| 1880 | } |
| 1881 | catch(std::bad_alloc&) |
| 1882 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1883 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1884 | } |
| 1885 | } |
| 1886 | |
| 1887 | void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer) |
| 1888 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1889 | EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1890 | |
| 1891 | try |
| 1892 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 1893 | 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] | 1894 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1895 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1896 | } |
| 1897 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1898 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1899 | |
| 1900 | if (context) |
| 1901 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 1902 | if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 1903 | { |
| 1904 | context->bindReadFramebuffer(framebuffer); |
| 1905 | } |
| 1906 | |
| 1907 | if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 1908 | { |
| 1909 | context->bindDrawFramebuffer(framebuffer); |
| 1910 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1911 | } |
| 1912 | } |
| 1913 | catch(std::bad_alloc&) |
| 1914 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1915 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1916 | } |
| 1917 | } |
| 1918 | |
| 1919 | void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 1920 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1921 | EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1922 | |
| 1923 | try |
| 1924 | { |
| 1925 | if (target != GL_RENDERBUFFER) |
| 1926 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1927 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1928 | } |
| 1929 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1930 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1931 | |
| 1932 | if (context) |
| 1933 | { |
| 1934 | context->bindRenderbuffer(renderbuffer); |
| 1935 | } |
| 1936 | } |
| 1937 | catch(std::bad_alloc&) |
| 1938 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1939 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1940 | } |
| 1941 | } |
| 1942 | |
| 1943 | void __stdcall glBindTexture(GLenum target, GLuint texture) |
| 1944 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1945 | EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1946 | |
| 1947 | try |
| 1948 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1949 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1950 | |
| 1951 | if (context) |
| 1952 | { |
| 1953 | gl::Texture *textureObject = context->getTexture(texture); |
| 1954 | |
| 1955 | if (textureObject && textureObject->getTarget() != target && texture != 0) |
| 1956 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1957 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1958 | } |
| 1959 | |
| 1960 | switch (target) |
| 1961 | { |
| 1962 | case GL_TEXTURE_2D: |
| 1963 | context->bindTexture2D(texture); |
| 1964 | return; |
| 1965 | case GL_TEXTURE_CUBE_MAP: |
| 1966 | context->bindTextureCubeMap(texture); |
| 1967 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 1968 | case GL_TEXTURE_3D: |
| 1969 | if (context->getClientVersion() < 3) |
| 1970 | { |
| 1971 | return gl::error(GL_INVALID_ENUM); |
| 1972 | } |
| 1973 | context->bindTexture3D(texture); |
| 1974 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 1975 | case GL_TEXTURE_2D_ARRAY: |
| 1976 | if (context->getClientVersion() < 3) |
| 1977 | { |
| 1978 | return gl::error(GL_INVALID_ENUM); |
| 1979 | } |
| 1980 | context->bindTexture2DArray(texture); |
| 1981 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1982 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1983 | return gl::error(GL_INVALID_ENUM); |
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 | |
| 1993 | void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 1994 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1995 | 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] | 1996 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1997 | |
| 1998 | try |
| 1999 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2000 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2001 | |
| 2002 | if (context) |
| 2003 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2004 | 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] | 2005 | } |
| 2006 | } |
| 2007 | catch(std::bad_alloc&) |
| 2008 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2009 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2010 | } |
| 2011 | } |
| 2012 | |
| 2013 | void __stdcall glBlendEquation(GLenum mode) |
| 2014 | { |
| 2015 | glBlendEquationSeparate(mode, mode); |
| 2016 | } |
| 2017 | |
| 2018 | void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 2019 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2020 | EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2021 | |
| 2022 | try |
| 2023 | { |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2024 | gl::Context *context = gl::getNonLostContext(); |
| 2025 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2026 | switch (modeRGB) |
| 2027 | { |
| 2028 | case GL_FUNC_ADD: |
| 2029 | case GL_FUNC_SUBTRACT: |
| 2030 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2031 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2032 | |
| 2033 | case GL_MIN: |
| 2034 | case GL_MAX: |
| 2035 | if (context && context->getClientVersion() < 3) |
| 2036 | { |
| 2037 | return gl::error(GL_INVALID_ENUM); |
| 2038 | } |
| 2039 | break; |
| 2040 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2041 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2042 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2043 | } |
| 2044 | |
| 2045 | switch (modeAlpha) |
| 2046 | { |
| 2047 | case GL_FUNC_ADD: |
| 2048 | case GL_FUNC_SUBTRACT: |
| 2049 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2050 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2051 | |
| 2052 | case GL_MIN: |
| 2053 | case GL_MAX: |
| 2054 | if (context && context->getClientVersion() < 3) |
| 2055 | { |
| 2056 | return gl::error(GL_INVALID_ENUM); |
| 2057 | } |
| 2058 | break; |
| 2059 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2060 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2061 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2062 | } |
| 2063 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2064 | if (context) |
| 2065 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2066 | context->setBlendEquation(modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2067 | } |
| 2068 | } |
| 2069 | catch(std::bad_alloc&) |
| 2070 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2071 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2072 | } |
| 2073 | } |
| 2074 | |
| 2075 | void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor) |
| 2076 | { |
| 2077 | glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor); |
| 2078 | } |
| 2079 | |
| 2080 | void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 2081 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2082 | 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] | 2083 | srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2084 | |
| 2085 | try |
| 2086 | { |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2087 | gl::Context *context = gl::getNonLostContext(); |
| 2088 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2089 | switch (srcRGB) |
| 2090 | { |
| 2091 | case GL_ZERO: |
| 2092 | case GL_ONE: |
| 2093 | case GL_SRC_COLOR: |
| 2094 | case GL_ONE_MINUS_SRC_COLOR: |
| 2095 | case GL_DST_COLOR: |
| 2096 | case GL_ONE_MINUS_DST_COLOR: |
| 2097 | case GL_SRC_ALPHA: |
| 2098 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2099 | case GL_DST_ALPHA: |
| 2100 | case GL_ONE_MINUS_DST_ALPHA: |
| 2101 | case GL_CONSTANT_COLOR: |
| 2102 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2103 | case GL_CONSTANT_ALPHA: |
| 2104 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2105 | case GL_SRC_ALPHA_SATURATE: |
| 2106 | break; |
| 2107 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2108 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2109 | } |
| 2110 | |
| 2111 | switch (dstRGB) |
| 2112 | { |
| 2113 | case GL_ZERO: |
| 2114 | case GL_ONE: |
| 2115 | case GL_SRC_COLOR: |
| 2116 | case GL_ONE_MINUS_SRC_COLOR: |
| 2117 | case GL_DST_COLOR: |
| 2118 | case GL_ONE_MINUS_DST_COLOR: |
| 2119 | case GL_SRC_ALPHA: |
| 2120 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2121 | case GL_DST_ALPHA: |
| 2122 | case GL_ONE_MINUS_DST_ALPHA: |
| 2123 | case GL_CONSTANT_COLOR: |
| 2124 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2125 | case GL_CONSTANT_ALPHA: |
| 2126 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2127 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2128 | |
| 2129 | case GL_SRC_ALPHA_SATURATE: |
| 2130 | if (!context || context->getClientVersion() < 3) |
| 2131 | { |
| 2132 | return gl::error(GL_INVALID_ENUM); |
| 2133 | } |
| 2134 | break; |
| 2135 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2136 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2137 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2138 | } |
| 2139 | |
| 2140 | switch (srcAlpha) |
| 2141 | { |
| 2142 | case GL_ZERO: |
| 2143 | case GL_ONE: |
| 2144 | case GL_SRC_COLOR: |
| 2145 | case GL_ONE_MINUS_SRC_COLOR: |
| 2146 | case GL_DST_COLOR: |
| 2147 | case GL_ONE_MINUS_DST_COLOR: |
| 2148 | case GL_SRC_ALPHA: |
| 2149 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2150 | case GL_DST_ALPHA: |
| 2151 | case GL_ONE_MINUS_DST_ALPHA: |
| 2152 | case GL_CONSTANT_COLOR: |
| 2153 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2154 | case GL_CONSTANT_ALPHA: |
| 2155 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2156 | case GL_SRC_ALPHA_SATURATE: |
| 2157 | break; |
| 2158 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2159 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2160 | } |
| 2161 | |
| 2162 | switch (dstAlpha) |
| 2163 | { |
| 2164 | case GL_ZERO: |
| 2165 | case GL_ONE: |
| 2166 | case GL_SRC_COLOR: |
| 2167 | case GL_ONE_MINUS_SRC_COLOR: |
| 2168 | case GL_DST_COLOR: |
| 2169 | case GL_ONE_MINUS_DST_COLOR: |
| 2170 | case GL_SRC_ALPHA: |
| 2171 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2172 | case GL_DST_ALPHA: |
| 2173 | case GL_ONE_MINUS_DST_ALPHA: |
| 2174 | case GL_CONSTANT_COLOR: |
| 2175 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2176 | case GL_CONSTANT_ALPHA: |
| 2177 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2178 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2179 | |
| 2180 | case GL_SRC_ALPHA_SATURATE: |
| 2181 | if (!context || context->getClientVersion() < 3) |
| 2182 | { |
| 2183 | return gl::error(GL_INVALID_ENUM); |
| 2184 | } |
| 2185 | break; |
| 2186 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2187 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2188 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2189 | } |
| 2190 | |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2191 | bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR || |
| 2192 | dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR); |
| 2193 | |
| 2194 | bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA || |
| 2195 | dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA); |
| 2196 | |
| 2197 | if (constantColorUsed && constantAlphaUsed) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2198 | { |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2199 | 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] | 2200 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2201 | } |
| 2202 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2203 | if (context) |
| 2204 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2205 | context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2206 | } |
| 2207 | } |
| 2208 | catch(std::bad_alloc&) |
| 2209 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2210 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2211 | } |
| 2212 | } |
| 2213 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2214 | 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] | 2215 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2216 | 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] | 2217 | target, size, data, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2218 | |
| 2219 | try |
| 2220 | { |
| 2221 | if (size < 0) |
| 2222 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2223 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2224 | } |
| 2225 | |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2226 | gl::Context *context = gl::getNonLostContext(); |
| 2227 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2228 | switch (usage) |
| 2229 | { |
| 2230 | case GL_STREAM_DRAW: |
| 2231 | case GL_STATIC_DRAW: |
| 2232 | case GL_DYNAMIC_DRAW: |
| 2233 | break; |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2234 | |
| 2235 | case GL_STREAM_READ: |
| 2236 | case GL_STREAM_COPY: |
| 2237 | case GL_STATIC_READ: |
| 2238 | case GL_STATIC_COPY: |
| 2239 | case GL_DYNAMIC_READ: |
| 2240 | case GL_DYNAMIC_COPY: |
| 2241 | if (context && context->getClientVersion() < 3) |
| 2242 | { |
| 2243 | return gl::error(GL_INVALID_ENUM); |
| 2244 | } |
| 2245 | break; |
| 2246 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2247 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2248 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2249 | } |
| 2250 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2251 | if (context) |
| 2252 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2253 | // Check ES3 specific targets |
| 2254 | switch (target) |
| 2255 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2256 | case GL_COPY_READ_BUFFER: |
| 2257 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2258 | case GL_PIXEL_PACK_BUFFER: |
| 2259 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2260 | case GL_UNIFORM_BUFFER: |
| 2261 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2262 | if (context->getClientVersion() < 3) |
| 2263 | { |
| 2264 | return gl::error(GL_INVALID_ENUM); |
| 2265 | } |
| 2266 | } |
| 2267 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2268 | gl::Buffer *buffer; |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2269 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2270 | switch (target) |
| 2271 | { |
| 2272 | case GL_ARRAY_BUFFER: |
| 2273 | buffer = context->getArrayBuffer(); |
| 2274 | break; |
| 2275 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2276 | buffer = context->getElementArrayBuffer(); |
| 2277 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2278 | case GL_COPY_READ_BUFFER: |
| 2279 | buffer = context->getCopyReadBuffer(); |
| 2280 | break; |
| 2281 | case GL_COPY_WRITE_BUFFER: |
| 2282 | buffer = context->getCopyWriteBuffer(); |
| 2283 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2284 | case GL_PIXEL_PACK_BUFFER: |
| 2285 | buffer = context->getPixelPackBuffer(); |
| 2286 | break; |
| 2287 | case GL_PIXEL_UNPACK_BUFFER: |
| 2288 | buffer = context->getPixelUnpackBuffer(); |
| 2289 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2290 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2291 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2292 | break; |
| 2293 | case GL_UNIFORM_BUFFER: |
| 2294 | buffer = context->getGenericUniformBuffer(); |
| 2295 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2296 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2297 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2298 | } |
| 2299 | |
| 2300 | if (!buffer) |
| 2301 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2302 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2303 | } |
| 2304 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2305 | buffer->bufferData(data, size, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2306 | } |
| 2307 | } |
| 2308 | catch(std::bad_alloc&) |
| 2309 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2310 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2311 | } |
| 2312 | } |
| 2313 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2314 | 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] | 2315 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2316 | 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] | 2317 | target, offset, size, data); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2318 | |
| 2319 | try |
| 2320 | { |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2321 | if (size < 0 || offset < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2322 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2323 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2324 | } |
| 2325 | |
daniel@transgaming.com | d4620a3 | 2010-03-21 04:31:28 +0000 | [diff] [blame] | 2326 | if (data == NULL) |
| 2327 | { |
| 2328 | return; |
| 2329 | } |
| 2330 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2331 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2332 | |
| 2333 | if (context) |
| 2334 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2335 | // Check ES3 specific targets |
| 2336 | switch (target) |
| 2337 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2338 | case GL_COPY_READ_BUFFER: |
| 2339 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2340 | case GL_PIXEL_PACK_BUFFER: |
| 2341 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2342 | case GL_UNIFORM_BUFFER: |
| 2343 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2344 | if (context->getClientVersion() < 3) |
| 2345 | { |
| 2346 | return gl::error(GL_INVALID_ENUM); |
| 2347 | } |
| 2348 | } |
| 2349 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2350 | gl::Buffer *buffer; |
| 2351 | |
| 2352 | switch (target) |
| 2353 | { |
| 2354 | case GL_ARRAY_BUFFER: |
| 2355 | buffer = context->getArrayBuffer(); |
| 2356 | break; |
| 2357 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2358 | buffer = context->getElementArrayBuffer(); |
| 2359 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2360 | case GL_COPY_READ_BUFFER: |
| 2361 | buffer = context->getCopyReadBuffer(); |
| 2362 | break; |
| 2363 | case GL_COPY_WRITE_BUFFER: |
| 2364 | buffer = context->getCopyWriteBuffer(); |
| 2365 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2366 | case GL_PIXEL_PACK_BUFFER: |
| 2367 | buffer = context->getPixelPackBuffer(); |
| 2368 | break; |
| 2369 | case GL_PIXEL_UNPACK_BUFFER: |
| 2370 | buffer = context->getPixelUnpackBuffer(); |
| 2371 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2372 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2373 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2374 | break; |
| 2375 | case GL_UNIFORM_BUFFER: |
| 2376 | buffer = context->getGenericUniformBuffer(); |
| 2377 | break; |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2378 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2379 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2380 | } |
| 2381 | |
| 2382 | if (!buffer) |
| 2383 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2384 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2385 | } |
| 2386 | |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2387 | if ((size_t)size + offset > buffer->size()) |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2388 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2389 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2390 | } |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2391 | |
| 2392 | buffer->bufferSubData(data, size, offset); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2393 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2394 | } |
| 2395 | catch(std::bad_alloc&) |
| 2396 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2397 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2398 | } |
| 2399 | } |
| 2400 | |
| 2401 | GLenum __stdcall glCheckFramebufferStatus(GLenum target) |
| 2402 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2403 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2404 | |
| 2405 | try |
| 2406 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2407 | 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] | 2408 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2409 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2410 | } |
| 2411 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2412 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2413 | |
| 2414 | if (context) |
| 2415 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2416 | gl::Framebuffer *framebuffer = NULL; |
| 2417 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 2418 | { |
| 2419 | framebuffer = context->getReadFramebuffer(); |
| 2420 | } |
| 2421 | else |
| 2422 | { |
| 2423 | framebuffer = context->getDrawFramebuffer(); |
| 2424 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2425 | |
| 2426 | return framebuffer->completeness(); |
| 2427 | } |
| 2428 | } |
| 2429 | catch(std::bad_alloc&) |
| 2430 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2431 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2432 | } |
| 2433 | |
| 2434 | return 0; |
| 2435 | } |
| 2436 | |
| 2437 | void __stdcall glClear(GLbitfield mask) |
| 2438 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2439 | EVENT("(GLbitfield mask = 0x%X)", mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2440 | |
| 2441 | try |
| 2442 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2443 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2444 | |
| 2445 | if (context) |
| 2446 | { |
| 2447 | context->clear(mask); |
| 2448 | } |
| 2449 | } |
| 2450 | catch(std::bad_alloc&) |
| 2451 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2452 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2453 | } |
| 2454 | } |
| 2455 | |
| 2456 | void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2457 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2458 | 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] | 2459 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2460 | |
| 2461 | try |
| 2462 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2463 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2464 | |
| 2465 | if (context) |
| 2466 | { |
| 2467 | context->setClearColor(red, green, blue, alpha); |
| 2468 | } |
| 2469 | } |
| 2470 | catch(std::bad_alloc&) |
| 2471 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2472 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2473 | } |
| 2474 | } |
| 2475 | |
| 2476 | void __stdcall glClearDepthf(GLclampf depth) |
| 2477 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2478 | EVENT("(GLclampf depth = %f)", depth); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2479 | |
| 2480 | try |
| 2481 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2482 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2483 | |
| 2484 | if (context) |
| 2485 | { |
| 2486 | context->setClearDepth(depth); |
| 2487 | } |
| 2488 | } |
| 2489 | catch(std::bad_alloc&) |
| 2490 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2491 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2492 | } |
| 2493 | } |
| 2494 | |
| 2495 | void __stdcall glClearStencil(GLint s) |
| 2496 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2497 | EVENT("(GLint s = %d)", s); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2498 | |
| 2499 | try |
| 2500 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2501 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2502 | |
| 2503 | if (context) |
| 2504 | { |
| 2505 | context->setClearStencil(s); |
| 2506 | } |
| 2507 | } |
| 2508 | catch(std::bad_alloc&) |
| 2509 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2510 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2511 | } |
| 2512 | } |
| 2513 | |
| 2514 | void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 2515 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2516 | 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] | 2517 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2518 | |
| 2519 | try |
| 2520 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2521 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2522 | |
| 2523 | if (context) |
| 2524 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 2525 | 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] | 2526 | } |
| 2527 | } |
| 2528 | catch(std::bad_alloc&) |
| 2529 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2530 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2531 | } |
| 2532 | } |
| 2533 | |
| 2534 | void __stdcall glCompileShader(GLuint shader) |
| 2535 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2536 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2537 | |
| 2538 | try |
| 2539 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2540 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2541 | |
| 2542 | if (context) |
| 2543 | { |
| 2544 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2545 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2546 | if (!shaderObject) |
| 2547 | { |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2548 | if (context->getProgram(shader)) |
| 2549 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2550 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2551 | } |
| 2552 | else |
| 2553 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2554 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2555 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2556 | } |
| 2557 | |
| 2558 | shaderObject->compile(); |
| 2559 | } |
| 2560 | } |
| 2561 | catch(std::bad_alloc&) |
| 2562 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2563 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2564 | } |
| 2565 | } |
| 2566 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2567 | void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, |
| 2568 | GLint border, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2569 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2570 | 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] | 2571 | "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] | 2572 | target, level, internalformat, width, height, border, imageSize, data); |
| 2573 | |
| 2574 | try |
| 2575 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2576 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2577 | |
| 2578 | if (context) |
| 2579 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2580 | if (context->getClientVersion() < 3 && |
| 2581 | !validateES2TexImageParameters(context, target, level, internalformat, true, false, |
| 2582 | 0, 0, width, height, 0, GL_NONE, GL_NONE, data)) |
| 2583 | { |
| 2584 | return; |
| 2585 | } |
| 2586 | |
| 2587 | if (context->getClientVersion() >= 3 && |
| 2588 | !validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 2589 | 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 2590 | { |
| 2591 | return; |
| 2592 | } |
| 2593 | |
| 2594 | 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] | 2595 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2596 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2597 | } |
| 2598 | |
| 2599 | switch (target) |
| 2600 | { |
| 2601 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2602 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2603 | gl::Texture2D *texture = context->getTexture2D(); |
| 2604 | texture->setCompressedImage(level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2605 | } |
| 2606 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2607 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2608 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2609 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2610 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2611 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2612 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2613 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2614 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2615 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 2616 | texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2617 | } |
| 2618 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2619 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2620 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2621 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2622 | } |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2623 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2624 | } |
| 2625 | catch(std::bad_alloc&) |
| 2626 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2627 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2628 | } |
| 2629 | } |
| 2630 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2631 | void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 2632 | GLenum format, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2633 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2634 | 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] | 2635 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2636 | "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2637 | target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 2638 | |
| 2639 | try |
| 2640 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2641 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2642 | |
| 2643 | if (context) |
| 2644 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2645 | if (context->getClientVersion() < 3 && |
| 2646 | !validateES2TexImageParameters(context, target, level, GL_NONE, true, true, |
| 2647 | xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data)) |
| 2648 | { |
| 2649 | return; |
| 2650 | } |
| 2651 | |
| 2652 | if (context->getClientVersion() >= 3 && |
| 2653 | !validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 2654 | xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 2655 | { |
| 2656 | return; |
| 2657 | } |
| 2658 | |
| 2659 | 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] | 2660 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2661 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2662 | } |
| 2663 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2664 | switch (target) |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2665 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2666 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2667 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2668 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 2669 | texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2670 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2671 | break; |
| 2672 | |
| 2673 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2674 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2675 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2676 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2677 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2678 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2679 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2680 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 2681 | texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2682 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2683 | break; |
| 2684 | |
| 2685 | default: |
| 2686 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2687 | } |
| 2688 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2689 | } |
| 2690 | catch(std::bad_alloc&) |
| 2691 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2692 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2693 | } |
| 2694 | } |
| 2695 | |
| 2696 | void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) |
| 2697 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2698 | 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] | 2699 | "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] | 2700 | target, level, internalformat, x, y, width, height, border); |
| 2701 | |
| 2702 | try |
| 2703 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2704 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2705 | |
| 2706 | if (context) |
| 2707 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2708 | if (context->getClientVersion() < 3 && |
| 2709 | !validateES2CopyTexImageParameters(context, target, level, internalformat, false, |
| 2710 | 0, 0, x, y, width, height, border)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 2711 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2712 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 2713 | } |
| 2714 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2715 | if (context->getClientVersion() >= 3 && |
| 2716 | !validateES3CopyTexImageParameters(context, target, level, internalformat, false, |
| 2717 | 0, 0, 0, x, y, width, height, border)) |
| 2718 | { |
| 2719 | return; |
| 2720 | } |
| 2721 | |
| 2722 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 2723 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2724 | switch (target) |
| 2725 | { |
| 2726 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2727 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2728 | gl::Texture2D *texture = context->getTexture2D(); |
| 2729 | texture->copyImage(level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2730 | } |
| 2731 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2732 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2733 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2734 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2735 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2736 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2737 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2738 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2739 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2740 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 2741 | texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2742 | } |
| 2743 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2744 | |
| 2745 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2746 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2747 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2748 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2749 | } |
| 2750 | catch(std::bad_alloc&) |
| 2751 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2752 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2753 | } |
| 2754 | } |
| 2755 | |
| 2756 | void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 2757 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2758 | 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] | 2759 | "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] | 2760 | target, level, xoffset, yoffset, x, y, width, height); |
| 2761 | |
| 2762 | try |
| 2763 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2764 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2765 | |
| 2766 | if (context) |
| 2767 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2768 | if (context->getClientVersion() < 3 && |
| 2769 | !validateES2CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 2770 | xoffset, yoffset, x, y, width, height, 0)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2771 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2772 | return; |
| 2773 | } |
| 2774 | |
| 2775 | if (context->getClientVersion() >= 3 && |
| 2776 | !validateES3CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 2777 | xoffset, yoffset, 0, x, y, width, height, 0)) |
| 2778 | { |
| 2779 | return; |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2780 | } |
| 2781 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2782 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 2783 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2784 | switch (target) |
daniel@transgaming.com | bbc5779 | 2010-07-28 19:21:05 +0000 | [diff] [blame] | 2785 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2786 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 2787 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2788 | gl::Texture2D *texture = context->getTexture2D(); |
| 2789 | 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] | 2790 | } |
| 2791 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2792 | |
| 2793 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2794 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2795 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2796 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2797 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2798 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 2799 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2800 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 2801 | 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] | 2802 | } |
| 2803 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2804 | |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 2805 | default: |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2806 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 2807 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2808 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2809 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2810 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2811 | catch(std::bad_alloc&) |
| 2812 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2813 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2814 | } |
| 2815 | } |
| 2816 | |
| 2817 | GLuint __stdcall glCreateProgram(void) |
| 2818 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2819 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2820 | |
| 2821 | try |
| 2822 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2823 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2824 | |
| 2825 | if (context) |
| 2826 | { |
| 2827 | return context->createProgram(); |
| 2828 | } |
| 2829 | } |
| 2830 | catch(std::bad_alloc&) |
| 2831 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2832 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2833 | } |
| 2834 | |
| 2835 | return 0; |
| 2836 | } |
| 2837 | |
| 2838 | GLuint __stdcall glCreateShader(GLenum type) |
| 2839 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2840 | EVENT("(GLenum type = 0x%X)", type); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2841 | |
| 2842 | try |
| 2843 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2844 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2845 | |
| 2846 | if (context) |
| 2847 | { |
| 2848 | switch (type) |
| 2849 | { |
| 2850 | case GL_FRAGMENT_SHADER: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2851 | case GL_VERTEX_SHADER: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2852 | return context->createShader(type); |
| 2853 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2854 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2855 | } |
| 2856 | } |
| 2857 | } |
| 2858 | catch(std::bad_alloc&) |
| 2859 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2860 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2861 | } |
| 2862 | |
| 2863 | return 0; |
| 2864 | } |
| 2865 | |
| 2866 | void __stdcall glCullFace(GLenum mode) |
| 2867 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2868 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2869 | |
| 2870 | try |
| 2871 | { |
| 2872 | switch (mode) |
| 2873 | { |
| 2874 | case GL_FRONT: |
| 2875 | case GL_BACK: |
| 2876 | case GL_FRONT_AND_BACK: |
| 2877 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2878 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2879 | |
| 2880 | if (context) |
| 2881 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2882 | context->setCullMode(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2883 | } |
| 2884 | } |
| 2885 | break; |
| 2886 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2887 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2888 | } |
| 2889 | } |
| 2890 | catch(std::bad_alloc&) |
| 2891 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2892 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2893 | } |
| 2894 | } |
| 2895 | |
| 2896 | void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers) |
| 2897 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2898 | 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] | 2899 | |
| 2900 | try |
| 2901 | { |
| 2902 | if (n < 0) |
| 2903 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2904 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2905 | } |
| 2906 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2907 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2908 | |
| 2909 | if (context) |
| 2910 | { |
| 2911 | for (int i = 0; i < n; i++) |
| 2912 | { |
| 2913 | context->deleteBuffer(buffers[i]); |
| 2914 | } |
| 2915 | } |
| 2916 | } |
| 2917 | catch(std::bad_alloc&) |
| 2918 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2919 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2920 | } |
| 2921 | } |
| 2922 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2923 | void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences) |
| 2924 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2925 | 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] | 2926 | |
| 2927 | try |
| 2928 | { |
| 2929 | if (n < 0) |
| 2930 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2931 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2932 | } |
| 2933 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2934 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2935 | |
| 2936 | if (context) |
| 2937 | { |
| 2938 | for (int i = 0; i < n; i++) |
| 2939 | { |
| 2940 | context->deleteFence(fences[i]); |
| 2941 | } |
| 2942 | } |
| 2943 | } |
| 2944 | catch(std::bad_alloc&) |
| 2945 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2946 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2947 | } |
| 2948 | } |
| 2949 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2950 | void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) |
| 2951 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2952 | 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] | 2953 | |
| 2954 | try |
| 2955 | { |
| 2956 | if (n < 0) |
| 2957 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2958 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2959 | } |
| 2960 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2961 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2962 | |
| 2963 | if (context) |
| 2964 | { |
| 2965 | for (int i = 0; i < n; i++) |
| 2966 | { |
| 2967 | if (framebuffers[i] != 0) |
| 2968 | { |
| 2969 | context->deleteFramebuffer(framebuffers[i]); |
| 2970 | } |
| 2971 | } |
| 2972 | } |
| 2973 | } |
| 2974 | catch(std::bad_alloc&) |
| 2975 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2976 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2977 | } |
| 2978 | } |
| 2979 | |
| 2980 | void __stdcall glDeleteProgram(GLuint program) |
| 2981 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2982 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2983 | |
| 2984 | try |
| 2985 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 2986 | if (program == 0) |
| 2987 | { |
| 2988 | return; |
| 2989 | } |
| 2990 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2991 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2992 | |
| 2993 | if (context) |
| 2994 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 2995 | if (!context->getProgram(program)) |
| 2996 | { |
| 2997 | if(context->getShader(program)) |
| 2998 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2999 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3000 | } |
| 3001 | else |
| 3002 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3003 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3004 | } |
| 3005 | } |
| 3006 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3007 | context->deleteProgram(program); |
| 3008 | } |
| 3009 | } |
| 3010 | catch(std::bad_alloc&) |
| 3011 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3012 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3013 | } |
| 3014 | } |
| 3015 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3016 | void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids) |
| 3017 | { |
| 3018 | EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids); |
| 3019 | |
| 3020 | try |
| 3021 | { |
| 3022 | if (n < 0) |
| 3023 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3024 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3025 | } |
| 3026 | |
| 3027 | gl::Context *context = gl::getNonLostContext(); |
| 3028 | |
| 3029 | if (context) |
| 3030 | { |
| 3031 | for (int i = 0; i < n; i++) |
| 3032 | { |
| 3033 | context->deleteQuery(ids[i]); |
| 3034 | } |
| 3035 | } |
| 3036 | } |
| 3037 | catch(std::bad_alloc&) |
| 3038 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3039 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3040 | } |
| 3041 | } |
| 3042 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3043 | void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) |
| 3044 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3045 | 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] | 3046 | |
| 3047 | try |
| 3048 | { |
| 3049 | if (n < 0) |
| 3050 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3051 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3052 | } |
| 3053 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3054 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3055 | |
| 3056 | if (context) |
| 3057 | { |
daniel@transgaming.com | e2b2212 | 2010-03-11 19:22:14 +0000 | [diff] [blame] | 3058 | for (int i = 0; i < n; i++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3059 | { |
| 3060 | context->deleteRenderbuffer(renderbuffers[i]); |
| 3061 | } |
| 3062 | } |
| 3063 | } |
| 3064 | catch(std::bad_alloc&) |
| 3065 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3066 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3067 | } |
| 3068 | } |
| 3069 | |
| 3070 | void __stdcall glDeleteShader(GLuint shader) |
| 3071 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3072 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3073 | |
| 3074 | try |
| 3075 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3076 | if (shader == 0) |
| 3077 | { |
| 3078 | return; |
| 3079 | } |
| 3080 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3081 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3082 | |
| 3083 | if (context) |
| 3084 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3085 | if (!context->getShader(shader)) |
| 3086 | { |
| 3087 | if(context->getProgram(shader)) |
| 3088 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3089 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3090 | } |
| 3091 | else |
| 3092 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3093 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3094 | } |
| 3095 | } |
| 3096 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3097 | context->deleteShader(shader); |
| 3098 | } |
| 3099 | } |
| 3100 | catch(std::bad_alloc&) |
| 3101 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3102 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3103 | } |
| 3104 | } |
| 3105 | |
| 3106 | void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures) |
| 3107 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3108 | 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] | 3109 | |
| 3110 | try |
| 3111 | { |
| 3112 | if (n < 0) |
| 3113 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3114 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3115 | } |
| 3116 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3117 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3118 | |
| 3119 | if (context) |
| 3120 | { |
| 3121 | for (int i = 0; i < n; i++) |
| 3122 | { |
| 3123 | if (textures[i] != 0) |
| 3124 | { |
| 3125 | context->deleteTexture(textures[i]); |
| 3126 | } |
| 3127 | } |
| 3128 | } |
| 3129 | } |
| 3130 | catch(std::bad_alloc&) |
| 3131 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3132 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3133 | } |
| 3134 | } |
| 3135 | |
| 3136 | void __stdcall glDepthFunc(GLenum func) |
| 3137 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3138 | EVENT("(GLenum func = 0x%X)", func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3139 | |
| 3140 | try |
| 3141 | { |
| 3142 | switch (func) |
| 3143 | { |
| 3144 | case GL_NEVER: |
| 3145 | case GL_ALWAYS: |
| 3146 | case GL_LESS: |
| 3147 | case GL_LEQUAL: |
| 3148 | case GL_EQUAL: |
| 3149 | case GL_GREATER: |
| 3150 | case GL_GEQUAL: |
| 3151 | case GL_NOTEQUAL: |
| 3152 | break; |
| 3153 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3154 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3155 | } |
| 3156 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3157 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3158 | |
| 3159 | if (context) |
| 3160 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3161 | context->setDepthFunc(func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3162 | } |
| 3163 | } |
| 3164 | catch(std::bad_alloc&) |
| 3165 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3166 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3167 | } |
| 3168 | } |
| 3169 | |
| 3170 | void __stdcall glDepthMask(GLboolean flag) |
| 3171 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 3172 | EVENT("(GLboolean flag = %u)", flag); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3173 | |
| 3174 | try |
| 3175 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3176 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3177 | |
| 3178 | if (context) |
| 3179 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3180 | context->setDepthMask(flag != GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3181 | } |
| 3182 | } |
| 3183 | catch(std::bad_alloc&) |
| 3184 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3185 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3186 | } |
| 3187 | } |
| 3188 | |
| 3189 | void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar) |
| 3190 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3191 | EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3192 | |
| 3193 | try |
| 3194 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3195 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3196 | |
| 3197 | if (context) |
| 3198 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3199 | context->setDepthRange(zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3200 | } |
| 3201 | } |
| 3202 | catch(std::bad_alloc&) |
| 3203 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3204 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3205 | } |
| 3206 | } |
| 3207 | |
| 3208 | void __stdcall glDetachShader(GLuint program, GLuint shader) |
| 3209 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3210 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3211 | |
| 3212 | try |
| 3213 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3214 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3215 | |
| 3216 | if (context) |
| 3217 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3218 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3219 | gl::Program *programObject = context->getProgram(program); |
| 3220 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3221 | |
| 3222 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3223 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3224 | gl::Shader *shaderByProgramHandle; |
| 3225 | shaderByProgramHandle = context->getShader(program); |
| 3226 | if (!shaderByProgramHandle) |
| 3227 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3228 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3229 | } |
| 3230 | else |
| 3231 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3232 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3233 | } |
| 3234 | } |
| 3235 | |
| 3236 | if (!shaderObject) |
| 3237 | { |
| 3238 | gl::Program *programByShaderHandle = context->getProgram(shader); |
| 3239 | if (!programByShaderHandle) |
| 3240 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3241 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3242 | } |
| 3243 | else |
| 3244 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3245 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3246 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3247 | } |
| 3248 | |
| 3249 | if (!programObject->detachShader(shaderObject)) |
| 3250 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3251 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3252 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3253 | } |
| 3254 | } |
| 3255 | catch(std::bad_alloc&) |
| 3256 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3257 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3258 | } |
| 3259 | } |
| 3260 | |
| 3261 | void __stdcall glDisable(GLenum cap) |
| 3262 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3263 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3264 | |
| 3265 | try |
| 3266 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3267 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3268 | |
| 3269 | if (context) |
| 3270 | { |
| 3271 | switch (cap) |
| 3272 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3273 | case GL_CULL_FACE: context->setCullFace(false); break; |
| 3274 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break; |
| 3275 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break; |
| 3276 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break; |
| 3277 | case GL_SCISSOR_TEST: context->setScissorTest(false); break; |
| 3278 | case GL_STENCIL_TEST: context->setStencilTest(false); break; |
| 3279 | case GL_DEPTH_TEST: context->setDepthTest(false); break; |
| 3280 | case GL_BLEND: context->setBlend(false); break; |
| 3281 | case GL_DITHER: context->setDither(false); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 3282 | |
| 3283 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 3284 | case GL_RASTERIZER_DISCARD: |
| 3285 | if (context->getClientVersion() < 3) |
| 3286 | { |
| 3287 | return gl::error(GL_INVALID_ENUM); |
| 3288 | } |
| 3289 | UNIMPLEMENTED(); |
| 3290 | break; |
| 3291 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3292 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3293 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3294 | } |
| 3295 | } |
| 3296 | } |
| 3297 | catch(std::bad_alloc&) |
| 3298 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3299 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3300 | } |
| 3301 | } |
| 3302 | |
| 3303 | void __stdcall glDisableVertexAttribArray(GLuint index) |
| 3304 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3305 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3306 | |
| 3307 | try |
| 3308 | { |
| 3309 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3310 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3311 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3312 | } |
| 3313 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3314 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3315 | |
| 3316 | if (context) |
| 3317 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3318 | context->setEnableVertexAttribArray(index, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3319 | } |
| 3320 | } |
| 3321 | catch(std::bad_alloc&) |
| 3322 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3323 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3324 | } |
| 3325 | } |
| 3326 | |
| 3327 | void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count) |
| 3328 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3329 | 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] | 3330 | |
| 3331 | try |
| 3332 | { |
| 3333 | if (count < 0 || first < 0) |
| 3334 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3335 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3336 | } |
| 3337 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3338 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3339 | |
| 3340 | if (context) |
| 3341 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3342 | context->drawArrays(mode, first, count, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3343 | } |
| 3344 | } |
| 3345 | catch(std::bad_alloc&) |
| 3346 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3347 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3348 | } |
| 3349 | } |
| 3350 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3351 | void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
| 3352 | { |
| 3353 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount); |
| 3354 | |
| 3355 | try |
| 3356 | { |
| 3357 | if (count < 0 || first < 0 || primcount < 0) |
| 3358 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3359 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3360 | } |
| 3361 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3362 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3363 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3364 | gl::Context *context = gl::getNonLostContext(); |
| 3365 | |
| 3366 | if (context) |
| 3367 | { |
| 3368 | context->drawArrays(mode, first, count, primcount); |
| 3369 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3370 | } |
| 3371 | } |
| 3372 | catch(std::bad_alloc&) |
| 3373 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3374 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3375 | } |
| 3376 | } |
| 3377 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3378 | 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] | 3379 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3380 | 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] | 3381 | mode, count, type, indices); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3382 | |
| 3383 | try |
| 3384 | { |
| 3385 | if (count < 0) |
| 3386 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3387 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3388 | } |
| 3389 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3390 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3391 | |
| 3392 | if (context) |
| 3393 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3394 | switch (type) |
| 3395 | { |
| 3396 | case GL_UNSIGNED_BYTE: |
| 3397 | case GL_UNSIGNED_SHORT: |
| 3398 | break; |
| 3399 | case GL_UNSIGNED_INT: |
| 3400 | if (!context->supports32bitIndices()) |
| 3401 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3402 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3403 | } |
| 3404 | break; |
| 3405 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3406 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3407 | } |
| 3408 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3409 | context->drawElements(mode, count, type, indices, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3410 | } |
| 3411 | } |
| 3412 | catch(std::bad_alloc&) |
| 3413 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3414 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3415 | } |
| 3416 | } |
| 3417 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3418 | void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount) |
| 3419 | { |
| 3420 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)", |
| 3421 | mode, count, type, indices, primcount); |
| 3422 | |
| 3423 | try |
| 3424 | { |
| 3425 | if (count < 0 || primcount < 0) |
| 3426 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3427 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3428 | } |
| 3429 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3430 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3431 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3432 | gl::Context *context = gl::getNonLostContext(); |
| 3433 | |
| 3434 | if (context) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3435 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3436 | switch (type) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3437 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3438 | case GL_UNSIGNED_BYTE: |
| 3439 | case GL_UNSIGNED_SHORT: |
| 3440 | break; |
| 3441 | case GL_UNSIGNED_INT: |
| 3442 | if (!context->supports32bitIndices()) |
| 3443 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3444 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3445 | } |
| 3446 | break; |
| 3447 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3448 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3449 | } |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3450 | |
| 3451 | context->drawElements(mode, count, type, indices, primcount); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3452 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3453 | } |
| 3454 | } |
| 3455 | catch(std::bad_alloc&) |
| 3456 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3457 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3458 | } |
| 3459 | } |
| 3460 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3461 | void __stdcall glEnable(GLenum cap) |
| 3462 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3463 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3464 | |
| 3465 | try |
| 3466 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3467 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3468 | |
| 3469 | if (context) |
| 3470 | { |
| 3471 | switch (cap) |
| 3472 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3473 | case GL_CULL_FACE: context->setCullFace(true); break; |
| 3474 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break; |
| 3475 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break; |
| 3476 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break; |
| 3477 | case GL_SCISSOR_TEST: context->setScissorTest(true); break; |
| 3478 | case GL_STENCIL_TEST: context->setStencilTest(true); break; |
| 3479 | case GL_DEPTH_TEST: context->setDepthTest(true); break; |
| 3480 | case GL_BLEND: context->setBlend(true); break; |
| 3481 | case GL_DITHER: context->setDither(true); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3482 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3483 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3484 | } |
| 3485 | } |
| 3486 | } |
| 3487 | catch(std::bad_alloc&) |
| 3488 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3489 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3490 | } |
| 3491 | } |
| 3492 | |
| 3493 | void __stdcall glEnableVertexAttribArray(GLuint index) |
| 3494 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3495 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3496 | |
| 3497 | try |
| 3498 | { |
| 3499 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3500 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3501 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3502 | } |
| 3503 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3504 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3505 | |
| 3506 | if (context) |
| 3507 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3508 | context->setEnableVertexAttribArray(index, true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3509 | } |
| 3510 | } |
| 3511 | catch(std::bad_alloc&) |
| 3512 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3513 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3514 | } |
| 3515 | } |
| 3516 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3517 | void __stdcall glEndQueryEXT(GLenum target) |
| 3518 | { |
| 3519 | EVENT("GLenum target = 0x%X)", target); |
| 3520 | |
| 3521 | try |
| 3522 | { |
| 3523 | switch (target) |
| 3524 | { |
| 3525 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 3526 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 3527 | break; |
| 3528 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3529 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3530 | } |
| 3531 | |
| 3532 | gl::Context *context = gl::getNonLostContext(); |
| 3533 | |
| 3534 | if (context) |
| 3535 | { |
| 3536 | context->endQuery(target); |
| 3537 | } |
| 3538 | } |
| 3539 | catch(std::bad_alloc&) |
| 3540 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3541 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3542 | } |
| 3543 | } |
| 3544 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3545 | void __stdcall glFinishFenceNV(GLuint fence) |
| 3546 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3547 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3548 | |
| 3549 | try |
| 3550 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3551 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3552 | |
| 3553 | if (context) |
| 3554 | { |
| 3555 | gl::Fence* fenceObject = context->getFence(fence); |
| 3556 | |
| 3557 | if (fenceObject == NULL) |
| 3558 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3559 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3560 | } |
| 3561 | |
| 3562 | fenceObject->finishFence(); |
| 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); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3568 | } |
| 3569 | } |
| 3570 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3571 | void __stdcall glFinish(void) |
| 3572 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3573 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3574 | |
| 3575 | try |
| 3576 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3577 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3578 | |
| 3579 | if (context) |
| 3580 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 3581 | context->sync(true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3582 | } |
| 3583 | } |
| 3584 | catch(std::bad_alloc&) |
| 3585 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3586 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3587 | } |
| 3588 | } |
| 3589 | |
| 3590 | void __stdcall glFlush(void) |
| 3591 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3592 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3593 | |
| 3594 | try |
| 3595 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3596 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3597 | |
| 3598 | if (context) |
| 3599 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 3600 | context->sync(false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3601 | } |
| 3602 | } |
| 3603 | catch(std::bad_alloc&) |
| 3604 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3605 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3606 | } |
| 3607 | } |
| 3608 | |
| 3609 | void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) |
| 3610 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3611 | 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] | 3612 | "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3613 | |
| 3614 | try |
| 3615 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3616 | 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] | 3617 | || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3618 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3619 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3620 | } |
| 3621 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3622 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3623 | |
| 3624 | if (context) |
| 3625 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3626 | gl::Framebuffer *framebuffer = NULL; |
| 3627 | GLuint framebufferHandle = 0; |
| 3628 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 3629 | { |
| 3630 | framebuffer = context->getReadFramebuffer(); |
| 3631 | framebufferHandle = context->getReadFramebufferHandle(); |
| 3632 | } |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 3633 | else |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3634 | { |
| 3635 | framebuffer = context->getDrawFramebuffer(); |
| 3636 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 3637 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3638 | |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 3639 | if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3640 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3641 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3642 | } |
| 3643 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3644 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3645 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3646 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 3647 | |
| 3648 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 3649 | { |
| 3650 | return gl::error(GL_INVALID_VALUE); |
| 3651 | } |
| 3652 | |
| 3653 | framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer); |
| 3654 | } |
| 3655 | else |
| 3656 | { |
| 3657 | switch (attachment) |
| 3658 | { |
| 3659 | case GL_DEPTH_ATTACHMENT: |
| 3660 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer); |
| 3661 | break; |
| 3662 | case GL_STENCIL_ATTACHMENT: |
| 3663 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer); |
| 3664 | break; |
| 3665 | default: |
| 3666 | return gl::error(GL_INVALID_ENUM); |
| 3667 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3668 | } |
| 3669 | } |
| 3670 | } |
| 3671 | catch(std::bad_alloc&) |
| 3672 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3673 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3674 | } |
| 3675 | } |
| 3676 | |
| 3677 | void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) |
| 3678 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3679 | 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] | 3680 | "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3681 | |
| 3682 | try |
| 3683 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3684 | 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] | 3685 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3686 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3687 | } |
| 3688 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3689 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3690 | |
| 3691 | if (context) |
| 3692 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3693 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 3694 | { |
| 3695 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 3696 | |
| 3697 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 3698 | { |
| 3699 | return gl::error(GL_INVALID_VALUE); |
| 3700 | } |
| 3701 | } |
| 3702 | else |
| 3703 | { |
| 3704 | switch (attachment) |
| 3705 | { |
| 3706 | case GL_DEPTH_ATTACHMENT: |
| 3707 | case GL_STENCIL_ATTACHMENT: |
| 3708 | break; |
| 3709 | default: |
| 3710 | return gl::error(GL_INVALID_ENUM); |
| 3711 | } |
| 3712 | } |
| 3713 | |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3714 | if (texture == 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3715 | { |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3716 | textarget = GL_NONE; |
| 3717 | } |
| 3718 | else |
| 3719 | { |
| 3720 | gl::Texture *tex = context->getTexture(texture); |
| 3721 | |
| 3722 | if (tex == NULL) |
| 3723 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3724 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3725 | } |
| 3726 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3727 | switch (textarget) |
| 3728 | { |
| 3729 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3730 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3731 | if (tex->getTarget() != GL_TEXTURE_2D) |
| 3732 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3733 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3734 | } |
| 3735 | gl::Texture2D *tex2d = static_cast<gl::Texture2D *>(tex); |
daniel@transgaming.com | 92f4992 | 2012-05-09 15:49:19 +0000 | [diff] [blame] | 3736 | if (tex2d->isCompressed(0)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3737 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3738 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3739 | } |
| 3740 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3741 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3742 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3743 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3744 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3745 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3746 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3747 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3748 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3749 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3750 | if (tex->getTarget() != GL_TEXTURE_CUBE_MAP) |
| 3751 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3752 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3753 | } |
| 3754 | gl::TextureCubeMap *texcube = static_cast<gl::TextureCubeMap *>(tex); |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 3755 | if (texcube->isCompressed(textarget, level)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3756 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3757 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3758 | } |
| 3759 | break; |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3760 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3761 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3762 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3763 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3764 | } |
| 3765 | |
| 3766 | if (level != 0) |
| 3767 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3768 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3769 | } |
| 3770 | } |
| 3771 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3772 | gl::Framebuffer *framebuffer = NULL; |
| 3773 | GLuint framebufferHandle = 0; |
| 3774 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 3775 | { |
| 3776 | framebuffer = context->getReadFramebuffer(); |
| 3777 | framebufferHandle = context->getReadFramebufferHandle(); |
| 3778 | } |
| 3779 | else |
| 3780 | { |
| 3781 | framebuffer = context->getDrawFramebuffer(); |
| 3782 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 3783 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3784 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3785 | if (framebufferHandle == 0 || !framebuffer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3786 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3787 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3788 | } |
| 3789 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3790 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 3791 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3792 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 3793 | |
| 3794 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 3795 | { |
| 3796 | return gl::error(GL_INVALID_VALUE); |
| 3797 | } |
| 3798 | |
| 3799 | framebuffer->setColorbuffer(colorAttachment, textarget, texture); |
| 3800 | } |
| 3801 | else |
| 3802 | { |
| 3803 | switch (attachment) |
| 3804 | { |
| 3805 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break; |
| 3806 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break; |
| 3807 | } |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 3808 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3809 | } |
| 3810 | } |
| 3811 | catch(std::bad_alloc&) |
| 3812 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3813 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3814 | } |
| 3815 | } |
| 3816 | |
| 3817 | void __stdcall glFrontFace(GLenum mode) |
| 3818 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3819 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3820 | |
| 3821 | try |
| 3822 | { |
| 3823 | switch (mode) |
| 3824 | { |
| 3825 | case GL_CW: |
| 3826 | case GL_CCW: |
| 3827 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3828 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3829 | |
| 3830 | if (context) |
| 3831 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3832 | context->setFrontFace(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3833 | } |
| 3834 | } |
| 3835 | break; |
| 3836 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3837 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3838 | } |
| 3839 | } |
| 3840 | catch(std::bad_alloc&) |
| 3841 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3842 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3843 | } |
| 3844 | } |
| 3845 | |
| 3846 | void __stdcall glGenBuffers(GLsizei n, GLuint* buffers) |
| 3847 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3848 | EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3849 | |
| 3850 | try |
| 3851 | { |
| 3852 | if (n < 0) |
| 3853 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3854 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3855 | } |
| 3856 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3857 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3858 | |
| 3859 | if (context) |
| 3860 | { |
| 3861 | for (int i = 0; i < n; i++) |
| 3862 | { |
| 3863 | buffers[i] = context->createBuffer(); |
| 3864 | } |
| 3865 | } |
| 3866 | } |
| 3867 | catch(std::bad_alloc&) |
| 3868 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3869 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3870 | } |
| 3871 | } |
| 3872 | |
| 3873 | void __stdcall glGenerateMipmap(GLenum target) |
| 3874 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3875 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3876 | |
| 3877 | try |
| 3878 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3879 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3880 | |
| 3881 | if (context) |
| 3882 | { |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3883 | switch (target) |
| 3884 | { |
| 3885 | case GL_TEXTURE_2D: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3886 | { |
| 3887 | gl::Texture2D *tex2d = context->getTexture2D(); |
| 3888 | |
daniel@transgaming.com | 92f4992 | 2012-05-09 15:49:19 +0000 | [diff] [blame] | 3889 | if (tex2d->isCompressed(0)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3890 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3891 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3892 | } |
daniel@transgaming.com | 0c85468 | 2012-05-31 01:14:11 +0000 | [diff] [blame] | 3893 | if (tex2d->isDepth(0)) |
| 3894 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3895 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0c85468 | 2012-05-31 01:14:11 +0000 | [diff] [blame] | 3896 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3897 | |
| 3898 | tex2d->generateMipmaps(); |
| 3899 | break; |
| 3900 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3901 | |
| 3902 | case GL_TEXTURE_CUBE_MAP: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3903 | { |
| 3904 | gl::TextureCubeMap *texcube = context->getTextureCubeMap(); |
| 3905 | |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 3906 | if (texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3907 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3908 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3909 | } |
| 3910 | |
| 3911 | texcube->generateMipmaps(); |
| 3912 | break; |
| 3913 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3914 | |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 3915 | case GL_TEXTURE_3D: |
| 3916 | { |
| 3917 | if (context->getClientVersion() < 3) |
| 3918 | { |
| 3919 | return gl::error(GL_INVALID_ENUM); |
| 3920 | } |
| 3921 | |
| 3922 | gl::Texture3D *tex3D = context->getTexture3D(); |
| 3923 | if (tex3D->isCompressed(0)) |
| 3924 | { |
| 3925 | return gl::error(GL_INVALID_OPERATION); |
| 3926 | } |
| 3927 | |
| 3928 | tex3D->generateMipmaps(); |
| 3929 | break; |
| 3930 | } |
| 3931 | |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 3932 | case GL_TEXTURE_2D_ARRAY: |
| 3933 | { |
| 3934 | if (context->getClientVersion() < 3) |
| 3935 | { |
| 3936 | return gl::error(GL_INVALID_ENUM); |
| 3937 | } |
| 3938 | |
| 3939 | gl::Texture2DArray *tex2darr = context->getTexture2DArray(); |
| 3940 | if (tex2darr->isCompressed(0)) |
| 3941 | { |
| 3942 | return gl::error(GL_INVALID_OPERATION); |
| 3943 | } |
| 3944 | |
| 3945 | tex2darr->generateMipmaps(); |
| 3946 | break; |
| 3947 | } |
| 3948 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3949 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3950 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3951 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3952 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3953 | } |
| 3954 | catch(std::bad_alloc&) |
| 3955 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3956 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3957 | } |
| 3958 | } |
| 3959 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3960 | void __stdcall glGenFencesNV(GLsizei n, GLuint* fences) |
| 3961 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3962 | EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3963 | |
| 3964 | try |
| 3965 | { |
| 3966 | if (n < 0) |
| 3967 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3968 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3969 | } |
| 3970 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3971 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3972 | |
| 3973 | if (context) |
| 3974 | { |
| 3975 | for (int i = 0; i < n; i++) |
| 3976 | { |
| 3977 | fences[i] = context->createFence(); |
| 3978 | } |
| 3979 | } |
| 3980 | } |
| 3981 | catch(std::bad_alloc&) |
| 3982 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3983 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3984 | } |
| 3985 | } |
| 3986 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3987 | void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers) |
| 3988 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3989 | EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3990 | |
| 3991 | try |
| 3992 | { |
| 3993 | if (n < 0) |
| 3994 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3995 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3996 | } |
| 3997 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3998 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3999 | |
| 4000 | if (context) |
| 4001 | { |
| 4002 | for (int i = 0; i < n; i++) |
| 4003 | { |
| 4004 | framebuffers[i] = context->createFramebuffer(); |
| 4005 | } |
| 4006 | } |
| 4007 | } |
| 4008 | catch(std::bad_alloc&) |
| 4009 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4010 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4011 | } |
| 4012 | } |
| 4013 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4014 | void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids) |
| 4015 | { |
| 4016 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 4017 | |
| 4018 | try |
| 4019 | { |
| 4020 | if (n < 0) |
| 4021 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4022 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4023 | } |
| 4024 | |
| 4025 | gl::Context *context = gl::getNonLostContext(); |
| 4026 | |
| 4027 | if (context) |
| 4028 | { |
| 4029 | for (int i = 0; i < n; i++) |
| 4030 | { |
| 4031 | ids[i] = context->createQuery(); |
| 4032 | } |
| 4033 | } |
| 4034 | } |
| 4035 | catch(std::bad_alloc&) |
| 4036 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4037 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4038 | } |
| 4039 | } |
| 4040 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4041 | void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) |
| 4042 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4043 | EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4044 | |
| 4045 | try |
| 4046 | { |
| 4047 | if (n < 0) |
| 4048 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4049 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4050 | } |
| 4051 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4052 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4053 | |
| 4054 | if (context) |
| 4055 | { |
| 4056 | for (int i = 0; i < n; i++) |
| 4057 | { |
| 4058 | renderbuffers[i] = context->createRenderbuffer(); |
| 4059 | } |
| 4060 | } |
| 4061 | } |
| 4062 | catch(std::bad_alloc&) |
| 4063 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4064 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4065 | } |
| 4066 | } |
| 4067 | |
| 4068 | void __stdcall glGenTextures(GLsizei n, GLuint* textures) |
| 4069 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4070 | EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4071 | |
| 4072 | try |
| 4073 | { |
| 4074 | if (n < 0) |
| 4075 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4076 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4077 | } |
| 4078 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4079 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4080 | |
| 4081 | if (context) |
| 4082 | { |
| 4083 | for (int i = 0; i < n; i++) |
| 4084 | { |
| 4085 | textures[i] = context->createTexture(); |
| 4086 | } |
| 4087 | } |
| 4088 | } |
| 4089 | catch(std::bad_alloc&) |
| 4090 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4091 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4092 | } |
| 4093 | } |
| 4094 | |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4095 | 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] | 4096 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4097 | 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] | 4098 | "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] | 4099 | program, index, bufsize, length, size, type, name); |
| 4100 | |
| 4101 | try |
| 4102 | { |
| 4103 | if (bufsize < 0) |
| 4104 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4105 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4106 | } |
| 4107 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4108 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4109 | |
| 4110 | if (context) |
| 4111 | { |
| 4112 | gl::Program *programObject = context->getProgram(program); |
| 4113 | |
| 4114 | if (!programObject) |
| 4115 | { |
| 4116 | if (context->getShader(program)) |
| 4117 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4118 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4119 | } |
| 4120 | else |
| 4121 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4122 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4123 | } |
| 4124 | } |
| 4125 | |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4126 | if (index >= (GLuint)programObject->getActiveAttributeCount()) |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4127 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4128 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4129 | } |
| 4130 | |
| 4131 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 4132 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4133 | } |
| 4134 | catch(std::bad_alloc&) |
| 4135 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4136 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4137 | } |
| 4138 | } |
| 4139 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4140 | 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] | 4141 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4142 | EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4143 | "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] | 4144 | program, index, bufsize, length, size, type, name); |
| 4145 | |
| 4146 | try |
| 4147 | { |
| 4148 | if (bufsize < 0) |
| 4149 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4150 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4151 | } |
| 4152 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4153 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4154 | |
| 4155 | if (context) |
| 4156 | { |
| 4157 | gl::Program *programObject = context->getProgram(program); |
| 4158 | |
| 4159 | if (!programObject) |
| 4160 | { |
| 4161 | if (context->getShader(program)) |
| 4162 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4163 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4164 | } |
| 4165 | else |
| 4166 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4167 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4168 | } |
| 4169 | } |
| 4170 | |
| 4171 | if (index >= (GLuint)programObject->getActiveUniformCount()) |
| 4172 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4173 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4174 | } |
| 4175 | |
| 4176 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 4177 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4178 | } |
| 4179 | catch(std::bad_alloc&) |
| 4180 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4181 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4182 | } |
| 4183 | } |
| 4184 | |
| 4185 | void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) |
| 4186 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4187 | 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] | 4188 | program, maxcount, count, shaders); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4189 | |
| 4190 | try |
| 4191 | { |
| 4192 | if (maxcount < 0) |
| 4193 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4194 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4195 | } |
| 4196 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4197 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4198 | |
| 4199 | if (context) |
| 4200 | { |
| 4201 | gl::Program *programObject = context->getProgram(program); |
| 4202 | |
| 4203 | if (!programObject) |
| 4204 | { |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4205 | if (context->getShader(program)) |
| 4206 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4207 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4208 | } |
| 4209 | else |
| 4210 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4211 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4212 | } |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4213 | } |
| 4214 | |
| 4215 | return programObject->getAttachedShaders(maxcount, count, shaders); |
| 4216 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4217 | } |
| 4218 | catch(std::bad_alloc&) |
| 4219 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4220 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4221 | } |
| 4222 | } |
| 4223 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4224 | int __stdcall glGetAttribLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4225 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4226 | EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4227 | |
| 4228 | try |
| 4229 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4230 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4231 | |
| 4232 | if (context) |
| 4233 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4234 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4235 | gl::Program *programObject = context->getProgram(program); |
| 4236 | |
| 4237 | if (!programObject) |
| 4238 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4239 | if (context->getShader(program)) |
| 4240 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4241 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4242 | } |
| 4243 | else |
| 4244 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4245 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4246 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4247 | } |
| 4248 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4249 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 4250 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4251 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4252 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4253 | } |
| 4254 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4255 | return programBinary->getAttributeLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4256 | } |
| 4257 | } |
| 4258 | catch(std::bad_alloc&) |
| 4259 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4260 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4261 | } |
| 4262 | |
| 4263 | return -1; |
| 4264 | } |
| 4265 | |
| 4266 | void __stdcall glGetBooleanv(GLenum pname, GLboolean* params) |
| 4267 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4268 | 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] | 4269 | |
| 4270 | try |
| 4271 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4272 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4273 | |
| 4274 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4275 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4276 | if (!(context->getBooleanv(pname, params))) |
| 4277 | { |
| 4278 | GLenum nativeType; |
| 4279 | unsigned int numParams = 0; |
| 4280 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4281 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4282 | |
| 4283 | if (numParams == 0) |
| 4284 | return; // it is known that the pname is valid, but there are no parameters to return |
| 4285 | |
| 4286 | if (nativeType == GL_FLOAT) |
| 4287 | { |
| 4288 | GLfloat *floatParams = NULL; |
| 4289 | floatParams = new GLfloat[numParams]; |
| 4290 | |
| 4291 | context->getFloatv(pname, floatParams); |
| 4292 | |
| 4293 | for (unsigned int i = 0; i < numParams; ++i) |
| 4294 | { |
| 4295 | if (floatParams[i] == 0.0f) |
| 4296 | params[i] = GL_FALSE; |
| 4297 | else |
| 4298 | params[i] = GL_TRUE; |
| 4299 | } |
| 4300 | |
| 4301 | delete [] floatParams; |
| 4302 | } |
| 4303 | else if (nativeType == GL_INT) |
| 4304 | { |
| 4305 | GLint *intParams = NULL; |
| 4306 | intParams = new GLint[numParams]; |
| 4307 | |
| 4308 | context->getIntegerv(pname, intParams); |
| 4309 | |
| 4310 | for (unsigned int i = 0; i < numParams; ++i) |
| 4311 | { |
| 4312 | if (intParams[i] == 0) |
| 4313 | params[i] = GL_FALSE; |
| 4314 | else |
| 4315 | params[i] = GL_TRUE; |
| 4316 | } |
| 4317 | |
| 4318 | delete [] intParams; |
| 4319 | } |
| 4320 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4321 | } |
| 4322 | } |
| 4323 | catch(std::bad_alloc&) |
| 4324 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4325 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4326 | } |
| 4327 | } |
| 4328 | |
| 4329 | void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 4330 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4331 | 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] | 4332 | |
| 4333 | try |
| 4334 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4335 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4336 | |
| 4337 | if (context) |
| 4338 | { |
| 4339 | gl::Buffer *buffer; |
| 4340 | |
| 4341 | switch (target) |
| 4342 | { |
| 4343 | case GL_ARRAY_BUFFER: |
| 4344 | buffer = context->getArrayBuffer(); |
| 4345 | break; |
| 4346 | case GL_ELEMENT_ARRAY_BUFFER: |
| 4347 | buffer = context->getElementArrayBuffer(); |
| 4348 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4349 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4350 | } |
| 4351 | |
| 4352 | if (!buffer) |
| 4353 | { |
| 4354 | // 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] | 4355 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4356 | } |
| 4357 | |
| 4358 | switch (pname) |
| 4359 | { |
| 4360 | case GL_BUFFER_USAGE: |
| 4361 | *params = buffer->usage(); |
| 4362 | break; |
| 4363 | case GL_BUFFER_SIZE: |
| 4364 | *params = buffer->size(); |
| 4365 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4366 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4367 | } |
| 4368 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4369 | } |
| 4370 | catch(std::bad_alloc&) |
| 4371 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4372 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4373 | } |
| 4374 | } |
| 4375 | |
| 4376 | GLenum __stdcall glGetError(void) |
| 4377 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4378 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4379 | |
| 4380 | gl::Context *context = gl::getContext(); |
| 4381 | |
| 4382 | if (context) |
| 4383 | { |
daniel@transgaming.com | 82b2891 | 2011-12-12 21:01:35 +0000 | [diff] [blame] | 4384 | return context->getError(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4385 | } |
| 4386 | |
| 4387 | return GL_NO_ERROR; |
| 4388 | } |
| 4389 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4390 | void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 4391 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4392 | 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] | 4393 | |
| 4394 | try |
| 4395 | { |
| 4396 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4397 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4398 | |
| 4399 | if (context) |
| 4400 | { |
| 4401 | gl::Fence *fenceObject = context->getFence(fence); |
| 4402 | |
| 4403 | if (fenceObject == NULL) |
| 4404 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4405 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4406 | } |
| 4407 | |
| 4408 | fenceObject->getFenceiv(pname, params); |
| 4409 | } |
| 4410 | } |
| 4411 | catch(std::bad_alloc&) |
| 4412 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4413 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4414 | } |
| 4415 | } |
| 4416 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4417 | void __stdcall glGetFloatv(GLenum pname, GLfloat* params) |
| 4418 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4419 | 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] | 4420 | |
| 4421 | try |
| 4422 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4423 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4424 | |
| 4425 | if (context) |
| 4426 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4427 | if (!(context->getFloatv(pname, params))) |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4428 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4429 | GLenum nativeType; |
| 4430 | unsigned int numParams = 0; |
| 4431 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4432 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4433 | |
| 4434 | if (numParams == 0) |
| 4435 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 4436 | |
| 4437 | if (nativeType == GL_BOOL) |
| 4438 | { |
| 4439 | GLboolean *boolParams = NULL; |
| 4440 | boolParams = new GLboolean[numParams]; |
| 4441 | |
| 4442 | context->getBooleanv(pname, boolParams); |
| 4443 | |
| 4444 | for (unsigned int i = 0; i < numParams; ++i) |
| 4445 | { |
| 4446 | if (boolParams[i] == GL_FALSE) |
| 4447 | params[i] = 0.0f; |
| 4448 | else |
| 4449 | params[i] = 1.0f; |
| 4450 | } |
| 4451 | |
| 4452 | delete [] boolParams; |
| 4453 | } |
| 4454 | else if (nativeType == GL_INT) |
| 4455 | { |
| 4456 | GLint *intParams = NULL; |
| 4457 | intParams = new GLint[numParams]; |
| 4458 | |
| 4459 | context->getIntegerv(pname, intParams); |
| 4460 | |
| 4461 | for (unsigned int i = 0; i < numParams; ++i) |
| 4462 | { |
| 4463 | params[i] = (GLfloat)intParams[i]; |
| 4464 | } |
| 4465 | |
| 4466 | delete [] intParams; |
| 4467 | } |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4468 | } |
| 4469 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4470 | } |
| 4471 | catch(std::bad_alloc&) |
| 4472 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4473 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4474 | } |
| 4475 | } |
| 4476 | |
| 4477 | void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) |
| 4478 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4479 | 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] | 4480 | target, attachment, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4481 | |
| 4482 | try |
| 4483 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4484 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4485 | |
| 4486 | if (context) |
| 4487 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4488 | 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] | 4489 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4490 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4491 | } |
| 4492 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4493 | gl::Framebuffer *framebuffer = NULL; |
| 4494 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4495 | { |
| 4496 | if(context->getReadFramebufferHandle() == 0) |
| 4497 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4498 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4499 | } |
| 4500 | |
| 4501 | framebuffer = context->getReadFramebuffer(); |
| 4502 | } |
| 4503 | else |
| 4504 | { |
| 4505 | if (context->getDrawFramebufferHandle() == 0) |
| 4506 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4507 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4508 | } |
| 4509 | |
| 4510 | framebuffer = context->getDrawFramebuffer(); |
| 4511 | } |
| 4512 | |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4513 | GLenum attachmentType; |
| 4514 | GLuint attachmentHandle; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4515 | |
| 4516 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4517 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4518 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4519 | |
| 4520 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4521 | { |
| 4522 | return gl::error(GL_INVALID_ENUM); |
| 4523 | } |
| 4524 | |
| 4525 | attachmentType = framebuffer->getColorbufferType(colorAttachment); |
| 4526 | attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment); |
| 4527 | } |
| 4528 | else |
| 4529 | { |
| 4530 | switch (attachment) |
| 4531 | { |
| 4532 | case GL_DEPTH_ATTACHMENT: |
| 4533 | attachmentType = framebuffer->getDepthbufferType(); |
| 4534 | attachmentHandle = framebuffer->getDepthbufferHandle(); |
| 4535 | break; |
| 4536 | case GL_STENCIL_ATTACHMENT: |
| 4537 | attachmentType = framebuffer->getStencilbufferType(); |
| 4538 | attachmentHandle = framebuffer->getStencilbufferHandle(); |
| 4539 | break; |
| 4540 | default: return gl::error(GL_INVALID_ENUM); |
| 4541 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4542 | } |
| 4543 | |
| 4544 | GLenum attachmentObjectType; // Type category |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4545 | if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4546 | { |
| 4547 | attachmentObjectType = attachmentType; |
| 4548 | } |
apatrick@chromium.org | 551022e | 2012-01-23 19:56:54 +0000 | [diff] [blame] | 4549 | else if (gl::IsInternalTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4550 | { |
| 4551 | attachmentObjectType = GL_TEXTURE; |
| 4552 | } |
apatrick@chromium.org | a1d8059 | 2012-01-25 21:52:10 +0000 | [diff] [blame] | 4553 | else |
| 4554 | { |
| 4555 | UNREACHABLE(); |
| 4556 | return; |
| 4557 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4558 | |
| 4559 | switch (pname) |
| 4560 | { |
| 4561 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 4562 | *params = attachmentObjectType; |
| 4563 | break; |
| 4564 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 4565 | if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE) |
| 4566 | { |
| 4567 | *params = attachmentHandle; |
| 4568 | } |
| 4569 | else |
| 4570 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4571 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4572 | } |
| 4573 | break; |
| 4574 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 4575 | if (attachmentObjectType == GL_TEXTURE) |
| 4576 | { |
| 4577 | *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0 |
| 4578 | } |
| 4579 | else |
| 4580 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4581 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4582 | } |
| 4583 | break; |
| 4584 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 4585 | if (attachmentObjectType == GL_TEXTURE) |
| 4586 | { |
daniel@transgaming.com | 19ffc24 | 2010-05-04 03:35:21 +0000 | [diff] [blame] | 4587 | if (gl::IsCubemapTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4588 | { |
| 4589 | *params = attachmentType; |
| 4590 | } |
| 4591 | else |
| 4592 | { |
| 4593 | *params = 0; |
| 4594 | } |
| 4595 | } |
| 4596 | else |
| 4597 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4598 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4599 | } |
| 4600 | break; |
| 4601 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4602 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4603 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4604 | } |
| 4605 | } |
| 4606 | catch(std::bad_alloc&) |
| 4607 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4608 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4609 | } |
| 4610 | } |
| 4611 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 4612 | GLenum __stdcall glGetGraphicsResetStatusEXT(void) |
| 4613 | { |
| 4614 | EVENT("()"); |
| 4615 | |
| 4616 | try |
| 4617 | { |
| 4618 | gl::Context *context = gl::getContext(); |
| 4619 | |
| 4620 | if (context) |
| 4621 | { |
| 4622 | return context->getResetStatus(); |
| 4623 | } |
| 4624 | |
| 4625 | return GL_NO_ERROR; |
| 4626 | } |
| 4627 | catch(std::bad_alloc&) |
| 4628 | { |
| 4629 | return GL_OUT_OF_MEMORY; |
| 4630 | } |
| 4631 | } |
| 4632 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4633 | void __stdcall glGetIntegerv(GLenum pname, GLint* params) |
| 4634 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4635 | 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] | 4636 | |
| 4637 | try |
| 4638 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4639 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4640 | |
| 4641 | if (context) |
| 4642 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4643 | if (!(context->getIntegerv(pname, params))) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4644 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4645 | GLenum nativeType; |
| 4646 | unsigned int numParams = 0; |
| 4647 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4648 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4649 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4650 | if (numParams == 0) |
| 4651 | return; // it is known that pname is valid, but there are no parameters to return |
| 4652 | |
| 4653 | if (nativeType == GL_BOOL) |
| 4654 | { |
| 4655 | GLboolean *boolParams = NULL; |
| 4656 | boolParams = new GLboolean[numParams]; |
| 4657 | |
| 4658 | context->getBooleanv(pname, boolParams); |
| 4659 | |
| 4660 | for (unsigned int i = 0; i < numParams; ++i) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4661 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4662 | if (boolParams[i] == GL_FALSE) |
| 4663 | params[i] = 0; |
| 4664 | else |
| 4665 | params[i] = 1; |
| 4666 | } |
| 4667 | |
| 4668 | delete [] boolParams; |
| 4669 | } |
| 4670 | else if (nativeType == GL_FLOAT) |
| 4671 | { |
| 4672 | GLfloat *floatParams = NULL; |
| 4673 | floatParams = new GLfloat[numParams]; |
| 4674 | |
| 4675 | context->getFloatv(pname, floatParams); |
| 4676 | |
| 4677 | for (unsigned int i = 0; i < numParams; ++i) |
| 4678 | { |
daniel@transgaming.com | c164135 | 2010-04-26 15:33:36 +0000 | [diff] [blame] | 4679 | 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] | 4680 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4681 | params[i] = (GLint)(((GLfloat)(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4682 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4683 | else |
| 4684 | 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] | 4685 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4686 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4687 | delete [] floatParams; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4688 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4689 | } |
| 4690 | } |
| 4691 | } |
| 4692 | catch(std::bad_alloc&) |
| 4693 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4694 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4695 | } |
| 4696 | } |
| 4697 | |
| 4698 | void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params) |
| 4699 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4700 | 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] | 4701 | |
| 4702 | try |
| 4703 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4704 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4705 | |
| 4706 | if (context) |
| 4707 | { |
| 4708 | gl::Program *programObject = context->getProgram(program); |
| 4709 | |
| 4710 | if (!programObject) |
| 4711 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4712 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4713 | } |
| 4714 | |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 4715 | if (context->getClientVersion() < 3) |
| 4716 | { |
| 4717 | switch (pname) |
| 4718 | { |
| 4719 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 4720 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 4721 | return gl::error(GL_INVALID_ENUM); |
| 4722 | } |
| 4723 | } |
| 4724 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4725 | switch (pname) |
| 4726 | { |
| 4727 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4728 | *params = programObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4729 | return; |
| 4730 | case GL_LINK_STATUS: |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 4731 | *params = programObject->isLinked(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4732 | return; |
| 4733 | case GL_VALIDATE_STATUS: |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 4734 | *params = programObject->isValidated(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4735 | return; |
| 4736 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4737 | *params = programObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4738 | return; |
| 4739 | case GL_ATTACHED_SHADERS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4740 | *params = programObject->getAttachedShadersCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4741 | return; |
| 4742 | case GL_ACTIVE_ATTRIBUTES: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4743 | *params = programObject->getActiveAttributeCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4744 | return; |
| 4745 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4746 | *params = programObject->getActiveAttributeMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4747 | return; |
| 4748 | case GL_ACTIVE_UNIFORMS: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4749 | *params = programObject->getActiveUniformCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4750 | return; |
| 4751 | case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4752 | *params = programObject->getActiveUniformMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4753 | return; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 4754 | case GL_PROGRAM_BINARY_LENGTH_OES: |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 4755 | *params = programObject->getProgramBinaryLength(); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 4756 | return; |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 4757 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 4758 | *params = programObject->getActiveUniformBlockCount(); |
| 4759 | return; |
| 4760 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 4761 | *params = programObject->getActiveUniformBlockMaxLength(); |
| 4762 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4763 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4764 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4765 | } |
| 4766 | } |
| 4767 | } |
| 4768 | catch(std::bad_alloc&) |
| 4769 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4770 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4771 | } |
| 4772 | } |
| 4773 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4774 | void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4775 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4776 | 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] | 4777 | program, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4778 | |
| 4779 | try |
| 4780 | { |
| 4781 | if (bufsize < 0) |
| 4782 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4783 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4784 | } |
| 4785 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4786 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4787 | |
| 4788 | if (context) |
| 4789 | { |
| 4790 | gl::Program *programObject = context->getProgram(program); |
| 4791 | |
| 4792 | if (!programObject) |
| 4793 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4794 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4795 | } |
| 4796 | |
| 4797 | programObject->getInfoLog(bufsize, length, infolog); |
| 4798 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4799 | } |
| 4800 | catch(std::bad_alloc&) |
| 4801 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4802 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4803 | } |
| 4804 | } |
| 4805 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4806 | void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params) |
| 4807 | { |
| 4808 | EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params); |
| 4809 | |
| 4810 | try |
| 4811 | { |
| 4812 | switch (pname) |
| 4813 | { |
| 4814 | case GL_CURRENT_QUERY_EXT: |
| 4815 | break; |
| 4816 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4817 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4818 | } |
| 4819 | |
| 4820 | gl::Context *context = gl::getNonLostContext(); |
| 4821 | |
| 4822 | if (context) |
| 4823 | { |
| 4824 | params[0] = context->getActiveQuery(target); |
| 4825 | } |
| 4826 | } |
| 4827 | catch(std::bad_alloc&) |
| 4828 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4829 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4830 | } |
| 4831 | } |
| 4832 | |
| 4833 | void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) |
| 4834 | { |
| 4835 | EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params); |
| 4836 | |
| 4837 | try |
| 4838 | { |
| 4839 | switch (pname) |
| 4840 | { |
| 4841 | case GL_QUERY_RESULT_EXT: |
| 4842 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 4843 | break; |
| 4844 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4845 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4846 | } |
| 4847 | gl::Context *context = gl::getNonLostContext(); |
| 4848 | |
| 4849 | if (context) |
| 4850 | { |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4851 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 4852 | |
| 4853 | if (!queryObject) |
| 4854 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4855 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4856 | } |
| 4857 | |
| 4858 | if (context->getActiveQuery(queryObject->getType()) == id) |
| 4859 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4860 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4861 | } |
| 4862 | |
| 4863 | switch(pname) |
| 4864 | { |
| 4865 | case GL_QUERY_RESULT_EXT: |
| 4866 | params[0] = queryObject->getResult(); |
| 4867 | break; |
| 4868 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 4869 | params[0] = queryObject->isResultAvailable(); |
| 4870 | break; |
| 4871 | default: |
| 4872 | ASSERT(false); |
| 4873 | } |
| 4874 | } |
| 4875 | } |
| 4876 | catch(std::bad_alloc&) |
| 4877 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4878 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4879 | } |
| 4880 | } |
| 4881 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4882 | void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 4883 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4884 | 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] | 4885 | |
| 4886 | try |
| 4887 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4888 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4889 | |
| 4890 | if (context) |
| 4891 | { |
| 4892 | if (target != GL_RENDERBUFFER) |
| 4893 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4894 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4895 | } |
| 4896 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4897 | if (context->getRenderbufferHandle() == 0) |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4898 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4899 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4900 | } |
| 4901 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4902 | gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle()); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4903 | |
| 4904 | switch (pname) |
| 4905 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 4906 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break; |
| 4907 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break; |
| 4908 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break; |
| 4909 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break; |
| 4910 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break; |
| 4911 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break; |
| 4912 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break; |
| 4913 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break; |
| 4914 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break; |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 4915 | case GL_RENDERBUFFER_SAMPLES_ANGLE: |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 4916 | if (context->getMaxSupportedSamples() != 0) |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 4917 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 4918 | *params = renderbuffer->getSamples(); |
| 4919 | } |
| 4920 | else |
| 4921 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4922 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 4923 | } |
| 4924 | break; |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4925 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4926 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4927 | } |
| 4928 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4929 | } |
| 4930 | catch(std::bad_alloc&) |
| 4931 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4932 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4933 | } |
| 4934 | } |
| 4935 | |
| 4936 | void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params) |
| 4937 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4938 | 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] | 4939 | |
| 4940 | try |
| 4941 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4942 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4943 | |
| 4944 | if (context) |
| 4945 | { |
| 4946 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 4947 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4948 | if (!shaderObject) |
| 4949 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4950 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4951 | } |
| 4952 | |
| 4953 | switch (pname) |
| 4954 | { |
| 4955 | case GL_SHADER_TYPE: |
| 4956 | *params = shaderObject->getType(); |
| 4957 | return; |
| 4958 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4959 | *params = shaderObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4960 | return; |
| 4961 | case GL_COMPILE_STATUS: |
| 4962 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; |
| 4963 | return; |
| 4964 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4965 | *params = shaderObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4966 | return; |
| 4967 | case GL_SHADER_SOURCE_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4968 | *params = shaderObject->getSourceLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4969 | return; |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 4970 | case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: |
| 4971 | *params = shaderObject->getTranslatedSourceLength(); |
| 4972 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4973 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4974 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4975 | } |
| 4976 | } |
| 4977 | } |
| 4978 | catch(std::bad_alloc&) |
| 4979 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4980 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4981 | } |
| 4982 | } |
| 4983 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4984 | void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4985 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4986 | 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] | 4987 | shader, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4988 | |
| 4989 | try |
| 4990 | { |
| 4991 | if (bufsize < 0) |
| 4992 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4993 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4994 | } |
| 4995 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4996 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4997 | |
| 4998 | if (context) |
| 4999 | { |
| 5000 | gl::Shader *shaderObject = context->getShader(shader); |
| 5001 | |
| 5002 | if (!shaderObject) |
| 5003 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5004 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5005 | } |
| 5006 | |
| 5007 | shaderObject->getInfoLog(bufsize, length, infolog); |
| 5008 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5009 | } |
| 5010 | catch(std::bad_alloc&) |
| 5011 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5012 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5013 | } |
| 5014 | } |
| 5015 | |
| 5016 | void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) |
| 5017 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5018 | 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] | 5019 | shadertype, precisiontype, range, precision); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5020 | |
| 5021 | try |
| 5022 | { |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5023 | switch (shadertype) |
| 5024 | { |
| 5025 | case GL_VERTEX_SHADER: |
| 5026 | case GL_FRAGMENT_SHADER: |
| 5027 | break; |
| 5028 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5029 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5030 | } |
| 5031 | |
| 5032 | switch (precisiontype) |
| 5033 | { |
| 5034 | case GL_LOW_FLOAT: |
| 5035 | case GL_MEDIUM_FLOAT: |
| 5036 | case GL_HIGH_FLOAT: |
| 5037 | // Assume IEEE 754 precision |
| 5038 | range[0] = 127; |
| 5039 | range[1] = 127; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5040 | *precision = 23; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5041 | break; |
| 5042 | case GL_LOW_INT: |
| 5043 | case GL_MEDIUM_INT: |
| 5044 | case GL_HIGH_INT: |
| 5045 | // Some (most) hardware only supports single-precision floating-point numbers, |
| 5046 | // which can accurately represent integers up to +/-16777216 |
| 5047 | range[0] = 24; |
| 5048 | range[1] = 24; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5049 | *precision = 0; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5050 | break; |
| 5051 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5052 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5053 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5054 | } |
| 5055 | catch(std::bad_alloc&) |
| 5056 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5057 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5058 | } |
| 5059 | } |
| 5060 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5061 | void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5062 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5063 | 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] | 5064 | shader, bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5065 | |
| 5066 | try |
| 5067 | { |
| 5068 | if (bufsize < 0) |
| 5069 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5070 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5071 | } |
| 5072 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5073 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5074 | |
| 5075 | if (context) |
| 5076 | { |
| 5077 | gl::Shader *shaderObject = context->getShader(shader); |
| 5078 | |
| 5079 | if (!shaderObject) |
| 5080 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5081 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5082 | } |
| 5083 | |
| 5084 | shaderObject->getSource(bufsize, length, source); |
| 5085 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5086 | } |
| 5087 | catch(std::bad_alloc&) |
| 5088 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5089 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5090 | } |
| 5091 | } |
| 5092 | |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5093 | void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
| 5094 | { |
| 5095 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)", |
| 5096 | shader, bufsize, length, source); |
| 5097 | |
| 5098 | try |
| 5099 | { |
| 5100 | if (bufsize < 0) |
| 5101 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5102 | return gl::error(GL_INVALID_VALUE); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5103 | } |
| 5104 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5105 | gl::Context *context = gl::getNonLostContext(); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5106 | |
| 5107 | if (context) |
| 5108 | { |
| 5109 | gl::Shader *shaderObject = context->getShader(shader); |
| 5110 | |
| 5111 | if (!shaderObject) |
| 5112 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5113 | return gl::error(GL_INVALID_OPERATION); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5114 | } |
| 5115 | |
| 5116 | shaderObject->getTranslatedSource(bufsize, length, source); |
| 5117 | } |
| 5118 | } |
| 5119 | catch(std::bad_alloc&) |
| 5120 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5121 | return gl::error(GL_OUT_OF_MEMORY); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5122 | } |
| 5123 | } |
| 5124 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5125 | const GLubyte* __stdcall glGetString(GLenum name) |
| 5126 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5127 | EVENT("(GLenum name = 0x%X)", name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5128 | |
| 5129 | try |
| 5130 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5131 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3e4c600 | 2010-05-05 18:50:13 +0000 | [diff] [blame] | 5132 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5133 | switch (name) |
| 5134 | { |
| 5135 | case GL_VENDOR: |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 5136 | return (GLubyte*)"Google Inc."; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5137 | case GL_RENDERER: |
daniel@transgaming.com | c23ff64 | 2011-08-16 20:28:45 +0000 | [diff] [blame] | 5138 | return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5139 | case GL_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5140 | if (context->getClientVersion() == 2) |
| 5141 | { |
| 5142 | return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")"; |
| 5143 | } |
| 5144 | else |
| 5145 | { |
| 5146 | return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")"; |
| 5147 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5148 | case GL_SHADING_LANGUAGE_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5149 | if (context->getClientVersion() == 2) |
| 5150 | { |
| 5151 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")"; |
| 5152 | } |
| 5153 | else |
| 5154 | { |
| 5155 | return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")"; |
| 5156 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5157 | case GL_EXTENSIONS: |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 5158 | return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : ""); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5159 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5160 | return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5161 | } |
| 5162 | } |
| 5163 | catch(std::bad_alloc&) |
| 5164 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5165 | return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5166 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5167 | } |
| 5168 | |
| 5169 | void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) |
| 5170 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5171 | 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] | 5172 | |
| 5173 | try |
| 5174 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5175 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5176 | |
| 5177 | if (context) |
| 5178 | { |
| 5179 | gl::Texture *texture; |
| 5180 | |
| 5181 | switch (target) |
| 5182 | { |
| 5183 | case GL_TEXTURE_2D: |
| 5184 | texture = context->getTexture2D(); |
| 5185 | break; |
| 5186 | case GL_TEXTURE_CUBE_MAP: |
| 5187 | texture = context->getTextureCubeMap(); |
| 5188 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5189 | case GL_TEXTURE_3D: |
| 5190 | if (context->getClientVersion() < 3) |
| 5191 | { |
| 5192 | return gl::error(GL_INVALID_ENUM); |
| 5193 | } |
| 5194 | texture = context->getTexture3D(); |
| 5195 | break; |
shannonwoods@chromium.org | 0c611d1 | 2013-05-30 00:15:05 +0000 | [diff] [blame] | 5196 | case GL_TEXTURE_2D_ARRAY: |
| 5197 | if (context->getClientVersion() < 3) |
| 5198 | { |
| 5199 | return gl::error(GL_INVALID_ENUM); |
| 5200 | } |
| 5201 | texture = context->getTexture2DArray(); |
| 5202 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5203 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5204 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5205 | } |
| 5206 | |
| 5207 | switch (pname) |
| 5208 | { |
| 5209 | case GL_TEXTURE_MAG_FILTER: |
| 5210 | *params = (GLfloat)texture->getMagFilter(); |
| 5211 | break; |
| 5212 | case GL_TEXTURE_MIN_FILTER: |
| 5213 | *params = (GLfloat)texture->getMinFilter(); |
| 5214 | break; |
| 5215 | case GL_TEXTURE_WRAP_S: |
| 5216 | *params = (GLfloat)texture->getWrapS(); |
| 5217 | break; |
| 5218 | case GL_TEXTURE_WRAP_T: |
| 5219 | *params = (GLfloat)texture->getWrapT(); |
| 5220 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5221 | case GL_TEXTURE_WRAP_R: |
| 5222 | if (context->getClientVersion() < 3) |
| 5223 | { |
| 5224 | return gl::error(GL_INVALID_ENUM); |
| 5225 | } |
| 5226 | *params = (GLfloat)texture->getWrapR(); |
| 5227 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5228 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5229 | // 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] | 5230 | *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE); |
| 5231 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5232 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5233 | if (context->getClientVersion() < 3) |
| 5234 | { |
| 5235 | return gl::error(GL_INVALID_ENUM); |
| 5236 | } |
| 5237 | *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0); |
| 5238 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5239 | case GL_TEXTURE_USAGE_ANGLE: |
| 5240 | *params = (GLfloat)texture->getUsage(); |
| 5241 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5242 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5243 | if (!context->supportsTextureFilterAnisotropy()) |
| 5244 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5245 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5246 | } |
| 5247 | *params = (GLfloat)texture->getMaxAnisotropy(); |
| 5248 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5249 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5250 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5251 | } |
| 5252 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5253 | } |
| 5254 | catch(std::bad_alloc&) |
| 5255 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5256 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5257 | } |
| 5258 | } |
| 5259 | |
| 5260 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5261 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5262 | 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] | 5263 | |
| 5264 | try |
| 5265 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5266 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5267 | |
| 5268 | if (context) |
| 5269 | { |
| 5270 | gl::Texture *texture; |
| 5271 | |
| 5272 | switch (target) |
| 5273 | { |
| 5274 | case GL_TEXTURE_2D: |
| 5275 | texture = context->getTexture2D(); |
| 5276 | break; |
| 5277 | case GL_TEXTURE_CUBE_MAP: |
| 5278 | texture = context->getTextureCubeMap(); |
| 5279 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5280 | case GL_TEXTURE_3D: |
| 5281 | if (context->getClientVersion() < 3) |
| 5282 | { |
| 5283 | return gl::error(GL_INVALID_ENUM); |
| 5284 | } |
| 5285 | texture = context->getTexture3D(); |
| 5286 | break; |
shannonwoods@chromium.org | 0c611d1 | 2013-05-30 00:15:05 +0000 | [diff] [blame] | 5287 | case GL_TEXTURE_2D_ARRAY: |
| 5288 | if (context->getClientVersion() < 3) |
| 5289 | { |
| 5290 | return gl::error(GL_INVALID_ENUM); |
| 5291 | } |
| 5292 | texture = context->getTexture2DArray(); |
| 5293 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5294 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5295 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5296 | } |
| 5297 | |
| 5298 | switch (pname) |
| 5299 | { |
| 5300 | case GL_TEXTURE_MAG_FILTER: |
| 5301 | *params = texture->getMagFilter(); |
| 5302 | break; |
| 5303 | case GL_TEXTURE_MIN_FILTER: |
| 5304 | *params = texture->getMinFilter(); |
| 5305 | break; |
| 5306 | case GL_TEXTURE_WRAP_S: |
| 5307 | *params = texture->getWrapS(); |
| 5308 | break; |
| 5309 | case GL_TEXTURE_WRAP_T: |
| 5310 | *params = texture->getWrapT(); |
| 5311 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5312 | case GL_TEXTURE_WRAP_R: |
| 5313 | if (context->getClientVersion() < 3) |
| 5314 | { |
| 5315 | return gl::error(GL_INVALID_ENUM); |
| 5316 | } |
| 5317 | *params = texture->getWrapR(); |
| 5318 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5319 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5320 | // 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] | 5321 | *params = texture->isImmutable() ? GL_TRUE : GL_FALSE; |
| 5322 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5323 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5324 | if (context->getClientVersion() < 3) |
| 5325 | { |
| 5326 | return gl::error(GL_INVALID_ENUM); |
| 5327 | } |
| 5328 | *params = texture->isImmutable() ? texture->levelCount() : 0; |
| 5329 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5330 | case GL_TEXTURE_USAGE_ANGLE: |
| 5331 | *params = texture->getUsage(); |
| 5332 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5333 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5334 | if (!context->supportsTextureFilterAnisotropy()) |
| 5335 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5336 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5337 | } |
| 5338 | *params = (GLint)texture->getMaxAnisotropy(); |
| 5339 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 5340 | |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5341 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5342 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5343 | } |
| 5344 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5345 | } |
| 5346 | catch(std::bad_alloc&) |
| 5347 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5348 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5349 | } |
| 5350 | } |
| 5351 | |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5352 | void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
| 5353 | { |
| 5354 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)", |
| 5355 | program, location, bufSize, params); |
| 5356 | |
| 5357 | try |
| 5358 | { |
| 5359 | if (bufSize < 0) |
| 5360 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5361 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5362 | } |
| 5363 | |
| 5364 | gl::Context *context = gl::getNonLostContext(); |
| 5365 | |
| 5366 | if (context) |
| 5367 | { |
| 5368 | if (program == 0) |
| 5369 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5370 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5371 | } |
| 5372 | |
| 5373 | gl::Program *programObject = context->getProgram(program); |
| 5374 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5375 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5376 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5377 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5378 | } |
| 5379 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5380 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5381 | if (!programBinary) |
| 5382 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5383 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5384 | } |
| 5385 | |
| 5386 | if (!programBinary->getUniformfv(location, &bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5387 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5388 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5389 | } |
| 5390 | } |
| 5391 | } |
| 5392 | catch(std::bad_alloc&) |
| 5393 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5394 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5395 | } |
| 5396 | } |
| 5397 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5398 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 5399 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5400 | 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] | 5401 | |
| 5402 | try |
| 5403 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5404 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5405 | |
| 5406 | if (context) |
| 5407 | { |
| 5408 | if (program == 0) |
| 5409 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5410 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5411 | } |
| 5412 | |
| 5413 | gl::Program *programObject = context->getProgram(program); |
| 5414 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5415 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5416 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5417 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5418 | } |
| 5419 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5420 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5421 | if (!programBinary) |
| 5422 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5423 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5424 | } |
| 5425 | |
| 5426 | if (!programBinary->getUniformfv(location, NULL, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5427 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5428 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5429 | } |
| 5430 | } |
| 5431 | } |
| 5432 | catch(std::bad_alloc&) |
| 5433 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5434 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5435 | } |
| 5436 | } |
| 5437 | |
| 5438 | void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) |
| 5439 | { |
| 5440 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)", |
| 5441 | program, location, bufSize, params); |
| 5442 | |
| 5443 | try |
| 5444 | { |
| 5445 | if (bufSize < 0) |
| 5446 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5447 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5448 | } |
| 5449 | |
| 5450 | gl::Context *context = gl::getNonLostContext(); |
| 5451 | |
| 5452 | if (context) |
| 5453 | { |
| 5454 | if (program == 0) |
| 5455 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5456 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5457 | } |
| 5458 | |
| 5459 | gl::Program *programObject = context->getProgram(program); |
| 5460 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5461 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5462 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5463 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5464 | } |
| 5465 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5466 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5467 | if (!programBinary) |
| 5468 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5469 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5470 | } |
| 5471 | |
| 5472 | if (!programBinary->getUniformiv(location, &bufSize, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5473 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5474 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5475 | } |
| 5476 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5477 | } |
| 5478 | catch(std::bad_alloc&) |
| 5479 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5480 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5481 | } |
| 5482 | } |
| 5483 | |
| 5484 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 5485 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5486 | 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] | 5487 | |
| 5488 | try |
| 5489 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5490 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5491 | |
| 5492 | if (context) |
| 5493 | { |
| 5494 | if (program == 0) |
| 5495 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5496 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5497 | } |
| 5498 | |
| 5499 | gl::Program *programObject = context->getProgram(program); |
| 5500 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5501 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5502 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5503 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5504 | } |
| 5505 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5506 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5507 | if (!programBinary) |
| 5508 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5509 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5510 | } |
| 5511 | |
| 5512 | if (!programBinary->getUniformiv(location, NULL, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5513 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5514 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5515 | } |
| 5516 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5517 | } |
| 5518 | catch(std::bad_alloc&) |
| 5519 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5520 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5521 | } |
| 5522 | } |
| 5523 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5524 | int __stdcall glGetUniformLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5525 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5526 | 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] | 5527 | |
| 5528 | try |
| 5529 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5530 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5531 | |
| 5532 | if (strstr(name, "gl_") == name) |
| 5533 | { |
| 5534 | return -1; |
| 5535 | } |
| 5536 | |
| 5537 | if (context) |
| 5538 | { |
| 5539 | gl::Program *programObject = context->getProgram(program); |
| 5540 | |
| 5541 | if (!programObject) |
| 5542 | { |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5543 | if (context->getShader(program)) |
| 5544 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5545 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5546 | } |
| 5547 | else |
| 5548 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5549 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5550 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5551 | } |
| 5552 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5553 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5554 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5555 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5556 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5557 | } |
| 5558 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5559 | return programBinary->getUniformLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5560 | } |
| 5561 | } |
| 5562 | catch(std::bad_alloc&) |
| 5563 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5564 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5565 | } |
| 5566 | |
| 5567 | return -1; |
| 5568 | } |
| 5569 | |
| 5570 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 5571 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5572 | 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] | 5573 | |
| 5574 | try |
| 5575 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5576 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5577 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5578 | if (context) |
| 5579 | { |
| 5580 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5581 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5582 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5583 | } |
| 5584 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5585 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5586 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5587 | switch (pname) |
| 5588 | { |
| 5589 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5590 | *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5591 | break; |
| 5592 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5593 | *params = (GLfloat)attribState.mSize; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5594 | break; |
| 5595 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5596 | *params = (GLfloat)attribState.mStride; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5597 | break; |
| 5598 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5599 | *params = (GLfloat)attribState.mType; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5600 | break; |
| 5601 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5602 | *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5603 | break; |
| 5604 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 5605 | *params = (GLfloat)attribState.mBoundBuffer.id(); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5606 | break; |
| 5607 | case GL_CURRENT_VERTEX_ATTRIB: |
| 5608 | for (int i = 0; i < 4; ++i) |
| 5609 | { |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame] | 5610 | params[i] = attribState.mCurrentValue.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5611 | } |
| 5612 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 5613 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 5614 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 5615 | // the same constant. |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 5616 | *params = (GLfloat)attribState.mDivisor; |
| 5617 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5618 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5619 | } |
| 5620 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5621 | } |
| 5622 | catch(std::bad_alloc&) |
| 5623 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5624 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5625 | } |
| 5626 | } |
| 5627 | |
| 5628 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 5629 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5630 | 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] | 5631 | |
| 5632 | try |
| 5633 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5634 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5635 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5636 | if (context) |
| 5637 | { |
| 5638 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5639 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5640 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5641 | } |
| 5642 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5643 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5644 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5645 | switch (pname) |
| 5646 | { |
| 5647 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5648 | *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5649 | break; |
| 5650 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5651 | *params = attribState.mSize; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5652 | break; |
| 5653 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5654 | *params = attribState.mStride; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5655 | break; |
| 5656 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5657 | *params = attribState.mType; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5658 | break; |
| 5659 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5660 | *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5661 | break; |
| 5662 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 5663 | *params = attribState.mBoundBuffer.id(); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5664 | break; |
| 5665 | case GL_CURRENT_VERTEX_ATTRIB: |
| 5666 | for (int i = 0; i < 4; ++i) |
| 5667 | { |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame] | 5668 | float currentValue = attribState.mCurrentValue.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5669 | params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f)); |
| 5670 | } |
| 5671 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 5672 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 5673 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 5674 | // the same constant. |
| 5675 | 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] | 5676 | *params = (GLint)attribState.mDivisor; |
| 5677 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5678 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5679 | } |
| 5680 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5681 | } |
| 5682 | catch(std::bad_alloc&) |
| 5683 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5684 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5685 | } |
| 5686 | } |
| 5687 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5688 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5689 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5690 | 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] | 5691 | |
| 5692 | try |
| 5693 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5694 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5695 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5696 | if (context) |
| 5697 | { |
| 5698 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5699 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5700 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5701 | } |
| 5702 | |
| 5703 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) |
| 5704 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5705 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5706 | } |
| 5707 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5708 | *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index)); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5709 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5710 | } |
| 5711 | catch(std::bad_alloc&) |
| 5712 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5713 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5714 | } |
| 5715 | } |
| 5716 | |
| 5717 | void __stdcall glHint(GLenum target, GLenum mode) |
| 5718 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5719 | EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5720 | |
| 5721 | try |
| 5722 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5723 | switch (mode) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5724 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5725 | case GL_FASTEST: |
| 5726 | case GL_NICEST: |
| 5727 | case GL_DONT_CARE: |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5728 | break; |
| 5729 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5730 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5731 | } |
| 5732 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5733 | gl::Context *context = gl::getNonLostContext(); |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5734 | switch (target) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5735 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5736 | case GL_GENERATE_MIPMAP_HINT: |
| 5737 | if (context) context->setGenerateMipmapHint(mode); |
| 5738 | break; |
| 5739 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 5740 | if (context) context->setFragmentShaderDerivativeHint(mode); |
| 5741 | break; |
| 5742 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5743 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5744 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5745 | } |
| 5746 | catch(std::bad_alloc&) |
| 5747 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5748 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5749 | } |
| 5750 | } |
| 5751 | |
| 5752 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 5753 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5754 | EVENT("(GLuint buffer = %d)", buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5755 | |
| 5756 | try |
| 5757 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5758 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5759 | |
| 5760 | if (context && buffer) |
| 5761 | { |
| 5762 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 5763 | |
| 5764 | if (bufferObject) |
| 5765 | { |
| 5766 | return GL_TRUE; |
| 5767 | } |
| 5768 | } |
| 5769 | } |
| 5770 | catch(std::bad_alloc&) |
| 5771 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5772 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5773 | } |
| 5774 | |
| 5775 | return GL_FALSE; |
| 5776 | } |
| 5777 | |
| 5778 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 5779 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5780 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5781 | |
| 5782 | try |
| 5783 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5784 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5785 | |
| 5786 | if (context) |
| 5787 | { |
| 5788 | switch (cap) |
| 5789 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5790 | case GL_CULL_FACE: return context->isCullFaceEnabled(); |
| 5791 | case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled(); |
| 5792 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled(); |
| 5793 | case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled(); |
| 5794 | case GL_SCISSOR_TEST: return context->isScissorTestEnabled(); |
| 5795 | case GL_STENCIL_TEST: return context->isStencilTestEnabled(); |
| 5796 | case GL_DEPTH_TEST: return context->isDepthTestEnabled(); |
| 5797 | case GL_BLEND: return context->isBlendEnabled(); |
| 5798 | case GL_DITHER: return context->isDitherEnabled(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5799 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5800 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5801 | } |
| 5802 | } |
| 5803 | } |
| 5804 | catch(std::bad_alloc&) |
| 5805 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5806 | return gl::error(GL_OUT_OF_MEMORY, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5807 | } |
| 5808 | |
| 5809 | return false; |
| 5810 | } |
| 5811 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 5812 | GLboolean __stdcall glIsFenceNV(GLuint fence) |
| 5813 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5814 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5815 | |
| 5816 | try |
| 5817 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5818 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5819 | |
| 5820 | if (context) |
| 5821 | { |
| 5822 | gl::Fence *fenceObject = context->getFence(fence); |
| 5823 | |
| 5824 | if (fenceObject == NULL) |
| 5825 | { |
| 5826 | return GL_FALSE; |
| 5827 | } |
| 5828 | |
| 5829 | return fenceObject->isFence(); |
| 5830 | } |
| 5831 | } |
| 5832 | catch(std::bad_alloc&) |
| 5833 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5834 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5835 | } |
| 5836 | |
| 5837 | return GL_FALSE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 5838 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5839 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5840 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 5841 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5842 | EVENT("(GLuint framebuffer = %d)", framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5843 | |
| 5844 | try |
| 5845 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5846 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5847 | |
| 5848 | if (context && framebuffer) |
| 5849 | { |
| 5850 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 5851 | |
| 5852 | if (framebufferObject) |
| 5853 | { |
| 5854 | return GL_TRUE; |
| 5855 | } |
| 5856 | } |
| 5857 | } |
| 5858 | catch(std::bad_alloc&) |
| 5859 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5860 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5861 | } |
| 5862 | |
| 5863 | return GL_FALSE; |
| 5864 | } |
| 5865 | |
| 5866 | GLboolean __stdcall glIsProgram(GLuint program) |
| 5867 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5868 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5869 | |
| 5870 | try |
| 5871 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5872 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5873 | |
| 5874 | if (context && program) |
| 5875 | { |
| 5876 | gl::Program *programObject = context->getProgram(program); |
| 5877 | |
| 5878 | if (programObject) |
| 5879 | { |
| 5880 | return GL_TRUE; |
| 5881 | } |
| 5882 | } |
| 5883 | } |
| 5884 | catch(std::bad_alloc&) |
| 5885 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5886 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5887 | } |
| 5888 | |
| 5889 | return GL_FALSE; |
| 5890 | } |
| 5891 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5892 | GLboolean __stdcall glIsQueryEXT(GLuint id) |
| 5893 | { |
| 5894 | EVENT("(GLuint id = %d)", id); |
| 5895 | |
| 5896 | try |
| 5897 | { |
| 5898 | if (id == 0) |
| 5899 | { |
| 5900 | return GL_FALSE; |
| 5901 | } |
| 5902 | |
| 5903 | gl::Context *context = gl::getNonLostContext(); |
| 5904 | |
| 5905 | if (context) |
| 5906 | { |
| 5907 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 5908 | |
| 5909 | if (queryObject) |
| 5910 | { |
| 5911 | return GL_TRUE; |
| 5912 | } |
| 5913 | } |
| 5914 | } |
| 5915 | catch(std::bad_alloc&) |
| 5916 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5917 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5918 | } |
| 5919 | |
| 5920 | return GL_FALSE; |
| 5921 | } |
| 5922 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5923 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 5924 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5925 | EVENT("(GLuint renderbuffer = %d)", renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5926 | |
| 5927 | try |
| 5928 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5929 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5930 | |
| 5931 | if (context && renderbuffer) |
| 5932 | { |
| 5933 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 5934 | |
| 5935 | if (renderbufferObject) |
| 5936 | { |
| 5937 | return GL_TRUE; |
| 5938 | } |
| 5939 | } |
| 5940 | } |
| 5941 | catch(std::bad_alloc&) |
| 5942 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5943 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5944 | } |
| 5945 | |
| 5946 | return GL_FALSE; |
| 5947 | } |
| 5948 | |
| 5949 | GLboolean __stdcall glIsShader(GLuint shader) |
| 5950 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5951 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5952 | |
| 5953 | try |
| 5954 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5955 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5956 | |
| 5957 | if (context && shader) |
| 5958 | { |
| 5959 | gl::Shader *shaderObject = context->getShader(shader); |
| 5960 | |
| 5961 | if (shaderObject) |
| 5962 | { |
| 5963 | return GL_TRUE; |
| 5964 | } |
| 5965 | } |
| 5966 | } |
| 5967 | catch(std::bad_alloc&) |
| 5968 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5969 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5970 | } |
| 5971 | |
| 5972 | return GL_FALSE; |
| 5973 | } |
| 5974 | |
| 5975 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 5976 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5977 | EVENT("(GLuint texture = %d)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5978 | |
| 5979 | try |
| 5980 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5981 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5982 | |
| 5983 | if (context && texture) |
| 5984 | { |
| 5985 | gl::Texture *textureObject = context->getTexture(texture); |
| 5986 | |
| 5987 | if (textureObject) |
| 5988 | { |
| 5989 | return GL_TRUE; |
| 5990 | } |
| 5991 | } |
| 5992 | } |
| 5993 | catch(std::bad_alloc&) |
| 5994 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5995 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5996 | } |
| 5997 | |
| 5998 | return GL_FALSE; |
| 5999 | } |
| 6000 | |
| 6001 | void __stdcall glLineWidth(GLfloat width) |
| 6002 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6003 | EVENT("(GLfloat width = %f)", width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6004 | |
| 6005 | try |
| 6006 | { |
| 6007 | if (width <= 0.0f) |
| 6008 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6009 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6010 | } |
| 6011 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6012 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 6013 | |
| 6014 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6015 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6016 | context->setLineWidth(width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6017 | } |
| 6018 | } |
| 6019 | catch(std::bad_alloc&) |
| 6020 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6021 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6022 | } |
| 6023 | } |
| 6024 | |
| 6025 | void __stdcall glLinkProgram(GLuint program) |
| 6026 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6027 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6028 | |
| 6029 | try |
| 6030 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6031 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6032 | |
| 6033 | if (context) |
| 6034 | { |
| 6035 | gl::Program *programObject = context->getProgram(program); |
| 6036 | |
| 6037 | if (!programObject) |
| 6038 | { |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6039 | if (context->getShader(program)) |
| 6040 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6041 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6042 | } |
| 6043 | else |
| 6044 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6045 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6046 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6047 | } |
| 6048 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 6049 | context->linkProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6050 | } |
| 6051 | } |
| 6052 | catch(std::bad_alloc&) |
| 6053 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6054 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6055 | } |
| 6056 | } |
| 6057 | |
| 6058 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 6059 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6060 | EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6061 | |
| 6062 | try |
| 6063 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6064 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6065 | |
| 6066 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6067 | { |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6068 | switch (pname) |
| 6069 | { |
| 6070 | case GL_UNPACK_ALIGNMENT: |
| 6071 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6072 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6073 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6074 | } |
| 6075 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6076 | context->setUnpackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6077 | break; |
| 6078 | |
| 6079 | case GL_PACK_ALIGNMENT: |
| 6080 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6081 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6082 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6083 | } |
| 6084 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6085 | context->setPackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6086 | break; |
| 6087 | |
bsalomon@google.com | 56d46ab | 2011-11-23 14:53:10 +0000 | [diff] [blame] | 6088 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 6089 | context->setPackReverseRowOrder(param != 0); |
| 6090 | break; |
| 6091 | |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6092 | case GL_UNPACK_IMAGE_HEIGHT: |
| 6093 | case GL_UNPACK_SKIP_IMAGES: |
| 6094 | case GL_UNPACK_ROW_LENGTH: |
| 6095 | case GL_UNPACK_SKIP_ROWS: |
| 6096 | case GL_UNPACK_SKIP_PIXELS: |
| 6097 | case GL_PACK_ROW_LENGTH: |
| 6098 | case GL_PACK_SKIP_ROWS: |
| 6099 | case GL_PACK_SKIP_PIXELS: |
| 6100 | if (context->getClientVersion() < 3) |
| 6101 | { |
| 6102 | return gl::error(GL_INVALID_ENUM); |
| 6103 | } |
| 6104 | UNIMPLEMENTED(); |
| 6105 | break; |
| 6106 | |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6107 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6108 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6109 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6110 | } |
| 6111 | } |
| 6112 | catch(std::bad_alloc&) |
| 6113 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6114 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6115 | } |
| 6116 | } |
| 6117 | |
| 6118 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 6119 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6120 | EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6121 | |
| 6122 | try |
| 6123 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6124 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aede630 | 2010-04-29 03:35:48 +0000 | [diff] [blame] | 6125 | |
| 6126 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6127 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6128 | context->setPolygonOffsetParams(factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6129 | } |
| 6130 | } |
| 6131 | catch(std::bad_alloc&) |
| 6132 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6133 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6134 | } |
| 6135 | } |
| 6136 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6137 | void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6138 | GLenum format, GLenum type, GLsizei bufSize, |
| 6139 | GLvoid *data) |
| 6140 | { |
| 6141 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
| 6142 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)", |
| 6143 | x, y, width, height, format, type, bufSize, data); |
| 6144 | |
| 6145 | try |
| 6146 | { |
| 6147 | if (width < 0 || height < 0 || bufSize < 0) |
| 6148 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6149 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6150 | } |
| 6151 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6152 | gl::Context *context = gl::getNonLostContext(); |
| 6153 | |
| 6154 | if (context) |
| 6155 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6156 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6157 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6158 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6159 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6160 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6161 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6162 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6163 | return; |
| 6164 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6165 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6166 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6167 | |
| 6168 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6169 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6170 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6171 | } |
| 6172 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6173 | context->readPixels(x, y, width, height, format, type, &bufSize, data); |
| 6174 | } |
| 6175 | } |
| 6176 | catch(std::bad_alloc&) |
| 6177 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6178 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6179 | } |
| 6180 | } |
| 6181 | |
| 6182 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6183 | GLenum format, GLenum type, GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6184 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6185 | 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] | 6186 | "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] | 6187 | x, y, width, height, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6188 | |
| 6189 | try |
| 6190 | { |
| 6191 | if (width < 0 || height < 0) |
| 6192 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6193 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6194 | } |
| 6195 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6196 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6197 | |
| 6198 | if (context) |
| 6199 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6200 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6201 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6202 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6203 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6204 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6205 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6206 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6207 | return; |
| 6208 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6209 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6210 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6211 | |
| 6212 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6213 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6214 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6215 | } |
| 6216 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6217 | context->readPixels(x, y, width, height, format, type, NULL, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6218 | } |
| 6219 | } |
| 6220 | catch(std::bad_alloc&) |
| 6221 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6222 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6223 | } |
| 6224 | } |
| 6225 | |
| 6226 | void __stdcall glReleaseShaderCompiler(void) |
| 6227 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6228 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6229 | |
| 6230 | try |
| 6231 | { |
| 6232 | gl::Shader::releaseCompiler(); |
| 6233 | } |
| 6234 | catch(std::bad_alloc&) |
| 6235 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6236 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6237 | } |
| 6238 | } |
| 6239 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6240 | 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] | 6241 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6242 | 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] | 6243 | target, samples, internalformat, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6244 | |
| 6245 | try |
| 6246 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6247 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6248 | |
| 6249 | if (context) |
| 6250 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6251 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 6252 | width, height, true)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6253 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6254 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6255 | } |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 6256 | |
| 6257 | context->setRenderbufferStorage(width, height, internalformat, samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6258 | } |
| 6259 | } |
| 6260 | catch(std::bad_alloc&) |
| 6261 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6262 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6263 | } |
| 6264 | } |
| 6265 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6266 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 6267 | { |
| 6268 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height); |
| 6269 | } |
| 6270 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6271 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 6272 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6273 | EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6274 | |
| 6275 | try |
| 6276 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6277 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6278 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6279 | if (context) |
| 6280 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 6281 | context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6282 | } |
| 6283 | } |
| 6284 | catch(std::bad_alloc&) |
| 6285 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6286 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6287 | } |
| 6288 | } |
| 6289 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6290 | void __stdcall glSetFenceNV(GLuint fence, GLenum condition) |
| 6291 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6292 | EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6293 | |
| 6294 | try |
| 6295 | { |
| 6296 | if (condition != GL_ALL_COMPLETED_NV) |
| 6297 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6298 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6299 | } |
| 6300 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6301 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6302 | |
| 6303 | if (context) |
| 6304 | { |
| 6305 | gl::Fence *fenceObject = context->getFence(fence); |
| 6306 | |
| 6307 | if (fenceObject == NULL) |
| 6308 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6309 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6310 | } |
| 6311 | |
| 6312 | fenceObject->setFence(condition); |
| 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); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6318 | } |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6319 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6320 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6321 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 6322 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6323 | 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] | 6324 | |
| 6325 | try |
| 6326 | { |
| 6327 | if (width < 0 || height < 0) |
| 6328 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6329 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6330 | } |
| 6331 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6332 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6333 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6334 | if (context) |
| 6335 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6336 | context->setScissorParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6337 | } |
| 6338 | } |
| 6339 | catch(std::bad_alloc&) |
| 6340 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6341 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6342 | } |
| 6343 | } |
| 6344 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6345 | 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] | 6346 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6347 | 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] | 6348 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 6349 | n, shaders, binaryformat, binary, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6350 | |
| 6351 | try |
| 6352 | { |
daniel@transgaming.com | d1f667f | 2010-04-29 03:38:52 +0000 | [diff] [blame] | 6353 | // No binary shader formats are supported. |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6354 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6355 | } |
| 6356 | catch(std::bad_alloc&) |
| 6357 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6358 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6359 | } |
| 6360 | } |
| 6361 | |
shannon.woods%transgaming.com@gtempaccount.com | 5f33933 | 2013-04-13 03:29:02 +0000 | [diff] [blame] | 6362 | 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] | 6363 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6364 | 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] | 6365 | shader, count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6366 | |
| 6367 | try |
| 6368 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6369 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6370 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6371 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6372 | } |
| 6373 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6374 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6375 | |
| 6376 | if (context) |
| 6377 | { |
| 6378 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6379 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6380 | if (!shaderObject) |
| 6381 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6382 | if (context->getProgram(shader)) |
| 6383 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6384 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6385 | } |
| 6386 | else |
| 6387 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6388 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6389 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6390 | } |
| 6391 | |
| 6392 | shaderObject->setSource(count, string, length); |
| 6393 | } |
| 6394 | } |
| 6395 | catch(std::bad_alloc&) |
| 6396 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6397 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6398 | } |
| 6399 | } |
| 6400 | |
| 6401 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 6402 | { |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6403 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6404 | } |
| 6405 | |
| 6406 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 6407 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6408 | 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] | 6409 | |
| 6410 | try |
| 6411 | { |
| 6412 | switch (face) |
| 6413 | { |
| 6414 | case GL_FRONT: |
| 6415 | case GL_BACK: |
| 6416 | case GL_FRONT_AND_BACK: |
| 6417 | break; |
| 6418 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6419 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6420 | } |
| 6421 | |
| 6422 | switch (func) |
| 6423 | { |
| 6424 | case GL_NEVER: |
| 6425 | case GL_ALWAYS: |
| 6426 | case GL_LESS: |
| 6427 | case GL_LEQUAL: |
| 6428 | case GL_EQUAL: |
| 6429 | case GL_GEQUAL: |
| 6430 | case GL_GREATER: |
| 6431 | case GL_NOTEQUAL: |
| 6432 | break; |
| 6433 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6434 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6435 | } |
| 6436 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6437 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6438 | |
| 6439 | if (context) |
| 6440 | { |
| 6441 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6442 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6443 | context->setStencilParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6444 | } |
| 6445 | |
| 6446 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6447 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6448 | context->setStencilBackParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6449 | } |
| 6450 | } |
| 6451 | } |
| 6452 | catch(std::bad_alloc&) |
| 6453 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6454 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6455 | } |
| 6456 | } |
| 6457 | |
| 6458 | void __stdcall glStencilMask(GLuint mask) |
| 6459 | { |
| 6460 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 6461 | } |
| 6462 | |
| 6463 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 6464 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6465 | EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6466 | |
| 6467 | try |
| 6468 | { |
| 6469 | switch (face) |
| 6470 | { |
| 6471 | case GL_FRONT: |
| 6472 | case GL_BACK: |
| 6473 | case GL_FRONT_AND_BACK: |
| 6474 | break; |
| 6475 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6476 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6477 | } |
| 6478 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6479 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6480 | |
| 6481 | if (context) |
| 6482 | { |
| 6483 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6484 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6485 | context->setStencilWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6486 | } |
| 6487 | |
| 6488 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6489 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6490 | context->setStencilBackWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6491 | } |
| 6492 | } |
| 6493 | } |
| 6494 | catch(std::bad_alloc&) |
| 6495 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6496 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6497 | } |
| 6498 | } |
| 6499 | |
| 6500 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 6501 | { |
| 6502 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 6503 | } |
| 6504 | |
| 6505 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 6506 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6507 | 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] | 6508 | face, fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6509 | |
| 6510 | try |
| 6511 | { |
| 6512 | switch (face) |
| 6513 | { |
| 6514 | case GL_FRONT: |
| 6515 | case GL_BACK: |
| 6516 | case GL_FRONT_AND_BACK: |
| 6517 | break; |
| 6518 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6519 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6520 | } |
| 6521 | |
| 6522 | switch (fail) |
| 6523 | { |
| 6524 | case GL_ZERO: |
| 6525 | case GL_KEEP: |
| 6526 | case GL_REPLACE: |
| 6527 | case GL_INCR: |
| 6528 | case GL_DECR: |
| 6529 | case GL_INVERT: |
| 6530 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6531 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6532 | break; |
| 6533 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6534 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6535 | } |
| 6536 | |
| 6537 | switch (zfail) |
| 6538 | { |
| 6539 | case GL_ZERO: |
| 6540 | case GL_KEEP: |
| 6541 | case GL_REPLACE: |
| 6542 | case GL_INCR: |
| 6543 | case GL_DECR: |
| 6544 | case GL_INVERT: |
| 6545 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6546 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6547 | break; |
| 6548 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6549 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6550 | } |
| 6551 | |
| 6552 | switch (zpass) |
| 6553 | { |
| 6554 | case GL_ZERO: |
| 6555 | case GL_KEEP: |
| 6556 | case GL_REPLACE: |
| 6557 | case GL_INCR: |
| 6558 | case GL_DECR: |
| 6559 | case GL_INVERT: |
| 6560 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6561 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6562 | break; |
| 6563 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6564 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6565 | } |
| 6566 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6567 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6568 | |
| 6569 | if (context) |
| 6570 | { |
| 6571 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6572 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6573 | context->setStencilOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6574 | } |
| 6575 | |
| 6576 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6577 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6578 | context->setStencilBackOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6579 | } |
| 6580 | } |
| 6581 | } |
| 6582 | catch(std::bad_alloc&) |
| 6583 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6584 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6585 | } |
| 6586 | } |
| 6587 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6588 | GLboolean __stdcall glTestFenceNV(GLuint fence) |
| 6589 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6590 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6591 | |
| 6592 | try |
| 6593 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6594 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6595 | |
| 6596 | if (context) |
| 6597 | { |
| 6598 | gl::Fence *fenceObject = context->getFence(fence); |
| 6599 | |
| 6600 | if (fenceObject == NULL) |
| 6601 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6602 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6603 | } |
| 6604 | |
| 6605 | return fenceObject->testFence(); |
| 6606 | } |
| 6607 | } |
| 6608 | catch(std::bad_alloc&) |
| 6609 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6610 | gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6611 | } |
| 6612 | |
| 6613 | return GL_TRUE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6614 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6615 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6616 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, |
| 6617 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6618 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6619 | 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] | 6620 | "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] | 6621 | target, level, internalformat, width, height, border, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6622 | |
| 6623 | try |
| 6624 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6625 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6626 | |
| 6627 | if (context) |
| 6628 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6629 | if (context->getClientVersion() < 3 && |
| 6630 | !validateES2TexImageParameters(context, target, level, internalformat, false, false, |
| 6631 | 0, 0, width, height, border, format, type, pixels)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 6632 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6633 | return; |
| 6634 | } |
| 6635 | |
| 6636 | if (context->getClientVersion() >= 3 && |
| 6637 | !validateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 6638 | 0, 0, 0, width, height, 1, border, format, type)) |
| 6639 | { |
| 6640 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 6641 | } |
| 6642 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6643 | switch (target) |
| 6644 | { |
| 6645 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6646 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6647 | gl::Texture2D *texture = context->getTexture2D(); |
| 6648 | texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6649 | } |
| 6650 | break; |
| 6651 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6652 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6653 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 6654 | texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6655 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6656 | break; |
| 6657 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 6658 | { |
| 6659 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6660 | texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6661 | } |
| 6662 | break; |
| 6663 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 6664 | { |
| 6665 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6666 | texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6667 | } |
| 6668 | break; |
| 6669 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 6670 | { |
| 6671 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6672 | texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6673 | } |
| 6674 | break; |
| 6675 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 6676 | { |
| 6677 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6678 | texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6679 | } |
| 6680 | break; |
| 6681 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 6682 | { |
| 6683 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6684 | texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6685 | } |
| 6686 | break; |
| 6687 | default: UNREACHABLE(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6688 | } |
| 6689 | } |
| 6690 | } |
| 6691 | catch(std::bad_alloc&) |
| 6692 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6693 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6694 | } |
| 6695 | } |
| 6696 | |
| 6697 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 6698 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6699 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param); |
| 6700 | |
| 6701 | try |
| 6702 | { |
| 6703 | gl::Context *context = gl::getNonLostContext(); |
| 6704 | |
| 6705 | if (context) |
| 6706 | { |
| 6707 | gl::Texture *texture; |
| 6708 | |
| 6709 | switch (target) |
| 6710 | { |
| 6711 | case GL_TEXTURE_2D: |
| 6712 | texture = context->getTexture2D(); |
| 6713 | break; |
| 6714 | case GL_TEXTURE_CUBE_MAP: |
| 6715 | texture = context->getTextureCubeMap(); |
| 6716 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 6717 | case GL_TEXTURE_3D: |
| 6718 | if (context->getClientVersion() < 3) |
| 6719 | { |
| 6720 | return gl::error(GL_INVALID_ENUM); |
| 6721 | } |
| 6722 | texture = context->getTexture3D(); |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 6723 | case GL_TEXTURE_2D_ARRAY: |
| 6724 | if (context->getClientVersion() < 3) |
| 6725 | { |
| 6726 | return gl::error(GL_INVALID_ENUM); |
| 6727 | } |
| 6728 | texture = context->getTexture2DArray(); |
| 6729 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6730 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6731 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6732 | } |
| 6733 | |
| 6734 | switch (pname) |
| 6735 | { |
| 6736 | case GL_TEXTURE_WRAP_S: |
| 6737 | if (!texture->setWrapS((GLenum)param)) |
| 6738 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6739 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6740 | } |
| 6741 | break; |
| 6742 | case GL_TEXTURE_WRAP_T: |
| 6743 | if (!texture->setWrapT((GLenum)param)) |
| 6744 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6745 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6746 | } |
| 6747 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 6748 | case GL_TEXTURE_WRAP_R: |
| 6749 | if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param)) |
| 6750 | { |
| 6751 | return gl::error(GL_INVALID_ENUM); |
| 6752 | } |
| 6753 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6754 | case GL_TEXTURE_MIN_FILTER: |
| 6755 | if (!texture->setMinFilter((GLenum)param)) |
| 6756 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6757 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6758 | } |
| 6759 | break; |
| 6760 | case GL_TEXTURE_MAG_FILTER: |
| 6761 | if (!texture->setMagFilter((GLenum)param)) |
| 6762 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6763 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6764 | } |
| 6765 | break; |
| 6766 | case GL_TEXTURE_USAGE_ANGLE: |
| 6767 | if (!texture->setUsage((GLenum)param)) |
| 6768 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6769 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6770 | } |
| 6771 | break; |
| 6772 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 6773 | if (!context->supportsTextureFilterAnisotropy()) |
| 6774 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6775 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6776 | } |
| 6777 | if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy())) |
| 6778 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6779 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6780 | } |
| 6781 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6782 | |
| 6783 | case GL_TEXTURE_MIN_LOD: |
| 6784 | case GL_TEXTURE_MAX_LOD: |
| 6785 | if (context->getClientVersion() < 3) |
| 6786 | { |
| 6787 | return gl::error(GL_INVALID_ENUM); |
| 6788 | } |
| 6789 | UNIMPLEMENTED(); |
| 6790 | break; |
| 6791 | |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6792 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6793 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6794 | } |
| 6795 | } |
| 6796 | } |
| 6797 | catch(std::bad_alloc&) |
| 6798 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6799 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6800 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6801 | } |
| 6802 | |
| 6803 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 6804 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6805 | glTexParameterf(target, pname, (GLfloat)*params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6806 | } |
| 6807 | |
| 6808 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 6809 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6810 | 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] | 6811 | |
| 6812 | try |
| 6813 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6814 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6815 | |
| 6816 | if (context) |
| 6817 | { |
| 6818 | gl::Texture *texture; |
| 6819 | |
| 6820 | switch (target) |
| 6821 | { |
| 6822 | case GL_TEXTURE_2D: |
| 6823 | texture = context->getTexture2D(); |
| 6824 | break; |
| 6825 | case GL_TEXTURE_CUBE_MAP: |
| 6826 | texture = context->getTextureCubeMap(); |
| 6827 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 6828 | case GL_TEXTURE_3D: |
| 6829 | if (context->getClientVersion() < 3) |
| 6830 | { |
| 6831 | return gl::error(GL_INVALID_ENUM); |
| 6832 | } |
| 6833 | texture = context->getTexture3D(); |
| 6834 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 6835 | case GL_TEXTURE_2D_ARRAY: |
| 6836 | if (context->getClientVersion() < 3) |
| 6837 | { |
| 6838 | return gl::error(GL_INVALID_ENUM); |
| 6839 | } |
| 6840 | texture = context->getTexture2DArray(); |
| 6841 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6842 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6843 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6844 | } |
| 6845 | |
| 6846 | switch (pname) |
| 6847 | { |
| 6848 | case GL_TEXTURE_WRAP_S: |
| 6849 | if (!texture->setWrapS((GLenum)param)) |
| 6850 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6851 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6852 | } |
| 6853 | break; |
| 6854 | case GL_TEXTURE_WRAP_T: |
| 6855 | if (!texture->setWrapT((GLenum)param)) |
| 6856 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6857 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6858 | } |
| 6859 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 6860 | case GL_TEXTURE_WRAP_R: |
| 6861 | if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param)) |
| 6862 | { |
| 6863 | return gl::error(GL_INVALID_ENUM); |
| 6864 | } |
| 6865 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6866 | case GL_TEXTURE_MIN_FILTER: |
| 6867 | if (!texture->setMinFilter((GLenum)param)) |
| 6868 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6869 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6870 | } |
| 6871 | break; |
| 6872 | case GL_TEXTURE_MAG_FILTER: |
| 6873 | if (!texture->setMagFilter((GLenum)param)) |
| 6874 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6875 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6876 | } |
| 6877 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 6878 | case GL_TEXTURE_USAGE_ANGLE: |
| 6879 | if (!texture->setUsage((GLenum)param)) |
| 6880 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6881 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 6882 | } |
| 6883 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6884 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 6885 | if (!context->supportsTextureFilterAnisotropy()) |
| 6886 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6887 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6888 | } |
| 6889 | if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy())) |
| 6890 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6891 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6892 | } |
| 6893 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6894 | |
| 6895 | case GL_TEXTURE_SWIZZLE_R: |
| 6896 | case GL_TEXTURE_SWIZZLE_G: |
| 6897 | case GL_TEXTURE_SWIZZLE_B: |
| 6898 | case GL_TEXTURE_SWIZZLE_A: |
| 6899 | case GL_TEXTURE_BASE_LEVEL: |
| 6900 | case GL_TEXTURE_MAX_LEVEL: |
| 6901 | case GL_TEXTURE_COMPARE_MODE: |
| 6902 | case GL_TEXTURE_COMPARE_FUNC: |
| 6903 | if (context->getClientVersion() < 3) |
| 6904 | { |
| 6905 | return gl::error(GL_INVALID_ENUM); |
| 6906 | } |
| 6907 | UNIMPLEMENTED(); |
| 6908 | break; |
| 6909 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6910 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6911 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6912 | } |
| 6913 | } |
| 6914 | } |
| 6915 | catch(std::bad_alloc&) |
| 6916 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6917 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6918 | } |
| 6919 | } |
| 6920 | |
| 6921 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 6922 | { |
| 6923 | glTexParameteri(target, pname, *params); |
| 6924 | } |
| 6925 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6926 | void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 6927 | { |
| 6928 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 6929 | target, levels, internalformat, width, height); |
| 6930 | |
| 6931 | try |
| 6932 | { |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6933 | gl::Context *context = gl::getNonLostContext(); |
| 6934 | |
| 6935 | if (context) |
| 6936 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6937 | if (context->getClientVersion() < 3 && |
| 6938 | !validateES2TexStorageParameters(context, target, levels, internalformat, width, height)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6939 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6940 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6941 | } |
| 6942 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6943 | if (context->getClientVersion() >= 3 && |
| 6944 | !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6945 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6946 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6947 | } |
| 6948 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6949 | switch (target) |
| 6950 | { |
| 6951 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6952 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6953 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 6954 | texture2d->storage(levels, internalformat, width, height); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6955 | } |
| 6956 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6957 | |
| 6958 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 6959 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 6960 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 6961 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 6962 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 6963 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6964 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6965 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 6966 | textureCube->storage(levels, internalformat, width); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6967 | } |
| 6968 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6969 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6970 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6971 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6972 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6973 | } |
| 6974 | } |
| 6975 | catch(std::bad_alloc&) |
| 6976 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6977 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6978 | } |
| 6979 | } |
| 6980 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6981 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 6982 | GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6983 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6984 | 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] | 6985 | "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] | 6986 | "const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6987 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 6988 | |
| 6989 | try |
| 6990 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6991 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 6992 | |
| 6993 | if (context) |
| 6994 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6995 | if (context->getClientVersion() < 3 && |
| 6996 | !validateES2TexImageParameters(context, target, level, GL_NONE, false, true, |
| 6997 | 0, 0, width, height, 0, format, type, pixels)) |
daniel@transgaming.com | 1d2d3c4 | 2012-05-31 01:14:15 +0000 | [diff] [blame] | 6998 | { |
| 6999 | return; |
| 7000 | } |
| 7001 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7002 | if (context->getClientVersion() >= 3 && |
| 7003 | !validateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7004 | 0, 0, 0, width, height, 1, 0, format, type)) |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7005 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7006 | return; |
| 7007 | } |
| 7008 | |
| 7009 | switch (target) |
| 7010 | { |
| 7011 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7012 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7013 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7014 | 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] | 7015 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7016 | break; |
| 7017 | |
| 7018 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7019 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7020 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7021 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7022 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7023 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7024 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7025 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7026 | 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] | 7027 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7028 | break; |
| 7029 | |
| 7030 | default: |
| 7031 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7032 | } |
| 7033 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7034 | } |
| 7035 | catch(std::bad_alloc&) |
| 7036 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7037 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7038 | } |
| 7039 | } |
| 7040 | |
| 7041 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 7042 | { |
| 7043 | glUniform1fv(location, 1, &x); |
| 7044 | } |
| 7045 | |
| 7046 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 7047 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7048 | 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] | 7049 | |
| 7050 | try |
| 7051 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7052 | if (count < 0) |
| 7053 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7054 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7055 | } |
| 7056 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7057 | if (location == -1) |
| 7058 | { |
| 7059 | return; |
| 7060 | } |
| 7061 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7062 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7063 | |
| 7064 | if (context) |
| 7065 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7066 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7067 | if (!programBinary) |
| 7068 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7069 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7070 | } |
| 7071 | |
| 7072 | if (!programBinary->setUniform1fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7073 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7074 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7075 | } |
| 7076 | } |
| 7077 | } |
| 7078 | catch(std::bad_alloc&) |
| 7079 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7080 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7081 | } |
| 7082 | } |
| 7083 | |
| 7084 | void __stdcall glUniform1i(GLint location, GLint x) |
| 7085 | { |
| 7086 | glUniform1iv(location, 1, &x); |
| 7087 | } |
| 7088 | |
| 7089 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 7090 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7091 | 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] | 7092 | |
| 7093 | try |
| 7094 | { |
| 7095 | if (count < 0) |
| 7096 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7097 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7098 | } |
| 7099 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7100 | if (location == -1) |
| 7101 | { |
| 7102 | return; |
| 7103 | } |
| 7104 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7105 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7106 | |
| 7107 | if (context) |
| 7108 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7109 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7110 | if (!programBinary) |
| 7111 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7112 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7113 | } |
| 7114 | |
| 7115 | if (!programBinary->setUniform1iv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7116 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7117 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7118 | } |
| 7119 | } |
| 7120 | } |
| 7121 | catch(std::bad_alloc&) |
| 7122 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7123 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7124 | } |
| 7125 | } |
| 7126 | |
| 7127 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 7128 | { |
| 7129 | GLfloat xy[2] = {x, y}; |
| 7130 | |
| 7131 | glUniform2fv(location, 1, (GLfloat*)&xy); |
| 7132 | } |
| 7133 | |
| 7134 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 7135 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7136 | 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] | 7137 | |
| 7138 | try |
| 7139 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7140 | if (count < 0) |
| 7141 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7142 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7143 | } |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7144 | |
| 7145 | if (location == -1) |
| 7146 | { |
| 7147 | return; |
| 7148 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7149 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7150 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7151 | |
| 7152 | if (context) |
| 7153 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7154 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7155 | if (!programBinary) |
| 7156 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7157 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7158 | } |
| 7159 | |
| 7160 | if (!programBinary->setUniform2fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7161 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7162 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7163 | } |
| 7164 | } |
| 7165 | } |
| 7166 | catch(std::bad_alloc&) |
| 7167 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7168 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7169 | } |
| 7170 | } |
| 7171 | |
| 7172 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 7173 | { |
| 7174 | GLint xy[4] = {x, y}; |
| 7175 | |
| 7176 | glUniform2iv(location, 1, (GLint*)&xy); |
| 7177 | } |
| 7178 | |
| 7179 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 7180 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7181 | 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] | 7182 | |
| 7183 | try |
| 7184 | { |
| 7185 | if (count < 0) |
| 7186 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7187 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7188 | } |
| 7189 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7190 | if (location == -1) |
| 7191 | { |
| 7192 | return; |
| 7193 | } |
| 7194 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7195 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7196 | |
| 7197 | if (context) |
| 7198 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7199 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7200 | if (!programBinary) |
| 7201 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7202 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7203 | } |
| 7204 | |
| 7205 | if (!programBinary->setUniform2iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7206 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7207 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7208 | } |
| 7209 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7210 | } |
| 7211 | catch(std::bad_alloc&) |
| 7212 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7213 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7214 | } |
| 7215 | } |
| 7216 | |
| 7217 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 7218 | { |
| 7219 | GLfloat xyz[3] = {x, y, z}; |
| 7220 | |
| 7221 | glUniform3fv(location, 1, (GLfloat*)&xyz); |
| 7222 | } |
| 7223 | |
| 7224 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 7225 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7226 | 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] | 7227 | |
| 7228 | try |
| 7229 | { |
| 7230 | if (count < 0) |
| 7231 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7232 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7233 | } |
| 7234 | |
| 7235 | if (location == -1) |
| 7236 | { |
| 7237 | return; |
| 7238 | } |
| 7239 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7240 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7241 | |
| 7242 | if (context) |
| 7243 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7244 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7245 | if (!programBinary) |
| 7246 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7247 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7248 | } |
| 7249 | |
| 7250 | if (!programBinary->setUniform3fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7251 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7252 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7253 | } |
| 7254 | } |
| 7255 | } |
| 7256 | catch(std::bad_alloc&) |
| 7257 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7258 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7259 | } |
| 7260 | } |
| 7261 | |
| 7262 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 7263 | { |
| 7264 | GLint xyz[3] = {x, y, z}; |
| 7265 | |
| 7266 | glUniform3iv(location, 1, (GLint*)&xyz); |
| 7267 | } |
| 7268 | |
| 7269 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 7270 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7271 | 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] | 7272 | |
| 7273 | try |
| 7274 | { |
| 7275 | if (count < 0) |
| 7276 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7277 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7278 | } |
| 7279 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7280 | if (location == -1) |
| 7281 | { |
| 7282 | return; |
| 7283 | } |
| 7284 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7285 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7286 | |
| 7287 | if (context) |
| 7288 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7289 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7290 | if (!programBinary) |
| 7291 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7292 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7293 | } |
| 7294 | |
| 7295 | if (!programBinary->setUniform3iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7296 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7297 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7298 | } |
| 7299 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7300 | } |
| 7301 | catch(std::bad_alloc&) |
| 7302 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7303 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7304 | } |
| 7305 | } |
| 7306 | |
| 7307 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7308 | { |
| 7309 | GLfloat xyzw[4] = {x, y, z, w}; |
| 7310 | |
| 7311 | glUniform4fv(location, 1, (GLfloat*)&xyzw); |
| 7312 | } |
| 7313 | |
| 7314 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 7315 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7316 | 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] | 7317 | |
| 7318 | try |
| 7319 | { |
| 7320 | if (count < 0) |
| 7321 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7322 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7323 | } |
| 7324 | |
| 7325 | if (location == -1) |
| 7326 | { |
| 7327 | return; |
| 7328 | } |
| 7329 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7330 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7331 | |
| 7332 | if (context) |
| 7333 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7334 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7335 | if (!programBinary) |
| 7336 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7337 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7338 | } |
| 7339 | |
| 7340 | if (!programBinary->setUniform4fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7341 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7342 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7343 | } |
| 7344 | } |
| 7345 | } |
| 7346 | catch(std::bad_alloc&) |
| 7347 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7348 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7349 | } |
| 7350 | } |
| 7351 | |
| 7352 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 7353 | { |
| 7354 | GLint xyzw[4] = {x, y, z, w}; |
| 7355 | |
| 7356 | glUniform4iv(location, 1, (GLint*)&xyzw); |
| 7357 | } |
| 7358 | |
| 7359 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 7360 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7361 | 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] | 7362 | |
| 7363 | try |
| 7364 | { |
| 7365 | if (count < 0) |
| 7366 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7367 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7368 | } |
| 7369 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7370 | if (location == -1) |
| 7371 | { |
| 7372 | return; |
| 7373 | } |
| 7374 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7375 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7376 | |
| 7377 | if (context) |
| 7378 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7379 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7380 | if (!programBinary) |
| 7381 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7382 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7383 | } |
| 7384 | |
| 7385 | if (!programBinary->setUniform4iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7386 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7387 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7388 | } |
| 7389 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7390 | } |
| 7391 | catch(std::bad_alloc&) |
| 7392 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7393 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7394 | } |
| 7395 | } |
| 7396 | |
| 7397 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7398 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7399 | 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] | 7400 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7401 | |
| 7402 | try |
| 7403 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7404 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7405 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7406 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7407 | } |
| 7408 | |
| 7409 | if (location == -1) |
| 7410 | { |
| 7411 | return; |
| 7412 | } |
| 7413 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7414 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7415 | |
| 7416 | if (context) |
| 7417 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7418 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7419 | { |
| 7420 | return gl::error(GL_INVALID_VALUE); |
| 7421 | } |
| 7422 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7423 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7424 | if (!programBinary) |
| 7425 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7426 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7427 | } |
| 7428 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7429 | if (!programBinary->setUniformMatrix2fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7430 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7431 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7432 | } |
| 7433 | } |
| 7434 | } |
| 7435 | catch(std::bad_alloc&) |
| 7436 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7437 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7438 | } |
| 7439 | } |
| 7440 | |
| 7441 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7442 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7443 | 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] | 7444 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7445 | |
| 7446 | try |
| 7447 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7448 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 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 | |
| 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 | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7459 | |
| 7460 | if (context) |
| 7461 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7462 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7463 | { |
| 7464 | return gl::error(GL_INVALID_VALUE); |
| 7465 | } |
| 7466 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7467 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7468 | if (!programBinary) |
| 7469 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7470 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7471 | } |
| 7472 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7473 | if (!programBinary->setUniformMatrix3fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7474 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7475 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7476 | } |
| 7477 | } |
| 7478 | } |
| 7479 | catch(std::bad_alloc&) |
| 7480 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7481 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7482 | } |
| 7483 | } |
| 7484 | |
| 7485 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7486 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7487 | 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] | 7488 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7489 | |
| 7490 | try |
| 7491 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7492 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7493 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7494 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7495 | } |
| 7496 | |
| 7497 | if (location == -1) |
| 7498 | { |
| 7499 | return; |
| 7500 | } |
| 7501 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7502 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7503 | |
| 7504 | if (context) |
| 7505 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7506 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7507 | { |
| 7508 | return gl::error(GL_INVALID_VALUE); |
| 7509 | } |
| 7510 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7511 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7512 | if (!programBinary) |
| 7513 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7514 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7515 | } |
| 7516 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7517 | if (!programBinary->setUniformMatrix4fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7518 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7519 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7520 | } |
| 7521 | } |
| 7522 | } |
| 7523 | catch(std::bad_alloc&) |
| 7524 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7525 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7526 | } |
| 7527 | } |
| 7528 | |
| 7529 | void __stdcall glUseProgram(GLuint program) |
| 7530 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7531 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7532 | |
| 7533 | try |
| 7534 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7535 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7536 | |
| 7537 | if (context) |
| 7538 | { |
| 7539 | gl::Program *programObject = context->getProgram(program); |
| 7540 | |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7541 | if (!programObject && program != 0) |
| 7542 | { |
| 7543 | if (context->getShader(program)) |
| 7544 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7545 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7546 | } |
| 7547 | else |
| 7548 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7549 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7550 | } |
| 7551 | } |
| 7552 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 7553 | if (program != 0 && !programObject->isLinked()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7554 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7555 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7556 | } |
| 7557 | |
| 7558 | context->useProgram(program); |
| 7559 | } |
| 7560 | } |
| 7561 | catch(std::bad_alloc&) |
| 7562 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7563 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7564 | } |
| 7565 | } |
| 7566 | |
| 7567 | void __stdcall glValidateProgram(GLuint program) |
| 7568 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7569 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7570 | |
| 7571 | try |
| 7572 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7573 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7574 | |
| 7575 | if (context) |
| 7576 | { |
| 7577 | gl::Program *programObject = context->getProgram(program); |
| 7578 | |
| 7579 | if (!programObject) |
| 7580 | { |
| 7581 | if (context->getShader(program)) |
| 7582 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7583 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7584 | } |
| 7585 | else |
| 7586 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7587 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7588 | } |
| 7589 | } |
| 7590 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 7591 | programObject->validate(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7592 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7593 | } |
| 7594 | catch(std::bad_alloc&) |
| 7595 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7596 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7597 | } |
| 7598 | } |
| 7599 | |
| 7600 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 7601 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7602 | EVENT("(GLuint index = %d, GLfloat x = %f)", index, x); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7603 | |
| 7604 | try |
| 7605 | { |
| 7606 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7607 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7608 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7609 | } |
| 7610 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7611 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7612 | |
| 7613 | if (context) |
| 7614 | { |
| 7615 | GLfloat vals[4] = { x, 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7616 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7617 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7618 | } |
| 7619 | catch(std::bad_alloc&) |
| 7620 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7621 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7622 | } |
| 7623 | } |
| 7624 | |
| 7625 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 7626 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7627 | 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] | 7628 | |
| 7629 | try |
| 7630 | { |
| 7631 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7632 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7633 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7634 | } |
| 7635 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7636 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7637 | |
| 7638 | if (context) |
| 7639 | { |
| 7640 | GLfloat vals[4] = { values[0], 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7641 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7642 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7643 | } |
| 7644 | catch(std::bad_alloc&) |
| 7645 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7646 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7647 | } |
| 7648 | } |
| 7649 | |
| 7650 | void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 7651 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7652 | 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] | 7653 | |
| 7654 | try |
| 7655 | { |
| 7656 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7657 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7658 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7659 | } |
| 7660 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7661 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7662 | |
| 7663 | if (context) |
| 7664 | { |
| 7665 | GLfloat vals[4] = { x, y, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7666 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7667 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7668 | } |
| 7669 | catch(std::bad_alloc&) |
| 7670 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7671 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7672 | } |
| 7673 | } |
| 7674 | |
| 7675 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 7676 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7677 | 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] | 7678 | |
| 7679 | try |
| 7680 | { |
| 7681 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7682 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7683 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7684 | } |
| 7685 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7686 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7687 | |
| 7688 | if (context) |
| 7689 | { |
| 7690 | 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] | 7691 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7692 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7693 | } |
| 7694 | catch(std::bad_alloc&) |
| 7695 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7696 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7697 | } |
| 7698 | } |
| 7699 | |
| 7700 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 7701 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7702 | 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] | 7703 | |
| 7704 | try |
| 7705 | { |
| 7706 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7707 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7708 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7709 | } |
| 7710 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7711 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7712 | |
| 7713 | if (context) |
| 7714 | { |
| 7715 | GLfloat vals[4] = { x, y, z, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7716 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7717 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7718 | } |
| 7719 | catch(std::bad_alloc&) |
| 7720 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7721 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7722 | } |
| 7723 | } |
| 7724 | |
| 7725 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 7726 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7727 | 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] | 7728 | |
| 7729 | try |
| 7730 | { |
| 7731 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7732 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7733 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7734 | } |
| 7735 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7736 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7737 | |
| 7738 | if (context) |
| 7739 | { |
| 7740 | 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] | 7741 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7742 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7743 | } |
| 7744 | catch(std::bad_alloc&) |
| 7745 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7746 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7747 | } |
| 7748 | } |
| 7749 | |
| 7750 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7751 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7752 | 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] | 7753 | |
| 7754 | try |
| 7755 | { |
| 7756 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7757 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7758 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7759 | } |
| 7760 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7761 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7762 | |
| 7763 | if (context) |
| 7764 | { |
| 7765 | GLfloat vals[4] = { x, y, z, w }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7766 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7767 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7768 | } |
| 7769 | catch(std::bad_alloc&) |
| 7770 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7771 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7772 | } |
| 7773 | } |
| 7774 | |
| 7775 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 7776 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7777 | 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] | 7778 | |
| 7779 | try |
| 7780 | { |
| 7781 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7782 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7783 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7784 | } |
| 7785 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7786 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7787 | |
| 7788 | if (context) |
| 7789 | { |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7790 | context->setVertexAttribf(index, values); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7791 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7792 | } |
| 7793 | catch(std::bad_alloc&) |
| 7794 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7795 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7796 | } |
| 7797 | } |
| 7798 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 7799 | void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
| 7800 | { |
| 7801 | EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor); |
| 7802 | |
| 7803 | try |
| 7804 | { |
| 7805 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7806 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7807 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 7808 | } |
| 7809 | |
| 7810 | gl::Context *context = gl::getNonLostContext(); |
| 7811 | |
| 7812 | if (context) |
| 7813 | { |
| 7814 | context->setVertexAttribDivisor(index, divisor); |
| 7815 | } |
| 7816 | } |
| 7817 | catch(std::bad_alloc&) |
| 7818 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7819 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 7820 | } |
| 7821 | } |
| 7822 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7823 | 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] | 7824 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7825 | 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] | 7826 | "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] | 7827 | index, size, type, normalized, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7828 | |
| 7829 | try |
| 7830 | { |
| 7831 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7832 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7833 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7834 | } |
| 7835 | |
| 7836 | if (size < 1 || size > 4) |
| 7837 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7838 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7839 | } |
| 7840 | |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 7841 | gl::Context *context = gl::getNonLostContext(); |
| 7842 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7843 | switch (type) |
| 7844 | { |
| 7845 | case GL_BYTE: |
| 7846 | case GL_UNSIGNED_BYTE: |
| 7847 | case GL_SHORT: |
| 7848 | case GL_UNSIGNED_SHORT: |
| 7849 | case GL_FIXED: |
| 7850 | case GL_FLOAT: |
| 7851 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 7852 | case GL_HALF_FLOAT: |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7853 | case GL_INT: |
| 7854 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 7855 | case GL_INT_2_10_10_10_REV: |
| 7856 | 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] | 7857 | if (context && context->getClientVersion() < 3) |
| 7858 | { |
| 7859 | return gl::error(GL_INVALID_ENUM); |
| 7860 | } |
| 7861 | else |
| 7862 | { |
| 7863 | break; |
| 7864 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7865 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7866 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7867 | } |
| 7868 | |
| 7869 | if (stride < 0) |
| 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 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 7874 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 7875 | { |
| 7876 | return gl::error(GL_INVALID_OPERATION); |
| 7877 | } |
| 7878 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7879 | if (context) |
| 7880 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8de4e6a | 2013-04-13 03:37:44 +0000 | [diff] [blame] | 7881 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, |
| 7882 | normalized == GL_TRUE, false, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7883 | } |
| 7884 | } |
| 7885 | catch(std::bad_alloc&) |
| 7886 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7887 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7888 | } |
| 7889 | } |
| 7890 | |
| 7891 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 7892 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7893 | 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] | 7894 | |
| 7895 | try |
| 7896 | { |
| 7897 | if (width < 0 || height < 0) |
| 7898 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7899 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7900 | } |
| 7901 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7902 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7903 | |
| 7904 | if (context) |
| 7905 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7906 | context->setViewportParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7907 | } |
| 7908 | } |
| 7909 | catch(std::bad_alloc&) |
| 7910 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7911 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7912 | } |
| 7913 | } |
| 7914 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7915 | // OpenGL ES 3.0 functions |
| 7916 | |
| 7917 | void __stdcall glReadBuffer(GLenum mode) |
| 7918 | { |
| 7919 | EVENT("(GLenum mode = 0x%X)", mode); |
| 7920 | |
| 7921 | try |
| 7922 | { |
| 7923 | gl::Context *context = gl::getNonLostContext(); |
| 7924 | |
| 7925 | if (context) |
| 7926 | { |
| 7927 | if (context->getClientVersion() < 3) |
| 7928 | { |
| 7929 | return gl::error(GL_INVALID_OPERATION); |
| 7930 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7931 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7932 | UNIMPLEMENTED(); |
| 7933 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7934 | } |
| 7935 | catch(std::bad_alloc&) |
| 7936 | { |
| 7937 | return gl::error(GL_OUT_OF_MEMORY); |
| 7938 | } |
| 7939 | } |
| 7940 | |
| 7941 | void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) |
| 7942 | { |
| 7943 | EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, " |
| 7944 | "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices); |
| 7945 | |
| 7946 | try |
| 7947 | { |
| 7948 | gl::Context *context = gl::getNonLostContext(); |
| 7949 | |
| 7950 | if (context) |
| 7951 | { |
| 7952 | if (context->getClientVersion() < 3) |
| 7953 | { |
| 7954 | return gl::error(GL_INVALID_OPERATION); |
| 7955 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7956 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7957 | UNIMPLEMENTED(); |
| 7958 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7959 | } |
| 7960 | catch(std::bad_alloc&) |
| 7961 | { |
| 7962 | return gl::error(GL_OUT_OF_MEMORY); |
| 7963 | } |
| 7964 | } |
| 7965 | |
| 7966 | void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
| 7967 | { |
| 7968 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 7969 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " |
| 7970 | "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 7971 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 7972 | |
| 7973 | try |
| 7974 | { |
| 7975 | gl::Context *context = gl::getNonLostContext(); |
| 7976 | |
| 7977 | if (context) |
| 7978 | { |
| 7979 | if (context->getClientVersion() < 3) |
| 7980 | { |
| 7981 | return gl::error(GL_INVALID_OPERATION); |
| 7982 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7983 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 7984 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 7985 | if (!validateES3TexImageParameters(context, target, level, internalformat, false, false, |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 7986 | 0, 0, 0, width, height, depth, border, format, type)) |
| 7987 | { |
| 7988 | return; |
| 7989 | } |
| 7990 | |
| 7991 | switch(target) |
| 7992 | { |
| 7993 | case GL_TEXTURE_3D: |
| 7994 | { |
| 7995 | gl::Texture3D *texture = context->getTexture3D(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 7996 | 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] | 7997 | } |
| 7998 | break; |
| 7999 | |
| 8000 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8001 | { |
| 8002 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8003 | 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] | 8004 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8005 | break; |
| 8006 | |
| 8007 | default: |
| 8008 | return gl::error(GL_INVALID_ENUM); |
| 8009 | } |
| 8010 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8011 | } |
| 8012 | catch(std::bad_alloc&) |
| 8013 | { |
| 8014 | return gl::error(GL_OUT_OF_MEMORY); |
| 8015 | } |
| 8016 | } |
| 8017 | |
| 8018 | 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) |
| 8019 | { |
| 8020 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8021 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8022 | "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8023 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); |
| 8024 | |
| 8025 | try |
| 8026 | { |
| 8027 | gl::Context *context = gl::getNonLostContext(); |
| 8028 | |
| 8029 | if (context) |
| 8030 | { |
| 8031 | if (context->getClientVersion() < 3) |
| 8032 | { |
| 8033 | return gl::error(GL_INVALID_OPERATION); |
| 8034 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8035 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8036 | if (!pixels) |
| 8037 | { |
| 8038 | return gl::error(GL_INVALID_VALUE); |
| 8039 | } |
| 8040 | |
| 8041 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8042 | 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] | 8043 | xoffset, yoffset, zoffset, width, height, depth, 0, |
| 8044 | format, type)) |
| 8045 | { |
| 8046 | return; |
| 8047 | } |
| 8048 | |
| 8049 | switch(target) |
| 8050 | { |
| 8051 | case GL_TEXTURE_3D: |
| 8052 | { |
| 8053 | gl::Texture3D *texture = context->getTexture3D(); |
| 8054 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8055 | } |
| 8056 | break; |
| 8057 | |
| 8058 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8059 | { |
| 8060 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8061 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8062 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8063 | break; |
| 8064 | |
| 8065 | default: |
| 8066 | return gl::error(GL_INVALID_ENUM); |
| 8067 | } |
| 8068 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8069 | } |
| 8070 | catch(std::bad_alloc&) |
| 8071 | { |
| 8072 | return gl::error(GL_OUT_OF_MEMORY); |
| 8073 | } |
| 8074 | } |
| 8075 | |
| 8076 | void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 8077 | { |
| 8078 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8079 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 8080 | target, level, xoffset, yoffset, zoffset, x, y, width, height); |
| 8081 | |
| 8082 | try |
| 8083 | { |
| 8084 | gl::Context *context = gl::getNonLostContext(); |
| 8085 | |
| 8086 | if (context) |
| 8087 | { |
| 8088 | if (context->getClientVersion() < 3) |
| 8089 | { |
| 8090 | return gl::error(GL_INVALID_OPERATION); |
| 8091 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8092 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8093 | if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset, |
| 8094 | x, y, width, height, 0)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8095 | { |
| 8096 | return; |
| 8097 | } |
| 8098 | |
| 8099 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 8100 | gl::Texture *texture = NULL; |
| 8101 | switch (target) |
| 8102 | { |
| 8103 | case GL_TEXTURE_3D: |
| 8104 | texture = context->getTexture3D(); |
| 8105 | break; |
| 8106 | |
| 8107 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8108 | texture = context->getTexture2DArray(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8109 | break; |
| 8110 | |
| 8111 | default: |
| 8112 | return gl::error(GL_INVALID_ENUM); |
| 8113 | } |
| 8114 | |
| 8115 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer); |
| 8116 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8117 | } |
| 8118 | catch(std::bad_alloc&) |
| 8119 | { |
| 8120 | return gl::error(GL_OUT_OF_MEMORY); |
| 8121 | } |
| 8122 | } |
| 8123 | |
| 8124 | void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) |
| 8125 | { |
| 8126 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8127 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, " |
| 8128 | "const GLvoid* data = 0x%0.8p)", |
| 8129 | target, level, internalformat, width, height, depth, border, imageSize, data); |
| 8130 | |
| 8131 | try |
| 8132 | { |
| 8133 | gl::Context *context = gl::getNonLostContext(); |
| 8134 | |
| 8135 | if (context) |
| 8136 | { |
| 8137 | if (context->getClientVersion() < 3) |
| 8138 | { |
| 8139 | return gl::error(GL_INVALID_OPERATION); |
| 8140 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8141 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8142 | 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] | 8143 | { |
| 8144 | return gl::error(GL_INVALID_VALUE); |
| 8145 | } |
| 8146 | |
| 8147 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8148 | if (!validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 8149 | 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] | 8150 | { |
| 8151 | return; |
| 8152 | } |
| 8153 | |
| 8154 | switch(target) |
| 8155 | { |
| 8156 | case GL_TEXTURE_3D: |
| 8157 | { |
| 8158 | gl::Texture3D *texture = context->getTexture3D(); |
| 8159 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8160 | } |
| 8161 | break; |
| 8162 | |
| 8163 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8164 | { |
| 8165 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8166 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8167 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8168 | break; |
| 8169 | |
| 8170 | default: |
| 8171 | return gl::error(GL_INVALID_ENUM); |
| 8172 | } |
| 8173 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8174 | } |
| 8175 | catch(std::bad_alloc&) |
| 8176 | { |
| 8177 | return gl::error(GL_OUT_OF_MEMORY); |
| 8178 | } |
| 8179 | } |
| 8180 | |
| 8181 | void __stdcall glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) |
| 8182 | { |
| 8183 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8184 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8185 | "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 8186 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); |
| 8187 | |
| 8188 | try |
| 8189 | { |
| 8190 | gl::Context *context = gl::getNonLostContext(); |
| 8191 | |
| 8192 | if (context) |
| 8193 | { |
| 8194 | if (context->getClientVersion() < 3) |
| 8195 | { |
| 8196 | return gl::error(GL_INVALID_OPERATION); |
| 8197 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8198 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8199 | 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] | 8200 | { |
| 8201 | return gl::error(GL_INVALID_VALUE); |
| 8202 | } |
| 8203 | |
| 8204 | if (!data) |
| 8205 | { |
| 8206 | return gl::error(GL_INVALID_VALUE); |
| 8207 | } |
| 8208 | |
| 8209 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8210 | if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 8211 | 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] | 8212 | { |
| 8213 | return; |
| 8214 | } |
| 8215 | |
| 8216 | switch(target) |
| 8217 | { |
| 8218 | case GL_TEXTURE_3D: |
| 8219 | { |
| 8220 | gl::Texture3D *texture = context->getTexture3D(); |
| 8221 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8222 | format, imageSize, data); |
| 8223 | } |
| 8224 | break; |
| 8225 | |
| 8226 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8227 | { |
| 8228 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8229 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8230 | format, imageSize, data); |
| 8231 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8232 | break; |
| 8233 | |
| 8234 | default: |
| 8235 | return gl::error(GL_INVALID_ENUM); |
| 8236 | } |
| 8237 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8238 | } |
| 8239 | catch(std::bad_alloc&) |
| 8240 | { |
| 8241 | return gl::error(GL_OUT_OF_MEMORY); |
| 8242 | } |
| 8243 | } |
| 8244 | |
| 8245 | void __stdcall glGenQueries(GLsizei n, GLuint* ids) |
| 8246 | { |
| 8247 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8248 | |
| 8249 | try |
| 8250 | { |
| 8251 | gl::Context *context = gl::getNonLostContext(); |
| 8252 | |
| 8253 | if (context) |
| 8254 | { |
| 8255 | if (context->getClientVersion() < 3) |
| 8256 | { |
| 8257 | return gl::error(GL_INVALID_OPERATION); |
| 8258 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8259 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8260 | UNIMPLEMENTED(); |
| 8261 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8262 | } |
| 8263 | catch(std::bad_alloc&) |
| 8264 | { |
| 8265 | return gl::error(GL_OUT_OF_MEMORY); |
| 8266 | } |
| 8267 | } |
| 8268 | |
| 8269 | void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids) |
| 8270 | { |
| 8271 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8272 | |
| 8273 | try |
| 8274 | { |
| 8275 | gl::Context *context = gl::getNonLostContext(); |
| 8276 | |
| 8277 | if (context) |
| 8278 | { |
| 8279 | if (context->getClientVersion() < 3) |
| 8280 | { |
| 8281 | return gl::error(GL_INVALID_OPERATION); |
| 8282 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8283 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8284 | UNIMPLEMENTED(); |
| 8285 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8286 | } |
| 8287 | catch(std::bad_alloc&) |
| 8288 | { |
| 8289 | return gl::error(GL_OUT_OF_MEMORY); |
| 8290 | } |
| 8291 | } |
| 8292 | |
| 8293 | GLboolean __stdcall glIsQuery(GLuint id) |
| 8294 | { |
| 8295 | EVENT("(GLuint id = %u)", id); |
| 8296 | |
| 8297 | try |
| 8298 | { |
| 8299 | gl::Context *context = gl::getNonLostContext(); |
| 8300 | |
| 8301 | if (context) |
| 8302 | { |
| 8303 | if (context->getClientVersion() < 3) |
| 8304 | { |
| 8305 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8306 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8307 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8308 | UNIMPLEMENTED(); |
| 8309 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8310 | } |
| 8311 | catch(std::bad_alloc&) |
| 8312 | { |
| 8313 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8314 | } |
| 8315 | |
| 8316 | return GL_FALSE; |
| 8317 | } |
| 8318 | |
| 8319 | void __stdcall glBeginQuery(GLenum target, GLuint id) |
| 8320 | { |
| 8321 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 8322 | |
| 8323 | try |
| 8324 | { |
| 8325 | gl::Context *context = gl::getNonLostContext(); |
| 8326 | |
| 8327 | if (context) |
| 8328 | { |
| 8329 | if (context->getClientVersion() < 3) |
| 8330 | { |
| 8331 | return gl::error(GL_INVALID_OPERATION); |
| 8332 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8333 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8334 | UNIMPLEMENTED(); |
| 8335 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8336 | } |
| 8337 | catch(std::bad_alloc&) |
| 8338 | { |
| 8339 | return gl::error(GL_OUT_OF_MEMORY); |
| 8340 | } |
| 8341 | } |
| 8342 | |
| 8343 | void __stdcall glEndQuery(GLenum target) |
| 8344 | { |
| 8345 | EVENT("(GLenum target = 0x%X)", target); |
| 8346 | |
| 8347 | try |
| 8348 | { |
| 8349 | gl::Context *context = gl::getNonLostContext(); |
| 8350 | |
| 8351 | if (context) |
| 8352 | { |
| 8353 | if (context->getClientVersion() < 3) |
| 8354 | { |
| 8355 | return gl::error(GL_INVALID_OPERATION); |
| 8356 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8357 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8358 | UNIMPLEMENTED(); |
| 8359 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8360 | } |
| 8361 | catch(std::bad_alloc&) |
| 8362 | { |
| 8363 | return gl::error(GL_OUT_OF_MEMORY); |
| 8364 | } |
| 8365 | } |
| 8366 | |
| 8367 | void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params) |
| 8368 | { |
| 8369 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
| 8370 | |
| 8371 | try |
| 8372 | { |
| 8373 | gl::Context *context = gl::getNonLostContext(); |
| 8374 | |
| 8375 | if (context) |
| 8376 | { |
| 8377 | if (context->getClientVersion() < 3) |
| 8378 | { |
| 8379 | return gl::error(GL_INVALID_OPERATION); |
| 8380 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8381 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8382 | UNIMPLEMENTED(); |
| 8383 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8384 | } |
| 8385 | catch(std::bad_alloc&) |
| 8386 | { |
| 8387 | return gl::error(GL_OUT_OF_MEMORY); |
| 8388 | } |
| 8389 | } |
| 8390 | |
| 8391 | void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) |
| 8392 | { |
| 8393 | EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params); |
| 8394 | |
| 8395 | try |
| 8396 | { |
| 8397 | gl::Context *context = gl::getNonLostContext(); |
| 8398 | |
| 8399 | if (context) |
| 8400 | { |
| 8401 | if (context->getClientVersion() < 3) |
| 8402 | { |
| 8403 | return gl::error(GL_INVALID_OPERATION); |
| 8404 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8405 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8406 | UNIMPLEMENTED(); |
| 8407 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8408 | } |
| 8409 | catch(std::bad_alloc&) |
| 8410 | { |
| 8411 | return gl::error(GL_OUT_OF_MEMORY); |
| 8412 | } |
| 8413 | } |
| 8414 | |
| 8415 | GLboolean __stdcall glUnmapBuffer(GLenum target) |
| 8416 | { |
| 8417 | EVENT("(GLenum target = 0x%X)", target); |
| 8418 | |
| 8419 | try |
| 8420 | { |
| 8421 | gl::Context *context = gl::getNonLostContext(); |
| 8422 | |
| 8423 | if (context) |
| 8424 | { |
| 8425 | if (context->getClientVersion() < 3) |
| 8426 | { |
| 8427 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8428 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8429 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8430 | UNIMPLEMENTED(); |
| 8431 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8432 | } |
| 8433 | catch(std::bad_alloc&) |
| 8434 | { |
| 8435 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8436 | } |
| 8437 | |
| 8438 | return GL_FALSE; |
| 8439 | } |
| 8440 | |
| 8441 | void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) |
| 8442 | { |
| 8443 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 8444 | |
| 8445 | try |
| 8446 | { |
| 8447 | gl::Context *context = gl::getNonLostContext(); |
| 8448 | |
| 8449 | if (context) |
| 8450 | { |
| 8451 | if (context->getClientVersion() < 3) |
| 8452 | { |
| 8453 | return gl::error(GL_INVALID_OPERATION); |
| 8454 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8455 | |
shannonwoods@chromium.org | 2d2190a | 2013-05-30 00:17:35 +0000 | [diff] [blame] | 8456 | UNIMPLEMENTED(); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8457 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8458 | } |
| 8459 | catch(std::bad_alloc&) |
| 8460 | { |
| 8461 | return gl::error(GL_OUT_OF_MEMORY); |
| 8462 | } |
| 8463 | } |
| 8464 | |
| 8465 | void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs) |
| 8466 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8467 | try |
| 8468 | { |
| 8469 | gl::Context *context = gl::getNonLostContext(); |
| 8470 | |
| 8471 | if (context) |
| 8472 | { |
| 8473 | if (context->getClientVersion() < 3) |
| 8474 | { |
| 8475 | return gl::error(GL_INVALID_OPERATION); |
| 8476 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8477 | |
shannon.woods%transgaming.com@gtempaccount.com | 7948c5f | 2013-04-13 03:38:58 +0000 | [diff] [blame] | 8478 | glDrawBuffersEXT(n, bufs); |
| 8479 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8480 | } |
| 8481 | catch(std::bad_alloc&) |
| 8482 | { |
| 8483 | return gl::error(GL_OUT_OF_MEMORY); |
| 8484 | } |
| 8485 | } |
| 8486 | |
| 8487 | void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8488 | { |
| 8489 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8490 | location, count, transpose, value); |
| 8491 | |
| 8492 | try |
| 8493 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8494 | if (count < 0) |
| 8495 | { |
| 8496 | return gl::error(GL_INVALID_VALUE); |
| 8497 | } |
| 8498 | |
| 8499 | if (location == -1) |
| 8500 | { |
| 8501 | return; |
| 8502 | } |
| 8503 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8504 | gl::Context *context = gl::getNonLostContext(); |
| 8505 | |
| 8506 | if (context) |
| 8507 | { |
| 8508 | if (context->getClientVersion() < 3) |
| 8509 | { |
| 8510 | return gl::error(GL_INVALID_OPERATION); |
| 8511 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8512 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8513 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8514 | if (!programBinary) |
| 8515 | { |
| 8516 | return gl::error(GL_INVALID_OPERATION); |
| 8517 | } |
| 8518 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8519 | if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8520 | { |
| 8521 | return gl::error(GL_INVALID_OPERATION); |
| 8522 | } |
| 8523 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8524 | } |
| 8525 | catch(std::bad_alloc&) |
| 8526 | { |
| 8527 | return gl::error(GL_OUT_OF_MEMORY); |
| 8528 | } |
| 8529 | } |
| 8530 | |
| 8531 | void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8532 | { |
| 8533 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8534 | location, count, transpose, value); |
| 8535 | |
| 8536 | try |
| 8537 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8538 | if (count < 0) |
| 8539 | { |
| 8540 | return gl::error(GL_INVALID_VALUE); |
| 8541 | } |
| 8542 | |
| 8543 | if (location == -1) |
| 8544 | { |
| 8545 | return; |
| 8546 | } |
| 8547 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8548 | gl::Context *context = gl::getNonLostContext(); |
| 8549 | |
| 8550 | if (context) |
| 8551 | { |
| 8552 | if (context->getClientVersion() < 3) |
| 8553 | { |
| 8554 | return gl::error(GL_INVALID_OPERATION); |
| 8555 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8556 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8557 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8558 | if (!programBinary) |
| 8559 | { |
| 8560 | return gl::error(GL_INVALID_OPERATION); |
| 8561 | } |
| 8562 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8563 | if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8564 | { |
| 8565 | return gl::error(GL_INVALID_OPERATION); |
| 8566 | } |
| 8567 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8568 | } |
| 8569 | catch(std::bad_alloc&) |
| 8570 | { |
| 8571 | return gl::error(GL_OUT_OF_MEMORY); |
| 8572 | } |
| 8573 | } |
| 8574 | |
| 8575 | void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8576 | { |
| 8577 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8578 | location, count, transpose, value); |
| 8579 | |
| 8580 | try |
| 8581 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8582 | if (count < 0) |
| 8583 | { |
| 8584 | return gl::error(GL_INVALID_VALUE); |
| 8585 | } |
| 8586 | |
| 8587 | if (location == -1) |
| 8588 | { |
| 8589 | return; |
| 8590 | } |
| 8591 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8592 | gl::Context *context = gl::getNonLostContext(); |
| 8593 | |
| 8594 | if (context) |
| 8595 | { |
| 8596 | if (context->getClientVersion() < 3) |
| 8597 | { |
| 8598 | return gl::error(GL_INVALID_OPERATION); |
| 8599 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8600 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8601 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8602 | if (!programBinary) |
| 8603 | { |
| 8604 | return gl::error(GL_INVALID_OPERATION); |
| 8605 | } |
| 8606 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8607 | if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8608 | { |
| 8609 | return gl::error(GL_INVALID_OPERATION); |
| 8610 | } |
| 8611 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8612 | } |
| 8613 | catch(std::bad_alloc&) |
| 8614 | { |
| 8615 | return gl::error(GL_OUT_OF_MEMORY); |
| 8616 | } |
| 8617 | } |
| 8618 | |
| 8619 | void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8620 | { |
| 8621 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8622 | location, count, transpose, value); |
| 8623 | |
| 8624 | try |
| 8625 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8626 | if (count < 0) |
| 8627 | { |
| 8628 | return gl::error(GL_INVALID_VALUE); |
| 8629 | } |
| 8630 | |
| 8631 | if (location == -1) |
| 8632 | { |
| 8633 | return; |
| 8634 | } |
| 8635 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 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 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8645 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8646 | if (!programBinary) |
| 8647 | { |
| 8648 | return gl::error(GL_INVALID_OPERATION); |
| 8649 | } |
| 8650 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8651 | if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8652 | { |
| 8653 | return gl::error(GL_INVALID_OPERATION); |
| 8654 | } |
| 8655 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8656 | } |
| 8657 | catch(std::bad_alloc&) |
| 8658 | { |
| 8659 | return gl::error(GL_OUT_OF_MEMORY); |
| 8660 | } |
| 8661 | } |
| 8662 | |
| 8663 | void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8664 | { |
| 8665 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8666 | location, count, transpose, value); |
| 8667 | |
| 8668 | try |
| 8669 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8670 | if (count < 0) |
| 8671 | { |
| 8672 | return gl::error(GL_INVALID_VALUE); |
| 8673 | } |
| 8674 | |
| 8675 | if (location == -1) |
| 8676 | { |
| 8677 | return; |
| 8678 | } |
| 8679 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8680 | gl::Context *context = gl::getNonLostContext(); |
| 8681 | |
| 8682 | if (context) |
| 8683 | { |
| 8684 | if (context->getClientVersion() < 3) |
| 8685 | { |
| 8686 | return gl::error(GL_INVALID_OPERATION); |
| 8687 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8688 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8689 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8690 | if (!programBinary) |
| 8691 | { |
| 8692 | return gl::error(GL_INVALID_OPERATION); |
| 8693 | } |
| 8694 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8695 | if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8696 | { |
| 8697 | return gl::error(GL_INVALID_OPERATION); |
| 8698 | } |
| 8699 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8700 | } |
| 8701 | catch(std::bad_alloc&) |
| 8702 | { |
| 8703 | return gl::error(GL_OUT_OF_MEMORY); |
| 8704 | } |
| 8705 | } |
| 8706 | |
| 8707 | void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8708 | { |
| 8709 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8710 | location, count, transpose, value); |
| 8711 | |
| 8712 | try |
| 8713 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8714 | if (count < 0) |
| 8715 | { |
| 8716 | return gl::error(GL_INVALID_VALUE); |
| 8717 | } |
| 8718 | |
| 8719 | if (location == -1) |
| 8720 | { |
| 8721 | return; |
| 8722 | } |
| 8723 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8724 | gl::Context *context = gl::getNonLostContext(); |
| 8725 | |
| 8726 | if (context) |
| 8727 | { |
| 8728 | if (context->getClientVersion() < 3) |
| 8729 | { |
| 8730 | return gl::error(GL_INVALID_OPERATION); |
| 8731 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8732 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8733 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8734 | if (!programBinary) |
| 8735 | { |
| 8736 | return gl::error(GL_INVALID_OPERATION); |
| 8737 | } |
| 8738 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8739 | if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8740 | { |
| 8741 | return gl::error(GL_INVALID_OPERATION); |
| 8742 | } |
| 8743 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8744 | } |
| 8745 | catch(std::bad_alloc&) |
| 8746 | { |
| 8747 | return gl::error(GL_OUT_OF_MEMORY); |
| 8748 | } |
| 8749 | } |
| 8750 | |
| 8751 | void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) |
| 8752 | { |
| 8753 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, " |
| 8754 | "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 8755 | srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 8756 | |
| 8757 | try |
| 8758 | { |
| 8759 | gl::Context *context = gl::getNonLostContext(); |
| 8760 | |
| 8761 | if (context) |
| 8762 | { |
| 8763 | if (context->getClientVersion() < 3) |
| 8764 | { |
| 8765 | return gl::error(GL_INVALID_OPERATION); |
| 8766 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8767 | |
shannonwoods@chromium.org | ee14856 | 2013-05-30 00:17:21 +0000 | [diff] [blame] | 8768 | glBlitFramebufferANGLE(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8769 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8770 | } |
| 8771 | catch(std::bad_alloc&) |
| 8772 | { |
| 8773 | return gl::error(GL_OUT_OF_MEMORY); |
| 8774 | } |
| 8775 | } |
| 8776 | |
| 8777 | void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| 8778 | { |
| 8779 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 8780 | target, samples, internalformat, width, height); |
| 8781 | |
| 8782 | try |
| 8783 | { |
| 8784 | gl::Context *context = gl::getNonLostContext(); |
| 8785 | |
| 8786 | if (context) |
| 8787 | { |
| 8788 | if (context->getClientVersion() < 3) |
| 8789 | { |
| 8790 | return gl::error(GL_INVALID_OPERATION); |
| 8791 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8792 | |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 8793 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 8794 | width, height, false)) |
| 8795 | { |
| 8796 | return; |
| 8797 | } |
| 8798 | |
| 8799 | context->setRenderbufferStorage(width, height, internalformat, samples); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8800 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8801 | } |
| 8802 | catch(std::bad_alloc&) |
| 8803 | { |
| 8804 | return gl::error(GL_OUT_OF_MEMORY); |
| 8805 | } |
| 8806 | } |
| 8807 | |
| 8808 | void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) |
| 8809 | { |
| 8810 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)", |
| 8811 | target, attachment, texture, level, layer); |
| 8812 | |
| 8813 | try |
| 8814 | { |
| 8815 | gl::Context *context = gl::getNonLostContext(); |
| 8816 | |
| 8817 | if (context) |
| 8818 | { |
| 8819 | if (context->getClientVersion() < 3) |
| 8820 | { |
| 8821 | return gl::error(GL_INVALID_OPERATION); |
| 8822 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8823 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8824 | UNIMPLEMENTED(); |
| 8825 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8826 | } |
| 8827 | catch(std::bad_alloc&) |
| 8828 | { |
| 8829 | return gl::error(GL_OUT_OF_MEMORY); |
| 8830 | } |
| 8831 | } |
| 8832 | |
| 8833 | GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 8834 | { |
| 8835 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 8836 | target, offset, length, access); |
| 8837 | |
| 8838 | try |
| 8839 | { |
| 8840 | gl::Context *context = gl::getNonLostContext(); |
| 8841 | |
| 8842 | if (context) |
| 8843 | { |
| 8844 | if (context->getClientVersion() < 3) |
| 8845 | { |
| 8846 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 8847 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8848 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8849 | UNIMPLEMENTED(); |
| 8850 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8851 | } |
| 8852 | catch(std::bad_alloc&) |
| 8853 | { |
| 8854 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL)); |
| 8855 | } |
| 8856 | |
| 8857 | return NULL; |
| 8858 | } |
| 8859 | |
| 8860 | void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) |
| 8861 | { |
| 8862 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 8863 | |
| 8864 | try |
| 8865 | { |
| 8866 | gl::Context *context = gl::getNonLostContext(); |
| 8867 | |
| 8868 | if (context) |
| 8869 | { |
| 8870 | if (context->getClientVersion() < 3) |
| 8871 | { |
| 8872 | return gl::error(GL_INVALID_OPERATION); |
| 8873 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8874 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8875 | UNIMPLEMENTED(); |
| 8876 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8877 | } |
| 8878 | catch(std::bad_alloc&) |
| 8879 | { |
| 8880 | return gl::error(GL_OUT_OF_MEMORY); |
| 8881 | } |
| 8882 | } |
| 8883 | |
| 8884 | void __stdcall glBindVertexArray(GLuint array) |
| 8885 | { |
| 8886 | EVENT("(GLuint array = %u)", array); |
| 8887 | |
| 8888 | try |
| 8889 | { |
| 8890 | gl::Context *context = gl::getNonLostContext(); |
| 8891 | |
| 8892 | if (context) |
| 8893 | { |
| 8894 | if (context->getClientVersion() < 3) |
| 8895 | { |
| 8896 | return gl::error(GL_INVALID_OPERATION); |
| 8897 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8898 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8899 | UNIMPLEMENTED(); |
| 8900 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8901 | } |
| 8902 | catch(std::bad_alloc&) |
| 8903 | { |
| 8904 | return gl::error(GL_OUT_OF_MEMORY); |
| 8905 | } |
| 8906 | } |
| 8907 | |
| 8908 | void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) |
| 8909 | { |
| 8910 | EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays); |
| 8911 | |
| 8912 | try |
| 8913 | { |
| 8914 | gl::Context *context = gl::getNonLostContext(); |
| 8915 | |
| 8916 | if (context) |
| 8917 | { |
| 8918 | if (context->getClientVersion() < 3) |
| 8919 | { |
| 8920 | return gl::error(GL_INVALID_OPERATION); |
| 8921 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8922 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8923 | UNIMPLEMENTED(); |
| 8924 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8925 | } |
| 8926 | catch(std::bad_alloc&) |
| 8927 | { |
| 8928 | return gl::error(GL_OUT_OF_MEMORY); |
| 8929 | } |
| 8930 | } |
| 8931 | |
| 8932 | void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) |
| 8933 | { |
| 8934 | EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays); |
| 8935 | |
| 8936 | try |
| 8937 | { |
| 8938 | gl::Context *context = gl::getNonLostContext(); |
| 8939 | |
| 8940 | if (context) |
| 8941 | { |
| 8942 | if (context->getClientVersion() < 3) |
| 8943 | { |
| 8944 | return gl::error(GL_INVALID_OPERATION); |
| 8945 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8946 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8947 | UNIMPLEMENTED(); |
| 8948 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8949 | } |
| 8950 | catch(std::bad_alloc&) |
| 8951 | { |
| 8952 | return gl::error(GL_OUT_OF_MEMORY); |
| 8953 | } |
| 8954 | } |
| 8955 | |
| 8956 | GLboolean __stdcall glIsVertexArray(GLuint array) |
| 8957 | { |
| 8958 | EVENT("(GLuint array = %u)", array); |
| 8959 | |
| 8960 | try |
| 8961 | { |
| 8962 | gl::Context *context = gl::getNonLostContext(); |
| 8963 | |
| 8964 | if (context) |
| 8965 | { |
| 8966 | if (context->getClientVersion() < 3) |
| 8967 | { |
| 8968 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8969 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8970 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8971 | UNIMPLEMENTED(); |
| 8972 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8973 | } |
| 8974 | catch(std::bad_alloc&) |
| 8975 | { |
| 8976 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8977 | } |
| 8978 | |
| 8979 | return GL_FALSE; |
| 8980 | } |
| 8981 | |
| 8982 | void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data) |
| 8983 | { |
| 8984 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)", |
| 8985 | target, index, data); |
| 8986 | |
| 8987 | try |
| 8988 | { |
| 8989 | gl::Context *context = gl::getNonLostContext(); |
| 8990 | |
| 8991 | if (context) |
| 8992 | { |
| 8993 | if (context->getClientVersion() < 3) |
| 8994 | { |
| 8995 | return gl::error(GL_INVALID_OPERATION); |
| 8996 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8997 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8998 | UNIMPLEMENTED(); |
| 8999 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9000 | } |
| 9001 | catch(std::bad_alloc&) |
| 9002 | { |
| 9003 | return gl::error(GL_OUT_OF_MEMORY); |
| 9004 | } |
| 9005 | } |
| 9006 | |
| 9007 | void __stdcall glBeginTransformFeedback(GLenum primitiveMode) |
| 9008 | { |
| 9009 | EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode); |
| 9010 | |
| 9011 | try |
| 9012 | { |
| 9013 | gl::Context *context = gl::getNonLostContext(); |
| 9014 | |
| 9015 | if (context) |
| 9016 | { |
| 9017 | if (context->getClientVersion() < 3) |
| 9018 | { |
| 9019 | return gl::error(GL_INVALID_OPERATION); |
| 9020 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9021 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9022 | UNIMPLEMENTED(); |
| 9023 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9024 | } |
| 9025 | catch(std::bad_alloc&) |
| 9026 | { |
| 9027 | return gl::error(GL_OUT_OF_MEMORY); |
| 9028 | } |
| 9029 | } |
| 9030 | |
| 9031 | void __stdcall glEndTransformFeedback(void) |
| 9032 | { |
| 9033 | EVENT("(void)"); |
| 9034 | |
| 9035 | try |
| 9036 | { |
| 9037 | gl::Context *context = gl::getNonLostContext(); |
| 9038 | |
| 9039 | if (context) |
| 9040 | { |
| 9041 | if (context->getClientVersion() < 3) |
| 9042 | { |
| 9043 | return gl::error(GL_INVALID_OPERATION); |
| 9044 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9045 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9046 | UNIMPLEMENTED(); |
| 9047 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9048 | } |
| 9049 | catch(std::bad_alloc&) |
| 9050 | { |
| 9051 | return gl::error(GL_OUT_OF_MEMORY); |
| 9052 | } |
| 9053 | } |
| 9054 | |
| 9055 | void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
| 9056 | { |
| 9057 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)", |
| 9058 | target, index, buffer, offset, size); |
| 9059 | |
| 9060 | try |
| 9061 | { |
| 9062 | gl::Context *context = gl::getNonLostContext(); |
| 9063 | |
| 9064 | if (context) |
| 9065 | { |
| 9066 | if (context->getClientVersion() < 3) |
| 9067 | { |
| 9068 | return gl::error(GL_INVALID_OPERATION); |
| 9069 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9070 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9071 | switch (target) |
| 9072 | { |
| 9073 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9074 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9075 | { |
| 9076 | return gl::error(GL_INVALID_VALUE); |
| 9077 | } |
| 9078 | break; |
| 9079 | |
| 9080 | case GL_UNIFORM_BUFFER: |
| 9081 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 9082 | { |
| 9083 | return gl::error(GL_INVALID_VALUE); |
| 9084 | } |
| 9085 | break; |
| 9086 | |
| 9087 | default: |
| 9088 | return gl::error(GL_INVALID_ENUM); |
| 9089 | } |
| 9090 | |
shannonwoods@chromium.org | e6e0079 | 2013-05-30 00:06:07 +0000 | [diff] [blame] | 9091 | if (buffer != 0 && size <= 0) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9092 | { |
| 9093 | return gl::error(GL_INVALID_VALUE); |
| 9094 | } |
| 9095 | |
| 9096 | switch (target) |
| 9097 | { |
| 9098 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | a26aeaf | 2013-05-30 00:06:13 +0000 | [diff] [blame] | 9099 | |
| 9100 | // size and offset must be a multiple of 4 |
| 9101 | if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) |
| 9102 | { |
| 9103 | return gl::error(GL_INVALID_VALUE); |
| 9104 | } |
| 9105 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9106 | context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 9107 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9108 | break; |
| 9109 | |
| 9110 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 97c3d50 | 2013-05-30 00:04:34 +0000 | [diff] [blame] | 9111 | |
| 9112 | // it is an error to bind an offset not a multiple of the alignment |
| 9113 | if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0) |
| 9114 | { |
| 9115 | return gl::error(GL_INVALID_VALUE); |
| 9116 | } |
| 9117 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9118 | context->bindIndexedUniformBuffer(buffer, index, offset, size); |
| 9119 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9120 | break; |
| 9121 | |
| 9122 | default: |
| 9123 | UNREACHABLE(); |
| 9124 | } |
| 9125 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9126 | } |
| 9127 | catch(std::bad_alloc&) |
| 9128 | { |
| 9129 | return gl::error(GL_OUT_OF_MEMORY); |
| 9130 | } |
| 9131 | } |
| 9132 | |
| 9133 | void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 9134 | { |
| 9135 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)", |
| 9136 | target, index, buffer); |
| 9137 | |
| 9138 | try |
| 9139 | { |
| 9140 | gl::Context *context = gl::getNonLostContext(); |
| 9141 | |
| 9142 | if (context) |
| 9143 | { |
| 9144 | if (context->getClientVersion() < 3) |
| 9145 | { |
| 9146 | return gl::error(GL_INVALID_OPERATION); |
| 9147 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9148 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9149 | switch (target) |
| 9150 | { |
| 9151 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9152 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9153 | { |
| 9154 | return gl::error(GL_INVALID_VALUE); |
| 9155 | } |
| 9156 | break; |
| 9157 | |
| 9158 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9159 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9160 | { |
| 9161 | return gl::error(GL_INVALID_VALUE); |
| 9162 | } |
| 9163 | break; |
| 9164 | |
| 9165 | default: |
| 9166 | return gl::error(GL_INVALID_ENUM); |
| 9167 | } |
| 9168 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9169 | switch (target) |
| 9170 | { |
| 9171 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9172 | context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9173 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9174 | break; |
| 9175 | |
| 9176 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9177 | context->bindIndexedUniformBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9178 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9179 | break; |
| 9180 | |
| 9181 | default: |
| 9182 | UNREACHABLE(); |
| 9183 | } |
| 9184 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9185 | } |
| 9186 | catch(std::bad_alloc&) |
| 9187 | { |
| 9188 | return gl::error(GL_OUT_OF_MEMORY); |
| 9189 | } |
| 9190 | } |
| 9191 | |
| 9192 | void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
| 9193 | { |
| 9194 | EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)", |
| 9195 | program, count, varyings, bufferMode); |
| 9196 | |
| 9197 | try |
| 9198 | { |
| 9199 | gl::Context *context = gl::getNonLostContext(); |
| 9200 | |
| 9201 | if (context) |
| 9202 | { |
| 9203 | if (context->getClientVersion() < 3) |
| 9204 | { |
| 9205 | return gl::error(GL_INVALID_OPERATION); |
| 9206 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9207 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9208 | UNIMPLEMENTED(); |
| 9209 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9210 | } |
| 9211 | catch(std::bad_alloc&) |
| 9212 | { |
| 9213 | return gl::error(GL_OUT_OF_MEMORY); |
| 9214 | } |
| 9215 | } |
| 9216 | |
| 9217 | void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
| 9218 | { |
| 9219 | EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, " |
| 9220 | "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
| 9221 | program, index, bufSize, length, size, type, name); |
| 9222 | |
| 9223 | try |
| 9224 | { |
| 9225 | gl::Context *context = gl::getNonLostContext(); |
| 9226 | |
| 9227 | if (context) |
| 9228 | { |
| 9229 | if (context->getClientVersion() < 3) |
| 9230 | { |
| 9231 | return gl::error(GL_INVALID_OPERATION); |
| 9232 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9233 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9234 | UNIMPLEMENTED(); |
| 9235 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9236 | } |
| 9237 | catch(std::bad_alloc&) |
| 9238 | { |
| 9239 | return gl::error(GL_OUT_OF_MEMORY); |
| 9240 | } |
| 9241 | } |
| 9242 | |
| 9243 | void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) |
| 9244 | { |
| 9245 | EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)", |
| 9246 | index, size, type, stride, pointer); |
| 9247 | |
| 9248 | try |
| 9249 | { |
| 9250 | gl::Context *context = gl::getNonLostContext(); |
| 9251 | |
| 9252 | if (context) |
| 9253 | { |
| 9254 | if (context->getClientVersion() < 3) |
| 9255 | { |
| 9256 | return gl::error(GL_INVALID_OPERATION); |
| 9257 | } |
| 9258 | } |
| 9259 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9260 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9261 | { |
| 9262 | return gl::error(GL_INVALID_VALUE); |
| 9263 | } |
| 9264 | |
| 9265 | if (size < 1 || size > 4) |
| 9266 | { |
| 9267 | return gl::error(GL_INVALID_VALUE); |
| 9268 | } |
| 9269 | |
| 9270 | switch (type) |
| 9271 | { |
| 9272 | case GL_BYTE: |
| 9273 | case GL_UNSIGNED_BYTE: |
| 9274 | case GL_SHORT: |
| 9275 | case GL_UNSIGNED_SHORT: |
| 9276 | case GL_INT: |
| 9277 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9278 | case GL_INT_2_10_10_10_REV: |
| 9279 | 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] | 9280 | break; |
| 9281 | default: |
| 9282 | return gl::error(GL_INVALID_ENUM); |
| 9283 | } |
| 9284 | |
| 9285 | if (stride < 0) |
| 9286 | { |
| 9287 | return gl::error(GL_INVALID_VALUE); |
| 9288 | } |
| 9289 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9290 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 9291 | { |
| 9292 | return gl::error(GL_INVALID_OPERATION); |
| 9293 | } |
| 9294 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9295 | if (context) |
| 9296 | { |
| 9297 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true, |
| 9298 | stride, pointer); |
| 9299 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9300 | } |
| 9301 | catch(std::bad_alloc&) |
| 9302 | { |
| 9303 | return gl::error(GL_OUT_OF_MEMORY); |
| 9304 | } |
| 9305 | } |
| 9306 | |
| 9307 | void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) |
| 9308 | { |
| 9309 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 9310 | index, pname, params); |
| 9311 | |
| 9312 | try |
| 9313 | { |
| 9314 | gl::Context *context = gl::getNonLostContext(); |
| 9315 | |
| 9316 | if (context) |
| 9317 | { |
| 9318 | if (context->getClientVersion() < 3) |
| 9319 | { |
| 9320 | return gl::error(GL_INVALID_OPERATION); |
| 9321 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9322 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9323 | UNIMPLEMENTED(); |
| 9324 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9325 | } |
| 9326 | catch(std::bad_alloc&) |
| 9327 | { |
| 9328 | return gl::error(GL_OUT_OF_MEMORY); |
| 9329 | } |
| 9330 | } |
| 9331 | |
| 9332 | void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) |
| 9333 | { |
| 9334 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)", |
| 9335 | index, pname, params); |
| 9336 | |
| 9337 | try |
| 9338 | { |
| 9339 | gl::Context *context = gl::getNonLostContext(); |
| 9340 | |
| 9341 | if (context) |
| 9342 | { |
| 9343 | if (context->getClientVersion() < 3) |
| 9344 | { |
| 9345 | return gl::error(GL_INVALID_OPERATION); |
| 9346 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9347 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9348 | UNIMPLEMENTED(); |
| 9349 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9350 | } |
| 9351 | catch(std::bad_alloc&) |
| 9352 | { |
| 9353 | return gl::error(GL_OUT_OF_MEMORY); |
| 9354 | } |
| 9355 | } |
| 9356 | |
| 9357 | void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 9358 | { |
| 9359 | EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)", |
| 9360 | index, x, y, z, w); |
| 9361 | |
| 9362 | try |
| 9363 | { |
| 9364 | gl::Context *context = gl::getNonLostContext(); |
| 9365 | |
| 9366 | if (context) |
| 9367 | { |
| 9368 | if (context->getClientVersion() < 3) |
| 9369 | { |
| 9370 | return gl::error(GL_INVALID_OPERATION); |
| 9371 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9372 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9373 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9374 | { |
| 9375 | return gl::error(GL_INVALID_VALUE); |
| 9376 | } |
| 9377 | |
| 9378 | GLint vals[4] = { x, y, z, w }; |
| 9379 | context->setVertexAttribi(index, vals); |
| 9380 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9381 | } |
| 9382 | catch(std::bad_alloc&) |
| 9383 | { |
| 9384 | return gl::error(GL_OUT_OF_MEMORY); |
| 9385 | } |
| 9386 | } |
| 9387 | |
| 9388 | void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 9389 | { |
| 9390 | EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)", |
| 9391 | index, x, y, z, w); |
| 9392 | |
| 9393 | try |
| 9394 | { |
| 9395 | gl::Context *context = gl::getNonLostContext(); |
| 9396 | |
| 9397 | if (context) |
| 9398 | { |
| 9399 | if (context->getClientVersion() < 3) |
| 9400 | { |
| 9401 | return gl::error(GL_INVALID_OPERATION); |
| 9402 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9403 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9404 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9405 | { |
| 9406 | return gl::error(GL_INVALID_VALUE); |
| 9407 | } |
| 9408 | |
| 9409 | GLuint vals[4] = { x, y, z, w }; |
| 9410 | context->setVertexAttribu(index, vals); |
| 9411 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9412 | } |
| 9413 | catch(std::bad_alloc&) |
| 9414 | { |
| 9415 | return gl::error(GL_OUT_OF_MEMORY); |
| 9416 | } |
| 9417 | } |
| 9418 | |
| 9419 | void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) |
| 9420 | { |
| 9421 | EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v); |
| 9422 | |
| 9423 | try |
| 9424 | { |
| 9425 | gl::Context *context = gl::getNonLostContext(); |
| 9426 | |
| 9427 | if (context) |
| 9428 | { |
| 9429 | if (context->getClientVersion() < 3) |
| 9430 | { |
| 9431 | return gl::error(GL_INVALID_OPERATION); |
| 9432 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9433 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9434 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9435 | { |
| 9436 | return gl::error(GL_INVALID_VALUE); |
| 9437 | } |
| 9438 | |
| 9439 | context->setVertexAttribi(index, v); |
| 9440 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9441 | } |
| 9442 | catch(std::bad_alloc&) |
| 9443 | { |
| 9444 | return gl::error(GL_OUT_OF_MEMORY); |
| 9445 | } |
| 9446 | } |
| 9447 | |
| 9448 | void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v) |
| 9449 | { |
| 9450 | EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v); |
| 9451 | |
| 9452 | try |
| 9453 | { |
| 9454 | gl::Context *context = gl::getNonLostContext(); |
| 9455 | |
| 9456 | if (context) |
| 9457 | { |
| 9458 | if (context->getClientVersion() < 3) |
| 9459 | { |
| 9460 | return gl::error(GL_INVALID_OPERATION); |
| 9461 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9462 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9463 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9464 | { |
| 9465 | return gl::error(GL_INVALID_VALUE); |
| 9466 | } |
| 9467 | |
| 9468 | context->setVertexAttribu(index, v); |
| 9469 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9470 | } |
| 9471 | catch(std::bad_alloc&) |
| 9472 | { |
| 9473 | return gl::error(GL_OUT_OF_MEMORY); |
| 9474 | } |
| 9475 | } |
| 9476 | |
| 9477 | void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) |
| 9478 | { |
| 9479 | EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)", |
| 9480 | program, location, params); |
| 9481 | |
| 9482 | try |
| 9483 | { |
| 9484 | gl::Context *context = gl::getNonLostContext(); |
| 9485 | |
| 9486 | if (context) |
| 9487 | { |
| 9488 | if (context->getClientVersion() < 3) |
| 9489 | { |
| 9490 | return gl::error(GL_INVALID_OPERATION); |
| 9491 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9492 | |
shannon.woods%transgaming.com@gtempaccount.com | e229012 | 2013-04-13 03:41:07 +0000 | [diff] [blame] | 9493 | if (program == 0) |
| 9494 | { |
| 9495 | return gl::error(GL_INVALID_VALUE); |
| 9496 | } |
| 9497 | |
| 9498 | gl::Program *programObject = context->getProgram(program); |
| 9499 | |
| 9500 | if (!programObject || !programObject->isLinked()) |
| 9501 | { |
| 9502 | return gl::error(GL_INVALID_OPERATION); |
| 9503 | } |
| 9504 | |
| 9505 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9506 | if (!programBinary) |
| 9507 | { |
| 9508 | return gl::error(GL_INVALID_OPERATION); |
| 9509 | } |
| 9510 | |
| 9511 | if (!programBinary->getUniformuiv(location, NULL, params)) |
| 9512 | { |
| 9513 | return gl::error(GL_INVALID_OPERATION); |
| 9514 | } |
| 9515 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9516 | } |
| 9517 | catch(std::bad_alloc&) |
| 9518 | { |
| 9519 | return gl::error(GL_OUT_OF_MEMORY); |
| 9520 | } |
| 9521 | } |
| 9522 | |
| 9523 | GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) |
| 9524 | { |
| 9525 | EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)", |
| 9526 | program, name); |
| 9527 | |
| 9528 | try |
| 9529 | { |
| 9530 | gl::Context *context = gl::getNonLostContext(); |
| 9531 | |
| 9532 | if (context) |
| 9533 | { |
| 9534 | if (context->getClientVersion() < 3) |
| 9535 | { |
| 9536 | return gl::error(GL_INVALID_OPERATION, 0); |
| 9537 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9538 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9539 | UNIMPLEMENTED(); |
| 9540 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9541 | } |
| 9542 | catch(std::bad_alloc&) |
| 9543 | { |
| 9544 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 9545 | } |
| 9546 | |
| 9547 | return 0; |
| 9548 | } |
| 9549 | |
| 9550 | void __stdcall glUniform1ui(GLint location, GLuint v0) |
| 9551 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9552 | glUniform1uiv(location, 1, &v0); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9553 | } |
| 9554 | |
| 9555 | void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1) |
| 9556 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9557 | const GLuint xy[] = { v0, v1 }; |
| 9558 | glUniform2uiv(location, 1, xy); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9559 | } |
| 9560 | |
| 9561 | void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 9562 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9563 | const GLuint xyz[] = { v0, v1, v2 }; |
| 9564 | glUniform3uiv(location, 1, xyz); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9565 | } |
| 9566 | |
| 9567 | void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 9568 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9569 | const GLuint xyzw[] = { v0, v1, v2, v3 }; |
| 9570 | glUniform4uiv(location, 1, xyzw); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9571 | } |
| 9572 | |
| 9573 | void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) |
| 9574 | { |
| 9575 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9576 | location, count, value); |
| 9577 | |
| 9578 | try |
| 9579 | { |
| 9580 | gl::Context *context = gl::getNonLostContext(); |
| 9581 | |
| 9582 | if (context) |
| 9583 | { |
| 9584 | if (context->getClientVersion() < 3) |
| 9585 | { |
| 9586 | return gl::error(GL_INVALID_OPERATION); |
| 9587 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9588 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9589 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9590 | if (!programBinary) |
| 9591 | { |
| 9592 | return gl::error(GL_INVALID_OPERATION); |
| 9593 | } |
| 9594 | |
| 9595 | if (!programBinary->setUniform1uiv(location, count, value)) |
| 9596 | { |
| 9597 | return gl::error(GL_INVALID_OPERATION); |
| 9598 | } |
| 9599 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9600 | } |
| 9601 | catch(std::bad_alloc&) |
| 9602 | { |
| 9603 | return gl::error(GL_OUT_OF_MEMORY); |
| 9604 | } |
| 9605 | } |
| 9606 | |
| 9607 | void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) |
| 9608 | { |
| 9609 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9610 | location, count, value); |
| 9611 | |
| 9612 | try |
| 9613 | { |
| 9614 | gl::Context *context = gl::getNonLostContext(); |
| 9615 | |
| 9616 | if (context) |
| 9617 | { |
| 9618 | if (context->getClientVersion() < 3) |
| 9619 | { |
| 9620 | return gl::error(GL_INVALID_OPERATION); |
| 9621 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9622 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9623 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9624 | if (!programBinary) |
| 9625 | { |
| 9626 | return gl::error(GL_INVALID_OPERATION); |
| 9627 | } |
| 9628 | |
| 9629 | if (!programBinary->setUniform2uiv(location, count, value)) |
| 9630 | { |
| 9631 | return gl::error(GL_INVALID_OPERATION); |
| 9632 | } |
| 9633 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9634 | } |
| 9635 | catch(std::bad_alloc&) |
| 9636 | { |
| 9637 | return gl::error(GL_OUT_OF_MEMORY); |
| 9638 | } |
| 9639 | } |
| 9640 | |
| 9641 | void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) |
| 9642 | { |
| 9643 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)", |
| 9644 | location, count, value); |
| 9645 | |
| 9646 | try |
| 9647 | { |
| 9648 | gl::Context *context = gl::getNonLostContext(); |
| 9649 | |
| 9650 | if (context) |
| 9651 | { |
| 9652 | if (context->getClientVersion() < 3) |
| 9653 | { |
| 9654 | return gl::error(GL_INVALID_OPERATION); |
| 9655 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9656 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9657 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9658 | if (!programBinary) |
| 9659 | { |
| 9660 | return gl::error(GL_INVALID_OPERATION); |
| 9661 | } |
| 9662 | |
| 9663 | if (!programBinary->setUniform3uiv(location, count, value)) |
| 9664 | { |
| 9665 | return gl::error(GL_INVALID_OPERATION); |
| 9666 | } |
| 9667 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9668 | } |
| 9669 | catch(std::bad_alloc&) |
| 9670 | { |
| 9671 | return gl::error(GL_OUT_OF_MEMORY); |
| 9672 | } |
| 9673 | } |
| 9674 | |
| 9675 | void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) |
| 9676 | { |
| 9677 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9678 | location, count, value); |
| 9679 | |
| 9680 | try |
| 9681 | { |
| 9682 | gl::Context *context = gl::getNonLostContext(); |
| 9683 | |
| 9684 | if (context) |
| 9685 | { |
| 9686 | if (context->getClientVersion() < 3) |
| 9687 | { |
| 9688 | return gl::error(GL_INVALID_OPERATION); |
| 9689 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9690 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9691 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9692 | if (!programBinary) |
| 9693 | { |
| 9694 | return gl::error(GL_INVALID_OPERATION); |
| 9695 | } |
| 9696 | |
| 9697 | if (!programBinary->setUniform4uiv(location, count, value)) |
| 9698 | { |
| 9699 | return gl::error(GL_INVALID_OPERATION); |
| 9700 | } |
| 9701 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9702 | } |
| 9703 | catch(std::bad_alloc&) |
| 9704 | { |
| 9705 | return gl::error(GL_OUT_OF_MEMORY); |
| 9706 | } |
| 9707 | } |
| 9708 | |
| 9709 | void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) |
| 9710 | { |
| 9711 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)", |
| 9712 | buffer, drawbuffer, value); |
| 9713 | |
| 9714 | try |
| 9715 | { |
| 9716 | gl::Context *context = gl::getNonLostContext(); |
| 9717 | |
| 9718 | if (context) |
| 9719 | { |
| 9720 | if (context->getClientVersion() < 3) |
| 9721 | { |
| 9722 | return gl::error(GL_INVALID_OPERATION); |
| 9723 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9724 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9725 | UNIMPLEMENTED(); |
| 9726 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9727 | } |
| 9728 | catch(std::bad_alloc&) |
| 9729 | { |
| 9730 | return gl::error(GL_OUT_OF_MEMORY); |
| 9731 | } |
| 9732 | } |
| 9733 | |
| 9734 | void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) |
| 9735 | { |
| 9736 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)", |
| 9737 | buffer, drawbuffer, value); |
| 9738 | |
| 9739 | try |
| 9740 | { |
| 9741 | gl::Context *context = gl::getNonLostContext(); |
| 9742 | |
| 9743 | if (context) |
| 9744 | { |
| 9745 | if (context->getClientVersion() < 3) |
| 9746 | { |
| 9747 | return gl::error(GL_INVALID_OPERATION); |
| 9748 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9749 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9750 | UNIMPLEMENTED(); |
| 9751 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9752 | } |
| 9753 | catch(std::bad_alloc&) |
| 9754 | { |
| 9755 | return gl::error(GL_OUT_OF_MEMORY); |
| 9756 | } |
| 9757 | } |
| 9758 | |
| 9759 | void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) |
| 9760 | { |
| 9761 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)", |
| 9762 | buffer, drawbuffer, value); |
| 9763 | |
| 9764 | try |
| 9765 | { |
| 9766 | gl::Context *context = gl::getNonLostContext(); |
| 9767 | |
| 9768 | if (context) |
| 9769 | { |
| 9770 | if (context->getClientVersion() < 3) |
| 9771 | { |
| 9772 | return gl::error(GL_INVALID_OPERATION); |
| 9773 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9774 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9775 | UNIMPLEMENTED(); |
| 9776 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9777 | } |
| 9778 | catch(std::bad_alloc&) |
| 9779 | { |
| 9780 | return gl::error(GL_OUT_OF_MEMORY); |
| 9781 | } |
| 9782 | } |
| 9783 | |
| 9784 | void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 9785 | { |
| 9786 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)", |
| 9787 | buffer, drawbuffer, depth, stencil); |
| 9788 | |
| 9789 | try |
| 9790 | { |
| 9791 | gl::Context *context = gl::getNonLostContext(); |
| 9792 | |
| 9793 | if (context) |
| 9794 | { |
| 9795 | if (context->getClientVersion() < 3) |
| 9796 | { |
| 9797 | return gl::error(GL_INVALID_OPERATION); |
| 9798 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9799 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9800 | UNIMPLEMENTED(); |
| 9801 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9802 | } |
| 9803 | catch(std::bad_alloc&) |
| 9804 | { |
| 9805 | return gl::error(GL_OUT_OF_MEMORY); |
| 9806 | } |
| 9807 | } |
| 9808 | |
| 9809 | const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) |
| 9810 | { |
| 9811 | EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index); |
| 9812 | |
| 9813 | try |
| 9814 | { |
| 9815 | gl::Context *context = gl::getNonLostContext(); |
| 9816 | |
| 9817 | if (context) |
| 9818 | { |
| 9819 | if (context->getClientVersion() < 3) |
| 9820 | { |
| 9821 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL)); |
| 9822 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9823 | |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 9824 | if (name != GL_EXTENSIONS) |
| 9825 | { |
| 9826 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL)); |
| 9827 | } |
| 9828 | |
| 9829 | if (index >= context->getNumExtensions()) |
| 9830 | { |
| 9831 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL)); |
| 9832 | } |
| 9833 | |
| 9834 | return reinterpret_cast<const GLubyte*>(context->getExtensionString(index)); |
| 9835 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9836 | } |
| 9837 | catch(std::bad_alloc&) |
| 9838 | { |
| 9839 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL)); |
| 9840 | } |
| 9841 | |
| 9842 | return NULL; |
| 9843 | } |
| 9844 | |
| 9845 | void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 9846 | { |
| 9847 | EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)", |
| 9848 | readTarget, writeTarget, readOffset, writeOffset, size); |
| 9849 | |
| 9850 | try |
| 9851 | { |
| 9852 | gl::Context *context = gl::getNonLostContext(); |
| 9853 | |
| 9854 | if (context) |
| 9855 | { |
| 9856 | if (context->getClientVersion() < 3) |
| 9857 | { |
| 9858 | return gl::error(GL_INVALID_OPERATION); |
| 9859 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9860 | |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 9861 | gl::Buffer *readBuffer = NULL; |
| 9862 | switch (readTarget) |
| 9863 | { |
| 9864 | case GL_ARRAY_BUFFER: |
| 9865 | readBuffer = context->getArrayBuffer(); |
| 9866 | break; |
| 9867 | case GL_COPY_READ_BUFFER: |
| 9868 | readBuffer = context->getCopyReadBuffer(); |
| 9869 | break; |
| 9870 | case GL_COPY_WRITE_BUFFER: |
| 9871 | readBuffer = context->getCopyWriteBuffer(); |
| 9872 | break; |
| 9873 | case GL_ELEMENT_ARRAY_BUFFER: |
| 9874 | readBuffer = context->getElementArrayBuffer(); |
| 9875 | break; |
| 9876 | case GL_PIXEL_PACK_BUFFER: |
| 9877 | readBuffer = context->getPixelPackBuffer(); |
| 9878 | break; |
| 9879 | case GL_PIXEL_UNPACK_BUFFER: |
| 9880 | readBuffer = context->getPixelUnpackBuffer(); |
| 9881 | break; |
| 9882 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 9883 | readBuffer = context->getGenericTransformFeedbackBuffer(); |
| 9884 | break; |
| 9885 | case GL_UNIFORM_BUFFER: |
| 9886 | readBuffer = context->getGenericUniformBuffer(); |
| 9887 | break; |
| 9888 | default: |
| 9889 | return gl::error(GL_INVALID_ENUM); |
| 9890 | } |
| 9891 | |
| 9892 | gl::Buffer *writeBuffer = NULL; |
| 9893 | switch (writeTarget) |
| 9894 | { |
| 9895 | case GL_ARRAY_BUFFER: |
| 9896 | writeBuffer = context->getArrayBuffer(); |
| 9897 | break; |
| 9898 | case GL_COPY_READ_BUFFER: |
| 9899 | writeBuffer = context->getCopyReadBuffer(); |
| 9900 | break; |
| 9901 | case GL_COPY_WRITE_BUFFER: |
| 9902 | writeBuffer = context->getCopyWriteBuffer(); |
| 9903 | break; |
| 9904 | case GL_ELEMENT_ARRAY_BUFFER: |
| 9905 | writeBuffer = context->getElementArrayBuffer(); |
| 9906 | break; |
| 9907 | case GL_PIXEL_PACK_BUFFER: |
| 9908 | writeBuffer = context->getPixelPackBuffer(); |
| 9909 | break; |
| 9910 | case GL_PIXEL_UNPACK_BUFFER: |
| 9911 | writeBuffer = context->getPixelUnpackBuffer(); |
| 9912 | break; |
| 9913 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 9914 | writeBuffer = context->getGenericTransformFeedbackBuffer(); |
| 9915 | break; |
| 9916 | case GL_UNIFORM_BUFFER: |
| 9917 | writeBuffer = context->getGenericUniformBuffer(); |
| 9918 | break; |
| 9919 | default: |
| 9920 | return gl::error(GL_INVALID_ENUM); |
| 9921 | } |
| 9922 | |
| 9923 | if (!readBuffer || !writeBuffer) |
| 9924 | { |
| 9925 | return gl::error(GL_INVALID_OPERATION); |
| 9926 | } |
| 9927 | |
| 9928 | if (readOffset < 0 || writeOffset < 0 || size < 0 || |
| 9929 | static_cast<unsigned int>(readOffset + size) > readBuffer->size() || |
| 9930 | static_cast<unsigned int>(writeOffset + size) > writeBuffer->size()) |
| 9931 | { |
| 9932 | return gl::error(GL_INVALID_VALUE); |
| 9933 | } |
| 9934 | |
| 9935 | if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size) |
| 9936 | { |
| 9937 | return gl::error(GL_INVALID_VALUE); |
| 9938 | } |
| 9939 | |
| 9940 | // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION) |
| 9941 | |
shannon.woods%transgaming.com@gtempaccount.com | c53376a | 2013-04-13 03:41:23 +0000 | [diff] [blame] | 9942 | // if size is zero, the copy is a successful no-op |
| 9943 | if (size > 0) |
| 9944 | { |
| 9945 | writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); |
| 9946 | } |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 9947 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9948 | } |
| 9949 | catch(std::bad_alloc&) |
| 9950 | { |
| 9951 | return gl::error(GL_OUT_OF_MEMORY); |
| 9952 | } |
| 9953 | } |
| 9954 | |
| 9955 | void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) |
| 9956 | { |
| 9957 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)", |
| 9958 | program, uniformCount, uniformNames, uniformIndices); |
| 9959 | |
| 9960 | try |
| 9961 | { |
| 9962 | gl::Context *context = gl::getNonLostContext(); |
| 9963 | |
| 9964 | if (context) |
| 9965 | { |
| 9966 | if (context->getClientVersion() < 3) |
| 9967 | { |
| 9968 | return gl::error(GL_INVALID_OPERATION); |
| 9969 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9970 | |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 9971 | if (uniformCount < 0) |
| 9972 | { |
| 9973 | return gl::error(GL_INVALID_VALUE); |
| 9974 | } |
| 9975 | |
| 9976 | gl::Program *programObject = context->getProgram(program); |
| 9977 | |
| 9978 | if (!programObject) |
| 9979 | { |
| 9980 | if (context->getShader(program)) |
| 9981 | { |
| 9982 | return gl::error(GL_INVALID_OPERATION); |
| 9983 | } |
| 9984 | else |
| 9985 | { |
| 9986 | return gl::error(GL_INVALID_VALUE); |
| 9987 | } |
| 9988 | } |
| 9989 | |
| 9990 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9991 | if (!programObject->isLinked() || !programBinary) |
| 9992 | { |
| 9993 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 9994 | { |
| 9995 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 9996 | } |
| 9997 | } |
| 9998 | else |
| 9999 | { |
| 10000 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10001 | { |
| 10002 | uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]); |
| 10003 | } |
| 10004 | } |
| 10005 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10006 | } |
| 10007 | catch(std::bad_alloc&) |
| 10008 | { |
| 10009 | return gl::error(GL_OUT_OF_MEMORY); |
| 10010 | } |
| 10011 | } |
| 10012 | |
| 10013 | void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) |
| 10014 | { |
| 10015 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10016 | program, uniformCount, uniformIndices, pname, params); |
| 10017 | |
| 10018 | try |
| 10019 | { |
| 10020 | gl::Context *context = gl::getNonLostContext(); |
| 10021 | |
| 10022 | if (context) |
| 10023 | { |
| 10024 | if (context->getClientVersion() < 3) |
| 10025 | { |
| 10026 | return gl::error(GL_INVALID_OPERATION); |
| 10027 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10028 | |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 10029 | if (uniformCount < 0) |
| 10030 | { |
| 10031 | return gl::error(GL_INVALID_VALUE); |
| 10032 | } |
| 10033 | |
| 10034 | gl::Program *programObject = context->getProgram(program); |
| 10035 | |
| 10036 | if (!programObject) |
| 10037 | { |
| 10038 | if (context->getShader(program)) |
| 10039 | { |
| 10040 | return gl::error(GL_INVALID_OPERATION); |
| 10041 | } |
| 10042 | else |
| 10043 | { |
| 10044 | return gl::error(GL_INVALID_VALUE); |
| 10045 | } |
| 10046 | } |
| 10047 | |
| 10048 | switch (pname) |
| 10049 | { |
| 10050 | case GL_UNIFORM_TYPE: |
| 10051 | case GL_UNIFORM_SIZE: |
| 10052 | case GL_UNIFORM_NAME_LENGTH: |
| 10053 | case GL_UNIFORM_BLOCK_INDEX: |
| 10054 | case GL_UNIFORM_OFFSET: |
| 10055 | case GL_UNIFORM_ARRAY_STRIDE: |
| 10056 | case GL_UNIFORM_MATRIX_STRIDE: |
| 10057 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 10058 | break; |
| 10059 | default: |
| 10060 | return gl::error(GL_INVALID_ENUM); |
| 10061 | } |
| 10062 | |
| 10063 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10064 | |
| 10065 | if (!programBinary && uniformCount > 0) |
| 10066 | { |
| 10067 | return gl::error(GL_INVALID_VALUE); |
| 10068 | } |
| 10069 | |
| 10070 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10071 | { |
| 10072 | const GLuint index = uniformIndices[uniformId]; |
| 10073 | |
| 10074 | if (index >= (GLuint)programBinary->getActiveUniformCount()) |
| 10075 | { |
| 10076 | return gl::error(GL_INVALID_VALUE); |
| 10077 | } |
| 10078 | } |
| 10079 | |
| 10080 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10081 | { |
| 10082 | const GLuint index = uniformIndices[uniformId]; |
| 10083 | params[uniformId] = programBinary->getActiveUniformi(index, pname); |
| 10084 | } |
| 10085 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10086 | } |
| 10087 | catch(std::bad_alloc&) |
| 10088 | { |
| 10089 | return gl::error(GL_OUT_OF_MEMORY); |
| 10090 | } |
| 10091 | } |
| 10092 | |
| 10093 | GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) |
| 10094 | { |
| 10095 | EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName); |
| 10096 | |
| 10097 | try |
| 10098 | { |
| 10099 | gl::Context *context = gl::getNonLostContext(); |
| 10100 | |
| 10101 | if (context) |
| 10102 | { |
| 10103 | if (context->getClientVersion() < 3) |
| 10104 | { |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10105 | 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] | 10106 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10107 | |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10108 | gl::Program *programObject = context->getProgram(program); |
| 10109 | |
| 10110 | if (!programObject) |
| 10111 | { |
| 10112 | if (context->getShader(program)) |
| 10113 | { |
| 10114 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
| 10115 | } |
| 10116 | else |
| 10117 | { |
| 10118 | return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX); |
| 10119 | } |
| 10120 | } |
| 10121 | |
| 10122 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10123 | if (!programBinary) |
| 10124 | { |
| 10125 | return GL_INVALID_INDEX; |
| 10126 | } |
| 10127 | |
| 10128 | return programBinary->getUniformBlockIndex(uniformBlockName); |
| 10129 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10130 | } |
| 10131 | catch(std::bad_alloc&) |
| 10132 | { |
| 10133 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10134 | } |
| 10135 | |
| 10136 | return 0; |
| 10137 | } |
| 10138 | |
| 10139 | void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) |
| 10140 | { |
| 10141 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10142 | program, uniformBlockIndex, pname, params); |
| 10143 | |
| 10144 | try |
| 10145 | { |
| 10146 | gl::Context *context = gl::getNonLostContext(); |
| 10147 | |
| 10148 | if (context) |
| 10149 | { |
| 10150 | if (context->getClientVersion() < 3) |
| 10151 | { |
| 10152 | return gl::error(GL_INVALID_OPERATION); |
| 10153 | } |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10154 | gl::Program *programObject = context->getProgram(program); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10155 | |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10156 | if (!programObject) |
| 10157 | { |
| 10158 | if (context->getShader(program)) |
| 10159 | { |
| 10160 | return gl::error(GL_INVALID_OPERATION); |
| 10161 | } |
| 10162 | else |
| 10163 | { |
| 10164 | return gl::error(GL_INVALID_VALUE); |
| 10165 | } |
| 10166 | } |
| 10167 | |
| 10168 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10169 | |
| 10170 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10171 | { |
| 10172 | return gl::error(GL_INVALID_VALUE); |
| 10173 | } |
| 10174 | |
| 10175 | switch (pname) |
| 10176 | { |
| 10177 | case GL_UNIFORM_BLOCK_BINDING: |
| 10178 | *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); |
| 10179 | break; |
| 10180 | |
| 10181 | case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 10182 | case GL_UNIFORM_BLOCK_NAME_LENGTH: |
| 10183 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 10184 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| 10185 | case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
| 10186 | case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
| 10187 | programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params); |
| 10188 | break; |
| 10189 | |
| 10190 | default: |
| 10191 | return gl::error(GL_INVALID_ENUM); |
| 10192 | } |
| 10193 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10194 | } |
| 10195 | catch(std::bad_alloc&) |
| 10196 | { |
| 10197 | return gl::error(GL_OUT_OF_MEMORY); |
| 10198 | } |
| 10199 | } |
| 10200 | |
| 10201 | void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) |
| 10202 | { |
| 10203 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)", |
| 10204 | program, uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10205 | |
| 10206 | try |
| 10207 | { |
| 10208 | gl::Context *context = gl::getNonLostContext(); |
| 10209 | |
| 10210 | if (context) |
| 10211 | { |
| 10212 | if (context->getClientVersion() < 3) |
| 10213 | { |
| 10214 | return gl::error(GL_INVALID_OPERATION); |
| 10215 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10216 | |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 10217 | gl::Program *programObject = context->getProgram(program); |
| 10218 | |
| 10219 | if (!programObject) |
| 10220 | { |
| 10221 | if (context->getShader(program)) |
| 10222 | { |
| 10223 | return gl::error(GL_INVALID_OPERATION); |
| 10224 | } |
| 10225 | else |
| 10226 | { |
| 10227 | return gl::error(GL_INVALID_VALUE); |
| 10228 | } |
| 10229 | } |
| 10230 | |
| 10231 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10232 | |
| 10233 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10234 | { |
| 10235 | return gl::error(GL_INVALID_VALUE); |
| 10236 | } |
| 10237 | |
| 10238 | programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10239 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10240 | } |
| 10241 | catch(std::bad_alloc&) |
| 10242 | { |
| 10243 | return gl::error(GL_OUT_OF_MEMORY); |
| 10244 | } |
| 10245 | } |
| 10246 | |
| 10247 | void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) |
| 10248 | { |
| 10249 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)", |
| 10250 | program, uniformBlockIndex, uniformBlockBinding); |
| 10251 | |
| 10252 | try |
| 10253 | { |
| 10254 | gl::Context *context = gl::getNonLostContext(); |
| 10255 | |
| 10256 | if (context) |
| 10257 | { |
| 10258 | if (context->getClientVersion() < 3) |
| 10259 | { |
| 10260 | return gl::error(GL_INVALID_OPERATION); |
| 10261 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10262 | |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 10263 | if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings()) |
| 10264 | { |
| 10265 | return gl::error(GL_INVALID_VALUE); |
| 10266 | } |
| 10267 | |
| 10268 | gl::Program *programObject = context->getProgram(program); |
| 10269 | |
| 10270 | if (!programObject) |
| 10271 | { |
| 10272 | if (context->getShader(program)) |
| 10273 | { |
| 10274 | return gl::error(GL_INVALID_OPERATION); |
| 10275 | } |
| 10276 | else |
| 10277 | { |
| 10278 | return gl::error(GL_INVALID_VALUE); |
| 10279 | } |
| 10280 | } |
| 10281 | |
| 10282 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10283 | |
| 10284 | // if never linked, there won't be any uniform blocks |
| 10285 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10286 | { |
| 10287 | return gl::error(GL_INVALID_VALUE); |
| 10288 | } |
| 10289 | |
| 10290 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
| 10291 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10292 | } |
| 10293 | catch(std::bad_alloc&) |
| 10294 | { |
| 10295 | return gl::error(GL_OUT_OF_MEMORY); |
| 10296 | } |
| 10297 | } |
| 10298 | |
| 10299 | void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 10300 | { |
| 10301 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)", |
| 10302 | mode, first, count, instanceCount); |
| 10303 | |
| 10304 | try |
| 10305 | { |
| 10306 | gl::Context *context = gl::getNonLostContext(); |
| 10307 | |
| 10308 | if (context) |
| 10309 | { |
| 10310 | if (context->getClientVersion() < 3) |
| 10311 | { |
| 10312 | return gl::error(GL_INVALID_OPERATION); |
| 10313 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10314 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10315 | UNIMPLEMENTED(); |
| 10316 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10317 | } |
| 10318 | catch(std::bad_alloc&) |
| 10319 | { |
| 10320 | return gl::error(GL_OUT_OF_MEMORY); |
| 10321 | } |
| 10322 | } |
| 10323 | |
| 10324 | void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) |
| 10325 | { |
| 10326 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)", |
| 10327 | mode, count, type, indices, instanceCount); |
| 10328 | |
| 10329 | try |
| 10330 | { |
| 10331 | gl::Context *context = gl::getNonLostContext(); |
| 10332 | |
| 10333 | if (context) |
| 10334 | { |
| 10335 | if (context->getClientVersion() < 3) |
| 10336 | { |
| 10337 | return gl::error(GL_INVALID_OPERATION); |
| 10338 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10339 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10340 | UNIMPLEMENTED(); |
| 10341 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10342 | } |
| 10343 | catch(std::bad_alloc&) |
| 10344 | { |
| 10345 | return gl::error(GL_OUT_OF_MEMORY); |
| 10346 | } |
| 10347 | } |
| 10348 | |
| 10349 | GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags) |
| 10350 | { |
| 10351 | EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags); |
| 10352 | |
| 10353 | try |
| 10354 | { |
| 10355 | gl::Context *context = gl::getNonLostContext(); |
| 10356 | |
| 10357 | if (context) |
| 10358 | { |
| 10359 | if (context->getClientVersion() < 3) |
| 10360 | { |
| 10361 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(NULL)); |
| 10362 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10363 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10364 | UNIMPLEMENTED(); |
| 10365 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10366 | } |
| 10367 | catch(std::bad_alloc&) |
| 10368 | { |
| 10369 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL)); |
| 10370 | } |
| 10371 | |
| 10372 | return NULL; |
| 10373 | } |
| 10374 | |
| 10375 | GLboolean __stdcall glIsSync(GLsync sync) |
| 10376 | { |
| 10377 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10378 | |
| 10379 | try |
| 10380 | { |
| 10381 | gl::Context *context = gl::getNonLostContext(); |
| 10382 | |
| 10383 | if (context) |
| 10384 | { |
| 10385 | if (context->getClientVersion() < 3) |
| 10386 | { |
| 10387 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10388 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10389 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10390 | UNIMPLEMENTED(); |
| 10391 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10392 | } |
| 10393 | catch(std::bad_alloc&) |
| 10394 | { |
| 10395 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10396 | } |
| 10397 | |
| 10398 | return GL_FALSE; |
| 10399 | } |
| 10400 | |
| 10401 | void __stdcall glDeleteSync(GLsync sync) |
| 10402 | { |
| 10403 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10404 | |
| 10405 | try |
| 10406 | { |
| 10407 | gl::Context *context = gl::getNonLostContext(); |
| 10408 | |
| 10409 | if (context) |
| 10410 | { |
| 10411 | if (context->getClientVersion() < 3) |
| 10412 | { |
| 10413 | return gl::error(GL_INVALID_OPERATION); |
| 10414 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10415 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10416 | UNIMPLEMENTED(); |
| 10417 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10418 | } |
| 10419 | catch(std::bad_alloc&) |
| 10420 | { |
| 10421 | return gl::error(GL_OUT_OF_MEMORY); |
| 10422 | } |
| 10423 | } |
| 10424 | |
| 10425 | GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10426 | { |
| 10427 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10428 | sync, flags, timeout); |
| 10429 | |
| 10430 | try |
| 10431 | { |
| 10432 | gl::Context *context = gl::getNonLostContext(); |
| 10433 | |
| 10434 | if (context) |
| 10435 | { |
| 10436 | if (context->getClientVersion() < 3) |
| 10437 | { |
| 10438 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10439 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10440 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10441 | UNIMPLEMENTED(); |
| 10442 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10443 | } |
| 10444 | catch(std::bad_alloc&) |
| 10445 | { |
| 10446 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10447 | } |
| 10448 | |
| 10449 | return GL_FALSE; |
| 10450 | } |
| 10451 | |
| 10452 | void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10453 | { |
| 10454 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10455 | sync, flags, timeout); |
| 10456 | |
| 10457 | try |
| 10458 | { |
| 10459 | gl::Context *context = gl::getNonLostContext(); |
| 10460 | |
| 10461 | if (context) |
| 10462 | { |
| 10463 | if (context->getClientVersion() < 3) |
| 10464 | { |
| 10465 | return gl::error(GL_INVALID_OPERATION); |
| 10466 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10467 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10468 | UNIMPLEMENTED(); |
| 10469 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10470 | } |
| 10471 | catch(std::bad_alloc&) |
| 10472 | { |
| 10473 | return gl::error(GL_OUT_OF_MEMORY); |
| 10474 | } |
| 10475 | } |
| 10476 | |
| 10477 | void __stdcall glGetInteger64v(GLenum pname, GLint64* params) |
| 10478 | { |
| 10479 | EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10480 | pname, params); |
| 10481 | |
| 10482 | try |
| 10483 | { |
| 10484 | gl::Context *context = gl::getNonLostContext(); |
| 10485 | |
| 10486 | if (context) |
| 10487 | { |
| 10488 | if (context->getClientVersion() < 3) |
| 10489 | { |
| 10490 | return gl::error(GL_INVALID_OPERATION); |
| 10491 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10492 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10493 | UNIMPLEMENTED(); |
| 10494 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10495 | } |
| 10496 | catch(std::bad_alloc&) |
| 10497 | { |
| 10498 | return gl::error(GL_OUT_OF_MEMORY); |
| 10499 | } |
| 10500 | } |
| 10501 | |
| 10502 | void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) |
| 10503 | { |
| 10504 | EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)", |
| 10505 | sync, pname, bufSize, length, values); |
| 10506 | |
| 10507 | try |
| 10508 | { |
| 10509 | gl::Context *context = gl::getNonLostContext(); |
| 10510 | |
| 10511 | if (context) |
| 10512 | { |
| 10513 | if (context->getClientVersion() < 3) |
| 10514 | { |
| 10515 | return gl::error(GL_INVALID_OPERATION); |
| 10516 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10517 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10518 | UNIMPLEMENTED(); |
| 10519 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10520 | } |
| 10521 | catch(std::bad_alloc&) |
| 10522 | { |
| 10523 | return gl::error(GL_OUT_OF_MEMORY); |
| 10524 | } |
| 10525 | } |
| 10526 | |
| 10527 | void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) |
| 10528 | { |
| 10529 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)", |
| 10530 | target, index, data); |
| 10531 | |
| 10532 | try |
| 10533 | { |
| 10534 | gl::Context *context = gl::getNonLostContext(); |
| 10535 | |
| 10536 | if (context) |
| 10537 | { |
| 10538 | if (context->getClientVersion() < 3) |
| 10539 | { |
| 10540 | return gl::error(GL_INVALID_OPERATION); |
| 10541 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10542 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10543 | UNIMPLEMENTED(); |
| 10544 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10545 | } |
| 10546 | catch(std::bad_alloc&) |
| 10547 | { |
| 10548 | return gl::error(GL_OUT_OF_MEMORY); |
| 10549 | } |
| 10550 | } |
| 10551 | |
| 10552 | void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) |
| 10553 | { |
| 10554 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10555 | target, pname, params); |
| 10556 | |
| 10557 | try |
| 10558 | { |
| 10559 | gl::Context *context = gl::getNonLostContext(); |
| 10560 | |
| 10561 | if (context) |
| 10562 | { |
| 10563 | if (context->getClientVersion() < 3) |
| 10564 | { |
| 10565 | return gl::error(GL_INVALID_OPERATION); |
| 10566 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10567 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10568 | UNIMPLEMENTED(); |
| 10569 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10570 | } |
| 10571 | catch(std::bad_alloc&) |
| 10572 | { |
| 10573 | return gl::error(GL_OUT_OF_MEMORY); |
| 10574 | } |
| 10575 | } |
| 10576 | |
| 10577 | void __stdcall glGenSamplers(GLsizei count, GLuint* samplers) |
| 10578 | { |
| 10579 | EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers); |
| 10580 | |
| 10581 | try |
| 10582 | { |
| 10583 | gl::Context *context = gl::getNonLostContext(); |
| 10584 | |
| 10585 | if (context) |
| 10586 | { |
| 10587 | if (context->getClientVersion() < 3) |
| 10588 | { |
| 10589 | return gl::error(GL_INVALID_OPERATION); |
| 10590 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10591 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10592 | UNIMPLEMENTED(); |
| 10593 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10594 | } |
| 10595 | catch(std::bad_alloc&) |
| 10596 | { |
| 10597 | return gl::error(GL_OUT_OF_MEMORY); |
| 10598 | } |
| 10599 | } |
| 10600 | |
| 10601 | void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers) |
| 10602 | { |
| 10603 | EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers); |
| 10604 | |
| 10605 | try |
| 10606 | { |
| 10607 | gl::Context *context = gl::getNonLostContext(); |
| 10608 | |
| 10609 | if (context) |
| 10610 | { |
| 10611 | if (context->getClientVersion() < 3) |
| 10612 | { |
| 10613 | return gl::error(GL_INVALID_OPERATION); |
| 10614 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10615 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10616 | UNIMPLEMENTED(); |
| 10617 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10618 | } |
| 10619 | catch(std::bad_alloc&) |
| 10620 | { |
| 10621 | return gl::error(GL_OUT_OF_MEMORY); |
| 10622 | } |
| 10623 | } |
| 10624 | |
| 10625 | GLboolean __stdcall glIsSampler(GLuint sampler) |
| 10626 | { |
| 10627 | EVENT("(GLuint sampler = %u)", sampler); |
| 10628 | |
| 10629 | try |
| 10630 | { |
| 10631 | gl::Context *context = gl::getNonLostContext(); |
| 10632 | |
| 10633 | if (context) |
| 10634 | { |
| 10635 | if (context->getClientVersion() < 3) |
| 10636 | { |
| 10637 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10638 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10639 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10640 | UNIMPLEMENTED(); |
| 10641 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10642 | } |
| 10643 | catch(std::bad_alloc&) |
| 10644 | { |
| 10645 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10646 | } |
| 10647 | |
| 10648 | return GL_FALSE; |
| 10649 | } |
| 10650 | |
| 10651 | void __stdcall glBindSampler(GLuint unit, GLuint sampler) |
| 10652 | { |
| 10653 | EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler); |
| 10654 | |
| 10655 | try |
| 10656 | { |
| 10657 | gl::Context *context = gl::getNonLostContext(); |
| 10658 | |
| 10659 | if (context) |
| 10660 | { |
| 10661 | if (context->getClientVersion() < 3) |
| 10662 | { |
| 10663 | return gl::error(GL_INVALID_OPERATION); |
| 10664 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10665 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10666 | UNIMPLEMENTED(); |
| 10667 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10668 | } |
| 10669 | catch(std::bad_alloc&) |
| 10670 | { |
| 10671 | return gl::error(GL_OUT_OF_MEMORY); |
| 10672 | } |
| 10673 | } |
| 10674 | |
| 10675 | void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 10676 | { |
| 10677 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param); |
| 10678 | |
| 10679 | try |
| 10680 | { |
| 10681 | gl::Context *context = gl::getNonLostContext(); |
| 10682 | |
| 10683 | if (context) |
| 10684 | { |
| 10685 | if (context->getClientVersion() < 3) |
| 10686 | { |
| 10687 | return gl::error(GL_INVALID_OPERATION); |
| 10688 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10689 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10690 | UNIMPLEMENTED(); |
| 10691 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10692 | } |
| 10693 | catch(std::bad_alloc&) |
| 10694 | { |
| 10695 | return gl::error(GL_OUT_OF_MEMORY); |
| 10696 | } |
| 10697 | } |
| 10698 | |
| 10699 | void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) |
| 10700 | { |
| 10701 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLint* param = 0x%0.8p)", |
| 10702 | sampler, pname, param); |
| 10703 | |
| 10704 | try |
| 10705 | { |
| 10706 | gl::Context *context = gl::getNonLostContext(); |
| 10707 | |
| 10708 | if (context) |
| 10709 | { |
| 10710 | if (context->getClientVersion() < 3) |
| 10711 | { |
| 10712 | return gl::error(GL_INVALID_OPERATION); |
| 10713 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10714 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10715 | UNIMPLEMENTED(); |
| 10716 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10717 | } |
| 10718 | catch(std::bad_alloc&) |
| 10719 | { |
| 10720 | return gl::error(GL_OUT_OF_MEMORY); |
| 10721 | } |
| 10722 | } |
| 10723 | |
| 10724 | void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 10725 | { |
| 10726 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param); |
| 10727 | |
| 10728 | try |
| 10729 | { |
| 10730 | gl::Context *context = gl::getNonLostContext(); |
| 10731 | |
| 10732 | if (context) |
| 10733 | { |
| 10734 | if (context->getClientVersion() < 3) |
| 10735 | { |
| 10736 | return gl::error(GL_INVALID_OPERATION); |
| 10737 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10738 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10739 | UNIMPLEMENTED(); |
| 10740 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10741 | } |
| 10742 | catch(std::bad_alloc&) |
| 10743 | { |
| 10744 | return gl::error(GL_OUT_OF_MEMORY); |
| 10745 | } |
| 10746 | } |
| 10747 | |
| 10748 | void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) |
| 10749 | { |
| 10750 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLfloat* param = 0x%0.8p)", sampler, pname, param); |
| 10751 | |
| 10752 | try |
| 10753 | { |
| 10754 | gl::Context *context = gl::getNonLostContext(); |
| 10755 | |
| 10756 | if (context) |
| 10757 | { |
| 10758 | if (context->getClientVersion() < 3) |
| 10759 | { |
| 10760 | return gl::error(GL_INVALID_OPERATION); |
| 10761 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10762 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10763 | UNIMPLEMENTED(); |
| 10764 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10765 | } |
| 10766 | catch(std::bad_alloc&) |
| 10767 | { |
| 10768 | return gl::error(GL_OUT_OF_MEMORY); |
| 10769 | } |
| 10770 | } |
| 10771 | |
| 10772 | void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) |
| 10773 | { |
| 10774 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); |
| 10775 | |
| 10776 | try |
| 10777 | { |
| 10778 | gl::Context *context = gl::getNonLostContext(); |
| 10779 | |
| 10780 | if (context) |
| 10781 | { |
| 10782 | if (context->getClientVersion() < 3) |
| 10783 | { |
| 10784 | return gl::error(GL_INVALID_OPERATION); |
| 10785 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10786 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10787 | UNIMPLEMENTED(); |
| 10788 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10789 | } |
| 10790 | catch(std::bad_alloc&) |
| 10791 | { |
| 10792 | return gl::error(GL_OUT_OF_MEMORY); |
| 10793 | } |
| 10794 | } |
| 10795 | |
| 10796 | void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) |
| 10797 | { |
| 10798 | EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params); |
| 10799 | |
| 10800 | try |
| 10801 | { |
| 10802 | gl::Context *context = gl::getNonLostContext(); |
| 10803 | |
| 10804 | if (context) |
| 10805 | { |
| 10806 | if (context->getClientVersion() < 3) |
| 10807 | { |
| 10808 | return gl::error(GL_INVALID_OPERATION); |
| 10809 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10810 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10811 | UNIMPLEMENTED(); |
| 10812 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10813 | } |
| 10814 | catch(std::bad_alloc&) |
| 10815 | { |
| 10816 | return gl::error(GL_OUT_OF_MEMORY); |
| 10817 | } |
| 10818 | } |
| 10819 | |
| 10820 | void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor) |
| 10821 | { |
| 10822 | EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor); |
| 10823 | |
| 10824 | try |
| 10825 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 10826 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 10827 | { |
| 10828 | return gl::error(GL_INVALID_VALUE); |
| 10829 | } |
| 10830 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10831 | gl::Context *context = gl::getNonLostContext(); |
| 10832 | |
| 10833 | if (context) |
| 10834 | { |
| 10835 | if (context->getClientVersion() < 3) |
| 10836 | { |
| 10837 | return gl::error(GL_INVALID_OPERATION); |
| 10838 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10839 | |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 10840 | context->setVertexAttribDivisor(index, divisor); |
| 10841 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10842 | } |
| 10843 | catch(std::bad_alloc&) |
| 10844 | { |
| 10845 | return gl::error(GL_OUT_OF_MEMORY); |
| 10846 | } |
| 10847 | } |
| 10848 | |
| 10849 | void __stdcall glBindTransformFeedback(GLenum target, GLuint id) |
| 10850 | { |
| 10851 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 10852 | |
| 10853 | try |
| 10854 | { |
| 10855 | gl::Context *context = gl::getNonLostContext(); |
| 10856 | |
| 10857 | if (context) |
| 10858 | { |
| 10859 | if (context->getClientVersion() < 3) |
| 10860 | { |
| 10861 | return gl::error(GL_INVALID_OPERATION); |
| 10862 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10863 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10864 | UNIMPLEMENTED(); |
| 10865 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10866 | } |
| 10867 | catch(std::bad_alloc&) |
| 10868 | { |
| 10869 | return gl::error(GL_OUT_OF_MEMORY); |
| 10870 | } |
| 10871 | } |
| 10872 | |
| 10873 | void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) |
| 10874 | { |
| 10875 | EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids); |
| 10876 | |
| 10877 | try |
| 10878 | { |
| 10879 | gl::Context *context = gl::getNonLostContext(); |
| 10880 | |
| 10881 | if (context) |
| 10882 | { |
| 10883 | if (context->getClientVersion() < 3) |
| 10884 | { |
| 10885 | return gl::error(GL_INVALID_OPERATION); |
| 10886 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10887 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10888 | UNIMPLEMENTED(); |
| 10889 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10890 | } |
| 10891 | catch(std::bad_alloc&) |
| 10892 | { |
| 10893 | return gl::error(GL_OUT_OF_MEMORY); |
| 10894 | } |
| 10895 | } |
| 10896 | |
| 10897 | void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids) |
| 10898 | { |
| 10899 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 10900 | |
| 10901 | try |
| 10902 | { |
| 10903 | gl::Context *context = gl::getNonLostContext(); |
| 10904 | |
| 10905 | if (context) |
| 10906 | { |
| 10907 | if (context->getClientVersion() < 3) |
| 10908 | { |
| 10909 | return gl::error(GL_INVALID_OPERATION); |
| 10910 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10911 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10912 | UNIMPLEMENTED(); |
| 10913 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10914 | } |
| 10915 | catch(std::bad_alloc&) |
| 10916 | { |
| 10917 | return gl::error(GL_OUT_OF_MEMORY); |
| 10918 | } |
| 10919 | } |
| 10920 | |
| 10921 | GLboolean __stdcall glIsTransformFeedback(GLuint id) |
| 10922 | { |
| 10923 | EVENT("(GLuint id = %u)", id); |
| 10924 | |
| 10925 | try |
| 10926 | { |
| 10927 | gl::Context *context = gl::getNonLostContext(); |
| 10928 | |
| 10929 | if (context) |
| 10930 | { |
| 10931 | if (context->getClientVersion() < 3) |
| 10932 | { |
| 10933 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10934 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10935 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10936 | UNIMPLEMENTED(); |
| 10937 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10938 | } |
| 10939 | catch(std::bad_alloc&) |
| 10940 | { |
| 10941 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10942 | } |
| 10943 | |
| 10944 | return GL_FALSE; |
| 10945 | } |
| 10946 | |
| 10947 | void __stdcall glPauseTransformFeedback(void) |
| 10948 | { |
| 10949 | EVENT("(void)"); |
| 10950 | |
| 10951 | try |
| 10952 | { |
| 10953 | gl::Context *context = gl::getNonLostContext(); |
| 10954 | |
| 10955 | if (context) |
| 10956 | { |
| 10957 | if (context->getClientVersion() < 3) |
| 10958 | { |
| 10959 | return gl::error(GL_INVALID_OPERATION); |
| 10960 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10961 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10962 | UNIMPLEMENTED(); |
| 10963 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10964 | } |
| 10965 | catch(std::bad_alloc&) |
| 10966 | { |
| 10967 | return gl::error(GL_OUT_OF_MEMORY); |
| 10968 | } |
| 10969 | } |
| 10970 | |
| 10971 | void __stdcall glResumeTransformFeedback(void) |
| 10972 | { |
| 10973 | EVENT("(void)"); |
| 10974 | |
| 10975 | try |
| 10976 | { |
| 10977 | gl::Context *context = gl::getNonLostContext(); |
| 10978 | |
| 10979 | if (context) |
| 10980 | { |
| 10981 | if (context->getClientVersion() < 3) |
| 10982 | { |
| 10983 | return gl::error(GL_INVALID_OPERATION); |
| 10984 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10985 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10986 | UNIMPLEMENTED(); |
| 10987 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10988 | } |
| 10989 | catch(std::bad_alloc&) |
| 10990 | { |
| 10991 | return gl::error(GL_OUT_OF_MEMORY); |
| 10992 | } |
| 10993 | } |
| 10994 | |
| 10995 | void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) |
| 10996 | { |
| 10997 | EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)", |
| 10998 | program, bufSize, length, binaryFormat, binary); |
| 10999 | |
| 11000 | try |
| 11001 | { |
| 11002 | gl::Context *context = gl::getNonLostContext(); |
| 11003 | |
| 11004 | if (context) |
| 11005 | { |
| 11006 | if (context->getClientVersion() < 3) |
| 11007 | { |
| 11008 | return gl::error(GL_INVALID_OPERATION); |
| 11009 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11010 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11011 | UNIMPLEMENTED(); |
| 11012 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11013 | } |
| 11014 | catch(std::bad_alloc&) |
| 11015 | { |
| 11016 | return gl::error(GL_OUT_OF_MEMORY); |
| 11017 | } |
| 11018 | } |
| 11019 | |
| 11020 | void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) |
| 11021 | { |
| 11022 | EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
| 11023 | program, binaryFormat, binary, length); |
| 11024 | |
| 11025 | try |
| 11026 | { |
| 11027 | gl::Context *context = gl::getNonLostContext(); |
| 11028 | |
| 11029 | if (context) |
| 11030 | { |
| 11031 | if (context->getClientVersion() < 3) |
| 11032 | { |
| 11033 | return gl::error(GL_INVALID_OPERATION); |
| 11034 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11035 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11036 | UNIMPLEMENTED(); |
| 11037 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11038 | } |
| 11039 | catch(std::bad_alloc&) |
| 11040 | { |
| 11041 | return gl::error(GL_OUT_OF_MEMORY); |
| 11042 | } |
| 11043 | } |
| 11044 | |
| 11045 | void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value) |
| 11046 | { |
| 11047 | EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)", |
| 11048 | program, pname, value); |
| 11049 | |
| 11050 | try |
| 11051 | { |
| 11052 | gl::Context *context = gl::getNonLostContext(); |
| 11053 | |
| 11054 | if (context) |
| 11055 | { |
| 11056 | if (context->getClientVersion() < 3) |
| 11057 | { |
| 11058 | return gl::error(GL_INVALID_OPERATION); |
| 11059 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11060 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11061 | UNIMPLEMENTED(); |
| 11062 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11063 | } |
| 11064 | catch(std::bad_alloc&) |
| 11065 | { |
| 11066 | return gl::error(GL_OUT_OF_MEMORY); |
| 11067 | } |
| 11068 | } |
| 11069 | |
| 11070 | void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) |
| 11071 | { |
| 11072 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)", |
| 11073 | target, numAttachments, attachments); |
| 11074 | |
| 11075 | try |
| 11076 | { |
| 11077 | gl::Context *context = gl::getNonLostContext(); |
| 11078 | |
| 11079 | if (context) |
| 11080 | { |
| 11081 | if (context->getClientVersion() < 3) |
| 11082 | { |
| 11083 | return gl::error(GL_INVALID_OPERATION); |
| 11084 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11085 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11086 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11087 | { |
| 11088 | return; |
| 11089 | } |
| 11090 | |
| 11091 | int maxDimension = context->getMaximumRenderbufferDimension(); |
| 11092 | context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension); |
| 11093 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11094 | } |
| 11095 | catch(std::bad_alloc&) |
| 11096 | { |
| 11097 | return gl::error(GL_OUT_OF_MEMORY); |
| 11098 | } |
| 11099 | } |
| 11100 | |
| 11101 | void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) |
| 11102 | { |
| 11103 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, " |
| 11104 | "GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 11105 | target, numAttachments, attachments, x, y, width, height); |
| 11106 | |
| 11107 | try |
| 11108 | { |
| 11109 | gl::Context *context = gl::getNonLostContext(); |
| 11110 | |
| 11111 | if (context) |
| 11112 | { |
| 11113 | if (context->getClientVersion() < 3) |
| 11114 | { |
| 11115 | return gl::error(GL_INVALID_OPERATION); |
| 11116 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11117 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11118 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11119 | { |
| 11120 | return; |
| 11121 | } |
| 11122 | |
| 11123 | context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height); |
| 11124 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11125 | } |
| 11126 | catch(std::bad_alloc&) |
| 11127 | { |
| 11128 | return gl::error(GL_OUT_OF_MEMORY); |
| 11129 | } |
| 11130 | } |
| 11131 | |
| 11132 | void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 11133 | { |
| 11134 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 11135 | target, levels, internalformat, width, height); |
| 11136 | |
| 11137 | try |
| 11138 | { |
| 11139 | gl::Context *context = gl::getNonLostContext(); |
| 11140 | |
| 11141 | if (context) |
| 11142 | { |
| 11143 | if (context->getClientVersion() < 3) |
| 11144 | { |
| 11145 | return gl::error(GL_INVALID_OPERATION); |
| 11146 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11147 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11148 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 11149 | { |
| 11150 | return; |
| 11151 | } |
| 11152 | |
| 11153 | switch (target) |
| 11154 | { |
| 11155 | case GL_TEXTURE_2D: |
| 11156 | { |
| 11157 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 11158 | texture2d->storage(levels, internalformat, width, height); |
| 11159 | } |
| 11160 | break; |
| 11161 | |
| 11162 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 11163 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 11164 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 11165 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 11166 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 11167 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 11168 | { |
| 11169 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 11170 | textureCube->storage(levels, internalformat, width); |
| 11171 | } |
| 11172 | break; |
| 11173 | |
| 11174 | default: |
| 11175 | return gl::error(GL_INVALID_ENUM); |
| 11176 | } |
| 11177 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11178 | } |
| 11179 | catch(std::bad_alloc&) |
| 11180 | { |
| 11181 | return gl::error(GL_OUT_OF_MEMORY); |
| 11182 | } |
| 11183 | } |
| 11184 | |
| 11185 | void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
| 11186 | { |
| 11187 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 11188 | "GLsizei height = %d, GLsizei depth = %d)", |
| 11189 | target, levels, internalformat, width, height, depth); |
| 11190 | |
| 11191 | try |
| 11192 | { |
| 11193 | gl::Context *context = gl::getNonLostContext(); |
| 11194 | |
| 11195 | if (context) |
| 11196 | { |
| 11197 | if (context->getClientVersion() < 3) |
| 11198 | { |
| 11199 | return gl::error(GL_INVALID_OPERATION); |
| 11200 | } |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11201 | |
| 11202 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) |
| 11203 | { |
| 11204 | return; |
| 11205 | } |
| 11206 | |
| 11207 | switch (target) |
| 11208 | { |
| 11209 | case GL_TEXTURE_3D: |
| 11210 | { |
| 11211 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 11212 | texture3d->storage(levels, internalformat, width, height, depth); |
| 11213 | } |
| 11214 | break; |
| 11215 | |
| 11216 | case GL_TEXTURE_2D_ARRAY: |
| 11217 | { |
| 11218 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 11219 | texture2darray->storage(levels, internalformat, width, height, depth); |
| 11220 | } |
| 11221 | break; |
| 11222 | |
| 11223 | default: |
| 11224 | return gl::error(GL_INVALID_ENUM); |
| 11225 | } |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 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); |
| 11231 | } |
| 11232 | } |
| 11233 | |
| 11234 | void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) |
| 11235 | { |
| 11236 | EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, " |
| 11237 | "GLint* params = 0x%0.8p)", |
| 11238 | target, internalformat, pname, bufSize, params); |
| 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 | // Extension functions |
| 11261 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11262 | void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 11263 | GLbitfield mask, GLenum filter) |
| 11264 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11265 | 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] | 11266 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, " |
| 11267 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 11268 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 11269 | |
| 11270 | try |
| 11271 | { |
| 11272 | switch (filter) |
| 11273 | { |
| 11274 | case GL_NEAREST: |
| 11275 | break; |
| 11276 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11277 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11278 | } |
| 11279 | |
| 11280 | if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0) |
| 11281 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11282 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11283 | } |
| 11284 | |
| 11285 | if (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0) |
| 11286 | { |
| 11287 | ERR("Scaling and flipping in BlitFramebufferANGLE not supported by this implementation"); |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11288 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11289 | } |
| 11290 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11291 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11292 | |
| 11293 | if (context) |
| 11294 | { |
| 11295 | if (context->getReadFramebufferHandle() == context->getDrawFramebufferHandle()) |
| 11296 | { |
| 11297 | ERR("Blits with the same source and destination framebuffer are not supported by this implementation."); |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11298 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11299 | } |
| 11300 | |
| 11301 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask); |
| 11302 | } |
| 11303 | } |
| 11304 | catch(std::bad_alloc&) |
| 11305 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11306 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11307 | } |
| 11308 | } |
| 11309 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 11310 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, |
| 11311 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11312 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11313 | 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] | 11314 | "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] | 11315 | "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] | 11316 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 11317 | |
| 11318 | try |
| 11319 | { |
| 11320 | UNIMPLEMENTED(); // FIXME |
| 11321 | } |
| 11322 | catch(std::bad_alloc&) |
| 11323 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11324 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11325 | } |
| 11326 | } |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11327 | |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11328 | void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, |
| 11329 | GLenum *binaryFormat, void *binary) |
| 11330 | { |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11331 | 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] | 11332 | program, bufSize, length, binaryFormat, binary); |
| 11333 | |
| 11334 | try |
| 11335 | { |
| 11336 | gl::Context *context = gl::getNonLostContext(); |
| 11337 | |
| 11338 | if (context) |
| 11339 | { |
| 11340 | gl::Program *programObject = context->getProgram(program); |
| 11341 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 11342 | if (!programObject || !programObject->isLinked()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11343 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11344 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11345 | } |
| 11346 | |
| 11347 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 11348 | |
| 11349 | if (!programBinary) |
| 11350 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11351 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11352 | } |
| 11353 | |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11354 | if (!programBinary->save(binary, bufSize, length)) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11355 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11356 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11357 | } |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11358 | |
| 11359 | *binaryFormat = GL_PROGRAM_BINARY_ANGLE; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11360 | } |
| 11361 | } |
| 11362 | catch(std::bad_alloc&) |
| 11363 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11364 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11365 | } |
| 11366 | } |
| 11367 | |
| 11368 | void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat, |
| 11369 | const void *binary, GLint length) |
| 11370 | { |
| 11371 | EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)", |
| 11372 | program, binaryFormat, binary, length); |
| 11373 | |
| 11374 | try |
| 11375 | { |
| 11376 | gl::Context *context = gl::getNonLostContext(); |
| 11377 | |
| 11378 | if (context) |
| 11379 | { |
| 11380 | if (binaryFormat != GL_PROGRAM_BINARY_ANGLE) |
| 11381 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11382 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11383 | } |
| 11384 | |
| 11385 | gl::Program *programObject = context->getProgram(program); |
| 11386 | |
| 11387 | if (!programObject) |
| 11388 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11389 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11390 | } |
| 11391 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 11392 | context->setProgramBinary(program, binary, length); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11393 | } |
| 11394 | } |
| 11395 | catch(std::bad_alloc&) |
| 11396 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11397 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11398 | } |
| 11399 | } |
| 11400 | |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11401 | void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) |
| 11402 | { |
| 11403 | EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs); |
| 11404 | |
| 11405 | try |
| 11406 | { |
| 11407 | gl::Context *context = gl::getNonLostContext(); |
| 11408 | |
| 11409 | if (context) |
| 11410 | { |
| 11411 | if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets()) |
| 11412 | { |
| 11413 | return gl::error(GL_INVALID_VALUE); |
| 11414 | } |
| 11415 | |
| 11416 | if (context->getDrawFramebufferHandle() == 0) |
| 11417 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11418 | if (n != 1) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11419 | { |
| 11420 | return gl::error(GL_INVALID_OPERATION); |
| 11421 | } |
| 11422 | |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11423 | 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] | 11424 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11425 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11426 | } |
| 11427 | } |
| 11428 | else |
| 11429 | { |
| 11430 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 11431 | { |
| 11432 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 11433 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment) |
| 11434 | { |
| 11435 | return gl::error(GL_INVALID_OPERATION); |
| 11436 | } |
| 11437 | } |
| 11438 | } |
| 11439 | |
| 11440 | gl::Framebuffer *framebuffer = context->getDrawFramebuffer(); |
| 11441 | |
| 11442 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 11443 | { |
| 11444 | framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]); |
| 11445 | } |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11446 | |
| 11447 | for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++) |
| 11448 | { |
| 11449 | framebuffer->setDrawBufferState(colorAttachment, GL_NONE); |
| 11450 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11451 | } |
| 11452 | } |
| 11453 | catch (std::bad_alloc&) |
| 11454 | { |
| 11455 | return gl::error(GL_OUT_OF_MEMORY); |
| 11456 | } |
| 11457 | } |
| 11458 | |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11459 | __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) |
| 11460 | { |
| 11461 | struct Extension |
| 11462 | { |
| 11463 | const char *name; |
| 11464 | __eglMustCastToProperFunctionPointerType address; |
| 11465 | }; |
| 11466 | |
| 11467 | static const Extension glExtensions[] = |
| 11468 | { |
| 11469 | {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 11470 | {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, |
daniel@transgaming.com | 1fe96c9 | 2011-01-14 15:08:44 +0000 | [diff] [blame] | 11471 | {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 11472 | {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, |
| 11473 | {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, |
| 11474 | {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, |
| 11475 | {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, |
| 11476 | {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, |
| 11477 | {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, |
| 11478 | {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 11479 | {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE}, |
daniel@transgaming.com | 0bd1f2f | 2011-11-11 04:19:03 +0000 | [diff] [blame] | 11480 | {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT}, |
daniel@transgaming.com | 709ed11 | 2011-11-12 03:18:10 +0000 | [diff] [blame] | 11481 | {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT}, |
| 11482 | {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT}, |
| 11483 | {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT}, |
| 11484 | {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT}, |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 11485 | {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT}, |
| 11486 | {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT}, |
| 11487 | {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT}, |
| 11488 | {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT}, |
| 11489 | {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT}, |
| 11490 | {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT}, |
| 11491 | {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT}, |
shannon.woods%transgaming.com@gtempaccount.com | 77d9472 | 2013-04-13 03:34:22 +0000 | [diff] [blame] | 11492 | {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT}, |
daniel@transgaming.com | dce02fd | 2012-01-27 15:39:51 +0000 | [diff] [blame] | 11493 | {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE}, |
| 11494 | {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, |
| 11495 | {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11496 | {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, |
| 11497 | {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, }; |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11498 | |
shannon.woods@transgaming.com | d438fd4 | 2013-02-28 23:17:45 +0000 | [diff] [blame] | 11499 | for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11500 | { |
| 11501 | if (strcmp(procname, glExtensions[ext].name) == 0) |
| 11502 | { |
| 11503 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address; |
| 11504 | } |
| 11505 | } |
| 11506 | |
| 11507 | return NULL; |
| 11508 | } |
| 11509 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 11510 | // Non-public functions used by EGL |
| 11511 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11512 | bool __stdcall glBindTexImage(egl::Surface *surface) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11513 | { |
| 11514 | EVENT("(egl::Surface* surface = 0x%0.8p)", |
| 11515 | surface); |
| 11516 | |
| 11517 | try |
| 11518 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11519 | gl::Context *context = gl::getNonLostContext(); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11520 | |
| 11521 | if (context) |
| 11522 | { |
| 11523 | gl::Texture2D *textureObject = context->getTexture2D(); |
| 11524 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11525 | if (textureObject->isImmutable()) |
| 11526 | { |
| 11527 | return false; |
| 11528 | } |
| 11529 | |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11530 | if (textureObject) |
| 11531 | { |
| 11532 | textureObject->bindTexImage(surface); |
| 11533 | } |
| 11534 | } |
| 11535 | } |
| 11536 | catch(std::bad_alloc&) |
| 11537 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11538 | return gl::error(GL_OUT_OF_MEMORY, false); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11539 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11540 | |
| 11541 | return true; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11542 | } |
| 11543 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11544 | } |