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 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3883 | gl::Texture *texture = NULL; |
| 3884 | GLint internalFormat = GL_NONE; |
| 3885 | bool isCompressed = false; |
| 3886 | bool isDepth = false; |
| 3887 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3888 | switch (target) |
| 3889 | { |
| 3890 | case GL_TEXTURE_2D: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3891 | { |
| 3892 | gl::Texture2D *tex2d = context->getTexture2D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3893 | if (tex2d) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3894 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3895 | internalFormat = tex2d->getInternalFormat(0); |
| 3896 | isCompressed = tex2d->isCompressed(0); |
| 3897 | isDepth = tex2d->isDepth(0); |
| 3898 | texture = tex2d; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3899 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3900 | break; |
| 3901 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3902 | |
| 3903 | case GL_TEXTURE_CUBE_MAP: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3904 | { |
| 3905 | gl::TextureCubeMap *texcube = context->getTextureCubeMap(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3906 | if (texcube) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3907 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3908 | internalFormat = texcube->getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 3909 | isCompressed = texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 3910 | isDepth = false; |
| 3911 | texture = texcube; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3912 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3913 | break; |
| 3914 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3915 | |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 3916 | case GL_TEXTURE_3D: |
| 3917 | { |
| 3918 | if (context->getClientVersion() < 3) |
| 3919 | { |
| 3920 | return gl::error(GL_INVALID_ENUM); |
| 3921 | } |
| 3922 | |
| 3923 | gl::Texture3D *tex3D = context->getTexture3D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3924 | if (tex3D) |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 3925 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3926 | internalFormat = tex3D->getInternalFormat(0); |
| 3927 | isCompressed = tex3D->isCompressed(0); |
| 3928 | isDepth = tex3D->isDepth(0); |
| 3929 | texture = tex3D; |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 3930 | } |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 3931 | break; |
| 3932 | } |
| 3933 | |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 3934 | case GL_TEXTURE_2D_ARRAY: |
| 3935 | { |
| 3936 | if (context->getClientVersion() < 3) |
| 3937 | { |
| 3938 | return gl::error(GL_INVALID_ENUM); |
| 3939 | } |
| 3940 | |
| 3941 | gl::Texture2DArray *tex2darr = context->getTexture2DArray(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3942 | if (tex2darr) |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 3943 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3944 | internalFormat = tex2darr->getInternalFormat(0); |
| 3945 | isCompressed = tex2darr->isCompressed(0); |
| 3946 | isDepth = tex2darr->isDepth(0); |
| 3947 | texture = tex2darr; |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 3948 | } |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 3949 | break; |
| 3950 | } |
| 3951 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3952 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3953 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3954 | } |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 3955 | |
| 3956 | if (!texture) |
| 3957 | { |
| 3958 | return gl::error(GL_INVALID_OPERATION); |
| 3959 | } |
| 3960 | |
| 3961 | // Internally, all texture formats are sized so checking if the format |
| 3962 | // is color renderable and filterable will not fail. |
| 3963 | if (isDepth || isCompressed || |
| 3964 | !gl::IsColorRenderingSupported(internalFormat, context) || |
| 3965 | !gl::IsTextureFilteringSupported(internalFormat, context)) |
| 3966 | { |
| 3967 | return gl::error(GL_INVALID_OPERATION); |
| 3968 | } |
| 3969 | |
| 3970 | texture->generateMipmaps(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3971 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3972 | } |
| 3973 | catch(std::bad_alloc&) |
| 3974 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3975 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3976 | } |
| 3977 | } |
| 3978 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3979 | void __stdcall glGenFencesNV(GLsizei n, GLuint* fences) |
| 3980 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3981 | EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3982 | |
| 3983 | try |
| 3984 | { |
| 3985 | if (n < 0) |
| 3986 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3987 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3988 | } |
| 3989 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3990 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3991 | |
| 3992 | if (context) |
| 3993 | { |
| 3994 | for (int i = 0; i < n; i++) |
| 3995 | { |
| 3996 | fences[i] = context->createFence(); |
| 3997 | } |
| 3998 | } |
| 3999 | } |
| 4000 | catch(std::bad_alloc&) |
| 4001 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4002 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4003 | } |
| 4004 | } |
| 4005 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4006 | void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers) |
| 4007 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4008 | EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4009 | |
| 4010 | try |
| 4011 | { |
| 4012 | if (n < 0) |
| 4013 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4014 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4015 | } |
| 4016 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4017 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4018 | |
| 4019 | if (context) |
| 4020 | { |
| 4021 | for (int i = 0; i < n; i++) |
| 4022 | { |
| 4023 | framebuffers[i] = context->createFramebuffer(); |
| 4024 | } |
| 4025 | } |
| 4026 | } |
| 4027 | catch(std::bad_alloc&) |
| 4028 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4029 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4030 | } |
| 4031 | } |
| 4032 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4033 | void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids) |
| 4034 | { |
| 4035 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 4036 | |
| 4037 | try |
| 4038 | { |
| 4039 | if (n < 0) |
| 4040 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4041 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4042 | } |
| 4043 | |
| 4044 | gl::Context *context = gl::getNonLostContext(); |
| 4045 | |
| 4046 | if (context) |
| 4047 | { |
| 4048 | for (int i = 0; i < n; i++) |
| 4049 | { |
| 4050 | ids[i] = context->createQuery(); |
| 4051 | } |
| 4052 | } |
| 4053 | } |
| 4054 | catch(std::bad_alloc&) |
| 4055 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4056 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4057 | } |
| 4058 | } |
| 4059 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4060 | void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) |
| 4061 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4062 | EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4063 | |
| 4064 | try |
| 4065 | { |
| 4066 | if (n < 0) |
| 4067 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4068 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4069 | } |
| 4070 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4071 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4072 | |
| 4073 | if (context) |
| 4074 | { |
| 4075 | for (int i = 0; i < n; i++) |
| 4076 | { |
| 4077 | renderbuffers[i] = context->createRenderbuffer(); |
| 4078 | } |
| 4079 | } |
| 4080 | } |
| 4081 | catch(std::bad_alloc&) |
| 4082 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4083 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4084 | } |
| 4085 | } |
| 4086 | |
| 4087 | void __stdcall glGenTextures(GLsizei n, GLuint* textures) |
| 4088 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4089 | EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4090 | |
| 4091 | try |
| 4092 | { |
| 4093 | if (n < 0) |
| 4094 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4095 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4096 | } |
| 4097 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4098 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4099 | |
| 4100 | if (context) |
| 4101 | { |
| 4102 | for (int i = 0; i < n; i++) |
| 4103 | { |
| 4104 | textures[i] = context->createTexture(); |
| 4105 | } |
| 4106 | } |
| 4107 | } |
| 4108 | catch(std::bad_alloc&) |
| 4109 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4110 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4111 | } |
| 4112 | } |
| 4113 | |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4114 | 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] | 4115 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4116 | 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] | 4117 | "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] | 4118 | program, index, bufsize, length, size, type, name); |
| 4119 | |
| 4120 | try |
| 4121 | { |
| 4122 | if (bufsize < 0) |
| 4123 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4124 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4125 | } |
| 4126 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4127 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4128 | |
| 4129 | if (context) |
| 4130 | { |
| 4131 | gl::Program *programObject = context->getProgram(program); |
| 4132 | |
| 4133 | if (!programObject) |
| 4134 | { |
| 4135 | if (context->getShader(program)) |
| 4136 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4137 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4138 | } |
| 4139 | else |
| 4140 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4141 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4142 | } |
| 4143 | } |
| 4144 | |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4145 | if (index >= (GLuint)programObject->getActiveAttributeCount()) |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4146 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4147 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4148 | } |
| 4149 | |
| 4150 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 4151 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4152 | } |
| 4153 | catch(std::bad_alloc&) |
| 4154 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4155 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4156 | } |
| 4157 | } |
| 4158 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4159 | 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] | 4160 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4161 | EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4162 | "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] | 4163 | program, index, bufsize, length, size, type, name); |
| 4164 | |
| 4165 | try |
| 4166 | { |
| 4167 | if (bufsize < 0) |
| 4168 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4169 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4170 | } |
| 4171 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4172 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4173 | |
| 4174 | if (context) |
| 4175 | { |
| 4176 | gl::Program *programObject = context->getProgram(program); |
| 4177 | |
| 4178 | if (!programObject) |
| 4179 | { |
| 4180 | if (context->getShader(program)) |
| 4181 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4182 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4183 | } |
| 4184 | else |
| 4185 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4186 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4187 | } |
| 4188 | } |
| 4189 | |
| 4190 | if (index >= (GLuint)programObject->getActiveUniformCount()) |
| 4191 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4192 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4193 | } |
| 4194 | |
| 4195 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 4196 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4197 | } |
| 4198 | catch(std::bad_alloc&) |
| 4199 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4200 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4201 | } |
| 4202 | } |
| 4203 | |
| 4204 | void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) |
| 4205 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4206 | 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] | 4207 | program, maxcount, count, shaders); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4208 | |
| 4209 | try |
| 4210 | { |
| 4211 | if (maxcount < 0) |
| 4212 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4213 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4214 | } |
| 4215 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4216 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4217 | |
| 4218 | if (context) |
| 4219 | { |
| 4220 | gl::Program *programObject = context->getProgram(program); |
| 4221 | |
| 4222 | if (!programObject) |
| 4223 | { |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4224 | if (context->getShader(program)) |
| 4225 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4226 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4227 | } |
| 4228 | else |
| 4229 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4230 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4231 | } |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4232 | } |
| 4233 | |
| 4234 | return programObject->getAttachedShaders(maxcount, count, shaders); |
| 4235 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4236 | } |
| 4237 | catch(std::bad_alloc&) |
| 4238 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4239 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4240 | } |
| 4241 | } |
| 4242 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4243 | int __stdcall glGetAttribLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4244 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4245 | EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4246 | |
| 4247 | try |
| 4248 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4249 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4250 | |
| 4251 | if (context) |
| 4252 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4253 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4254 | gl::Program *programObject = context->getProgram(program); |
| 4255 | |
| 4256 | if (!programObject) |
| 4257 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4258 | if (context->getShader(program)) |
| 4259 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4260 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4261 | } |
| 4262 | else |
| 4263 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4264 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4265 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4266 | } |
| 4267 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4268 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 4269 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4270 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4271 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4272 | } |
| 4273 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4274 | return programBinary->getAttributeLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4275 | } |
| 4276 | } |
| 4277 | catch(std::bad_alloc&) |
| 4278 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4279 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4280 | } |
| 4281 | |
| 4282 | return -1; |
| 4283 | } |
| 4284 | |
| 4285 | void __stdcall glGetBooleanv(GLenum pname, GLboolean* params) |
| 4286 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4287 | 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] | 4288 | |
| 4289 | try |
| 4290 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4291 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4292 | |
| 4293 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4294 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4295 | if (!(context->getBooleanv(pname, params))) |
| 4296 | { |
| 4297 | GLenum nativeType; |
| 4298 | unsigned int numParams = 0; |
| 4299 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4300 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4301 | |
| 4302 | if (numParams == 0) |
| 4303 | return; // it is known that the pname is valid, but there are no parameters to return |
| 4304 | |
| 4305 | if (nativeType == GL_FLOAT) |
| 4306 | { |
| 4307 | GLfloat *floatParams = NULL; |
| 4308 | floatParams = new GLfloat[numParams]; |
| 4309 | |
| 4310 | context->getFloatv(pname, floatParams); |
| 4311 | |
| 4312 | for (unsigned int i = 0; i < numParams; ++i) |
| 4313 | { |
| 4314 | if (floatParams[i] == 0.0f) |
| 4315 | params[i] = GL_FALSE; |
| 4316 | else |
| 4317 | params[i] = GL_TRUE; |
| 4318 | } |
| 4319 | |
| 4320 | delete [] floatParams; |
| 4321 | } |
| 4322 | else if (nativeType == GL_INT) |
| 4323 | { |
| 4324 | GLint *intParams = NULL; |
| 4325 | intParams = new GLint[numParams]; |
| 4326 | |
| 4327 | context->getIntegerv(pname, intParams); |
| 4328 | |
| 4329 | for (unsigned int i = 0; i < numParams; ++i) |
| 4330 | { |
| 4331 | if (intParams[i] == 0) |
| 4332 | params[i] = GL_FALSE; |
| 4333 | else |
| 4334 | params[i] = GL_TRUE; |
| 4335 | } |
| 4336 | |
| 4337 | delete [] intParams; |
| 4338 | } |
| 4339 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4340 | } |
| 4341 | } |
| 4342 | catch(std::bad_alloc&) |
| 4343 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4344 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4345 | } |
| 4346 | } |
| 4347 | |
| 4348 | void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 4349 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4350 | 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] | 4351 | |
| 4352 | try |
| 4353 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4354 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4355 | |
| 4356 | if (context) |
| 4357 | { |
| 4358 | gl::Buffer *buffer; |
| 4359 | |
| 4360 | switch (target) |
| 4361 | { |
| 4362 | case GL_ARRAY_BUFFER: |
| 4363 | buffer = context->getArrayBuffer(); |
| 4364 | break; |
| 4365 | case GL_ELEMENT_ARRAY_BUFFER: |
| 4366 | buffer = context->getElementArrayBuffer(); |
| 4367 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4368 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4369 | } |
| 4370 | |
| 4371 | if (!buffer) |
| 4372 | { |
| 4373 | // 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] | 4374 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4375 | } |
| 4376 | |
| 4377 | switch (pname) |
| 4378 | { |
| 4379 | case GL_BUFFER_USAGE: |
| 4380 | *params = buffer->usage(); |
| 4381 | break; |
| 4382 | case GL_BUFFER_SIZE: |
| 4383 | *params = buffer->size(); |
| 4384 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4385 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4386 | } |
| 4387 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4388 | } |
| 4389 | catch(std::bad_alloc&) |
| 4390 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4391 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4392 | } |
| 4393 | } |
| 4394 | |
| 4395 | GLenum __stdcall glGetError(void) |
| 4396 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4397 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4398 | |
| 4399 | gl::Context *context = gl::getContext(); |
| 4400 | |
| 4401 | if (context) |
| 4402 | { |
daniel@transgaming.com | 82b2891 | 2011-12-12 21:01:35 +0000 | [diff] [blame] | 4403 | return context->getError(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4404 | } |
| 4405 | |
| 4406 | return GL_NO_ERROR; |
| 4407 | } |
| 4408 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4409 | void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 4410 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4411 | 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] | 4412 | |
| 4413 | try |
| 4414 | { |
| 4415 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4416 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4417 | |
| 4418 | if (context) |
| 4419 | { |
| 4420 | gl::Fence *fenceObject = context->getFence(fence); |
| 4421 | |
| 4422 | if (fenceObject == NULL) |
| 4423 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4424 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4425 | } |
| 4426 | |
| 4427 | fenceObject->getFenceiv(pname, params); |
| 4428 | } |
| 4429 | } |
| 4430 | catch(std::bad_alloc&) |
| 4431 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4432 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4433 | } |
| 4434 | } |
| 4435 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4436 | void __stdcall glGetFloatv(GLenum pname, GLfloat* params) |
| 4437 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4438 | 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] | 4439 | |
| 4440 | try |
| 4441 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4442 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4443 | |
| 4444 | if (context) |
| 4445 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4446 | if (!(context->getFloatv(pname, params))) |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4447 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4448 | GLenum nativeType; |
| 4449 | unsigned int numParams = 0; |
| 4450 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4451 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4452 | |
| 4453 | if (numParams == 0) |
| 4454 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 4455 | |
| 4456 | if (nativeType == GL_BOOL) |
| 4457 | { |
| 4458 | GLboolean *boolParams = NULL; |
| 4459 | boolParams = new GLboolean[numParams]; |
| 4460 | |
| 4461 | context->getBooleanv(pname, boolParams); |
| 4462 | |
| 4463 | for (unsigned int i = 0; i < numParams; ++i) |
| 4464 | { |
| 4465 | if (boolParams[i] == GL_FALSE) |
| 4466 | params[i] = 0.0f; |
| 4467 | else |
| 4468 | params[i] = 1.0f; |
| 4469 | } |
| 4470 | |
| 4471 | delete [] boolParams; |
| 4472 | } |
| 4473 | else if (nativeType == GL_INT) |
| 4474 | { |
| 4475 | GLint *intParams = NULL; |
| 4476 | intParams = new GLint[numParams]; |
| 4477 | |
| 4478 | context->getIntegerv(pname, intParams); |
| 4479 | |
| 4480 | for (unsigned int i = 0; i < numParams; ++i) |
| 4481 | { |
| 4482 | params[i] = (GLfloat)intParams[i]; |
| 4483 | } |
| 4484 | |
| 4485 | delete [] intParams; |
| 4486 | } |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4487 | } |
| 4488 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4489 | } |
| 4490 | catch(std::bad_alloc&) |
| 4491 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4492 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4493 | } |
| 4494 | } |
| 4495 | |
| 4496 | void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) |
| 4497 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4498 | 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] | 4499 | target, attachment, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4500 | |
| 4501 | try |
| 4502 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4503 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4504 | |
| 4505 | if (context) |
| 4506 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4507 | 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] | 4508 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4509 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4510 | } |
| 4511 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4512 | gl::Framebuffer *framebuffer = NULL; |
| 4513 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4514 | { |
| 4515 | if(context->getReadFramebufferHandle() == 0) |
| 4516 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4517 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4518 | } |
| 4519 | |
| 4520 | framebuffer = context->getReadFramebuffer(); |
| 4521 | } |
| 4522 | else |
| 4523 | { |
| 4524 | if (context->getDrawFramebufferHandle() == 0) |
| 4525 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4526 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4527 | } |
| 4528 | |
| 4529 | framebuffer = context->getDrawFramebuffer(); |
| 4530 | } |
| 4531 | |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4532 | GLenum attachmentType; |
| 4533 | GLuint attachmentHandle; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4534 | |
| 4535 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4536 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4537 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4538 | |
| 4539 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4540 | { |
| 4541 | return gl::error(GL_INVALID_ENUM); |
| 4542 | } |
| 4543 | |
| 4544 | attachmentType = framebuffer->getColorbufferType(colorAttachment); |
| 4545 | attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment); |
| 4546 | } |
| 4547 | else |
| 4548 | { |
| 4549 | switch (attachment) |
| 4550 | { |
| 4551 | case GL_DEPTH_ATTACHMENT: |
| 4552 | attachmentType = framebuffer->getDepthbufferType(); |
| 4553 | attachmentHandle = framebuffer->getDepthbufferHandle(); |
| 4554 | break; |
| 4555 | case GL_STENCIL_ATTACHMENT: |
| 4556 | attachmentType = framebuffer->getStencilbufferType(); |
| 4557 | attachmentHandle = framebuffer->getStencilbufferHandle(); |
| 4558 | break; |
| 4559 | default: return gl::error(GL_INVALID_ENUM); |
| 4560 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4561 | } |
| 4562 | |
| 4563 | GLenum attachmentObjectType; // Type category |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4564 | if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4565 | { |
| 4566 | attachmentObjectType = attachmentType; |
| 4567 | } |
apatrick@chromium.org | 551022e | 2012-01-23 19:56:54 +0000 | [diff] [blame] | 4568 | else if (gl::IsInternalTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4569 | { |
| 4570 | attachmentObjectType = GL_TEXTURE; |
| 4571 | } |
apatrick@chromium.org | a1d8059 | 2012-01-25 21:52:10 +0000 | [diff] [blame] | 4572 | else |
| 4573 | { |
| 4574 | UNREACHABLE(); |
| 4575 | return; |
| 4576 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4577 | |
| 4578 | switch (pname) |
| 4579 | { |
| 4580 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 4581 | *params = attachmentObjectType; |
| 4582 | break; |
| 4583 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 4584 | if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE) |
| 4585 | { |
| 4586 | *params = attachmentHandle; |
| 4587 | } |
| 4588 | else |
| 4589 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4590 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4591 | } |
| 4592 | break; |
| 4593 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 4594 | if (attachmentObjectType == GL_TEXTURE) |
| 4595 | { |
| 4596 | *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0 |
| 4597 | } |
| 4598 | else |
| 4599 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4600 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4601 | } |
| 4602 | break; |
| 4603 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 4604 | if (attachmentObjectType == GL_TEXTURE) |
| 4605 | { |
daniel@transgaming.com | 19ffc24 | 2010-05-04 03:35:21 +0000 | [diff] [blame] | 4606 | if (gl::IsCubemapTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4607 | { |
| 4608 | *params = attachmentType; |
| 4609 | } |
| 4610 | else |
| 4611 | { |
| 4612 | *params = 0; |
| 4613 | } |
| 4614 | } |
| 4615 | else |
| 4616 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4617 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4618 | } |
| 4619 | break; |
| 4620 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4621 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4622 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4623 | } |
| 4624 | } |
| 4625 | catch(std::bad_alloc&) |
| 4626 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4627 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4628 | } |
| 4629 | } |
| 4630 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 4631 | GLenum __stdcall glGetGraphicsResetStatusEXT(void) |
| 4632 | { |
| 4633 | EVENT("()"); |
| 4634 | |
| 4635 | try |
| 4636 | { |
| 4637 | gl::Context *context = gl::getContext(); |
| 4638 | |
| 4639 | if (context) |
| 4640 | { |
| 4641 | return context->getResetStatus(); |
| 4642 | } |
| 4643 | |
| 4644 | return GL_NO_ERROR; |
| 4645 | } |
| 4646 | catch(std::bad_alloc&) |
| 4647 | { |
| 4648 | return GL_OUT_OF_MEMORY; |
| 4649 | } |
| 4650 | } |
| 4651 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4652 | void __stdcall glGetIntegerv(GLenum pname, GLint* params) |
| 4653 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4654 | 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] | 4655 | |
| 4656 | try |
| 4657 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4658 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4659 | |
| 4660 | if (context) |
| 4661 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4662 | if (!(context->getIntegerv(pname, params))) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4663 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4664 | GLenum nativeType; |
| 4665 | unsigned int numParams = 0; |
| 4666 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4667 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4668 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4669 | if (numParams == 0) |
| 4670 | return; // it is known that pname is valid, but there are no parameters to return |
| 4671 | |
| 4672 | if (nativeType == GL_BOOL) |
| 4673 | { |
| 4674 | GLboolean *boolParams = NULL; |
| 4675 | boolParams = new GLboolean[numParams]; |
| 4676 | |
| 4677 | context->getBooleanv(pname, boolParams); |
| 4678 | |
| 4679 | for (unsigned int i = 0; i < numParams; ++i) |
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 | if (boolParams[i] == GL_FALSE) |
| 4682 | params[i] = 0; |
| 4683 | else |
| 4684 | params[i] = 1; |
| 4685 | } |
| 4686 | |
| 4687 | delete [] boolParams; |
| 4688 | } |
| 4689 | else if (nativeType == GL_FLOAT) |
| 4690 | { |
| 4691 | GLfloat *floatParams = NULL; |
| 4692 | floatParams = new GLfloat[numParams]; |
| 4693 | |
| 4694 | context->getFloatv(pname, floatParams); |
| 4695 | |
| 4696 | for (unsigned int i = 0; i < numParams; ++i) |
| 4697 | { |
daniel@transgaming.com | c164135 | 2010-04-26 15:33:36 +0000 | [diff] [blame] | 4698 | 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] | 4699 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4700 | params[i] = (GLint)(((GLfloat)(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4701 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4702 | else |
| 4703 | 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] | 4704 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4705 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4706 | delete [] floatParams; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4707 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4708 | } |
| 4709 | } |
| 4710 | } |
| 4711 | catch(std::bad_alloc&) |
| 4712 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4713 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4714 | } |
| 4715 | } |
| 4716 | |
| 4717 | void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params) |
| 4718 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4719 | 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] | 4720 | |
| 4721 | try |
| 4722 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4723 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4724 | |
| 4725 | if (context) |
| 4726 | { |
| 4727 | gl::Program *programObject = context->getProgram(program); |
| 4728 | |
| 4729 | if (!programObject) |
| 4730 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4731 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4732 | } |
| 4733 | |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 4734 | if (context->getClientVersion() < 3) |
| 4735 | { |
| 4736 | switch (pname) |
| 4737 | { |
| 4738 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 4739 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 4740 | return gl::error(GL_INVALID_ENUM); |
| 4741 | } |
| 4742 | } |
| 4743 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4744 | switch (pname) |
| 4745 | { |
| 4746 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4747 | *params = programObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4748 | return; |
| 4749 | case GL_LINK_STATUS: |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 4750 | *params = programObject->isLinked(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4751 | return; |
| 4752 | case GL_VALIDATE_STATUS: |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 4753 | *params = programObject->isValidated(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4754 | return; |
| 4755 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4756 | *params = programObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4757 | return; |
| 4758 | case GL_ATTACHED_SHADERS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4759 | *params = programObject->getAttachedShadersCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4760 | return; |
| 4761 | case GL_ACTIVE_ATTRIBUTES: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4762 | *params = programObject->getActiveAttributeCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4763 | return; |
| 4764 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4765 | *params = programObject->getActiveAttributeMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4766 | return; |
| 4767 | case GL_ACTIVE_UNIFORMS: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4768 | *params = programObject->getActiveUniformCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4769 | return; |
| 4770 | case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4771 | *params = programObject->getActiveUniformMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4772 | return; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 4773 | case GL_PROGRAM_BINARY_LENGTH_OES: |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 4774 | *params = programObject->getProgramBinaryLength(); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 4775 | return; |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 4776 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 4777 | *params = programObject->getActiveUniformBlockCount(); |
| 4778 | return; |
| 4779 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 4780 | *params = programObject->getActiveUniformBlockMaxLength(); |
| 4781 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4782 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4783 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4784 | } |
| 4785 | } |
| 4786 | } |
| 4787 | catch(std::bad_alloc&) |
| 4788 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4789 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4790 | } |
| 4791 | } |
| 4792 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4793 | void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4794 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4795 | 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] | 4796 | program, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4797 | |
| 4798 | try |
| 4799 | { |
| 4800 | if (bufsize < 0) |
| 4801 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4802 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4803 | } |
| 4804 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4805 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4806 | |
| 4807 | if (context) |
| 4808 | { |
| 4809 | gl::Program *programObject = context->getProgram(program); |
| 4810 | |
| 4811 | if (!programObject) |
| 4812 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4813 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4814 | } |
| 4815 | |
| 4816 | programObject->getInfoLog(bufsize, length, infolog); |
| 4817 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4818 | } |
| 4819 | catch(std::bad_alloc&) |
| 4820 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4821 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4822 | } |
| 4823 | } |
| 4824 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4825 | void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params) |
| 4826 | { |
| 4827 | EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params); |
| 4828 | |
| 4829 | try |
| 4830 | { |
| 4831 | switch (pname) |
| 4832 | { |
| 4833 | case GL_CURRENT_QUERY_EXT: |
| 4834 | break; |
| 4835 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4836 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4837 | } |
| 4838 | |
| 4839 | gl::Context *context = gl::getNonLostContext(); |
| 4840 | |
| 4841 | if (context) |
| 4842 | { |
| 4843 | params[0] = context->getActiveQuery(target); |
| 4844 | } |
| 4845 | } |
| 4846 | catch(std::bad_alloc&) |
| 4847 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4848 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4849 | } |
| 4850 | } |
| 4851 | |
| 4852 | void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) |
| 4853 | { |
| 4854 | EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params); |
| 4855 | |
| 4856 | try |
| 4857 | { |
| 4858 | switch (pname) |
| 4859 | { |
| 4860 | case GL_QUERY_RESULT_EXT: |
| 4861 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 4862 | break; |
| 4863 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4864 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4865 | } |
| 4866 | gl::Context *context = gl::getNonLostContext(); |
| 4867 | |
| 4868 | if (context) |
| 4869 | { |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4870 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 4871 | |
| 4872 | if (!queryObject) |
| 4873 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4874 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4875 | } |
| 4876 | |
| 4877 | if (context->getActiveQuery(queryObject->getType()) == id) |
| 4878 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4879 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4880 | } |
| 4881 | |
| 4882 | switch(pname) |
| 4883 | { |
| 4884 | case GL_QUERY_RESULT_EXT: |
| 4885 | params[0] = queryObject->getResult(); |
| 4886 | break; |
| 4887 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 4888 | params[0] = queryObject->isResultAvailable(); |
| 4889 | break; |
| 4890 | default: |
| 4891 | ASSERT(false); |
| 4892 | } |
| 4893 | } |
| 4894 | } |
| 4895 | catch(std::bad_alloc&) |
| 4896 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4897 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4898 | } |
| 4899 | } |
| 4900 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4901 | void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 4902 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4903 | 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] | 4904 | |
| 4905 | try |
| 4906 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4907 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4908 | |
| 4909 | if (context) |
| 4910 | { |
| 4911 | if (target != GL_RENDERBUFFER) |
| 4912 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4913 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4914 | } |
| 4915 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4916 | if (context->getRenderbufferHandle() == 0) |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4917 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4918 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4919 | } |
| 4920 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4921 | gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle()); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4922 | |
| 4923 | switch (pname) |
| 4924 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 4925 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break; |
| 4926 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break; |
| 4927 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break; |
| 4928 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break; |
| 4929 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break; |
| 4930 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break; |
| 4931 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break; |
| 4932 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break; |
| 4933 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break; |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 4934 | case GL_RENDERBUFFER_SAMPLES_ANGLE: |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 4935 | if (context->getMaxSupportedSamples() != 0) |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 4936 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 4937 | *params = renderbuffer->getSamples(); |
| 4938 | } |
| 4939 | else |
| 4940 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4941 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 4942 | } |
| 4943 | break; |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4944 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4945 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4946 | } |
| 4947 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4948 | } |
| 4949 | catch(std::bad_alloc&) |
| 4950 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4951 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4952 | } |
| 4953 | } |
| 4954 | |
| 4955 | void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params) |
| 4956 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4957 | 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] | 4958 | |
| 4959 | try |
| 4960 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4961 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4962 | |
| 4963 | if (context) |
| 4964 | { |
| 4965 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 4966 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4967 | if (!shaderObject) |
| 4968 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4969 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4970 | } |
| 4971 | |
| 4972 | switch (pname) |
| 4973 | { |
| 4974 | case GL_SHADER_TYPE: |
| 4975 | *params = shaderObject->getType(); |
| 4976 | return; |
| 4977 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4978 | *params = shaderObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4979 | return; |
| 4980 | case GL_COMPILE_STATUS: |
| 4981 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; |
| 4982 | return; |
| 4983 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4984 | *params = shaderObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4985 | return; |
| 4986 | case GL_SHADER_SOURCE_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4987 | *params = shaderObject->getSourceLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4988 | return; |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 4989 | case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: |
| 4990 | *params = shaderObject->getTranslatedSourceLength(); |
| 4991 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4992 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4993 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4994 | } |
| 4995 | } |
| 4996 | } |
| 4997 | catch(std::bad_alloc&) |
| 4998 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4999 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5000 | } |
| 5001 | } |
| 5002 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5003 | void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5004 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5005 | 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] | 5006 | shader, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5007 | |
| 5008 | try |
| 5009 | { |
| 5010 | if (bufsize < 0) |
| 5011 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5012 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5013 | } |
| 5014 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5015 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5016 | |
| 5017 | if (context) |
| 5018 | { |
| 5019 | gl::Shader *shaderObject = context->getShader(shader); |
| 5020 | |
| 5021 | if (!shaderObject) |
| 5022 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5023 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5024 | } |
| 5025 | |
| 5026 | shaderObject->getInfoLog(bufsize, length, infolog); |
| 5027 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5028 | } |
| 5029 | catch(std::bad_alloc&) |
| 5030 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5031 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5032 | } |
| 5033 | } |
| 5034 | |
| 5035 | void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) |
| 5036 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5037 | 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] | 5038 | shadertype, precisiontype, range, precision); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5039 | |
| 5040 | try |
| 5041 | { |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5042 | switch (shadertype) |
| 5043 | { |
| 5044 | case GL_VERTEX_SHADER: |
| 5045 | case GL_FRAGMENT_SHADER: |
| 5046 | break; |
| 5047 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5048 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5049 | } |
| 5050 | |
| 5051 | switch (precisiontype) |
| 5052 | { |
| 5053 | case GL_LOW_FLOAT: |
| 5054 | case GL_MEDIUM_FLOAT: |
| 5055 | case GL_HIGH_FLOAT: |
| 5056 | // Assume IEEE 754 precision |
| 5057 | range[0] = 127; |
| 5058 | range[1] = 127; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5059 | *precision = 23; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5060 | break; |
| 5061 | case GL_LOW_INT: |
| 5062 | case GL_MEDIUM_INT: |
| 5063 | case GL_HIGH_INT: |
| 5064 | // Some (most) hardware only supports single-precision floating-point numbers, |
| 5065 | // which can accurately represent integers up to +/-16777216 |
| 5066 | range[0] = 24; |
| 5067 | range[1] = 24; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5068 | *precision = 0; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5069 | break; |
| 5070 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5071 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5072 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5073 | } |
| 5074 | catch(std::bad_alloc&) |
| 5075 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5076 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5077 | } |
| 5078 | } |
| 5079 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5080 | void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5081 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5082 | 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] | 5083 | shader, bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5084 | |
| 5085 | try |
| 5086 | { |
| 5087 | if (bufsize < 0) |
| 5088 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5089 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5090 | } |
| 5091 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5092 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5093 | |
| 5094 | if (context) |
| 5095 | { |
| 5096 | gl::Shader *shaderObject = context->getShader(shader); |
| 5097 | |
| 5098 | if (!shaderObject) |
| 5099 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5100 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5101 | } |
| 5102 | |
| 5103 | shaderObject->getSource(bufsize, length, source); |
| 5104 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5105 | } |
| 5106 | catch(std::bad_alloc&) |
| 5107 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5108 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5109 | } |
| 5110 | } |
| 5111 | |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5112 | void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
| 5113 | { |
| 5114 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)", |
| 5115 | shader, bufsize, length, source); |
| 5116 | |
| 5117 | try |
| 5118 | { |
| 5119 | if (bufsize < 0) |
| 5120 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5121 | return gl::error(GL_INVALID_VALUE); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5122 | } |
| 5123 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5124 | gl::Context *context = gl::getNonLostContext(); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5125 | |
| 5126 | if (context) |
| 5127 | { |
| 5128 | gl::Shader *shaderObject = context->getShader(shader); |
| 5129 | |
| 5130 | if (!shaderObject) |
| 5131 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5132 | return gl::error(GL_INVALID_OPERATION); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5133 | } |
| 5134 | |
| 5135 | shaderObject->getTranslatedSource(bufsize, length, source); |
| 5136 | } |
| 5137 | } |
| 5138 | catch(std::bad_alloc&) |
| 5139 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5140 | return gl::error(GL_OUT_OF_MEMORY); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5141 | } |
| 5142 | } |
| 5143 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5144 | const GLubyte* __stdcall glGetString(GLenum name) |
| 5145 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5146 | EVENT("(GLenum name = 0x%X)", name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5147 | |
| 5148 | try |
| 5149 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5150 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3e4c600 | 2010-05-05 18:50:13 +0000 | [diff] [blame] | 5151 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5152 | switch (name) |
| 5153 | { |
| 5154 | case GL_VENDOR: |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 5155 | return (GLubyte*)"Google Inc."; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5156 | case GL_RENDERER: |
daniel@transgaming.com | c23ff64 | 2011-08-16 20:28:45 +0000 | [diff] [blame] | 5157 | return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5158 | case GL_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5159 | if (context->getClientVersion() == 2) |
| 5160 | { |
| 5161 | return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")"; |
| 5162 | } |
| 5163 | else |
| 5164 | { |
| 5165 | return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")"; |
| 5166 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5167 | case GL_SHADING_LANGUAGE_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5168 | if (context->getClientVersion() == 2) |
| 5169 | { |
| 5170 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")"; |
| 5171 | } |
| 5172 | else |
| 5173 | { |
| 5174 | return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")"; |
| 5175 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5176 | case GL_EXTENSIONS: |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 5177 | return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : ""); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5178 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5179 | return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5180 | } |
| 5181 | } |
| 5182 | catch(std::bad_alloc&) |
| 5183 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5184 | return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5185 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5186 | } |
| 5187 | |
| 5188 | void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) |
| 5189 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5190 | 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] | 5191 | |
| 5192 | try |
| 5193 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5194 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5195 | |
| 5196 | if (context) |
| 5197 | { |
| 5198 | gl::Texture *texture; |
| 5199 | |
| 5200 | switch (target) |
| 5201 | { |
| 5202 | case GL_TEXTURE_2D: |
| 5203 | texture = context->getTexture2D(); |
| 5204 | break; |
| 5205 | case GL_TEXTURE_CUBE_MAP: |
| 5206 | texture = context->getTextureCubeMap(); |
| 5207 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5208 | case GL_TEXTURE_3D: |
| 5209 | if (context->getClientVersion() < 3) |
| 5210 | { |
| 5211 | return gl::error(GL_INVALID_ENUM); |
| 5212 | } |
| 5213 | texture = context->getTexture3D(); |
| 5214 | break; |
shannonwoods@chromium.org | 0c611d1 | 2013-05-30 00:15:05 +0000 | [diff] [blame] | 5215 | case GL_TEXTURE_2D_ARRAY: |
| 5216 | if (context->getClientVersion() < 3) |
| 5217 | { |
| 5218 | return gl::error(GL_INVALID_ENUM); |
| 5219 | } |
| 5220 | texture = context->getTexture2DArray(); |
| 5221 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5222 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5223 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5224 | } |
| 5225 | |
| 5226 | switch (pname) |
| 5227 | { |
| 5228 | case GL_TEXTURE_MAG_FILTER: |
| 5229 | *params = (GLfloat)texture->getMagFilter(); |
| 5230 | break; |
| 5231 | case GL_TEXTURE_MIN_FILTER: |
| 5232 | *params = (GLfloat)texture->getMinFilter(); |
| 5233 | break; |
| 5234 | case GL_TEXTURE_WRAP_S: |
| 5235 | *params = (GLfloat)texture->getWrapS(); |
| 5236 | break; |
| 5237 | case GL_TEXTURE_WRAP_T: |
| 5238 | *params = (GLfloat)texture->getWrapT(); |
| 5239 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5240 | case GL_TEXTURE_WRAP_R: |
| 5241 | if (context->getClientVersion() < 3) |
| 5242 | { |
| 5243 | return gl::error(GL_INVALID_ENUM); |
| 5244 | } |
| 5245 | *params = (GLfloat)texture->getWrapR(); |
| 5246 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5247 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5248 | // 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] | 5249 | *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE); |
| 5250 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5251 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5252 | if (context->getClientVersion() < 3) |
| 5253 | { |
| 5254 | return gl::error(GL_INVALID_ENUM); |
| 5255 | } |
| 5256 | *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0); |
| 5257 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5258 | case GL_TEXTURE_USAGE_ANGLE: |
| 5259 | *params = (GLfloat)texture->getUsage(); |
| 5260 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5261 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5262 | if (!context->supportsTextureFilterAnisotropy()) |
| 5263 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5264 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5265 | } |
| 5266 | *params = (GLfloat)texture->getMaxAnisotropy(); |
| 5267 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5268 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5269 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5270 | } |
| 5271 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5272 | } |
| 5273 | catch(std::bad_alloc&) |
| 5274 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5275 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5276 | } |
| 5277 | } |
| 5278 | |
| 5279 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5280 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5281 | 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] | 5282 | |
| 5283 | try |
| 5284 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5285 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5286 | |
| 5287 | if (context) |
| 5288 | { |
| 5289 | gl::Texture *texture; |
| 5290 | |
| 5291 | switch (target) |
| 5292 | { |
| 5293 | case GL_TEXTURE_2D: |
| 5294 | texture = context->getTexture2D(); |
| 5295 | break; |
| 5296 | case GL_TEXTURE_CUBE_MAP: |
| 5297 | texture = context->getTextureCubeMap(); |
| 5298 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5299 | case GL_TEXTURE_3D: |
| 5300 | if (context->getClientVersion() < 3) |
| 5301 | { |
| 5302 | return gl::error(GL_INVALID_ENUM); |
| 5303 | } |
| 5304 | texture = context->getTexture3D(); |
| 5305 | break; |
shannonwoods@chromium.org | 0c611d1 | 2013-05-30 00:15:05 +0000 | [diff] [blame] | 5306 | case GL_TEXTURE_2D_ARRAY: |
| 5307 | if (context->getClientVersion() < 3) |
| 5308 | { |
| 5309 | return gl::error(GL_INVALID_ENUM); |
| 5310 | } |
| 5311 | texture = context->getTexture2DArray(); |
| 5312 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5313 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5314 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5315 | } |
| 5316 | |
| 5317 | switch (pname) |
| 5318 | { |
| 5319 | case GL_TEXTURE_MAG_FILTER: |
| 5320 | *params = texture->getMagFilter(); |
| 5321 | break; |
| 5322 | case GL_TEXTURE_MIN_FILTER: |
| 5323 | *params = texture->getMinFilter(); |
| 5324 | break; |
| 5325 | case GL_TEXTURE_WRAP_S: |
| 5326 | *params = texture->getWrapS(); |
| 5327 | break; |
| 5328 | case GL_TEXTURE_WRAP_T: |
| 5329 | *params = texture->getWrapT(); |
| 5330 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5331 | case GL_TEXTURE_WRAP_R: |
| 5332 | if (context->getClientVersion() < 3) |
| 5333 | { |
| 5334 | return gl::error(GL_INVALID_ENUM); |
| 5335 | } |
| 5336 | *params = texture->getWrapR(); |
| 5337 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5338 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5339 | // 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] | 5340 | *params = texture->isImmutable() ? GL_TRUE : GL_FALSE; |
| 5341 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5342 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5343 | if (context->getClientVersion() < 3) |
| 5344 | { |
| 5345 | return gl::error(GL_INVALID_ENUM); |
| 5346 | } |
| 5347 | *params = texture->isImmutable() ? texture->levelCount() : 0; |
| 5348 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5349 | case GL_TEXTURE_USAGE_ANGLE: |
| 5350 | *params = texture->getUsage(); |
| 5351 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5352 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5353 | if (!context->supportsTextureFilterAnisotropy()) |
| 5354 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5355 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5356 | } |
| 5357 | *params = (GLint)texture->getMaxAnisotropy(); |
| 5358 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 5359 | |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5360 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5361 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5362 | } |
| 5363 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5364 | } |
| 5365 | catch(std::bad_alloc&) |
| 5366 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5367 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5368 | } |
| 5369 | } |
| 5370 | |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5371 | void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
| 5372 | { |
| 5373 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)", |
| 5374 | program, location, bufSize, params); |
| 5375 | |
| 5376 | try |
| 5377 | { |
| 5378 | if (bufSize < 0) |
| 5379 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5380 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5381 | } |
| 5382 | |
| 5383 | gl::Context *context = gl::getNonLostContext(); |
| 5384 | |
| 5385 | if (context) |
| 5386 | { |
| 5387 | if (program == 0) |
| 5388 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5389 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5390 | } |
| 5391 | |
| 5392 | gl::Program *programObject = context->getProgram(program); |
| 5393 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5394 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5395 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5396 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5397 | } |
| 5398 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5399 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5400 | if (!programBinary) |
| 5401 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5402 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5403 | } |
| 5404 | |
| 5405 | if (!programBinary->getUniformfv(location, &bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5406 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5407 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5408 | } |
| 5409 | } |
| 5410 | } |
| 5411 | catch(std::bad_alloc&) |
| 5412 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5413 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5414 | } |
| 5415 | } |
| 5416 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5417 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 5418 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5419 | 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] | 5420 | |
| 5421 | try |
| 5422 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5423 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5424 | |
| 5425 | if (context) |
| 5426 | { |
| 5427 | if (program == 0) |
| 5428 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5429 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5430 | } |
| 5431 | |
| 5432 | gl::Program *programObject = context->getProgram(program); |
| 5433 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5434 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5435 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5436 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5437 | } |
| 5438 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5439 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5440 | if (!programBinary) |
| 5441 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5442 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5443 | } |
| 5444 | |
| 5445 | if (!programBinary->getUniformfv(location, NULL, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5446 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5447 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5448 | } |
| 5449 | } |
| 5450 | } |
| 5451 | catch(std::bad_alloc&) |
| 5452 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5453 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5454 | } |
| 5455 | } |
| 5456 | |
| 5457 | void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) |
| 5458 | { |
| 5459 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)", |
| 5460 | program, location, bufSize, params); |
| 5461 | |
| 5462 | try |
| 5463 | { |
| 5464 | if (bufSize < 0) |
| 5465 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5466 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5467 | } |
| 5468 | |
| 5469 | gl::Context *context = gl::getNonLostContext(); |
| 5470 | |
| 5471 | if (context) |
| 5472 | { |
| 5473 | if (program == 0) |
| 5474 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5475 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5476 | } |
| 5477 | |
| 5478 | gl::Program *programObject = context->getProgram(program); |
| 5479 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5480 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5481 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5482 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5483 | } |
| 5484 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5485 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5486 | if (!programBinary) |
| 5487 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5488 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5489 | } |
| 5490 | |
| 5491 | if (!programBinary->getUniformiv(location, &bufSize, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5492 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5493 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5494 | } |
| 5495 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5496 | } |
| 5497 | catch(std::bad_alloc&) |
| 5498 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5499 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5500 | } |
| 5501 | } |
| 5502 | |
| 5503 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 5504 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5505 | 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] | 5506 | |
| 5507 | try |
| 5508 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5509 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5510 | |
| 5511 | if (context) |
| 5512 | { |
| 5513 | if (program == 0) |
| 5514 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5515 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5516 | } |
| 5517 | |
| 5518 | gl::Program *programObject = context->getProgram(program); |
| 5519 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5520 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5521 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5522 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5523 | } |
| 5524 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5525 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5526 | if (!programBinary) |
| 5527 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5528 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5529 | } |
| 5530 | |
| 5531 | if (!programBinary->getUniformiv(location, NULL, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5532 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5533 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5534 | } |
| 5535 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5536 | } |
| 5537 | catch(std::bad_alloc&) |
| 5538 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5539 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5540 | } |
| 5541 | } |
| 5542 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5543 | int __stdcall glGetUniformLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5544 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5545 | 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] | 5546 | |
| 5547 | try |
| 5548 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5549 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5550 | |
| 5551 | if (strstr(name, "gl_") == name) |
| 5552 | { |
| 5553 | return -1; |
| 5554 | } |
| 5555 | |
| 5556 | if (context) |
| 5557 | { |
| 5558 | gl::Program *programObject = context->getProgram(program); |
| 5559 | |
| 5560 | if (!programObject) |
| 5561 | { |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5562 | if (context->getShader(program)) |
| 5563 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5564 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5565 | } |
| 5566 | else |
| 5567 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5568 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5569 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5570 | } |
| 5571 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5572 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5573 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5574 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5575 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5576 | } |
| 5577 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5578 | return programBinary->getUniformLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5579 | } |
| 5580 | } |
| 5581 | catch(std::bad_alloc&) |
| 5582 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5583 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5584 | } |
| 5585 | |
| 5586 | return -1; |
| 5587 | } |
| 5588 | |
| 5589 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 5590 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5591 | 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] | 5592 | |
| 5593 | try |
| 5594 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5595 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5596 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5597 | if (context) |
| 5598 | { |
| 5599 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5600 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5601 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5602 | } |
| 5603 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5604 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5605 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5606 | switch (pname) |
| 5607 | { |
| 5608 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5609 | *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5610 | break; |
| 5611 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5612 | *params = (GLfloat)attribState.mSize; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5613 | break; |
| 5614 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5615 | *params = (GLfloat)attribState.mStride; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5616 | break; |
| 5617 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5618 | *params = (GLfloat)attribState.mType; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5619 | break; |
| 5620 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5621 | *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5622 | break; |
| 5623 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 5624 | *params = (GLfloat)attribState.mBoundBuffer.id(); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5625 | break; |
| 5626 | case GL_CURRENT_VERTEX_ATTRIB: |
| 5627 | for (int i = 0; i < 4; ++i) |
| 5628 | { |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame] | 5629 | params[i] = attribState.mCurrentValue.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5630 | } |
| 5631 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 5632 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 5633 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 5634 | // the same constant. |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 5635 | *params = (GLfloat)attribState.mDivisor; |
| 5636 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5637 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5638 | } |
| 5639 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5640 | } |
| 5641 | catch(std::bad_alloc&) |
| 5642 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5643 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5644 | } |
| 5645 | } |
| 5646 | |
| 5647 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 5648 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5649 | 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] | 5650 | |
| 5651 | try |
| 5652 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5653 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5654 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5655 | if (context) |
| 5656 | { |
| 5657 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5658 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5659 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5660 | } |
| 5661 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5662 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5663 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5664 | switch (pname) |
| 5665 | { |
| 5666 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5667 | *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5668 | break; |
| 5669 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5670 | *params = attribState.mSize; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5671 | break; |
| 5672 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5673 | *params = attribState.mStride; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5674 | break; |
| 5675 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5676 | *params = attribState.mType; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5677 | break; |
| 5678 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5679 | *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5680 | break; |
| 5681 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 5682 | *params = attribState.mBoundBuffer.id(); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5683 | break; |
| 5684 | case GL_CURRENT_VERTEX_ATTRIB: |
| 5685 | for (int i = 0; i < 4; ++i) |
| 5686 | { |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame] | 5687 | float currentValue = attribState.mCurrentValue.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5688 | params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f)); |
| 5689 | } |
| 5690 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 5691 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 5692 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 5693 | // the same constant. |
| 5694 | 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] | 5695 | *params = (GLint)attribState.mDivisor; |
| 5696 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5697 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5698 | } |
| 5699 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5700 | } |
| 5701 | catch(std::bad_alloc&) |
| 5702 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5703 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5704 | } |
| 5705 | } |
| 5706 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5707 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5708 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5709 | 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] | 5710 | |
| 5711 | try |
| 5712 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5713 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5714 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5715 | if (context) |
| 5716 | { |
| 5717 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5718 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5719 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5720 | } |
| 5721 | |
| 5722 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) |
| 5723 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5724 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5725 | } |
| 5726 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5727 | *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index)); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5728 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5729 | } |
| 5730 | catch(std::bad_alloc&) |
| 5731 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5732 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5733 | } |
| 5734 | } |
| 5735 | |
| 5736 | void __stdcall glHint(GLenum target, GLenum mode) |
| 5737 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5738 | EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5739 | |
| 5740 | try |
| 5741 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5742 | switch (mode) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5743 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5744 | case GL_FASTEST: |
| 5745 | case GL_NICEST: |
| 5746 | case GL_DONT_CARE: |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5747 | break; |
| 5748 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5749 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5750 | } |
| 5751 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5752 | gl::Context *context = gl::getNonLostContext(); |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5753 | switch (target) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5754 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5755 | case GL_GENERATE_MIPMAP_HINT: |
| 5756 | if (context) context->setGenerateMipmapHint(mode); |
| 5757 | break; |
| 5758 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 5759 | if (context) context->setFragmentShaderDerivativeHint(mode); |
| 5760 | break; |
| 5761 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5762 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5763 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5764 | } |
| 5765 | catch(std::bad_alloc&) |
| 5766 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5767 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5768 | } |
| 5769 | } |
| 5770 | |
| 5771 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 5772 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5773 | EVENT("(GLuint buffer = %d)", buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5774 | |
| 5775 | try |
| 5776 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5777 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5778 | |
| 5779 | if (context && buffer) |
| 5780 | { |
| 5781 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 5782 | |
| 5783 | if (bufferObject) |
| 5784 | { |
| 5785 | return GL_TRUE; |
| 5786 | } |
| 5787 | } |
| 5788 | } |
| 5789 | catch(std::bad_alloc&) |
| 5790 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5791 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5792 | } |
| 5793 | |
| 5794 | return GL_FALSE; |
| 5795 | } |
| 5796 | |
| 5797 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 5798 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5799 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5800 | |
| 5801 | try |
| 5802 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5803 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5804 | |
| 5805 | if (context) |
| 5806 | { |
| 5807 | switch (cap) |
| 5808 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5809 | case GL_CULL_FACE: return context->isCullFaceEnabled(); |
| 5810 | case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled(); |
| 5811 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled(); |
| 5812 | case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled(); |
| 5813 | case GL_SCISSOR_TEST: return context->isScissorTestEnabled(); |
| 5814 | case GL_STENCIL_TEST: return context->isStencilTestEnabled(); |
| 5815 | case GL_DEPTH_TEST: return context->isDepthTestEnabled(); |
| 5816 | case GL_BLEND: return context->isBlendEnabled(); |
| 5817 | case GL_DITHER: return context->isDitherEnabled(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5818 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5819 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5820 | } |
| 5821 | } |
| 5822 | } |
| 5823 | catch(std::bad_alloc&) |
| 5824 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5825 | return gl::error(GL_OUT_OF_MEMORY, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5826 | } |
| 5827 | |
| 5828 | return false; |
| 5829 | } |
| 5830 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 5831 | GLboolean __stdcall glIsFenceNV(GLuint fence) |
| 5832 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5833 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5834 | |
| 5835 | try |
| 5836 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5837 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5838 | |
| 5839 | if (context) |
| 5840 | { |
| 5841 | gl::Fence *fenceObject = context->getFence(fence); |
| 5842 | |
| 5843 | if (fenceObject == NULL) |
| 5844 | { |
| 5845 | return GL_FALSE; |
| 5846 | } |
| 5847 | |
| 5848 | return fenceObject->isFence(); |
| 5849 | } |
| 5850 | } |
| 5851 | catch(std::bad_alloc&) |
| 5852 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5853 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5854 | } |
| 5855 | |
| 5856 | return GL_FALSE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 5857 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5858 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5859 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 5860 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5861 | EVENT("(GLuint framebuffer = %d)", framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5862 | |
| 5863 | try |
| 5864 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5865 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5866 | |
| 5867 | if (context && framebuffer) |
| 5868 | { |
| 5869 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 5870 | |
| 5871 | if (framebufferObject) |
| 5872 | { |
| 5873 | return GL_TRUE; |
| 5874 | } |
| 5875 | } |
| 5876 | } |
| 5877 | catch(std::bad_alloc&) |
| 5878 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5879 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5880 | } |
| 5881 | |
| 5882 | return GL_FALSE; |
| 5883 | } |
| 5884 | |
| 5885 | GLboolean __stdcall glIsProgram(GLuint program) |
| 5886 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5887 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5888 | |
| 5889 | try |
| 5890 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5891 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5892 | |
| 5893 | if (context && program) |
| 5894 | { |
| 5895 | gl::Program *programObject = context->getProgram(program); |
| 5896 | |
| 5897 | if (programObject) |
| 5898 | { |
| 5899 | return GL_TRUE; |
| 5900 | } |
| 5901 | } |
| 5902 | } |
| 5903 | catch(std::bad_alloc&) |
| 5904 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5905 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5906 | } |
| 5907 | |
| 5908 | return GL_FALSE; |
| 5909 | } |
| 5910 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5911 | GLboolean __stdcall glIsQueryEXT(GLuint id) |
| 5912 | { |
| 5913 | EVENT("(GLuint id = %d)", id); |
| 5914 | |
| 5915 | try |
| 5916 | { |
| 5917 | if (id == 0) |
| 5918 | { |
| 5919 | return GL_FALSE; |
| 5920 | } |
| 5921 | |
| 5922 | gl::Context *context = gl::getNonLostContext(); |
| 5923 | |
| 5924 | if (context) |
| 5925 | { |
| 5926 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 5927 | |
| 5928 | if (queryObject) |
| 5929 | { |
| 5930 | return GL_TRUE; |
| 5931 | } |
| 5932 | } |
| 5933 | } |
| 5934 | catch(std::bad_alloc&) |
| 5935 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5936 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5937 | } |
| 5938 | |
| 5939 | return GL_FALSE; |
| 5940 | } |
| 5941 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5942 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 5943 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5944 | EVENT("(GLuint renderbuffer = %d)", renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5945 | |
| 5946 | try |
| 5947 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5948 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5949 | |
| 5950 | if (context && renderbuffer) |
| 5951 | { |
| 5952 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 5953 | |
| 5954 | if (renderbufferObject) |
| 5955 | { |
| 5956 | return GL_TRUE; |
| 5957 | } |
| 5958 | } |
| 5959 | } |
| 5960 | catch(std::bad_alloc&) |
| 5961 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5962 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5963 | } |
| 5964 | |
| 5965 | return GL_FALSE; |
| 5966 | } |
| 5967 | |
| 5968 | GLboolean __stdcall glIsShader(GLuint shader) |
| 5969 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5970 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5971 | |
| 5972 | try |
| 5973 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5974 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5975 | |
| 5976 | if (context && shader) |
| 5977 | { |
| 5978 | gl::Shader *shaderObject = context->getShader(shader); |
| 5979 | |
| 5980 | if (shaderObject) |
| 5981 | { |
| 5982 | return GL_TRUE; |
| 5983 | } |
| 5984 | } |
| 5985 | } |
| 5986 | catch(std::bad_alloc&) |
| 5987 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5988 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5989 | } |
| 5990 | |
| 5991 | return GL_FALSE; |
| 5992 | } |
| 5993 | |
| 5994 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 5995 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5996 | EVENT("(GLuint texture = %d)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5997 | |
| 5998 | try |
| 5999 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6000 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6001 | |
| 6002 | if (context && texture) |
| 6003 | { |
| 6004 | gl::Texture *textureObject = context->getTexture(texture); |
| 6005 | |
| 6006 | if (textureObject) |
| 6007 | { |
| 6008 | return GL_TRUE; |
| 6009 | } |
| 6010 | } |
| 6011 | } |
| 6012 | catch(std::bad_alloc&) |
| 6013 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6014 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6015 | } |
| 6016 | |
| 6017 | return GL_FALSE; |
| 6018 | } |
| 6019 | |
| 6020 | void __stdcall glLineWidth(GLfloat width) |
| 6021 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6022 | EVENT("(GLfloat width = %f)", width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6023 | |
| 6024 | try |
| 6025 | { |
| 6026 | if (width <= 0.0f) |
| 6027 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6028 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6029 | } |
| 6030 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6031 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 6032 | |
| 6033 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6034 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6035 | context->setLineWidth(width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6036 | } |
| 6037 | } |
| 6038 | catch(std::bad_alloc&) |
| 6039 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6040 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6041 | } |
| 6042 | } |
| 6043 | |
| 6044 | void __stdcall glLinkProgram(GLuint program) |
| 6045 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6046 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6047 | |
| 6048 | try |
| 6049 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6050 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6051 | |
| 6052 | if (context) |
| 6053 | { |
| 6054 | gl::Program *programObject = context->getProgram(program); |
| 6055 | |
| 6056 | if (!programObject) |
| 6057 | { |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6058 | if (context->getShader(program)) |
| 6059 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6060 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6061 | } |
| 6062 | else |
| 6063 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6064 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6065 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6066 | } |
| 6067 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 6068 | context->linkProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6069 | } |
| 6070 | } |
| 6071 | catch(std::bad_alloc&) |
| 6072 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6073 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6074 | } |
| 6075 | } |
| 6076 | |
| 6077 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 6078 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6079 | EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6080 | |
| 6081 | try |
| 6082 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6083 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6084 | |
| 6085 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6086 | { |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6087 | switch (pname) |
| 6088 | { |
| 6089 | case GL_UNPACK_ALIGNMENT: |
| 6090 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6091 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6092 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6093 | } |
| 6094 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6095 | context->setUnpackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6096 | break; |
| 6097 | |
| 6098 | case GL_PACK_ALIGNMENT: |
| 6099 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6100 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6101 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6102 | } |
| 6103 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6104 | context->setPackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6105 | break; |
| 6106 | |
bsalomon@google.com | 56d46ab | 2011-11-23 14:53:10 +0000 | [diff] [blame] | 6107 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 6108 | context->setPackReverseRowOrder(param != 0); |
| 6109 | break; |
| 6110 | |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6111 | case GL_UNPACK_IMAGE_HEIGHT: |
| 6112 | case GL_UNPACK_SKIP_IMAGES: |
| 6113 | case GL_UNPACK_ROW_LENGTH: |
| 6114 | case GL_UNPACK_SKIP_ROWS: |
| 6115 | case GL_UNPACK_SKIP_PIXELS: |
| 6116 | case GL_PACK_ROW_LENGTH: |
| 6117 | case GL_PACK_SKIP_ROWS: |
| 6118 | case GL_PACK_SKIP_PIXELS: |
| 6119 | if (context->getClientVersion() < 3) |
| 6120 | { |
| 6121 | return gl::error(GL_INVALID_ENUM); |
| 6122 | } |
| 6123 | UNIMPLEMENTED(); |
| 6124 | break; |
| 6125 | |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6126 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6127 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6128 | } |
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 | |
| 6137 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 6138 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6139 | EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6140 | |
| 6141 | try |
| 6142 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6143 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aede630 | 2010-04-29 03:35:48 +0000 | [diff] [blame] | 6144 | |
| 6145 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6146 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6147 | context->setPolygonOffsetParams(factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6148 | } |
| 6149 | } |
| 6150 | catch(std::bad_alloc&) |
| 6151 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6152 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6153 | } |
| 6154 | } |
| 6155 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6156 | void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6157 | GLenum format, GLenum type, GLsizei bufSize, |
| 6158 | GLvoid *data) |
| 6159 | { |
| 6160 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
| 6161 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)", |
| 6162 | x, y, width, height, format, type, bufSize, data); |
| 6163 | |
| 6164 | try |
| 6165 | { |
| 6166 | if (width < 0 || height < 0 || bufSize < 0) |
| 6167 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6168 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6169 | } |
| 6170 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6171 | gl::Context *context = gl::getNonLostContext(); |
| 6172 | |
| 6173 | if (context) |
| 6174 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6175 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6176 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6177 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6178 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6179 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6180 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6181 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6182 | return; |
| 6183 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6184 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6185 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6186 | |
| 6187 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6188 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6189 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6190 | } |
| 6191 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6192 | context->readPixels(x, y, width, height, format, type, &bufSize, data); |
| 6193 | } |
| 6194 | } |
| 6195 | catch(std::bad_alloc&) |
| 6196 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6197 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6198 | } |
| 6199 | } |
| 6200 | |
| 6201 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6202 | GLenum format, GLenum type, GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6203 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6204 | 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] | 6205 | "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] | 6206 | x, y, width, height, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6207 | |
| 6208 | try |
| 6209 | { |
| 6210 | if (width < 0 || height < 0) |
| 6211 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6212 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6213 | } |
| 6214 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6215 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6216 | |
| 6217 | if (context) |
| 6218 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6219 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6220 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6221 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6222 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6223 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6224 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6225 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6226 | return; |
| 6227 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6228 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6229 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6230 | |
| 6231 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6232 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6233 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6234 | } |
| 6235 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6236 | context->readPixels(x, y, width, height, format, type, NULL, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6237 | } |
| 6238 | } |
| 6239 | catch(std::bad_alloc&) |
| 6240 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6241 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6242 | } |
| 6243 | } |
| 6244 | |
| 6245 | void __stdcall glReleaseShaderCompiler(void) |
| 6246 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6247 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6248 | |
| 6249 | try |
| 6250 | { |
| 6251 | gl::Shader::releaseCompiler(); |
| 6252 | } |
| 6253 | catch(std::bad_alloc&) |
| 6254 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6255 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6256 | } |
| 6257 | } |
| 6258 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6259 | 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] | 6260 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6261 | 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] | 6262 | target, samples, internalformat, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6263 | |
| 6264 | try |
| 6265 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6266 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6267 | |
| 6268 | if (context) |
| 6269 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6270 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 6271 | width, height, true)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6272 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6273 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6274 | } |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 6275 | |
| 6276 | context->setRenderbufferStorage(width, height, internalformat, samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6277 | } |
| 6278 | } |
| 6279 | catch(std::bad_alloc&) |
| 6280 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6281 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6282 | } |
| 6283 | } |
| 6284 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6285 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 6286 | { |
| 6287 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height); |
| 6288 | } |
| 6289 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6290 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 6291 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6292 | EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6293 | |
| 6294 | try |
| 6295 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6296 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6297 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6298 | if (context) |
| 6299 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 6300 | context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6301 | } |
| 6302 | } |
| 6303 | catch(std::bad_alloc&) |
| 6304 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6305 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6306 | } |
| 6307 | } |
| 6308 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6309 | void __stdcall glSetFenceNV(GLuint fence, GLenum condition) |
| 6310 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6311 | EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6312 | |
| 6313 | try |
| 6314 | { |
| 6315 | if (condition != GL_ALL_COMPLETED_NV) |
| 6316 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6317 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6318 | } |
| 6319 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6320 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6321 | |
| 6322 | if (context) |
| 6323 | { |
| 6324 | gl::Fence *fenceObject = context->getFence(fence); |
| 6325 | |
| 6326 | if (fenceObject == NULL) |
| 6327 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6328 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6329 | } |
| 6330 | |
| 6331 | fenceObject->setFence(condition); |
| 6332 | } |
| 6333 | } |
| 6334 | catch(std::bad_alloc&) |
| 6335 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6336 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6337 | } |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6338 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6339 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6340 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 6341 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6342 | 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] | 6343 | |
| 6344 | try |
| 6345 | { |
| 6346 | if (width < 0 || height < 0) |
| 6347 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6348 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6349 | } |
| 6350 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6351 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6352 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6353 | if (context) |
| 6354 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6355 | context->setScissorParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6356 | } |
| 6357 | } |
| 6358 | catch(std::bad_alloc&) |
| 6359 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6360 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6361 | } |
| 6362 | } |
| 6363 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6364 | 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] | 6365 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6366 | 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] | 6367 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 6368 | n, shaders, binaryformat, binary, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6369 | |
| 6370 | try |
| 6371 | { |
daniel@transgaming.com | d1f667f | 2010-04-29 03:38:52 +0000 | [diff] [blame] | 6372 | // No binary shader formats are supported. |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6373 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6374 | } |
| 6375 | catch(std::bad_alloc&) |
| 6376 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6377 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6378 | } |
| 6379 | } |
| 6380 | |
shannon.woods%transgaming.com@gtempaccount.com | 5f33933 | 2013-04-13 03:29:02 +0000 | [diff] [blame] | 6381 | 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] | 6382 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6383 | 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] | 6384 | shader, count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6385 | |
| 6386 | try |
| 6387 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6388 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6389 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6390 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6391 | } |
| 6392 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6393 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6394 | |
| 6395 | if (context) |
| 6396 | { |
| 6397 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6398 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6399 | if (!shaderObject) |
| 6400 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6401 | if (context->getProgram(shader)) |
| 6402 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6403 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6404 | } |
| 6405 | else |
| 6406 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6407 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6408 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6409 | } |
| 6410 | |
| 6411 | shaderObject->setSource(count, string, length); |
| 6412 | } |
| 6413 | } |
| 6414 | catch(std::bad_alloc&) |
| 6415 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6416 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6417 | } |
| 6418 | } |
| 6419 | |
| 6420 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 6421 | { |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6422 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6423 | } |
| 6424 | |
| 6425 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 6426 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6427 | 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] | 6428 | |
| 6429 | try |
| 6430 | { |
| 6431 | switch (face) |
| 6432 | { |
| 6433 | case GL_FRONT: |
| 6434 | case GL_BACK: |
| 6435 | case GL_FRONT_AND_BACK: |
| 6436 | break; |
| 6437 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6438 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6439 | } |
| 6440 | |
| 6441 | switch (func) |
| 6442 | { |
| 6443 | case GL_NEVER: |
| 6444 | case GL_ALWAYS: |
| 6445 | case GL_LESS: |
| 6446 | case GL_LEQUAL: |
| 6447 | case GL_EQUAL: |
| 6448 | case GL_GEQUAL: |
| 6449 | case GL_GREATER: |
| 6450 | case GL_NOTEQUAL: |
| 6451 | break; |
| 6452 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6453 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6454 | } |
| 6455 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6456 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6457 | |
| 6458 | if (context) |
| 6459 | { |
| 6460 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6461 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6462 | context->setStencilParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6463 | } |
| 6464 | |
| 6465 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6466 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6467 | context->setStencilBackParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6468 | } |
| 6469 | } |
| 6470 | } |
| 6471 | catch(std::bad_alloc&) |
| 6472 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6473 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6474 | } |
| 6475 | } |
| 6476 | |
| 6477 | void __stdcall glStencilMask(GLuint mask) |
| 6478 | { |
| 6479 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 6480 | } |
| 6481 | |
| 6482 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 6483 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6484 | EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6485 | |
| 6486 | try |
| 6487 | { |
| 6488 | switch (face) |
| 6489 | { |
| 6490 | case GL_FRONT: |
| 6491 | case GL_BACK: |
| 6492 | case GL_FRONT_AND_BACK: |
| 6493 | break; |
| 6494 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6495 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6496 | } |
| 6497 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6498 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6499 | |
| 6500 | if (context) |
| 6501 | { |
| 6502 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6503 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6504 | context->setStencilWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6505 | } |
| 6506 | |
| 6507 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6508 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6509 | context->setStencilBackWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6510 | } |
| 6511 | } |
| 6512 | } |
| 6513 | catch(std::bad_alloc&) |
| 6514 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6515 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6516 | } |
| 6517 | } |
| 6518 | |
| 6519 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 6520 | { |
| 6521 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 6522 | } |
| 6523 | |
| 6524 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 6525 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6526 | 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] | 6527 | face, fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6528 | |
| 6529 | try |
| 6530 | { |
| 6531 | switch (face) |
| 6532 | { |
| 6533 | case GL_FRONT: |
| 6534 | case GL_BACK: |
| 6535 | case GL_FRONT_AND_BACK: |
| 6536 | break; |
| 6537 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6538 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6539 | } |
| 6540 | |
| 6541 | switch (fail) |
| 6542 | { |
| 6543 | case GL_ZERO: |
| 6544 | case GL_KEEP: |
| 6545 | case GL_REPLACE: |
| 6546 | case GL_INCR: |
| 6547 | case GL_DECR: |
| 6548 | case GL_INVERT: |
| 6549 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6550 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6551 | break; |
| 6552 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6553 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6554 | } |
| 6555 | |
| 6556 | switch (zfail) |
| 6557 | { |
| 6558 | case GL_ZERO: |
| 6559 | case GL_KEEP: |
| 6560 | case GL_REPLACE: |
| 6561 | case GL_INCR: |
| 6562 | case GL_DECR: |
| 6563 | case GL_INVERT: |
| 6564 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6565 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6566 | break; |
| 6567 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6568 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6569 | } |
| 6570 | |
| 6571 | switch (zpass) |
| 6572 | { |
| 6573 | case GL_ZERO: |
| 6574 | case GL_KEEP: |
| 6575 | case GL_REPLACE: |
| 6576 | case GL_INCR: |
| 6577 | case GL_DECR: |
| 6578 | case GL_INVERT: |
| 6579 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6580 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6581 | break; |
| 6582 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6583 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6584 | } |
| 6585 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6586 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6587 | |
| 6588 | if (context) |
| 6589 | { |
| 6590 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6591 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6592 | context->setStencilOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6593 | } |
| 6594 | |
| 6595 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6596 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6597 | context->setStencilBackOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6598 | } |
| 6599 | } |
| 6600 | } |
| 6601 | catch(std::bad_alloc&) |
| 6602 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6603 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6604 | } |
| 6605 | } |
| 6606 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6607 | GLboolean __stdcall glTestFenceNV(GLuint fence) |
| 6608 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6609 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6610 | |
| 6611 | try |
| 6612 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6613 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6614 | |
| 6615 | if (context) |
| 6616 | { |
| 6617 | gl::Fence *fenceObject = context->getFence(fence); |
| 6618 | |
| 6619 | if (fenceObject == NULL) |
| 6620 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6621 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6622 | } |
| 6623 | |
| 6624 | return fenceObject->testFence(); |
| 6625 | } |
| 6626 | } |
| 6627 | catch(std::bad_alloc&) |
| 6628 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6629 | gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6630 | } |
| 6631 | |
| 6632 | return GL_TRUE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6633 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6634 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6635 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, |
| 6636 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6637 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6638 | 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] | 6639 | "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] | 6640 | target, level, internalformat, width, height, border, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6641 | |
| 6642 | try |
| 6643 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6644 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6645 | |
| 6646 | if (context) |
| 6647 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6648 | if (context->getClientVersion() < 3 && |
| 6649 | !validateES2TexImageParameters(context, target, level, internalformat, false, false, |
| 6650 | 0, 0, width, height, border, format, type, pixels)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 6651 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6652 | return; |
| 6653 | } |
| 6654 | |
| 6655 | if (context->getClientVersion() >= 3 && |
| 6656 | !validateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 6657 | 0, 0, 0, width, height, 1, border, format, type)) |
| 6658 | { |
| 6659 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 6660 | } |
| 6661 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6662 | switch (target) |
| 6663 | { |
| 6664 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6665 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6666 | gl::Texture2D *texture = context->getTexture2D(); |
| 6667 | texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6668 | } |
| 6669 | break; |
| 6670 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6671 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6672 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 6673 | texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6674 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6675 | break; |
| 6676 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 6677 | { |
| 6678 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6679 | texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6680 | } |
| 6681 | break; |
| 6682 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 6683 | { |
| 6684 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6685 | texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6686 | } |
| 6687 | break; |
| 6688 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 6689 | { |
| 6690 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6691 | texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6692 | } |
| 6693 | break; |
| 6694 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 6695 | { |
| 6696 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6697 | texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6698 | } |
| 6699 | break; |
| 6700 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 6701 | { |
| 6702 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6703 | texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6704 | } |
| 6705 | break; |
| 6706 | default: UNREACHABLE(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6707 | } |
| 6708 | } |
| 6709 | } |
| 6710 | catch(std::bad_alloc&) |
| 6711 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6712 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6713 | } |
| 6714 | } |
| 6715 | |
| 6716 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 6717 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6718 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param); |
| 6719 | |
| 6720 | try |
| 6721 | { |
| 6722 | gl::Context *context = gl::getNonLostContext(); |
| 6723 | |
| 6724 | if (context) |
| 6725 | { |
| 6726 | gl::Texture *texture; |
| 6727 | |
| 6728 | switch (target) |
| 6729 | { |
| 6730 | case GL_TEXTURE_2D: |
| 6731 | texture = context->getTexture2D(); |
| 6732 | break; |
| 6733 | case GL_TEXTURE_CUBE_MAP: |
| 6734 | texture = context->getTextureCubeMap(); |
| 6735 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 6736 | case GL_TEXTURE_3D: |
| 6737 | if (context->getClientVersion() < 3) |
| 6738 | { |
| 6739 | return gl::error(GL_INVALID_ENUM); |
| 6740 | } |
| 6741 | texture = context->getTexture3D(); |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 6742 | case GL_TEXTURE_2D_ARRAY: |
| 6743 | if (context->getClientVersion() < 3) |
| 6744 | { |
| 6745 | return gl::error(GL_INVALID_ENUM); |
| 6746 | } |
| 6747 | texture = context->getTexture2DArray(); |
| 6748 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6749 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6750 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6751 | } |
| 6752 | |
| 6753 | switch (pname) |
| 6754 | { |
| 6755 | case GL_TEXTURE_WRAP_S: |
| 6756 | if (!texture->setWrapS((GLenum)param)) |
| 6757 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6758 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6759 | } |
| 6760 | break; |
| 6761 | case GL_TEXTURE_WRAP_T: |
| 6762 | if (!texture->setWrapT((GLenum)param)) |
| 6763 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6764 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6765 | } |
| 6766 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 6767 | case GL_TEXTURE_WRAP_R: |
| 6768 | if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param)) |
| 6769 | { |
| 6770 | return gl::error(GL_INVALID_ENUM); |
| 6771 | } |
| 6772 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6773 | case GL_TEXTURE_MIN_FILTER: |
| 6774 | if (!texture->setMinFilter((GLenum)param)) |
| 6775 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6776 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6777 | } |
| 6778 | break; |
| 6779 | case GL_TEXTURE_MAG_FILTER: |
| 6780 | if (!texture->setMagFilter((GLenum)param)) |
| 6781 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6782 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6783 | } |
| 6784 | break; |
| 6785 | case GL_TEXTURE_USAGE_ANGLE: |
| 6786 | if (!texture->setUsage((GLenum)param)) |
| 6787 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6788 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6789 | } |
| 6790 | break; |
| 6791 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 6792 | if (!context->supportsTextureFilterAnisotropy()) |
| 6793 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6794 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6795 | } |
| 6796 | if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy())) |
| 6797 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6798 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6799 | } |
| 6800 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6801 | |
| 6802 | case GL_TEXTURE_MIN_LOD: |
| 6803 | case GL_TEXTURE_MAX_LOD: |
| 6804 | if (context->getClientVersion() < 3) |
| 6805 | { |
| 6806 | return gl::error(GL_INVALID_ENUM); |
| 6807 | } |
| 6808 | UNIMPLEMENTED(); |
| 6809 | break; |
| 6810 | |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6811 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6812 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6813 | } |
| 6814 | } |
| 6815 | } |
| 6816 | catch(std::bad_alloc&) |
| 6817 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6818 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6819 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6820 | } |
| 6821 | |
| 6822 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 6823 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6824 | glTexParameterf(target, pname, (GLfloat)*params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6825 | } |
| 6826 | |
| 6827 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 6828 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6829 | 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] | 6830 | |
| 6831 | try |
| 6832 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6833 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6834 | |
| 6835 | if (context) |
| 6836 | { |
| 6837 | gl::Texture *texture; |
| 6838 | |
| 6839 | switch (target) |
| 6840 | { |
| 6841 | case GL_TEXTURE_2D: |
| 6842 | texture = context->getTexture2D(); |
| 6843 | break; |
| 6844 | case GL_TEXTURE_CUBE_MAP: |
| 6845 | texture = context->getTextureCubeMap(); |
| 6846 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 6847 | case GL_TEXTURE_3D: |
| 6848 | if (context->getClientVersion() < 3) |
| 6849 | { |
| 6850 | return gl::error(GL_INVALID_ENUM); |
| 6851 | } |
| 6852 | texture = context->getTexture3D(); |
| 6853 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 6854 | case GL_TEXTURE_2D_ARRAY: |
| 6855 | if (context->getClientVersion() < 3) |
| 6856 | { |
| 6857 | return gl::error(GL_INVALID_ENUM); |
| 6858 | } |
| 6859 | texture = context->getTexture2DArray(); |
| 6860 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6861 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6862 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6863 | } |
| 6864 | |
| 6865 | switch (pname) |
| 6866 | { |
| 6867 | case GL_TEXTURE_WRAP_S: |
| 6868 | if (!texture->setWrapS((GLenum)param)) |
| 6869 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6870 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6871 | } |
| 6872 | break; |
| 6873 | case GL_TEXTURE_WRAP_T: |
| 6874 | if (!texture->setWrapT((GLenum)param)) |
| 6875 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6876 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6877 | } |
| 6878 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 6879 | case GL_TEXTURE_WRAP_R: |
| 6880 | if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param)) |
| 6881 | { |
| 6882 | return gl::error(GL_INVALID_ENUM); |
| 6883 | } |
| 6884 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6885 | case GL_TEXTURE_MIN_FILTER: |
| 6886 | if (!texture->setMinFilter((GLenum)param)) |
| 6887 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6888 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6889 | } |
| 6890 | break; |
| 6891 | case GL_TEXTURE_MAG_FILTER: |
| 6892 | if (!texture->setMagFilter((GLenum)param)) |
| 6893 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6894 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6895 | } |
| 6896 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 6897 | case GL_TEXTURE_USAGE_ANGLE: |
| 6898 | if (!texture->setUsage((GLenum)param)) |
| 6899 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6900 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 6901 | } |
| 6902 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6903 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 6904 | if (!context->supportsTextureFilterAnisotropy()) |
| 6905 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6906 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6907 | } |
| 6908 | if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy())) |
| 6909 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6910 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6911 | } |
| 6912 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6913 | |
| 6914 | case GL_TEXTURE_SWIZZLE_R: |
| 6915 | case GL_TEXTURE_SWIZZLE_G: |
| 6916 | case GL_TEXTURE_SWIZZLE_B: |
| 6917 | case GL_TEXTURE_SWIZZLE_A: |
| 6918 | case GL_TEXTURE_BASE_LEVEL: |
| 6919 | case GL_TEXTURE_MAX_LEVEL: |
| 6920 | case GL_TEXTURE_COMPARE_MODE: |
| 6921 | case GL_TEXTURE_COMPARE_FUNC: |
| 6922 | if (context->getClientVersion() < 3) |
| 6923 | { |
| 6924 | return gl::error(GL_INVALID_ENUM); |
| 6925 | } |
| 6926 | UNIMPLEMENTED(); |
| 6927 | break; |
| 6928 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6929 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6930 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6931 | } |
| 6932 | } |
| 6933 | } |
| 6934 | catch(std::bad_alloc&) |
| 6935 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6936 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6937 | } |
| 6938 | } |
| 6939 | |
| 6940 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 6941 | { |
| 6942 | glTexParameteri(target, pname, *params); |
| 6943 | } |
| 6944 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6945 | void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 6946 | { |
| 6947 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 6948 | target, levels, internalformat, width, height); |
| 6949 | |
| 6950 | try |
| 6951 | { |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6952 | gl::Context *context = gl::getNonLostContext(); |
| 6953 | |
| 6954 | if (context) |
| 6955 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6956 | if (context->getClientVersion() < 3 && |
| 6957 | !validateES2TexStorageParameters(context, target, levels, internalformat, width, height)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6958 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6959 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6960 | } |
| 6961 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6962 | if (context->getClientVersion() >= 3 && |
| 6963 | !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6964 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6965 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6966 | } |
| 6967 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6968 | switch (target) |
| 6969 | { |
| 6970 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6971 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6972 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 6973 | texture2d->storage(levels, internalformat, width, height); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6974 | } |
| 6975 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6976 | |
| 6977 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 6978 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 6979 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 6980 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 6981 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 6982 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6983 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6984 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 6985 | textureCube->storage(levels, internalformat, width); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6986 | } |
| 6987 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6988 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6989 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6990 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6991 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6992 | } |
| 6993 | } |
| 6994 | catch(std::bad_alloc&) |
| 6995 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6996 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6997 | } |
| 6998 | } |
| 6999 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7000 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 7001 | GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7002 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7003 | 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] | 7004 | "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] | 7005 | "const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7006 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 7007 | |
| 7008 | try |
| 7009 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7010 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7011 | |
| 7012 | if (context) |
| 7013 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7014 | if (context->getClientVersion() < 3 && |
| 7015 | !validateES2TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7016 | 0, 0, width, height, 0, format, type, pixels)) |
daniel@transgaming.com | 1d2d3c4 | 2012-05-31 01:14:15 +0000 | [diff] [blame] | 7017 | { |
| 7018 | return; |
| 7019 | } |
| 7020 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7021 | if (context->getClientVersion() >= 3 && |
| 7022 | !validateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7023 | 0, 0, 0, width, height, 1, 0, format, type)) |
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 | return; |
| 7026 | } |
| 7027 | |
| 7028 | switch (target) |
| 7029 | { |
| 7030 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7031 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7032 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7033 | 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] | 7034 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7035 | break; |
| 7036 | |
| 7037 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7038 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7039 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7040 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7041 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7042 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7043 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7044 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7045 | 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] | 7046 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7047 | break; |
| 7048 | |
| 7049 | default: |
| 7050 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7051 | } |
| 7052 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7053 | } |
| 7054 | catch(std::bad_alloc&) |
| 7055 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7056 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7057 | } |
| 7058 | } |
| 7059 | |
| 7060 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 7061 | { |
| 7062 | glUniform1fv(location, 1, &x); |
| 7063 | } |
| 7064 | |
| 7065 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 7066 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7067 | 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] | 7068 | |
| 7069 | try |
| 7070 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7071 | if (count < 0) |
| 7072 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7073 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7074 | } |
| 7075 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7076 | if (location == -1) |
| 7077 | { |
| 7078 | return; |
| 7079 | } |
| 7080 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7081 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7082 | |
| 7083 | if (context) |
| 7084 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7085 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7086 | if (!programBinary) |
| 7087 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7088 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7089 | } |
| 7090 | |
| 7091 | if (!programBinary->setUniform1fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7092 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7093 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7094 | } |
| 7095 | } |
| 7096 | } |
| 7097 | catch(std::bad_alloc&) |
| 7098 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7099 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7100 | } |
| 7101 | } |
| 7102 | |
| 7103 | void __stdcall glUniform1i(GLint location, GLint x) |
| 7104 | { |
| 7105 | glUniform1iv(location, 1, &x); |
| 7106 | } |
| 7107 | |
| 7108 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 7109 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7110 | 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] | 7111 | |
| 7112 | try |
| 7113 | { |
| 7114 | if (count < 0) |
| 7115 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7116 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7117 | } |
| 7118 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7119 | if (location == -1) |
| 7120 | { |
| 7121 | return; |
| 7122 | } |
| 7123 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7124 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7125 | |
| 7126 | if (context) |
| 7127 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7128 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7129 | if (!programBinary) |
| 7130 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7131 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7132 | } |
| 7133 | |
| 7134 | if (!programBinary->setUniform1iv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7135 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7136 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7137 | } |
| 7138 | } |
| 7139 | } |
| 7140 | catch(std::bad_alloc&) |
| 7141 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7142 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7143 | } |
| 7144 | } |
| 7145 | |
| 7146 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 7147 | { |
| 7148 | GLfloat xy[2] = {x, y}; |
| 7149 | |
| 7150 | glUniform2fv(location, 1, (GLfloat*)&xy); |
| 7151 | } |
| 7152 | |
| 7153 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 7154 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7155 | 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] | 7156 | |
| 7157 | try |
| 7158 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7159 | if (count < 0) |
| 7160 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7161 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7162 | } |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7163 | |
| 7164 | if (location == -1) |
| 7165 | { |
| 7166 | return; |
| 7167 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7168 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7169 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7170 | |
| 7171 | if (context) |
| 7172 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7173 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7174 | if (!programBinary) |
| 7175 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7176 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7177 | } |
| 7178 | |
| 7179 | if (!programBinary->setUniform2fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7180 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7181 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7182 | } |
| 7183 | } |
| 7184 | } |
| 7185 | catch(std::bad_alloc&) |
| 7186 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7187 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7188 | } |
| 7189 | } |
| 7190 | |
| 7191 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 7192 | { |
| 7193 | GLint xy[4] = {x, y}; |
| 7194 | |
| 7195 | glUniform2iv(location, 1, (GLint*)&xy); |
| 7196 | } |
| 7197 | |
| 7198 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 7199 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7200 | 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] | 7201 | |
| 7202 | try |
| 7203 | { |
| 7204 | if (count < 0) |
| 7205 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7206 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7207 | } |
| 7208 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7209 | if (location == -1) |
| 7210 | { |
| 7211 | return; |
| 7212 | } |
| 7213 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7214 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7215 | |
| 7216 | if (context) |
| 7217 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7218 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7219 | if (!programBinary) |
| 7220 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7221 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7222 | } |
| 7223 | |
| 7224 | if (!programBinary->setUniform2iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7225 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7226 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7227 | } |
| 7228 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7229 | } |
| 7230 | catch(std::bad_alloc&) |
| 7231 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7232 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7233 | } |
| 7234 | } |
| 7235 | |
| 7236 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 7237 | { |
| 7238 | GLfloat xyz[3] = {x, y, z}; |
| 7239 | |
| 7240 | glUniform3fv(location, 1, (GLfloat*)&xyz); |
| 7241 | } |
| 7242 | |
| 7243 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 7244 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7245 | 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] | 7246 | |
| 7247 | try |
| 7248 | { |
| 7249 | if (count < 0) |
| 7250 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7251 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7252 | } |
| 7253 | |
| 7254 | if (location == -1) |
| 7255 | { |
| 7256 | return; |
| 7257 | } |
| 7258 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7259 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7260 | |
| 7261 | if (context) |
| 7262 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7263 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7264 | if (!programBinary) |
| 7265 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7266 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7267 | } |
| 7268 | |
| 7269 | if (!programBinary->setUniform3fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7270 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7271 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7272 | } |
| 7273 | } |
| 7274 | } |
| 7275 | catch(std::bad_alloc&) |
| 7276 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7277 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7278 | } |
| 7279 | } |
| 7280 | |
| 7281 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 7282 | { |
| 7283 | GLint xyz[3] = {x, y, z}; |
| 7284 | |
| 7285 | glUniform3iv(location, 1, (GLint*)&xyz); |
| 7286 | } |
| 7287 | |
| 7288 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 7289 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7290 | 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] | 7291 | |
| 7292 | try |
| 7293 | { |
| 7294 | if (count < 0) |
| 7295 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7296 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7297 | } |
| 7298 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7299 | if (location == -1) |
| 7300 | { |
| 7301 | return; |
| 7302 | } |
| 7303 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7304 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7305 | |
| 7306 | if (context) |
| 7307 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7308 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7309 | if (!programBinary) |
| 7310 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7311 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7312 | } |
| 7313 | |
| 7314 | if (!programBinary->setUniform3iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7315 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7316 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7317 | } |
| 7318 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7319 | } |
| 7320 | catch(std::bad_alloc&) |
| 7321 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7322 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7323 | } |
| 7324 | } |
| 7325 | |
| 7326 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7327 | { |
| 7328 | GLfloat xyzw[4] = {x, y, z, w}; |
| 7329 | |
| 7330 | glUniform4fv(location, 1, (GLfloat*)&xyzw); |
| 7331 | } |
| 7332 | |
| 7333 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 7334 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7335 | 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] | 7336 | |
| 7337 | try |
| 7338 | { |
| 7339 | if (count < 0) |
| 7340 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7341 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7342 | } |
| 7343 | |
| 7344 | if (location == -1) |
| 7345 | { |
| 7346 | return; |
| 7347 | } |
| 7348 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7349 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7350 | |
| 7351 | if (context) |
| 7352 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7353 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7354 | if (!programBinary) |
| 7355 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7356 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7357 | } |
| 7358 | |
| 7359 | if (!programBinary->setUniform4fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7360 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7361 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7362 | } |
| 7363 | } |
| 7364 | } |
| 7365 | catch(std::bad_alloc&) |
| 7366 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7367 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7368 | } |
| 7369 | } |
| 7370 | |
| 7371 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 7372 | { |
| 7373 | GLint xyzw[4] = {x, y, z, w}; |
| 7374 | |
| 7375 | glUniform4iv(location, 1, (GLint*)&xyzw); |
| 7376 | } |
| 7377 | |
| 7378 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 7379 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7380 | 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] | 7381 | |
| 7382 | try |
| 7383 | { |
| 7384 | if (count < 0) |
| 7385 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7386 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7387 | } |
| 7388 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7389 | if (location == -1) |
| 7390 | { |
| 7391 | return; |
| 7392 | } |
| 7393 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7394 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7395 | |
| 7396 | if (context) |
| 7397 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7398 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7399 | if (!programBinary) |
| 7400 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7401 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7402 | } |
| 7403 | |
| 7404 | if (!programBinary->setUniform4iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7405 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7406 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7407 | } |
| 7408 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7409 | } |
| 7410 | catch(std::bad_alloc&) |
| 7411 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7412 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7413 | } |
| 7414 | } |
| 7415 | |
| 7416 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7417 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7418 | 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] | 7419 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7420 | |
| 7421 | try |
| 7422 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7423 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7424 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7425 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7426 | } |
| 7427 | |
| 7428 | if (location == -1) |
| 7429 | { |
| 7430 | return; |
| 7431 | } |
| 7432 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7433 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7434 | |
| 7435 | if (context) |
| 7436 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7437 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7438 | { |
| 7439 | return gl::error(GL_INVALID_VALUE); |
| 7440 | } |
| 7441 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7442 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7443 | if (!programBinary) |
| 7444 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7445 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7446 | } |
| 7447 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7448 | if (!programBinary->setUniformMatrix2fv(location, count, transpose, value)) |
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_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7451 | } |
| 7452 | } |
| 7453 | } |
| 7454 | catch(std::bad_alloc&) |
| 7455 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7456 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7457 | } |
| 7458 | } |
| 7459 | |
| 7460 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7461 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7462 | 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] | 7463 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7464 | |
| 7465 | try |
| 7466 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7467 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7468 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7469 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7470 | } |
| 7471 | |
| 7472 | if (location == -1) |
| 7473 | { |
| 7474 | return; |
| 7475 | } |
| 7476 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7477 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7478 | |
| 7479 | if (context) |
| 7480 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7481 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7482 | { |
| 7483 | return gl::error(GL_INVALID_VALUE); |
| 7484 | } |
| 7485 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7486 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7487 | if (!programBinary) |
| 7488 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7489 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7490 | } |
| 7491 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7492 | if (!programBinary->setUniformMatrix3fv(location, count, transpose, value)) |
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_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7495 | } |
| 7496 | } |
| 7497 | } |
| 7498 | catch(std::bad_alloc&) |
| 7499 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7500 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7501 | } |
| 7502 | } |
| 7503 | |
| 7504 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7505 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7506 | 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] | 7507 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7508 | |
| 7509 | try |
| 7510 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7511 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7512 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7513 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7514 | } |
| 7515 | |
| 7516 | if (location == -1) |
| 7517 | { |
| 7518 | return; |
| 7519 | } |
| 7520 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7521 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7522 | |
| 7523 | if (context) |
| 7524 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7525 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7526 | { |
| 7527 | return gl::error(GL_INVALID_VALUE); |
| 7528 | } |
| 7529 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7530 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7531 | if (!programBinary) |
| 7532 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7533 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7534 | } |
| 7535 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7536 | if (!programBinary->setUniformMatrix4fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7537 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7538 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7539 | } |
| 7540 | } |
| 7541 | } |
| 7542 | catch(std::bad_alloc&) |
| 7543 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7544 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7545 | } |
| 7546 | } |
| 7547 | |
| 7548 | void __stdcall glUseProgram(GLuint program) |
| 7549 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7550 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7551 | |
| 7552 | try |
| 7553 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7554 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7555 | |
| 7556 | if (context) |
| 7557 | { |
| 7558 | gl::Program *programObject = context->getProgram(program); |
| 7559 | |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7560 | if (!programObject && program != 0) |
| 7561 | { |
| 7562 | if (context->getShader(program)) |
| 7563 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7564 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7565 | } |
| 7566 | else |
| 7567 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7568 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7569 | } |
| 7570 | } |
| 7571 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 7572 | if (program != 0 && !programObject->isLinked()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7573 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7574 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7575 | } |
| 7576 | |
| 7577 | context->useProgram(program); |
| 7578 | } |
| 7579 | } |
| 7580 | catch(std::bad_alloc&) |
| 7581 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7582 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7583 | } |
| 7584 | } |
| 7585 | |
| 7586 | void __stdcall glValidateProgram(GLuint program) |
| 7587 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7588 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7589 | |
| 7590 | try |
| 7591 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7592 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7593 | |
| 7594 | if (context) |
| 7595 | { |
| 7596 | gl::Program *programObject = context->getProgram(program); |
| 7597 | |
| 7598 | if (!programObject) |
| 7599 | { |
| 7600 | if (context->getShader(program)) |
| 7601 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7602 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7603 | } |
| 7604 | else |
| 7605 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7606 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7607 | } |
| 7608 | } |
| 7609 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 7610 | programObject->validate(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7611 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7612 | } |
| 7613 | catch(std::bad_alloc&) |
| 7614 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7615 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7616 | } |
| 7617 | } |
| 7618 | |
| 7619 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 7620 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7621 | EVENT("(GLuint index = %d, GLfloat x = %f)", index, x); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7622 | |
| 7623 | try |
| 7624 | { |
| 7625 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7626 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7627 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7628 | } |
| 7629 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7630 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7631 | |
| 7632 | if (context) |
| 7633 | { |
| 7634 | GLfloat vals[4] = { x, 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7635 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7636 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7637 | } |
| 7638 | catch(std::bad_alloc&) |
| 7639 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7640 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7641 | } |
| 7642 | } |
| 7643 | |
| 7644 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 7645 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7646 | 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] | 7647 | |
| 7648 | try |
| 7649 | { |
| 7650 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7651 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7652 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7653 | } |
| 7654 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7655 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7656 | |
| 7657 | if (context) |
| 7658 | { |
| 7659 | GLfloat vals[4] = { values[0], 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7660 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7661 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7662 | } |
| 7663 | catch(std::bad_alloc&) |
| 7664 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7665 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7666 | } |
| 7667 | } |
| 7668 | |
| 7669 | void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 7670 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7671 | 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] | 7672 | |
| 7673 | try |
| 7674 | { |
| 7675 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7676 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7677 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7678 | } |
| 7679 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7680 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7681 | |
| 7682 | if (context) |
| 7683 | { |
| 7684 | GLfloat vals[4] = { x, y, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7685 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7686 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7687 | } |
| 7688 | catch(std::bad_alloc&) |
| 7689 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7690 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7691 | } |
| 7692 | } |
| 7693 | |
| 7694 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 7695 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7696 | 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] | 7697 | |
| 7698 | try |
| 7699 | { |
| 7700 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7701 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7702 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7703 | } |
| 7704 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7705 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7706 | |
| 7707 | if (context) |
| 7708 | { |
| 7709 | 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] | 7710 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7711 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7712 | } |
| 7713 | catch(std::bad_alloc&) |
| 7714 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7715 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7716 | } |
| 7717 | } |
| 7718 | |
| 7719 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 7720 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7721 | 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] | 7722 | |
| 7723 | try |
| 7724 | { |
| 7725 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7726 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7727 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7728 | } |
| 7729 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7730 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7731 | |
| 7732 | if (context) |
| 7733 | { |
| 7734 | GLfloat vals[4] = { x, y, z, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7735 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7736 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7737 | } |
| 7738 | catch(std::bad_alloc&) |
| 7739 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7740 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7741 | } |
| 7742 | } |
| 7743 | |
| 7744 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 7745 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7746 | 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] | 7747 | |
| 7748 | try |
| 7749 | { |
| 7750 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7751 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7752 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7753 | } |
| 7754 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7755 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7756 | |
| 7757 | if (context) |
| 7758 | { |
| 7759 | 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] | 7760 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7761 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7762 | } |
| 7763 | catch(std::bad_alloc&) |
| 7764 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7765 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7766 | } |
| 7767 | } |
| 7768 | |
| 7769 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7770 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7771 | 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] | 7772 | |
| 7773 | try |
| 7774 | { |
| 7775 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7776 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7777 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7778 | } |
| 7779 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7780 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7781 | |
| 7782 | if (context) |
| 7783 | { |
| 7784 | GLfloat vals[4] = { x, y, z, w }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7785 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7786 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7787 | } |
| 7788 | catch(std::bad_alloc&) |
| 7789 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7790 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7791 | } |
| 7792 | } |
| 7793 | |
| 7794 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 7795 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7796 | 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] | 7797 | |
| 7798 | try |
| 7799 | { |
| 7800 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7801 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7802 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7803 | } |
| 7804 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7805 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7806 | |
| 7807 | if (context) |
| 7808 | { |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7809 | context->setVertexAttribf(index, values); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7810 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7811 | } |
| 7812 | catch(std::bad_alloc&) |
| 7813 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7814 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7815 | } |
| 7816 | } |
| 7817 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 7818 | void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
| 7819 | { |
| 7820 | EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor); |
| 7821 | |
| 7822 | try |
| 7823 | { |
| 7824 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7825 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7826 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 7827 | } |
| 7828 | |
| 7829 | gl::Context *context = gl::getNonLostContext(); |
| 7830 | |
| 7831 | if (context) |
| 7832 | { |
| 7833 | context->setVertexAttribDivisor(index, divisor); |
| 7834 | } |
| 7835 | } |
| 7836 | catch(std::bad_alloc&) |
| 7837 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7838 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 7839 | } |
| 7840 | } |
| 7841 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7842 | 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] | 7843 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7844 | 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] | 7845 | "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] | 7846 | index, size, type, normalized, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7847 | |
| 7848 | try |
| 7849 | { |
| 7850 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7851 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7852 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7853 | } |
| 7854 | |
| 7855 | if (size < 1 || size > 4) |
| 7856 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7857 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7858 | } |
| 7859 | |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 7860 | gl::Context *context = gl::getNonLostContext(); |
| 7861 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7862 | switch (type) |
| 7863 | { |
| 7864 | case GL_BYTE: |
| 7865 | case GL_UNSIGNED_BYTE: |
| 7866 | case GL_SHORT: |
| 7867 | case GL_UNSIGNED_SHORT: |
| 7868 | case GL_FIXED: |
| 7869 | case GL_FLOAT: |
| 7870 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 7871 | case GL_HALF_FLOAT: |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7872 | case GL_INT: |
| 7873 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 7874 | case GL_INT_2_10_10_10_REV: |
| 7875 | 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] | 7876 | if (context && context->getClientVersion() < 3) |
| 7877 | { |
| 7878 | return gl::error(GL_INVALID_ENUM); |
| 7879 | } |
| 7880 | else |
| 7881 | { |
| 7882 | break; |
| 7883 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7884 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7885 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7886 | } |
| 7887 | |
| 7888 | if (stride < 0) |
| 7889 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7890 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7891 | } |
| 7892 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 7893 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 7894 | { |
| 7895 | return gl::error(GL_INVALID_OPERATION); |
| 7896 | } |
| 7897 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7898 | if (context) |
| 7899 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8de4e6a | 2013-04-13 03:37:44 +0000 | [diff] [blame] | 7900 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, |
| 7901 | normalized == GL_TRUE, false, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7902 | } |
| 7903 | } |
| 7904 | catch(std::bad_alloc&) |
| 7905 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7906 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7907 | } |
| 7908 | } |
| 7909 | |
| 7910 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 7911 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7912 | 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] | 7913 | |
| 7914 | try |
| 7915 | { |
| 7916 | if (width < 0 || height < 0) |
| 7917 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7918 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7919 | } |
| 7920 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7921 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7922 | |
| 7923 | if (context) |
| 7924 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7925 | context->setViewportParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7926 | } |
| 7927 | } |
| 7928 | catch(std::bad_alloc&) |
| 7929 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7930 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7931 | } |
| 7932 | } |
| 7933 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7934 | // OpenGL ES 3.0 functions |
| 7935 | |
| 7936 | void __stdcall glReadBuffer(GLenum mode) |
| 7937 | { |
| 7938 | EVENT("(GLenum mode = 0x%X)", mode); |
| 7939 | |
| 7940 | try |
| 7941 | { |
| 7942 | gl::Context *context = gl::getNonLostContext(); |
| 7943 | |
| 7944 | if (context) |
| 7945 | { |
| 7946 | if (context->getClientVersion() < 3) |
| 7947 | { |
| 7948 | return gl::error(GL_INVALID_OPERATION); |
| 7949 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7950 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7951 | UNIMPLEMENTED(); |
| 7952 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7953 | } |
| 7954 | catch(std::bad_alloc&) |
| 7955 | { |
| 7956 | return gl::error(GL_OUT_OF_MEMORY); |
| 7957 | } |
| 7958 | } |
| 7959 | |
| 7960 | void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) |
| 7961 | { |
| 7962 | EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, " |
| 7963 | "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices); |
| 7964 | |
| 7965 | try |
| 7966 | { |
| 7967 | gl::Context *context = gl::getNonLostContext(); |
| 7968 | |
| 7969 | if (context) |
| 7970 | { |
| 7971 | if (context->getClientVersion() < 3) |
| 7972 | { |
| 7973 | return gl::error(GL_INVALID_OPERATION); |
| 7974 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7975 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7976 | UNIMPLEMENTED(); |
| 7977 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7978 | } |
| 7979 | catch(std::bad_alloc&) |
| 7980 | { |
| 7981 | return gl::error(GL_OUT_OF_MEMORY); |
| 7982 | } |
| 7983 | } |
| 7984 | |
| 7985 | void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
| 7986 | { |
| 7987 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 7988 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " |
| 7989 | "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 7990 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 7991 | |
| 7992 | try |
| 7993 | { |
| 7994 | gl::Context *context = gl::getNonLostContext(); |
| 7995 | |
| 7996 | if (context) |
| 7997 | { |
| 7998 | if (context->getClientVersion() < 3) |
| 7999 | { |
| 8000 | return gl::error(GL_INVALID_OPERATION); |
| 8001 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8002 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8003 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8004 | if (!validateES3TexImageParameters(context, target, level, internalformat, false, false, |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8005 | 0, 0, 0, width, height, depth, border, format, type)) |
| 8006 | { |
| 8007 | return; |
| 8008 | } |
| 8009 | |
| 8010 | switch(target) |
| 8011 | { |
| 8012 | case GL_TEXTURE_3D: |
| 8013 | { |
| 8014 | gl::Texture3D *texture = context->getTexture3D(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8015 | 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] | 8016 | } |
| 8017 | break; |
| 8018 | |
| 8019 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8020 | { |
| 8021 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8022 | 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] | 8023 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8024 | break; |
| 8025 | |
| 8026 | default: |
| 8027 | return gl::error(GL_INVALID_ENUM); |
| 8028 | } |
| 8029 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8030 | } |
| 8031 | catch(std::bad_alloc&) |
| 8032 | { |
| 8033 | return gl::error(GL_OUT_OF_MEMORY); |
| 8034 | } |
| 8035 | } |
| 8036 | |
| 8037 | 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) |
| 8038 | { |
| 8039 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8040 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8041 | "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8042 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); |
| 8043 | |
| 8044 | try |
| 8045 | { |
| 8046 | gl::Context *context = gl::getNonLostContext(); |
| 8047 | |
| 8048 | if (context) |
| 8049 | { |
| 8050 | if (context->getClientVersion() < 3) |
| 8051 | { |
| 8052 | return gl::error(GL_INVALID_OPERATION); |
| 8053 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8054 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8055 | if (!pixels) |
| 8056 | { |
| 8057 | return gl::error(GL_INVALID_VALUE); |
| 8058 | } |
| 8059 | |
| 8060 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8061 | 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] | 8062 | xoffset, yoffset, zoffset, width, height, depth, 0, |
| 8063 | format, type)) |
| 8064 | { |
| 8065 | return; |
| 8066 | } |
| 8067 | |
| 8068 | switch(target) |
| 8069 | { |
| 8070 | case GL_TEXTURE_3D: |
| 8071 | { |
| 8072 | gl::Texture3D *texture = context->getTexture3D(); |
| 8073 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8074 | } |
| 8075 | break; |
| 8076 | |
| 8077 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8078 | { |
| 8079 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8080 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8081 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8082 | break; |
| 8083 | |
| 8084 | default: |
| 8085 | return gl::error(GL_INVALID_ENUM); |
| 8086 | } |
| 8087 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8088 | } |
| 8089 | catch(std::bad_alloc&) |
| 8090 | { |
| 8091 | return gl::error(GL_OUT_OF_MEMORY); |
| 8092 | } |
| 8093 | } |
| 8094 | |
| 8095 | void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 8096 | { |
| 8097 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8098 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 8099 | target, level, xoffset, yoffset, zoffset, x, y, width, height); |
| 8100 | |
| 8101 | try |
| 8102 | { |
| 8103 | gl::Context *context = gl::getNonLostContext(); |
| 8104 | |
| 8105 | if (context) |
| 8106 | { |
| 8107 | if (context->getClientVersion() < 3) |
| 8108 | { |
| 8109 | return gl::error(GL_INVALID_OPERATION); |
| 8110 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8111 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8112 | if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset, |
| 8113 | x, y, width, height, 0)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8114 | { |
| 8115 | return; |
| 8116 | } |
| 8117 | |
| 8118 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 8119 | gl::Texture *texture = NULL; |
| 8120 | switch (target) |
| 8121 | { |
| 8122 | case GL_TEXTURE_3D: |
| 8123 | texture = context->getTexture3D(); |
| 8124 | break; |
| 8125 | |
| 8126 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8127 | texture = context->getTexture2DArray(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8128 | break; |
| 8129 | |
| 8130 | default: |
| 8131 | return gl::error(GL_INVALID_ENUM); |
| 8132 | } |
| 8133 | |
| 8134 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer); |
| 8135 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8136 | } |
| 8137 | catch(std::bad_alloc&) |
| 8138 | { |
| 8139 | return gl::error(GL_OUT_OF_MEMORY); |
| 8140 | } |
| 8141 | } |
| 8142 | |
| 8143 | void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) |
| 8144 | { |
| 8145 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8146 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, " |
| 8147 | "const GLvoid* data = 0x%0.8p)", |
| 8148 | target, level, internalformat, width, height, depth, border, imageSize, data); |
| 8149 | |
| 8150 | try |
| 8151 | { |
| 8152 | gl::Context *context = gl::getNonLostContext(); |
| 8153 | |
| 8154 | if (context) |
| 8155 | { |
| 8156 | if (context->getClientVersion() < 3) |
| 8157 | { |
| 8158 | return gl::error(GL_INVALID_OPERATION); |
| 8159 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8160 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8161 | 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] | 8162 | { |
| 8163 | return gl::error(GL_INVALID_VALUE); |
| 8164 | } |
| 8165 | |
| 8166 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8167 | if (!validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 8168 | 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] | 8169 | { |
| 8170 | return; |
| 8171 | } |
| 8172 | |
| 8173 | switch(target) |
| 8174 | { |
| 8175 | case GL_TEXTURE_3D: |
| 8176 | { |
| 8177 | gl::Texture3D *texture = context->getTexture3D(); |
| 8178 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8179 | } |
| 8180 | break; |
| 8181 | |
| 8182 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8183 | { |
| 8184 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8185 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8186 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8187 | break; |
| 8188 | |
| 8189 | default: |
| 8190 | return gl::error(GL_INVALID_ENUM); |
| 8191 | } |
| 8192 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8193 | } |
| 8194 | catch(std::bad_alloc&) |
| 8195 | { |
| 8196 | return gl::error(GL_OUT_OF_MEMORY); |
| 8197 | } |
| 8198 | } |
| 8199 | |
| 8200 | 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) |
| 8201 | { |
| 8202 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8203 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8204 | "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 8205 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); |
| 8206 | |
| 8207 | try |
| 8208 | { |
| 8209 | gl::Context *context = gl::getNonLostContext(); |
| 8210 | |
| 8211 | if (context) |
| 8212 | { |
| 8213 | if (context->getClientVersion() < 3) |
| 8214 | { |
| 8215 | return gl::error(GL_INVALID_OPERATION); |
| 8216 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8217 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8218 | 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] | 8219 | { |
| 8220 | return gl::error(GL_INVALID_VALUE); |
| 8221 | } |
| 8222 | |
| 8223 | if (!data) |
| 8224 | { |
| 8225 | return gl::error(GL_INVALID_VALUE); |
| 8226 | } |
| 8227 | |
| 8228 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8229 | if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 8230 | 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] | 8231 | { |
| 8232 | return; |
| 8233 | } |
| 8234 | |
| 8235 | switch(target) |
| 8236 | { |
| 8237 | case GL_TEXTURE_3D: |
| 8238 | { |
| 8239 | gl::Texture3D *texture = context->getTexture3D(); |
| 8240 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8241 | format, imageSize, data); |
| 8242 | } |
| 8243 | break; |
| 8244 | |
| 8245 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8246 | { |
| 8247 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8248 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8249 | format, imageSize, data); |
| 8250 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8251 | break; |
| 8252 | |
| 8253 | default: |
| 8254 | return gl::error(GL_INVALID_ENUM); |
| 8255 | } |
| 8256 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8257 | } |
| 8258 | catch(std::bad_alloc&) |
| 8259 | { |
| 8260 | return gl::error(GL_OUT_OF_MEMORY); |
| 8261 | } |
| 8262 | } |
| 8263 | |
| 8264 | void __stdcall glGenQueries(GLsizei n, GLuint* ids) |
| 8265 | { |
| 8266 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8267 | |
| 8268 | try |
| 8269 | { |
| 8270 | gl::Context *context = gl::getNonLostContext(); |
| 8271 | |
| 8272 | if (context) |
| 8273 | { |
| 8274 | if (context->getClientVersion() < 3) |
| 8275 | { |
| 8276 | return gl::error(GL_INVALID_OPERATION); |
| 8277 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8278 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8279 | UNIMPLEMENTED(); |
| 8280 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8281 | } |
| 8282 | catch(std::bad_alloc&) |
| 8283 | { |
| 8284 | return gl::error(GL_OUT_OF_MEMORY); |
| 8285 | } |
| 8286 | } |
| 8287 | |
| 8288 | void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids) |
| 8289 | { |
| 8290 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8291 | |
| 8292 | try |
| 8293 | { |
| 8294 | gl::Context *context = gl::getNonLostContext(); |
| 8295 | |
| 8296 | if (context) |
| 8297 | { |
| 8298 | if (context->getClientVersion() < 3) |
| 8299 | { |
| 8300 | return gl::error(GL_INVALID_OPERATION); |
| 8301 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8302 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8303 | UNIMPLEMENTED(); |
| 8304 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8305 | } |
| 8306 | catch(std::bad_alloc&) |
| 8307 | { |
| 8308 | return gl::error(GL_OUT_OF_MEMORY); |
| 8309 | } |
| 8310 | } |
| 8311 | |
| 8312 | GLboolean __stdcall glIsQuery(GLuint id) |
| 8313 | { |
| 8314 | EVENT("(GLuint id = %u)", id); |
| 8315 | |
| 8316 | try |
| 8317 | { |
| 8318 | gl::Context *context = gl::getNonLostContext(); |
| 8319 | |
| 8320 | if (context) |
| 8321 | { |
| 8322 | if (context->getClientVersion() < 3) |
| 8323 | { |
| 8324 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8325 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8326 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8327 | UNIMPLEMENTED(); |
| 8328 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8329 | } |
| 8330 | catch(std::bad_alloc&) |
| 8331 | { |
| 8332 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8333 | } |
| 8334 | |
| 8335 | return GL_FALSE; |
| 8336 | } |
| 8337 | |
| 8338 | void __stdcall glBeginQuery(GLenum target, GLuint id) |
| 8339 | { |
| 8340 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 8341 | |
| 8342 | try |
| 8343 | { |
| 8344 | gl::Context *context = gl::getNonLostContext(); |
| 8345 | |
| 8346 | if (context) |
| 8347 | { |
| 8348 | if (context->getClientVersion() < 3) |
| 8349 | { |
| 8350 | return gl::error(GL_INVALID_OPERATION); |
| 8351 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8352 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8353 | UNIMPLEMENTED(); |
| 8354 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8355 | } |
| 8356 | catch(std::bad_alloc&) |
| 8357 | { |
| 8358 | return gl::error(GL_OUT_OF_MEMORY); |
| 8359 | } |
| 8360 | } |
| 8361 | |
| 8362 | void __stdcall glEndQuery(GLenum target) |
| 8363 | { |
| 8364 | EVENT("(GLenum target = 0x%X)", target); |
| 8365 | |
| 8366 | try |
| 8367 | { |
| 8368 | gl::Context *context = gl::getNonLostContext(); |
| 8369 | |
| 8370 | if (context) |
| 8371 | { |
| 8372 | if (context->getClientVersion() < 3) |
| 8373 | { |
| 8374 | return gl::error(GL_INVALID_OPERATION); |
| 8375 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8376 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8377 | UNIMPLEMENTED(); |
| 8378 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8379 | } |
| 8380 | catch(std::bad_alloc&) |
| 8381 | { |
| 8382 | return gl::error(GL_OUT_OF_MEMORY); |
| 8383 | } |
| 8384 | } |
| 8385 | |
| 8386 | void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params) |
| 8387 | { |
| 8388 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
| 8389 | |
| 8390 | try |
| 8391 | { |
| 8392 | gl::Context *context = gl::getNonLostContext(); |
| 8393 | |
| 8394 | if (context) |
| 8395 | { |
| 8396 | if (context->getClientVersion() < 3) |
| 8397 | { |
| 8398 | return gl::error(GL_INVALID_OPERATION); |
| 8399 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8400 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8401 | UNIMPLEMENTED(); |
| 8402 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8403 | } |
| 8404 | catch(std::bad_alloc&) |
| 8405 | { |
| 8406 | return gl::error(GL_OUT_OF_MEMORY); |
| 8407 | } |
| 8408 | } |
| 8409 | |
| 8410 | void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) |
| 8411 | { |
| 8412 | EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params); |
| 8413 | |
| 8414 | try |
| 8415 | { |
| 8416 | gl::Context *context = gl::getNonLostContext(); |
| 8417 | |
| 8418 | if (context) |
| 8419 | { |
| 8420 | if (context->getClientVersion() < 3) |
| 8421 | { |
| 8422 | return gl::error(GL_INVALID_OPERATION); |
| 8423 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8424 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8425 | UNIMPLEMENTED(); |
| 8426 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8427 | } |
| 8428 | catch(std::bad_alloc&) |
| 8429 | { |
| 8430 | return gl::error(GL_OUT_OF_MEMORY); |
| 8431 | } |
| 8432 | } |
| 8433 | |
| 8434 | GLboolean __stdcall glUnmapBuffer(GLenum target) |
| 8435 | { |
| 8436 | EVENT("(GLenum target = 0x%X)", target); |
| 8437 | |
| 8438 | try |
| 8439 | { |
| 8440 | gl::Context *context = gl::getNonLostContext(); |
| 8441 | |
| 8442 | if (context) |
| 8443 | { |
| 8444 | if (context->getClientVersion() < 3) |
| 8445 | { |
| 8446 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8447 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8448 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8449 | UNIMPLEMENTED(); |
| 8450 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8451 | } |
| 8452 | catch(std::bad_alloc&) |
| 8453 | { |
| 8454 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8455 | } |
| 8456 | |
| 8457 | return GL_FALSE; |
| 8458 | } |
| 8459 | |
| 8460 | void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) |
| 8461 | { |
| 8462 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 8463 | |
| 8464 | try |
| 8465 | { |
| 8466 | gl::Context *context = gl::getNonLostContext(); |
| 8467 | |
| 8468 | if (context) |
| 8469 | { |
| 8470 | if (context->getClientVersion() < 3) |
| 8471 | { |
| 8472 | return gl::error(GL_INVALID_OPERATION); |
| 8473 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8474 | |
shannonwoods@chromium.org | 2d2190a | 2013-05-30 00:17:35 +0000 | [diff] [blame] | 8475 | UNIMPLEMENTED(); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8476 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8477 | } |
| 8478 | catch(std::bad_alloc&) |
| 8479 | { |
| 8480 | return gl::error(GL_OUT_OF_MEMORY); |
| 8481 | } |
| 8482 | } |
| 8483 | |
| 8484 | void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs) |
| 8485 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8486 | try |
| 8487 | { |
| 8488 | gl::Context *context = gl::getNonLostContext(); |
| 8489 | |
| 8490 | if (context) |
| 8491 | { |
| 8492 | if (context->getClientVersion() < 3) |
| 8493 | { |
| 8494 | return gl::error(GL_INVALID_OPERATION); |
| 8495 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8496 | |
shannon.woods%transgaming.com@gtempaccount.com | 7948c5f | 2013-04-13 03:38:58 +0000 | [diff] [blame] | 8497 | glDrawBuffersEXT(n, bufs); |
| 8498 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8499 | } |
| 8500 | catch(std::bad_alloc&) |
| 8501 | { |
| 8502 | return gl::error(GL_OUT_OF_MEMORY); |
| 8503 | } |
| 8504 | } |
| 8505 | |
| 8506 | void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8507 | { |
| 8508 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8509 | location, count, transpose, value); |
| 8510 | |
| 8511 | try |
| 8512 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8513 | if (count < 0) |
| 8514 | { |
| 8515 | return gl::error(GL_INVALID_VALUE); |
| 8516 | } |
| 8517 | |
| 8518 | if (location == -1) |
| 8519 | { |
| 8520 | return; |
| 8521 | } |
| 8522 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8523 | gl::Context *context = gl::getNonLostContext(); |
| 8524 | |
| 8525 | if (context) |
| 8526 | { |
| 8527 | if (context->getClientVersion() < 3) |
| 8528 | { |
| 8529 | return gl::error(GL_INVALID_OPERATION); |
| 8530 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8531 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8532 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8533 | if (!programBinary) |
| 8534 | { |
| 8535 | return gl::error(GL_INVALID_OPERATION); |
| 8536 | } |
| 8537 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8538 | if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8539 | { |
| 8540 | return gl::error(GL_INVALID_OPERATION); |
| 8541 | } |
| 8542 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8543 | } |
| 8544 | catch(std::bad_alloc&) |
| 8545 | { |
| 8546 | return gl::error(GL_OUT_OF_MEMORY); |
| 8547 | } |
| 8548 | } |
| 8549 | |
| 8550 | void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8551 | { |
| 8552 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8553 | location, count, transpose, value); |
| 8554 | |
| 8555 | try |
| 8556 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8557 | if (count < 0) |
| 8558 | { |
| 8559 | return gl::error(GL_INVALID_VALUE); |
| 8560 | } |
| 8561 | |
| 8562 | if (location == -1) |
| 8563 | { |
| 8564 | return; |
| 8565 | } |
| 8566 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8567 | gl::Context *context = gl::getNonLostContext(); |
| 8568 | |
| 8569 | if (context) |
| 8570 | { |
| 8571 | if (context->getClientVersion() < 3) |
| 8572 | { |
| 8573 | return gl::error(GL_INVALID_OPERATION); |
| 8574 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8575 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8576 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8577 | if (!programBinary) |
| 8578 | { |
| 8579 | return gl::error(GL_INVALID_OPERATION); |
| 8580 | } |
| 8581 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8582 | if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8583 | { |
| 8584 | return gl::error(GL_INVALID_OPERATION); |
| 8585 | } |
| 8586 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8587 | } |
| 8588 | catch(std::bad_alloc&) |
| 8589 | { |
| 8590 | return gl::error(GL_OUT_OF_MEMORY); |
| 8591 | } |
| 8592 | } |
| 8593 | |
| 8594 | void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8595 | { |
| 8596 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8597 | location, count, transpose, value); |
| 8598 | |
| 8599 | try |
| 8600 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8601 | if (count < 0) |
| 8602 | { |
| 8603 | return gl::error(GL_INVALID_VALUE); |
| 8604 | } |
| 8605 | |
| 8606 | if (location == -1) |
| 8607 | { |
| 8608 | return; |
| 8609 | } |
| 8610 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8611 | gl::Context *context = gl::getNonLostContext(); |
| 8612 | |
| 8613 | if (context) |
| 8614 | { |
| 8615 | if (context->getClientVersion() < 3) |
| 8616 | { |
| 8617 | return gl::error(GL_INVALID_OPERATION); |
| 8618 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8619 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8620 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8621 | if (!programBinary) |
| 8622 | { |
| 8623 | return gl::error(GL_INVALID_OPERATION); |
| 8624 | } |
| 8625 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8626 | if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8627 | { |
| 8628 | return gl::error(GL_INVALID_OPERATION); |
| 8629 | } |
| 8630 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8631 | } |
| 8632 | catch(std::bad_alloc&) |
| 8633 | { |
| 8634 | return gl::error(GL_OUT_OF_MEMORY); |
| 8635 | } |
| 8636 | } |
| 8637 | |
| 8638 | void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8639 | { |
| 8640 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8641 | location, count, transpose, value); |
| 8642 | |
| 8643 | try |
| 8644 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8645 | if (count < 0) |
| 8646 | { |
| 8647 | return gl::error(GL_INVALID_VALUE); |
| 8648 | } |
| 8649 | |
| 8650 | if (location == -1) |
| 8651 | { |
| 8652 | return; |
| 8653 | } |
| 8654 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8655 | gl::Context *context = gl::getNonLostContext(); |
| 8656 | |
| 8657 | if (context) |
| 8658 | { |
| 8659 | if (context->getClientVersion() < 3) |
| 8660 | { |
| 8661 | return gl::error(GL_INVALID_OPERATION); |
| 8662 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8663 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8664 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8665 | if (!programBinary) |
| 8666 | { |
| 8667 | return gl::error(GL_INVALID_OPERATION); |
| 8668 | } |
| 8669 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8670 | if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8671 | { |
| 8672 | return gl::error(GL_INVALID_OPERATION); |
| 8673 | } |
| 8674 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8675 | } |
| 8676 | catch(std::bad_alloc&) |
| 8677 | { |
| 8678 | return gl::error(GL_OUT_OF_MEMORY); |
| 8679 | } |
| 8680 | } |
| 8681 | |
| 8682 | void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8683 | { |
| 8684 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8685 | location, count, transpose, value); |
| 8686 | |
| 8687 | try |
| 8688 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8689 | if (count < 0) |
| 8690 | { |
| 8691 | return gl::error(GL_INVALID_VALUE); |
| 8692 | } |
| 8693 | |
| 8694 | if (location == -1) |
| 8695 | { |
| 8696 | return; |
| 8697 | } |
| 8698 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8699 | gl::Context *context = gl::getNonLostContext(); |
| 8700 | |
| 8701 | if (context) |
| 8702 | { |
| 8703 | if (context->getClientVersion() < 3) |
| 8704 | { |
| 8705 | return gl::error(GL_INVALID_OPERATION); |
| 8706 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8707 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8708 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8709 | if (!programBinary) |
| 8710 | { |
| 8711 | return gl::error(GL_INVALID_OPERATION); |
| 8712 | } |
| 8713 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8714 | if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8715 | { |
| 8716 | return gl::error(GL_INVALID_OPERATION); |
| 8717 | } |
| 8718 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8719 | } |
| 8720 | catch(std::bad_alloc&) |
| 8721 | { |
| 8722 | return gl::error(GL_OUT_OF_MEMORY); |
| 8723 | } |
| 8724 | } |
| 8725 | |
| 8726 | void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8727 | { |
| 8728 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8729 | location, count, transpose, value); |
| 8730 | |
| 8731 | try |
| 8732 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8733 | if (count < 0) |
| 8734 | { |
| 8735 | return gl::error(GL_INVALID_VALUE); |
| 8736 | } |
| 8737 | |
| 8738 | if (location == -1) |
| 8739 | { |
| 8740 | return; |
| 8741 | } |
| 8742 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8743 | gl::Context *context = gl::getNonLostContext(); |
| 8744 | |
| 8745 | if (context) |
| 8746 | { |
| 8747 | if (context->getClientVersion() < 3) |
| 8748 | { |
| 8749 | return gl::error(GL_INVALID_OPERATION); |
| 8750 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8751 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8752 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8753 | if (!programBinary) |
| 8754 | { |
| 8755 | return gl::error(GL_INVALID_OPERATION); |
| 8756 | } |
| 8757 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8758 | if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8759 | { |
| 8760 | return gl::error(GL_INVALID_OPERATION); |
| 8761 | } |
| 8762 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8763 | } |
| 8764 | catch(std::bad_alloc&) |
| 8765 | { |
| 8766 | return gl::error(GL_OUT_OF_MEMORY); |
| 8767 | } |
| 8768 | } |
| 8769 | |
| 8770 | void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) |
| 8771 | { |
| 8772 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, " |
| 8773 | "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 8774 | srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 8775 | |
| 8776 | try |
| 8777 | { |
| 8778 | gl::Context *context = gl::getNonLostContext(); |
| 8779 | |
| 8780 | if (context) |
| 8781 | { |
| 8782 | if (context->getClientVersion() < 3) |
| 8783 | { |
| 8784 | return gl::error(GL_INVALID_OPERATION); |
| 8785 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8786 | |
shannonwoods@chromium.org | ee14856 | 2013-05-30 00:17:21 +0000 | [diff] [blame] | 8787 | glBlitFramebufferANGLE(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8788 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8789 | } |
| 8790 | catch(std::bad_alloc&) |
| 8791 | { |
| 8792 | return gl::error(GL_OUT_OF_MEMORY); |
| 8793 | } |
| 8794 | } |
| 8795 | |
| 8796 | void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| 8797 | { |
| 8798 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 8799 | target, samples, internalformat, width, height); |
| 8800 | |
| 8801 | try |
| 8802 | { |
| 8803 | gl::Context *context = gl::getNonLostContext(); |
| 8804 | |
| 8805 | if (context) |
| 8806 | { |
| 8807 | if (context->getClientVersion() < 3) |
| 8808 | { |
| 8809 | return gl::error(GL_INVALID_OPERATION); |
| 8810 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8811 | |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 8812 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 8813 | width, height, false)) |
| 8814 | { |
| 8815 | return; |
| 8816 | } |
| 8817 | |
| 8818 | context->setRenderbufferStorage(width, height, internalformat, samples); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8819 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8820 | } |
| 8821 | catch(std::bad_alloc&) |
| 8822 | { |
| 8823 | return gl::error(GL_OUT_OF_MEMORY); |
| 8824 | } |
| 8825 | } |
| 8826 | |
| 8827 | void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) |
| 8828 | { |
| 8829 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)", |
| 8830 | target, attachment, texture, level, layer); |
| 8831 | |
| 8832 | try |
| 8833 | { |
| 8834 | gl::Context *context = gl::getNonLostContext(); |
| 8835 | |
| 8836 | if (context) |
| 8837 | { |
| 8838 | if (context->getClientVersion() < 3) |
| 8839 | { |
| 8840 | return gl::error(GL_INVALID_OPERATION); |
| 8841 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8842 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8843 | UNIMPLEMENTED(); |
| 8844 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8845 | } |
| 8846 | catch(std::bad_alloc&) |
| 8847 | { |
| 8848 | return gl::error(GL_OUT_OF_MEMORY); |
| 8849 | } |
| 8850 | } |
| 8851 | |
| 8852 | GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 8853 | { |
| 8854 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 8855 | target, offset, length, access); |
| 8856 | |
| 8857 | try |
| 8858 | { |
| 8859 | gl::Context *context = gl::getNonLostContext(); |
| 8860 | |
| 8861 | if (context) |
| 8862 | { |
| 8863 | if (context->getClientVersion() < 3) |
| 8864 | { |
| 8865 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 8866 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8867 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8868 | UNIMPLEMENTED(); |
| 8869 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8870 | } |
| 8871 | catch(std::bad_alloc&) |
| 8872 | { |
| 8873 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL)); |
| 8874 | } |
| 8875 | |
| 8876 | return NULL; |
| 8877 | } |
| 8878 | |
| 8879 | void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) |
| 8880 | { |
| 8881 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 8882 | |
| 8883 | try |
| 8884 | { |
| 8885 | gl::Context *context = gl::getNonLostContext(); |
| 8886 | |
| 8887 | if (context) |
| 8888 | { |
| 8889 | if (context->getClientVersion() < 3) |
| 8890 | { |
| 8891 | return gl::error(GL_INVALID_OPERATION); |
| 8892 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8893 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8894 | UNIMPLEMENTED(); |
| 8895 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8896 | } |
| 8897 | catch(std::bad_alloc&) |
| 8898 | { |
| 8899 | return gl::error(GL_OUT_OF_MEMORY); |
| 8900 | } |
| 8901 | } |
| 8902 | |
| 8903 | void __stdcall glBindVertexArray(GLuint array) |
| 8904 | { |
| 8905 | EVENT("(GLuint array = %u)", array); |
| 8906 | |
| 8907 | try |
| 8908 | { |
| 8909 | gl::Context *context = gl::getNonLostContext(); |
| 8910 | |
| 8911 | if (context) |
| 8912 | { |
| 8913 | if (context->getClientVersion() < 3) |
| 8914 | { |
| 8915 | return gl::error(GL_INVALID_OPERATION); |
| 8916 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8917 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8918 | UNIMPLEMENTED(); |
| 8919 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8920 | } |
| 8921 | catch(std::bad_alloc&) |
| 8922 | { |
| 8923 | return gl::error(GL_OUT_OF_MEMORY); |
| 8924 | } |
| 8925 | } |
| 8926 | |
| 8927 | void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) |
| 8928 | { |
| 8929 | EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays); |
| 8930 | |
| 8931 | try |
| 8932 | { |
| 8933 | gl::Context *context = gl::getNonLostContext(); |
| 8934 | |
| 8935 | if (context) |
| 8936 | { |
| 8937 | if (context->getClientVersion() < 3) |
| 8938 | { |
| 8939 | return gl::error(GL_INVALID_OPERATION); |
| 8940 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8941 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8942 | UNIMPLEMENTED(); |
| 8943 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8944 | } |
| 8945 | catch(std::bad_alloc&) |
| 8946 | { |
| 8947 | return gl::error(GL_OUT_OF_MEMORY); |
| 8948 | } |
| 8949 | } |
| 8950 | |
| 8951 | void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) |
| 8952 | { |
| 8953 | EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays); |
| 8954 | |
| 8955 | try |
| 8956 | { |
| 8957 | gl::Context *context = gl::getNonLostContext(); |
| 8958 | |
| 8959 | if (context) |
| 8960 | { |
| 8961 | if (context->getClientVersion() < 3) |
| 8962 | { |
| 8963 | return gl::error(GL_INVALID_OPERATION); |
| 8964 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8965 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8966 | UNIMPLEMENTED(); |
| 8967 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8968 | } |
| 8969 | catch(std::bad_alloc&) |
| 8970 | { |
| 8971 | return gl::error(GL_OUT_OF_MEMORY); |
| 8972 | } |
| 8973 | } |
| 8974 | |
| 8975 | GLboolean __stdcall glIsVertexArray(GLuint array) |
| 8976 | { |
| 8977 | EVENT("(GLuint array = %u)", array); |
| 8978 | |
| 8979 | try |
| 8980 | { |
| 8981 | gl::Context *context = gl::getNonLostContext(); |
| 8982 | |
| 8983 | if (context) |
| 8984 | { |
| 8985 | if (context->getClientVersion() < 3) |
| 8986 | { |
| 8987 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8988 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8989 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8990 | UNIMPLEMENTED(); |
| 8991 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8992 | } |
| 8993 | catch(std::bad_alloc&) |
| 8994 | { |
| 8995 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8996 | } |
| 8997 | |
| 8998 | return GL_FALSE; |
| 8999 | } |
| 9000 | |
| 9001 | void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data) |
| 9002 | { |
| 9003 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)", |
| 9004 | target, index, data); |
| 9005 | |
| 9006 | try |
| 9007 | { |
| 9008 | gl::Context *context = gl::getNonLostContext(); |
| 9009 | |
| 9010 | if (context) |
| 9011 | { |
| 9012 | if (context->getClientVersion() < 3) |
| 9013 | { |
| 9014 | return gl::error(GL_INVALID_OPERATION); |
| 9015 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9016 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9017 | UNIMPLEMENTED(); |
| 9018 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9019 | } |
| 9020 | catch(std::bad_alloc&) |
| 9021 | { |
| 9022 | return gl::error(GL_OUT_OF_MEMORY); |
| 9023 | } |
| 9024 | } |
| 9025 | |
| 9026 | void __stdcall glBeginTransformFeedback(GLenum primitiveMode) |
| 9027 | { |
| 9028 | EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode); |
| 9029 | |
| 9030 | try |
| 9031 | { |
| 9032 | gl::Context *context = gl::getNonLostContext(); |
| 9033 | |
| 9034 | if (context) |
| 9035 | { |
| 9036 | if (context->getClientVersion() < 3) |
| 9037 | { |
| 9038 | return gl::error(GL_INVALID_OPERATION); |
| 9039 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9040 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9041 | UNIMPLEMENTED(); |
| 9042 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9043 | } |
| 9044 | catch(std::bad_alloc&) |
| 9045 | { |
| 9046 | return gl::error(GL_OUT_OF_MEMORY); |
| 9047 | } |
| 9048 | } |
| 9049 | |
| 9050 | void __stdcall glEndTransformFeedback(void) |
| 9051 | { |
| 9052 | EVENT("(void)"); |
| 9053 | |
| 9054 | try |
| 9055 | { |
| 9056 | gl::Context *context = gl::getNonLostContext(); |
| 9057 | |
| 9058 | if (context) |
| 9059 | { |
| 9060 | if (context->getClientVersion() < 3) |
| 9061 | { |
| 9062 | return gl::error(GL_INVALID_OPERATION); |
| 9063 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9064 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9065 | UNIMPLEMENTED(); |
| 9066 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9067 | } |
| 9068 | catch(std::bad_alloc&) |
| 9069 | { |
| 9070 | return gl::error(GL_OUT_OF_MEMORY); |
| 9071 | } |
| 9072 | } |
| 9073 | |
| 9074 | void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
| 9075 | { |
| 9076 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)", |
| 9077 | target, index, buffer, offset, size); |
| 9078 | |
| 9079 | try |
| 9080 | { |
| 9081 | gl::Context *context = gl::getNonLostContext(); |
| 9082 | |
| 9083 | if (context) |
| 9084 | { |
| 9085 | if (context->getClientVersion() < 3) |
| 9086 | { |
| 9087 | return gl::error(GL_INVALID_OPERATION); |
| 9088 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9089 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9090 | switch (target) |
| 9091 | { |
| 9092 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9093 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9094 | { |
| 9095 | return gl::error(GL_INVALID_VALUE); |
| 9096 | } |
| 9097 | break; |
| 9098 | |
| 9099 | case GL_UNIFORM_BUFFER: |
| 9100 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 9101 | { |
| 9102 | return gl::error(GL_INVALID_VALUE); |
| 9103 | } |
| 9104 | break; |
| 9105 | |
| 9106 | default: |
| 9107 | return gl::error(GL_INVALID_ENUM); |
| 9108 | } |
| 9109 | |
shannonwoods@chromium.org | e6e0079 | 2013-05-30 00:06:07 +0000 | [diff] [blame] | 9110 | if (buffer != 0 && size <= 0) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9111 | { |
| 9112 | return gl::error(GL_INVALID_VALUE); |
| 9113 | } |
| 9114 | |
| 9115 | switch (target) |
| 9116 | { |
| 9117 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | a26aeaf | 2013-05-30 00:06:13 +0000 | [diff] [blame] | 9118 | |
| 9119 | // size and offset must be a multiple of 4 |
| 9120 | if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) |
| 9121 | { |
| 9122 | return gl::error(GL_INVALID_VALUE); |
| 9123 | } |
| 9124 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9125 | context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 9126 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9127 | break; |
| 9128 | |
| 9129 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 97c3d50 | 2013-05-30 00:04:34 +0000 | [diff] [blame] | 9130 | |
| 9131 | // it is an error to bind an offset not a multiple of the alignment |
| 9132 | if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0) |
| 9133 | { |
| 9134 | return gl::error(GL_INVALID_VALUE); |
| 9135 | } |
| 9136 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9137 | context->bindIndexedUniformBuffer(buffer, index, offset, size); |
| 9138 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9139 | break; |
| 9140 | |
| 9141 | default: |
| 9142 | UNREACHABLE(); |
| 9143 | } |
| 9144 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9145 | } |
| 9146 | catch(std::bad_alloc&) |
| 9147 | { |
| 9148 | return gl::error(GL_OUT_OF_MEMORY); |
| 9149 | } |
| 9150 | } |
| 9151 | |
| 9152 | void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 9153 | { |
| 9154 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)", |
| 9155 | target, index, buffer); |
| 9156 | |
| 9157 | try |
| 9158 | { |
| 9159 | gl::Context *context = gl::getNonLostContext(); |
| 9160 | |
| 9161 | if (context) |
| 9162 | { |
| 9163 | if (context->getClientVersion() < 3) |
| 9164 | { |
| 9165 | return gl::error(GL_INVALID_OPERATION); |
| 9166 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9167 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9168 | switch (target) |
| 9169 | { |
| 9170 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9171 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9172 | { |
| 9173 | return gl::error(GL_INVALID_VALUE); |
| 9174 | } |
| 9175 | break; |
| 9176 | |
| 9177 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9178 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9179 | { |
| 9180 | return gl::error(GL_INVALID_VALUE); |
| 9181 | } |
| 9182 | break; |
| 9183 | |
| 9184 | default: |
| 9185 | return gl::error(GL_INVALID_ENUM); |
| 9186 | } |
| 9187 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9188 | switch (target) |
| 9189 | { |
| 9190 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9191 | context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9192 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9193 | break; |
| 9194 | |
| 9195 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9196 | context->bindIndexedUniformBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9197 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9198 | break; |
| 9199 | |
| 9200 | default: |
| 9201 | UNREACHABLE(); |
| 9202 | } |
| 9203 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9204 | } |
| 9205 | catch(std::bad_alloc&) |
| 9206 | { |
| 9207 | return gl::error(GL_OUT_OF_MEMORY); |
| 9208 | } |
| 9209 | } |
| 9210 | |
| 9211 | void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
| 9212 | { |
| 9213 | EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)", |
| 9214 | program, count, varyings, bufferMode); |
| 9215 | |
| 9216 | try |
| 9217 | { |
| 9218 | gl::Context *context = gl::getNonLostContext(); |
| 9219 | |
| 9220 | if (context) |
| 9221 | { |
| 9222 | if (context->getClientVersion() < 3) |
| 9223 | { |
| 9224 | return gl::error(GL_INVALID_OPERATION); |
| 9225 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9226 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9227 | UNIMPLEMENTED(); |
| 9228 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9229 | } |
| 9230 | catch(std::bad_alloc&) |
| 9231 | { |
| 9232 | return gl::error(GL_OUT_OF_MEMORY); |
| 9233 | } |
| 9234 | } |
| 9235 | |
| 9236 | void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
| 9237 | { |
| 9238 | EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, " |
| 9239 | "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
| 9240 | program, index, bufSize, length, size, type, name); |
| 9241 | |
| 9242 | try |
| 9243 | { |
| 9244 | gl::Context *context = gl::getNonLostContext(); |
| 9245 | |
| 9246 | if (context) |
| 9247 | { |
| 9248 | if (context->getClientVersion() < 3) |
| 9249 | { |
| 9250 | return gl::error(GL_INVALID_OPERATION); |
| 9251 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9252 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9253 | UNIMPLEMENTED(); |
| 9254 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9255 | } |
| 9256 | catch(std::bad_alloc&) |
| 9257 | { |
| 9258 | return gl::error(GL_OUT_OF_MEMORY); |
| 9259 | } |
| 9260 | } |
| 9261 | |
| 9262 | void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) |
| 9263 | { |
| 9264 | EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)", |
| 9265 | index, size, type, stride, pointer); |
| 9266 | |
| 9267 | try |
| 9268 | { |
| 9269 | gl::Context *context = gl::getNonLostContext(); |
| 9270 | |
| 9271 | if (context) |
| 9272 | { |
| 9273 | if (context->getClientVersion() < 3) |
| 9274 | { |
| 9275 | return gl::error(GL_INVALID_OPERATION); |
| 9276 | } |
| 9277 | } |
| 9278 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9279 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9280 | { |
| 9281 | return gl::error(GL_INVALID_VALUE); |
| 9282 | } |
| 9283 | |
| 9284 | if (size < 1 || size > 4) |
| 9285 | { |
| 9286 | return gl::error(GL_INVALID_VALUE); |
| 9287 | } |
| 9288 | |
| 9289 | switch (type) |
| 9290 | { |
| 9291 | case GL_BYTE: |
| 9292 | case GL_UNSIGNED_BYTE: |
| 9293 | case GL_SHORT: |
| 9294 | case GL_UNSIGNED_SHORT: |
| 9295 | case GL_INT: |
| 9296 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9297 | case GL_INT_2_10_10_10_REV: |
| 9298 | 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] | 9299 | break; |
| 9300 | default: |
| 9301 | return gl::error(GL_INVALID_ENUM); |
| 9302 | } |
| 9303 | |
| 9304 | if (stride < 0) |
| 9305 | { |
| 9306 | return gl::error(GL_INVALID_VALUE); |
| 9307 | } |
| 9308 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9309 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 9310 | { |
| 9311 | return gl::error(GL_INVALID_OPERATION); |
| 9312 | } |
| 9313 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9314 | if (context) |
| 9315 | { |
| 9316 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true, |
| 9317 | stride, pointer); |
| 9318 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9319 | } |
| 9320 | catch(std::bad_alloc&) |
| 9321 | { |
| 9322 | return gl::error(GL_OUT_OF_MEMORY); |
| 9323 | } |
| 9324 | } |
| 9325 | |
| 9326 | void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) |
| 9327 | { |
| 9328 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 9329 | index, pname, params); |
| 9330 | |
| 9331 | try |
| 9332 | { |
| 9333 | gl::Context *context = gl::getNonLostContext(); |
| 9334 | |
| 9335 | if (context) |
| 9336 | { |
| 9337 | if (context->getClientVersion() < 3) |
| 9338 | { |
| 9339 | return gl::error(GL_INVALID_OPERATION); |
| 9340 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9341 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9342 | UNIMPLEMENTED(); |
| 9343 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9344 | } |
| 9345 | catch(std::bad_alloc&) |
| 9346 | { |
| 9347 | return gl::error(GL_OUT_OF_MEMORY); |
| 9348 | } |
| 9349 | } |
| 9350 | |
| 9351 | void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) |
| 9352 | { |
| 9353 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)", |
| 9354 | index, pname, params); |
| 9355 | |
| 9356 | try |
| 9357 | { |
| 9358 | gl::Context *context = gl::getNonLostContext(); |
| 9359 | |
| 9360 | if (context) |
| 9361 | { |
| 9362 | if (context->getClientVersion() < 3) |
| 9363 | { |
| 9364 | return gl::error(GL_INVALID_OPERATION); |
| 9365 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9366 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9367 | UNIMPLEMENTED(); |
| 9368 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9369 | } |
| 9370 | catch(std::bad_alloc&) |
| 9371 | { |
| 9372 | return gl::error(GL_OUT_OF_MEMORY); |
| 9373 | } |
| 9374 | } |
| 9375 | |
| 9376 | void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 9377 | { |
| 9378 | EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)", |
| 9379 | index, x, y, z, w); |
| 9380 | |
| 9381 | try |
| 9382 | { |
| 9383 | gl::Context *context = gl::getNonLostContext(); |
| 9384 | |
| 9385 | if (context) |
| 9386 | { |
| 9387 | if (context->getClientVersion() < 3) |
| 9388 | { |
| 9389 | return gl::error(GL_INVALID_OPERATION); |
| 9390 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9391 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9392 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9393 | { |
| 9394 | return gl::error(GL_INVALID_VALUE); |
| 9395 | } |
| 9396 | |
| 9397 | GLint vals[4] = { x, y, z, w }; |
| 9398 | context->setVertexAttribi(index, vals); |
| 9399 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9400 | } |
| 9401 | catch(std::bad_alloc&) |
| 9402 | { |
| 9403 | return gl::error(GL_OUT_OF_MEMORY); |
| 9404 | } |
| 9405 | } |
| 9406 | |
| 9407 | void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 9408 | { |
| 9409 | EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)", |
| 9410 | index, x, y, z, w); |
| 9411 | |
| 9412 | try |
| 9413 | { |
| 9414 | gl::Context *context = gl::getNonLostContext(); |
| 9415 | |
| 9416 | if (context) |
| 9417 | { |
| 9418 | if (context->getClientVersion() < 3) |
| 9419 | { |
| 9420 | return gl::error(GL_INVALID_OPERATION); |
| 9421 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9422 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9423 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9424 | { |
| 9425 | return gl::error(GL_INVALID_VALUE); |
| 9426 | } |
| 9427 | |
| 9428 | GLuint vals[4] = { x, y, z, w }; |
| 9429 | context->setVertexAttribu(index, vals); |
| 9430 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9431 | } |
| 9432 | catch(std::bad_alloc&) |
| 9433 | { |
| 9434 | return gl::error(GL_OUT_OF_MEMORY); |
| 9435 | } |
| 9436 | } |
| 9437 | |
| 9438 | void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) |
| 9439 | { |
| 9440 | EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v); |
| 9441 | |
| 9442 | try |
| 9443 | { |
| 9444 | gl::Context *context = gl::getNonLostContext(); |
| 9445 | |
| 9446 | if (context) |
| 9447 | { |
| 9448 | if (context->getClientVersion() < 3) |
| 9449 | { |
| 9450 | return gl::error(GL_INVALID_OPERATION); |
| 9451 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9452 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9453 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9454 | { |
| 9455 | return gl::error(GL_INVALID_VALUE); |
| 9456 | } |
| 9457 | |
| 9458 | context->setVertexAttribi(index, v); |
| 9459 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9460 | } |
| 9461 | catch(std::bad_alloc&) |
| 9462 | { |
| 9463 | return gl::error(GL_OUT_OF_MEMORY); |
| 9464 | } |
| 9465 | } |
| 9466 | |
| 9467 | void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v) |
| 9468 | { |
| 9469 | EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v); |
| 9470 | |
| 9471 | try |
| 9472 | { |
| 9473 | gl::Context *context = gl::getNonLostContext(); |
| 9474 | |
| 9475 | if (context) |
| 9476 | { |
| 9477 | if (context->getClientVersion() < 3) |
| 9478 | { |
| 9479 | return gl::error(GL_INVALID_OPERATION); |
| 9480 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9481 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9482 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9483 | { |
| 9484 | return gl::error(GL_INVALID_VALUE); |
| 9485 | } |
| 9486 | |
| 9487 | context->setVertexAttribu(index, v); |
| 9488 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9489 | } |
| 9490 | catch(std::bad_alloc&) |
| 9491 | { |
| 9492 | return gl::error(GL_OUT_OF_MEMORY); |
| 9493 | } |
| 9494 | } |
| 9495 | |
| 9496 | void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) |
| 9497 | { |
| 9498 | EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)", |
| 9499 | program, location, params); |
| 9500 | |
| 9501 | try |
| 9502 | { |
| 9503 | gl::Context *context = gl::getNonLostContext(); |
| 9504 | |
| 9505 | if (context) |
| 9506 | { |
| 9507 | if (context->getClientVersion() < 3) |
| 9508 | { |
| 9509 | return gl::error(GL_INVALID_OPERATION); |
| 9510 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9511 | |
shannon.woods%transgaming.com@gtempaccount.com | e229012 | 2013-04-13 03:41:07 +0000 | [diff] [blame] | 9512 | if (program == 0) |
| 9513 | { |
| 9514 | return gl::error(GL_INVALID_VALUE); |
| 9515 | } |
| 9516 | |
| 9517 | gl::Program *programObject = context->getProgram(program); |
| 9518 | |
| 9519 | if (!programObject || !programObject->isLinked()) |
| 9520 | { |
| 9521 | return gl::error(GL_INVALID_OPERATION); |
| 9522 | } |
| 9523 | |
| 9524 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9525 | if (!programBinary) |
| 9526 | { |
| 9527 | return gl::error(GL_INVALID_OPERATION); |
| 9528 | } |
| 9529 | |
| 9530 | if (!programBinary->getUniformuiv(location, NULL, params)) |
| 9531 | { |
| 9532 | return gl::error(GL_INVALID_OPERATION); |
| 9533 | } |
| 9534 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9535 | } |
| 9536 | catch(std::bad_alloc&) |
| 9537 | { |
| 9538 | return gl::error(GL_OUT_OF_MEMORY); |
| 9539 | } |
| 9540 | } |
| 9541 | |
| 9542 | GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) |
| 9543 | { |
| 9544 | EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)", |
| 9545 | program, name); |
| 9546 | |
| 9547 | try |
| 9548 | { |
| 9549 | gl::Context *context = gl::getNonLostContext(); |
| 9550 | |
| 9551 | if (context) |
| 9552 | { |
| 9553 | if (context->getClientVersion() < 3) |
| 9554 | { |
| 9555 | return gl::error(GL_INVALID_OPERATION, 0); |
| 9556 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9557 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9558 | UNIMPLEMENTED(); |
| 9559 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9560 | } |
| 9561 | catch(std::bad_alloc&) |
| 9562 | { |
| 9563 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 9564 | } |
| 9565 | |
| 9566 | return 0; |
| 9567 | } |
| 9568 | |
| 9569 | void __stdcall glUniform1ui(GLint location, GLuint v0) |
| 9570 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9571 | glUniform1uiv(location, 1, &v0); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9572 | } |
| 9573 | |
| 9574 | void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1) |
| 9575 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9576 | const GLuint xy[] = { v0, v1 }; |
| 9577 | glUniform2uiv(location, 1, xy); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9578 | } |
| 9579 | |
| 9580 | void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 9581 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9582 | const GLuint xyz[] = { v0, v1, v2 }; |
| 9583 | glUniform3uiv(location, 1, xyz); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9584 | } |
| 9585 | |
| 9586 | void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 9587 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9588 | const GLuint xyzw[] = { v0, v1, v2, v3 }; |
| 9589 | glUniform4uiv(location, 1, xyzw); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9590 | } |
| 9591 | |
| 9592 | void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) |
| 9593 | { |
| 9594 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9595 | location, count, value); |
| 9596 | |
| 9597 | try |
| 9598 | { |
| 9599 | gl::Context *context = gl::getNonLostContext(); |
| 9600 | |
| 9601 | if (context) |
| 9602 | { |
| 9603 | if (context->getClientVersion() < 3) |
| 9604 | { |
| 9605 | return gl::error(GL_INVALID_OPERATION); |
| 9606 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9607 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9608 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9609 | if (!programBinary) |
| 9610 | { |
| 9611 | return gl::error(GL_INVALID_OPERATION); |
| 9612 | } |
| 9613 | |
| 9614 | if (!programBinary->setUniform1uiv(location, count, value)) |
| 9615 | { |
| 9616 | return gl::error(GL_INVALID_OPERATION); |
| 9617 | } |
| 9618 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9619 | } |
| 9620 | catch(std::bad_alloc&) |
| 9621 | { |
| 9622 | return gl::error(GL_OUT_OF_MEMORY); |
| 9623 | } |
| 9624 | } |
| 9625 | |
| 9626 | void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) |
| 9627 | { |
| 9628 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9629 | location, count, value); |
| 9630 | |
| 9631 | try |
| 9632 | { |
| 9633 | gl::Context *context = gl::getNonLostContext(); |
| 9634 | |
| 9635 | if (context) |
| 9636 | { |
| 9637 | if (context->getClientVersion() < 3) |
| 9638 | { |
| 9639 | return gl::error(GL_INVALID_OPERATION); |
| 9640 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9641 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9642 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9643 | if (!programBinary) |
| 9644 | { |
| 9645 | return gl::error(GL_INVALID_OPERATION); |
| 9646 | } |
| 9647 | |
| 9648 | if (!programBinary->setUniform2uiv(location, count, value)) |
| 9649 | { |
| 9650 | return gl::error(GL_INVALID_OPERATION); |
| 9651 | } |
| 9652 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9653 | } |
| 9654 | catch(std::bad_alloc&) |
| 9655 | { |
| 9656 | return gl::error(GL_OUT_OF_MEMORY); |
| 9657 | } |
| 9658 | } |
| 9659 | |
| 9660 | void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) |
| 9661 | { |
| 9662 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)", |
| 9663 | location, count, value); |
| 9664 | |
| 9665 | try |
| 9666 | { |
| 9667 | gl::Context *context = gl::getNonLostContext(); |
| 9668 | |
| 9669 | if (context) |
| 9670 | { |
| 9671 | if (context->getClientVersion() < 3) |
| 9672 | { |
| 9673 | return gl::error(GL_INVALID_OPERATION); |
| 9674 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9675 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9676 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9677 | if (!programBinary) |
| 9678 | { |
| 9679 | return gl::error(GL_INVALID_OPERATION); |
| 9680 | } |
| 9681 | |
| 9682 | if (!programBinary->setUniform3uiv(location, count, value)) |
| 9683 | { |
| 9684 | return gl::error(GL_INVALID_OPERATION); |
| 9685 | } |
| 9686 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9687 | } |
| 9688 | catch(std::bad_alloc&) |
| 9689 | { |
| 9690 | return gl::error(GL_OUT_OF_MEMORY); |
| 9691 | } |
| 9692 | } |
| 9693 | |
| 9694 | void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) |
| 9695 | { |
| 9696 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9697 | location, count, value); |
| 9698 | |
| 9699 | try |
| 9700 | { |
| 9701 | gl::Context *context = gl::getNonLostContext(); |
| 9702 | |
| 9703 | if (context) |
| 9704 | { |
| 9705 | if (context->getClientVersion() < 3) |
| 9706 | { |
| 9707 | return gl::error(GL_INVALID_OPERATION); |
| 9708 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9709 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9710 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9711 | if (!programBinary) |
| 9712 | { |
| 9713 | return gl::error(GL_INVALID_OPERATION); |
| 9714 | } |
| 9715 | |
| 9716 | if (!programBinary->setUniform4uiv(location, count, value)) |
| 9717 | { |
| 9718 | return gl::error(GL_INVALID_OPERATION); |
| 9719 | } |
| 9720 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9721 | } |
| 9722 | catch(std::bad_alloc&) |
| 9723 | { |
| 9724 | return gl::error(GL_OUT_OF_MEMORY); |
| 9725 | } |
| 9726 | } |
| 9727 | |
| 9728 | void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) |
| 9729 | { |
| 9730 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)", |
| 9731 | buffer, drawbuffer, value); |
| 9732 | |
| 9733 | try |
| 9734 | { |
| 9735 | gl::Context *context = gl::getNonLostContext(); |
| 9736 | |
| 9737 | if (context) |
| 9738 | { |
| 9739 | if (context->getClientVersion() < 3) |
| 9740 | { |
| 9741 | return gl::error(GL_INVALID_OPERATION); |
| 9742 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9743 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9744 | UNIMPLEMENTED(); |
| 9745 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9746 | } |
| 9747 | catch(std::bad_alloc&) |
| 9748 | { |
| 9749 | return gl::error(GL_OUT_OF_MEMORY); |
| 9750 | } |
| 9751 | } |
| 9752 | |
| 9753 | void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) |
| 9754 | { |
| 9755 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)", |
| 9756 | buffer, drawbuffer, value); |
| 9757 | |
| 9758 | try |
| 9759 | { |
| 9760 | gl::Context *context = gl::getNonLostContext(); |
| 9761 | |
| 9762 | if (context) |
| 9763 | { |
| 9764 | if (context->getClientVersion() < 3) |
| 9765 | { |
| 9766 | return gl::error(GL_INVALID_OPERATION); |
| 9767 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9768 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9769 | UNIMPLEMENTED(); |
| 9770 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9771 | } |
| 9772 | catch(std::bad_alloc&) |
| 9773 | { |
| 9774 | return gl::error(GL_OUT_OF_MEMORY); |
| 9775 | } |
| 9776 | } |
| 9777 | |
| 9778 | void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) |
| 9779 | { |
| 9780 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)", |
| 9781 | buffer, drawbuffer, value); |
| 9782 | |
| 9783 | try |
| 9784 | { |
| 9785 | gl::Context *context = gl::getNonLostContext(); |
| 9786 | |
| 9787 | if (context) |
| 9788 | { |
| 9789 | if (context->getClientVersion() < 3) |
| 9790 | { |
| 9791 | return gl::error(GL_INVALID_OPERATION); |
| 9792 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9793 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9794 | UNIMPLEMENTED(); |
| 9795 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9796 | } |
| 9797 | catch(std::bad_alloc&) |
| 9798 | { |
| 9799 | return gl::error(GL_OUT_OF_MEMORY); |
| 9800 | } |
| 9801 | } |
| 9802 | |
| 9803 | void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 9804 | { |
| 9805 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)", |
| 9806 | buffer, drawbuffer, depth, stencil); |
| 9807 | |
| 9808 | try |
| 9809 | { |
| 9810 | gl::Context *context = gl::getNonLostContext(); |
| 9811 | |
| 9812 | if (context) |
| 9813 | { |
| 9814 | if (context->getClientVersion() < 3) |
| 9815 | { |
| 9816 | return gl::error(GL_INVALID_OPERATION); |
| 9817 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9818 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9819 | UNIMPLEMENTED(); |
| 9820 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9821 | } |
| 9822 | catch(std::bad_alloc&) |
| 9823 | { |
| 9824 | return gl::error(GL_OUT_OF_MEMORY); |
| 9825 | } |
| 9826 | } |
| 9827 | |
| 9828 | const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) |
| 9829 | { |
| 9830 | EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index); |
| 9831 | |
| 9832 | try |
| 9833 | { |
| 9834 | gl::Context *context = gl::getNonLostContext(); |
| 9835 | |
| 9836 | if (context) |
| 9837 | { |
| 9838 | if (context->getClientVersion() < 3) |
| 9839 | { |
| 9840 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL)); |
| 9841 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9842 | |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 9843 | if (name != GL_EXTENSIONS) |
| 9844 | { |
| 9845 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL)); |
| 9846 | } |
| 9847 | |
| 9848 | if (index >= context->getNumExtensions()) |
| 9849 | { |
| 9850 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL)); |
| 9851 | } |
| 9852 | |
| 9853 | return reinterpret_cast<const GLubyte*>(context->getExtensionString(index)); |
| 9854 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9855 | } |
| 9856 | catch(std::bad_alloc&) |
| 9857 | { |
| 9858 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL)); |
| 9859 | } |
| 9860 | |
| 9861 | return NULL; |
| 9862 | } |
| 9863 | |
| 9864 | void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 9865 | { |
| 9866 | EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)", |
| 9867 | readTarget, writeTarget, readOffset, writeOffset, size); |
| 9868 | |
| 9869 | try |
| 9870 | { |
| 9871 | gl::Context *context = gl::getNonLostContext(); |
| 9872 | |
| 9873 | if (context) |
| 9874 | { |
| 9875 | if (context->getClientVersion() < 3) |
| 9876 | { |
| 9877 | return gl::error(GL_INVALID_OPERATION); |
| 9878 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9879 | |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 9880 | gl::Buffer *readBuffer = NULL; |
| 9881 | switch (readTarget) |
| 9882 | { |
| 9883 | case GL_ARRAY_BUFFER: |
| 9884 | readBuffer = context->getArrayBuffer(); |
| 9885 | break; |
| 9886 | case GL_COPY_READ_BUFFER: |
| 9887 | readBuffer = context->getCopyReadBuffer(); |
| 9888 | break; |
| 9889 | case GL_COPY_WRITE_BUFFER: |
| 9890 | readBuffer = context->getCopyWriteBuffer(); |
| 9891 | break; |
| 9892 | case GL_ELEMENT_ARRAY_BUFFER: |
| 9893 | readBuffer = context->getElementArrayBuffer(); |
| 9894 | break; |
| 9895 | case GL_PIXEL_PACK_BUFFER: |
| 9896 | readBuffer = context->getPixelPackBuffer(); |
| 9897 | break; |
| 9898 | case GL_PIXEL_UNPACK_BUFFER: |
| 9899 | readBuffer = context->getPixelUnpackBuffer(); |
| 9900 | break; |
| 9901 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 9902 | readBuffer = context->getGenericTransformFeedbackBuffer(); |
| 9903 | break; |
| 9904 | case GL_UNIFORM_BUFFER: |
| 9905 | readBuffer = context->getGenericUniformBuffer(); |
| 9906 | break; |
| 9907 | default: |
| 9908 | return gl::error(GL_INVALID_ENUM); |
| 9909 | } |
| 9910 | |
| 9911 | gl::Buffer *writeBuffer = NULL; |
| 9912 | switch (writeTarget) |
| 9913 | { |
| 9914 | case GL_ARRAY_BUFFER: |
| 9915 | writeBuffer = context->getArrayBuffer(); |
| 9916 | break; |
| 9917 | case GL_COPY_READ_BUFFER: |
| 9918 | writeBuffer = context->getCopyReadBuffer(); |
| 9919 | break; |
| 9920 | case GL_COPY_WRITE_BUFFER: |
| 9921 | writeBuffer = context->getCopyWriteBuffer(); |
| 9922 | break; |
| 9923 | case GL_ELEMENT_ARRAY_BUFFER: |
| 9924 | writeBuffer = context->getElementArrayBuffer(); |
| 9925 | break; |
| 9926 | case GL_PIXEL_PACK_BUFFER: |
| 9927 | writeBuffer = context->getPixelPackBuffer(); |
| 9928 | break; |
| 9929 | case GL_PIXEL_UNPACK_BUFFER: |
| 9930 | writeBuffer = context->getPixelUnpackBuffer(); |
| 9931 | break; |
| 9932 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 9933 | writeBuffer = context->getGenericTransformFeedbackBuffer(); |
| 9934 | break; |
| 9935 | case GL_UNIFORM_BUFFER: |
| 9936 | writeBuffer = context->getGenericUniformBuffer(); |
| 9937 | break; |
| 9938 | default: |
| 9939 | return gl::error(GL_INVALID_ENUM); |
| 9940 | } |
| 9941 | |
| 9942 | if (!readBuffer || !writeBuffer) |
| 9943 | { |
| 9944 | return gl::error(GL_INVALID_OPERATION); |
| 9945 | } |
| 9946 | |
| 9947 | if (readOffset < 0 || writeOffset < 0 || size < 0 || |
| 9948 | static_cast<unsigned int>(readOffset + size) > readBuffer->size() || |
| 9949 | static_cast<unsigned int>(writeOffset + size) > writeBuffer->size()) |
| 9950 | { |
| 9951 | return gl::error(GL_INVALID_VALUE); |
| 9952 | } |
| 9953 | |
| 9954 | if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size) |
| 9955 | { |
| 9956 | return gl::error(GL_INVALID_VALUE); |
| 9957 | } |
| 9958 | |
| 9959 | // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION) |
| 9960 | |
shannon.woods%transgaming.com@gtempaccount.com | c53376a | 2013-04-13 03:41:23 +0000 | [diff] [blame] | 9961 | // if size is zero, the copy is a successful no-op |
| 9962 | if (size > 0) |
| 9963 | { |
| 9964 | writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); |
| 9965 | } |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 9966 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9967 | } |
| 9968 | catch(std::bad_alloc&) |
| 9969 | { |
| 9970 | return gl::error(GL_OUT_OF_MEMORY); |
| 9971 | } |
| 9972 | } |
| 9973 | |
| 9974 | void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) |
| 9975 | { |
| 9976 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)", |
| 9977 | program, uniformCount, uniformNames, uniformIndices); |
| 9978 | |
| 9979 | try |
| 9980 | { |
| 9981 | gl::Context *context = gl::getNonLostContext(); |
| 9982 | |
| 9983 | if (context) |
| 9984 | { |
| 9985 | if (context->getClientVersion() < 3) |
| 9986 | { |
| 9987 | return gl::error(GL_INVALID_OPERATION); |
| 9988 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9989 | |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 9990 | if (uniformCount < 0) |
| 9991 | { |
| 9992 | return gl::error(GL_INVALID_VALUE); |
| 9993 | } |
| 9994 | |
| 9995 | gl::Program *programObject = context->getProgram(program); |
| 9996 | |
| 9997 | if (!programObject) |
| 9998 | { |
| 9999 | if (context->getShader(program)) |
| 10000 | { |
| 10001 | return gl::error(GL_INVALID_OPERATION); |
| 10002 | } |
| 10003 | else |
| 10004 | { |
| 10005 | return gl::error(GL_INVALID_VALUE); |
| 10006 | } |
| 10007 | } |
| 10008 | |
| 10009 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10010 | if (!programObject->isLinked() || !programBinary) |
| 10011 | { |
| 10012 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10013 | { |
| 10014 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 10015 | } |
| 10016 | } |
| 10017 | else |
| 10018 | { |
| 10019 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10020 | { |
| 10021 | uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]); |
| 10022 | } |
| 10023 | } |
| 10024 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10025 | } |
| 10026 | catch(std::bad_alloc&) |
| 10027 | { |
| 10028 | return gl::error(GL_OUT_OF_MEMORY); |
| 10029 | } |
| 10030 | } |
| 10031 | |
| 10032 | void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) |
| 10033 | { |
| 10034 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10035 | program, uniformCount, uniformIndices, pname, params); |
| 10036 | |
| 10037 | try |
| 10038 | { |
| 10039 | gl::Context *context = gl::getNonLostContext(); |
| 10040 | |
| 10041 | if (context) |
| 10042 | { |
| 10043 | if (context->getClientVersion() < 3) |
| 10044 | { |
| 10045 | return gl::error(GL_INVALID_OPERATION); |
| 10046 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10047 | |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 10048 | if (uniformCount < 0) |
| 10049 | { |
| 10050 | return gl::error(GL_INVALID_VALUE); |
| 10051 | } |
| 10052 | |
| 10053 | gl::Program *programObject = context->getProgram(program); |
| 10054 | |
| 10055 | if (!programObject) |
| 10056 | { |
| 10057 | if (context->getShader(program)) |
| 10058 | { |
| 10059 | return gl::error(GL_INVALID_OPERATION); |
| 10060 | } |
| 10061 | else |
| 10062 | { |
| 10063 | return gl::error(GL_INVALID_VALUE); |
| 10064 | } |
| 10065 | } |
| 10066 | |
| 10067 | switch (pname) |
| 10068 | { |
| 10069 | case GL_UNIFORM_TYPE: |
| 10070 | case GL_UNIFORM_SIZE: |
| 10071 | case GL_UNIFORM_NAME_LENGTH: |
| 10072 | case GL_UNIFORM_BLOCK_INDEX: |
| 10073 | case GL_UNIFORM_OFFSET: |
| 10074 | case GL_UNIFORM_ARRAY_STRIDE: |
| 10075 | case GL_UNIFORM_MATRIX_STRIDE: |
| 10076 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 10077 | break; |
| 10078 | default: |
| 10079 | return gl::error(GL_INVALID_ENUM); |
| 10080 | } |
| 10081 | |
| 10082 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10083 | |
| 10084 | if (!programBinary && uniformCount > 0) |
| 10085 | { |
| 10086 | return gl::error(GL_INVALID_VALUE); |
| 10087 | } |
| 10088 | |
| 10089 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10090 | { |
| 10091 | const GLuint index = uniformIndices[uniformId]; |
| 10092 | |
| 10093 | if (index >= (GLuint)programBinary->getActiveUniformCount()) |
| 10094 | { |
| 10095 | return gl::error(GL_INVALID_VALUE); |
| 10096 | } |
| 10097 | } |
| 10098 | |
| 10099 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10100 | { |
| 10101 | const GLuint index = uniformIndices[uniformId]; |
| 10102 | params[uniformId] = programBinary->getActiveUniformi(index, pname); |
| 10103 | } |
| 10104 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10105 | } |
| 10106 | catch(std::bad_alloc&) |
| 10107 | { |
| 10108 | return gl::error(GL_OUT_OF_MEMORY); |
| 10109 | } |
| 10110 | } |
| 10111 | |
| 10112 | GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) |
| 10113 | { |
| 10114 | EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName); |
| 10115 | |
| 10116 | try |
| 10117 | { |
| 10118 | gl::Context *context = gl::getNonLostContext(); |
| 10119 | |
| 10120 | if (context) |
| 10121 | { |
| 10122 | if (context->getClientVersion() < 3) |
| 10123 | { |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10124 | 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] | 10125 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10126 | |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10127 | gl::Program *programObject = context->getProgram(program); |
| 10128 | |
| 10129 | if (!programObject) |
| 10130 | { |
| 10131 | if (context->getShader(program)) |
| 10132 | { |
| 10133 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
| 10134 | } |
| 10135 | else |
| 10136 | { |
| 10137 | return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX); |
| 10138 | } |
| 10139 | } |
| 10140 | |
| 10141 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10142 | if (!programBinary) |
| 10143 | { |
| 10144 | return GL_INVALID_INDEX; |
| 10145 | } |
| 10146 | |
| 10147 | return programBinary->getUniformBlockIndex(uniformBlockName); |
| 10148 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10149 | } |
| 10150 | catch(std::bad_alloc&) |
| 10151 | { |
| 10152 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10153 | } |
| 10154 | |
| 10155 | return 0; |
| 10156 | } |
| 10157 | |
| 10158 | void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) |
| 10159 | { |
| 10160 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10161 | program, uniformBlockIndex, pname, params); |
| 10162 | |
| 10163 | try |
| 10164 | { |
| 10165 | gl::Context *context = gl::getNonLostContext(); |
| 10166 | |
| 10167 | if (context) |
| 10168 | { |
| 10169 | if (context->getClientVersion() < 3) |
| 10170 | { |
| 10171 | return gl::error(GL_INVALID_OPERATION); |
| 10172 | } |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10173 | gl::Program *programObject = context->getProgram(program); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10174 | |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10175 | if (!programObject) |
| 10176 | { |
| 10177 | if (context->getShader(program)) |
| 10178 | { |
| 10179 | return gl::error(GL_INVALID_OPERATION); |
| 10180 | } |
| 10181 | else |
| 10182 | { |
| 10183 | return gl::error(GL_INVALID_VALUE); |
| 10184 | } |
| 10185 | } |
| 10186 | |
| 10187 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10188 | |
| 10189 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10190 | { |
| 10191 | return gl::error(GL_INVALID_VALUE); |
| 10192 | } |
| 10193 | |
| 10194 | switch (pname) |
| 10195 | { |
| 10196 | case GL_UNIFORM_BLOCK_BINDING: |
| 10197 | *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); |
| 10198 | break; |
| 10199 | |
| 10200 | case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 10201 | case GL_UNIFORM_BLOCK_NAME_LENGTH: |
| 10202 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 10203 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| 10204 | case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
| 10205 | case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
| 10206 | programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params); |
| 10207 | break; |
| 10208 | |
| 10209 | default: |
| 10210 | return gl::error(GL_INVALID_ENUM); |
| 10211 | } |
| 10212 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10213 | } |
| 10214 | catch(std::bad_alloc&) |
| 10215 | { |
| 10216 | return gl::error(GL_OUT_OF_MEMORY); |
| 10217 | } |
| 10218 | } |
| 10219 | |
| 10220 | void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) |
| 10221 | { |
| 10222 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)", |
| 10223 | program, uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10224 | |
| 10225 | try |
| 10226 | { |
| 10227 | gl::Context *context = gl::getNonLostContext(); |
| 10228 | |
| 10229 | if (context) |
| 10230 | { |
| 10231 | if (context->getClientVersion() < 3) |
| 10232 | { |
| 10233 | return gl::error(GL_INVALID_OPERATION); |
| 10234 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10235 | |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 10236 | gl::Program *programObject = context->getProgram(program); |
| 10237 | |
| 10238 | if (!programObject) |
| 10239 | { |
| 10240 | if (context->getShader(program)) |
| 10241 | { |
| 10242 | return gl::error(GL_INVALID_OPERATION); |
| 10243 | } |
| 10244 | else |
| 10245 | { |
| 10246 | return gl::error(GL_INVALID_VALUE); |
| 10247 | } |
| 10248 | } |
| 10249 | |
| 10250 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10251 | |
| 10252 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10253 | { |
| 10254 | return gl::error(GL_INVALID_VALUE); |
| 10255 | } |
| 10256 | |
| 10257 | programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10258 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10259 | } |
| 10260 | catch(std::bad_alloc&) |
| 10261 | { |
| 10262 | return gl::error(GL_OUT_OF_MEMORY); |
| 10263 | } |
| 10264 | } |
| 10265 | |
| 10266 | void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) |
| 10267 | { |
| 10268 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)", |
| 10269 | program, uniformBlockIndex, uniformBlockBinding); |
| 10270 | |
| 10271 | try |
| 10272 | { |
| 10273 | gl::Context *context = gl::getNonLostContext(); |
| 10274 | |
| 10275 | if (context) |
| 10276 | { |
| 10277 | if (context->getClientVersion() < 3) |
| 10278 | { |
| 10279 | return gl::error(GL_INVALID_OPERATION); |
| 10280 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10281 | |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 10282 | if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings()) |
| 10283 | { |
| 10284 | return gl::error(GL_INVALID_VALUE); |
| 10285 | } |
| 10286 | |
| 10287 | gl::Program *programObject = context->getProgram(program); |
| 10288 | |
| 10289 | if (!programObject) |
| 10290 | { |
| 10291 | if (context->getShader(program)) |
| 10292 | { |
| 10293 | return gl::error(GL_INVALID_OPERATION); |
| 10294 | } |
| 10295 | else |
| 10296 | { |
| 10297 | return gl::error(GL_INVALID_VALUE); |
| 10298 | } |
| 10299 | } |
| 10300 | |
| 10301 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10302 | |
| 10303 | // if never linked, there won't be any uniform blocks |
| 10304 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10305 | { |
| 10306 | return gl::error(GL_INVALID_VALUE); |
| 10307 | } |
| 10308 | |
| 10309 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
| 10310 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10311 | } |
| 10312 | catch(std::bad_alloc&) |
| 10313 | { |
| 10314 | return gl::error(GL_OUT_OF_MEMORY); |
| 10315 | } |
| 10316 | } |
| 10317 | |
| 10318 | void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 10319 | { |
| 10320 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)", |
| 10321 | mode, first, count, instanceCount); |
| 10322 | |
| 10323 | try |
| 10324 | { |
| 10325 | gl::Context *context = gl::getNonLostContext(); |
| 10326 | |
| 10327 | if (context) |
| 10328 | { |
| 10329 | if (context->getClientVersion() < 3) |
| 10330 | { |
| 10331 | return gl::error(GL_INVALID_OPERATION); |
| 10332 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10333 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10334 | UNIMPLEMENTED(); |
| 10335 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10336 | } |
| 10337 | catch(std::bad_alloc&) |
| 10338 | { |
| 10339 | return gl::error(GL_OUT_OF_MEMORY); |
| 10340 | } |
| 10341 | } |
| 10342 | |
| 10343 | void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) |
| 10344 | { |
| 10345 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)", |
| 10346 | mode, count, type, indices, instanceCount); |
| 10347 | |
| 10348 | try |
| 10349 | { |
| 10350 | gl::Context *context = gl::getNonLostContext(); |
| 10351 | |
| 10352 | if (context) |
| 10353 | { |
| 10354 | if (context->getClientVersion() < 3) |
| 10355 | { |
| 10356 | return gl::error(GL_INVALID_OPERATION); |
| 10357 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10358 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10359 | UNIMPLEMENTED(); |
| 10360 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10361 | } |
| 10362 | catch(std::bad_alloc&) |
| 10363 | { |
| 10364 | return gl::error(GL_OUT_OF_MEMORY); |
| 10365 | } |
| 10366 | } |
| 10367 | |
| 10368 | GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags) |
| 10369 | { |
| 10370 | EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags); |
| 10371 | |
| 10372 | try |
| 10373 | { |
| 10374 | gl::Context *context = gl::getNonLostContext(); |
| 10375 | |
| 10376 | if (context) |
| 10377 | { |
| 10378 | if (context->getClientVersion() < 3) |
| 10379 | { |
| 10380 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(NULL)); |
| 10381 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10382 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10383 | UNIMPLEMENTED(); |
| 10384 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10385 | } |
| 10386 | catch(std::bad_alloc&) |
| 10387 | { |
| 10388 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL)); |
| 10389 | } |
| 10390 | |
| 10391 | return NULL; |
| 10392 | } |
| 10393 | |
| 10394 | GLboolean __stdcall glIsSync(GLsync sync) |
| 10395 | { |
| 10396 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10397 | |
| 10398 | try |
| 10399 | { |
| 10400 | gl::Context *context = gl::getNonLostContext(); |
| 10401 | |
| 10402 | if (context) |
| 10403 | { |
| 10404 | if (context->getClientVersion() < 3) |
| 10405 | { |
| 10406 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10407 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10408 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10409 | UNIMPLEMENTED(); |
| 10410 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10411 | } |
| 10412 | catch(std::bad_alloc&) |
| 10413 | { |
| 10414 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10415 | } |
| 10416 | |
| 10417 | return GL_FALSE; |
| 10418 | } |
| 10419 | |
| 10420 | void __stdcall glDeleteSync(GLsync sync) |
| 10421 | { |
| 10422 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10423 | |
| 10424 | try |
| 10425 | { |
| 10426 | gl::Context *context = gl::getNonLostContext(); |
| 10427 | |
| 10428 | if (context) |
| 10429 | { |
| 10430 | if (context->getClientVersion() < 3) |
| 10431 | { |
| 10432 | return gl::error(GL_INVALID_OPERATION); |
| 10433 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10434 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10435 | UNIMPLEMENTED(); |
| 10436 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10437 | } |
| 10438 | catch(std::bad_alloc&) |
| 10439 | { |
| 10440 | return gl::error(GL_OUT_OF_MEMORY); |
| 10441 | } |
| 10442 | } |
| 10443 | |
| 10444 | GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10445 | { |
| 10446 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10447 | sync, flags, timeout); |
| 10448 | |
| 10449 | try |
| 10450 | { |
| 10451 | gl::Context *context = gl::getNonLostContext(); |
| 10452 | |
| 10453 | if (context) |
| 10454 | { |
| 10455 | if (context->getClientVersion() < 3) |
| 10456 | { |
| 10457 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10458 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10459 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10460 | UNIMPLEMENTED(); |
| 10461 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10462 | } |
| 10463 | catch(std::bad_alloc&) |
| 10464 | { |
| 10465 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10466 | } |
| 10467 | |
| 10468 | return GL_FALSE; |
| 10469 | } |
| 10470 | |
| 10471 | void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10472 | { |
| 10473 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10474 | sync, flags, timeout); |
| 10475 | |
| 10476 | try |
| 10477 | { |
| 10478 | gl::Context *context = gl::getNonLostContext(); |
| 10479 | |
| 10480 | if (context) |
| 10481 | { |
| 10482 | if (context->getClientVersion() < 3) |
| 10483 | { |
| 10484 | return gl::error(GL_INVALID_OPERATION); |
| 10485 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10486 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10487 | UNIMPLEMENTED(); |
| 10488 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10489 | } |
| 10490 | catch(std::bad_alloc&) |
| 10491 | { |
| 10492 | return gl::error(GL_OUT_OF_MEMORY); |
| 10493 | } |
| 10494 | } |
| 10495 | |
| 10496 | void __stdcall glGetInteger64v(GLenum pname, GLint64* params) |
| 10497 | { |
| 10498 | EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10499 | pname, params); |
| 10500 | |
| 10501 | try |
| 10502 | { |
| 10503 | gl::Context *context = gl::getNonLostContext(); |
| 10504 | |
| 10505 | if (context) |
| 10506 | { |
| 10507 | if (context->getClientVersion() < 3) |
| 10508 | { |
| 10509 | return gl::error(GL_INVALID_OPERATION); |
| 10510 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10511 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10512 | UNIMPLEMENTED(); |
| 10513 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10514 | } |
| 10515 | catch(std::bad_alloc&) |
| 10516 | { |
| 10517 | return gl::error(GL_OUT_OF_MEMORY); |
| 10518 | } |
| 10519 | } |
| 10520 | |
| 10521 | void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) |
| 10522 | { |
| 10523 | EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)", |
| 10524 | sync, pname, bufSize, length, values); |
| 10525 | |
| 10526 | try |
| 10527 | { |
| 10528 | gl::Context *context = gl::getNonLostContext(); |
| 10529 | |
| 10530 | if (context) |
| 10531 | { |
| 10532 | if (context->getClientVersion() < 3) |
| 10533 | { |
| 10534 | return gl::error(GL_INVALID_OPERATION); |
| 10535 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10536 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10537 | UNIMPLEMENTED(); |
| 10538 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10539 | } |
| 10540 | catch(std::bad_alloc&) |
| 10541 | { |
| 10542 | return gl::error(GL_OUT_OF_MEMORY); |
| 10543 | } |
| 10544 | } |
| 10545 | |
| 10546 | void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) |
| 10547 | { |
| 10548 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)", |
| 10549 | target, index, data); |
| 10550 | |
| 10551 | try |
| 10552 | { |
| 10553 | gl::Context *context = gl::getNonLostContext(); |
| 10554 | |
| 10555 | if (context) |
| 10556 | { |
| 10557 | if (context->getClientVersion() < 3) |
| 10558 | { |
| 10559 | return gl::error(GL_INVALID_OPERATION); |
| 10560 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10561 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10562 | UNIMPLEMENTED(); |
| 10563 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10564 | } |
| 10565 | catch(std::bad_alloc&) |
| 10566 | { |
| 10567 | return gl::error(GL_OUT_OF_MEMORY); |
| 10568 | } |
| 10569 | } |
| 10570 | |
| 10571 | void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) |
| 10572 | { |
| 10573 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10574 | target, pname, params); |
| 10575 | |
| 10576 | try |
| 10577 | { |
| 10578 | gl::Context *context = gl::getNonLostContext(); |
| 10579 | |
| 10580 | if (context) |
| 10581 | { |
| 10582 | if (context->getClientVersion() < 3) |
| 10583 | { |
| 10584 | return gl::error(GL_INVALID_OPERATION); |
| 10585 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10586 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10587 | UNIMPLEMENTED(); |
| 10588 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10589 | } |
| 10590 | catch(std::bad_alloc&) |
| 10591 | { |
| 10592 | return gl::error(GL_OUT_OF_MEMORY); |
| 10593 | } |
| 10594 | } |
| 10595 | |
| 10596 | void __stdcall glGenSamplers(GLsizei count, GLuint* samplers) |
| 10597 | { |
| 10598 | EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers); |
| 10599 | |
| 10600 | try |
| 10601 | { |
| 10602 | gl::Context *context = gl::getNonLostContext(); |
| 10603 | |
| 10604 | if (context) |
| 10605 | { |
| 10606 | if (context->getClientVersion() < 3) |
| 10607 | { |
| 10608 | return gl::error(GL_INVALID_OPERATION); |
| 10609 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10610 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10611 | UNIMPLEMENTED(); |
| 10612 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10613 | } |
| 10614 | catch(std::bad_alloc&) |
| 10615 | { |
| 10616 | return gl::error(GL_OUT_OF_MEMORY); |
| 10617 | } |
| 10618 | } |
| 10619 | |
| 10620 | void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers) |
| 10621 | { |
| 10622 | EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers); |
| 10623 | |
| 10624 | try |
| 10625 | { |
| 10626 | gl::Context *context = gl::getNonLostContext(); |
| 10627 | |
| 10628 | if (context) |
| 10629 | { |
| 10630 | if (context->getClientVersion() < 3) |
| 10631 | { |
| 10632 | return gl::error(GL_INVALID_OPERATION); |
| 10633 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10634 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10635 | UNIMPLEMENTED(); |
| 10636 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10637 | } |
| 10638 | catch(std::bad_alloc&) |
| 10639 | { |
| 10640 | return gl::error(GL_OUT_OF_MEMORY); |
| 10641 | } |
| 10642 | } |
| 10643 | |
| 10644 | GLboolean __stdcall glIsSampler(GLuint sampler) |
| 10645 | { |
| 10646 | EVENT("(GLuint sampler = %u)", sampler); |
| 10647 | |
| 10648 | try |
| 10649 | { |
| 10650 | gl::Context *context = gl::getNonLostContext(); |
| 10651 | |
| 10652 | if (context) |
| 10653 | { |
| 10654 | if (context->getClientVersion() < 3) |
| 10655 | { |
| 10656 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10657 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10658 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10659 | UNIMPLEMENTED(); |
| 10660 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10661 | } |
| 10662 | catch(std::bad_alloc&) |
| 10663 | { |
| 10664 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10665 | } |
| 10666 | |
| 10667 | return GL_FALSE; |
| 10668 | } |
| 10669 | |
| 10670 | void __stdcall glBindSampler(GLuint unit, GLuint sampler) |
| 10671 | { |
| 10672 | EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler); |
| 10673 | |
| 10674 | try |
| 10675 | { |
| 10676 | gl::Context *context = gl::getNonLostContext(); |
| 10677 | |
| 10678 | if (context) |
| 10679 | { |
| 10680 | if (context->getClientVersion() < 3) |
| 10681 | { |
| 10682 | return gl::error(GL_INVALID_OPERATION); |
| 10683 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10684 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10685 | UNIMPLEMENTED(); |
| 10686 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10687 | } |
| 10688 | catch(std::bad_alloc&) |
| 10689 | { |
| 10690 | return gl::error(GL_OUT_OF_MEMORY); |
| 10691 | } |
| 10692 | } |
| 10693 | |
| 10694 | void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 10695 | { |
| 10696 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param); |
| 10697 | |
| 10698 | try |
| 10699 | { |
| 10700 | gl::Context *context = gl::getNonLostContext(); |
| 10701 | |
| 10702 | if (context) |
| 10703 | { |
| 10704 | if (context->getClientVersion() < 3) |
| 10705 | { |
| 10706 | return gl::error(GL_INVALID_OPERATION); |
| 10707 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10708 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10709 | UNIMPLEMENTED(); |
| 10710 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10711 | } |
| 10712 | catch(std::bad_alloc&) |
| 10713 | { |
| 10714 | return gl::error(GL_OUT_OF_MEMORY); |
| 10715 | } |
| 10716 | } |
| 10717 | |
| 10718 | void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) |
| 10719 | { |
| 10720 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLint* param = 0x%0.8p)", |
| 10721 | sampler, pname, param); |
| 10722 | |
| 10723 | try |
| 10724 | { |
| 10725 | gl::Context *context = gl::getNonLostContext(); |
| 10726 | |
| 10727 | if (context) |
| 10728 | { |
| 10729 | if (context->getClientVersion() < 3) |
| 10730 | { |
| 10731 | return gl::error(GL_INVALID_OPERATION); |
| 10732 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10733 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10734 | UNIMPLEMENTED(); |
| 10735 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10736 | } |
| 10737 | catch(std::bad_alloc&) |
| 10738 | { |
| 10739 | return gl::error(GL_OUT_OF_MEMORY); |
| 10740 | } |
| 10741 | } |
| 10742 | |
| 10743 | void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 10744 | { |
| 10745 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param); |
| 10746 | |
| 10747 | try |
| 10748 | { |
| 10749 | gl::Context *context = gl::getNonLostContext(); |
| 10750 | |
| 10751 | if (context) |
| 10752 | { |
| 10753 | if (context->getClientVersion() < 3) |
| 10754 | { |
| 10755 | return gl::error(GL_INVALID_OPERATION); |
| 10756 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10757 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10758 | UNIMPLEMENTED(); |
| 10759 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10760 | } |
| 10761 | catch(std::bad_alloc&) |
| 10762 | { |
| 10763 | return gl::error(GL_OUT_OF_MEMORY); |
| 10764 | } |
| 10765 | } |
| 10766 | |
| 10767 | void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) |
| 10768 | { |
| 10769 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLfloat* param = 0x%0.8p)", sampler, pname, param); |
| 10770 | |
| 10771 | try |
| 10772 | { |
| 10773 | gl::Context *context = gl::getNonLostContext(); |
| 10774 | |
| 10775 | if (context) |
| 10776 | { |
| 10777 | if (context->getClientVersion() < 3) |
| 10778 | { |
| 10779 | return gl::error(GL_INVALID_OPERATION); |
| 10780 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10781 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10782 | UNIMPLEMENTED(); |
| 10783 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10784 | } |
| 10785 | catch(std::bad_alloc&) |
| 10786 | { |
| 10787 | return gl::error(GL_OUT_OF_MEMORY); |
| 10788 | } |
| 10789 | } |
| 10790 | |
| 10791 | void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) |
| 10792 | { |
| 10793 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); |
| 10794 | |
| 10795 | try |
| 10796 | { |
| 10797 | gl::Context *context = gl::getNonLostContext(); |
| 10798 | |
| 10799 | if (context) |
| 10800 | { |
| 10801 | if (context->getClientVersion() < 3) |
| 10802 | { |
| 10803 | return gl::error(GL_INVALID_OPERATION); |
| 10804 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10805 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10806 | UNIMPLEMENTED(); |
| 10807 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10808 | } |
| 10809 | catch(std::bad_alloc&) |
| 10810 | { |
| 10811 | return gl::error(GL_OUT_OF_MEMORY); |
| 10812 | } |
| 10813 | } |
| 10814 | |
| 10815 | void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) |
| 10816 | { |
| 10817 | EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params); |
| 10818 | |
| 10819 | try |
| 10820 | { |
| 10821 | gl::Context *context = gl::getNonLostContext(); |
| 10822 | |
| 10823 | if (context) |
| 10824 | { |
| 10825 | if (context->getClientVersion() < 3) |
| 10826 | { |
| 10827 | return gl::error(GL_INVALID_OPERATION); |
| 10828 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10829 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10830 | UNIMPLEMENTED(); |
| 10831 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10832 | } |
| 10833 | catch(std::bad_alloc&) |
| 10834 | { |
| 10835 | return gl::error(GL_OUT_OF_MEMORY); |
| 10836 | } |
| 10837 | } |
| 10838 | |
| 10839 | void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor) |
| 10840 | { |
| 10841 | EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor); |
| 10842 | |
| 10843 | try |
| 10844 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 10845 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 10846 | { |
| 10847 | return gl::error(GL_INVALID_VALUE); |
| 10848 | } |
| 10849 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10850 | gl::Context *context = gl::getNonLostContext(); |
| 10851 | |
| 10852 | if (context) |
| 10853 | { |
| 10854 | if (context->getClientVersion() < 3) |
| 10855 | { |
| 10856 | return gl::error(GL_INVALID_OPERATION); |
| 10857 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10858 | |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 10859 | context->setVertexAttribDivisor(index, divisor); |
| 10860 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10861 | } |
| 10862 | catch(std::bad_alloc&) |
| 10863 | { |
| 10864 | return gl::error(GL_OUT_OF_MEMORY); |
| 10865 | } |
| 10866 | } |
| 10867 | |
| 10868 | void __stdcall glBindTransformFeedback(GLenum target, GLuint id) |
| 10869 | { |
| 10870 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 10871 | |
| 10872 | try |
| 10873 | { |
| 10874 | gl::Context *context = gl::getNonLostContext(); |
| 10875 | |
| 10876 | if (context) |
| 10877 | { |
| 10878 | if (context->getClientVersion() < 3) |
| 10879 | { |
| 10880 | return gl::error(GL_INVALID_OPERATION); |
| 10881 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10882 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10883 | UNIMPLEMENTED(); |
| 10884 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10885 | } |
| 10886 | catch(std::bad_alloc&) |
| 10887 | { |
| 10888 | return gl::error(GL_OUT_OF_MEMORY); |
| 10889 | } |
| 10890 | } |
| 10891 | |
| 10892 | void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) |
| 10893 | { |
| 10894 | EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids); |
| 10895 | |
| 10896 | try |
| 10897 | { |
| 10898 | gl::Context *context = gl::getNonLostContext(); |
| 10899 | |
| 10900 | if (context) |
| 10901 | { |
| 10902 | if (context->getClientVersion() < 3) |
| 10903 | { |
| 10904 | return gl::error(GL_INVALID_OPERATION); |
| 10905 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10906 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10907 | UNIMPLEMENTED(); |
| 10908 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10909 | } |
| 10910 | catch(std::bad_alloc&) |
| 10911 | { |
| 10912 | return gl::error(GL_OUT_OF_MEMORY); |
| 10913 | } |
| 10914 | } |
| 10915 | |
| 10916 | void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids) |
| 10917 | { |
| 10918 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 10919 | |
| 10920 | try |
| 10921 | { |
| 10922 | gl::Context *context = gl::getNonLostContext(); |
| 10923 | |
| 10924 | if (context) |
| 10925 | { |
| 10926 | if (context->getClientVersion() < 3) |
| 10927 | { |
| 10928 | return gl::error(GL_INVALID_OPERATION); |
| 10929 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10930 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10931 | UNIMPLEMENTED(); |
| 10932 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10933 | } |
| 10934 | catch(std::bad_alloc&) |
| 10935 | { |
| 10936 | return gl::error(GL_OUT_OF_MEMORY); |
| 10937 | } |
| 10938 | } |
| 10939 | |
| 10940 | GLboolean __stdcall glIsTransformFeedback(GLuint id) |
| 10941 | { |
| 10942 | EVENT("(GLuint id = %u)", id); |
| 10943 | |
| 10944 | try |
| 10945 | { |
| 10946 | gl::Context *context = gl::getNonLostContext(); |
| 10947 | |
| 10948 | if (context) |
| 10949 | { |
| 10950 | if (context->getClientVersion() < 3) |
| 10951 | { |
| 10952 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10953 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10954 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10955 | UNIMPLEMENTED(); |
| 10956 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10957 | } |
| 10958 | catch(std::bad_alloc&) |
| 10959 | { |
| 10960 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10961 | } |
| 10962 | |
| 10963 | return GL_FALSE; |
| 10964 | } |
| 10965 | |
| 10966 | void __stdcall glPauseTransformFeedback(void) |
| 10967 | { |
| 10968 | EVENT("(void)"); |
| 10969 | |
| 10970 | try |
| 10971 | { |
| 10972 | gl::Context *context = gl::getNonLostContext(); |
| 10973 | |
| 10974 | if (context) |
| 10975 | { |
| 10976 | if (context->getClientVersion() < 3) |
| 10977 | { |
| 10978 | return gl::error(GL_INVALID_OPERATION); |
| 10979 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10980 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10981 | UNIMPLEMENTED(); |
| 10982 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10983 | } |
| 10984 | catch(std::bad_alloc&) |
| 10985 | { |
| 10986 | return gl::error(GL_OUT_OF_MEMORY); |
| 10987 | } |
| 10988 | } |
| 10989 | |
| 10990 | void __stdcall glResumeTransformFeedback(void) |
| 10991 | { |
| 10992 | EVENT("(void)"); |
| 10993 | |
| 10994 | try |
| 10995 | { |
| 10996 | gl::Context *context = gl::getNonLostContext(); |
| 10997 | |
| 10998 | if (context) |
| 10999 | { |
| 11000 | if (context->getClientVersion() < 3) |
| 11001 | { |
| 11002 | return gl::error(GL_INVALID_OPERATION); |
| 11003 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11004 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11005 | UNIMPLEMENTED(); |
| 11006 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11007 | } |
| 11008 | catch(std::bad_alloc&) |
| 11009 | { |
| 11010 | return gl::error(GL_OUT_OF_MEMORY); |
| 11011 | } |
| 11012 | } |
| 11013 | |
| 11014 | void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) |
| 11015 | { |
| 11016 | EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)", |
| 11017 | program, bufSize, length, binaryFormat, binary); |
| 11018 | |
| 11019 | try |
| 11020 | { |
| 11021 | gl::Context *context = gl::getNonLostContext(); |
| 11022 | |
| 11023 | if (context) |
| 11024 | { |
| 11025 | if (context->getClientVersion() < 3) |
| 11026 | { |
| 11027 | return gl::error(GL_INVALID_OPERATION); |
| 11028 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11029 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11030 | UNIMPLEMENTED(); |
| 11031 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11032 | } |
| 11033 | catch(std::bad_alloc&) |
| 11034 | { |
| 11035 | return gl::error(GL_OUT_OF_MEMORY); |
| 11036 | } |
| 11037 | } |
| 11038 | |
| 11039 | void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) |
| 11040 | { |
| 11041 | EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
| 11042 | program, binaryFormat, binary, length); |
| 11043 | |
| 11044 | try |
| 11045 | { |
| 11046 | gl::Context *context = gl::getNonLostContext(); |
| 11047 | |
| 11048 | if (context) |
| 11049 | { |
| 11050 | if (context->getClientVersion() < 3) |
| 11051 | { |
| 11052 | return gl::error(GL_INVALID_OPERATION); |
| 11053 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11054 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11055 | UNIMPLEMENTED(); |
| 11056 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11057 | } |
| 11058 | catch(std::bad_alloc&) |
| 11059 | { |
| 11060 | return gl::error(GL_OUT_OF_MEMORY); |
| 11061 | } |
| 11062 | } |
| 11063 | |
| 11064 | void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value) |
| 11065 | { |
| 11066 | EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)", |
| 11067 | program, pname, value); |
| 11068 | |
| 11069 | try |
| 11070 | { |
| 11071 | gl::Context *context = gl::getNonLostContext(); |
| 11072 | |
| 11073 | if (context) |
| 11074 | { |
| 11075 | if (context->getClientVersion() < 3) |
| 11076 | { |
| 11077 | return gl::error(GL_INVALID_OPERATION); |
| 11078 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11079 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11080 | UNIMPLEMENTED(); |
| 11081 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11082 | } |
| 11083 | catch(std::bad_alloc&) |
| 11084 | { |
| 11085 | return gl::error(GL_OUT_OF_MEMORY); |
| 11086 | } |
| 11087 | } |
| 11088 | |
| 11089 | void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) |
| 11090 | { |
| 11091 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)", |
| 11092 | target, numAttachments, attachments); |
| 11093 | |
| 11094 | try |
| 11095 | { |
| 11096 | gl::Context *context = gl::getNonLostContext(); |
| 11097 | |
| 11098 | if (context) |
| 11099 | { |
| 11100 | if (context->getClientVersion() < 3) |
| 11101 | { |
| 11102 | return gl::error(GL_INVALID_OPERATION); |
| 11103 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11104 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11105 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11106 | { |
| 11107 | return; |
| 11108 | } |
| 11109 | |
| 11110 | int maxDimension = context->getMaximumRenderbufferDimension(); |
| 11111 | context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension); |
| 11112 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11113 | } |
| 11114 | catch(std::bad_alloc&) |
| 11115 | { |
| 11116 | return gl::error(GL_OUT_OF_MEMORY); |
| 11117 | } |
| 11118 | } |
| 11119 | |
| 11120 | void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) |
| 11121 | { |
| 11122 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, " |
| 11123 | "GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 11124 | target, numAttachments, attachments, x, y, width, height); |
| 11125 | |
| 11126 | try |
| 11127 | { |
| 11128 | gl::Context *context = gl::getNonLostContext(); |
| 11129 | |
| 11130 | if (context) |
| 11131 | { |
| 11132 | if (context->getClientVersion() < 3) |
| 11133 | { |
| 11134 | return gl::error(GL_INVALID_OPERATION); |
| 11135 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11136 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11137 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11138 | { |
| 11139 | return; |
| 11140 | } |
| 11141 | |
| 11142 | context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height); |
| 11143 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11144 | } |
| 11145 | catch(std::bad_alloc&) |
| 11146 | { |
| 11147 | return gl::error(GL_OUT_OF_MEMORY); |
| 11148 | } |
| 11149 | } |
| 11150 | |
| 11151 | void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 11152 | { |
| 11153 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 11154 | target, levels, internalformat, width, height); |
| 11155 | |
| 11156 | try |
| 11157 | { |
| 11158 | gl::Context *context = gl::getNonLostContext(); |
| 11159 | |
| 11160 | if (context) |
| 11161 | { |
| 11162 | if (context->getClientVersion() < 3) |
| 11163 | { |
| 11164 | return gl::error(GL_INVALID_OPERATION); |
| 11165 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11166 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11167 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 11168 | { |
| 11169 | return; |
| 11170 | } |
| 11171 | |
| 11172 | switch (target) |
| 11173 | { |
| 11174 | case GL_TEXTURE_2D: |
| 11175 | { |
| 11176 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 11177 | texture2d->storage(levels, internalformat, width, height); |
| 11178 | } |
| 11179 | break; |
| 11180 | |
| 11181 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 11182 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 11183 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 11184 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 11185 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 11186 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 11187 | { |
| 11188 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 11189 | textureCube->storage(levels, internalformat, width); |
| 11190 | } |
| 11191 | break; |
| 11192 | |
| 11193 | default: |
| 11194 | return gl::error(GL_INVALID_ENUM); |
| 11195 | } |
| 11196 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11197 | } |
| 11198 | catch(std::bad_alloc&) |
| 11199 | { |
| 11200 | return gl::error(GL_OUT_OF_MEMORY); |
| 11201 | } |
| 11202 | } |
| 11203 | |
| 11204 | void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
| 11205 | { |
| 11206 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 11207 | "GLsizei height = %d, GLsizei depth = %d)", |
| 11208 | target, levels, internalformat, width, height, depth); |
| 11209 | |
| 11210 | try |
| 11211 | { |
| 11212 | gl::Context *context = gl::getNonLostContext(); |
| 11213 | |
| 11214 | if (context) |
| 11215 | { |
| 11216 | if (context->getClientVersion() < 3) |
| 11217 | { |
| 11218 | return gl::error(GL_INVALID_OPERATION); |
| 11219 | } |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11220 | |
| 11221 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) |
| 11222 | { |
| 11223 | return; |
| 11224 | } |
| 11225 | |
| 11226 | switch (target) |
| 11227 | { |
| 11228 | case GL_TEXTURE_3D: |
| 11229 | { |
| 11230 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 11231 | texture3d->storage(levels, internalformat, width, height, depth); |
| 11232 | } |
| 11233 | break; |
| 11234 | |
| 11235 | case GL_TEXTURE_2D_ARRAY: |
| 11236 | { |
| 11237 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 11238 | texture2darray->storage(levels, internalformat, width, height, depth); |
| 11239 | } |
| 11240 | break; |
| 11241 | |
| 11242 | default: |
| 11243 | return gl::error(GL_INVALID_ENUM); |
| 11244 | } |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 11245 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11246 | } |
| 11247 | catch(std::bad_alloc&) |
| 11248 | { |
| 11249 | return gl::error(GL_OUT_OF_MEMORY); |
| 11250 | } |
| 11251 | } |
| 11252 | |
| 11253 | void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) |
| 11254 | { |
| 11255 | EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, " |
| 11256 | "GLint* params = 0x%0.8p)", |
| 11257 | target, internalformat, pname, bufSize, params); |
| 11258 | |
| 11259 | try |
| 11260 | { |
| 11261 | gl::Context *context = gl::getNonLostContext(); |
| 11262 | |
| 11263 | if (context) |
| 11264 | { |
| 11265 | if (context->getClientVersion() < 3) |
| 11266 | { |
| 11267 | return gl::error(GL_INVALID_OPERATION); |
| 11268 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11269 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11270 | UNIMPLEMENTED(); |
| 11271 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11272 | } |
| 11273 | catch(std::bad_alloc&) |
| 11274 | { |
| 11275 | return gl::error(GL_OUT_OF_MEMORY); |
| 11276 | } |
| 11277 | } |
| 11278 | |
| 11279 | // Extension functions |
| 11280 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11281 | void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 11282 | GLbitfield mask, GLenum filter) |
| 11283 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11284 | 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] | 11285 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, " |
| 11286 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 11287 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 11288 | |
| 11289 | try |
| 11290 | { |
| 11291 | switch (filter) |
| 11292 | { |
| 11293 | case GL_NEAREST: |
| 11294 | break; |
| 11295 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11296 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11297 | } |
| 11298 | |
| 11299 | if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0) |
| 11300 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11301 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11302 | } |
| 11303 | |
| 11304 | if (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0) |
| 11305 | { |
| 11306 | 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] | 11307 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11308 | } |
| 11309 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11310 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11311 | |
| 11312 | if (context) |
| 11313 | { |
| 11314 | if (context->getReadFramebufferHandle() == context->getDrawFramebufferHandle()) |
| 11315 | { |
| 11316 | 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] | 11317 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11318 | } |
| 11319 | |
| 11320 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask); |
| 11321 | } |
| 11322 | } |
| 11323 | catch(std::bad_alloc&) |
| 11324 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11325 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11326 | } |
| 11327 | } |
| 11328 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 11329 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, |
| 11330 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11331 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11332 | 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] | 11333 | "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] | 11334 | "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] | 11335 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 11336 | |
| 11337 | try |
| 11338 | { |
| 11339 | UNIMPLEMENTED(); // FIXME |
| 11340 | } |
| 11341 | catch(std::bad_alloc&) |
| 11342 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11343 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11344 | } |
| 11345 | } |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11346 | |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11347 | void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, |
| 11348 | GLenum *binaryFormat, void *binary) |
| 11349 | { |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11350 | 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] | 11351 | program, bufSize, length, binaryFormat, binary); |
| 11352 | |
| 11353 | try |
| 11354 | { |
| 11355 | gl::Context *context = gl::getNonLostContext(); |
| 11356 | |
| 11357 | if (context) |
| 11358 | { |
| 11359 | gl::Program *programObject = context->getProgram(program); |
| 11360 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 11361 | if (!programObject || !programObject->isLinked()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11362 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11363 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11364 | } |
| 11365 | |
| 11366 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 11367 | |
| 11368 | if (!programBinary) |
| 11369 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11370 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11371 | } |
| 11372 | |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11373 | if (!programBinary->save(binary, bufSize, length)) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11374 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11375 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11376 | } |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11377 | |
| 11378 | *binaryFormat = GL_PROGRAM_BINARY_ANGLE; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11379 | } |
| 11380 | } |
| 11381 | catch(std::bad_alloc&) |
| 11382 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11383 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11384 | } |
| 11385 | } |
| 11386 | |
| 11387 | void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat, |
| 11388 | const void *binary, GLint length) |
| 11389 | { |
| 11390 | EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)", |
| 11391 | program, binaryFormat, binary, length); |
| 11392 | |
| 11393 | try |
| 11394 | { |
| 11395 | gl::Context *context = gl::getNonLostContext(); |
| 11396 | |
| 11397 | if (context) |
| 11398 | { |
| 11399 | if (binaryFormat != GL_PROGRAM_BINARY_ANGLE) |
| 11400 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11401 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11402 | } |
| 11403 | |
| 11404 | gl::Program *programObject = context->getProgram(program); |
| 11405 | |
| 11406 | if (!programObject) |
| 11407 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11408 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11409 | } |
| 11410 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 11411 | context->setProgramBinary(program, binary, length); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11412 | } |
| 11413 | } |
| 11414 | catch(std::bad_alloc&) |
| 11415 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11416 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11417 | } |
| 11418 | } |
| 11419 | |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11420 | void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) |
| 11421 | { |
| 11422 | EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs); |
| 11423 | |
| 11424 | try |
| 11425 | { |
| 11426 | gl::Context *context = gl::getNonLostContext(); |
| 11427 | |
| 11428 | if (context) |
| 11429 | { |
| 11430 | if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets()) |
| 11431 | { |
| 11432 | return gl::error(GL_INVALID_VALUE); |
| 11433 | } |
| 11434 | |
| 11435 | if (context->getDrawFramebufferHandle() == 0) |
| 11436 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11437 | if (n != 1) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11438 | { |
| 11439 | return gl::error(GL_INVALID_OPERATION); |
| 11440 | } |
| 11441 | |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11442 | 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] | 11443 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11444 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11445 | } |
| 11446 | } |
| 11447 | else |
| 11448 | { |
| 11449 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 11450 | { |
| 11451 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 11452 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment) |
| 11453 | { |
| 11454 | return gl::error(GL_INVALID_OPERATION); |
| 11455 | } |
| 11456 | } |
| 11457 | } |
| 11458 | |
| 11459 | gl::Framebuffer *framebuffer = context->getDrawFramebuffer(); |
| 11460 | |
| 11461 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 11462 | { |
| 11463 | framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]); |
| 11464 | } |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11465 | |
| 11466 | for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++) |
| 11467 | { |
| 11468 | framebuffer->setDrawBufferState(colorAttachment, GL_NONE); |
| 11469 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11470 | } |
| 11471 | } |
| 11472 | catch (std::bad_alloc&) |
| 11473 | { |
| 11474 | return gl::error(GL_OUT_OF_MEMORY); |
| 11475 | } |
| 11476 | } |
| 11477 | |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11478 | __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) |
| 11479 | { |
| 11480 | struct Extension |
| 11481 | { |
| 11482 | const char *name; |
| 11483 | __eglMustCastToProperFunctionPointerType address; |
| 11484 | }; |
| 11485 | |
| 11486 | static const Extension glExtensions[] = |
| 11487 | { |
| 11488 | {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 11489 | {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, |
daniel@transgaming.com | 1fe96c9 | 2011-01-14 15:08:44 +0000 | [diff] [blame] | 11490 | {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 11491 | {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, |
| 11492 | {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, |
| 11493 | {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, |
| 11494 | {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, |
| 11495 | {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, |
| 11496 | {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, |
| 11497 | {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 11498 | {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE}, |
daniel@transgaming.com | 0bd1f2f | 2011-11-11 04:19:03 +0000 | [diff] [blame] | 11499 | {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT}, |
daniel@transgaming.com | 709ed11 | 2011-11-12 03:18:10 +0000 | [diff] [blame] | 11500 | {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT}, |
| 11501 | {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT}, |
| 11502 | {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT}, |
| 11503 | {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT}, |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 11504 | {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT}, |
| 11505 | {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT}, |
| 11506 | {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT}, |
| 11507 | {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT}, |
| 11508 | {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT}, |
| 11509 | {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT}, |
| 11510 | {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT}, |
shannon.woods%transgaming.com@gtempaccount.com | 77d9472 | 2013-04-13 03:34:22 +0000 | [diff] [blame] | 11511 | {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT}, |
daniel@transgaming.com | dce02fd | 2012-01-27 15:39:51 +0000 | [diff] [blame] | 11512 | {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE}, |
| 11513 | {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, |
| 11514 | {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11515 | {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, |
| 11516 | {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, }; |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11517 | |
shannon.woods@transgaming.com | d438fd4 | 2013-02-28 23:17:45 +0000 | [diff] [blame] | 11518 | for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11519 | { |
| 11520 | if (strcmp(procname, glExtensions[ext].name) == 0) |
| 11521 | { |
| 11522 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address; |
| 11523 | } |
| 11524 | } |
| 11525 | |
| 11526 | return NULL; |
| 11527 | } |
| 11528 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 11529 | // Non-public functions used by EGL |
| 11530 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11531 | bool __stdcall glBindTexImage(egl::Surface *surface) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11532 | { |
| 11533 | EVENT("(egl::Surface* surface = 0x%0.8p)", |
| 11534 | surface); |
| 11535 | |
| 11536 | try |
| 11537 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11538 | gl::Context *context = gl::getNonLostContext(); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11539 | |
| 11540 | if (context) |
| 11541 | { |
| 11542 | gl::Texture2D *textureObject = context->getTexture2D(); |
| 11543 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11544 | if (textureObject->isImmutable()) |
| 11545 | { |
| 11546 | return false; |
| 11547 | } |
| 11548 | |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11549 | if (textureObject) |
| 11550 | { |
| 11551 | textureObject->bindTexImage(surface); |
| 11552 | } |
| 11553 | } |
| 11554 | } |
| 11555 | catch(std::bad_alloc&) |
| 11556 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11557 | return gl::error(GL_OUT_OF_MEMORY, false); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11558 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11559 | |
| 11560 | return true; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11561 | } |
| 11562 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11563 | } |