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(); |
| 1095 | GLenum colorbufferFormat = source->getInternalFormat(); |
| 1096 | gl::Texture *texture = NULL; |
| 1097 | GLenum textureFormat = GL_RGBA; |
| 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 | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 1109 | textureFormat = gl::GetFormat(texture2d->getInternalFormat(level), context->getClientVersion()); |
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 | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 1129 | textureFormat = gl::GetFormat(textureCube->getInternalFormat(target, level), context->getClientVersion()); |
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 | { |
| 1144 | textureFormat = gl::GetFormat(texture2dArray->getInternalFormat(level), context->getClientVersion()); |
| 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 | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 1159 | textureFormat = gl::GetFormat(texture3d->getInternalFormat(level), context->getClientVersion()); |
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 | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 1199 | if (!gl::IsValidCopyTexImageCombination(textureFormat, colorbufferFormat, context->getClientVersion())) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1200 | { |
| 1201 | return gl::error(GL_INVALID_OPERATION, false); |
| 1202 | } |
| 1203 | |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 1204 | return true; |
| 1205 | } |
| 1206 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 1207 | bool validateES2TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat, |
| 1208 | GLsizei width, GLsizei height) |
| 1209 | { |
| 1210 | if (target != GL_TEXTURE_2D && target != GL_TEXTURE_CUBE_MAP) |
| 1211 | { |
| 1212 | return gl::error(GL_INVALID_ENUM, false); |
| 1213 | } |
| 1214 | |
| 1215 | if (width < 1 || height < 1 || levels < 1) |
| 1216 | { |
| 1217 | return gl::error(GL_INVALID_VALUE, false); |
| 1218 | } |
| 1219 | |
| 1220 | if (target == GL_TEXTURE_CUBE_MAP && width != height) |
| 1221 | { |
| 1222 | return gl::error(GL_INVALID_VALUE, false); |
| 1223 | } |
| 1224 | |
| 1225 | if (levels != 1 && levels != gl::log2(std::max(width, height)) + 1) |
| 1226 | { |
| 1227 | return gl::error(GL_INVALID_OPERATION, false); |
| 1228 | } |
| 1229 | |
| 1230 | GLenum format = gl::GetFormat(internalformat, context->getClientVersion()); |
| 1231 | GLenum type = gl::GetType(internalformat, context->getClientVersion()); |
| 1232 | |
| 1233 | if (format == GL_NONE || type == GL_NONE) |
| 1234 | { |
| 1235 | return gl::error(GL_INVALID_ENUM, false); |
| 1236 | } |
| 1237 | |
| 1238 | switch (target) |
| 1239 | { |
| 1240 | case GL_TEXTURE_2D: |
| 1241 | if (width > context->getMaximum2DTextureDimension() || |
| 1242 | height > context->getMaximum2DTextureDimension()) |
| 1243 | { |
| 1244 | return gl::error(GL_INVALID_VALUE, false); |
| 1245 | } |
| 1246 | break; |
| 1247 | case GL_TEXTURE_CUBE_MAP: |
| 1248 | if (width > context->getMaximumCubeTextureDimension() || |
| 1249 | height > context->getMaximumCubeTextureDimension()) |
| 1250 | { |
| 1251 | return gl::error(GL_INVALID_VALUE, false); |
| 1252 | } |
| 1253 | break; |
| 1254 | default: |
| 1255 | return gl::error(GL_INVALID_ENUM, false); |
| 1256 | } |
| 1257 | |
| 1258 | if (levels != 1 && !context->supportsNonPower2Texture()) |
| 1259 | { |
| 1260 | if (!gl::isPow2(width) || !gl::isPow2(height)) |
| 1261 | { |
| 1262 | return gl::error(GL_INVALID_OPERATION, false); |
| 1263 | } |
| 1264 | } |
| 1265 | |
| 1266 | switch (internalformat) |
| 1267 | { |
| 1268 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 1269 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 1270 | if (!context->supportsDXT1Textures()) |
| 1271 | { |
| 1272 | return gl::error(GL_INVALID_ENUM, false); |
| 1273 | } |
| 1274 | break; |
| 1275 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 1276 | if (!context->supportsDXT3Textures()) |
| 1277 | { |
| 1278 | return gl::error(GL_INVALID_ENUM, false); |
| 1279 | } |
| 1280 | break; |
| 1281 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 1282 | if (!context->supportsDXT5Textures()) |
| 1283 | { |
| 1284 | return gl::error(GL_INVALID_ENUM, false); |
| 1285 | } |
| 1286 | break; |
| 1287 | case GL_RGBA32F_EXT: |
| 1288 | case GL_RGB32F_EXT: |
| 1289 | case GL_ALPHA32F_EXT: |
| 1290 | case GL_LUMINANCE32F_EXT: |
| 1291 | case GL_LUMINANCE_ALPHA32F_EXT: |
| 1292 | if (!context->supportsFloat32Textures()) |
| 1293 | { |
| 1294 | return gl::error(GL_INVALID_ENUM, false); |
| 1295 | } |
| 1296 | break; |
| 1297 | case GL_RGBA16F_EXT: |
| 1298 | case GL_RGB16F_EXT: |
| 1299 | case GL_ALPHA16F_EXT: |
| 1300 | case GL_LUMINANCE16F_EXT: |
| 1301 | case GL_LUMINANCE_ALPHA16F_EXT: |
| 1302 | if (!context->supportsFloat16Textures()) |
| 1303 | { |
| 1304 | return gl::error(GL_INVALID_ENUM, false); |
| 1305 | } |
| 1306 | break; |
| 1307 | case GL_DEPTH_COMPONENT16: |
| 1308 | case GL_DEPTH_COMPONENT32_OES: |
| 1309 | case GL_DEPTH24_STENCIL8_OES: |
| 1310 | if (!context->supportsDepthTextures()) |
| 1311 | { |
| 1312 | return gl::error(GL_INVALID_ENUM, false); |
| 1313 | } |
| 1314 | if (target != GL_TEXTURE_2D) |
| 1315 | { |
| 1316 | return gl::error(GL_INVALID_OPERATION, false); |
| 1317 | } |
| 1318 | // ANGLE_depth_texture only supports 1-level textures |
| 1319 | if (levels != 1) |
| 1320 | { |
| 1321 | return gl::error(GL_INVALID_OPERATION, false); |
| 1322 | } |
| 1323 | break; |
| 1324 | default: |
| 1325 | break; |
| 1326 | } |
| 1327 | |
| 1328 | gl::Texture *texture = NULL; |
| 1329 | switch(target) |
| 1330 | { |
| 1331 | case GL_TEXTURE_2D: |
| 1332 | texture = context->getTexture2D(); |
| 1333 | break; |
| 1334 | case GL_TEXTURE_CUBE_MAP: |
| 1335 | texture = context->getTextureCubeMap(); |
| 1336 | break; |
| 1337 | default: |
| 1338 | UNREACHABLE(); |
| 1339 | } |
| 1340 | |
| 1341 | if (!texture || texture->id() == 0) |
| 1342 | { |
| 1343 | return gl::error(GL_INVALID_OPERATION, false); |
| 1344 | } |
| 1345 | |
| 1346 | if (texture->isImmutable()) |
| 1347 | { |
| 1348 | return gl::error(GL_INVALID_OPERATION, false); |
| 1349 | } |
| 1350 | |
| 1351 | return true; |
| 1352 | } |
| 1353 | |
| 1354 | bool validateES3TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat, |
| 1355 | GLsizei width, GLsizei height, GLsizei depth) |
| 1356 | { |
| 1357 | if (width < 1 || height < 1 || depth < 1 || levels < 1) |
| 1358 | { |
| 1359 | return gl::error(GL_INVALID_VALUE, false); |
| 1360 | } |
| 1361 | |
| 1362 | if (levels > gl::log2(std::max(std::max(width, height), depth)) + 1) |
| 1363 | { |
| 1364 | return gl::error(GL_INVALID_OPERATION, false); |
| 1365 | } |
| 1366 | |
| 1367 | gl::Texture *texture = NULL; |
| 1368 | switch (target) |
| 1369 | { |
| 1370 | case GL_TEXTURE_2D: |
| 1371 | { |
| 1372 | texture = context->getTexture2D(); |
| 1373 | |
| 1374 | if (width > (context->getMaximum2DTextureDimension()) || |
| 1375 | height > (context->getMaximum2DTextureDimension())) |
| 1376 | { |
| 1377 | return gl::error(GL_INVALID_VALUE, false); |
| 1378 | } |
| 1379 | } |
| 1380 | break; |
| 1381 | |
| 1382 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 1383 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 1384 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 1385 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 1386 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 1387 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 1388 | { |
| 1389 | texture = context->getTextureCubeMap(); |
| 1390 | |
| 1391 | if (width != height) |
| 1392 | { |
| 1393 | return gl::error(GL_INVALID_VALUE, false); |
| 1394 | } |
| 1395 | |
| 1396 | if (width > (context->getMaximumCubeTextureDimension())) |
| 1397 | { |
| 1398 | return gl::error(GL_INVALID_VALUE, false); |
| 1399 | } |
| 1400 | } |
| 1401 | break; |
| 1402 | |
| 1403 | case GL_TEXTURE_3D: |
| 1404 | { |
| 1405 | texture = context->getTexture3D(); |
| 1406 | |
| 1407 | if (width > (context->getMaximum3DTextureDimension()) || |
| 1408 | height > (context->getMaximum3DTextureDimension()) || |
| 1409 | depth > (context->getMaximum3DTextureDimension())) |
| 1410 | { |
| 1411 | return gl::error(GL_INVALID_VALUE, false); |
| 1412 | } |
| 1413 | } |
| 1414 | break; |
| 1415 | |
| 1416 | case GL_TEXTURE_2D_ARRAY: |
| 1417 | { |
| 1418 | texture = context->getTexture2DArray(); |
| 1419 | |
| 1420 | if (width > (context->getMaximum2DTextureDimension()) || |
| 1421 | height > (context->getMaximum2DTextureDimension()) || |
| 1422 | depth > (context->getMaximum2DArrayTextureLayers())) |
| 1423 | { |
| 1424 | return gl::error(GL_INVALID_VALUE, false); |
| 1425 | } |
| 1426 | } |
| 1427 | break; |
| 1428 | |
| 1429 | default: |
| 1430 | return gl::error(GL_INVALID_ENUM, false); |
| 1431 | } |
| 1432 | |
| 1433 | if (!texture || texture->id() == 0) |
| 1434 | { |
| 1435 | return gl::error(GL_INVALID_OPERATION, false); |
| 1436 | } |
| 1437 | |
| 1438 | if (texture->isImmutable()) |
| 1439 | { |
| 1440 | return gl::error(GL_INVALID_OPERATION, false); |
| 1441 | } |
| 1442 | |
| 1443 | if (!gl::IsValidInternalFormat(internalformat, context)) |
| 1444 | { |
| 1445 | return gl::error(GL_INVALID_ENUM, false); |
| 1446 | } |
| 1447 | |
| 1448 | if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion())) |
| 1449 | { |
| 1450 | return gl::error(GL_INVALID_ENUM, false); |
| 1451 | } |
| 1452 | |
| 1453 | return true; |
| 1454 | } |
| 1455 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1456 | // 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] | 1457 | bool validES2ReadFormatType(GLenum format, GLenum type) |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1458 | { |
| 1459 | switch (format) |
| 1460 | { |
| 1461 | case GL_RGBA: |
| 1462 | switch (type) |
| 1463 | { |
| 1464 | case GL_UNSIGNED_BYTE: |
| 1465 | break; |
| 1466 | default: |
| 1467 | return false; |
| 1468 | } |
| 1469 | break; |
| 1470 | case GL_BGRA_EXT: |
| 1471 | switch (type) |
| 1472 | { |
| 1473 | case GL_UNSIGNED_BYTE: |
| 1474 | case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: |
| 1475 | case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: |
| 1476 | break; |
| 1477 | default: |
| 1478 | return false; |
| 1479 | } |
| 1480 | break; |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1481 | default: |
| 1482 | return false; |
| 1483 | } |
| 1484 | return true; |
| 1485 | } |
| 1486 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 1487 | bool validES3ReadFormatType(GLenum internalFormat, GLenum format, GLenum type) |
| 1488 | { |
| 1489 | switch (format) |
| 1490 | { |
| 1491 | case GL_RGBA: |
| 1492 | switch (type) |
| 1493 | { |
| 1494 | case GL_UNSIGNED_BYTE: |
| 1495 | break; |
| 1496 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 1497 | if (internalFormat != GL_RGB10_A2) |
| 1498 | { |
| 1499 | return false; |
| 1500 | } |
| 1501 | break; |
| 1502 | default: |
| 1503 | return false; |
| 1504 | } |
| 1505 | break; |
| 1506 | case GL_RGBA_INTEGER: |
| 1507 | switch (type) |
| 1508 | { |
| 1509 | case GL_INT: |
| 1510 | case GL_UNSIGNED_INT: |
| 1511 | break; |
| 1512 | default: |
| 1513 | return false; |
| 1514 | } |
| 1515 | break; |
| 1516 | case GL_BGRA_EXT: |
| 1517 | switch (type) |
| 1518 | { |
| 1519 | case GL_UNSIGNED_BYTE: |
| 1520 | case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: |
| 1521 | case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: |
| 1522 | break; |
| 1523 | default: |
| 1524 | return false; |
| 1525 | } |
| 1526 | break; |
| 1527 | default: |
| 1528 | return false; |
| 1529 | } |
| 1530 | return true; |
| 1531 | } |
| 1532 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 1533 | bool validateInvalidateFramebufferParameters(gl::Context *context, GLenum target, GLsizei numAttachments, |
| 1534 | const GLenum* attachments) |
| 1535 | { |
| 1536 | bool defaultFramebuffer = false; |
| 1537 | |
| 1538 | switch (target) |
| 1539 | { |
| 1540 | case GL_DRAW_FRAMEBUFFER: |
| 1541 | case GL_FRAMEBUFFER: |
| 1542 | defaultFramebuffer = context->getDrawFramebufferHandle() == 0; |
| 1543 | break; |
| 1544 | case GL_READ_FRAMEBUFFER: |
| 1545 | defaultFramebuffer = context->getReadFramebufferHandle() == 0; |
| 1546 | break; |
| 1547 | default: |
| 1548 | return gl::error(GL_INVALID_ENUM, false); |
| 1549 | } |
| 1550 | |
| 1551 | for (int i = 0; i < numAttachments; ++i) |
| 1552 | { |
| 1553 | if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15) |
| 1554 | { |
| 1555 | if (defaultFramebuffer) |
| 1556 | { |
| 1557 | return gl::error(GL_INVALID_ENUM, false); |
| 1558 | } |
| 1559 | |
| 1560 | if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getMaximumRenderTargets()) |
| 1561 | { |
| 1562 | return gl::error(GL_INVALID_OPERATION, false); |
| 1563 | } |
| 1564 | } |
| 1565 | else |
| 1566 | { |
| 1567 | switch (attachments[i]) |
| 1568 | { |
| 1569 | case GL_DEPTH_ATTACHMENT: |
| 1570 | case GL_STENCIL_ATTACHMENT: |
| 1571 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 1572 | if (defaultFramebuffer) |
| 1573 | { |
| 1574 | return gl::error(GL_INVALID_ENUM, false); |
| 1575 | } |
| 1576 | break; |
| 1577 | case GL_COLOR: |
| 1578 | case GL_DEPTH: |
| 1579 | case GL_STENCIL: |
| 1580 | if (!defaultFramebuffer) |
| 1581 | { |
| 1582 | return gl::error(GL_INVALID_ENUM, false); |
| 1583 | } |
| 1584 | break; |
| 1585 | default: |
| 1586 | return gl::error(GL_INVALID_ENUM, false); |
| 1587 | } |
| 1588 | } |
| 1589 | } |
| 1590 | |
| 1591 | return true; |
| 1592 | } |
| 1593 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1594 | extern "C" |
| 1595 | { |
| 1596 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 1597 | // OpenGL ES 2.0 functions |
| 1598 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1599 | void __stdcall glActiveTexture(GLenum texture) |
| 1600 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1601 | EVENT("(GLenum texture = 0x%X)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1602 | |
| 1603 | try |
| 1604 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1605 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1606 | |
| 1607 | if (context) |
| 1608 | { |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 1609 | if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1) |
| 1610 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1611 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 1612 | } |
| 1613 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 1614 | context->setActiveSampler(texture - GL_TEXTURE0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1615 | } |
| 1616 | } |
| 1617 | catch(std::bad_alloc&) |
| 1618 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1619 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1620 | } |
| 1621 | } |
| 1622 | |
| 1623 | void __stdcall glAttachShader(GLuint program, GLuint shader) |
| 1624 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1625 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1626 | |
| 1627 | try |
| 1628 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1629 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1630 | |
| 1631 | if (context) |
| 1632 | { |
| 1633 | gl::Program *programObject = context->getProgram(program); |
| 1634 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 1635 | |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1636 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1637 | { |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1638 | if (context->getShader(program)) |
| 1639 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1640 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1641 | } |
| 1642 | else |
| 1643 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1644 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1645 | } |
| 1646 | } |
| 1647 | |
| 1648 | if (!shaderObject) |
| 1649 | { |
| 1650 | if (context->getProgram(shader)) |
| 1651 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1652 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1653 | } |
| 1654 | else |
| 1655 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1656 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1657 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1658 | } |
| 1659 | |
| 1660 | if (!programObject->attachShader(shaderObject)) |
| 1661 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1662 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1663 | } |
| 1664 | } |
| 1665 | } |
| 1666 | catch(std::bad_alloc&) |
| 1667 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1668 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1669 | } |
| 1670 | } |
| 1671 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1672 | void __stdcall glBeginQueryEXT(GLenum target, GLuint id) |
| 1673 | { |
| 1674 | EVENT("(GLenum target = 0x%X, GLuint %d)", target, id); |
| 1675 | |
| 1676 | try |
| 1677 | { |
| 1678 | switch (target) |
| 1679 | { |
| 1680 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 1681 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 1682 | break; |
| 1683 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1684 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1685 | } |
| 1686 | |
| 1687 | if (id == 0) |
| 1688 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1689 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1690 | } |
| 1691 | |
| 1692 | gl::Context *context = gl::getNonLostContext(); |
| 1693 | |
| 1694 | if (context) |
| 1695 | { |
| 1696 | context->beginQuery(target, id); |
| 1697 | } |
| 1698 | } |
| 1699 | catch(std::bad_alloc&) |
| 1700 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1701 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1702 | } |
| 1703 | } |
| 1704 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 1705 | void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1706 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1707 | 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] | 1708 | |
| 1709 | try |
| 1710 | { |
| 1711 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 1712 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1713 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1714 | } |
| 1715 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1716 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1717 | |
| 1718 | if (context) |
| 1719 | { |
| 1720 | gl::Program *programObject = context->getProgram(program); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 1721 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1722 | if (!programObject) |
| 1723 | { |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 1724 | if (context->getShader(program)) |
| 1725 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1726 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 1727 | } |
| 1728 | else |
| 1729 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1730 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 1731 | } |
| 1732 | } |
| 1733 | |
| 1734 | if (strncmp(name, "gl_", 3) == 0) |
| 1735 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1736 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1737 | } |
| 1738 | |
| 1739 | programObject->bindAttributeLocation(index, name); |
| 1740 | } |
| 1741 | } |
| 1742 | catch(std::bad_alloc&) |
| 1743 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1744 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1745 | } |
| 1746 | } |
| 1747 | |
| 1748 | void __stdcall glBindBuffer(GLenum target, GLuint buffer) |
| 1749 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1750 | EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1751 | |
| 1752 | try |
| 1753 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1754 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1755 | |
| 1756 | if (context) |
| 1757 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1758 | // Check ES3 specific targets |
| 1759 | switch (target) |
| 1760 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 1761 | case GL_COPY_READ_BUFFER: |
| 1762 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1763 | case GL_PIXEL_PACK_BUFFER: |
| 1764 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1765 | case GL_UNIFORM_BUFFER: |
| 1766 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 1767 | if (context->getClientVersion() < 3) |
| 1768 | { |
| 1769 | return gl::error(GL_INVALID_ENUM); |
| 1770 | } |
| 1771 | } |
| 1772 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1773 | switch (target) |
| 1774 | { |
| 1775 | case GL_ARRAY_BUFFER: |
| 1776 | context->bindArrayBuffer(buffer); |
| 1777 | return; |
| 1778 | case GL_ELEMENT_ARRAY_BUFFER: |
| 1779 | context->bindElementArrayBuffer(buffer); |
| 1780 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 1781 | case GL_COPY_READ_BUFFER: |
| 1782 | context->bindCopyReadBuffer(buffer); |
| 1783 | return; |
| 1784 | case GL_COPY_WRITE_BUFFER: |
| 1785 | context->bindCopyWriteBuffer(buffer); |
| 1786 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1787 | case GL_PIXEL_PACK_BUFFER: |
| 1788 | context->bindPixelPackBuffer(buffer); |
| 1789 | return; |
| 1790 | case GL_PIXEL_UNPACK_BUFFER: |
| 1791 | context->bindPixelUnpackBuffer(buffer); |
| 1792 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1793 | case GL_UNIFORM_BUFFER: |
| 1794 | context->bindGenericUniformBuffer(buffer); |
| 1795 | return; |
| 1796 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 7a1ebad | 2013-05-30 00:05:20 +0000 | [diff] [blame] | 1797 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 1798 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1799 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1800 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1801 | } |
| 1802 | } |
| 1803 | } |
| 1804 | catch(std::bad_alloc&) |
| 1805 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1806 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1807 | } |
| 1808 | } |
| 1809 | |
| 1810 | void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer) |
| 1811 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1812 | EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1813 | |
| 1814 | try |
| 1815 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 1816 | 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] | 1817 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1818 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1819 | } |
| 1820 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1821 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1822 | |
| 1823 | if (context) |
| 1824 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 1825 | if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 1826 | { |
| 1827 | context->bindReadFramebuffer(framebuffer); |
| 1828 | } |
| 1829 | |
| 1830 | if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 1831 | { |
| 1832 | context->bindDrawFramebuffer(framebuffer); |
| 1833 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1834 | } |
| 1835 | } |
| 1836 | catch(std::bad_alloc&) |
| 1837 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1838 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1839 | } |
| 1840 | } |
| 1841 | |
| 1842 | void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 1843 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1844 | EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1845 | |
| 1846 | try |
| 1847 | { |
| 1848 | if (target != GL_RENDERBUFFER) |
| 1849 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1850 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1851 | } |
| 1852 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1853 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1854 | |
| 1855 | if (context) |
| 1856 | { |
| 1857 | context->bindRenderbuffer(renderbuffer); |
| 1858 | } |
| 1859 | } |
| 1860 | catch(std::bad_alloc&) |
| 1861 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1862 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1863 | } |
| 1864 | } |
| 1865 | |
| 1866 | void __stdcall glBindTexture(GLenum target, GLuint texture) |
| 1867 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1868 | EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1869 | |
| 1870 | try |
| 1871 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1872 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1873 | |
| 1874 | if (context) |
| 1875 | { |
| 1876 | gl::Texture *textureObject = context->getTexture(texture); |
| 1877 | |
| 1878 | if (textureObject && textureObject->getTarget() != target && texture != 0) |
| 1879 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1880 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1881 | } |
| 1882 | |
| 1883 | switch (target) |
| 1884 | { |
| 1885 | case GL_TEXTURE_2D: |
| 1886 | context->bindTexture2D(texture); |
| 1887 | return; |
| 1888 | case GL_TEXTURE_CUBE_MAP: |
| 1889 | context->bindTextureCubeMap(texture); |
| 1890 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 1891 | case GL_TEXTURE_3D: |
| 1892 | if (context->getClientVersion() < 3) |
| 1893 | { |
| 1894 | return gl::error(GL_INVALID_ENUM); |
| 1895 | } |
| 1896 | context->bindTexture3D(texture); |
| 1897 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 1898 | case GL_TEXTURE_2D_ARRAY: |
| 1899 | if (context->getClientVersion() < 3) |
| 1900 | { |
| 1901 | return gl::error(GL_INVALID_ENUM); |
| 1902 | } |
| 1903 | context->bindTexture2DArray(texture); |
| 1904 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1905 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1906 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1907 | } |
| 1908 | } |
| 1909 | } |
| 1910 | catch(std::bad_alloc&) |
| 1911 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1912 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1913 | } |
| 1914 | } |
| 1915 | |
| 1916 | void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 1917 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1918 | 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] | 1919 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1920 | |
| 1921 | try |
| 1922 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1923 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1924 | |
| 1925 | if (context) |
| 1926 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 1927 | 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] | 1928 | } |
| 1929 | } |
| 1930 | catch(std::bad_alloc&) |
| 1931 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1932 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1933 | } |
| 1934 | } |
| 1935 | |
| 1936 | void __stdcall glBlendEquation(GLenum mode) |
| 1937 | { |
| 1938 | glBlendEquationSeparate(mode, mode); |
| 1939 | } |
| 1940 | |
| 1941 | void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 1942 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1943 | EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1944 | |
| 1945 | try |
| 1946 | { |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 1947 | gl::Context *context = gl::getNonLostContext(); |
| 1948 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1949 | switch (modeRGB) |
| 1950 | { |
| 1951 | case GL_FUNC_ADD: |
| 1952 | case GL_FUNC_SUBTRACT: |
| 1953 | case GL_FUNC_REVERSE_SUBTRACT: |
| 1954 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 1955 | |
| 1956 | case GL_MIN: |
| 1957 | case GL_MAX: |
| 1958 | if (context && context->getClientVersion() < 3) |
| 1959 | { |
| 1960 | return gl::error(GL_INVALID_ENUM); |
| 1961 | } |
| 1962 | break; |
| 1963 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1964 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1965 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1966 | } |
| 1967 | |
| 1968 | switch (modeAlpha) |
| 1969 | { |
| 1970 | case GL_FUNC_ADD: |
| 1971 | case GL_FUNC_SUBTRACT: |
| 1972 | case GL_FUNC_REVERSE_SUBTRACT: |
| 1973 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 1974 | |
| 1975 | case GL_MIN: |
| 1976 | case GL_MAX: |
| 1977 | if (context && context->getClientVersion() < 3) |
| 1978 | { |
| 1979 | return gl::error(GL_INVALID_ENUM); |
| 1980 | } |
| 1981 | break; |
| 1982 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1983 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1984 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1985 | } |
| 1986 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1987 | if (context) |
| 1988 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 1989 | context->setBlendEquation(modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1990 | } |
| 1991 | } |
| 1992 | catch(std::bad_alloc&) |
| 1993 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1994 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1995 | } |
| 1996 | } |
| 1997 | |
| 1998 | void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor) |
| 1999 | { |
| 2000 | glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor); |
| 2001 | } |
| 2002 | |
| 2003 | void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 2004 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2005 | 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] | 2006 | srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2007 | |
| 2008 | try |
| 2009 | { |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2010 | gl::Context *context = gl::getNonLostContext(); |
| 2011 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2012 | switch (srcRGB) |
| 2013 | { |
| 2014 | case GL_ZERO: |
| 2015 | case GL_ONE: |
| 2016 | case GL_SRC_COLOR: |
| 2017 | case GL_ONE_MINUS_SRC_COLOR: |
| 2018 | case GL_DST_COLOR: |
| 2019 | case GL_ONE_MINUS_DST_COLOR: |
| 2020 | case GL_SRC_ALPHA: |
| 2021 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2022 | case GL_DST_ALPHA: |
| 2023 | case GL_ONE_MINUS_DST_ALPHA: |
| 2024 | case GL_CONSTANT_COLOR: |
| 2025 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2026 | case GL_CONSTANT_ALPHA: |
| 2027 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2028 | case GL_SRC_ALPHA_SATURATE: |
| 2029 | break; |
| 2030 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2031 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2032 | } |
| 2033 | |
| 2034 | switch (dstRGB) |
| 2035 | { |
| 2036 | case GL_ZERO: |
| 2037 | case GL_ONE: |
| 2038 | case GL_SRC_COLOR: |
| 2039 | case GL_ONE_MINUS_SRC_COLOR: |
| 2040 | case GL_DST_COLOR: |
| 2041 | case GL_ONE_MINUS_DST_COLOR: |
| 2042 | case GL_SRC_ALPHA: |
| 2043 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2044 | case GL_DST_ALPHA: |
| 2045 | case GL_ONE_MINUS_DST_ALPHA: |
| 2046 | case GL_CONSTANT_COLOR: |
| 2047 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2048 | case GL_CONSTANT_ALPHA: |
| 2049 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2050 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2051 | |
| 2052 | case GL_SRC_ALPHA_SATURATE: |
| 2053 | if (!context || context->getClientVersion() < 3) |
| 2054 | { |
| 2055 | return gl::error(GL_INVALID_ENUM); |
| 2056 | } |
| 2057 | break; |
| 2058 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2059 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2060 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2061 | } |
| 2062 | |
| 2063 | switch (srcAlpha) |
| 2064 | { |
| 2065 | case GL_ZERO: |
| 2066 | case GL_ONE: |
| 2067 | case GL_SRC_COLOR: |
| 2068 | case GL_ONE_MINUS_SRC_COLOR: |
| 2069 | case GL_DST_COLOR: |
| 2070 | case GL_ONE_MINUS_DST_COLOR: |
| 2071 | case GL_SRC_ALPHA: |
| 2072 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2073 | case GL_DST_ALPHA: |
| 2074 | case GL_ONE_MINUS_DST_ALPHA: |
| 2075 | case GL_CONSTANT_COLOR: |
| 2076 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2077 | case GL_CONSTANT_ALPHA: |
| 2078 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2079 | case GL_SRC_ALPHA_SATURATE: |
| 2080 | break; |
| 2081 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2082 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2083 | } |
| 2084 | |
| 2085 | switch (dstAlpha) |
| 2086 | { |
| 2087 | case GL_ZERO: |
| 2088 | case GL_ONE: |
| 2089 | case GL_SRC_COLOR: |
| 2090 | case GL_ONE_MINUS_SRC_COLOR: |
| 2091 | case GL_DST_COLOR: |
| 2092 | case GL_ONE_MINUS_DST_COLOR: |
| 2093 | case GL_SRC_ALPHA: |
| 2094 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2095 | case GL_DST_ALPHA: |
| 2096 | case GL_ONE_MINUS_DST_ALPHA: |
| 2097 | case GL_CONSTANT_COLOR: |
| 2098 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2099 | case GL_CONSTANT_ALPHA: |
| 2100 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2101 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2102 | |
| 2103 | case GL_SRC_ALPHA_SATURATE: |
| 2104 | if (!context || context->getClientVersion() < 3) |
| 2105 | { |
| 2106 | return gl::error(GL_INVALID_ENUM); |
| 2107 | } |
| 2108 | break; |
| 2109 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2110 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2111 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2112 | } |
| 2113 | |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2114 | bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR || |
| 2115 | dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR); |
| 2116 | |
| 2117 | bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA || |
| 2118 | dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA); |
| 2119 | |
| 2120 | if (constantColorUsed && constantAlphaUsed) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2121 | { |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2122 | 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] | 2123 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2124 | } |
| 2125 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2126 | if (context) |
| 2127 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2128 | context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2129 | } |
| 2130 | } |
| 2131 | catch(std::bad_alloc&) |
| 2132 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2133 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2134 | } |
| 2135 | } |
| 2136 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2137 | 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] | 2138 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2139 | 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] | 2140 | target, size, data, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2141 | |
| 2142 | try |
| 2143 | { |
| 2144 | if (size < 0) |
| 2145 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2146 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2147 | } |
| 2148 | |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2149 | gl::Context *context = gl::getNonLostContext(); |
| 2150 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2151 | switch (usage) |
| 2152 | { |
| 2153 | case GL_STREAM_DRAW: |
| 2154 | case GL_STATIC_DRAW: |
| 2155 | case GL_DYNAMIC_DRAW: |
| 2156 | break; |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2157 | |
| 2158 | case GL_STREAM_READ: |
| 2159 | case GL_STREAM_COPY: |
| 2160 | case GL_STATIC_READ: |
| 2161 | case GL_STATIC_COPY: |
| 2162 | case GL_DYNAMIC_READ: |
| 2163 | case GL_DYNAMIC_COPY: |
| 2164 | if (context && context->getClientVersion() < 3) |
| 2165 | { |
| 2166 | return gl::error(GL_INVALID_ENUM); |
| 2167 | } |
| 2168 | break; |
| 2169 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2170 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2171 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2172 | } |
| 2173 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2174 | if (context) |
| 2175 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2176 | // Check ES3 specific targets |
| 2177 | switch (target) |
| 2178 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2179 | case GL_COPY_READ_BUFFER: |
| 2180 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2181 | case GL_PIXEL_PACK_BUFFER: |
| 2182 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2183 | case GL_UNIFORM_BUFFER: |
| 2184 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2185 | if (context->getClientVersion() < 3) |
| 2186 | { |
| 2187 | return gl::error(GL_INVALID_ENUM); |
| 2188 | } |
| 2189 | } |
| 2190 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2191 | gl::Buffer *buffer; |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2192 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2193 | switch (target) |
| 2194 | { |
| 2195 | case GL_ARRAY_BUFFER: |
| 2196 | buffer = context->getArrayBuffer(); |
| 2197 | break; |
| 2198 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2199 | buffer = context->getElementArrayBuffer(); |
| 2200 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2201 | case GL_COPY_READ_BUFFER: |
| 2202 | buffer = context->getCopyReadBuffer(); |
| 2203 | break; |
| 2204 | case GL_COPY_WRITE_BUFFER: |
| 2205 | buffer = context->getCopyWriteBuffer(); |
| 2206 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2207 | case GL_PIXEL_PACK_BUFFER: |
| 2208 | buffer = context->getPixelPackBuffer(); |
| 2209 | break; |
| 2210 | case GL_PIXEL_UNPACK_BUFFER: |
| 2211 | buffer = context->getPixelUnpackBuffer(); |
| 2212 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2213 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2214 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2215 | break; |
| 2216 | case GL_UNIFORM_BUFFER: |
| 2217 | buffer = context->getGenericUniformBuffer(); |
| 2218 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2219 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2220 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2221 | } |
| 2222 | |
| 2223 | if (!buffer) |
| 2224 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2225 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2226 | } |
| 2227 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2228 | buffer->bufferData(data, size, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2229 | } |
| 2230 | } |
| 2231 | catch(std::bad_alloc&) |
| 2232 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2233 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2234 | } |
| 2235 | } |
| 2236 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2237 | 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] | 2238 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2239 | 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] | 2240 | target, offset, size, data); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2241 | |
| 2242 | try |
| 2243 | { |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2244 | if (size < 0 || offset < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2245 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2246 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2247 | } |
| 2248 | |
daniel@transgaming.com | d4620a3 | 2010-03-21 04:31:28 +0000 | [diff] [blame] | 2249 | if (data == NULL) |
| 2250 | { |
| 2251 | return; |
| 2252 | } |
| 2253 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2254 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2255 | |
| 2256 | if (context) |
| 2257 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2258 | // Check ES3 specific targets |
| 2259 | switch (target) |
| 2260 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2261 | case GL_COPY_READ_BUFFER: |
| 2262 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2263 | case GL_PIXEL_PACK_BUFFER: |
| 2264 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2265 | case GL_UNIFORM_BUFFER: |
| 2266 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2267 | if (context->getClientVersion() < 3) |
| 2268 | { |
| 2269 | return gl::error(GL_INVALID_ENUM); |
| 2270 | } |
| 2271 | } |
| 2272 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2273 | gl::Buffer *buffer; |
| 2274 | |
| 2275 | switch (target) |
| 2276 | { |
| 2277 | case GL_ARRAY_BUFFER: |
| 2278 | buffer = context->getArrayBuffer(); |
| 2279 | break; |
| 2280 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2281 | buffer = context->getElementArrayBuffer(); |
| 2282 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2283 | case GL_COPY_READ_BUFFER: |
| 2284 | buffer = context->getCopyReadBuffer(); |
| 2285 | break; |
| 2286 | case GL_COPY_WRITE_BUFFER: |
| 2287 | buffer = context->getCopyWriteBuffer(); |
| 2288 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2289 | case GL_PIXEL_PACK_BUFFER: |
| 2290 | buffer = context->getPixelPackBuffer(); |
| 2291 | break; |
| 2292 | case GL_PIXEL_UNPACK_BUFFER: |
| 2293 | buffer = context->getPixelUnpackBuffer(); |
| 2294 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2295 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2296 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2297 | break; |
| 2298 | case GL_UNIFORM_BUFFER: |
| 2299 | buffer = context->getGenericUniformBuffer(); |
| 2300 | break; |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2301 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2302 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2303 | } |
| 2304 | |
| 2305 | if (!buffer) |
| 2306 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2307 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2308 | } |
| 2309 | |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2310 | if ((size_t)size + offset > buffer->size()) |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2311 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2312 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2313 | } |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2314 | |
| 2315 | buffer->bufferSubData(data, size, offset); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2316 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2317 | } |
| 2318 | catch(std::bad_alloc&) |
| 2319 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2320 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2321 | } |
| 2322 | } |
| 2323 | |
| 2324 | GLenum __stdcall glCheckFramebufferStatus(GLenum target) |
| 2325 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2326 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2327 | |
| 2328 | try |
| 2329 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2330 | 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] | 2331 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2332 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2333 | } |
| 2334 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2335 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2336 | |
| 2337 | if (context) |
| 2338 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2339 | gl::Framebuffer *framebuffer = NULL; |
| 2340 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 2341 | { |
| 2342 | framebuffer = context->getReadFramebuffer(); |
| 2343 | } |
| 2344 | else |
| 2345 | { |
| 2346 | framebuffer = context->getDrawFramebuffer(); |
| 2347 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2348 | |
| 2349 | return framebuffer->completeness(); |
| 2350 | } |
| 2351 | } |
| 2352 | catch(std::bad_alloc&) |
| 2353 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2354 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2355 | } |
| 2356 | |
| 2357 | return 0; |
| 2358 | } |
| 2359 | |
| 2360 | void __stdcall glClear(GLbitfield mask) |
| 2361 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2362 | EVENT("(GLbitfield mask = 0x%X)", mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2363 | |
| 2364 | try |
| 2365 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2366 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2367 | |
| 2368 | if (context) |
| 2369 | { |
| 2370 | context->clear(mask); |
| 2371 | } |
| 2372 | } |
| 2373 | catch(std::bad_alloc&) |
| 2374 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2375 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2376 | } |
| 2377 | } |
| 2378 | |
| 2379 | void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2380 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2381 | 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] | 2382 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2383 | |
| 2384 | try |
| 2385 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2386 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2387 | |
| 2388 | if (context) |
| 2389 | { |
| 2390 | context->setClearColor(red, green, blue, alpha); |
| 2391 | } |
| 2392 | } |
| 2393 | catch(std::bad_alloc&) |
| 2394 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2395 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2396 | } |
| 2397 | } |
| 2398 | |
| 2399 | void __stdcall glClearDepthf(GLclampf depth) |
| 2400 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2401 | EVENT("(GLclampf depth = %f)", depth); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2402 | |
| 2403 | try |
| 2404 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2405 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2406 | |
| 2407 | if (context) |
| 2408 | { |
| 2409 | context->setClearDepth(depth); |
| 2410 | } |
| 2411 | } |
| 2412 | catch(std::bad_alloc&) |
| 2413 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2414 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2415 | } |
| 2416 | } |
| 2417 | |
| 2418 | void __stdcall glClearStencil(GLint s) |
| 2419 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2420 | EVENT("(GLint s = %d)", s); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2421 | |
| 2422 | try |
| 2423 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2424 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2425 | |
| 2426 | if (context) |
| 2427 | { |
| 2428 | context->setClearStencil(s); |
| 2429 | } |
| 2430 | } |
| 2431 | catch(std::bad_alloc&) |
| 2432 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2433 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2434 | } |
| 2435 | } |
| 2436 | |
| 2437 | void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 2438 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2439 | 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] | 2440 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2441 | |
| 2442 | try |
| 2443 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2444 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2445 | |
| 2446 | if (context) |
| 2447 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 2448 | 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] | 2449 | } |
| 2450 | } |
| 2451 | catch(std::bad_alloc&) |
| 2452 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2453 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2454 | } |
| 2455 | } |
| 2456 | |
| 2457 | void __stdcall glCompileShader(GLuint shader) |
| 2458 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2459 | EVENT("(GLuint shader = %d)", shader); |
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 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2468 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2469 | if (!shaderObject) |
| 2470 | { |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2471 | if (context->getProgram(shader)) |
| 2472 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2473 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2474 | } |
| 2475 | else |
| 2476 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2477 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2478 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2479 | } |
| 2480 | |
| 2481 | shaderObject->compile(); |
| 2482 | } |
| 2483 | } |
| 2484 | catch(std::bad_alloc&) |
| 2485 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2486 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2487 | } |
| 2488 | } |
| 2489 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2490 | void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, |
| 2491 | GLint border, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2492 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2493 | 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] | 2494 | "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] | 2495 | target, level, internalformat, width, height, border, imageSize, data); |
| 2496 | |
| 2497 | try |
| 2498 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2499 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2500 | |
| 2501 | if (context) |
| 2502 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2503 | if (context->getClientVersion() < 3 && |
| 2504 | !validateES2TexImageParameters(context, target, level, internalformat, true, false, |
| 2505 | 0, 0, width, height, 0, GL_NONE, GL_NONE, data)) |
| 2506 | { |
| 2507 | return; |
| 2508 | } |
| 2509 | |
| 2510 | if (context->getClientVersion() >= 3 && |
| 2511 | !validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 2512 | 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 2513 | { |
| 2514 | return; |
| 2515 | } |
| 2516 | |
| 2517 | 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] | 2518 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2519 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2520 | } |
| 2521 | |
| 2522 | switch (target) |
| 2523 | { |
| 2524 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2525 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2526 | gl::Texture2D *texture = context->getTexture2D(); |
| 2527 | texture->setCompressedImage(level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2528 | } |
| 2529 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2530 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2531 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2532 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2533 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2534 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2535 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2536 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2537 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2538 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 2539 | texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2540 | } |
| 2541 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2542 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2543 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2544 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2545 | } |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2546 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2547 | } |
| 2548 | catch(std::bad_alloc&) |
| 2549 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2550 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2551 | } |
| 2552 | } |
| 2553 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2554 | void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 2555 | GLenum format, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2556 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2557 | EVENT("(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] | 2558 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2559 | "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2560 | target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 2561 | |
| 2562 | try |
| 2563 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2564 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2565 | |
| 2566 | if (context) |
| 2567 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2568 | if (context->getClientVersion() < 3 && |
| 2569 | !validateES2TexImageParameters(context, target, level, GL_NONE, true, true, |
| 2570 | xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data)) |
| 2571 | { |
| 2572 | return; |
| 2573 | } |
| 2574 | |
| 2575 | if (context->getClientVersion() >= 3 && |
| 2576 | !validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 2577 | xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 2578 | { |
| 2579 | return; |
| 2580 | } |
| 2581 | |
| 2582 | 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] | 2583 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2584 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2585 | } |
| 2586 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2587 | switch (target) |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2588 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2589 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2590 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2591 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 2592 | texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2593 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2594 | break; |
| 2595 | |
| 2596 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2597 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2598 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2599 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2600 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2601 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2602 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2603 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 2604 | texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2605 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2606 | break; |
| 2607 | |
| 2608 | default: |
| 2609 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2610 | } |
| 2611 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2612 | } |
| 2613 | catch(std::bad_alloc&) |
| 2614 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2615 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2616 | } |
| 2617 | } |
| 2618 | |
| 2619 | void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) |
| 2620 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2621 | 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] | 2622 | "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] | 2623 | target, level, internalformat, x, y, width, height, border); |
| 2624 | |
| 2625 | try |
| 2626 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2627 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2628 | |
| 2629 | if (context) |
| 2630 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2631 | if (context->getClientVersion() < 3 && |
| 2632 | !validateES2CopyTexImageParameters(context, target, level, internalformat, false, |
| 2633 | 0, 0, x, y, width, height, border)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 2634 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2635 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 2636 | } |
| 2637 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2638 | if (context->getClientVersion() >= 3 && |
| 2639 | !validateES3CopyTexImageParameters(context, target, level, internalformat, false, |
| 2640 | 0, 0, 0, x, y, width, height, border)) |
| 2641 | { |
| 2642 | return; |
| 2643 | } |
| 2644 | |
| 2645 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 2646 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2647 | switch (target) |
| 2648 | { |
| 2649 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2650 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2651 | gl::Texture2D *texture = context->getTexture2D(); |
| 2652 | texture->copyImage(level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2653 | } |
| 2654 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2655 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2656 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2657 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2658 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2659 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2660 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2661 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2662 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2663 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 2664 | texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2665 | } |
| 2666 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2667 | |
| 2668 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2669 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2670 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2671 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2672 | } |
| 2673 | catch(std::bad_alloc&) |
| 2674 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2675 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2676 | } |
| 2677 | } |
| 2678 | |
| 2679 | void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 2680 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2681 | 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] | 2682 | "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] | 2683 | target, level, xoffset, yoffset, x, y, width, height); |
| 2684 | |
| 2685 | try |
| 2686 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2687 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2688 | |
| 2689 | if (context) |
| 2690 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2691 | if (context->getClientVersion() < 3 && |
| 2692 | !validateES2CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 2693 | xoffset, yoffset, x, y, width, height, 0)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2694 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2695 | return; |
| 2696 | } |
| 2697 | |
| 2698 | if (context->getClientVersion() >= 3 && |
| 2699 | !validateES3CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 2700 | xoffset, yoffset, 0, x, y, width, height, 0)) |
| 2701 | { |
| 2702 | return; |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2703 | } |
| 2704 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2705 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 2706 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2707 | switch (target) |
daniel@transgaming.com | bbc5779 | 2010-07-28 19:21:05 +0000 | [diff] [blame] | 2708 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2709 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 2710 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2711 | gl::Texture2D *texture = context->getTexture2D(); |
| 2712 | 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] | 2713 | } |
| 2714 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2715 | |
| 2716 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2717 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2718 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2719 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2720 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2721 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 2722 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2723 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 2724 | 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] | 2725 | } |
| 2726 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2727 | |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 2728 | default: |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2729 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 2730 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2731 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2732 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2733 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2734 | catch(std::bad_alloc&) |
| 2735 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2736 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2737 | } |
| 2738 | } |
| 2739 | |
| 2740 | GLuint __stdcall glCreateProgram(void) |
| 2741 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2742 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2743 | |
| 2744 | try |
| 2745 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2746 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2747 | |
| 2748 | if (context) |
| 2749 | { |
| 2750 | return context->createProgram(); |
| 2751 | } |
| 2752 | } |
| 2753 | catch(std::bad_alloc&) |
| 2754 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2755 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2756 | } |
| 2757 | |
| 2758 | return 0; |
| 2759 | } |
| 2760 | |
| 2761 | GLuint __stdcall glCreateShader(GLenum type) |
| 2762 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2763 | EVENT("(GLenum type = 0x%X)", type); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2764 | |
| 2765 | try |
| 2766 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2767 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2768 | |
| 2769 | if (context) |
| 2770 | { |
| 2771 | switch (type) |
| 2772 | { |
| 2773 | case GL_FRAGMENT_SHADER: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2774 | case GL_VERTEX_SHADER: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2775 | return context->createShader(type); |
| 2776 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2777 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2778 | } |
| 2779 | } |
| 2780 | } |
| 2781 | catch(std::bad_alloc&) |
| 2782 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2783 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2784 | } |
| 2785 | |
| 2786 | return 0; |
| 2787 | } |
| 2788 | |
| 2789 | void __stdcall glCullFace(GLenum mode) |
| 2790 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2791 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2792 | |
| 2793 | try |
| 2794 | { |
| 2795 | switch (mode) |
| 2796 | { |
| 2797 | case GL_FRONT: |
| 2798 | case GL_BACK: |
| 2799 | case GL_FRONT_AND_BACK: |
| 2800 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2801 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2802 | |
| 2803 | if (context) |
| 2804 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2805 | context->setCullMode(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2806 | } |
| 2807 | } |
| 2808 | break; |
| 2809 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2810 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2811 | } |
| 2812 | } |
| 2813 | catch(std::bad_alloc&) |
| 2814 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2815 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2816 | } |
| 2817 | } |
| 2818 | |
| 2819 | void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers) |
| 2820 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2821 | 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] | 2822 | |
| 2823 | try |
| 2824 | { |
| 2825 | if (n < 0) |
| 2826 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2827 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2828 | } |
| 2829 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2830 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2831 | |
| 2832 | if (context) |
| 2833 | { |
| 2834 | for (int i = 0; i < n; i++) |
| 2835 | { |
| 2836 | context->deleteBuffer(buffers[i]); |
| 2837 | } |
| 2838 | } |
| 2839 | } |
| 2840 | catch(std::bad_alloc&) |
| 2841 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2842 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2843 | } |
| 2844 | } |
| 2845 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2846 | void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences) |
| 2847 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2848 | 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] | 2849 | |
| 2850 | try |
| 2851 | { |
| 2852 | if (n < 0) |
| 2853 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2854 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2855 | } |
| 2856 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2857 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2858 | |
| 2859 | if (context) |
| 2860 | { |
| 2861 | for (int i = 0; i < n; i++) |
| 2862 | { |
| 2863 | context->deleteFence(fences[i]); |
| 2864 | } |
| 2865 | } |
| 2866 | } |
| 2867 | catch(std::bad_alloc&) |
| 2868 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2869 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2870 | } |
| 2871 | } |
| 2872 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2873 | void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) |
| 2874 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2875 | 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] | 2876 | |
| 2877 | try |
| 2878 | { |
| 2879 | if (n < 0) |
| 2880 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2881 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2882 | } |
| 2883 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2884 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2885 | |
| 2886 | if (context) |
| 2887 | { |
| 2888 | for (int i = 0; i < n; i++) |
| 2889 | { |
| 2890 | if (framebuffers[i] != 0) |
| 2891 | { |
| 2892 | context->deleteFramebuffer(framebuffers[i]); |
| 2893 | } |
| 2894 | } |
| 2895 | } |
| 2896 | } |
| 2897 | catch(std::bad_alloc&) |
| 2898 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2899 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2900 | } |
| 2901 | } |
| 2902 | |
| 2903 | void __stdcall glDeleteProgram(GLuint program) |
| 2904 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2905 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2906 | |
| 2907 | try |
| 2908 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 2909 | if (program == 0) |
| 2910 | { |
| 2911 | return; |
| 2912 | } |
| 2913 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2914 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2915 | |
| 2916 | if (context) |
| 2917 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 2918 | if (!context->getProgram(program)) |
| 2919 | { |
| 2920 | if(context->getShader(program)) |
| 2921 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2922 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 2923 | } |
| 2924 | else |
| 2925 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2926 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 2927 | } |
| 2928 | } |
| 2929 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2930 | context->deleteProgram(program); |
| 2931 | } |
| 2932 | } |
| 2933 | catch(std::bad_alloc&) |
| 2934 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2935 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2936 | } |
| 2937 | } |
| 2938 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2939 | void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids) |
| 2940 | { |
| 2941 | EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids); |
| 2942 | |
| 2943 | try |
| 2944 | { |
| 2945 | if (n < 0) |
| 2946 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2947 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2948 | } |
| 2949 | |
| 2950 | gl::Context *context = gl::getNonLostContext(); |
| 2951 | |
| 2952 | if (context) |
| 2953 | { |
| 2954 | for (int i = 0; i < n; i++) |
| 2955 | { |
| 2956 | context->deleteQuery(ids[i]); |
| 2957 | } |
| 2958 | } |
| 2959 | } |
| 2960 | catch(std::bad_alloc&) |
| 2961 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2962 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2963 | } |
| 2964 | } |
| 2965 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2966 | void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) |
| 2967 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2968 | 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] | 2969 | |
| 2970 | try |
| 2971 | { |
| 2972 | if (n < 0) |
| 2973 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2974 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2975 | } |
| 2976 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2977 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2978 | |
| 2979 | if (context) |
| 2980 | { |
daniel@transgaming.com | e2b2212 | 2010-03-11 19:22:14 +0000 | [diff] [blame] | 2981 | for (int i = 0; i < n; i++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2982 | { |
| 2983 | context->deleteRenderbuffer(renderbuffers[i]); |
| 2984 | } |
| 2985 | } |
| 2986 | } |
| 2987 | catch(std::bad_alloc&) |
| 2988 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2989 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2990 | } |
| 2991 | } |
| 2992 | |
| 2993 | void __stdcall glDeleteShader(GLuint shader) |
| 2994 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2995 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2996 | |
| 2997 | try |
| 2998 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 2999 | if (shader == 0) |
| 3000 | { |
| 3001 | return; |
| 3002 | } |
| 3003 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3004 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3005 | |
| 3006 | if (context) |
| 3007 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3008 | if (!context->getShader(shader)) |
| 3009 | { |
| 3010 | if(context->getProgram(shader)) |
| 3011 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3012 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3013 | } |
| 3014 | else |
| 3015 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3016 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3017 | } |
| 3018 | } |
| 3019 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3020 | context->deleteShader(shader); |
| 3021 | } |
| 3022 | } |
| 3023 | catch(std::bad_alloc&) |
| 3024 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3025 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3026 | } |
| 3027 | } |
| 3028 | |
| 3029 | void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures) |
| 3030 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3031 | 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] | 3032 | |
| 3033 | try |
| 3034 | { |
| 3035 | if (n < 0) |
| 3036 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3037 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3038 | } |
| 3039 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3040 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3041 | |
| 3042 | if (context) |
| 3043 | { |
| 3044 | for (int i = 0; i < n; i++) |
| 3045 | { |
| 3046 | if (textures[i] != 0) |
| 3047 | { |
| 3048 | context->deleteTexture(textures[i]); |
| 3049 | } |
| 3050 | } |
| 3051 | } |
| 3052 | } |
| 3053 | catch(std::bad_alloc&) |
| 3054 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3055 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3056 | } |
| 3057 | } |
| 3058 | |
| 3059 | void __stdcall glDepthFunc(GLenum func) |
| 3060 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3061 | EVENT("(GLenum func = 0x%X)", func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3062 | |
| 3063 | try |
| 3064 | { |
| 3065 | switch (func) |
| 3066 | { |
| 3067 | case GL_NEVER: |
| 3068 | case GL_ALWAYS: |
| 3069 | case GL_LESS: |
| 3070 | case GL_LEQUAL: |
| 3071 | case GL_EQUAL: |
| 3072 | case GL_GREATER: |
| 3073 | case GL_GEQUAL: |
| 3074 | case GL_NOTEQUAL: |
| 3075 | break; |
| 3076 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3077 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3078 | } |
| 3079 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3080 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3081 | |
| 3082 | if (context) |
| 3083 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3084 | context->setDepthFunc(func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3085 | } |
| 3086 | } |
| 3087 | catch(std::bad_alloc&) |
| 3088 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3089 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3090 | } |
| 3091 | } |
| 3092 | |
| 3093 | void __stdcall glDepthMask(GLboolean flag) |
| 3094 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 3095 | EVENT("(GLboolean flag = %u)", flag); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3096 | |
| 3097 | try |
| 3098 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3099 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3100 | |
| 3101 | if (context) |
| 3102 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3103 | context->setDepthMask(flag != GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3104 | } |
| 3105 | } |
| 3106 | catch(std::bad_alloc&) |
| 3107 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3108 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3109 | } |
| 3110 | } |
| 3111 | |
| 3112 | void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar) |
| 3113 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3114 | EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3115 | |
| 3116 | try |
| 3117 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3118 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3119 | |
| 3120 | if (context) |
| 3121 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3122 | context->setDepthRange(zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3123 | } |
| 3124 | } |
| 3125 | catch(std::bad_alloc&) |
| 3126 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3127 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3128 | } |
| 3129 | } |
| 3130 | |
| 3131 | void __stdcall glDetachShader(GLuint program, GLuint shader) |
| 3132 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3133 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3134 | |
| 3135 | try |
| 3136 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3137 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3138 | |
| 3139 | if (context) |
| 3140 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3141 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3142 | gl::Program *programObject = context->getProgram(program); |
| 3143 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3144 | |
| 3145 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3146 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3147 | gl::Shader *shaderByProgramHandle; |
| 3148 | shaderByProgramHandle = context->getShader(program); |
| 3149 | if (!shaderByProgramHandle) |
| 3150 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3151 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3152 | } |
| 3153 | else |
| 3154 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3155 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3156 | } |
| 3157 | } |
| 3158 | |
| 3159 | if (!shaderObject) |
| 3160 | { |
| 3161 | gl::Program *programByShaderHandle = context->getProgram(shader); |
| 3162 | if (!programByShaderHandle) |
| 3163 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3164 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3165 | } |
| 3166 | else |
| 3167 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3168 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3169 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3170 | } |
| 3171 | |
| 3172 | if (!programObject->detachShader(shaderObject)) |
| 3173 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3174 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3175 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3176 | } |
| 3177 | } |
| 3178 | catch(std::bad_alloc&) |
| 3179 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3180 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3181 | } |
| 3182 | } |
| 3183 | |
| 3184 | void __stdcall glDisable(GLenum cap) |
| 3185 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3186 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3187 | |
| 3188 | try |
| 3189 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3190 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3191 | |
| 3192 | if (context) |
| 3193 | { |
| 3194 | switch (cap) |
| 3195 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3196 | case GL_CULL_FACE: context->setCullFace(false); break; |
| 3197 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break; |
| 3198 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break; |
| 3199 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break; |
| 3200 | case GL_SCISSOR_TEST: context->setScissorTest(false); break; |
| 3201 | case GL_STENCIL_TEST: context->setStencilTest(false); break; |
| 3202 | case GL_DEPTH_TEST: context->setDepthTest(false); break; |
| 3203 | case GL_BLEND: context->setBlend(false); break; |
| 3204 | case GL_DITHER: context->setDither(false); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3205 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3206 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3207 | } |
| 3208 | } |
| 3209 | } |
| 3210 | catch(std::bad_alloc&) |
| 3211 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3212 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3213 | } |
| 3214 | } |
| 3215 | |
| 3216 | void __stdcall glDisableVertexAttribArray(GLuint index) |
| 3217 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3218 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3219 | |
| 3220 | try |
| 3221 | { |
| 3222 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3223 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3224 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3225 | } |
| 3226 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3227 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3228 | |
| 3229 | if (context) |
| 3230 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3231 | context->setEnableVertexAttribArray(index, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3232 | } |
| 3233 | } |
| 3234 | catch(std::bad_alloc&) |
| 3235 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3236 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3237 | } |
| 3238 | } |
| 3239 | |
| 3240 | void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count) |
| 3241 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3242 | 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] | 3243 | |
| 3244 | try |
| 3245 | { |
| 3246 | if (count < 0 || first < 0) |
| 3247 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3248 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3249 | } |
| 3250 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3251 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3252 | |
| 3253 | if (context) |
| 3254 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3255 | context->drawArrays(mode, first, count, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3256 | } |
| 3257 | } |
| 3258 | catch(std::bad_alloc&) |
| 3259 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3260 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3261 | } |
| 3262 | } |
| 3263 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3264 | void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
| 3265 | { |
| 3266 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount); |
| 3267 | |
| 3268 | try |
| 3269 | { |
| 3270 | if (count < 0 || first < 0 || primcount < 0) |
| 3271 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3272 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3273 | } |
| 3274 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3275 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3276 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3277 | gl::Context *context = gl::getNonLostContext(); |
| 3278 | |
| 3279 | if (context) |
| 3280 | { |
| 3281 | context->drawArrays(mode, first, count, primcount); |
| 3282 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3283 | } |
| 3284 | } |
| 3285 | catch(std::bad_alloc&) |
| 3286 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3287 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3288 | } |
| 3289 | } |
| 3290 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3291 | 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] | 3292 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3293 | 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] | 3294 | mode, count, type, indices); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3295 | |
| 3296 | try |
| 3297 | { |
| 3298 | if (count < 0) |
| 3299 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3300 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3301 | } |
| 3302 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3303 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3304 | |
| 3305 | if (context) |
| 3306 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3307 | switch (type) |
| 3308 | { |
| 3309 | case GL_UNSIGNED_BYTE: |
| 3310 | case GL_UNSIGNED_SHORT: |
| 3311 | break; |
| 3312 | case GL_UNSIGNED_INT: |
| 3313 | if (!context->supports32bitIndices()) |
| 3314 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3315 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3316 | } |
| 3317 | break; |
| 3318 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3319 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3320 | } |
| 3321 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3322 | context->drawElements(mode, count, type, indices, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3323 | } |
| 3324 | } |
| 3325 | catch(std::bad_alloc&) |
| 3326 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3327 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3328 | } |
| 3329 | } |
| 3330 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3331 | void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount) |
| 3332 | { |
| 3333 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)", |
| 3334 | mode, count, type, indices, primcount); |
| 3335 | |
| 3336 | try |
| 3337 | { |
| 3338 | if (count < 0 || primcount < 0) |
| 3339 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3340 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3341 | } |
| 3342 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3343 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3344 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3345 | gl::Context *context = gl::getNonLostContext(); |
| 3346 | |
| 3347 | if (context) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3348 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3349 | switch (type) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3350 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3351 | case GL_UNSIGNED_BYTE: |
| 3352 | case GL_UNSIGNED_SHORT: |
| 3353 | break; |
| 3354 | case GL_UNSIGNED_INT: |
| 3355 | if (!context->supports32bitIndices()) |
| 3356 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3357 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3358 | } |
| 3359 | break; |
| 3360 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3361 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3362 | } |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3363 | |
| 3364 | context->drawElements(mode, count, type, indices, primcount); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3365 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3366 | } |
| 3367 | } |
| 3368 | catch(std::bad_alloc&) |
| 3369 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3370 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3371 | } |
| 3372 | } |
| 3373 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3374 | void __stdcall glEnable(GLenum cap) |
| 3375 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3376 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3377 | |
| 3378 | try |
| 3379 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3380 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3381 | |
| 3382 | if (context) |
| 3383 | { |
| 3384 | switch (cap) |
| 3385 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3386 | case GL_CULL_FACE: context->setCullFace(true); break; |
| 3387 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break; |
| 3388 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break; |
| 3389 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break; |
| 3390 | case GL_SCISSOR_TEST: context->setScissorTest(true); break; |
| 3391 | case GL_STENCIL_TEST: context->setStencilTest(true); break; |
| 3392 | case GL_DEPTH_TEST: context->setDepthTest(true); break; |
| 3393 | case GL_BLEND: context->setBlend(true); break; |
| 3394 | case GL_DITHER: context->setDither(true); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3395 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3396 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3397 | } |
| 3398 | } |
| 3399 | } |
| 3400 | catch(std::bad_alloc&) |
| 3401 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3402 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3403 | } |
| 3404 | } |
| 3405 | |
| 3406 | void __stdcall glEnableVertexAttribArray(GLuint index) |
| 3407 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3408 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3409 | |
| 3410 | try |
| 3411 | { |
| 3412 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3413 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3414 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3415 | } |
| 3416 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3417 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3418 | |
| 3419 | if (context) |
| 3420 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3421 | context->setEnableVertexAttribArray(index, true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3422 | } |
| 3423 | } |
| 3424 | catch(std::bad_alloc&) |
| 3425 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3426 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3427 | } |
| 3428 | } |
| 3429 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3430 | void __stdcall glEndQueryEXT(GLenum target) |
| 3431 | { |
| 3432 | EVENT("GLenum target = 0x%X)", target); |
| 3433 | |
| 3434 | try |
| 3435 | { |
| 3436 | switch (target) |
| 3437 | { |
| 3438 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 3439 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 3440 | break; |
| 3441 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3442 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3443 | } |
| 3444 | |
| 3445 | gl::Context *context = gl::getNonLostContext(); |
| 3446 | |
| 3447 | if (context) |
| 3448 | { |
| 3449 | context->endQuery(target); |
| 3450 | } |
| 3451 | } |
| 3452 | catch(std::bad_alloc&) |
| 3453 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3454 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3455 | } |
| 3456 | } |
| 3457 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3458 | void __stdcall glFinishFenceNV(GLuint fence) |
| 3459 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3460 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3461 | |
| 3462 | try |
| 3463 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3464 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3465 | |
| 3466 | if (context) |
| 3467 | { |
| 3468 | gl::Fence* fenceObject = context->getFence(fence); |
| 3469 | |
| 3470 | if (fenceObject == NULL) |
| 3471 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3472 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3473 | } |
| 3474 | |
| 3475 | fenceObject->finishFence(); |
| 3476 | } |
| 3477 | } |
| 3478 | catch(std::bad_alloc&) |
| 3479 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3480 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3481 | } |
| 3482 | } |
| 3483 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3484 | void __stdcall glFinish(void) |
| 3485 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3486 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3487 | |
| 3488 | try |
| 3489 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3490 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3491 | |
| 3492 | if (context) |
| 3493 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 3494 | context->sync(true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3495 | } |
| 3496 | } |
| 3497 | catch(std::bad_alloc&) |
| 3498 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3499 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3500 | } |
| 3501 | } |
| 3502 | |
| 3503 | void __stdcall glFlush(void) |
| 3504 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3505 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3506 | |
| 3507 | try |
| 3508 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3509 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3510 | |
| 3511 | if (context) |
| 3512 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 3513 | context->sync(false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3514 | } |
| 3515 | } |
| 3516 | catch(std::bad_alloc&) |
| 3517 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3518 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3519 | } |
| 3520 | } |
| 3521 | |
| 3522 | void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) |
| 3523 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3524 | 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] | 3525 | "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3526 | |
| 3527 | try |
| 3528 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3529 | 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] | 3530 | || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3531 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3532 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3533 | } |
| 3534 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3535 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3536 | |
| 3537 | if (context) |
| 3538 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3539 | gl::Framebuffer *framebuffer = NULL; |
| 3540 | GLuint framebufferHandle = 0; |
| 3541 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 3542 | { |
| 3543 | framebuffer = context->getReadFramebuffer(); |
| 3544 | framebufferHandle = context->getReadFramebufferHandle(); |
| 3545 | } |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 3546 | else |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3547 | { |
| 3548 | framebuffer = context->getDrawFramebuffer(); |
| 3549 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 3550 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3551 | |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 3552 | if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3553 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3554 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3555 | } |
| 3556 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3557 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3558 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3559 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 3560 | |
| 3561 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 3562 | { |
| 3563 | return gl::error(GL_INVALID_VALUE); |
| 3564 | } |
| 3565 | |
| 3566 | framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer); |
| 3567 | } |
| 3568 | else |
| 3569 | { |
| 3570 | switch (attachment) |
| 3571 | { |
| 3572 | case GL_DEPTH_ATTACHMENT: |
| 3573 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer); |
| 3574 | break; |
| 3575 | case GL_STENCIL_ATTACHMENT: |
| 3576 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer); |
| 3577 | break; |
| 3578 | default: |
| 3579 | return gl::error(GL_INVALID_ENUM); |
| 3580 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3581 | } |
| 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 glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) |
| 3591 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3592 | 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] | 3593 | "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3594 | |
| 3595 | try |
| 3596 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3597 | 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] | 3598 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3599 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3600 | } |
| 3601 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3602 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3603 | |
| 3604 | if (context) |
| 3605 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3606 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 3607 | { |
| 3608 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 3609 | |
| 3610 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 3611 | { |
| 3612 | return gl::error(GL_INVALID_VALUE); |
| 3613 | } |
| 3614 | } |
| 3615 | else |
| 3616 | { |
| 3617 | switch (attachment) |
| 3618 | { |
| 3619 | case GL_DEPTH_ATTACHMENT: |
| 3620 | case GL_STENCIL_ATTACHMENT: |
| 3621 | break; |
| 3622 | default: |
| 3623 | return gl::error(GL_INVALID_ENUM); |
| 3624 | } |
| 3625 | } |
| 3626 | |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3627 | if (texture == 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3628 | { |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3629 | textarget = GL_NONE; |
| 3630 | } |
| 3631 | else |
| 3632 | { |
| 3633 | gl::Texture *tex = context->getTexture(texture); |
| 3634 | |
| 3635 | if (tex == NULL) |
| 3636 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3637 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3638 | } |
| 3639 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3640 | switch (textarget) |
| 3641 | { |
| 3642 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3643 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3644 | if (tex->getTarget() != GL_TEXTURE_2D) |
| 3645 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3646 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3647 | } |
| 3648 | gl::Texture2D *tex2d = static_cast<gl::Texture2D *>(tex); |
daniel@transgaming.com | 92f4992 | 2012-05-09 15:49:19 +0000 | [diff] [blame] | 3649 | if (tex2d->isCompressed(0)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3650 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3651 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3652 | } |
| 3653 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3654 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3655 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3656 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3657 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3658 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3659 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3660 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3661 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3662 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3663 | if (tex->getTarget() != GL_TEXTURE_CUBE_MAP) |
| 3664 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3665 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3666 | } |
| 3667 | gl::TextureCubeMap *texcube = static_cast<gl::TextureCubeMap *>(tex); |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 3668 | if (texcube->isCompressed(textarget, level)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3669 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3670 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3671 | } |
| 3672 | break; |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3673 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3674 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3675 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3676 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3677 | } |
| 3678 | |
| 3679 | if (level != 0) |
| 3680 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3681 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3682 | } |
| 3683 | } |
| 3684 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3685 | gl::Framebuffer *framebuffer = NULL; |
| 3686 | GLuint framebufferHandle = 0; |
| 3687 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 3688 | { |
| 3689 | framebuffer = context->getReadFramebuffer(); |
| 3690 | framebufferHandle = context->getReadFramebufferHandle(); |
| 3691 | } |
| 3692 | else |
| 3693 | { |
| 3694 | framebuffer = context->getDrawFramebuffer(); |
| 3695 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 3696 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3697 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3698 | if (framebufferHandle == 0 || !framebuffer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3699 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3700 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3701 | } |
| 3702 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3703 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 3704 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3705 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 3706 | |
| 3707 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 3708 | { |
| 3709 | return gl::error(GL_INVALID_VALUE); |
| 3710 | } |
| 3711 | |
| 3712 | framebuffer->setColorbuffer(colorAttachment, textarget, texture); |
| 3713 | } |
| 3714 | else |
| 3715 | { |
| 3716 | switch (attachment) |
| 3717 | { |
| 3718 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break; |
| 3719 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break; |
| 3720 | } |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 3721 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3722 | } |
| 3723 | } |
| 3724 | catch(std::bad_alloc&) |
| 3725 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3726 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3727 | } |
| 3728 | } |
| 3729 | |
| 3730 | void __stdcall glFrontFace(GLenum mode) |
| 3731 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3732 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3733 | |
| 3734 | try |
| 3735 | { |
| 3736 | switch (mode) |
| 3737 | { |
| 3738 | case GL_CW: |
| 3739 | case GL_CCW: |
| 3740 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3741 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3742 | |
| 3743 | if (context) |
| 3744 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3745 | context->setFrontFace(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3746 | } |
| 3747 | } |
| 3748 | break; |
| 3749 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3750 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3751 | } |
| 3752 | } |
| 3753 | catch(std::bad_alloc&) |
| 3754 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3755 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3756 | } |
| 3757 | } |
| 3758 | |
| 3759 | void __stdcall glGenBuffers(GLsizei n, GLuint* buffers) |
| 3760 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3761 | EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3762 | |
| 3763 | try |
| 3764 | { |
| 3765 | if (n < 0) |
| 3766 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3767 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3768 | } |
| 3769 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3770 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3771 | |
| 3772 | if (context) |
| 3773 | { |
| 3774 | for (int i = 0; i < n; i++) |
| 3775 | { |
| 3776 | buffers[i] = context->createBuffer(); |
| 3777 | } |
| 3778 | } |
| 3779 | } |
| 3780 | catch(std::bad_alloc&) |
| 3781 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3782 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3783 | } |
| 3784 | } |
| 3785 | |
| 3786 | void __stdcall glGenerateMipmap(GLenum target) |
| 3787 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3788 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3789 | |
| 3790 | try |
| 3791 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3792 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3793 | |
| 3794 | if (context) |
| 3795 | { |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3796 | switch (target) |
| 3797 | { |
| 3798 | case GL_TEXTURE_2D: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3799 | { |
| 3800 | gl::Texture2D *tex2d = context->getTexture2D(); |
| 3801 | |
daniel@transgaming.com | 92f4992 | 2012-05-09 15:49:19 +0000 | [diff] [blame] | 3802 | if (tex2d->isCompressed(0)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3803 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3804 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3805 | } |
daniel@transgaming.com | 0c85468 | 2012-05-31 01:14:11 +0000 | [diff] [blame] | 3806 | if (tex2d->isDepth(0)) |
| 3807 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3808 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0c85468 | 2012-05-31 01:14:11 +0000 | [diff] [blame] | 3809 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3810 | |
| 3811 | tex2d->generateMipmaps(); |
| 3812 | break; |
| 3813 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3814 | |
| 3815 | case GL_TEXTURE_CUBE_MAP: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3816 | { |
| 3817 | gl::TextureCubeMap *texcube = context->getTextureCubeMap(); |
| 3818 | |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 3819 | if (texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3820 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3821 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3822 | } |
| 3823 | |
| 3824 | texcube->generateMipmaps(); |
| 3825 | break; |
| 3826 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3827 | |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 3828 | case GL_TEXTURE_3D: |
| 3829 | { |
| 3830 | if (context->getClientVersion() < 3) |
| 3831 | { |
| 3832 | return gl::error(GL_INVALID_ENUM); |
| 3833 | } |
| 3834 | |
| 3835 | gl::Texture3D *tex3D = context->getTexture3D(); |
| 3836 | if (tex3D->isCompressed(0)) |
| 3837 | { |
| 3838 | return gl::error(GL_INVALID_OPERATION); |
| 3839 | } |
| 3840 | |
| 3841 | tex3D->generateMipmaps(); |
| 3842 | break; |
| 3843 | } |
| 3844 | |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 3845 | case GL_TEXTURE_2D_ARRAY: |
| 3846 | { |
| 3847 | if (context->getClientVersion() < 3) |
| 3848 | { |
| 3849 | return gl::error(GL_INVALID_ENUM); |
| 3850 | } |
| 3851 | |
| 3852 | gl::Texture2DArray *tex2darr = context->getTexture2DArray(); |
| 3853 | if (tex2darr->isCompressed(0)) |
| 3854 | { |
| 3855 | return gl::error(GL_INVALID_OPERATION); |
| 3856 | } |
| 3857 | |
| 3858 | tex2darr->generateMipmaps(); |
| 3859 | break; |
| 3860 | } |
| 3861 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3862 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3863 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3864 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 3865 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3866 | } |
| 3867 | catch(std::bad_alloc&) |
| 3868 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3869 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3870 | } |
| 3871 | } |
| 3872 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3873 | void __stdcall glGenFencesNV(GLsizei n, GLuint* fences) |
| 3874 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3875 | EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3876 | |
| 3877 | try |
| 3878 | { |
| 3879 | if (n < 0) |
| 3880 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3881 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3882 | } |
| 3883 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3884 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3885 | |
| 3886 | if (context) |
| 3887 | { |
| 3888 | for (int i = 0; i < n; i++) |
| 3889 | { |
| 3890 | fences[i] = context->createFence(); |
| 3891 | } |
| 3892 | } |
| 3893 | } |
| 3894 | catch(std::bad_alloc&) |
| 3895 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3896 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3897 | } |
| 3898 | } |
| 3899 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3900 | void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers) |
| 3901 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3902 | EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3903 | |
| 3904 | try |
| 3905 | { |
| 3906 | if (n < 0) |
| 3907 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3908 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3909 | } |
| 3910 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3911 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3912 | |
| 3913 | if (context) |
| 3914 | { |
| 3915 | for (int i = 0; i < n; i++) |
| 3916 | { |
| 3917 | framebuffers[i] = context->createFramebuffer(); |
| 3918 | } |
| 3919 | } |
| 3920 | } |
| 3921 | catch(std::bad_alloc&) |
| 3922 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3923 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3924 | } |
| 3925 | } |
| 3926 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3927 | void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids) |
| 3928 | { |
| 3929 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 3930 | |
| 3931 | try |
| 3932 | { |
| 3933 | if (n < 0) |
| 3934 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3935 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3936 | } |
| 3937 | |
| 3938 | gl::Context *context = gl::getNonLostContext(); |
| 3939 | |
| 3940 | if (context) |
| 3941 | { |
| 3942 | for (int i = 0; i < n; i++) |
| 3943 | { |
| 3944 | ids[i] = context->createQuery(); |
| 3945 | } |
| 3946 | } |
| 3947 | } |
| 3948 | catch(std::bad_alloc&) |
| 3949 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3950 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3951 | } |
| 3952 | } |
| 3953 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3954 | void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) |
| 3955 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3956 | EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3957 | |
| 3958 | try |
| 3959 | { |
| 3960 | if (n < 0) |
| 3961 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3962 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3963 | } |
| 3964 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3965 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3966 | |
| 3967 | if (context) |
| 3968 | { |
| 3969 | for (int i = 0; i < n; i++) |
| 3970 | { |
| 3971 | renderbuffers[i] = context->createRenderbuffer(); |
| 3972 | } |
| 3973 | } |
| 3974 | } |
| 3975 | catch(std::bad_alloc&) |
| 3976 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3977 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3978 | } |
| 3979 | } |
| 3980 | |
| 3981 | void __stdcall glGenTextures(GLsizei n, GLuint* textures) |
| 3982 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3983 | EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3984 | |
| 3985 | try |
| 3986 | { |
| 3987 | if (n < 0) |
| 3988 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3989 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3990 | } |
| 3991 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3992 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3993 | |
| 3994 | if (context) |
| 3995 | { |
| 3996 | for (int i = 0; i < n; i++) |
| 3997 | { |
| 3998 | textures[i] = context->createTexture(); |
| 3999 | } |
| 4000 | } |
| 4001 | } |
| 4002 | catch(std::bad_alloc&) |
| 4003 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4004 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4005 | } |
| 4006 | } |
| 4007 | |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4008 | 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] | 4009 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4010 | 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] | 4011 | "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] | 4012 | program, index, bufsize, length, size, type, name); |
| 4013 | |
| 4014 | try |
| 4015 | { |
| 4016 | if (bufsize < 0) |
| 4017 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4018 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4019 | } |
| 4020 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4021 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4022 | |
| 4023 | if (context) |
| 4024 | { |
| 4025 | gl::Program *programObject = context->getProgram(program); |
| 4026 | |
| 4027 | if (!programObject) |
| 4028 | { |
| 4029 | if (context->getShader(program)) |
| 4030 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4031 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4032 | } |
| 4033 | else |
| 4034 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4035 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4036 | } |
| 4037 | } |
| 4038 | |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4039 | if (index >= (GLuint)programObject->getActiveAttributeCount()) |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 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 | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4042 | } |
| 4043 | |
| 4044 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 4045 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4046 | } |
| 4047 | catch(std::bad_alloc&) |
| 4048 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4049 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4050 | } |
| 4051 | } |
| 4052 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4053 | 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] | 4054 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4055 | EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4056 | "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] | 4057 | program, index, bufsize, length, size, type, name); |
| 4058 | |
| 4059 | try |
| 4060 | { |
| 4061 | if (bufsize < 0) |
| 4062 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4063 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4064 | } |
| 4065 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4066 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4067 | |
| 4068 | if (context) |
| 4069 | { |
| 4070 | gl::Program *programObject = context->getProgram(program); |
| 4071 | |
| 4072 | if (!programObject) |
| 4073 | { |
| 4074 | if (context->getShader(program)) |
| 4075 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4076 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4077 | } |
| 4078 | else |
| 4079 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4080 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4081 | } |
| 4082 | } |
| 4083 | |
| 4084 | if (index >= (GLuint)programObject->getActiveUniformCount()) |
| 4085 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4086 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4087 | } |
| 4088 | |
| 4089 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 4090 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4091 | } |
| 4092 | catch(std::bad_alloc&) |
| 4093 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4094 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4095 | } |
| 4096 | } |
| 4097 | |
| 4098 | void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) |
| 4099 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4100 | 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] | 4101 | program, maxcount, count, shaders); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4102 | |
| 4103 | try |
| 4104 | { |
| 4105 | if (maxcount < 0) |
| 4106 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4107 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4108 | } |
| 4109 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4110 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4111 | |
| 4112 | if (context) |
| 4113 | { |
| 4114 | gl::Program *programObject = context->getProgram(program); |
| 4115 | |
| 4116 | if (!programObject) |
| 4117 | { |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4118 | if (context->getShader(program)) |
| 4119 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4120 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4121 | } |
| 4122 | else |
| 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 | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4125 | } |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4126 | } |
| 4127 | |
| 4128 | return programObject->getAttachedShaders(maxcount, count, shaders); |
| 4129 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4130 | } |
| 4131 | catch(std::bad_alloc&) |
| 4132 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4133 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4134 | } |
| 4135 | } |
| 4136 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4137 | int __stdcall glGetAttribLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4138 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4139 | EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4140 | |
| 4141 | try |
| 4142 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4143 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4144 | |
| 4145 | if (context) |
| 4146 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4147 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4148 | gl::Program *programObject = context->getProgram(program); |
| 4149 | |
| 4150 | if (!programObject) |
| 4151 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4152 | if (context->getShader(program)) |
| 4153 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4154 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4155 | } |
| 4156 | else |
| 4157 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4158 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4159 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4160 | } |
| 4161 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4162 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 4163 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4164 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4165 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4166 | } |
| 4167 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4168 | return programBinary->getAttributeLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4169 | } |
| 4170 | } |
| 4171 | catch(std::bad_alloc&) |
| 4172 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4173 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4174 | } |
| 4175 | |
| 4176 | return -1; |
| 4177 | } |
| 4178 | |
| 4179 | void __stdcall glGetBooleanv(GLenum pname, GLboolean* params) |
| 4180 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4181 | 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] | 4182 | |
| 4183 | try |
| 4184 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4185 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4186 | |
| 4187 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4188 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4189 | if (!(context->getBooleanv(pname, params))) |
| 4190 | { |
| 4191 | GLenum nativeType; |
| 4192 | unsigned int numParams = 0; |
| 4193 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4194 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4195 | |
| 4196 | if (numParams == 0) |
| 4197 | return; // it is known that the pname is valid, but there are no parameters to return |
| 4198 | |
| 4199 | if (nativeType == GL_FLOAT) |
| 4200 | { |
| 4201 | GLfloat *floatParams = NULL; |
| 4202 | floatParams = new GLfloat[numParams]; |
| 4203 | |
| 4204 | context->getFloatv(pname, floatParams); |
| 4205 | |
| 4206 | for (unsigned int i = 0; i < numParams; ++i) |
| 4207 | { |
| 4208 | if (floatParams[i] == 0.0f) |
| 4209 | params[i] = GL_FALSE; |
| 4210 | else |
| 4211 | params[i] = GL_TRUE; |
| 4212 | } |
| 4213 | |
| 4214 | delete [] floatParams; |
| 4215 | } |
| 4216 | else if (nativeType == GL_INT) |
| 4217 | { |
| 4218 | GLint *intParams = NULL; |
| 4219 | intParams = new GLint[numParams]; |
| 4220 | |
| 4221 | context->getIntegerv(pname, intParams); |
| 4222 | |
| 4223 | for (unsigned int i = 0; i < numParams; ++i) |
| 4224 | { |
| 4225 | if (intParams[i] == 0) |
| 4226 | params[i] = GL_FALSE; |
| 4227 | else |
| 4228 | params[i] = GL_TRUE; |
| 4229 | } |
| 4230 | |
| 4231 | delete [] intParams; |
| 4232 | } |
| 4233 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4234 | } |
| 4235 | } |
| 4236 | catch(std::bad_alloc&) |
| 4237 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4238 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4239 | } |
| 4240 | } |
| 4241 | |
| 4242 | void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 4243 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4244 | 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] | 4245 | |
| 4246 | try |
| 4247 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4248 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4249 | |
| 4250 | if (context) |
| 4251 | { |
| 4252 | gl::Buffer *buffer; |
| 4253 | |
| 4254 | switch (target) |
| 4255 | { |
| 4256 | case GL_ARRAY_BUFFER: |
| 4257 | buffer = context->getArrayBuffer(); |
| 4258 | break; |
| 4259 | case GL_ELEMENT_ARRAY_BUFFER: |
| 4260 | buffer = context->getElementArrayBuffer(); |
| 4261 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4262 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4263 | } |
| 4264 | |
| 4265 | if (!buffer) |
| 4266 | { |
| 4267 | // 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] | 4268 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4269 | } |
| 4270 | |
| 4271 | switch (pname) |
| 4272 | { |
| 4273 | case GL_BUFFER_USAGE: |
| 4274 | *params = buffer->usage(); |
| 4275 | break; |
| 4276 | case GL_BUFFER_SIZE: |
| 4277 | *params = buffer->size(); |
| 4278 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4279 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4280 | } |
| 4281 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4282 | } |
| 4283 | catch(std::bad_alloc&) |
| 4284 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4285 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4286 | } |
| 4287 | } |
| 4288 | |
| 4289 | GLenum __stdcall glGetError(void) |
| 4290 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4291 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4292 | |
| 4293 | gl::Context *context = gl::getContext(); |
| 4294 | |
| 4295 | if (context) |
| 4296 | { |
daniel@transgaming.com | 82b2891 | 2011-12-12 21:01:35 +0000 | [diff] [blame] | 4297 | return context->getError(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4298 | } |
| 4299 | |
| 4300 | return GL_NO_ERROR; |
| 4301 | } |
| 4302 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4303 | void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 4304 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4305 | 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] | 4306 | |
| 4307 | try |
| 4308 | { |
| 4309 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4310 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4311 | |
| 4312 | if (context) |
| 4313 | { |
| 4314 | gl::Fence *fenceObject = context->getFence(fence); |
| 4315 | |
| 4316 | if (fenceObject == NULL) |
| 4317 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4318 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4319 | } |
| 4320 | |
| 4321 | fenceObject->getFenceiv(pname, params); |
| 4322 | } |
| 4323 | } |
| 4324 | catch(std::bad_alloc&) |
| 4325 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4326 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4327 | } |
| 4328 | } |
| 4329 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4330 | void __stdcall glGetFloatv(GLenum pname, GLfloat* params) |
| 4331 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4332 | 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] | 4333 | |
| 4334 | try |
| 4335 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4336 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4337 | |
| 4338 | if (context) |
| 4339 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4340 | if (!(context->getFloatv(pname, params))) |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4341 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4342 | GLenum nativeType; |
| 4343 | unsigned int numParams = 0; |
| 4344 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4345 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4346 | |
| 4347 | if (numParams == 0) |
| 4348 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 4349 | |
| 4350 | if (nativeType == GL_BOOL) |
| 4351 | { |
| 4352 | GLboolean *boolParams = NULL; |
| 4353 | boolParams = new GLboolean[numParams]; |
| 4354 | |
| 4355 | context->getBooleanv(pname, boolParams); |
| 4356 | |
| 4357 | for (unsigned int i = 0; i < numParams; ++i) |
| 4358 | { |
| 4359 | if (boolParams[i] == GL_FALSE) |
| 4360 | params[i] = 0.0f; |
| 4361 | else |
| 4362 | params[i] = 1.0f; |
| 4363 | } |
| 4364 | |
| 4365 | delete [] boolParams; |
| 4366 | } |
| 4367 | else if (nativeType == GL_INT) |
| 4368 | { |
| 4369 | GLint *intParams = NULL; |
| 4370 | intParams = new GLint[numParams]; |
| 4371 | |
| 4372 | context->getIntegerv(pname, intParams); |
| 4373 | |
| 4374 | for (unsigned int i = 0; i < numParams; ++i) |
| 4375 | { |
| 4376 | params[i] = (GLfloat)intParams[i]; |
| 4377 | } |
| 4378 | |
| 4379 | delete [] intParams; |
| 4380 | } |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4381 | } |
| 4382 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4383 | } |
| 4384 | catch(std::bad_alloc&) |
| 4385 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4386 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4387 | } |
| 4388 | } |
| 4389 | |
| 4390 | void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) |
| 4391 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4392 | 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] | 4393 | target, attachment, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4394 | |
| 4395 | try |
| 4396 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4397 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4398 | |
| 4399 | if (context) |
| 4400 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4401 | 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] | 4402 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4403 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4404 | } |
| 4405 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4406 | gl::Framebuffer *framebuffer = NULL; |
| 4407 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4408 | { |
| 4409 | if(context->getReadFramebufferHandle() == 0) |
| 4410 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4411 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4412 | } |
| 4413 | |
| 4414 | framebuffer = context->getReadFramebuffer(); |
| 4415 | } |
| 4416 | else |
| 4417 | { |
| 4418 | if (context->getDrawFramebufferHandle() == 0) |
| 4419 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4420 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4421 | } |
| 4422 | |
| 4423 | framebuffer = context->getDrawFramebuffer(); |
| 4424 | } |
| 4425 | |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4426 | GLenum attachmentType; |
| 4427 | GLuint attachmentHandle; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4428 | |
| 4429 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4430 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4431 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4432 | |
| 4433 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4434 | { |
| 4435 | return gl::error(GL_INVALID_ENUM); |
| 4436 | } |
| 4437 | |
| 4438 | attachmentType = framebuffer->getColorbufferType(colorAttachment); |
| 4439 | attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment); |
| 4440 | } |
| 4441 | else |
| 4442 | { |
| 4443 | switch (attachment) |
| 4444 | { |
| 4445 | case GL_DEPTH_ATTACHMENT: |
| 4446 | attachmentType = framebuffer->getDepthbufferType(); |
| 4447 | attachmentHandle = framebuffer->getDepthbufferHandle(); |
| 4448 | break; |
| 4449 | case GL_STENCIL_ATTACHMENT: |
| 4450 | attachmentType = framebuffer->getStencilbufferType(); |
| 4451 | attachmentHandle = framebuffer->getStencilbufferHandle(); |
| 4452 | break; |
| 4453 | default: return gl::error(GL_INVALID_ENUM); |
| 4454 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4455 | } |
| 4456 | |
| 4457 | GLenum attachmentObjectType; // Type category |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4458 | if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4459 | { |
| 4460 | attachmentObjectType = attachmentType; |
| 4461 | } |
apatrick@chromium.org | 551022e | 2012-01-23 19:56:54 +0000 | [diff] [blame] | 4462 | else if (gl::IsInternalTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4463 | { |
| 4464 | attachmentObjectType = GL_TEXTURE; |
| 4465 | } |
apatrick@chromium.org | a1d8059 | 2012-01-25 21:52:10 +0000 | [diff] [blame] | 4466 | else |
| 4467 | { |
| 4468 | UNREACHABLE(); |
| 4469 | return; |
| 4470 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4471 | |
| 4472 | switch (pname) |
| 4473 | { |
| 4474 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 4475 | *params = attachmentObjectType; |
| 4476 | break; |
| 4477 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 4478 | if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE) |
| 4479 | { |
| 4480 | *params = attachmentHandle; |
| 4481 | } |
| 4482 | else |
| 4483 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4484 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4485 | } |
| 4486 | break; |
| 4487 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 4488 | if (attachmentObjectType == GL_TEXTURE) |
| 4489 | { |
| 4490 | *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0 |
| 4491 | } |
| 4492 | else |
| 4493 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4494 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4495 | } |
| 4496 | break; |
| 4497 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 4498 | if (attachmentObjectType == GL_TEXTURE) |
| 4499 | { |
daniel@transgaming.com | 19ffc24 | 2010-05-04 03:35:21 +0000 | [diff] [blame] | 4500 | if (gl::IsCubemapTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4501 | { |
| 4502 | *params = attachmentType; |
| 4503 | } |
| 4504 | else |
| 4505 | { |
| 4506 | *params = 0; |
| 4507 | } |
| 4508 | } |
| 4509 | else |
| 4510 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4511 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4512 | } |
| 4513 | break; |
| 4514 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4515 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4516 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4517 | } |
| 4518 | } |
| 4519 | catch(std::bad_alloc&) |
| 4520 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4521 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4522 | } |
| 4523 | } |
| 4524 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 4525 | GLenum __stdcall glGetGraphicsResetStatusEXT(void) |
| 4526 | { |
| 4527 | EVENT("()"); |
| 4528 | |
| 4529 | try |
| 4530 | { |
| 4531 | gl::Context *context = gl::getContext(); |
| 4532 | |
| 4533 | if (context) |
| 4534 | { |
| 4535 | return context->getResetStatus(); |
| 4536 | } |
| 4537 | |
| 4538 | return GL_NO_ERROR; |
| 4539 | } |
| 4540 | catch(std::bad_alloc&) |
| 4541 | { |
| 4542 | return GL_OUT_OF_MEMORY; |
| 4543 | } |
| 4544 | } |
| 4545 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4546 | void __stdcall glGetIntegerv(GLenum pname, GLint* params) |
| 4547 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4548 | 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] | 4549 | |
| 4550 | try |
| 4551 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4552 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4553 | |
| 4554 | if (context) |
| 4555 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4556 | if (!(context->getIntegerv(pname, params))) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4557 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4558 | GLenum nativeType; |
| 4559 | unsigned int numParams = 0; |
| 4560 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4561 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4562 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4563 | if (numParams == 0) |
| 4564 | return; // it is known that pname is valid, but there are no parameters to return |
| 4565 | |
| 4566 | if (nativeType == GL_BOOL) |
| 4567 | { |
| 4568 | GLboolean *boolParams = NULL; |
| 4569 | boolParams = new GLboolean[numParams]; |
| 4570 | |
| 4571 | context->getBooleanv(pname, boolParams); |
| 4572 | |
| 4573 | for (unsigned int i = 0; i < numParams; ++i) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4574 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4575 | if (boolParams[i] == GL_FALSE) |
| 4576 | params[i] = 0; |
| 4577 | else |
| 4578 | params[i] = 1; |
| 4579 | } |
| 4580 | |
| 4581 | delete [] boolParams; |
| 4582 | } |
| 4583 | else if (nativeType == GL_FLOAT) |
| 4584 | { |
| 4585 | GLfloat *floatParams = NULL; |
| 4586 | floatParams = new GLfloat[numParams]; |
| 4587 | |
| 4588 | context->getFloatv(pname, floatParams); |
| 4589 | |
| 4590 | for (unsigned int i = 0; i < numParams; ++i) |
| 4591 | { |
daniel@transgaming.com | c164135 | 2010-04-26 15:33:36 +0000 | [diff] [blame] | 4592 | 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] | 4593 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4594 | params[i] = (GLint)(((GLfloat)(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4595 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4596 | else |
| 4597 | 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] | 4598 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4599 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4600 | delete [] floatParams; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4601 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4602 | } |
| 4603 | } |
| 4604 | } |
| 4605 | catch(std::bad_alloc&) |
| 4606 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4607 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4608 | } |
| 4609 | } |
| 4610 | |
| 4611 | void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params) |
| 4612 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4613 | 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] | 4614 | |
| 4615 | try |
| 4616 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4617 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4618 | |
| 4619 | if (context) |
| 4620 | { |
| 4621 | gl::Program *programObject = context->getProgram(program); |
| 4622 | |
| 4623 | if (!programObject) |
| 4624 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4625 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4626 | } |
| 4627 | |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 4628 | if (context->getClientVersion() < 3) |
| 4629 | { |
| 4630 | switch (pname) |
| 4631 | { |
| 4632 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 4633 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 4634 | return gl::error(GL_INVALID_ENUM); |
| 4635 | } |
| 4636 | } |
| 4637 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4638 | switch (pname) |
| 4639 | { |
| 4640 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4641 | *params = programObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4642 | return; |
| 4643 | case GL_LINK_STATUS: |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 4644 | *params = programObject->isLinked(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4645 | return; |
| 4646 | case GL_VALIDATE_STATUS: |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 4647 | *params = programObject->isValidated(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4648 | return; |
| 4649 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4650 | *params = programObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4651 | return; |
| 4652 | case GL_ATTACHED_SHADERS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4653 | *params = programObject->getAttachedShadersCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4654 | return; |
| 4655 | case GL_ACTIVE_ATTRIBUTES: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4656 | *params = programObject->getActiveAttributeCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4657 | return; |
| 4658 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4659 | *params = programObject->getActiveAttributeMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4660 | return; |
| 4661 | case GL_ACTIVE_UNIFORMS: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4662 | *params = programObject->getActiveUniformCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4663 | return; |
| 4664 | case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4665 | *params = programObject->getActiveUniformMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4666 | return; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 4667 | case GL_PROGRAM_BINARY_LENGTH_OES: |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 4668 | *params = programObject->getProgramBinaryLength(); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 4669 | return; |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 4670 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 4671 | *params = programObject->getActiveUniformBlockCount(); |
| 4672 | return; |
| 4673 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 4674 | *params = programObject->getActiveUniformBlockMaxLength(); |
| 4675 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4676 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4677 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4678 | } |
| 4679 | } |
| 4680 | } |
| 4681 | catch(std::bad_alloc&) |
| 4682 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4683 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4684 | } |
| 4685 | } |
| 4686 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4687 | void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4688 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4689 | 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] | 4690 | program, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4691 | |
| 4692 | try |
| 4693 | { |
| 4694 | if (bufsize < 0) |
| 4695 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4696 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4697 | } |
| 4698 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4699 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4700 | |
| 4701 | if (context) |
| 4702 | { |
| 4703 | gl::Program *programObject = context->getProgram(program); |
| 4704 | |
| 4705 | if (!programObject) |
| 4706 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4707 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4708 | } |
| 4709 | |
| 4710 | programObject->getInfoLog(bufsize, length, infolog); |
| 4711 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4712 | } |
| 4713 | catch(std::bad_alloc&) |
| 4714 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4715 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4716 | } |
| 4717 | } |
| 4718 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4719 | void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params) |
| 4720 | { |
| 4721 | EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params); |
| 4722 | |
| 4723 | try |
| 4724 | { |
| 4725 | switch (pname) |
| 4726 | { |
| 4727 | case GL_CURRENT_QUERY_EXT: |
| 4728 | break; |
| 4729 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4730 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4731 | } |
| 4732 | |
| 4733 | gl::Context *context = gl::getNonLostContext(); |
| 4734 | |
| 4735 | if (context) |
| 4736 | { |
| 4737 | params[0] = context->getActiveQuery(target); |
| 4738 | } |
| 4739 | } |
| 4740 | catch(std::bad_alloc&) |
| 4741 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4742 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4743 | } |
| 4744 | } |
| 4745 | |
| 4746 | void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) |
| 4747 | { |
| 4748 | EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params); |
| 4749 | |
| 4750 | try |
| 4751 | { |
| 4752 | switch (pname) |
| 4753 | { |
| 4754 | case GL_QUERY_RESULT_EXT: |
| 4755 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 4756 | break; |
| 4757 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4758 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4759 | } |
| 4760 | gl::Context *context = gl::getNonLostContext(); |
| 4761 | |
| 4762 | if (context) |
| 4763 | { |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4764 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 4765 | |
| 4766 | if (!queryObject) |
| 4767 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4768 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4769 | } |
| 4770 | |
| 4771 | if (context->getActiveQuery(queryObject->getType()) == id) |
| 4772 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4773 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4774 | } |
| 4775 | |
| 4776 | switch(pname) |
| 4777 | { |
| 4778 | case GL_QUERY_RESULT_EXT: |
| 4779 | params[0] = queryObject->getResult(); |
| 4780 | break; |
| 4781 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 4782 | params[0] = queryObject->isResultAvailable(); |
| 4783 | break; |
| 4784 | default: |
| 4785 | ASSERT(false); |
| 4786 | } |
| 4787 | } |
| 4788 | } |
| 4789 | catch(std::bad_alloc&) |
| 4790 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4791 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4792 | } |
| 4793 | } |
| 4794 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4795 | void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 4796 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4797 | 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] | 4798 | |
| 4799 | try |
| 4800 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4801 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4802 | |
| 4803 | if (context) |
| 4804 | { |
| 4805 | if (target != GL_RENDERBUFFER) |
| 4806 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4807 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4808 | } |
| 4809 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4810 | if (context->getRenderbufferHandle() == 0) |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4811 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4812 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4813 | } |
| 4814 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4815 | gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle()); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4816 | |
| 4817 | switch (pname) |
| 4818 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 4819 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break; |
| 4820 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break; |
| 4821 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break; |
| 4822 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break; |
| 4823 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break; |
| 4824 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break; |
| 4825 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break; |
| 4826 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break; |
| 4827 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break; |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 4828 | case GL_RENDERBUFFER_SAMPLES_ANGLE: |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 4829 | if (context->getMaxSupportedSamples() != 0) |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 4830 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 4831 | *params = renderbuffer->getSamples(); |
| 4832 | } |
| 4833 | else |
| 4834 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4835 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 4836 | } |
| 4837 | break; |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4838 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4839 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 4840 | } |
| 4841 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4842 | } |
| 4843 | catch(std::bad_alloc&) |
| 4844 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4845 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4846 | } |
| 4847 | } |
| 4848 | |
| 4849 | void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params) |
| 4850 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4851 | 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] | 4852 | |
| 4853 | try |
| 4854 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4855 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4856 | |
| 4857 | if (context) |
| 4858 | { |
| 4859 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 4860 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4861 | if (!shaderObject) |
| 4862 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4863 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4864 | } |
| 4865 | |
| 4866 | switch (pname) |
| 4867 | { |
| 4868 | case GL_SHADER_TYPE: |
| 4869 | *params = shaderObject->getType(); |
| 4870 | return; |
| 4871 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4872 | *params = shaderObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4873 | return; |
| 4874 | case GL_COMPILE_STATUS: |
| 4875 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; |
| 4876 | return; |
| 4877 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4878 | *params = shaderObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4879 | return; |
| 4880 | case GL_SHADER_SOURCE_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4881 | *params = shaderObject->getSourceLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4882 | return; |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 4883 | case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: |
| 4884 | *params = shaderObject->getTranslatedSourceLength(); |
| 4885 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4886 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4887 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4888 | } |
| 4889 | } |
| 4890 | } |
| 4891 | catch(std::bad_alloc&) |
| 4892 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4893 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4894 | } |
| 4895 | } |
| 4896 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4897 | void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4898 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4899 | 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] | 4900 | shader, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4901 | |
| 4902 | try |
| 4903 | { |
| 4904 | if (bufsize < 0) |
| 4905 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4906 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4907 | } |
| 4908 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4909 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4910 | |
| 4911 | if (context) |
| 4912 | { |
| 4913 | gl::Shader *shaderObject = context->getShader(shader); |
| 4914 | |
| 4915 | if (!shaderObject) |
| 4916 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4917 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4918 | } |
| 4919 | |
| 4920 | shaderObject->getInfoLog(bufsize, length, infolog); |
| 4921 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4922 | } |
| 4923 | catch(std::bad_alloc&) |
| 4924 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4925 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4926 | } |
| 4927 | } |
| 4928 | |
| 4929 | void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) |
| 4930 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4931 | 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] | 4932 | shadertype, precisiontype, range, precision); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4933 | |
| 4934 | try |
| 4935 | { |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4936 | switch (shadertype) |
| 4937 | { |
| 4938 | case GL_VERTEX_SHADER: |
| 4939 | case GL_FRAGMENT_SHADER: |
| 4940 | break; |
| 4941 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4942 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4943 | } |
| 4944 | |
| 4945 | switch (precisiontype) |
| 4946 | { |
| 4947 | case GL_LOW_FLOAT: |
| 4948 | case GL_MEDIUM_FLOAT: |
| 4949 | case GL_HIGH_FLOAT: |
| 4950 | // Assume IEEE 754 precision |
| 4951 | range[0] = 127; |
| 4952 | range[1] = 127; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 4953 | *precision = 23; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4954 | break; |
| 4955 | case GL_LOW_INT: |
| 4956 | case GL_MEDIUM_INT: |
| 4957 | case GL_HIGH_INT: |
| 4958 | // Some (most) hardware only supports single-precision floating-point numbers, |
| 4959 | // which can accurately represent integers up to +/-16777216 |
| 4960 | range[0] = 24; |
| 4961 | range[1] = 24; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 4962 | *precision = 0; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4963 | break; |
| 4964 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4965 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4966 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4967 | } |
| 4968 | catch(std::bad_alloc&) |
| 4969 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4970 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4971 | } |
| 4972 | } |
| 4973 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4974 | void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4975 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4976 | 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] | 4977 | shader, bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4978 | |
| 4979 | try |
| 4980 | { |
| 4981 | if (bufsize < 0) |
| 4982 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4983 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4984 | } |
| 4985 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4986 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4987 | |
| 4988 | if (context) |
| 4989 | { |
| 4990 | gl::Shader *shaderObject = context->getShader(shader); |
| 4991 | |
| 4992 | if (!shaderObject) |
| 4993 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4994 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 4995 | } |
| 4996 | |
| 4997 | shaderObject->getSource(bufsize, length, source); |
| 4998 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4999 | } |
| 5000 | catch(std::bad_alloc&) |
| 5001 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5002 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5003 | } |
| 5004 | } |
| 5005 | |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5006 | void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
| 5007 | { |
| 5008 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)", |
| 5009 | shader, bufsize, length, source); |
| 5010 | |
| 5011 | try |
| 5012 | { |
| 5013 | if (bufsize < 0) |
| 5014 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5015 | return gl::error(GL_INVALID_VALUE); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5016 | } |
| 5017 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5018 | gl::Context *context = gl::getNonLostContext(); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5019 | |
| 5020 | if (context) |
| 5021 | { |
| 5022 | gl::Shader *shaderObject = context->getShader(shader); |
| 5023 | |
| 5024 | if (!shaderObject) |
| 5025 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5026 | return gl::error(GL_INVALID_OPERATION); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5027 | } |
| 5028 | |
| 5029 | shaderObject->getTranslatedSource(bufsize, length, source); |
| 5030 | } |
| 5031 | } |
| 5032 | catch(std::bad_alloc&) |
| 5033 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5034 | return gl::error(GL_OUT_OF_MEMORY); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5035 | } |
| 5036 | } |
| 5037 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5038 | const GLubyte* __stdcall glGetString(GLenum name) |
| 5039 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5040 | EVENT("(GLenum name = 0x%X)", name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5041 | |
| 5042 | try |
| 5043 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5044 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3e4c600 | 2010-05-05 18:50:13 +0000 | [diff] [blame] | 5045 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5046 | switch (name) |
| 5047 | { |
| 5048 | case GL_VENDOR: |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 5049 | return (GLubyte*)"Google Inc."; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5050 | case GL_RENDERER: |
daniel@transgaming.com | c23ff64 | 2011-08-16 20:28:45 +0000 | [diff] [blame] | 5051 | return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5052 | case GL_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5053 | if (context->getClientVersion() == 2) |
| 5054 | { |
| 5055 | return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")"; |
| 5056 | } |
| 5057 | else |
| 5058 | { |
| 5059 | return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")"; |
| 5060 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5061 | case GL_SHADING_LANGUAGE_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5062 | if (context->getClientVersion() == 2) |
| 5063 | { |
| 5064 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")"; |
| 5065 | } |
| 5066 | else |
| 5067 | { |
| 5068 | return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")"; |
| 5069 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5070 | case GL_EXTENSIONS: |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 5071 | return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : ""); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5072 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5073 | return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5074 | } |
| 5075 | } |
| 5076 | catch(std::bad_alloc&) |
| 5077 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5078 | return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5079 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5080 | } |
| 5081 | |
| 5082 | void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) |
| 5083 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5084 | 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] | 5085 | |
| 5086 | try |
| 5087 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5088 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5089 | |
| 5090 | if (context) |
| 5091 | { |
| 5092 | gl::Texture *texture; |
| 5093 | |
| 5094 | switch (target) |
| 5095 | { |
| 5096 | case GL_TEXTURE_2D: |
| 5097 | texture = context->getTexture2D(); |
| 5098 | break; |
| 5099 | case GL_TEXTURE_CUBE_MAP: |
| 5100 | texture = context->getTextureCubeMap(); |
| 5101 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5102 | case GL_TEXTURE_3D: |
| 5103 | if (context->getClientVersion() < 3) |
| 5104 | { |
| 5105 | return gl::error(GL_INVALID_ENUM); |
| 5106 | } |
| 5107 | texture = context->getTexture3D(); |
| 5108 | break; |
shannonwoods@chromium.org | 0c611d1 | 2013-05-30 00:15:05 +0000 | [diff] [blame^] | 5109 | case GL_TEXTURE_2D_ARRAY: |
| 5110 | if (context->getClientVersion() < 3) |
| 5111 | { |
| 5112 | return gl::error(GL_INVALID_ENUM); |
| 5113 | } |
| 5114 | texture = context->getTexture2DArray(); |
| 5115 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5116 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5117 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5118 | } |
| 5119 | |
| 5120 | switch (pname) |
| 5121 | { |
| 5122 | case GL_TEXTURE_MAG_FILTER: |
| 5123 | *params = (GLfloat)texture->getMagFilter(); |
| 5124 | break; |
| 5125 | case GL_TEXTURE_MIN_FILTER: |
| 5126 | *params = (GLfloat)texture->getMinFilter(); |
| 5127 | break; |
| 5128 | case GL_TEXTURE_WRAP_S: |
| 5129 | *params = (GLfloat)texture->getWrapS(); |
| 5130 | break; |
| 5131 | case GL_TEXTURE_WRAP_T: |
| 5132 | *params = (GLfloat)texture->getWrapT(); |
| 5133 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5134 | case GL_TEXTURE_WRAP_R: |
| 5135 | if (context->getClientVersion() < 3) |
| 5136 | { |
| 5137 | return gl::error(GL_INVALID_ENUM); |
| 5138 | } |
| 5139 | *params = (GLfloat)texture->getWrapR(); |
| 5140 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5141 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5142 | // 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] | 5143 | *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE); |
| 5144 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5145 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5146 | if (context->getClientVersion() < 3) |
| 5147 | { |
| 5148 | return gl::error(GL_INVALID_ENUM); |
| 5149 | } |
| 5150 | *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0); |
| 5151 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5152 | case GL_TEXTURE_USAGE_ANGLE: |
| 5153 | *params = (GLfloat)texture->getUsage(); |
| 5154 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5155 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5156 | if (!context->supportsTextureFilterAnisotropy()) |
| 5157 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5158 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5159 | } |
| 5160 | *params = (GLfloat)texture->getMaxAnisotropy(); |
| 5161 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5162 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5163 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5164 | } |
| 5165 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5166 | } |
| 5167 | catch(std::bad_alloc&) |
| 5168 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5169 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5170 | } |
| 5171 | } |
| 5172 | |
| 5173 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5174 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5175 | 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] | 5176 | |
| 5177 | try |
| 5178 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5179 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5180 | |
| 5181 | if (context) |
| 5182 | { |
| 5183 | gl::Texture *texture; |
| 5184 | |
| 5185 | switch (target) |
| 5186 | { |
| 5187 | case GL_TEXTURE_2D: |
| 5188 | texture = context->getTexture2D(); |
| 5189 | break; |
| 5190 | case GL_TEXTURE_CUBE_MAP: |
| 5191 | texture = context->getTextureCubeMap(); |
| 5192 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5193 | case GL_TEXTURE_3D: |
| 5194 | if (context->getClientVersion() < 3) |
| 5195 | { |
| 5196 | return gl::error(GL_INVALID_ENUM); |
| 5197 | } |
| 5198 | texture = context->getTexture3D(); |
| 5199 | break; |
shannonwoods@chromium.org | 0c611d1 | 2013-05-30 00:15:05 +0000 | [diff] [blame^] | 5200 | case GL_TEXTURE_2D_ARRAY: |
| 5201 | if (context->getClientVersion() < 3) |
| 5202 | { |
| 5203 | return gl::error(GL_INVALID_ENUM); |
| 5204 | } |
| 5205 | texture = context->getTexture2DArray(); |
| 5206 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5207 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5208 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5209 | } |
| 5210 | |
| 5211 | switch (pname) |
| 5212 | { |
| 5213 | case GL_TEXTURE_MAG_FILTER: |
| 5214 | *params = texture->getMagFilter(); |
| 5215 | break; |
| 5216 | case GL_TEXTURE_MIN_FILTER: |
| 5217 | *params = texture->getMinFilter(); |
| 5218 | break; |
| 5219 | case GL_TEXTURE_WRAP_S: |
| 5220 | *params = texture->getWrapS(); |
| 5221 | break; |
| 5222 | case GL_TEXTURE_WRAP_T: |
| 5223 | *params = texture->getWrapT(); |
| 5224 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5225 | case GL_TEXTURE_WRAP_R: |
| 5226 | if (context->getClientVersion() < 3) |
| 5227 | { |
| 5228 | return gl::error(GL_INVALID_ENUM); |
| 5229 | } |
| 5230 | *params = texture->getWrapR(); |
| 5231 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5232 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5233 | // 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] | 5234 | *params = texture->isImmutable() ? GL_TRUE : GL_FALSE; |
| 5235 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5236 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5237 | if (context->getClientVersion() < 3) |
| 5238 | { |
| 5239 | return gl::error(GL_INVALID_ENUM); |
| 5240 | } |
| 5241 | *params = texture->isImmutable() ? texture->levelCount() : 0; |
| 5242 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5243 | case GL_TEXTURE_USAGE_ANGLE: |
| 5244 | *params = texture->getUsage(); |
| 5245 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5246 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5247 | if (!context->supportsTextureFilterAnisotropy()) |
| 5248 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5249 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5250 | } |
| 5251 | *params = (GLint)texture->getMaxAnisotropy(); |
| 5252 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5253 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5254 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5255 | } |
| 5256 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5257 | } |
| 5258 | catch(std::bad_alloc&) |
| 5259 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5260 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5261 | } |
| 5262 | } |
| 5263 | |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5264 | void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
| 5265 | { |
| 5266 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)", |
| 5267 | program, location, bufSize, params); |
| 5268 | |
| 5269 | try |
| 5270 | { |
| 5271 | if (bufSize < 0) |
| 5272 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5273 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5274 | } |
| 5275 | |
| 5276 | gl::Context *context = gl::getNonLostContext(); |
| 5277 | |
| 5278 | if (context) |
| 5279 | { |
| 5280 | if (program == 0) |
| 5281 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5282 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5283 | } |
| 5284 | |
| 5285 | gl::Program *programObject = context->getProgram(program); |
| 5286 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5287 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5288 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5289 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5290 | } |
| 5291 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5292 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5293 | if (!programBinary) |
| 5294 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5295 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5296 | } |
| 5297 | |
| 5298 | if (!programBinary->getUniformfv(location, &bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5299 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5300 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5301 | } |
| 5302 | } |
| 5303 | } |
| 5304 | catch(std::bad_alloc&) |
| 5305 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5306 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5307 | } |
| 5308 | } |
| 5309 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5310 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 5311 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5312 | 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] | 5313 | |
| 5314 | try |
| 5315 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5316 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5317 | |
| 5318 | if (context) |
| 5319 | { |
| 5320 | if (program == 0) |
| 5321 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5322 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5323 | } |
| 5324 | |
| 5325 | gl::Program *programObject = context->getProgram(program); |
| 5326 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5327 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5328 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5329 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5330 | } |
| 5331 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5332 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5333 | if (!programBinary) |
| 5334 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5335 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5336 | } |
| 5337 | |
| 5338 | if (!programBinary->getUniformfv(location, NULL, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5339 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5340 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5341 | } |
| 5342 | } |
| 5343 | } |
| 5344 | catch(std::bad_alloc&) |
| 5345 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5346 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5347 | } |
| 5348 | } |
| 5349 | |
| 5350 | void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) |
| 5351 | { |
| 5352 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)", |
| 5353 | program, location, bufSize, params); |
| 5354 | |
| 5355 | try |
| 5356 | { |
| 5357 | if (bufSize < 0) |
| 5358 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5359 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5360 | } |
| 5361 | |
| 5362 | gl::Context *context = gl::getNonLostContext(); |
| 5363 | |
| 5364 | if (context) |
| 5365 | { |
| 5366 | if (program == 0) |
| 5367 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5368 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5369 | } |
| 5370 | |
| 5371 | gl::Program *programObject = context->getProgram(program); |
| 5372 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5373 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5374 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5375 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5376 | } |
| 5377 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5378 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5379 | if (!programBinary) |
| 5380 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5381 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5382 | } |
| 5383 | |
| 5384 | if (!programBinary->getUniformiv(location, &bufSize, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5385 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5386 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5387 | } |
| 5388 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5389 | } |
| 5390 | catch(std::bad_alloc&) |
| 5391 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5392 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5393 | } |
| 5394 | } |
| 5395 | |
| 5396 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 5397 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5398 | 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] | 5399 | |
| 5400 | try |
| 5401 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5402 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5403 | |
| 5404 | if (context) |
| 5405 | { |
| 5406 | if (program == 0) |
| 5407 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5408 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5409 | } |
| 5410 | |
| 5411 | gl::Program *programObject = context->getProgram(program); |
| 5412 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5413 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5414 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5415 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5416 | } |
| 5417 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5418 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5419 | if (!programBinary) |
| 5420 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5421 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5422 | } |
| 5423 | |
| 5424 | if (!programBinary->getUniformiv(location, NULL, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5425 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5426 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5427 | } |
| 5428 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5429 | } |
| 5430 | catch(std::bad_alloc&) |
| 5431 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5432 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5433 | } |
| 5434 | } |
| 5435 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5436 | int __stdcall glGetUniformLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5437 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5438 | 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] | 5439 | |
| 5440 | try |
| 5441 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5442 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5443 | |
| 5444 | if (strstr(name, "gl_") == name) |
| 5445 | { |
| 5446 | return -1; |
| 5447 | } |
| 5448 | |
| 5449 | if (context) |
| 5450 | { |
| 5451 | gl::Program *programObject = context->getProgram(program); |
| 5452 | |
| 5453 | if (!programObject) |
| 5454 | { |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5455 | if (context->getShader(program)) |
| 5456 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5457 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5458 | } |
| 5459 | else |
| 5460 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5461 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5462 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5463 | } |
| 5464 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5465 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5466 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5467 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5468 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5469 | } |
| 5470 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5471 | return programBinary->getUniformLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5472 | } |
| 5473 | } |
| 5474 | catch(std::bad_alloc&) |
| 5475 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5476 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5477 | } |
| 5478 | |
| 5479 | return -1; |
| 5480 | } |
| 5481 | |
| 5482 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 5483 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5484 | 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] | 5485 | |
| 5486 | try |
| 5487 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5488 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5489 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5490 | if (context) |
| 5491 | { |
| 5492 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5493 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5494 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5495 | } |
| 5496 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5497 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5498 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5499 | switch (pname) |
| 5500 | { |
| 5501 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5502 | *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5503 | break; |
| 5504 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5505 | *params = (GLfloat)attribState.mSize; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5506 | break; |
| 5507 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5508 | *params = (GLfloat)attribState.mStride; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5509 | break; |
| 5510 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5511 | *params = (GLfloat)attribState.mType; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5512 | break; |
| 5513 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5514 | *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5515 | break; |
| 5516 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 5517 | *params = (GLfloat)attribState.mBoundBuffer.id(); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5518 | break; |
| 5519 | case GL_CURRENT_VERTEX_ATTRIB: |
| 5520 | for (int i = 0; i < 4; ++i) |
| 5521 | { |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame] | 5522 | params[i] = attribState.mCurrentValue.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5523 | } |
| 5524 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 5525 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 5526 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 5527 | // the same constant. |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 5528 | *params = (GLfloat)attribState.mDivisor; |
| 5529 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5530 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5531 | } |
| 5532 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5533 | } |
| 5534 | catch(std::bad_alloc&) |
| 5535 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5536 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5537 | } |
| 5538 | } |
| 5539 | |
| 5540 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 5541 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5542 | 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] | 5543 | |
| 5544 | try |
| 5545 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5546 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5547 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5548 | if (context) |
| 5549 | { |
| 5550 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5551 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5552 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5553 | } |
| 5554 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5555 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5556 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5557 | switch (pname) |
| 5558 | { |
| 5559 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5560 | *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5561 | break; |
| 5562 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5563 | *params = attribState.mSize; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5564 | break; |
| 5565 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5566 | *params = attribState.mStride; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5567 | break; |
| 5568 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5569 | *params = attribState.mType; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5570 | break; |
| 5571 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5572 | *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5573 | break; |
| 5574 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 5575 | *params = attribState.mBoundBuffer.id(); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5576 | break; |
| 5577 | case GL_CURRENT_VERTEX_ATTRIB: |
| 5578 | for (int i = 0; i < 4; ++i) |
| 5579 | { |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame] | 5580 | float currentValue = attribState.mCurrentValue.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5581 | params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f)); |
| 5582 | } |
| 5583 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 5584 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 5585 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 5586 | // the same constant. |
| 5587 | 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] | 5588 | *params = (GLint)attribState.mDivisor; |
| 5589 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5590 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5591 | } |
| 5592 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5593 | } |
| 5594 | catch(std::bad_alloc&) |
| 5595 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5596 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5597 | } |
| 5598 | } |
| 5599 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5600 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5601 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5602 | 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] | 5603 | |
| 5604 | try |
| 5605 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5606 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5607 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5608 | if (context) |
| 5609 | { |
| 5610 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5611 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5612 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5613 | } |
| 5614 | |
| 5615 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) |
| 5616 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5617 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5618 | } |
| 5619 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5620 | *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index)); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5621 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5622 | } |
| 5623 | catch(std::bad_alloc&) |
| 5624 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5625 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5626 | } |
| 5627 | } |
| 5628 | |
| 5629 | void __stdcall glHint(GLenum target, GLenum mode) |
| 5630 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5631 | EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5632 | |
| 5633 | try |
| 5634 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5635 | switch (mode) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5636 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5637 | case GL_FASTEST: |
| 5638 | case GL_NICEST: |
| 5639 | case GL_DONT_CARE: |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5640 | break; |
| 5641 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5642 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5643 | } |
| 5644 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5645 | gl::Context *context = gl::getNonLostContext(); |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5646 | switch (target) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5647 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5648 | case GL_GENERATE_MIPMAP_HINT: |
| 5649 | if (context) context->setGenerateMipmapHint(mode); |
| 5650 | break; |
| 5651 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 5652 | if (context) context->setFragmentShaderDerivativeHint(mode); |
| 5653 | break; |
| 5654 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5655 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5656 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5657 | } |
| 5658 | catch(std::bad_alloc&) |
| 5659 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5660 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5661 | } |
| 5662 | } |
| 5663 | |
| 5664 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 5665 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5666 | EVENT("(GLuint buffer = %d)", buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5667 | |
| 5668 | try |
| 5669 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5670 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5671 | |
| 5672 | if (context && buffer) |
| 5673 | { |
| 5674 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 5675 | |
| 5676 | if (bufferObject) |
| 5677 | { |
| 5678 | return GL_TRUE; |
| 5679 | } |
| 5680 | } |
| 5681 | } |
| 5682 | catch(std::bad_alloc&) |
| 5683 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5684 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5685 | } |
| 5686 | |
| 5687 | return GL_FALSE; |
| 5688 | } |
| 5689 | |
| 5690 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 5691 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5692 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5693 | |
| 5694 | try |
| 5695 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5696 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5697 | |
| 5698 | if (context) |
| 5699 | { |
| 5700 | switch (cap) |
| 5701 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5702 | case GL_CULL_FACE: return context->isCullFaceEnabled(); |
| 5703 | case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled(); |
| 5704 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled(); |
| 5705 | case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled(); |
| 5706 | case GL_SCISSOR_TEST: return context->isScissorTestEnabled(); |
| 5707 | case GL_STENCIL_TEST: return context->isStencilTestEnabled(); |
| 5708 | case GL_DEPTH_TEST: return context->isDepthTestEnabled(); |
| 5709 | case GL_BLEND: return context->isBlendEnabled(); |
| 5710 | case GL_DITHER: return context->isDitherEnabled(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5711 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5712 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5713 | } |
| 5714 | } |
| 5715 | } |
| 5716 | catch(std::bad_alloc&) |
| 5717 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5718 | return gl::error(GL_OUT_OF_MEMORY, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5719 | } |
| 5720 | |
| 5721 | return false; |
| 5722 | } |
| 5723 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 5724 | GLboolean __stdcall glIsFenceNV(GLuint fence) |
| 5725 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5726 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5727 | |
| 5728 | try |
| 5729 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5730 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5731 | |
| 5732 | if (context) |
| 5733 | { |
| 5734 | gl::Fence *fenceObject = context->getFence(fence); |
| 5735 | |
| 5736 | if (fenceObject == NULL) |
| 5737 | { |
| 5738 | return GL_FALSE; |
| 5739 | } |
| 5740 | |
| 5741 | return fenceObject->isFence(); |
| 5742 | } |
| 5743 | } |
| 5744 | catch(std::bad_alloc&) |
| 5745 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5746 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5747 | } |
| 5748 | |
| 5749 | return GL_FALSE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 5750 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5751 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5752 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 5753 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5754 | EVENT("(GLuint framebuffer = %d)", framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5755 | |
| 5756 | try |
| 5757 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5758 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5759 | |
| 5760 | if (context && framebuffer) |
| 5761 | { |
| 5762 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 5763 | |
| 5764 | if (framebufferObject) |
| 5765 | { |
| 5766 | return GL_TRUE; |
| 5767 | } |
| 5768 | } |
| 5769 | } |
| 5770 | catch(std::bad_alloc&) |
| 5771 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5772 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5773 | } |
| 5774 | |
| 5775 | return GL_FALSE; |
| 5776 | } |
| 5777 | |
| 5778 | GLboolean __stdcall glIsProgram(GLuint program) |
| 5779 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5780 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5781 | |
| 5782 | try |
| 5783 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5784 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5785 | |
| 5786 | if (context && program) |
| 5787 | { |
| 5788 | gl::Program *programObject = context->getProgram(program); |
| 5789 | |
| 5790 | if (programObject) |
| 5791 | { |
| 5792 | return GL_TRUE; |
| 5793 | } |
| 5794 | } |
| 5795 | } |
| 5796 | catch(std::bad_alloc&) |
| 5797 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5798 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5799 | } |
| 5800 | |
| 5801 | return GL_FALSE; |
| 5802 | } |
| 5803 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5804 | GLboolean __stdcall glIsQueryEXT(GLuint id) |
| 5805 | { |
| 5806 | EVENT("(GLuint id = %d)", id); |
| 5807 | |
| 5808 | try |
| 5809 | { |
| 5810 | if (id == 0) |
| 5811 | { |
| 5812 | return GL_FALSE; |
| 5813 | } |
| 5814 | |
| 5815 | gl::Context *context = gl::getNonLostContext(); |
| 5816 | |
| 5817 | if (context) |
| 5818 | { |
| 5819 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 5820 | |
| 5821 | if (queryObject) |
| 5822 | { |
| 5823 | return GL_TRUE; |
| 5824 | } |
| 5825 | } |
| 5826 | } |
| 5827 | catch(std::bad_alloc&) |
| 5828 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5829 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5830 | } |
| 5831 | |
| 5832 | return GL_FALSE; |
| 5833 | } |
| 5834 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5835 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 5836 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5837 | EVENT("(GLuint renderbuffer = %d)", renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5838 | |
| 5839 | try |
| 5840 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5841 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5842 | |
| 5843 | if (context && renderbuffer) |
| 5844 | { |
| 5845 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 5846 | |
| 5847 | if (renderbufferObject) |
| 5848 | { |
| 5849 | return GL_TRUE; |
| 5850 | } |
| 5851 | } |
| 5852 | } |
| 5853 | catch(std::bad_alloc&) |
| 5854 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5855 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5856 | } |
| 5857 | |
| 5858 | return GL_FALSE; |
| 5859 | } |
| 5860 | |
| 5861 | GLboolean __stdcall glIsShader(GLuint shader) |
| 5862 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5863 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5864 | |
| 5865 | try |
| 5866 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5867 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5868 | |
| 5869 | if (context && shader) |
| 5870 | { |
| 5871 | gl::Shader *shaderObject = context->getShader(shader); |
| 5872 | |
| 5873 | if (shaderObject) |
| 5874 | { |
| 5875 | return GL_TRUE; |
| 5876 | } |
| 5877 | } |
| 5878 | } |
| 5879 | catch(std::bad_alloc&) |
| 5880 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5881 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5882 | } |
| 5883 | |
| 5884 | return GL_FALSE; |
| 5885 | } |
| 5886 | |
| 5887 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 5888 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5889 | EVENT("(GLuint texture = %d)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5890 | |
| 5891 | try |
| 5892 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5893 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5894 | |
| 5895 | if (context && texture) |
| 5896 | { |
| 5897 | gl::Texture *textureObject = context->getTexture(texture); |
| 5898 | |
| 5899 | if (textureObject) |
| 5900 | { |
| 5901 | return GL_TRUE; |
| 5902 | } |
| 5903 | } |
| 5904 | } |
| 5905 | catch(std::bad_alloc&) |
| 5906 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5907 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5908 | } |
| 5909 | |
| 5910 | return GL_FALSE; |
| 5911 | } |
| 5912 | |
| 5913 | void __stdcall glLineWidth(GLfloat width) |
| 5914 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5915 | EVENT("(GLfloat width = %f)", width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5916 | |
| 5917 | try |
| 5918 | { |
| 5919 | if (width <= 0.0f) |
| 5920 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5921 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5922 | } |
| 5923 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5924 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 5925 | |
| 5926 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5927 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5928 | context->setLineWidth(width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5929 | } |
| 5930 | } |
| 5931 | catch(std::bad_alloc&) |
| 5932 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5933 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5934 | } |
| 5935 | } |
| 5936 | |
| 5937 | void __stdcall glLinkProgram(GLuint program) |
| 5938 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5939 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5940 | |
| 5941 | try |
| 5942 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5943 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5944 | |
| 5945 | if (context) |
| 5946 | { |
| 5947 | gl::Program *programObject = context->getProgram(program); |
| 5948 | |
| 5949 | if (!programObject) |
| 5950 | { |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 5951 | if (context->getShader(program)) |
| 5952 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5953 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 5954 | } |
| 5955 | else |
| 5956 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5957 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 5958 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5959 | } |
| 5960 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 5961 | context->linkProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5962 | } |
| 5963 | } |
| 5964 | catch(std::bad_alloc&) |
| 5965 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5966 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5967 | } |
| 5968 | } |
| 5969 | |
| 5970 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 5971 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5972 | EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5973 | |
| 5974 | try |
| 5975 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5976 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 5977 | |
| 5978 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5979 | { |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 5980 | switch (pname) |
| 5981 | { |
| 5982 | case GL_UNPACK_ALIGNMENT: |
| 5983 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 5984 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5985 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 5986 | } |
| 5987 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5988 | context->setUnpackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 5989 | break; |
| 5990 | |
| 5991 | case GL_PACK_ALIGNMENT: |
| 5992 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 5993 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5994 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 5995 | } |
| 5996 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5997 | context->setPackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 5998 | break; |
| 5999 | |
bsalomon@google.com | 56d46ab | 2011-11-23 14:53:10 +0000 | [diff] [blame] | 6000 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 6001 | context->setPackReverseRowOrder(param != 0); |
| 6002 | break; |
| 6003 | |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6004 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6005 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6006 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6007 | } |
| 6008 | } |
| 6009 | catch(std::bad_alloc&) |
| 6010 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6011 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6012 | } |
| 6013 | } |
| 6014 | |
| 6015 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 6016 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6017 | EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6018 | |
| 6019 | try |
| 6020 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6021 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aede630 | 2010-04-29 03:35:48 +0000 | [diff] [blame] | 6022 | |
| 6023 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6024 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6025 | context->setPolygonOffsetParams(factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6026 | } |
| 6027 | } |
| 6028 | catch(std::bad_alloc&) |
| 6029 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6030 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6031 | } |
| 6032 | } |
| 6033 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6034 | void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6035 | GLenum format, GLenum type, GLsizei bufSize, |
| 6036 | GLvoid *data) |
| 6037 | { |
| 6038 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
| 6039 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)", |
| 6040 | x, y, width, height, format, type, bufSize, data); |
| 6041 | |
| 6042 | try |
| 6043 | { |
| 6044 | if (width < 0 || height < 0 || bufSize < 0) |
| 6045 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6046 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6047 | } |
| 6048 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6049 | gl::Context *context = gl::getNonLostContext(); |
| 6050 | |
| 6051 | if (context) |
| 6052 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6053 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6054 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6055 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6056 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6057 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6058 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6059 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6060 | return; |
| 6061 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6062 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6063 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6064 | |
| 6065 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6066 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6067 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6068 | } |
| 6069 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6070 | context->readPixels(x, y, width, height, format, type, &bufSize, data); |
| 6071 | } |
| 6072 | } |
| 6073 | catch(std::bad_alloc&) |
| 6074 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6075 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6076 | } |
| 6077 | } |
| 6078 | |
| 6079 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6080 | GLenum format, GLenum type, GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6081 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6082 | 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] | 6083 | "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] | 6084 | x, y, width, height, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6085 | |
| 6086 | try |
| 6087 | { |
| 6088 | if (width < 0 || height < 0) |
| 6089 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6090 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6091 | } |
| 6092 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6093 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6094 | |
| 6095 | if (context) |
| 6096 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6097 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6098 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6099 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6100 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6101 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6102 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6103 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6104 | return; |
| 6105 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6106 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6107 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6108 | |
| 6109 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6110 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6111 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6112 | } |
| 6113 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6114 | context->readPixels(x, y, width, height, format, type, NULL, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6115 | } |
| 6116 | } |
| 6117 | catch(std::bad_alloc&) |
| 6118 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6119 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6120 | } |
| 6121 | } |
| 6122 | |
| 6123 | void __stdcall glReleaseShaderCompiler(void) |
| 6124 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6125 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6126 | |
| 6127 | try |
| 6128 | { |
| 6129 | gl::Shader::releaseCompiler(); |
| 6130 | } |
| 6131 | catch(std::bad_alloc&) |
| 6132 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6133 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6134 | } |
| 6135 | } |
| 6136 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6137 | 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] | 6138 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6139 | 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] | 6140 | target, samples, internalformat, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6141 | |
| 6142 | try |
| 6143 | { |
| 6144 | switch (target) |
| 6145 | { |
| 6146 | case GL_RENDERBUFFER: |
| 6147 | break; |
| 6148 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6149 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6150 | } |
| 6151 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6152 | if (width < 0 || height < 0 || samples < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6153 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6154 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6155 | } |
| 6156 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6157 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6158 | |
| 6159 | if (context) |
| 6160 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6161 | if (!gl::IsValidInternalFormat(internalformat, context)) |
| 6162 | { |
| 6163 | return gl::error(GL_INVALID_ENUM); |
| 6164 | } |
| 6165 | |
| 6166 | if (!gl::IsColorRenderingSupported(internalformat, context) && |
| 6167 | !gl::IsDepthRenderingSupported(internalformat, context) && |
| 6168 | !gl::IsStencilRenderingSupported(internalformat, context)) |
| 6169 | { |
| 6170 | return gl::error(GL_INVALID_ENUM); |
| 6171 | } |
| 6172 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6173 | if (width > context->getMaximumRenderbufferDimension() || |
| 6174 | height > context->getMaximumRenderbufferDimension() || |
| 6175 | samples > context->getMaxSupportedSamples()) |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6176 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6177 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6178 | } |
| 6179 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 6180 | GLuint handle = context->getRenderbufferHandle(); |
| 6181 | if (handle == 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6182 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6183 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6184 | } |
| 6185 | |
| 6186 | switch (internalformat) |
| 6187 | { |
| 6188 | case GL_DEPTH_COMPONENT16: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6189 | case GL_RGBA4: |
| 6190 | case GL_RGB5_A1: |
| 6191 | case GL_RGB565: |
daniel@transgaming.com | 6397754 | 2010-08-24 19:21:02 +0000 | [diff] [blame] | 6192 | case GL_RGB8_OES: |
| 6193 | case GL_RGBA8_OES: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6194 | case GL_STENCIL_INDEX8: |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 6195 | case GL_DEPTH24_STENCIL8_OES: |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 6196 | break; |
| 6197 | case GL_SRGB8_ALPHA8: |
| 6198 | case GL_RGB10_A2: |
| 6199 | case GL_RG8: |
| 6200 | case GL_R8: |
| 6201 | if (context->getClientVersion() < 3) |
| 6202 | { |
| 6203 | return gl::error(GL_INVALID_ENUM); |
| 6204 | } |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 6205 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6206 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6207 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6208 | } |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 6209 | |
| 6210 | context->setRenderbufferStorage(width, height, internalformat, samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6211 | } |
| 6212 | } |
| 6213 | catch(std::bad_alloc&) |
| 6214 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6215 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6216 | } |
| 6217 | } |
| 6218 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6219 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 6220 | { |
| 6221 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height); |
| 6222 | } |
| 6223 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6224 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 6225 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6226 | EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6227 | |
| 6228 | try |
| 6229 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6230 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6231 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6232 | if (context) |
| 6233 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 6234 | context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6235 | } |
| 6236 | } |
| 6237 | catch(std::bad_alloc&) |
| 6238 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6239 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6240 | } |
| 6241 | } |
| 6242 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6243 | void __stdcall glSetFenceNV(GLuint fence, GLenum condition) |
| 6244 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6245 | EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6246 | |
| 6247 | try |
| 6248 | { |
| 6249 | if (condition != GL_ALL_COMPLETED_NV) |
| 6250 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6251 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6252 | } |
| 6253 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6254 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6255 | |
| 6256 | if (context) |
| 6257 | { |
| 6258 | gl::Fence *fenceObject = context->getFence(fence); |
| 6259 | |
| 6260 | if (fenceObject == NULL) |
| 6261 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6262 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6263 | } |
| 6264 | |
| 6265 | fenceObject->setFence(condition); |
| 6266 | } |
| 6267 | } |
| 6268 | catch(std::bad_alloc&) |
| 6269 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6270 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6271 | } |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6272 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6273 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6274 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 6275 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6276 | 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] | 6277 | |
| 6278 | try |
| 6279 | { |
| 6280 | if (width < 0 || height < 0) |
| 6281 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6282 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6283 | } |
| 6284 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6285 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6286 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6287 | if (context) |
| 6288 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6289 | context->setScissorParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6290 | } |
| 6291 | } |
| 6292 | catch(std::bad_alloc&) |
| 6293 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6294 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6295 | } |
| 6296 | } |
| 6297 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6298 | 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] | 6299 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6300 | 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] | 6301 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 6302 | n, shaders, binaryformat, binary, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6303 | |
| 6304 | try |
| 6305 | { |
daniel@transgaming.com | d1f667f | 2010-04-29 03:38:52 +0000 | [diff] [blame] | 6306 | // No binary shader formats are supported. |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6307 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6308 | } |
| 6309 | catch(std::bad_alloc&) |
| 6310 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6311 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6312 | } |
| 6313 | } |
| 6314 | |
shannon.woods%transgaming.com@gtempaccount.com | 5f33933 | 2013-04-13 03:29:02 +0000 | [diff] [blame] | 6315 | 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] | 6316 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6317 | 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] | 6318 | shader, count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6319 | |
| 6320 | try |
| 6321 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6322 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6323 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6324 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6325 | } |
| 6326 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6327 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6328 | |
| 6329 | if (context) |
| 6330 | { |
| 6331 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6332 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6333 | if (!shaderObject) |
| 6334 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6335 | if (context->getProgram(shader)) |
| 6336 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6337 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6338 | } |
| 6339 | else |
| 6340 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6341 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6342 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6343 | } |
| 6344 | |
| 6345 | shaderObject->setSource(count, string, length); |
| 6346 | } |
| 6347 | } |
| 6348 | catch(std::bad_alloc&) |
| 6349 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6350 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6351 | } |
| 6352 | } |
| 6353 | |
| 6354 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 6355 | { |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6356 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6357 | } |
| 6358 | |
| 6359 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 6360 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6361 | 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] | 6362 | |
| 6363 | try |
| 6364 | { |
| 6365 | switch (face) |
| 6366 | { |
| 6367 | case GL_FRONT: |
| 6368 | case GL_BACK: |
| 6369 | case GL_FRONT_AND_BACK: |
| 6370 | break; |
| 6371 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6372 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6373 | } |
| 6374 | |
| 6375 | switch (func) |
| 6376 | { |
| 6377 | case GL_NEVER: |
| 6378 | case GL_ALWAYS: |
| 6379 | case GL_LESS: |
| 6380 | case GL_LEQUAL: |
| 6381 | case GL_EQUAL: |
| 6382 | case GL_GEQUAL: |
| 6383 | case GL_GREATER: |
| 6384 | case GL_NOTEQUAL: |
| 6385 | break; |
| 6386 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6387 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6388 | } |
| 6389 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6390 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6391 | |
| 6392 | if (context) |
| 6393 | { |
| 6394 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6395 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6396 | context->setStencilParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6397 | } |
| 6398 | |
| 6399 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6400 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6401 | context->setStencilBackParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6402 | } |
| 6403 | } |
| 6404 | } |
| 6405 | catch(std::bad_alloc&) |
| 6406 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6407 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6408 | } |
| 6409 | } |
| 6410 | |
| 6411 | void __stdcall glStencilMask(GLuint mask) |
| 6412 | { |
| 6413 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 6414 | } |
| 6415 | |
| 6416 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 6417 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6418 | EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6419 | |
| 6420 | try |
| 6421 | { |
| 6422 | switch (face) |
| 6423 | { |
| 6424 | case GL_FRONT: |
| 6425 | case GL_BACK: |
| 6426 | case GL_FRONT_AND_BACK: |
| 6427 | break; |
| 6428 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6429 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6430 | } |
| 6431 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6432 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6433 | |
| 6434 | if (context) |
| 6435 | { |
| 6436 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6437 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6438 | context->setStencilWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6439 | } |
| 6440 | |
| 6441 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6442 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6443 | context->setStencilBackWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6444 | } |
| 6445 | } |
| 6446 | } |
| 6447 | catch(std::bad_alloc&) |
| 6448 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6449 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6450 | } |
| 6451 | } |
| 6452 | |
| 6453 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 6454 | { |
| 6455 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 6456 | } |
| 6457 | |
| 6458 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 6459 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6460 | 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] | 6461 | face, fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6462 | |
| 6463 | try |
| 6464 | { |
| 6465 | switch (face) |
| 6466 | { |
| 6467 | case GL_FRONT: |
| 6468 | case GL_BACK: |
| 6469 | case GL_FRONT_AND_BACK: |
| 6470 | break; |
| 6471 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6472 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6473 | } |
| 6474 | |
| 6475 | switch (fail) |
| 6476 | { |
| 6477 | case GL_ZERO: |
| 6478 | case GL_KEEP: |
| 6479 | case GL_REPLACE: |
| 6480 | case GL_INCR: |
| 6481 | case GL_DECR: |
| 6482 | case GL_INVERT: |
| 6483 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6484 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6485 | break; |
| 6486 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6487 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6488 | } |
| 6489 | |
| 6490 | switch (zfail) |
| 6491 | { |
| 6492 | case GL_ZERO: |
| 6493 | case GL_KEEP: |
| 6494 | case GL_REPLACE: |
| 6495 | case GL_INCR: |
| 6496 | case GL_DECR: |
| 6497 | case GL_INVERT: |
| 6498 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6499 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6500 | break; |
| 6501 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6502 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6503 | } |
| 6504 | |
| 6505 | switch (zpass) |
| 6506 | { |
| 6507 | case GL_ZERO: |
| 6508 | case GL_KEEP: |
| 6509 | case GL_REPLACE: |
| 6510 | case GL_INCR: |
| 6511 | case GL_DECR: |
| 6512 | case GL_INVERT: |
| 6513 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6514 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6515 | break; |
| 6516 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6517 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6518 | } |
| 6519 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6520 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6521 | |
| 6522 | if (context) |
| 6523 | { |
| 6524 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6525 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6526 | context->setStencilOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6527 | } |
| 6528 | |
| 6529 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6530 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6531 | context->setStencilBackOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6532 | } |
| 6533 | } |
| 6534 | } |
| 6535 | catch(std::bad_alloc&) |
| 6536 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6537 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6538 | } |
| 6539 | } |
| 6540 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6541 | GLboolean __stdcall glTestFenceNV(GLuint fence) |
| 6542 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6543 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6544 | |
| 6545 | try |
| 6546 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6547 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6548 | |
| 6549 | if (context) |
| 6550 | { |
| 6551 | gl::Fence *fenceObject = context->getFence(fence); |
| 6552 | |
| 6553 | if (fenceObject == NULL) |
| 6554 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6555 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6556 | } |
| 6557 | |
| 6558 | return fenceObject->testFence(); |
| 6559 | } |
| 6560 | } |
| 6561 | catch(std::bad_alloc&) |
| 6562 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6563 | gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6564 | } |
| 6565 | |
| 6566 | return GL_TRUE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6567 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6568 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6569 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, |
| 6570 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6571 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6572 | 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] | 6573 | "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] | 6574 | target, level, internalformat, width, height, border, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6575 | |
| 6576 | try |
| 6577 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6578 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6579 | |
| 6580 | if (context) |
| 6581 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6582 | if (context->getClientVersion() < 3 && |
| 6583 | !validateES2TexImageParameters(context, target, level, internalformat, false, false, |
| 6584 | 0, 0, width, height, border, format, type, pixels)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 6585 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6586 | return; |
| 6587 | } |
| 6588 | |
| 6589 | if (context->getClientVersion() >= 3 && |
| 6590 | !validateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 6591 | 0, 0, 0, width, height, 1, border, format, type)) |
| 6592 | { |
| 6593 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 6594 | } |
| 6595 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6596 | switch (target) |
| 6597 | { |
| 6598 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6599 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6600 | gl::Texture2D *texture = context->getTexture2D(); |
| 6601 | texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6602 | } |
| 6603 | break; |
| 6604 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6605 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6606 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 6607 | texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6608 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6609 | break; |
| 6610 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 6611 | { |
| 6612 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6613 | texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6614 | } |
| 6615 | break; |
| 6616 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 6617 | { |
| 6618 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6619 | texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6620 | } |
| 6621 | break; |
| 6622 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 6623 | { |
| 6624 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6625 | texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6626 | } |
| 6627 | break; |
| 6628 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 6629 | { |
| 6630 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6631 | texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6632 | } |
| 6633 | break; |
| 6634 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 6635 | { |
| 6636 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6637 | texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6638 | } |
| 6639 | break; |
| 6640 | default: UNREACHABLE(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6641 | } |
| 6642 | } |
| 6643 | } |
| 6644 | catch(std::bad_alloc&) |
| 6645 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6646 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6647 | } |
| 6648 | } |
| 6649 | |
| 6650 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 6651 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6652 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param); |
| 6653 | |
| 6654 | try |
| 6655 | { |
| 6656 | gl::Context *context = gl::getNonLostContext(); |
| 6657 | |
| 6658 | if (context) |
| 6659 | { |
| 6660 | gl::Texture *texture; |
| 6661 | |
| 6662 | switch (target) |
| 6663 | { |
| 6664 | case GL_TEXTURE_2D: |
| 6665 | texture = context->getTexture2D(); |
| 6666 | break; |
| 6667 | case GL_TEXTURE_CUBE_MAP: |
| 6668 | texture = context->getTextureCubeMap(); |
| 6669 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 6670 | case GL_TEXTURE_3D: |
| 6671 | if (context->getClientVersion() < 3) |
| 6672 | { |
| 6673 | return gl::error(GL_INVALID_ENUM); |
| 6674 | } |
| 6675 | texture = context->getTexture3D(); |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 6676 | case GL_TEXTURE_2D_ARRAY: |
| 6677 | if (context->getClientVersion() < 3) |
| 6678 | { |
| 6679 | return gl::error(GL_INVALID_ENUM); |
| 6680 | } |
| 6681 | texture = context->getTexture2DArray(); |
| 6682 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6683 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6684 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6685 | } |
| 6686 | |
| 6687 | switch (pname) |
| 6688 | { |
| 6689 | case GL_TEXTURE_WRAP_S: |
| 6690 | if (!texture->setWrapS((GLenum)param)) |
| 6691 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6692 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6693 | } |
| 6694 | break; |
| 6695 | case GL_TEXTURE_WRAP_T: |
| 6696 | if (!texture->setWrapT((GLenum)param)) |
| 6697 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6698 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6699 | } |
| 6700 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 6701 | case GL_TEXTURE_WRAP_R: |
| 6702 | if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param)) |
| 6703 | { |
| 6704 | return gl::error(GL_INVALID_ENUM); |
| 6705 | } |
| 6706 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6707 | case GL_TEXTURE_MIN_FILTER: |
| 6708 | if (!texture->setMinFilter((GLenum)param)) |
| 6709 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6710 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6711 | } |
| 6712 | break; |
| 6713 | case GL_TEXTURE_MAG_FILTER: |
| 6714 | if (!texture->setMagFilter((GLenum)param)) |
| 6715 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6716 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6717 | } |
| 6718 | break; |
| 6719 | case GL_TEXTURE_USAGE_ANGLE: |
| 6720 | if (!texture->setUsage((GLenum)param)) |
| 6721 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6722 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6723 | } |
| 6724 | break; |
| 6725 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 6726 | if (!context->supportsTextureFilterAnisotropy()) |
| 6727 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6728 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6729 | } |
| 6730 | if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy())) |
| 6731 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6732 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6733 | } |
| 6734 | break; |
| 6735 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6736 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6737 | } |
| 6738 | } |
| 6739 | } |
| 6740 | catch(std::bad_alloc&) |
| 6741 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6742 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6743 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6744 | } |
| 6745 | |
| 6746 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 6747 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6748 | glTexParameterf(target, pname, (GLfloat)*params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6749 | } |
| 6750 | |
| 6751 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 6752 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6753 | 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] | 6754 | |
| 6755 | try |
| 6756 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6757 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6758 | |
| 6759 | if (context) |
| 6760 | { |
| 6761 | gl::Texture *texture; |
| 6762 | |
| 6763 | switch (target) |
| 6764 | { |
| 6765 | case GL_TEXTURE_2D: |
| 6766 | texture = context->getTexture2D(); |
| 6767 | break; |
| 6768 | case GL_TEXTURE_CUBE_MAP: |
| 6769 | texture = context->getTextureCubeMap(); |
| 6770 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 6771 | case GL_TEXTURE_3D: |
| 6772 | if (context->getClientVersion() < 3) |
| 6773 | { |
| 6774 | return gl::error(GL_INVALID_ENUM); |
| 6775 | } |
| 6776 | texture = context->getTexture3D(); |
| 6777 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 6778 | case GL_TEXTURE_2D_ARRAY: |
| 6779 | if (context->getClientVersion() < 3) |
| 6780 | { |
| 6781 | return gl::error(GL_INVALID_ENUM); |
| 6782 | } |
| 6783 | texture = context->getTexture2DArray(); |
| 6784 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6785 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6786 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6787 | } |
| 6788 | |
| 6789 | switch (pname) |
| 6790 | { |
| 6791 | case GL_TEXTURE_WRAP_S: |
| 6792 | if (!texture->setWrapS((GLenum)param)) |
| 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 | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6795 | } |
| 6796 | break; |
| 6797 | case GL_TEXTURE_WRAP_T: |
| 6798 | if (!texture->setWrapT((GLenum)param)) |
| 6799 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6800 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6801 | } |
| 6802 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 6803 | case GL_TEXTURE_WRAP_R: |
| 6804 | if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param)) |
| 6805 | { |
| 6806 | return gl::error(GL_INVALID_ENUM); |
| 6807 | } |
| 6808 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6809 | case GL_TEXTURE_MIN_FILTER: |
| 6810 | if (!texture->setMinFilter((GLenum)param)) |
| 6811 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6812 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6813 | } |
| 6814 | break; |
| 6815 | case GL_TEXTURE_MAG_FILTER: |
| 6816 | if (!texture->setMagFilter((GLenum)param)) |
| 6817 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6818 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6819 | } |
| 6820 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 6821 | case GL_TEXTURE_USAGE_ANGLE: |
| 6822 | if (!texture->setUsage((GLenum)param)) |
| 6823 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6824 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 6825 | } |
| 6826 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6827 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 6828 | if (!context->supportsTextureFilterAnisotropy()) |
| 6829 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6830 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6831 | } |
| 6832 | if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy())) |
| 6833 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6834 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6835 | } |
| 6836 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6837 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6838 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6839 | } |
| 6840 | } |
| 6841 | } |
| 6842 | catch(std::bad_alloc&) |
| 6843 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6844 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6845 | } |
| 6846 | } |
| 6847 | |
| 6848 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 6849 | { |
| 6850 | glTexParameteri(target, pname, *params); |
| 6851 | } |
| 6852 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6853 | void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 6854 | { |
| 6855 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 6856 | target, levels, internalformat, width, height); |
| 6857 | |
| 6858 | try |
| 6859 | { |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6860 | gl::Context *context = gl::getNonLostContext(); |
| 6861 | |
| 6862 | if (context) |
| 6863 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6864 | if (context->getClientVersion() < 3 && |
| 6865 | !validateES2TexStorageParameters(context, target, levels, internalformat, width, height)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6866 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6867 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6868 | } |
| 6869 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6870 | if (context->getClientVersion() >= 3 && |
| 6871 | !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6872 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6873 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6874 | } |
| 6875 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6876 | switch (target) |
| 6877 | { |
| 6878 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6879 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6880 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 6881 | texture2d->storage(levels, internalformat, width, height); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6882 | } |
| 6883 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6884 | |
| 6885 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 6886 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 6887 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 6888 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 6889 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 6890 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6891 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6892 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 6893 | textureCube->storage(levels, internalformat, width); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6894 | } |
| 6895 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 6896 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6897 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6898 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6899 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6900 | } |
| 6901 | } |
| 6902 | catch(std::bad_alloc&) |
| 6903 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6904 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6905 | } |
| 6906 | } |
| 6907 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6908 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 6909 | GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6910 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6911 | 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] | 6912 | "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] | 6913 | "const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6914 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 6915 | |
| 6916 | try |
| 6917 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6918 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 6919 | |
| 6920 | if (context) |
| 6921 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6922 | if (context->getClientVersion() < 3 && |
| 6923 | !validateES2TexImageParameters(context, target, level, GL_NONE, false, true, |
| 6924 | 0, 0, width, height, 0, format, type, pixels)) |
daniel@transgaming.com | 1d2d3c4 | 2012-05-31 01:14:15 +0000 | [diff] [blame] | 6925 | { |
| 6926 | return; |
| 6927 | } |
| 6928 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6929 | if (context->getClientVersion() >= 3 && |
| 6930 | !validateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 6931 | 0, 0, 0, width, height, 1, 0, format, type)) |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 6932 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6933 | return; |
| 6934 | } |
| 6935 | |
| 6936 | switch (target) |
| 6937 | { |
| 6938 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 6939 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6940 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 6941 | 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] | 6942 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6943 | break; |
| 6944 | |
| 6945 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 6946 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 6947 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 6948 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 6949 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 6950 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 6951 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6952 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 6953 | 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] | 6954 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6955 | break; |
| 6956 | |
| 6957 | default: |
| 6958 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 6959 | } |
| 6960 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6961 | } |
| 6962 | catch(std::bad_alloc&) |
| 6963 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6964 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6965 | } |
| 6966 | } |
| 6967 | |
| 6968 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 6969 | { |
| 6970 | glUniform1fv(location, 1, &x); |
| 6971 | } |
| 6972 | |
| 6973 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 6974 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6975 | 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] | 6976 | |
| 6977 | try |
| 6978 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6979 | if (count < 0) |
| 6980 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6981 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6982 | } |
| 6983 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 6984 | if (location == -1) |
| 6985 | { |
| 6986 | return; |
| 6987 | } |
| 6988 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6989 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6990 | |
| 6991 | if (context) |
| 6992 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 6993 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6994 | if (!programBinary) |
| 6995 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6996 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6997 | } |
| 6998 | |
| 6999 | if (!programBinary->setUniform1fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7000 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7001 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7002 | } |
| 7003 | } |
| 7004 | } |
| 7005 | catch(std::bad_alloc&) |
| 7006 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7007 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7008 | } |
| 7009 | } |
| 7010 | |
| 7011 | void __stdcall glUniform1i(GLint location, GLint x) |
| 7012 | { |
| 7013 | glUniform1iv(location, 1, &x); |
| 7014 | } |
| 7015 | |
| 7016 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 7017 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7018 | 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] | 7019 | |
| 7020 | try |
| 7021 | { |
| 7022 | if (count < 0) |
| 7023 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7024 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7025 | } |
| 7026 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7027 | if (location == -1) |
| 7028 | { |
| 7029 | return; |
| 7030 | } |
| 7031 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7032 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7033 | |
| 7034 | if (context) |
| 7035 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7036 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7037 | if (!programBinary) |
| 7038 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7039 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7040 | } |
| 7041 | |
| 7042 | if (!programBinary->setUniform1iv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7043 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7044 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7045 | } |
| 7046 | } |
| 7047 | } |
| 7048 | catch(std::bad_alloc&) |
| 7049 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7050 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7051 | } |
| 7052 | } |
| 7053 | |
| 7054 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 7055 | { |
| 7056 | GLfloat xy[2] = {x, y}; |
| 7057 | |
| 7058 | glUniform2fv(location, 1, (GLfloat*)&xy); |
| 7059 | } |
| 7060 | |
| 7061 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 7062 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7063 | 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] | 7064 | |
| 7065 | try |
| 7066 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7067 | if (count < 0) |
| 7068 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7069 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7070 | } |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7071 | |
| 7072 | if (location == -1) |
| 7073 | { |
| 7074 | return; |
| 7075 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7076 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7077 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7078 | |
| 7079 | if (context) |
| 7080 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7081 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7082 | if (!programBinary) |
| 7083 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7084 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7085 | } |
| 7086 | |
| 7087 | if (!programBinary->setUniform2fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7088 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7089 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7090 | } |
| 7091 | } |
| 7092 | } |
| 7093 | catch(std::bad_alloc&) |
| 7094 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7095 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7096 | } |
| 7097 | } |
| 7098 | |
| 7099 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 7100 | { |
| 7101 | GLint xy[4] = {x, y}; |
| 7102 | |
| 7103 | glUniform2iv(location, 1, (GLint*)&xy); |
| 7104 | } |
| 7105 | |
| 7106 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 7107 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7108 | 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] | 7109 | |
| 7110 | try |
| 7111 | { |
| 7112 | if (count < 0) |
| 7113 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7114 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7115 | } |
| 7116 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7117 | if (location == -1) |
| 7118 | { |
| 7119 | return; |
| 7120 | } |
| 7121 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7122 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7123 | |
| 7124 | if (context) |
| 7125 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7126 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7127 | if (!programBinary) |
| 7128 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7129 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7130 | } |
| 7131 | |
| 7132 | if (!programBinary->setUniform2iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7133 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7134 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7135 | } |
| 7136 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7137 | } |
| 7138 | catch(std::bad_alloc&) |
| 7139 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7140 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7141 | } |
| 7142 | } |
| 7143 | |
| 7144 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 7145 | { |
| 7146 | GLfloat xyz[3] = {x, y, z}; |
| 7147 | |
| 7148 | glUniform3fv(location, 1, (GLfloat*)&xyz); |
| 7149 | } |
| 7150 | |
| 7151 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 7152 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7153 | 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] | 7154 | |
| 7155 | try |
| 7156 | { |
| 7157 | if (count < 0) |
| 7158 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7159 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7160 | } |
| 7161 | |
| 7162 | if (location == -1) |
| 7163 | { |
| 7164 | return; |
| 7165 | } |
| 7166 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7167 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7168 | |
| 7169 | if (context) |
| 7170 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7171 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7172 | if (!programBinary) |
| 7173 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7174 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7175 | } |
| 7176 | |
| 7177 | if (!programBinary->setUniform3fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7178 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7179 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7180 | } |
| 7181 | } |
| 7182 | } |
| 7183 | catch(std::bad_alloc&) |
| 7184 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7185 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7186 | } |
| 7187 | } |
| 7188 | |
| 7189 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 7190 | { |
| 7191 | GLint xyz[3] = {x, y, z}; |
| 7192 | |
| 7193 | glUniform3iv(location, 1, (GLint*)&xyz); |
| 7194 | } |
| 7195 | |
| 7196 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 7197 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7198 | 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] | 7199 | |
| 7200 | try |
| 7201 | { |
| 7202 | if (count < 0) |
| 7203 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7204 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7205 | } |
| 7206 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7207 | if (location == -1) |
| 7208 | { |
| 7209 | return; |
| 7210 | } |
| 7211 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7212 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7213 | |
| 7214 | if (context) |
| 7215 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7216 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7217 | if (!programBinary) |
| 7218 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7219 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7220 | } |
| 7221 | |
| 7222 | if (!programBinary->setUniform3iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7223 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7224 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7225 | } |
| 7226 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7227 | } |
| 7228 | catch(std::bad_alloc&) |
| 7229 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7230 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7231 | } |
| 7232 | } |
| 7233 | |
| 7234 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7235 | { |
| 7236 | GLfloat xyzw[4] = {x, y, z, w}; |
| 7237 | |
| 7238 | glUniform4fv(location, 1, (GLfloat*)&xyzw); |
| 7239 | } |
| 7240 | |
| 7241 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 7242 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7243 | 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] | 7244 | |
| 7245 | try |
| 7246 | { |
| 7247 | if (count < 0) |
| 7248 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7249 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7250 | } |
| 7251 | |
| 7252 | if (location == -1) |
| 7253 | { |
| 7254 | return; |
| 7255 | } |
| 7256 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7257 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7258 | |
| 7259 | if (context) |
| 7260 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7261 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7262 | if (!programBinary) |
| 7263 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7264 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7265 | } |
| 7266 | |
| 7267 | if (!programBinary->setUniform4fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7268 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7269 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7270 | } |
| 7271 | } |
| 7272 | } |
| 7273 | catch(std::bad_alloc&) |
| 7274 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7275 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7276 | } |
| 7277 | } |
| 7278 | |
| 7279 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 7280 | { |
| 7281 | GLint xyzw[4] = {x, y, z, w}; |
| 7282 | |
| 7283 | glUniform4iv(location, 1, (GLint*)&xyzw); |
| 7284 | } |
| 7285 | |
| 7286 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 7287 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7288 | 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] | 7289 | |
| 7290 | try |
| 7291 | { |
| 7292 | if (count < 0) |
| 7293 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7294 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7295 | } |
| 7296 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7297 | if (location == -1) |
| 7298 | { |
| 7299 | return; |
| 7300 | } |
| 7301 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7302 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7303 | |
| 7304 | if (context) |
| 7305 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7306 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7307 | if (!programBinary) |
| 7308 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7309 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7310 | } |
| 7311 | |
| 7312 | if (!programBinary->setUniform4iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7313 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7314 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7315 | } |
| 7316 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7317 | } |
| 7318 | catch(std::bad_alloc&) |
| 7319 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7320 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7321 | } |
| 7322 | } |
| 7323 | |
| 7324 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7325 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7326 | 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] | 7327 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7328 | |
| 7329 | try |
| 7330 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7331 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7332 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7333 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7334 | } |
| 7335 | |
| 7336 | if (location == -1) |
| 7337 | { |
| 7338 | return; |
| 7339 | } |
| 7340 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7341 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7342 | |
| 7343 | if (context) |
| 7344 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7345 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7346 | { |
| 7347 | return gl::error(GL_INVALID_VALUE); |
| 7348 | } |
| 7349 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7350 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7351 | if (!programBinary) |
| 7352 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7353 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7354 | } |
| 7355 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7356 | if (!programBinary->setUniformMatrix2fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7357 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7358 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7359 | } |
| 7360 | } |
| 7361 | } |
| 7362 | catch(std::bad_alloc&) |
| 7363 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7364 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7365 | } |
| 7366 | } |
| 7367 | |
| 7368 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7369 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7370 | 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] | 7371 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7372 | |
| 7373 | try |
| 7374 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7375 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7376 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7377 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7378 | } |
| 7379 | |
| 7380 | if (location == -1) |
| 7381 | { |
| 7382 | return; |
| 7383 | } |
| 7384 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7385 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7386 | |
| 7387 | if (context) |
| 7388 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7389 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7390 | { |
| 7391 | return gl::error(GL_INVALID_VALUE); |
| 7392 | } |
| 7393 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7394 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7395 | if (!programBinary) |
| 7396 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7397 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7398 | } |
| 7399 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7400 | if (!programBinary->setUniformMatrix3fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7401 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7402 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7403 | } |
| 7404 | } |
| 7405 | } |
| 7406 | catch(std::bad_alloc&) |
| 7407 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7408 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7409 | } |
| 7410 | } |
| 7411 | |
| 7412 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7413 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7414 | 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] | 7415 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7416 | |
| 7417 | try |
| 7418 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7419 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7420 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7421 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7422 | } |
| 7423 | |
| 7424 | if (location == -1) |
| 7425 | { |
| 7426 | return; |
| 7427 | } |
| 7428 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7429 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7430 | |
| 7431 | if (context) |
| 7432 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7433 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7434 | { |
| 7435 | return gl::error(GL_INVALID_VALUE); |
| 7436 | } |
| 7437 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7438 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7439 | if (!programBinary) |
| 7440 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7441 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7442 | } |
| 7443 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7444 | if (!programBinary->setUniformMatrix4fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7445 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7446 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7447 | } |
| 7448 | } |
| 7449 | } |
| 7450 | catch(std::bad_alloc&) |
| 7451 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7452 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7453 | } |
| 7454 | } |
| 7455 | |
| 7456 | void __stdcall glUseProgram(GLuint program) |
| 7457 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7458 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7459 | |
| 7460 | try |
| 7461 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7462 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7463 | |
| 7464 | if (context) |
| 7465 | { |
| 7466 | gl::Program *programObject = context->getProgram(program); |
| 7467 | |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7468 | if (!programObject && program != 0) |
| 7469 | { |
| 7470 | if (context->getShader(program)) |
| 7471 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7472 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7473 | } |
| 7474 | else |
| 7475 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7476 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7477 | } |
| 7478 | } |
| 7479 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 7480 | if (program != 0 && !programObject->isLinked()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7481 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7482 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7483 | } |
| 7484 | |
| 7485 | context->useProgram(program); |
| 7486 | } |
| 7487 | } |
| 7488 | catch(std::bad_alloc&) |
| 7489 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7490 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7491 | } |
| 7492 | } |
| 7493 | |
| 7494 | void __stdcall glValidateProgram(GLuint program) |
| 7495 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7496 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7497 | |
| 7498 | try |
| 7499 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7500 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7501 | |
| 7502 | if (context) |
| 7503 | { |
| 7504 | gl::Program *programObject = context->getProgram(program); |
| 7505 | |
| 7506 | if (!programObject) |
| 7507 | { |
| 7508 | if (context->getShader(program)) |
| 7509 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7510 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7511 | } |
| 7512 | else |
| 7513 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7514 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7515 | } |
| 7516 | } |
| 7517 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 7518 | programObject->validate(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7519 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7520 | } |
| 7521 | catch(std::bad_alloc&) |
| 7522 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7523 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7524 | } |
| 7525 | } |
| 7526 | |
| 7527 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 7528 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7529 | EVENT("(GLuint index = %d, GLfloat x = %f)", index, x); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7530 | |
| 7531 | try |
| 7532 | { |
| 7533 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7534 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7535 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7536 | } |
| 7537 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7538 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7539 | |
| 7540 | if (context) |
| 7541 | { |
| 7542 | GLfloat vals[4] = { x, 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7543 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7544 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7545 | } |
| 7546 | catch(std::bad_alloc&) |
| 7547 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7548 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7549 | } |
| 7550 | } |
| 7551 | |
| 7552 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 7553 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7554 | 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] | 7555 | |
| 7556 | try |
| 7557 | { |
| 7558 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7559 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7560 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7561 | } |
| 7562 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7563 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7564 | |
| 7565 | if (context) |
| 7566 | { |
| 7567 | GLfloat vals[4] = { values[0], 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7568 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7569 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7570 | } |
| 7571 | catch(std::bad_alloc&) |
| 7572 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7573 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7574 | } |
| 7575 | } |
| 7576 | |
| 7577 | void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 7578 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7579 | 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] | 7580 | |
| 7581 | try |
| 7582 | { |
| 7583 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7584 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7585 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7586 | } |
| 7587 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7588 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7589 | |
| 7590 | if (context) |
| 7591 | { |
| 7592 | GLfloat vals[4] = { x, y, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7593 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7594 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7595 | } |
| 7596 | catch(std::bad_alloc&) |
| 7597 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7598 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7599 | } |
| 7600 | } |
| 7601 | |
| 7602 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 7603 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7604 | 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] | 7605 | |
| 7606 | try |
| 7607 | { |
| 7608 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7609 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7610 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7611 | } |
| 7612 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7613 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7614 | |
| 7615 | if (context) |
| 7616 | { |
| 7617 | 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] | 7618 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7619 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7620 | } |
| 7621 | catch(std::bad_alloc&) |
| 7622 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7623 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7624 | } |
| 7625 | } |
| 7626 | |
| 7627 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 7628 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7629 | 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] | 7630 | |
| 7631 | try |
| 7632 | { |
| 7633 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7634 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7635 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7636 | } |
| 7637 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7638 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7639 | |
| 7640 | if (context) |
| 7641 | { |
| 7642 | GLfloat vals[4] = { x, y, z, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7643 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7644 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7645 | } |
| 7646 | catch(std::bad_alloc&) |
| 7647 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7648 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7649 | } |
| 7650 | } |
| 7651 | |
| 7652 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 7653 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7654 | 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] | 7655 | |
| 7656 | try |
| 7657 | { |
| 7658 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7659 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7660 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7661 | } |
| 7662 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7663 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7664 | |
| 7665 | if (context) |
| 7666 | { |
| 7667 | 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] | 7668 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7669 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7670 | } |
| 7671 | catch(std::bad_alloc&) |
| 7672 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7673 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7674 | } |
| 7675 | } |
| 7676 | |
| 7677 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7678 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7679 | 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] | 7680 | |
| 7681 | try |
| 7682 | { |
| 7683 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7684 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7685 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7686 | } |
| 7687 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7688 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7689 | |
| 7690 | if (context) |
| 7691 | { |
| 7692 | GLfloat vals[4] = { x, y, z, w }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7693 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7694 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7695 | } |
| 7696 | catch(std::bad_alloc&) |
| 7697 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7698 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7699 | } |
| 7700 | } |
| 7701 | |
| 7702 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 7703 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7704 | 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] | 7705 | |
| 7706 | try |
| 7707 | { |
| 7708 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7709 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7710 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7711 | } |
| 7712 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7713 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7714 | |
| 7715 | if (context) |
| 7716 | { |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7717 | context->setVertexAttribf(index, values); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7718 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7719 | } |
| 7720 | catch(std::bad_alloc&) |
| 7721 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7722 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7723 | } |
| 7724 | } |
| 7725 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 7726 | void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
| 7727 | { |
| 7728 | EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor); |
| 7729 | |
| 7730 | try |
| 7731 | { |
| 7732 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7733 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7734 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 7735 | } |
| 7736 | |
| 7737 | gl::Context *context = gl::getNonLostContext(); |
| 7738 | |
| 7739 | if (context) |
| 7740 | { |
| 7741 | context->setVertexAttribDivisor(index, divisor); |
| 7742 | } |
| 7743 | } |
| 7744 | catch(std::bad_alloc&) |
| 7745 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7746 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 7747 | } |
| 7748 | } |
| 7749 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7750 | 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] | 7751 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7752 | 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] | 7753 | "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] | 7754 | index, size, type, normalized, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7755 | |
| 7756 | try |
| 7757 | { |
| 7758 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7759 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7760 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7761 | } |
| 7762 | |
| 7763 | if (size < 1 || size > 4) |
| 7764 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7765 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7766 | } |
| 7767 | |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 7768 | gl::Context *context = gl::getNonLostContext(); |
| 7769 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7770 | switch (type) |
| 7771 | { |
| 7772 | case GL_BYTE: |
| 7773 | case GL_UNSIGNED_BYTE: |
| 7774 | case GL_SHORT: |
| 7775 | case GL_UNSIGNED_SHORT: |
| 7776 | case GL_FIXED: |
| 7777 | case GL_FLOAT: |
| 7778 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 7779 | case GL_HALF_FLOAT: |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7780 | case GL_INT: |
| 7781 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 7782 | case GL_INT_2_10_10_10_REV: |
| 7783 | 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] | 7784 | if (context && context->getClientVersion() < 3) |
| 7785 | { |
| 7786 | return gl::error(GL_INVALID_ENUM); |
| 7787 | } |
| 7788 | else |
| 7789 | { |
| 7790 | break; |
| 7791 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7792 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7793 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7794 | } |
| 7795 | |
| 7796 | if (stride < 0) |
| 7797 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7798 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7799 | } |
| 7800 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 7801 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 7802 | { |
| 7803 | return gl::error(GL_INVALID_OPERATION); |
| 7804 | } |
| 7805 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7806 | if (context) |
| 7807 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8de4e6a | 2013-04-13 03:37:44 +0000 | [diff] [blame] | 7808 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, |
| 7809 | normalized == GL_TRUE, false, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7810 | } |
| 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 | |
| 7818 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 7819 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7820 | 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] | 7821 | |
| 7822 | try |
| 7823 | { |
| 7824 | if (width < 0 || height < 0) |
| 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 | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7827 | } |
| 7828 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7829 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7830 | |
| 7831 | if (context) |
| 7832 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7833 | context->setViewportParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 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 | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7839 | } |
| 7840 | } |
| 7841 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7842 | // OpenGL ES 3.0 functions |
| 7843 | |
| 7844 | void __stdcall glReadBuffer(GLenum mode) |
| 7845 | { |
| 7846 | EVENT("(GLenum mode = 0x%X)", mode); |
| 7847 | |
| 7848 | try |
| 7849 | { |
| 7850 | gl::Context *context = gl::getNonLostContext(); |
| 7851 | |
| 7852 | if (context) |
| 7853 | { |
| 7854 | if (context->getClientVersion() < 3) |
| 7855 | { |
| 7856 | return gl::error(GL_INVALID_OPERATION); |
| 7857 | } |
| 7858 | } |
| 7859 | |
| 7860 | UNIMPLEMENTED(); |
| 7861 | } |
| 7862 | catch(std::bad_alloc&) |
| 7863 | { |
| 7864 | return gl::error(GL_OUT_OF_MEMORY); |
| 7865 | } |
| 7866 | } |
| 7867 | |
| 7868 | void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) |
| 7869 | { |
| 7870 | EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, " |
| 7871 | "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices); |
| 7872 | |
| 7873 | try |
| 7874 | { |
| 7875 | gl::Context *context = gl::getNonLostContext(); |
| 7876 | |
| 7877 | if (context) |
| 7878 | { |
| 7879 | if (context->getClientVersion() < 3) |
| 7880 | { |
| 7881 | return gl::error(GL_INVALID_OPERATION); |
| 7882 | } |
| 7883 | } |
| 7884 | |
| 7885 | UNIMPLEMENTED(); |
| 7886 | } |
| 7887 | catch(std::bad_alloc&) |
| 7888 | { |
| 7889 | return gl::error(GL_OUT_OF_MEMORY); |
| 7890 | } |
| 7891 | } |
| 7892 | |
| 7893 | void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
| 7894 | { |
| 7895 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 7896 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " |
| 7897 | "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 7898 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 7899 | |
| 7900 | try |
| 7901 | { |
| 7902 | gl::Context *context = gl::getNonLostContext(); |
| 7903 | |
| 7904 | if (context) |
| 7905 | { |
| 7906 | if (context->getClientVersion() < 3) |
| 7907 | { |
| 7908 | return gl::error(GL_INVALID_OPERATION); |
| 7909 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7910 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 7911 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 7912 | if (!validateES3TexImageParameters(context, target, level, internalformat, false, false, |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 7913 | 0, 0, 0, width, height, depth, border, format, type)) |
| 7914 | { |
| 7915 | return; |
| 7916 | } |
| 7917 | |
| 7918 | switch(target) |
| 7919 | { |
| 7920 | case GL_TEXTURE_3D: |
| 7921 | { |
| 7922 | gl::Texture3D *texture = context->getTexture3D(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 7923 | 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] | 7924 | } |
| 7925 | break; |
| 7926 | |
| 7927 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 7928 | { |
| 7929 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 7930 | 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] | 7931 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 7932 | break; |
| 7933 | |
| 7934 | default: |
| 7935 | return gl::error(GL_INVALID_ENUM); |
| 7936 | } |
| 7937 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7938 | } |
| 7939 | catch(std::bad_alloc&) |
| 7940 | { |
| 7941 | return gl::error(GL_OUT_OF_MEMORY); |
| 7942 | } |
| 7943 | } |
| 7944 | |
| 7945 | 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) |
| 7946 | { |
| 7947 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 7948 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 7949 | "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 7950 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); |
| 7951 | |
| 7952 | try |
| 7953 | { |
| 7954 | gl::Context *context = gl::getNonLostContext(); |
| 7955 | |
| 7956 | if (context) |
| 7957 | { |
| 7958 | if (context->getClientVersion() < 3) |
| 7959 | { |
| 7960 | return gl::error(GL_INVALID_OPERATION); |
| 7961 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7962 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 7963 | if (!pixels) |
| 7964 | { |
| 7965 | return gl::error(GL_INVALID_VALUE); |
| 7966 | } |
| 7967 | |
| 7968 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 7969 | 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] | 7970 | xoffset, yoffset, zoffset, width, height, depth, 0, |
| 7971 | format, type)) |
| 7972 | { |
| 7973 | return; |
| 7974 | } |
| 7975 | |
| 7976 | switch(target) |
| 7977 | { |
| 7978 | case GL_TEXTURE_3D: |
| 7979 | { |
| 7980 | gl::Texture3D *texture = context->getTexture3D(); |
| 7981 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 7982 | } |
| 7983 | break; |
| 7984 | |
| 7985 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 7986 | { |
| 7987 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 7988 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 7989 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 7990 | break; |
| 7991 | |
| 7992 | default: |
| 7993 | return gl::error(GL_INVALID_ENUM); |
| 7994 | } |
| 7995 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7996 | } |
| 7997 | catch(std::bad_alloc&) |
| 7998 | { |
| 7999 | return gl::error(GL_OUT_OF_MEMORY); |
| 8000 | } |
| 8001 | } |
| 8002 | |
| 8003 | void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 8004 | { |
| 8005 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8006 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 8007 | target, level, xoffset, yoffset, zoffset, x, y, width, height); |
| 8008 | |
| 8009 | try |
| 8010 | { |
| 8011 | gl::Context *context = gl::getNonLostContext(); |
| 8012 | |
| 8013 | if (context) |
| 8014 | { |
| 8015 | if (context->getClientVersion() < 3) |
| 8016 | { |
| 8017 | return gl::error(GL_INVALID_OPERATION); |
| 8018 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8019 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8020 | if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset, |
| 8021 | x, y, width, height, 0)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8022 | { |
| 8023 | return; |
| 8024 | } |
| 8025 | |
| 8026 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 8027 | gl::Texture *texture = NULL; |
| 8028 | switch (target) |
| 8029 | { |
| 8030 | case GL_TEXTURE_3D: |
| 8031 | texture = context->getTexture3D(); |
| 8032 | break; |
| 8033 | |
| 8034 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8035 | texture = context->getTexture2DArray(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8036 | break; |
| 8037 | |
| 8038 | default: |
| 8039 | return gl::error(GL_INVALID_ENUM); |
| 8040 | } |
| 8041 | |
| 8042 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer); |
| 8043 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8044 | } |
| 8045 | catch(std::bad_alloc&) |
| 8046 | { |
| 8047 | return gl::error(GL_OUT_OF_MEMORY); |
| 8048 | } |
| 8049 | } |
| 8050 | |
| 8051 | void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) |
| 8052 | { |
| 8053 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8054 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, " |
| 8055 | "const GLvoid* data = 0x%0.8p)", |
| 8056 | target, level, internalformat, width, height, depth, border, imageSize, data); |
| 8057 | |
| 8058 | try |
| 8059 | { |
| 8060 | gl::Context *context = gl::getNonLostContext(); |
| 8061 | |
| 8062 | if (context) |
| 8063 | { |
| 8064 | if (context->getClientVersion() < 3) |
| 8065 | { |
| 8066 | return gl::error(GL_INVALID_OPERATION); |
| 8067 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8068 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8069 | 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] | 8070 | { |
| 8071 | return gl::error(GL_INVALID_VALUE); |
| 8072 | } |
| 8073 | |
| 8074 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8075 | if (!validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 8076 | 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] | 8077 | { |
| 8078 | return; |
| 8079 | } |
| 8080 | |
| 8081 | switch(target) |
| 8082 | { |
| 8083 | case GL_TEXTURE_3D: |
| 8084 | { |
| 8085 | gl::Texture3D *texture = context->getTexture3D(); |
| 8086 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8087 | } |
| 8088 | break; |
| 8089 | |
| 8090 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8091 | { |
| 8092 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8093 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8094 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8095 | break; |
| 8096 | |
| 8097 | default: |
| 8098 | return gl::error(GL_INVALID_ENUM); |
| 8099 | } |
| 8100 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8101 | } |
| 8102 | catch(std::bad_alloc&) |
| 8103 | { |
| 8104 | return gl::error(GL_OUT_OF_MEMORY); |
| 8105 | } |
| 8106 | } |
| 8107 | |
| 8108 | 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) |
| 8109 | { |
| 8110 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8111 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8112 | "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 8113 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); |
| 8114 | |
| 8115 | try |
| 8116 | { |
| 8117 | gl::Context *context = gl::getNonLostContext(); |
| 8118 | |
| 8119 | if (context) |
| 8120 | { |
| 8121 | if (context->getClientVersion() < 3) |
| 8122 | { |
| 8123 | return gl::error(GL_INVALID_OPERATION); |
| 8124 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8125 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8126 | 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] | 8127 | { |
| 8128 | return gl::error(GL_INVALID_VALUE); |
| 8129 | } |
| 8130 | |
| 8131 | if (!data) |
| 8132 | { |
| 8133 | return gl::error(GL_INVALID_VALUE); |
| 8134 | } |
| 8135 | |
| 8136 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8137 | if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 8138 | 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] | 8139 | { |
| 8140 | return; |
| 8141 | } |
| 8142 | |
| 8143 | switch(target) |
| 8144 | { |
| 8145 | case GL_TEXTURE_3D: |
| 8146 | { |
| 8147 | gl::Texture3D *texture = context->getTexture3D(); |
| 8148 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8149 | format, imageSize, data); |
| 8150 | } |
| 8151 | break; |
| 8152 | |
| 8153 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8154 | { |
| 8155 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8156 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8157 | format, imageSize, data); |
| 8158 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8159 | break; |
| 8160 | |
| 8161 | default: |
| 8162 | return gl::error(GL_INVALID_ENUM); |
| 8163 | } |
| 8164 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8165 | } |
| 8166 | catch(std::bad_alloc&) |
| 8167 | { |
| 8168 | return gl::error(GL_OUT_OF_MEMORY); |
| 8169 | } |
| 8170 | } |
| 8171 | |
| 8172 | void __stdcall glGenQueries(GLsizei n, GLuint* ids) |
| 8173 | { |
| 8174 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8175 | |
| 8176 | try |
| 8177 | { |
| 8178 | gl::Context *context = gl::getNonLostContext(); |
| 8179 | |
| 8180 | if (context) |
| 8181 | { |
| 8182 | if (context->getClientVersion() < 3) |
| 8183 | { |
| 8184 | return gl::error(GL_INVALID_OPERATION); |
| 8185 | } |
| 8186 | } |
| 8187 | |
| 8188 | UNIMPLEMENTED(); |
| 8189 | } |
| 8190 | catch(std::bad_alloc&) |
| 8191 | { |
| 8192 | return gl::error(GL_OUT_OF_MEMORY); |
| 8193 | } |
| 8194 | } |
| 8195 | |
| 8196 | void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids) |
| 8197 | { |
| 8198 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8199 | |
| 8200 | try |
| 8201 | { |
| 8202 | gl::Context *context = gl::getNonLostContext(); |
| 8203 | |
| 8204 | if (context) |
| 8205 | { |
| 8206 | if (context->getClientVersion() < 3) |
| 8207 | { |
| 8208 | return gl::error(GL_INVALID_OPERATION); |
| 8209 | } |
| 8210 | } |
| 8211 | |
| 8212 | UNIMPLEMENTED(); |
| 8213 | } |
| 8214 | catch(std::bad_alloc&) |
| 8215 | { |
| 8216 | return gl::error(GL_OUT_OF_MEMORY); |
| 8217 | } |
| 8218 | } |
| 8219 | |
| 8220 | GLboolean __stdcall glIsQuery(GLuint id) |
| 8221 | { |
| 8222 | EVENT("(GLuint id = %u)", id); |
| 8223 | |
| 8224 | try |
| 8225 | { |
| 8226 | gl::Context *context = gl::getNonLostContext(); |
| 8227 | |
| 8228 | if (context) |
| 8229 | { |
| 8230 | if (context->getClientVersion() < 3) |
| 8231 | { |
| 8232 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8233 | } |
| 8234 | } |
| 8235 | |
| 8236 | UNIMPLEMENTED(); |
| 8237 | } |
| 8238 | catch(std::bad_alloc&) |
| 8239 | { |
| 8240 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8241 | } |
| 8242 | |
| 8243 | return GL_FALSE; |
| 8244 | } |
| 8245 | |
| 8246 | void __stdcall glBeginQuery(GLenum target, GLuint id) |
| 8247 | { |
| 8248 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 8249 | |
| 8250 | try |
| 8251 | { |
| 8252 | gl::Context *context = gl::getNonLostContext(); |
| 8253 | |
| 8254 | if (context) |
| 8255 | { |
| 8256 | if (context->getClientVersion() < 3) |
| 8257 | { |
| 8258 | return gl::error(GL_INVALID_OPERATION); |
| 8259 | } |
| 8260 | } |
| 8261 | |
| 8262 | UNIMPLEMENTED(); |
| 8263 | } |
| 8264 | catch(std::bad_alloc&) |
| 8265 | { |
| 8266 | return gl::error(GL_OUT_OF_MEMORY); |
| 8267 | } |
| 8268 | } |
| 8269 | |
| 8270 | void __stdcall glEndQuery(GLenum target) |
| 8271 | { |
| 8272 | EVENT("(GLenum target = 0x%X)", target); |
| 8273 | |
| 8274 | try |
| 8275 | { |
| 8276 | gl::Context *context = gl::getNonLostContext(); |
| 8277 | |
| 8278 | if (context) |
| 8279 | { |
| 8280 | if (context->getClientVersion() < 3) |
| 8281 | { |
| 8282 | return gl::error(GL_INVALID_OPERATION); |
| 8283 | } |
| 8284 | } |
| 8285 | |
| 8286 | UNIMPLEMENTED(); |
| 8287 | } |
| 8288 | catch(std::bad_alloc&) |
| 8289 | { |
| 8290 | return gl::error(GL_OUT_OF_MEMORY); |
| 8291 | } |
| 8292 | } |
| 8293 | |
| 8294 | void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params) |
| 8295 | { |
| 8296 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
| 8297 | |
| 8298 | try |
| 8299 | { |
| 8300 | gl::Context *context = gl::getNonLostContext(); |
| 8301 | |
| 8302 | if (context) |
| 8303 | { |
| 8304 | if (context->getClientVersion() < 3) |
| 8305 | { |
| 8306 | return gl::error(GL_INVALID_OPERATION); |
| 8307 | } |
| 8308 | } |
| 8309 | |
| 8310 | UNIMPLEMENTED(); |
| 8311 | } |
| 8312 | catch(std::bad_alloc&) |
| 8313 | { |
| 8314 | return gl::error(GL_OUT_OF_MEMORY); |
| 8315 | } |
| 8316 | } |
| 8317 | |
| 8318 | void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) |
| 8319 | { |
| 8320 | EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params); |
| 8321 | |
| 8322 | try |
| 8323 | { |
| 8324 | gl::Context *context = gl::getNonLostContext(); |
| 8325 | |
| 8326 | if (context) |
| 8327 | { |
| 8328 | if (context->getClientVersion() < 3) |
| 8329 | { |
| 8330 | return gl::error(GL_INVALID_OPERATION); |
| 8331 | } |
| 8332 | } |
| 8333 | |
| 8334 | UNIMPLEMENTED(); |
| 8335 | } |
| 8336 | catch(std::bad_alloc&) |
| 8337 | { |
| 8338 | return gl::error(GL_OUT_OF_MEMORY); |
| 8339 | } |
| 8340 | } |
| 8341 | |
| 8342 | GLboolean __stdcall glUnmapBuffer(GLenum target) |
| 8343 | { |
| 8344 | EVENT("(GLenum target = 0x%X)", target); |
| 8345 | |
| 8346 | try |
| 8347 | { |
| 8348 | gl::Context *context = gl::getNonLostContext(); |
| 8349 | |
| 8350 | if (context) |
| 8351 | { |
| 8352 | if (context->getClientVersion() < 3) |
| 8353 | { |
| 8354 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8355 | } |
| 8356 | } |
| 8357 | |
| 8358 | UNIMPLEMENTED(); |
| 8359 | } |
| 8360 | catch(std::bad_alloc&) |
| 8361 | { |
| 8362 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8363 | } |
| 8364 | |
| 8365 | return GL_FALSE; |
| 8366 | } |
| 8367 | |
| 8368 | void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) |
| 8369 | { |
| 8370 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 8371 | |
| 8372 | try |
| 8373 | { |
| 8374 | gl::Context *context = gl::getNonLostContext(); |
| 8375 | |
| 8376 | if (context) |
| 8377 | { |
| 8378 | if (context->getClientVersion() < 3) |
| 8379 | { |
| 8380 | return gl::error(GL_INVALID_OPERATION); |
| 8381 | } |
| 8382 | } |
| 8383 | |
| 8384 | UNIMPLEMENTED(); |
| 8385 | } |
| 8386 | catch(std::bad_alloc&) |
| 8387 | { |
| 8388 | return gl::error(GL_OUT_OF_MEMORY); |
| 8389 | } |
| 8390 | } |
| 8391 | |
| 8392 | void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs) |
| 8393 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8394 | try |
| 8395 | { |
| 8396 | gl::Context *context = gl::getNonLostContext(); |
| 8397 | |
| 8398 | if (context) |
| 8399 | { |
| 8400 | if (context->getClientVersion() < 3) |
| 8401 | { |
| 8402 | return gl::error(GL_INVALID_OPERATION); |
| 8403 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8404 | |
shannon.woods%transgaming.com@gtempaccount.com | 7948c5f | 2013-04-13 03:38:58 +0000 | [diff] [blame] | 8405 | glDrawBuffersEXT(n, bufs); |
| 8406 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8407 | } |
| 8408 | catch(std::bad_alloc&) |
| 8409 | { |
| 8410 | return gl::error(GL_OUT_OF_MEMORY); |
| 8411 | } |
| 8412 | } |
| 8413 | |
| 8414 | void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8415 | { |
| 8416 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8417 | location, count, transpose, value); |
| 8418 | |
| 8419 | try |
| 8420 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8421 | if (count < 0) |
| 8422 | { |
| 8423 | return gl::error(GL_INVALID_VALUE); |
| 8424 | } |
| 8425 | |
| 8426 | if (location == -1) |
| 8427 | { |
| 8428 | return; |
| 8429 | } |
| 8430 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8431 | gl::Context *context = gl::getNonLostContext(); |
| 8432 | |
| 8433 | if (context) |
| 8434 | { |
| 8435 | if (context->getClientVersion() < 3) |
| 8436 | { |
| 8437 | return gl::error(GL_INVALID_OPERATION); |
| 8438 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8439 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8440 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8441 | if (!programBinary) |
| 8442 | { |
| 8443 | return gl::error(GL_INVALID_OPERATION); |
| 8444 | } |
| 8445 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8446 | if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8447 | { |
| 8448 | return gl::error(GL_INVALID_OPERATION); |
| 8449 | } |
| 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); |
| 8455 | } |
| 8456 | } |
| 8457 | |
| 8458 | void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8459 | { |
| 8460 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8461 | location, count, transpose, value); |
| 8462 | |
| 8463 | try |
| 8464 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8465 | if (count < 0) |
| 8466 | { |
| 8467 | return gl::error(GL_INVALID_VALUE); |
| 8468 | } |
| 8469 | |
| 8470 | if (location == -1) |
| 8471 | { |
| 8472 | return; |
| 8473 | } |
| 8474 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8475 | gl::Context *context = gl::getNonLostContext(); |
| 8476 | |
| 8477 | if (context) |
| 8478 | { |
| 8479 | if (context->getClientVersion() < 3) |
| 8480 | { |
| 8481 | return gl::error(GL_INVALID_OPERATION); |
| 8482 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8483 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8484 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8485 | if (!programBinary) |
| 8486 | { |
| 8487 | return gl::error(GL_INVALID_OPERATION); |
| 8488 | } |
| 8489 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8490 | if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8491 | { |
| 8492 | return gl::error(GL_INVALID_OPERATION); |
| 8493 | } |
| 8494 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8495 | } |
| 8496 | catch(std::bad_alloc&) |
| 8497 | { |
| 8498 | return gl::error(GL_OUT_OF_MEMORY); |
| 8499 | } |
| 8500 | } |
| 8501 | |
| 8502 | void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8503 | { |
| 8504 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8505 | location, count, transpose, value); |
| 8506 | |
| 8507 | try |
| 8508 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8509 | if (count < 0) |
| 8510 | { |
| 8511 | return gl::error(GL_INVALID_VALUE); |
| 8512 | } |
| 8513 | |
| 8514 | if (location == -1) |
| 8515 | { |
| 8516 | return; |
| 8517 | } |
| 8518 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8519 | gl::Context *context = gl::getNonLostContext(); |
| 8520 | |
| 8521 | if (context) |
| 8522 | { |
| 8523 | if (context->getClientVersion() < 3) |
| 8524 | { |
| 8525 | return gl::error(GL_INVALID_OPERATION); |
| 8526 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8527 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8528 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8529 | if (!programBinary) |
| 8530 | { |
| 8531 | return gl::error(GL_INVALID_OPERATION); |
| 8532 | } |
| 8533 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8534 | if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8535 | { |
| 8536 | return gl::error(GL_INVALID_OPERATION); |
| 8537 | } |
| 8538 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8539 | } |
| 8540 | catch(std::bad_alloc&) |
| 8541 | { |
| 8542 | return gl::error(GL_OUT_OF_MEMORY); |
| 8543 | } |
| 8544 | } |
| 8545 | |
| 8546 | void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8547 | { |
| 8548 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8549 | location, count, transpose, value); |
| 8550 | |
| 8551 | try |
| 8552 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8553 | if (count < 0) |
| 8554 | { |
| 8555 | return gl::error(GL_INVALID_VALUE); |
| 8556 | } |
| 8557 | |
| 8558 | if (location == -1) |
| 8559 | { |
| 8560 | return; |
| 8561 | } |
| 8562 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8563 | gl::Context *context = gl::getNonLostContext(); |
| 8564 | |
| 8565 | if (context) |
| 8566 | { |
| 8567 | if (context->getClientVersion() < 3) |
| 8568 | { |
| 8569 | return gl::error(GL_INVALID_OPERATION); |
| 8570 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8571 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8572 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8573 | if (!programBinary) |
| 8574 | { |
| 8575 | return gl::error(GL_INVALID_OPERATION); |
| 8576 | } |
| 8577 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8578 | if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8579 | { |
| 8580 | return gl::error(GL_INVALID_OPERATION); |
| 8581 | } |
| 8582 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8583 | } |
| 8584 | catch(std::bad_alloc&) |
| 8585 | { |
| 8586 | return gl::error(GL_OUT_OF_MEMORY); |
| 8587 | } |
| 8588 | } |
| 8589 | |
| 8590 | void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8591 | { |
| 8592 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8593 | location, count, transpose, value); |
| 8594 | |
| 8595 | try |
| 8596 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8597 | if (count < 0) |
| 8598 | { |
| 8599 | return gl::error(GL_INVALID_VALUE); |
| 8600 | } |
| 8601 | |
| 8602 | if (location == -1) |
| 8603 | { |
| 8604 | return; |
| 8605 | } |
| 8606 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8607 | gl::Context *context = gl::getNonLostContext(); |
| 8608 | |
| 8609 | if (context) |
| 8610 | { |
| 8611 | if (context->getClientVersion() < 3) |
| 8612 | { |
| 8613 | return gl::error(GL_INVALID_OPERATION); |
| 8614 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8615 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8616 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8617 | if (!programBinary) |
| 8618 | { |
| 8619 | return gl::error(GL_INVALID_OPERATION); |
| 8620 | } |
| 8621 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8622 | if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8623 | { |
| 8624 | return gl::error(GL_INVALID_OPERATION); |
| 8625 | } |
| 8626 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8627 | } |
| 8628 | catch(std::bad_alloc&) |
| 8629 | { |
| 8630 | return gl::error(GL_OUT_OF_MEMORY); |
| 8631 | } |
| 8632 | } |
| 8633 | |
| 8634 | void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8635 | { |
| 8636 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8637 | location, count, transpose, value); |
| 8638 | |
| 8639 | try |
| 8640 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8641 | if (count < 0) |
| 8642 | { |
| 8643 | return gl::error(GL_INVALID_VALUE); |
| 8644 | } |
| 8645 | |
| 8646 | if (location == -1) |
| 8647 | { |
| 8648 | return; |
| 8649 | } |
| 8650 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8651 | gl::Context *context = gl::getNonLostContext(); |
| 8652 | |
| 8653 | if (context) |
| 8654 | { |
| 8655 | if (context->getClientVersion() < 3) |
| 8656 | { |
| 8657 | return gl::error(GL_INVALID_OPERATION); |
| 8658 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8659 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8660 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8661 | if (!programBinary) |
| 8662 | { |
| 8663 | return gl::error(GL_INVALID_OPERATION); |
| 8664 | } |
| 8665 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8666 | if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8667 | { |
| 8668 | return gl::error(GL_INVALID_OPERATION); |
| 8669 | } |
| 8670 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8671 | } |
| 8672 | catch(std::bad_alloc&) |
| 8673 | { |
| 8674 | return gl::error(GL_OUT_OF_MEMORY); |
| 8675 | } |
| 8676 | } |
| 8677 | |
| 8678 | void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) |
| 8679 | { |
| 8680 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, " |
| 8681 | "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 8682 | srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 8683 | |
| 8684 | try |
| 8685 | { |
| 8686 | gl::Context *context = gl::getNonLostContext(); |
| 8687 | |
| 8688 | if (context) |
| 8689 | { |
| 8690 | if (context->getClientVersion() < 3) |
| 8691 | { |
| 8692 | return gl::error(GL_INVALID_OPERATION); |
| 8693 | } |
| 8694 | } |
| 8695 | |
| 8696 | UNIMPLEMENTED(); |
| 8697 | } |
| 8698 | catch(std::bad_alloc&) |
| 8699 | { |
| 8700 | return gl::error(GL_OUT_OF_MEMORY); |
| 8701 | } |
| 8702 | } |
| 8703 | |
| 8704 | void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| 8705 | { |
| 8706 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 8707 | target, samples, internalformat, width, height); |
| 8708 | |
| 8709 | try |
| 8710 | { |
| 8711 | gl::Context *context = gl::getNonLostContext(); |
| 8712 | |
| 8713 | if (context) |
| 8714 | { |
| 8715 | if (context->getClientVersion() < 3) |
| 8716 | { |
| 8717 | return gl::error(GL_INVALID_OPERATION); |
| 8718 | } |
| 8719 | } |
| 8720 | |
| 8721 | UNIMPLEMENTED(); |
| 8722 | } |
| 8723 | catch(std::bad_alloc&) |
| 8724 | { |
| 8725 | return gl::error(GL_OUT_OF_MEMORY); |
| 8726 | } |
| 8727 | } |
| 8728 | |
| 8729 | void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) |
| 8730 | { |
| 8731 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)", |
| 8732 | target, attachment, texture, level, layer); |
| 8733 | |
| 8734 | try |
| 8735 | { |
| 8736 | gl::Context *context = gl::getNonLostContext(); |
| 8737 | |
| 8738 | if (context) |
| 8739 | { |
| 8740 | if (context->getClientVersion() < 3) |
| 8741 | { |
| 8742 | return gl::error(GL_INVALID_OPERATION); |
| 8743 | } |
| 8744 | } |
| 8745 | |
| 8746 | UNIMPLEMENTED(); |
| 8747 | } |
| 8748 | catch(std::bad_alloc&) |
| 8749 | { |
| 8750 | return gl::error(GL_OUT_OF_MEMORY); |
| 8751 | } |
| 8752 | } |
| 8753 | |
| 8754 | GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 8755 | { |
| 8756 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 8757 | target, offset, length, access); |
| 8758 | |
| 8759 | try |
| 8760 | { |
| 8761 | gl::Context *context = gl::getNonLostContext(); |
| 8762 | |
| 8763 | if (context) |
| 8764 | { |
| 8765 | if (context->getClientVersion() < 3) |
| 8766 | { |
| 8767 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 8768 | } |
| 8769 | } |
| 8770 | |
| 8771 | UNIMPLEMENTED(); |
| 8772 | } |
| 8773 | catch(std::bad_alloc&) |
| 8774 | { |
| 8775 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL)); |
| 8776 | } |
| 8777 | |
| 8778 | return NULL; |
| 8779 | } |
| 8780 | |
| 8781 | void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) |
| 8782 | { |
| 8783 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 8784 | |
| 8785 | try |
| 8786 | { |
| 8787 | gl::Context *context = gl::getNonLostContext(); |
| 8788 | |
| 8789 | if (context) |
| 8790 | { |
| 8791 | if (context->getClientVersion() < 3) |
| 8792 | { |
| 8793 | return gl::error(GL_INVALID_OPERATION); |
| 8794 | } |
| 8795 | } |
| 8796 | |
| 8797 | UNIMPLEMENTED(); |
| 8798 | } |
| 8799 | catch(std::bad_alloc&) |
| 8800 | { |
| 8801 | return gl::error(GL_OUT_OF_MEMORY); |
| 8802 | } |
| 8803 | } |
| 8804 | |
| 8805 | void __stdcall glBindVertexArray(GLuint array) |
| 8806 | { |
| 8807 | EVENT("(GLuint array = %u)", array); |
| 8808 | |
| 8809 | try |
| 8810 | { |
| 8811 | gl::Context *context = gl::getNonLostContext(); |
| 8812 | |
| 8813 | if (context) |
| 8814 | { |
| 8815 | if (context->getClientVersion() < 3) |
| 8816 | { |
| 8817 | return gl::error(GL_INVALID_OPERATION); |
| 8818 | } |
| 8819 | } |
| 8820 | |
| 8821 | UNIMPLEMENTED(); |
| 8822 | } |
| 8823 | catch(std::bad_alloc&) |
| 8824 | { |
| 8825 | return gl::error(GL_OUT_OF_MEMORY); |
| 8826 | } |
| 8827 | } |
| 8828 | |
| 8829 | void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) |
| 8830 | { |
| 8831 | EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays); |
| 8832 | |
| 8833 | try |
| 8834 | { |
| 8835 | gl::Context *context = gl::getNonLostContext(); |
| 8836 | |
| 8837 | if (context) |
| 8838 | { |
| 8839 | if (context->getClientVersion() < 3) |
| 8840 | { |
| 8841 | return gl::error(GL_INVALID_OPERATION); |
| 8842 | } |
| 8843 | } |
| 8844 | |
| 8845 | UNIMPLEMENTED(); |
| 8846 | } |
| 8847 | catch(std::bad_alloc&) |
| 8848 | { |
| 8849 | return gl::error(GL_OUT_OF_MEMORY); |
| 8850 | } |
| 8851 | } |
| 8852 | |
| 8853 | void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) |
| 8854 | { |
| 8855 | EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays); |
| 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); |
| 8866 | } |
| 8867 | } |
| 8868 | |
| 8869 | UNIMPLEMENTED(); |
| 8870 | } |
| 8871 | catch(std::bad_alloc&) |
| 8872 | { |
| 8873 | return gl::error(GL_OUT_OF_MEMORY); |
| 8874 | } |
| 8875 | } |
| 8876 | |
| 8877 | GLboolean __stdcall glIsVertexArray(GLuint array) |
| 8878 | { |
| 8879 | EVENT("(GLuint array = %u)", array); |
| 8880 | |
| 8881 | try |
| 8882 | { |
| 8883 | gl::Context *context = gl::getNonLostContext(); |
| 8884 | |
| 8885 | if (context) |
| 8886 | { |
| 8887 | if (context->getClientVersion() < 3) |
| 8888 | { |
| 8889 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8890 | } |
| 8891 | } |
| 8892 | |
| 8893 | UNIMPLEMENTED(); |
| 8894 | } |
| 8895 | catch(std::bad_alloc&) |
| 8896 | { |
| 8897 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8898 | } |
| 8899 | |
| 8900 | return GL_FALSE; |
| 8901 | } |
| 8902 | |
| 8903 | void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data) |
| 8904 | { |
| 8905 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)", |
| 8906 | target, index, data); |
| 8907 | |
| 8908 | try |
| 8909 | { |
| 8910 | gl::Context *context = gl::getNonLostContext(); |
| 8911 | |
| 8912 | if (context) |
| 8913 | { |
| 8914 | if (context->getClientVersion() < 3) |
| 8915 | { |
| 8916 | return gl::error(GL_INVALID_OPERATION); |
| 8917 | } |
| 8918 | } |
| 8919 | |
| 8920 | UNIMPLEMENTED(); |
| 8921 | } |
| 8922 | catch(std::bad_alloc&) |
| 8923 | { |
| 8924 | return gl::error(GL_OUT_OF_MEMORY); |
| 8925 | } |
| 8926 | } |
| 8927 | |
| 8928 | void __stdcall glBeginTransformFeedback(GLenum primitiveMode) |
| 8929 | { |
| 8930 | EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode); |
| 8931 | |
| 8932 | try |
| 8933 | { |
| 8934 | gl::Context *context = gl::getNonLostContext(); |
| 8935 | |
| 8936 | if (context) |
| 8937 | { |
| 8938 | if (context->getClientVersion() < 3) |
| 8939 | { |
| 8940 | return gl::error(GL_INVALID_OPERATION); |
| 8941 | } |
| 8942 | } |
| 8943 | |
| 8944 | UNIMPLEMENTED(); |
| 8945 | } |
| 8946 | catch(std::bad_alloc&) |
| 8947 | { |
| 8948 | return gl::error(GL_OUT_OF_MEMORY); |
| 8949 | } |
| 8950 | } |
| 8951 | |
| 8952 | void __stdcall glEndTransformFeedback(void) |
| 8953 | { |
| 8954 | EVENT("(void)"); |
| 8955 | |
| 8956 | try |
| 8957 | { |
| 8958 | gl::Context *context = gl::getNonLostContext(); |
| 8959 | |
| 8960 | if (context) |
| 8961 | { |
| 8962 | if (context->getClientVersion() < 3) |
| 8963 | { |
| 8964 | return gl::error(GL_INVALID_OPERATION); |
| 8965 | } |
| 8966 | } |
| 8967 | |
| 8968 | UNIMPLEMENTED(); |
| 8969 | } |
| 8970 | catch(std::bad_alloc&) |
| 8971 | { |
| 8972 | return gl::error(GL_OUT_OF_MEMORY); |
| 8973 | } |
| 8974 | } |
| 8975 | |
| 8976 | void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
| 8977 | { |
| 8978 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)", |
| 8979 | target, index, buffer, offset, size); |
| 8980 | |
| 8981 | try |
| 8982 | { |
| 8983 | gl::Context *context = gl::getNonLostContext(); |
| 8984 | |
| 8985 | if (context) |
| 8986 | { |
| 8987 | if (context->getClientVersion() < 3) |
| 8988 | { |
| 8989 | return gl::error(GL_INVALID_OPERATION); |
| 8990 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8991 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 8992 | switch (target) |
| 8993 | { |
| 8994 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 8995 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 8996 | { |
| 8997 | return gl::error(GL_INVALID_VALUE); |
| 8998 | } |
| 8999 | break; |
| 9000 | |
| 9001 | case GL_UNIFORM_BUFFER: |
| 9002 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 9003 | { |
| 9004 | return gl::error(GL_INVALID_VALUE); |
| 9005 | } |
| 9006 | break; |
| 9007 | |
| 9008 | default: |
| 9009 | return gl::error(GL_INVALID_ENUM); |
| 9010 | } |
| 9011 | |
shannonwoods@chromium.org | e6e0079 | 2013-05-30 00:06:07 +0000 | [diff] [blame] | 9012 | if (buffer != 0 && size <= 0) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9013 | { |
| 9014 | return gl::error(GL_INVALID_VALUE); |
| 9015 | } |
| 9016 | |
| 9017 | switch (target) |
| 9018 | { |
| 9019 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | a26aeaf | 2013-05-30 00:06:13 +0000 | [diff] [blame] | 9020 | |
| 9021 | // size and offset must be a multiple of 4 |
| 9022 | if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) |
| 9023 | { |
| 9024 | return gl::error(GL_INVALID_VALUE); |
| 9025 | } |
| 9026 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9027 | context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 9028 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9029 | break; |
| 9030 | |
| 9031 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 97c3d50 | 2013-05-30 00:04:34 +0000 | [diff] [blame] | 9032 | |
| 9033 | // it is an error to bind an offset not a multiple of the alignment |
| 9034 | if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0) |
| 9035 | { |
| 9036 | return gl::error(GL_INVALID_VALUE); |
| 9037 | } |
| 9038 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9039 | context->bindIndexedUniformBuffer(buffer, index, offset, size); |
| 9040 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9041 | break; |
| 9042 | |
| 9043 | default: |
| 9044 | UNREACHABLE(); |
| 9045 | } |
| 9046 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9047 | } |
| 9048 | catch(std::bad_alloc&) |
| 9049 | { |
| 9050 | return gl::error(GL_OUT_OF_MEMORY); |
| 9051 | } |
| 9052 | } |
| 9053 | |
| 9054 | void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 9055 | { |
| 9056 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)", |
| 9057 | target, index, buffer); |
| 9058 | |
| 9059 | try |
| 9060 | { |
| 9061 | gl::Context *context = gl::getNonLostContext(); |
| 9062 | |
| 9063 | if (context) |
| 9064 | { |
| 9065 | if (context->getClientVersion() < 3) |
| 9066 | { |
| 9067 | return gl::error(GL_INVALID_OPERATION); |
| 9068 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9069 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9070 | switch (target) |
| 9071 | { |
| 9072 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9073 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9074 | { |
| 9075 | return gl::error(GL_INVALID_VALUE); |
| 9076 | } |
| 9077 | break; |
| 9078 | |
| 9079 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9080 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9081 | { |
| 9082 | return gl::error(GL_INVALID_VALUE); |
| 9083 | } |
| 9084 | break; |
| 9085 | |
| 9086 | default: |
| 9087 | return gl::error(GL_INVALID_ENUM); |
| 9088 | } |
| 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 | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9093 | context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9094 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9095 | break; |
| 9096 | |
| 9097 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9098 | context->bindIndexedUniformBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9099 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9100 | break; |
| 9101 | |
| 9102 | default: |
| 9103 | UNREACHABLE(); |
| 9104 | } |
| 9105 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9106 | } |
| 9107 | catch(std::bad_alloc&) |
| 9108 | { |
| 9109 | return gl::error(GL_OUT_OF_MEMORY); |
| 9110 | } |
| 9111 | } |
| 9112 | |
| 9113 | void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
| 9114 | { |
| 9115 | EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)", |
| 9116 | program, count, varyings, bufferMode); |
| 9117 | |
| 9118 | try |
| 9119 | { |
| 9120 | gl::Context *context = gl::getNonLostContext(); |
| 9121 | |
| 9122 | if (context) |
| 9123 | { |
| 9124 | if (context->getClientVersion() < 3) |
| 9125 | { |
| 9126 | return gl::error(GL_INVALID_OPERATION); |
| 9127 | } |
| 9128 | } |
| 9129 | |
| 9130 | UNIMPLEMENTED(); |
| 9131 | } |
| 9132 | catch(std::bad_alloc&) |
| 9133 | { |
| 9134 | return gl::error(GL_OUT_OF_MEMORY); |
| 9135 | } |
| 9136 | } |
| 9137 | |
| 9138 | void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
| 9139 | { |
| 9140 | EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, " |
| 9141 | "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
| 9142 | program, index, bufSize, length, size, type, name); |
| 9143 | |
| 9144 | try |
| 9145 | { |
| 9146 | gl::Context *context = gl::getNonLostContext(); |
| 9147 | |
| 9148 | if (context) |
| 9149 | { |
| 9150 | if (context->getClientVersion() < 3) |
| 9151 | { |
| 9152 | return gl::error(GL_INVALID_OPERATION); |
| 9153 | } |
| 9154 | } |
| 9155 | |
| 9156 | UNIMPLEMENTED(); |
| 9157 | } |
| 9158 | catch(std::bad_alloc&) |
| 9159 | { |
| 9160 | return gl::error(GL_OUT_OF_MEMORY); |
| 9161 | } |
| 9162 | } |
| 9163 | |
| 9164 | void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) |
| 9165 | { |
| 9166 | EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)", |
| 9167 | index, size, type, stride, pointer); |
| 9168 | |
| 9169 | try |
| 9170 | { |
| 9171 | gl::Context *context = gl::getNonLostContext(); |
| 9172 | |
| 9173 | if (context) |
| 9174 | { |
| 9175 | if (context->getClientVersion() < 3) |
| 9176 | { |
| 9177 | return gl::error(GL_INVALID_OPERATION); |
| 9178 | } |
| 9179 | } |
| 9180 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9181 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9182 | { |
| 9183 | return gl::error(GL_INVALID_VALUE); |
| 9184 | } |
| 9185 | |
| 9186 | if (size < 1 || size > 4) |
| 9187 | { |
| 9188 | return gl::error(GL_INVALID_VALUE); |
| 9189 | } |
| 9190 | |
| 9191 | switch (type) |
| 9192 | { |
| 9193 | case GL_BYTE: |
| 9194 | case GL_UNSIGNED_BYTE: |
| 9195 | case GL_SHORT: |
| 9196 | case GL_UNSIGNED_SHORT: |
| 9197 | case GL_INT: |
| 9198 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9199 | case GL_INT_2_10_10_10_REV: |
| 9200 | 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] | 9201 | break; |
| 9202 | default: |
| 9203 | return gl::error(GL_INVALID_ENUM); |
| 9204 | } |
| 9205 | |
| 9206 | if (stride < 0) |
| 9207 | { |
| 9208 | return gl::error(GL_INVALID_VALUE); |
| 9209 | } |
| 9210 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9211 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 9212 | { |
| 9213 | return gl::error(GL_INVALID_OPERATION); |
| 9214 | } |
| 9215 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9216 | if (context) |
| 9217 | { |
| 9218 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true, |
| 9219 | stride, pointer); |
| 9220 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9221 | } |
| 9222 | catch(std::bad_alloc&) |
| 9223 | { |
| 9224 | return gl::error(GL_OUT_OF_MEMORY); |
| 9225 | } |
| 9226 | } |
| 9227 | |
| 9228 | void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) |
| 9229 | { |
| 9230 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 9231 | index, pname, params); |
| 9232 | |
| 9233 | try |
| 9234 | { |
| 9235 | gl::Context *context = gl::getNonLostContext(); |
| 9236 | |
| 9237 | if (context) |
| 9238 | { |
| 9239 | if (context->getClientVersion() < 3) |
| 9240 | { |
| 9241 | return gl::error(GL_INVALID_OPERATION); |
| 9242 | } |
| 9243 | } |
| 9244 | |
| 9245 | UNIMPLEMENTED(); |
| 9246 | } |
| 9247 | catch(std::bad_alloc&) |
| 9248 | { |
| 9249 | return gl::error(GL_OUT_OF_MEMORY); |
| 9250 | } |
| 9251 | } |
| 9252 | |
| 9253 | void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) |
| 9254 | { |
| 9255 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)", |
| 9256 | index, pname, params); |
| 9257 | |
| 9258 | try |
| 9259 | { |
| 9260 | gl::Context *context = gl::getNonLostContext(); |
| 9261 | |
| 9262 | if (context) |
| 9263 | { |
| 9264 | if (context->getClientVersion() < 3) |
| 9265 | { |
| 9266 | return gl::error(GL_INVALID_OPERATION); |
| 9267 | } |
| 9268 | } |
| 9269 | |
| 9270 | UNIMPLEMENTED(); |
| 9271 | } |
| 9272 | catch(std::bad_alloc&) |
| 9273 | { |
| 9274 | return gl::error(GL_OUT_OF_MEMORY); |
| 9275 | } |
| 9276 | } |
| 9277 | |
| 9278 | void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 9279 | { |
| 9280 | EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)", |
| 9281 | index, x, y, z, w); |
| 9282 | |
| 9283 | try |
| 9284 | { |
| 9285 | gl::Context *context = gl::getNonLostContext(); |
| 9286 | |
| 9287 | if (context) |
| 9288 | { |
| 9289 | if (context->getClientVersion() < 3) |
| 9290 | { |
| 9291 | return gl::error(GL_INVALID_OPERATION); |
| 9292 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9293 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9294 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9295 | { |
| 9296 | return gl::error(GL_INVALID_VALUE); |
| 9297 | } |
| 9298 | |
| 9299 | GLint vals[4] = { x, y, z, w }; |
| 9300 | context->setVertexAttribi(index, vals); |
| 9301 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9302 | } |
| 9303 | catch(std::bad_alloc&) |
| 9304 | { |
| 9305 | return gl::error(GL_OUT_OF_MEMORY); |
| 9306 | } |
| 9307 | } |
| 9308 | |
| 9309 | void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 9310 | { |
| 9311 | EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)", |
| 9312 | index, x, y, z, w); |
| 9313 | |
| 9314 | try |
| 9315 | { |
| 9316 | gl::Context *context = gl::getNonLostContext(); |
| 9317 | |
| 9318 | if (context) |
| 9319 | { |
| 9320 | if (context->getClientVersion() < 3) |
| 9321 | { |
| 9322 | return gl::error(GL_INVALID_OPERATION); |
| 9323 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9324 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9325 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9326 | { |
| 9327 | return gl::error(GL_INVALID_VALUE); |
| 9328 | } |
| 9329 | |
| 9330 | GLuint vals[4] = { x, y, z, w }; |
| 9331 | context->setVertexAttribu(index, vals); |
| 9332 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9333 | } |
| 9334 | catch(std::bad_alloc&) |
| 9335 | { |
| 9336 | return gl::error(GL_OUT_OF_MEMORY); |
| 9337 | } |
| 9338 | } |
| 9339 | |
| 9340 | void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) |
| 9341 | { |
| 9342 | EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v); |
| 9343 | |
| 9344 | try |
| 9345 | { |
| 9346 | gl::Context *context = gl::getNonLostContext(); |
| 9347 | |
| 9348 | if (context) |
| 9349 | { |
| 9350 | if (context->getClientVersion() < 3) |
| 9351 | { |
| 9352 | return gl::error(GL_INVALID_OPERATION); |
| 9353 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9354 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9355 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9356 | { |
| 9357 | return gl::error(GL_INVALID_VALUE); |
| 9358 | } |
| 9359 | |
| 9360 | context->setVertexAttribi(index, v); |
| 9361 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9362 | } |
| 9363 | catch(std::bad_alloc&) |
| 9364 | { |
| 9365 | return gl::error(GL_OUT_OF_MEMORY); |
| 9366 | } |
| 9367 | } |
| 9368 | |
| 9369 | void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v) |
| 9370 | { |
| 9371 | EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v); |
| 9372 | |
| 9373 | try |
| 9374 | { |
| 9375 | gl::Context *context = gl::getNonLostContext(); |
| 9376 | |
| 9377 | if (context) |
| 9378 | { |
| 9379 | if (context->getClientVersion() < 3) |
| 9380 | { |
| 9381 | return gl::error(GL_INVALID_OPERATION); |
| 9382 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9383 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9384 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9385 | { |
| 9386 | return gl::error(GL_INVALID_VALUE); |
| 9387 | } |
| 9388 | |
| 9389 | context->setVertexAttribu(index, v); |
| 9390 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9391 | } |
| 9392 | catch(std::bad_alloc&) |
| 9393 | { |
| 9394 | return gl::error(GL_OUT_OF_MEMORY); |
| 9395 | } |
| 9396 | } |
| 9397 | |
| 9398 | void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) |
| 9399 | { |
| 9400 | EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)", |
| 9401 | program, location, params); |
| 9402 | |
| 9403 | try |
| 9404 | { |
| 9405 | gl::Context *context = gl::getNonLostContext(); |
| 9406 | |
| 9407 | if (context) |
| 9408 | { |
| 9409 | if (context->getClientVersion() < 3) |
| 9410 | { |
| 9411 | return gl::error(GL_INVALID_OPERATION); |
| 9412 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9413 | |
shannon.woods%transgaming.com@gtempaccount.com | e229012 | 2013-04-13 03:41:07 +0000 | [diff] [blame] | 9414 | if (program == 0) |
| 9415 | { |
| 9416 | return gl::error(GL_INVALID_VALUE); |
| 9417 | } |
| 9418 | |
| 9419 | gl::Program *programObject = context->getProgram(program); |
| 9420 | |
| 9421 | if (!programObject || !programObject->isLinked()) |
| 9422 | { |
| 9423 | return gl::error(GL_INVALID_OPERATION); |
| 9424 | } |
| 9425 | |
| 9426 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9427 | if (!programBinary) |
| 9428 | { |
| 9429 | return gl::error(GL_INVALID_OPERATION); |
| 9430 | } |
| 9431 | |
| 9432 | if (!programBinary->getUniformuiv(location, NULL, params)) |
| 9433 | { |
| 9434 | return gl::error(GL_INVALID_OPERATION); |
| 9435 | } |
| 9436 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9437 | } |
| 9438 | catch(std::bad_alloc&) |
| 9439 | { |
| 9440 | return gl::error(GL_OUT_OF_MEMORY); |
| 9441 | } |
| 9442 | } |
| 9443 | |
| 9444 | GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) |
| 9445 | { |
| 9446 | EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)", |
| 9447 | program, name); |
| 9448 | |
| 9449 | try |
| 9450 | { |
| 9451 | gl::Context *context = gl::getNonLostContext(); |
| 9452 | |
| 9453 | if (context) |
| 9454 | { |
| 9455 | if (context->getClientVersion() < 3) |
| 9456 | { |
| 9457 | return gl::error(GL_INVALID_OPERATION, 0); |
| 9458 | } |
| 9459 | } |
| 9460 | |
| 9461 | UNIMPLEMENTED(); |
| 9462 | } |
| 9463 | catch(std::bad_alloc&) |
| 9464 | { |
| 9465 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 9466 | } |
| 9467 | |
| 9468 | return 0; |
| 9469 | } |
| 9470 | |
| 9471 | void __stdcall glUniform1ui(GLint location, GLuint v0) |
| 9472 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9473 | glUniform1uiv(location, 1, &v0); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9474 | } |
| 9475 | |
| 9476 | void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1) |
| 9477 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9478 | const GLuint xy[] = { v0, v1 }; |
| 9479 | glUniform2uiv(location, 1, xy); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9480 | } |
| 9481 | |
| 9482 | void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 9483 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9484 | const GLuint xyz[] = { v0, v1, v2 }; |
| 9485 | glUniform3uiv(location, 1, xyz); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9486 | } |
| 9487 | |
| 9488 | void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 9489 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9490 | const GLuint xyzw[] = { v0, v1, v2, v3 }; |
| 9491 | glUniform4uiv(location, 1, xyzw); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9492 | } |
| 9493 | |
| 9494 | void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) |
| 9495 | { |
| 9496 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9497 | location, count, value); |
| 9498 | |
| 9499 | try |
| 9500 | { |
| 9501 | gl::Context *context = gl::getNonLostContext(); |
| 9502 | |
| 9503 | if (context) |
| 9504 | { |
| 9505 | if (context->getClientVersion() < 3) |
| 9506 | { |
| 9507 | return gl::error(GL_INVALID_OPERATION); |
| 9508 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9509 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9510 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9511 | if (!programBinary) |
| 9512 | { |
| 9513 | return gl::error(GL_INVALID_OPERATION); |
| 9514 | } |
| 9515 | |
| 9516 | if (!programBinary->setUniform1uiv(location, count, value)) |
| 9517 | { |
| 9518 | return gl::error(GL_INVALID_OPERATION); |
| 9519 | } |
| 9520 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9521 | } |
| 9522 | catch(std::bad_alloc&) |
| 9523 | { |
| 9524 | return gl::error(GL_OUT_OF_MEMORY); |
| 9525 | } |
| 9526 | } |
| 9527 | |
| 9528 | void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) |
| 9529 | { |
| 9530 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9531 | location, count, value); |
| 9532 | |
| 9533 | try |
| 9534 | { |
| 9535 | gl::Context *context = gl::getNonLostContext(); |
| 9536 | |
| 9537 | if (context) |
| 9538 | { |
| 9539 | if (context->getClientVersion() < 3) |
| 9540 | { |
| 9541 | return gl::error(GL_INVALID_OPERATION); |
| 9542 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9543 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9544 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9545 | if (!programBinary) |
| 9546 | { |
| 9547 | return gl::error(GL_INVALID_OPERATION); |
| 9548 | } |
| 9549 | |
| 9550 | if (!programBinary->setUniform2uiv(location, count, value)) |
| 9551 | { |
| 9552 | return gl::error(GL_INVALID_OPERATION); |
| 9553 | } |
| 9554 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9555 | } |
| 9556 | catch(std::bad_alloc&) |
| 9557 | { |
| 9558 | return gl::error(GL_OUT_OF_MEMORY); |
| 9559 | } |
| 9560 | } |
| 9561 | |
| 9562 | void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) |
| 9563 | { |
| 9564 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)", |
| 9565 | location, count, value); |
| 9566 | |
| 9567 | try |
| 9568 | { |
| 9569 | gl::Context *context = gl::getNonLostContext(); |
| 9570 | |
| 9571 | if (context) |
| 9572 | { |
| 9573 | if (context->getClientVersion() < 3) |
| 9574 | { |
| 9575 | return gl::error(GL_INVALID_OPERATION); |
| 9576 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9577 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9578 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9579 | if (!programBinary) |
| 9580 | { |
| 9581 | return gl::error(GL_INVALID_OPERATION); |
| 9582 | } |
| 9583 | |
| 9584 | if (!programBinary->setUniform3uiv(location, count, value)) |
| 9585 | { |
| 9586 | return gl::error(GL_INVALID_OPERATION); |
| 9587 | } |
| 9588 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9589 | } |
| 9590 | catch(std::bad_alloc&) |
| 9591 | { |
| 9592 | return gl::error(GL_OUT_OF_MEMORY); |
| 9593 | } |
| 9594 | } |
| 9595 | |
| 9596 | void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) |
| 9597 | { |
| 9598 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9599 | location, count, value); |
| 9600 | |
| 9601 | try |
| 9602 | { |
| 9603 | gl::Context *context = gl::getNonLostContext(); |
| 9604 | |
| 9605 | if (context) |
| 9606 | { |
| 9607 | if (context->getClientVersion() < 3) |
| 9608 | { |
| 9609 | return gl::error(GL_INVALID_OPERATION); |
| 9610 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9611 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9612 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9613 | if (!programBinary) |
| 9614 | { |
| 9615 | return gl::error(GL_INVALID_OPERATION); |
| 9616 | } |
| 9617 | |
| 9618 | if (!programBinary->setUniform4uiv(location, count, value)) |
| 9619 | { |
| 9620 | return gl::error(GL_INVALID_OPERATION); |
| 9621 | } |
| 9622 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9623 | } |
| 9624 | catch(std::bad_alloc&) |
| 9625 | { |
| 9626 | return gl::error(GL_OUT_OF_MEMORY); |
| 9627 | } |
| 9628 | } |
| 9629 | |
| 9630 | void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) |
| 9631 | { |
| 9632 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)", |
| 9633 | buffer, drawbuffer, value); |
| 9634 | |
| 9635 | try |
| 9636 | { |
| 9637 | gl::Context *context = gl::getNonLostContext(); |
| 9638 | |
| 9639 | if (context) |
| 9640 | { |
| 9641 | if (context->getClientVersion() < 3) |
| 9642 | { |
| 9643 | return gl::error(GL_INVALID_OPERATION); |
| 9644 | } |
| 9645 | } |
| 9646 | |
| 9647 | UNIMPLEMENTED(); |
| 9648 | } |
| 9649 | catch(std::bad_alloc&) |
| 9650 | { |
| 9651 | return gl::error(GL_OUT_OF_MEMORY); |
| 9652 | } |
| 9653 | } |
| 9654 | |
| 9655 | void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) |
| 9656 | { |
| 9657 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)", |
| 9658 | buffer, drawbuffer, value); |
| 9659 | |
| 9660 | try |
| 9661 | { |
| 9662 | gl::Context *context = gl::getNonLostContext(); |
| 9663 | |
| 9664 | if (context) |
| 9665 | { |
| 9666 | if (context->getClientVersion() < 3) |
| 9667 | { |
| 9668 | return gl::error(GL_INVALID_OPERATION); |
| 9669 | } |
| 9670 | } |
| 9671 | |
| 9672 | UNIMPLEMENTED(); |
| 9673 | } |
| 9674 | catch(std::bad_alloc&) |
| 9675 | { |
| 9676 | return gl::error(GL_OUT_OF_MEMORY); |
| 9677 | } |
| 9678 | } |
| 9679 | |
| 9680 | void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) |
| 9681 | { |
| 9682 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)", |
| 9683 | buffer, drawbuffer, value); |
| 9684 | |
| 9685 | try |
| 9686 | { |
| 9687 | gl::Context *context = gl::getNonLostContext(); |
| 9688 | |
| 9689 | if (context) |
| 9690 | { |
| 9691 | if (context->getClientVersion() < 3) |
| 9692 | { |
| 9693 | return gl::error(GL_INVALID_OPERATION); |
| 9694 | } |
| 9695 | } |
| 9696 | |
| 9697 | UNIMPLEMENTED(); |
| 9698 | } |
| 9699 | catch(std::bad_alloc&) |
| 9700 | { |
| 9701 | return gl::error(GL_OUT_OF_MEMORY); |
| 9702 | } |
| 9703 | } |
| 9704 | |
| 9705 | void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 9706 | { |
| 9707 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)", |
| 9708 | buffer, drawbuffer, depth, stencil); |
| 9709 | |
| 9710 | try |
| 9711 | { |
| 9712 | gl::Context *context = gl::getNonLostContext(); |
| 9713 | |
| 9714 | if (context) |
| 9715 | { |
| 9716 | if (context->getClientVersion() < 3) |
| 9717 | { |
| 9718 | return gl::error(GL_INVALID_OPERATION); |
| 9719 | } |
| 9720 | } |
| 9721 | |
| 9722 | UNIMPLEMENTED(); |
| 9723 | } |
| 9724 | catch(std::bad_alloc&) |
| 9725 | { |
| 9726 | return gl::error(GL_OUT_OF_MEMORY); |
| 9727 | } |
| 9728 | } |
| 9729 | |
| 9730 | const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) |
| 9731 | { |
| 9732 | EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index); |
| 9733 | |
| 9734 | try |
| 9735 | { |
| 9736 | gl::Context *context = gl::getNonLostContext(); |
| 9737 | |
| 9738 | if (context) |
| 9739 | { |
| 9740 | if (context->getClientVersion() < 3) |
| 9741 | { |
| 9742 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL)); |
| 9743 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9744 | |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 9745 | if (name != GL_EXTENSIONS) |
| 9746 | { |
| 9747 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL)); |
| 9748 | } |
| 9749 | |
| 9750 | if (index >= context->getNumExtensions()) |
| 9751 | { |
| 9752 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL)); |
| 9753 | } |
| 9754 | |
| 9755 | return reinterpret_cast<const GLubyte*>(context->getExtensionString(index)); |
| 9756 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9757 | } |
| 9758 | catch(std::bad_alloc&) |
| 9759 | { |
| 9760 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL)); |
| 9761 | } |
| 9762 | |
| 9763 | return NULL; |
| 9764 | } |
| 9765 | |
| 9766 | void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 9767 | { |
| 9768 | EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)", |
| 9769 | readTarget, writeTarget, readOffset, writeOffset, size); |
| 9770 | |
| 9771 | try |
| 9772 | { |
| 9773 | gl::Context *context = gl::getNonLostContext(); |
| 9774 | |
| 9775 | if (context) |
| 9776 | { |
| 9777 | if (context->getClientVersion() < 3) |
| 9778 | { |
| 9779 | return gl::error(GL_INVALID_OPERATION); |
| 9780 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9781 | |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 9782 | gl::Buffer *readBuffer = NULL; |
| 9783 | switch (readTarget) |
| 9784 | { |
| 9785 | case GL_ARRAY_BUFFER: |
| 9786 | readBuffer = context->getArrayBuffer(); |
| 9787 | break; |
| 9788 | case GL_COPY_READ_BUFFER: |
| 9789 | readBuffer = context->getCopyReadBuffer(); |
| 9790 | break; |
| 9791 | case GL_COPY_WRITE_BUFFER: |
| 9792 | readBuffer = context->getCopyWriteBuffer(); |
| 9793 | break; |
| 9794 | case GL_ELEMENT_ARRAY_BUFFER: |
| 9795 | readBuffer = context->getElementArrayBuffer(); |
| 9796 | break; |
| 9797 | case GL_PIXEL_PACK_BUFFER: |
| 9798 | readBuffer = context->getPixelPackBuffer(); |
| 9799 | break; |
| 9800 | case GL_PIXEL_UNPACK_BUFFER: |
| 9801 | readBuffer = context->getPixelUnpackBuffer(); |
| 9802 | break; |
| 9803 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 9804 | readBuffer = context->getGenericTransformFeedbackBuffer(); |
| 9805 | break; |
| 9806 | case GL_UNIFORM_BUFFER: |
| 9807 | readBuffer = context->getGenericUniformBuffer(); |
| 9808 | break; |
| 9809 | default: |
| 9810 | return gl::error(GL_INVALID_ENUM); |
| 9811 | } |
| 9812 | |
| 9813 | gl::Buffer *writeBuffer = NULL; |
| 9814 | switch (writeTarget) |
| 9815 | { |
| 9816 | case GL_ARRAY_BUFFER: |
| 9817 | writeBuffer = context->getArrayBuffer(); |
| 9818 | break; |
| 9819 | case GL_COPY_READ_BUFFER: |
| 9820 | writeBuffer = context->getCopyReadBuffer(); |
| 9821 | break; |
| 9822 | case GL_COPY_WRITE_BUFFER: |
| 9823 | writeBuffer = context->getCopyWriteBuffer(); |
| 9824 | break; |
| 9825 | case GL_ELEMENT_ARRAY_BUFFER: |
| 9826 | writeBuffer = context->getElementArrayBuffer(); |
| 9827 | break; |
| 9828 | case GL_PIXEL_PACK_BUFFER: |
| 9829 | writeBuffer = context->getPixelPackBuffer(); |
| 9830 | break; |
| 9831 | case GL_PIXEL_UNPACK_BUFFER: |
| 9832 | writeBuffer = context->getPixelUnpackBuffer(); |
| 9833 | break; |
| 9834 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 9835 | writeBuffer = context->getGenericTransformFeedbackBuffer(); |
| 9836 | break; |
| 9837 | case GL_UNIFORM_BUFFER: |
| 9838 | writeBuffer = context->getGenericUniformBuffer(); |
| 9839 | break; |
| 9840 | default: |
| 9841 | return gl::error(GL_INVALID_ENUM); |
| 9842 | } |
| 9843 | |
| 9844 | if (!readBuffer || !writeBuffer) |
| 9845 | { |
| 9846 | return gl::error(GL_INVALID_OPERATION); |
| 9847 | } |
| 9848 | |
| 9849 | if (readOffset < 0 || writeOffset < 0 || size < 0 || |
| 9850 | static_cast<unsigned int>(readOffset + size) > readBuffer->size() || |
| 9851 | static_cast<unsigned int>(writeOffset + size) > writeBuffer->size()) |
| 9852 | { |
| 9853 | return gl::error(GL_INVALID_VALUE); |
| 9854 | } |
| 9855 | |
| 9856 | if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size) |
| 9857 | { |
| 9858 | return gl::error(GL_INVALID_VALUE); |
| 9859 | } |
| 9860 | |
| 9861 | // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION) |
| 9862 | |
shannon.woods%transgaming.com@gtempaccount.com | c53376a | 2013-04-13 03:41:23 +0000 | [diff] [blame] | 9863 | // if size is zero, the copy is a successful no-op |
| 9864 | if (size > 0) |
| 9865 | { |
| 9866 | writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); |
| 9867 | } |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 9868 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9869 | } |
| 9870 | catch(std::bad_alloc&) |
| 9871 | { |
| 9872 | return gl::error(GL_OUT_OF_MEMORY); |
| 9873 | } |
| 9874 | } |
| 9875 | |
| 9876 | void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) |
| 9877 | { |
| 9878 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)", |
| 9879 | program, uniformCount, uniformNames, uniformIndices); |
| 9880 | |
| 9881 | try |
| 9882 | { |
| 9883 | gl::Context *context = gl::getNonLostContext(); |
| 9884 | |
| 9885 | if (context) |
| 9886 | { |
| 9887 | if (context->getClientVersion() < 3) |
| 9888 | { |
| 9889 | return gl::error(GL_INVALID_OPERATION); |
| 9890 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9891 | |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 9892 | if (uniformCount < 0) |
| 9893 | { |
| 9894 | return gl::error(GL_INVALID_VALUE); |
| 9895 | } |
| 9896 | |
| 9897 | gl::Program *programObject = context->getProgram(program); |
| 9898 | |
| 9899 | if (!programObject) |
| 9900 | { |
| 9901 | if (context->getShader(program)) |
| 9902 | { |
| 9903 | return gl::error(GL_INVALID_OPERATION); |
| 9904 | } |
| 9905 | else |
| 9906 | { |
| 9907 | return gl::error(GL_INVALID_VALUE); |
| 9908 | } |
| 9909 | } |
| 9910 | |
| 9911 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9912 | if (!programObject->isLinked() || !programBinary) |
| 9913 | { |
| 9914 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 9915 | { |
| 9916 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 9917 | } |
| 9918 | } |
| 9919 | else |
| 9920 | { |
| 9921 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 9922 | { |
| 9923 | uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]); |
| 9924 | } |
| 9925 | } |
| 9926 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9927 | } |
| 9928 | catch(std::bad_alloc&) |
| 9929 | { |
| 9930 | return gl::error(GL_OUT_OF_MEMORY); |
| 9931 | } |
| 9932 | } |
| 9933 | |
| 9934 | void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) |
| 9935 | { |
| 9936 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 9937 | program, uniformCount, uniformIndices, pname, params); |
| 9938 | |
| 9939 | try |
| 9940 | { |
| 9941 | gl::Context *context = gl::getNonLostContext(); |
| 9942 | |
| 9943 | if (context) |
| 9944 | { |
| 9945 | if (context->getClientVersion() < 3) |
| 9946 | { |
| 9947 | return gl::error(GL_INVALID_OPERATION); |
| 9948 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9949 | |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 9950 | if (uniformCount < 0) |
| 9951 | { |
| 9952 | return gl::error(GL_INVALID_VALUE); |
| 9953 | } |
| 9954 | |
| 9955 | gl::Program *programObject = context->getProgram(program); |
| 9956 | |
| 9957 | if (!programObject) |
| 9958 | { |
| 9959 | if (context->getShader(program)) |
| 9960 | { |
| 9961 | return gl::error(GL_INVALID_OPERATION); |
| 9962 | } |
| 9963 | else |
| 9964 | { |
| 9965 | return gl::error(GL_INVALID_VALUE); |
| 9966 | } |
| 9967 | } |
| 9968 | |
| 9969 | switch (pname) |
| 9970 | { |
| 9971 | case GL_UNIFORM_TYPE: |
| 9972 | case GL_UNIFORM_SIZE: |
| 9973 | case GL_UNIFORM_NAME_LENGTH: |
| 9974 | case GL_UNIFORM_BLOCK_INDEX: |
| 9975 | case GL_UNIFORM_OFFSET: |
| 9976 | case GL_UNIFORM_ARRAY_STRIDE: |
| 9977 | case GL_UNIFORM_MATRIX_STRIDE: |
| 9978 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 9979 | break; |
| 9980 | default: |
| 9981 | return gl::error(GL_INVALID_ENUM); |
| 9982 | } |
| 9983 | |
| 9984 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9985 | |
| 9986 | if (!programBinary && uniformCount > 0) |
| 9987 | { |
| 9988 | return gl::error(GL_INVALID_VALUE); |
| 9989 | } |
| 9990 | |
| 9991 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 9992 | { |
| 9993 | const GLuint index = uniformIndices[uniformId]; |
| 9994 | |
| 9995 | if (index >= (GLuint)programBinary->getActiveUniformCount()) |
| 9996 | { |
| 9997 | return gl::error(GL_INVALID_VALUE); |
| 9998 | } |
| 9999 | } |
| 10000 | |
| 10001 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10002 | { |
| 10003 | const GLuint index = uniformIndices[uniformId]; |
| 10004 | params[uniformId] = programBinary->getActiveUniformi(index, pname); |
| 10005 | } |
| 10006 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10007 | } |
| 10008 | catch(std::bad_alloc&) |
| 10009 | { |
| 10010 | return gl::error(GL_OUT_OF_MEMORY); |
| 10011 | } |
| 10012 | } |
| 10013 | |
| 10014 | GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) |
| 10015 | { |
| 10016 | EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName); |
| 10017 | |
| 10018 | try |
| 10019 | { |
| 10020 | gl::Context *context = gl::getNonLostContext(); |
| 10021 | |
| 10022 | if (context) |
| 10023 | { |
| 10024 | if (context->getClientVersion() < 3) |
| 10025 | { |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10026 | 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] | 10027 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10028 | |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10029 | gl::Program *programObject = context->getProgram(program); |
| 10030 | |
| 10031 | if (!programObject) |
| 10032 | { |
| 10033 | if (context->getShader(program)) |
| 10034 | { |
| 10035 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
| 10036 | } |
| 10037 | else |
| 10038 | { |
| 10039 | return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX); |
| 10040 | } |
| 10041 | } |
| 10042 | |
| 10043 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10044 | if (!programBinary) |
| 10045 | { |
| 10046 | return GL_INVALID_INDEX; |
| 10047 | } |
| 10048 | |
| 10049 | return programBinary->getUniformBlockIndex(uniformBlockName); |
| 10050 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10051 | } |
| 10052 | catch(std::bad_alloc&) |
| 10053 | { |
| 10054 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10055 | } |
| 10056 | |
| 10057 | return 0; |
| 10058 | } |
| 10059 | |
| 10060 | void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) |
| 10061 | { |
| 10062 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10063 | program, uniformBlockIndex, pname, params); |
| 10064 | |
| 10065 | try |
| 10066 | { |
| 10067 | gl::Context *context = gl::getNonLostContext(); |
| 10068 | |
| 10069 | if (context) |
| 10070 | { |
| 10071 | if (context->getClientVersion() < 3) |
| 10072 | { |
| 10073 | return gl::error(GL_INVALID_OPERATION); |
| 10074 | } |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10075 | gl::Program *programObject = context->getProgram(program); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10076 | |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10077 | if (!programObject) |
| 10078 | { |
| 10079 | if (context->getShader(program)) |
| 10080 | { |
| 10081 | return gl::error(GL_INVALID_OPERATION); |
| 10082 | } |
| 10083 | else |
| 10084 | { |
| 10085 | return gl::error(GL_INVALID_VALUE); |
| 10086 | } |
| 10087 | } |
| 10088 | |
| 10089 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10090 | |
| 10091 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10092 | { |
| 10093 | return gl::error(GL_INVALID_VALUE); |
| 10094 | } |
| 10095 | |
| 10096 | switch (pname) |
| 10097 | { |
| 10098 | case GL_UNIFORM_BLOCK_BINDING: |
| 10099 | *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); |
| 10100 | break; |
| 10101 | |
| 10102 | case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 10103 | case GL_UNIFORM_BLOCK_NAME_LENGTH: |
| 10104 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 10105 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| 10106 | case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
| 10107 | case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
| 10108 | programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params); |
| 10109 | break; |
| 10110 | |
| 10111 | default: |
| 10112 | return gl::error(GL_INVALID_ENUM); |
| 10113 | } |
| 10114 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10115 | } |
| 10116 | catch(std::bad_alloc&) |
| 10117 | { |
| 10118 | return gl::error(GL_OUT_OF_MEMORY); |
| 10119 | } |
| 10120 | } |
| 10121 | |
| 10122 | void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) |
| 10123 | { |
| 10124 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)", |
| 10125 | program, uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10126 | |
| 10127 | try |
| 10128 | { |
| 10129 | gl::Context *context = gl::getNonLostContext(); |
| 10130 | |
| 10131 | if (context) |
| 10132 | { |
| 10133 | if (context->getClientVersion() < 3) |
| 10134 | { |
| 10135 | return gl::error(GL_INVALID_OPERATION); |
| 10136 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10137 | |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 10138 | gl::Program *programObject = context->getProgram(program); |
| 10139 | |
| 10140 | if (!programObject) |
| 10141 | { |
| 10142 | if (context->getShader(program)) |
| 10143 | { |
| 10144 | return gl::error(GL_INVALID_OPERATION); |
| 10145 | } |
| 10146 | else |
| 10147 | { |
| 10148 | return gl::error(GL_INVALID_VALUE); |
| 10149 | } |
| 10150 | } |
| 10151 | |
| 10152 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10153 | |
| 10154 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10155 | { |
| 10156 | return gl::error(GL_INVALID_VALUE); |
| 10157 | } |
| 10158 | |
| 10159 | programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10160 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10161 | } |
| 10162 | catch(std::bad_alloc&) |
| 10163 | { |
| 10164 | return gl::error(GL_OUT_OF_MEMORY); |
| 10165 | } |
| 10166 | } |
| 10167 | |
| 10168 | void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) |
| 10169 | { |
| 10170 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)", |
| 10171 | program, uniformBlockIndex, uniformBlockBinding); |
| 10172 | |
| 10173 | try |
| 10174 | { |
| 10175 | gl::Context *context = gl::getNonLostContext(); |
| 10176 | |
| 10177 | if (context) |
| 10178 | { |
| 10179 | if (context->getClientVersion() < 3) |
| 10180 | { |
| 10181 | return gl::error(GL_INVALID_OPERATION); |
| 10182 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10183 | |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 10184 | if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings()) |
| 10185 | { |
| 10186 | return gl::error(GL_INVALID_VALUE); |
| 10187 | } |
| 10188 | |
| 10189 | gl::Program *programObject = context->getProgram(program); |
| 10190 | |
| 10191 | if (!programObject) |
| 10192 | { |
| 10193 | if (context->getShader(program)) |
| 10194 | { |
| 10195 | return gl::error(GL_INVALID_OPERATION); |
| 10196 | } |
| 10197 | else |
| 10198 | { |
| 10199 | return gl::error(GL_INVALID_VALUE); |
| 10200 | } |
| 10201 | } |
| 10202 | |
| 10203 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10204 | |
| 10205 | // if never linked, there won't be any uniform blocks |
| 10206 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10207 | { |
| 10208 | return gl::error(GL_INVALID_VALUE); |
| 10209 | } |
| 10210 | |
| 10211 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
| 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 glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 10221 | { |
| 10222 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)", |
| 10223 | mode, first, count, instanceCount); |
| 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 | } |
| 10235 | } |
| 10236 | |
| 10237 | UNIMPLEMENTED(); |
| 10238 | } |
| 10239 | catch(std::bad_alloc&) |
| 10240 | { |
| 10241 | return gl::error(GL_OUT_OF_MEMORY); |
| 10242 | } |
| 10243 | } |
| 10244 | |
| 10245 | void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) |
| 10246 | { |
| 10247 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)", |
| 10248 | mode, count, type, indices, instanceCount); |
| 10249 | |
| 10250 | try |
| 10251 | { |
| 10252 | gl::Context *context = gl::getNonLostContext(); |
| 10253 | |
| 10254 | if (context) |
| 10255 | { |
| 10256 | if (context->getClientVersion() < 3) |
| 10257 | { |
| 10258 | return gl::error(GL_INVALID_OPERATION); |
| 10259 | } |
| 10260 | } |
| 10261 | |
| 10262 | UNIMPLEMENTED(); |
| 10263 | } |
| 10264 | catch(std::bad_alloc&) |
| 10265 | { |
| 10266 | return gl::error(GL_OUT_OF_MEMORY); |
| 10267 | } |
| 10268 | } |
| 10269 | |
| 10270 | GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags) |
| 10271 | { |
| 10272 | EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags); |
| 10273 | |
| 10274 | try |
| 10275 | { |
| 10276 | gl::Context *context = gl::getNonLostContext(); |
| 10277 | |
| 10278 | if (context) |
| 10279 | { |
| 10280 | if (context->getClientVersion() < 3) |
| 10281 | { |
| 10282 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(NULL)); |
| 10283 | } |
| 10284 | } |
| 10285 | |
| 10286 | UNIMPLEMENTED(); |
| 10287 | } |
| 10288 | catch(std::bad_alloc&) |
| 10289 | { |
| 10290 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL)); |
| 10291 | } |
| 10292 | |
| 10293 | return NULL; |
| 10294 | } |
| 10295 | |
| 10296 | GLboolean __stdcall glIsSync(GLsync sync) |
| 10297 | { |
| 10298 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10299 | |
| 10300 | try |
| 10301 | { |
| 10302 | gl::Context *context = gl::getNonLostContext(); |
| 10303 | |
| 10304 | if (context) |
| 10305 | { |
| 10306 | if (context->getClientVersion() < 3) |
| 10307 | { |
| 10308 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10309 | } |
| 10310 | } |
| 10311 | |
| 10312 | UNIMPLEMENTED(); |
| 10313 | } |
| 10314 | catch(std::bad_alloc&) |
| 10315 | { |
| 10316 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10317 | } |
| 10318 | |
| 10319 | return GL_FALSE; |
| 10320 | } |
| 10321 | |
| 10322 | void __stdcall glDeleteSync(GLsync sync) |
| 10323 | { |
| 10324 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10325 | |
| 10326 | try |
| 10327 | { |
| 10328 | gl::Context *context = gl::getNonLostContext(); |
| 10329 | |
| 10330 | if (context) |
| 10331 | { |
| 10332 | if (context->getClientVersion() < 3) |
| 10333 | { |
| 10334 | return gl::error(GL_INVALID_OPERATION); |
| 10335 | } |
| 10336 | } |
| 10337 | |
| 10338 | UNIMPLEMENTED(); |
| 10339 | } |
| 10340 | catch(std::bad_alloc&) |
| 10341 | { |
| 10342 | return gl::error(GL_OUT_OF_MEMORY); |
| 10343 | } |
| 10344 | } |
| 10345 | |
| 10346 | GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10347 | { |
| 10348 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10349 | sync, flags, timeout); |
| 10350 | |
| 10351 | try |
| 10352 | { |
| 10353 | gl::Context *context = gl::getNonLostContext(); |
| 10354 | |
| 10355 | if (context) |
| 10356 | { |
| 10357 | if (context->getClientVersion() < 3) |
| 10358 | { |
| 10359 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10360 | } |
| 10361 | } |
| 10362 | |
| 10363 | UNIMPLEMENTED(); |
| 10364 | } |
| 10365 | catch(std::bad_alloc&) |
| 10366 | { |
| 10367 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10368 | } |
| 10369 | |
| 10370 | return GL_FALSE; |
| 10371 | } |
| 10372 | |
| 10373 | void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10374 | { |
| 10375 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10376 | sync, flags, timeout); |
| 10377 | |
| 10378 | try |
| 10379 | { |
| 10380 | gl::Context *context = gl::getNonLostContext(); |
| 10381 | |
| 10382 | if (context) |
| 10383 | { |
| 10384 | if (context->getClientVersion() < 3) |
| 10385 | { |
| 10386 | return gl::error(GL_INVALID_OPERATION); |
| 10387 | } |
| 10388 | } |
| 10389 | |
| 10390 | UNIMPLEMENTED(); |
| 10391 | } |
| 10392 | catch(std::bad_alloc&) |
| 10393 | { |
| 10394 | return gl::error(GL_OUT_OF_MEMORY); |
| 10395 | } |
| 10396 | } |
| 10397 | |
| 10398 | void __stdcall glGetInteger64v(GLenum pname, GLint64* params) |
| 10399 | { |
| 10400 | EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10401 | pname, params); |
| 10402 | |
| 10403 | try |
| 10404 | { |
| 10405 | gl::Context *context = gl::getNonLostContext(); |
| 10406 | |
| 10407 | if (context) |
| 10408 | { |
| 10409 | if (context->getClientVersion() < 3) |
| 10410 | { |
| 10411 | return gl::error(GL_INVALID_OPERATION); |
| 10412 | } |
| 10413 | } |
| 10414 | |
| 10415 | UNIMPLEMENTED(); |
| 10416 | } |
| 10417 | catch(std::bad_alloc&) |
| 10418 | { |
| 10419 | return gl::error(GL_OUT_OF_MEMORY); |
| 10420 | } |
| 10421 | } |
| 10422 | |
| 10423 | void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) |
| 10424 | { |
| 10425 | EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)", |
| 10426 | sync, pname, bufSize, length, values); |
| 10427 | |
| 10428 | try |
| 10429 | { |
| 10430 | gl::Context *context = gl::getNonLostContext(); |
| 10431 | |
| 10432 | if (context) |
| 10433 | { |
| 10434 | if (context->getClientVersion() < 3) |
| 10435 | { |
| 10436 | return gl::error(GL_INVALID_OPERATION); |
| 10437 | } |
| 10438 | } |
| 10439 | |
| 10440 | UNIMPLEMENTED(); |
| 10441 | } |
| 10442 | catch(std::bad_alloc&) |
| 10443 | { |
| 10444 | return gl::error(GL_OUT_OF_MEMORY); |
| 10445 | } |
| 10446 | } |
| 10447 | |
| 10448 | void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) |
| 10449 | { |
| 10450 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)", |
| 10451 | target, index, data); |
| 10452 | |
| 10453 | try |
| 10454 | { |
| 10455 | gl::Context *context = gl::getNonLostContext(); |
| 10456 | |
| 10457 | if (context) |
| 10458 | { |
| 10459 | if (context->getClientVersion() < 3) |
| 10460 | { |
| 10461 | return gl::error(GL_INVALID_OPERATION); |
| 10462 | } |
| 10463 | } |
| 10464 | |
| 10465 | UNIMPLEMENTED(); |
| 10466 | } |
| 10467 | catch(std::bad_alloc&) |
| 10468 | { |
| 10469 | return gl::error(GL_OUT_OF_MEMORY); |
| 10470 | } |
| 10471 | } |
| 10472 | |
| 10473 | void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) |
| 10474 | { |
| 10475 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10476 | target, pname, params); |
| 10477 | |
| 10478 | try |
| 10479 | { |
| 10480 | gl::Context *context = gl::getNonLostContext(); |
| 10481 | |
| 10482 | if (context) |
| 10483 | { |
| 10484 | if (context->getClientVersion() < 3) |
| 10485 | { |
| 10486 | return gl::error(GL_INVALID_OPERATION); |
| 10487 | } |
| 10488 | } |
| 10489 | |
| 10490 | UNIMPLEMENTED(); |
| 10491 | } |
| 10492 | catch(std::bad_alloc&) |
| 10493 | { |
| 10494 | return gl::error(GL_OUT_OF_MEMORY); |
| 10495 | } |
| 10496 | } |
| 10497 | |
| 10498 | void __stdcall glGenSamplers(GLsizei count, GLuint* samplers) |
| 10499 | { |
| 10500 | EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers); |
| 10501 | |
| 10502 | try |
| 10503 | { |
| 10504 | gl::Context *context = gl::getNonLostContext(); |
| 10505 | |
| 10506 | if (context) |
| 10507 | { |
| 10508 | if (context->getClientVersion() < 3) |
| 10509 | { |
| 10510 | return gl::error(GL_INVALID_OPERATION); |
| 10511 | } |
| 10512 | } |
| 10513 | |
| 10514 | UNIMPLEMENTED(); |
| 10515 | } |
| 10516 | catch(std::bad_alloc&) |
| 10517 | { |
| 10518 | return gl::error(GL_OUT_OF_MEMORY); |
| 10519 | } |
| 10520 | } |
| 10521 | |
| 10522 | void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers) |
| 10523 | { |
| 10524 | EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers); |
| 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 | } |
| 10536 | } |
| 10537 | |
| 10538 | UNIMPLEMENTED(); |
| 10539 | } |
| 10540 | catch(std::bad_alloc&) |
| 10541 | { |
| 10542 | return gl::error(GL_OUT_OF_MEMORY); |
| 10543 | } |
| 10544 | } |
| 10545 | |
| 10546 | GLboolean __stdcall glIsSampler(GLuint sampler) |
| 10547 | { |
| 10548 | EVENT("(GLuint sampler = %u)", sampler); |
| 10549 | |
| 10550 | try |
| 10551 | { |
| 10552 | gl::Context *context = gl::getNonLostContext(); |
| 10553 | |
| 10554 | if (context) |
| 10555 | { |
| 10556 | if (context->getClientVersion() < 3) |
| 10557 | { |
| 10558 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10559 | } |
| 10560 | } |
| 10561 | |
| 10562 | UNIMPLEMENTED(); |
| 10563 | } |
| 10564 | catch(std::bad_alloc&) |
| 10565 | { |
| 10566 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10567 | } |
| 10568 | |
| 10569 | return GL_FALSE; |
| 10570 | } |
| 10571 | |
| 10572 | void __stdcall glBindSampler(GLuint unit, GLuint sampler) |
| 10573 | { |
| 10574 | EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler); |
| 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 | } |
| 10586 | } |
| 10587 | |
| 10588 | UNIMPLEMENTED(); |
| 10589 | } |
| 10590 | catch(std::bad_alloc&) |
| 10591 | { |
| 10592 | return gl::error(GL_OUT_OF_MEMORY); |
| 10593 | } |
| 10594 | } |
| 10595 | |
| 10596 | void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 10597 | { |
| 10598 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param); |
| 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 | } |
| 10610 | } |
| 10611 | |
| 10612 | UNIMPLEMENTED(); |
| 10613 | } |
| 10614 | catch(std::bad_alloc&) |
| 10615 | { |
| 10616 | return gl::error(GL_OUT_OF_MEMORY); |
| 10617 | } |
| 10618 | } |
| 10619 | |
| 10620 | void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) |
| 10621 | { |
| 10622 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLint* param = 0x%0.8p)", |
| 10623 | sampler, pname, param); |
| 10624 | |
| 10625 | try |
| 10626 | { |
| 10627 | gl::Context *context = gl::getNonLostContext(); |
| 10628 | |
| 10629 | if (context) |
| 10630 | { |
| 10631 | if (context->getClientVersion() < 3) |
| 10632 | { |
| 10633 | return gl::error(GL_INVALID_OPERATION); |
| 10634 | } |
| 10635 | } |
| 10636 | |
| 10637 | UNIMPLEMENTED(); |
| 10638 | } |
| 10639 | catch(std::bad_alloc&) |
| 10640 | { |
| 10641 | return gl::error(GL_OUT_OF_MEMORY); |
| 10642 | } |
| 10643 | } |
| 10644 | |
| 10645 | void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 10646 | { |
| 10647 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param); |
| 10648 | |
| 10649 | try |
| 10650 | { |
| 10651 | gl::Context *context = gl::getNonLostContext(); |
| 10652 | |
| 10653 | if (context) |
| 10654 | { |
| 10655 | if (context->getClientVersion() < 3) |
| 10656 | { |
| 10657 | return gl::error(GL_INVALID_OPERATION); |
| 10658 | } |
| 10659 | } |
| 10660 | |
| 10661 | UNIMPLEMENTED(); |
| 10662 | } |
| 10663 | catch(std::bad_alloc&) |
| 10664 | { |
| 10665 | return gl::error(GL_OUT_OF_MEMORY); |
| 10666 | } |
| 10667 | } |
| 10668 | |
| 10669 | void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) |
| 10670 | { |
| 10671 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLfloat* param = 0x%0.8p)", sampler, pname, param); |
| 10672 | |
| 10673 | try |
| 10674 | { |
| 10675 | gl::Context *context = gl::getNonLostContext(); |
| 10676 | |
| 10677 | if (context) |
| 10678 | { |
| 10679 | if (context->getClientVersion() < 3) |
| 10680 | { |
| 10681 | return gl::error(GL_INVALID_OPERATION); |
| 10682 | } |
| 10683 | } |
| 10684 | |
| 10685 | UNIMPLEMENTED(); |
| 10686 | } |
| 10687 | catch(std::bad_alloc&) |
| 10688 | { |
| 10689 | return gl::error(GL_OUT_OF_MEMORY); |
| 10690 | } |
| 10691 | } |
| 10692 | |
| 10693 | void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) |
| 10694 | { |
| 10695 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); |
| 10696 | |
| 10697 | try |
| 10698 | { |
| 10699 | gl::Context *context = gl::getNonLostContext(); |
| 10700 | |
| 10701 | if (context) |
| 10702 | { |
| 10703 | if (context->getClientVersion() < 3) |
| 10704 | { |
| 10705 | return gl::error(GL_INVALID_OPERATION); |
| 10706 | } |
| 10707 | } |
| 10708 | |
| 10709 | UNIMPLEMENTED(); |
| 10710 | } |
| 10711 | catch(std::bad_alloc&) |
| 10712 | { |
| 10713 | return gl::error(GL_OUT_OF_MEMORY); |
| 10714 | } |
| 10715 | } |
| 10716 | |
| 10717 | void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) |
| 10718 | { |
| 10719 | EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params); |
| 10720 | |
| 10721 | try |
| 10722 | { |
| 10723 | gl::Context *context = gl::getNonLostContext(); |
| 10724 | |
| 10725 | if (context) |
| 10726 | { |
| 10727 | if (context->getClientVersion() < 3) |
| 10728 | { |
| 10729 | return gl::error(GL_INVALID_OPERATION); |
| 10730 | } |
| 10731 | } |
| 10732 | |
| 10733 | UNIMPLEMENTED(); |
| 10734 | } |
| 10735 | catch(std::bad_alloc&) |
| 10736 | { |
| 10737 | return gl::error(GL_OUT_OF_MEMORY); |
| 10738 | } |
| 10739 | } |
| 10740 | |
| 10741 | void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor) |
| 10742 | { |
| 10743 | EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor); |
| 10744 | |
| 10745 | try |
| 10746 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 10747 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 10748 | { |
| 10749 | return gl::error(GL_INVALID_VALUE); |
| 10750 | } |
| 10751 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10752 | gl::Context *context = gl::getNonLostContext(); |
| 10753 | |
| 10754 | if (context) |
| 10755 | { |
| 10756 | if (context->getClientVersion() < 3) |
| 10757 | { |
| 10758 | return gl::error(GL_INVALID_OPERATION); |
| 10759 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10760 | |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 10761 | context->setVertexAttribDivisor(index, divisor); |
| 10762 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10763 | } |
| 10764 | catch(std::bad_alloc&) |
| 10765 | { |
| 10766 | return gl::error(GL_OUT_OF_MEMORY); |
| 10767 | } |
| 10768 | } |
| 10769 | |
| 10770 | void __stdcall glBindTransformFeedback(GLenum target, GLuint id) |
| 10771 | { |
| 10772 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 10773 | |
| 10774 | try |
| 10775 | { |
| 10776 | gl::Context *context = gl::getNonLostContext(); |
| 10777 | |
| 10778 | if (context) |
| 10779 | { |
| 10780 | if (context->getClientVersion() < 3) |
| 10781 | { |
| 10782 | return gl::error(GL_INVALID_OPERATION); |
| 10783 | } |
| 10784 | } |
| 10785 | |
| 10786 | UNIMPLEMENTED(); |
| 10787 | } |
| 10788 | catch(std::bad_alloc&) |
| 10789 | { |
| 10790 | return gl::error(GL_OUT_OF_MEMORY); |
| 10791 | } |
| 10792 | } |
| 10793 | |
| 10794 | void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) |
| 10795 | { |
| 10796 | EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids); |
| 10797 | |
| 10798 | try |
| 10799 | { |
| 10800 | gl::Context *context = gl::getNonLostContext(); |
| 10801 | |
| 10802 | if (context) |
| 10803 | { |
| 10804 | if (context->getClientVersion() < 3) |
| 10805 | { |
| 10806 | return gl::error(GL_INVALID_OPERATION); |
| 10807 | } |
| 10808 | } |
| 10809 | |
| 10810 | UNIMPLEMENTED(); |
| 10811 | } |
| 10812 | catch(std::bad_alloc&) |
| 10813 | { |
| 10814 | return gl::error(GL_OUT_OF_MEMORY); |
| 10815 | } |
| 10816 | } |
| 10817 | |
| 10818 | void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids) |
| 10819 | { |
| 10820 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 10821 | |
| 10822 | try |
| 10823 | { |
| 10824 | gl::Context *context = gl::getNonLostContext(); |
| 10825 | |
| 10826 | if (context) |
| 10827 | { |
| 10828 | if (context->getClientVersion() < 3) |
| 10829 | { |
| 10830 | return gl::error(GL_INVALID_OPERATION); |
| 10831 | } |
| 10832 | } |
| 10833 | |
| 10834 | UNIMPLEMENTED(); |
| 10835 | } |
| 10836 | catch(std::bad_alloc&) |
| 10837 | { |
| 10838 | return gl::error(GL_OUT_OF_MEMORY); |
| 10839 | } |
| 10840 | } |
| 10841 | |
| 10842 | GLboolean __stdcall glIsTransformFeedback(GLuint id) |
| 10843 | { |
| 10844 | EVENT("(GLuint id = %u)", id); |
| 10845 | |
| 10846 | try |
| 10847 | { |
| 10848 | gl::Context *context = gl::getNonLostContext(); |
| 10849 | |
| 10850 | if (context) |
| 10851 | { |
| 10852 | if (context->getClientVersion() < 3) |
| 10853 | { |
| 10854 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10855 | } |
| 10856 | } |
| 10857 | |
| 10858 | UNIMPLEMENTED(); |
| 10859 | } |
| 10860 | catch(std::bad_alloc&) |
| 10861 | { |
| 10862 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10863 | } |
| 10864 | |
| 10865 | return GL_FALSE; |
| 10866 | } |
| 10867 | |
| 10868 | void __stdcall glPauseTransformFeedback(void) |
| 10869 | { |
| 10870 | EVENT("(void)"); |
| 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 | } |
| 10882 | } |
| 10883 | |
| 10884 | UNIMPLEMENTED(); |
| 10885 | } |
| 10886 | catch(std::bad_alloc&) |
| 10887 | { |
| 10888 | return gl::error(GL_OUT_OF_MEMORY); |
| 10889 | } |
| 10890 | } |
| 10891 | |
| 10892 | void __stdcall glResumeTransformFeedback(void) |
| 10893 | { |
| 10894 | EVENT("(void)"); |
| 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 | } |
| 10906 | } |
| 10907 | |
| 10908 | UNIMPLEMENTED(); |
| 10909 | } |
| 10910 | catch(std::bad_alloc&) |
| 10911 | { |
| 10912 | return gl::error(GL_OUT_OF_MEMORY); |
| 10913 | } |
| 10914 | } |
| 10915 | |
| 10916 | void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) |
| 10917 | { |
| 10918 | EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)", |
| 10919 | program, bufSize, length, binaryFormat, binary); |
| 10920 | |
| 10921 | try |
| 10922 | { |
| 10923 | gl::Context *context = gl::getNonLostContext(); |
| 10924 | |
| 10925 | if (context) |
| 10926 | { |
| 10927 | if (context->getClientVersion() < 3) |
| 10928 | { |
| 10929 | return gl::error(GL_INVALID_OPERATION); |
| 10930 | } |
| 10931 | } |
| 10932 | |
| 10933 | UNIMPLEMENTED(); |
| 10934 | } |
| 10935 | catch(std::bad_alloc&) |
| 10936 | { |
| 10937 | return gl::error(GL_OUT_OF_MEMORY); |
| 10938 | } |
| 10939 | } |
| 10940 | |
| 10941 | void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) |
| 10942 | { |
| 10943 | EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
| 10944 | program, binaryFormat, binary, length); |
| 10945 | |
| 10946 | try |
| 10947 | { |
| 10948 | gl::Context *context = gl::getNonLostContext(); |
| 10949 | |
| 10950 | if (context) |
| 10951 | { |
| 10952 | if (context->getClientVersion() < 3) |
| 10953 | { |
| 10954 | return gl::error(GL_INVALID_OPERATION); |
| 10955 | } |
| 10956 | } |
| 10957 | |
| 10958 | UNIMPLEMENTED(); |
| 10959 | } |
| 10960 | catch(std::bad_alloc&) |
| 10961 | { |
| 10962 | return gl::error(GL_OUT_OF_MEMORY); |
| 10963 | } |
| 10964 | } |
| 10965 | |
| 10966 | void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value) |
| 10967 | { |
| 10968 | EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)", |
| 10969 | program, pname, value); |
| 10970 | |
| 10971 | try |
| 10972 | { |
| 10973 | gl::Context *context = gl::getNonLostContext(); |
| 10974 | |
| 10975 | if (context) |
| 10976 | { |
| 10977 | if (context->getClientVersion() < 3) |
| 10978 | { |
| 10979 | return gl::error(GL_INVALID_OPERATION); |
| 10980 | } |
| 10981 | } |
| 10982 | |
| 10983 | UNIMPLEMENTED(); |
| 10984 | } |
| 10985 | catch(std::bad_alloc&) |
| 10986 | { |
| 10987 | return gl::error(GL_OUT_OF_MEMORY); |
| 10988 | } |
| 10989 | } |
| 10990 | |
| 10991 | void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) |
| 10992 | { |
| 10993 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)", |
| 10994 | target, numAttachments, attachments); |
| 10995 | |
| 10996 | try |
| 10997 | { |
| 10998 | gl::Context *context = gl::getNonLostContext(); |
| 10999 | |
| 11000 | if (context) |
| 11001 | { |
| 11002 | if (context->getClientVersion() < 3) |
| 11003 | { |
| 11004 | return gl::error(GL_INVALID_OPERATION); |
| 11005 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11006 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11007 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11008 | { |
| 11009 | return; |
| 11010 | } |
| 11011 | |
| 11012 | int maxDimension = context->getMaximumRenderbufferDimension(); |
| 11013 | context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension); |
| 11014 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11015 | } |
| 11016 | catch(std::bad_alloc&) |
| 11017 | { |
| 11018 | return gl::error(GL_OUT_OF_MEMORY); |
| 11019 | } |
| 11020 | } |
| 11021 | |
| 11022 | void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) |
| 11023 | { |
| 11024 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, " |
| 11025 | "GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 11026 | target, numAttachments, attachments, x, y, width, height); |
| 11027 | |
| 11028 | try |
| 11029 | { |
| 11030 | gl::Context *context = gl::getNonLostContext(); |
| 11031 | |
| 11032 | if (context) |
| 11033 | { |
| 11034 | if (context->getClientVersion() < 3) |
| 11035 | { |
| 11036 | return gl::error(GL_INVALID_OPERATION); |
| 11037 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11038 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11039 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11040 | { |
| 11041 | return; |
| 11042 | } |
| 11043 | |
| 11044 | context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height); |
| 11045 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11046 | } |
| 11047 | catch(std::bad_alloc&) |
| 11048 | { |
| 11049 | return gl::error(GL_OUT_OF_MEMORY); |
| 11050 | } |
| 11051 | } |
| 11052 | |
| 11053 | void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 11054 | { |
| 11055 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 11056 | target, levels, internalformat, width, height); |
| 11057 | |
| 11058 | try |
| 11059 | { |
| 11060 | gl::Context *context = gl::getNonLostContext(); |
| 11061 | |
| 11062 | if (context) |
| 11063 | { |
| 11064 | if (context->getClientVersion() < 3) |
| 11065 | { |
| 11066 | return gl::error(GL_INVALID_OPERATION); |
| 11067 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11068 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11069 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 11070 | { |
| 11071 | return; |
| 11072 | } |
| 11073 | |
| 11074 | switch (target) |
| 11075 | { |
| 11076 | case GL_TEXTURE_2D: |
| 11077 | { |
| 11078 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 11079 | texture2d->storage(levels, internalformat, width, height); |
| 11080 | } |
| 11081 | break; |
| 11082 | |
| 11083 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 11084 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 11085 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 11086 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 11087 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 11088 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 11089 | { |
| 11090 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 11091 | textureCube->storage(levels, internalformat, width); |
| 11092 | } |
| 11093 | break; |
| 11094 | |
| 11095 | default: |
| 11096 | return gl::error(GL_INVALID_ENUM); |
| 11097 | } |
| 11098 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11099 | } |
| 11100 | catch(std::bad_alloc&) |
| 11101 | { |
| 11102 | return gl::error(GL_OUT_OF_MEMORY); |
| 11103 | } |
| 11104 | } |
| 11105 | |
| 11106 | void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
| 11107 | { |
| 11108 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 11109 | "GLsizei height = %d, GLsizei depth = %d)", |
| 11110 | target, levels, internalformat, width, height, depth); |
| 11111 | |
| 11112 | try |
| 11113 | { |
| 11114 | gl::Context *context = gl::getNonLostContext(); |
| 11115 | |
| 11116 | if (context) |
| 11117 | { |
| 11118 | if (context->getClientVersion() < 3) |
| 11119 | { |
| 11120 | return gl::error(GL_INVALID_OPERATION); |
| 11121 | } |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11122 | |
| 11123 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) |
| 11124 | { |
| 11125 | return; |
| 11126 | } |
| 11127 | |
| 11128 | switch (target) |
| 11129 | { |
| 11130 | case GL_TEXTURE_3D: |
| 11131 | { |
| 11132 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 11133 | texture3d->storage(levels, internalformat, width, height, depth); |
| 11134 | } |
| 11135 | break; |
| 11136 | |
| 11137 | case GL_TEXTURE_2D_ARRAY: |
| 11138 | { |
| 11139 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 11140 | texture2darray->storage(levels, internalformat, width, height, depth); |
| 11141 | } |
| 11142 | break; |
| 11143 | |
| 11144 | default: |
| 11145 | return gl::error(GL_INVALID_ENUM); |
| 11146 | } |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 11147 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11148 | } |
| 11149 | catch(std::bad_alloc&) |
| 11150 | { |
| 11151 | return gl::error(GL_OUT_OF_MEMORY); |
| 11152 | } |
| 11153 | } |
| 11154 | |
| 11155 | void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) |
| 11156 | { |
| 11157 | EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, " |
| 11158 | "GLint* params = 0x%0.8p)", |
| 11159 | target, internalformat, pname, bufSize, params); |
| 11160 | |
| 11161 | try |
| 11162 | { |
| 11163 | gl::Context *context = gl::getNonLostContext(); |
| 11164 | |
| 11165 | if (context) |
| 11166 | { |
| 11167 | if (context->getClientVersion() < 3) |
| 11168 | { |
| 11169 | return gl::error(GL_INVALID_OPERATION); |
| 11170 | } |
| 11171 | } |
| 11172 | |
| 11173 | UNIMPLEMENTED(); |
| 11174 | } |
| 11175 | catch(std::bad_alloc&) |
| 11176 | { |
| 11177 | return gl::error(GL_OUT_OF_MEMORY); |
| 11178 | } |
| 11179 | } |
| 11180 | |
| 11181 | // Extension functions |
| 11182 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11183 | void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 11184 | GLbitfield mask, GLenum filter) |
| 11185 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11186 | 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] | 11187 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, " |
| 11188 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 11189 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 11190 | |
| 11191 | try |
| 11192 | { |
| 11193 | switch (filter) |
| 11194 | { |
| 11195 | case GL_NEAREST: |
| 11196 | break; |
| 11197 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11198 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11199 | } |
| 11200 | |
| 11201 | if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0) |
| 11202 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11203 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11204 | } |
| 11205 | |
| 11206 | if (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0) |
| 11207 | { |
| 11208 | 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] | 11209 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11210 | } |
| 11211 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11212 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11213 | |
| 11214 | if (context) |
| 11215 | { |
| 11216 | if (context->getReadFramebufferHandle() == context->getDrawFramebufferHandle()) |
| 11217 | { |
| 11218 | 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] | 11219 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11220 | } |
| 11221 | |
| 11222 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask); |
| 11223 | } |
| 11224 | } |
| 11225 | catch(std::bad_alloc&) |
| 11226 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11227 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11228 | } |
| 11229 | } |
| 11230 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 11231 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, |
| 11232 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11233 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11234 | 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] | 11235 | "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] | 11236 | "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] | 11237 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 11238 | |
| 11239 | try |
| 11240 | { |
| 11241 | UNIMPLEMENTED(); // FIXME |
| 11242 | } |
| 11243 | catch(std::bad_alloc&) |
| 11244 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11245 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11246 | } |
| 11247 | } |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11248 | |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11249 | void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, |
| 11250 | GLenum *binaryFormat, void *binary) |
| 11251 | { |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11252 | 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] | 11253 | program, bufSize, length, binaryFormat, binary); |
| 11254 | |
| 11255 | try |
| 11256 | { |
| 11257 | gl::Context *context = gl::getNonLostContext(); |
| 11258 | |
| 11259 | if (context) |
| 11260 | { |
| 11261 | gl::Program *programObject = context->getProgram(program); |
| 11262 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 11263 | if (!programObject || !programObject->isLinked()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11264 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11265 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11266 | } |
| 11267 | |
| 11268 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 11269 | |
| 11270 | if (!programBinary) |
| 11271 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11272 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11273 | } |
| 11274 | |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11275 | if (!programBinary->save(binary, bufSize, length)) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11276 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11277 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11278 | } |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11279 | |
| 11280 | *binaryFormat = GL_PROGRAM_BINARY_ANGLE; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11281 | } |
| 11282 | } |
| 11283 | catch(std::bad_alloc&) |
| 11284 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11285 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11286 | } |
| 11287 | } |
| 11288 | |
| 11289 | void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat, |
| 11290 | const void *binary, GLint length) |
| 11291 | { |
| 11292 | EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)", |
| 11293 | program, binaryFormat, binary, length); |
| 11294 | |
| 11295 | try |
| 11296 | { |
| 11297 | gl::Context *context = gl::getNonLostContext(); |
| 11298 | |
| 11299 | if (context) |
| 11300 | { |
| 11301 | if (binaryFormat != GL_PROGRAM_BINARY_ANGLE) |
| 11302 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11303 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11304 | } |
| 11305 | |
| 11306 | gl::Program *programObject = context->getProgram(program); |
| 11307 | |
| 11308 | if (!programObject) |
| 11309 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11310 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11311 | } |
| 11312 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 11313 | context->setProgramBinary(program, binary, length); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11314 | } |
| 11315 | } |
| 11316 | catch(std::bad_alloc&) |
| 11317 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11318 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11319 | } |
| 11320 | } |
| 11321 | |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11322 | void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) |
| 11323 | { |
| 11324 | EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs); |
| 11325 | |
| 11326 | try |
| 11327 | { |
| 11328 | gl::Context *context = gl::getNonLostContext(); |
| 11329 | |
| 11330 | if (context) |
| 11331 | { |
| 11332 | if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets()) |
| 11333 | { |
| 11334 | return gl::error(GL_INVALID_VALUE); |
| 11335 | } |
| 11336 | |
| 11337 | if (context->getDrawFramebufferHandle() == 0) |
| 11338 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11339 | if (n != 1) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11340 | { |
| 11341 | return gl::error(GL_INVALID_OPERATION); |
| 11342 | } |
| 11343 | |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11344 | 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] | 11345 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11346 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11347 | } |
| 11348 | } |
| 11349 | else |
| 11350 | { |
| 11351 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 11352 | { |
| 11353 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 11354 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment) |
| 11355 | { |
| 11356 | return gl::error(GL_INVALID_OPERATION); |
| 11357 | } |
| 11358 | } |
| 11359 | } |
| 11360 | |
| 11361 | gl::Framebuffer *framebuffer = context->getDrawFramebuffer(); |
| 11362 | |
| 11363 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 11364 | { |
| 11365 | framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]); |
| 11366 | } |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11367 | |
| 11368 | for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++) |
| 11369 | { |
| 11370 | framebuffer->setDrawBufferState(colorAttachment, GL_NONE); |
| 11371 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11372 | } |
| 11373 | } |
| 11374 | catch (std::bad_alloc&) |
| 11375 | { |
| 11376 | return gl::error(GL_OUT_OF_MEMORY); |
| 11377 | } |
| 11378 | } |
| 11379 | |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11380 | __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) |
| 11381 | { |
| 11382 | struct Extension |
| 11383 | { |
| 11384 | const char *name; |
| 11385 | __eglMustCastToProperFunctionPointerType address; |
| 11386 | }; |
| 11387 | |
| 11388 | static const Extension glExtensions[] = |
| 11389 | { |
| 11390 | {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 11391 | {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, |
daniel@transgaming.com | 1fe96c9 | 2011-01-14 15:08:44 +0000 | [diff] [blame] | 11392 | {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 11393 | {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, |
| 11394 | {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, |
| 11395 | {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, |
| 11396 | {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, |
| 11397 | {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, |
| 11398 | {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, |
| 11399 | {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 11400 | {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE}, |
daniel@transgaming.com | 0bd1f2f | 2011-11-11 04:19:03 +0000 | [diff] [blame] | 11401 | {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT}, |
daniel@transgaming.com | 709ed11 | 2011-11-12 03:18:10 +0000 | [diff] [blame] | 11402 | {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT}, |
| 11403 | {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT}, |
| 11404 | {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT}, |
| 11405 | {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT}, |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 11406 | {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT}, |
| 11407 | {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT}, |
| 11408 | {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT}, |
| 11409 | {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT}, |
| 11410 | {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT}, |
| 11411 | {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT}, |
| 11412 | {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT}, |
shannon.woods%transgaming.com@gtempaccount.com | 77d9472 | 2013-04-13 03:34:22 +0000 | [diff] [blame] | 11413 | {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT}, |
daniel@transgaming.com | dce02fd | 2012-01-27 15:39:51 +0000 | [diff] [blame] | 11414 | {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE}, |
| 11415 | {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, |
| 11416 | {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11417 | {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, |
| 11418 | {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, }; |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11419 | |
shannon.woods@transgaming.com | d438fd4 | 2013-02-28 23:17:45 +0000 | [diff] [blame] | 11420 | for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11421 | { |
| 11422 | if (strcmp(procname, glExtensions[ext].name) == 0) |
| 11423 | { |
| 11424 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address; |
| 11425 | } |
| 11426 | } |
| 11427 | |
| 11428 | return NULL; |
| 11429 | } |
| 11430 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 11431 | // Non-public functions used by EGL |
| 11432 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11433 | bool __stdcall glBindTexImage(egl::Surface *surface) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11434 | { |
| 11435 | EVENT("(egl::Surface* surface = 0x%0.8p)", |
| 11436 | surface); |
| 11437 | |
| 11438 | try |
| 11439 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11440 | gl::Context *context = gl::getNonLostContext(); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11441 | |
| 11442 | if (context) |
| 11443 | { |
| 11444 | gl::Texture2D *textureObject = context->getTexture2D(); |
| 11445 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11446 | if (textureObject->isImmutable()) |
| 11447 | { |
| 11448 | return false; |
| 11449 | } |
| 11450 | |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11451 | if (textureObject) |
| 11452 | { |
| 11453 | textureObject->bindTexImage(surface); |
| 11454 | } |
| 11455 | } |
| 11456 | } |
| 11457 | catch(std::bad_alloc&) |
| 11458 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11459 | return gl::error(GL_OUT_OF_MEMORY, false); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11460 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11461 | |
| 11462 | return true; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11463 | } |
| 11464 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11465 | } |