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; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5109 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5110 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5111 | } |
| 5112 | |
| 5113 | switch (pname) |
| 5114 | { |
| 5115 | case GL_TEXTURE_MAG_FILTER: |
| 5116 | *params = (GLfloat)texture->getMagFilter(); |
| 5117 | break; |
| 5118 | case GL_TEXTURE_MIN_FILTER: |
| 5119 | *params = (GLfloat)texture->getMinFilter(); |
| 5120 | break; |
| 5121 | case GL_TEXTURE_WRAP_S: |
| 5122 | *params = (GLfloat)texture->getWrapS(); |
| 5123 | break; |
| 5124 | case GL_TEXTURE_WRAP_T: |
| 5125 | *params = (GLfloat)texture->getWrapT(); |
| 5126 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5127 | case GL_TEXTURE_WRAP_R: |
| 5128 | if (context->getClientVersion() < 3) |
| 5129 | { |
| 5130 | return gl::error(GL_INVALID_ENUM); |
| 5131 | } |
| 5132 | *params = (GLfloat)texture->getWrapR(); |
| 5133 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame^] | 5134 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5135 | // 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] | 5136 | *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE); |
| 5137 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame^] | 5138 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5139 | if (context->getClientVersion() < 3) |
| 5140 | { |
| 5141 | return gl::error(GL_INVALID_ENUM); |
| 5142 | } |
| 5143 | *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0); |
| 5144 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5145 | case GL_TEXTURE_USAGE_ANGLE: |
| 5146 | *params = (GLfloat)texture->getUsage(); |
| 5147 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5148 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5149 | if (!context->supportsTextureFilterAnisotropy()) |
| 5150 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5151 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5152 | } |
| 5153 | *params = (GLfloat)texture->getMaxAnisotropy(); |
| 5154 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5155 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5156 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5157 | } |
| 5158 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5159 | } |
| 5160 | catch(std::bad_alloc&) |
| 5161 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5162 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5163 | } |
| 5164 | } |
| 5165 | |
| 5166 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5167 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5168 | 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] | 5169 | |
| 5170 | try |
| 5171 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5172 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5173 | |
| 5174 | if (context) |
| 5175 | { |
| 5176 | gl::Texture *texture; |
| 5177 | |
| 5178 | switch (target) |
| 5179 | { |
| 5180 | case GL_TEXTURE_2D: |
| 5181 | texture = context->getTexture2D(); |
| 5182 | break; |
| 5183 | case GL_TEXTURE_CUBE_MAP: |
| 5184 | texture = context->getTextureCubeMap(); |
| 5185 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5186 | case GL_TEXTURE_3D: |
| 5187 | if (context->getClientVersion() < 3) |
| 5188 | { |
| 5189 | return gl::error(GL_INVALID_ENUM); |
| 5190 | } |
| 5191 | texture = context->getTexture3D(); |
| 5192 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5193 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5194 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5195 | } |
| 5196 | |
| 5197 | switch (pname) |
| 5198 | { |
| 5199 | case GL_TEXTURE_MAG_FILTER: |
| 5200 | *params = texture->getMagFilter(); |
| 5201 | break; |
| 5202 | case GL_TEXTURE_MIN_FILTER: |
| 5203 | *params = texture->getMinFilter(); |
| 5204 | break; |
| 5205 | case GL_TEXTURE_WRAP_S: |
| 5206 | *params = texture->getWrapS(); |
| 5207 | break; |
| 5208 | case GL_TEXTURE_WRAP_T: |
| 5209 | *params = texture->getWrapT(); |
| 5210 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5211 | case GL_TEXTURE_WRAP_R: |
| 5212 | if (context->getClientVersion() < 3) |
| 5213 | { |
| 5214 | return gl::error(GL_INVALID_ENUM); |
| 5215 | } |
| 5216 | *params = texture->getWrapR(); |
| 5217 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame^] | 5218 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5219 | // 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] | 5220 | *params = texture->isImmutable() ? GL_TRUE : GL_FALSE; |
| 5221 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame^] | 5222 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5223 | if (context->getClientVersion() < 3) |
| 5224 | { |
| 5225 | return gl::error(GL_INVALID_ENUM); |
| 5226 | } |
| 5227 | *params = texture->isImmutable() ? texture->levelCount() : 0; |
| 5228 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5229 | case GL_TEXTURE_USAGE_ANGLE: |
| 5230 | *params = texture->getUsage(); |
| 5231 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5232 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5233 | if (!context->supportsTextureFilterAnisotropy()) |
| 5234 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5235 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5236 | } |
| 5237 | *params = (GLint)texture->getMaxAnisotropy(); |
| 5238 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5239 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5240 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5241 | } |
| 5242 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5243 | } |
| 5244 | catch(std::bad_alloc&) |
| 5245 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5246 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5247 | } |
| 5248 | } |
| 5249 | |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5250 | void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
| 5251 | { |
| 5252 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)", |
| 5253 | program, location, bufSize, params); |
| 5254 | |
| 5255 | try |
| 5256 | { |
| 5257 | if (bufSize < 0) |
| 5258 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5259 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5260 | } |
| 5261 | |
| 5262 | gl::Context *context = gl::getNonLostContext(); |
| 5263 | |
| 5264 | if (context) |
| 5265 | { |
| 5266 | if (program == 0) |
| 5267 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5268 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5269 | } |
| 5270 | |
| 5271 | gl::Program *programObject = context->getProgram(program); |
| 5272 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5273 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5274 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5275 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5276 | } |
| 5277 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5278 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5279 | if (!programBinary) |
| 5280 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5281 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5282 | } |
| 5283 | |
| 5284 | if (!programBinary->getUniformfv(location, &bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5285 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5286 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5287 | } |
| 5288 | } |
| 5289 | } |
| 5290 | catch(std::bad_alloc&) |
| 5291 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5292 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5293 | } |
| 5294 | } |
| 5295 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5296 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 5297 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5298 | 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] | 5299 | |
| 5300 | try |
| 5301 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5302 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5303 | |
| 5304 | if (context) |
| 5305 | { |
| 5306 | if (program == 0) |
| 5307 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5308 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5309 | } |
| 5310 | |
| 5311 | gl::Program *programObject = context->getProgram(program); |
| 5312 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5313 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5314 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5315 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5316 | } |
| 5317 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5318 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5319 | if (!programBinary) |
| 5320 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5321 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5322 | } |
| 5323 | |
| 5324 | if (!programBinary->getUniformfv(location, NULL, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5325 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5326 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5327 | } |
| 5328 | } |
| 5329 | } |
| 5330 | catch(std::bad_alloc&) |
| 5331 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5332 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5333 | } |
| 5334 | } |
| 5335 | |
| 5336 | void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) |
| 5337 | { |
| 5338 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)", |
| 5339 | program, location, bufSize, params); |
| 5340 | |
| 5341 | try |
| 5342 | { |
| 5343 | if (bufSize < 0) |
| 5344 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5345 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5346 | } |
| 5347 | |
| 5348 | gl::Context *context = gl::getNonLostContext(); |
| 5349 | |
| 5350 | if (context) |
| 5351 | { |
| 5352 | if (program == 0) |
| 5353 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5354 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5355 | } |
| 5356 | |
| 5357 | gl::Program *programObject = context->getProgram(program); |
| 5358 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5359 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5360 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5361 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5362 | } |
| 5363 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5364 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5365 | if (!programBinary) |
| 5366 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5367 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5368 | } |
| 5369 | |
| 5370 | if (!programBinary->getUniformiv(location, &bufSize, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5371 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5372 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5373 | } |
| 5374 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5375 | } |
| 5376 | catch(std::bad_alloc&) |
| 5377 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5378 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5379 | } |
| 5380 | } |
| 5381 | |
| 5382 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 5383 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5384 | 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] | 5385 | |
| 5386 | try |
| 5387 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5388 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5389 | |
| 5390 | if (context) |
| 5391 | { |
| 5392 | if (program == 0) |
| 5393 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5394 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5395 | } |
| 5396 | |
| 5397 | gl::Program *programObject = context->getProgram(program); |
| 5398 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5399 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5400 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5401 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5402 | } |
| 5403 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5404 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5405 | if (!programBinary) |
| 5406 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5407 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5408 | } |
| 5409 | |
| 5410 | if (!programBinary->getUniformiv(location, NULL, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5411 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5412 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5413 | } |
| 5414 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5415 | } |
| 5416 | catch(std::bad_alloc&) |
| 5417 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5418 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5419 | } |
| 5420 | } |
| 5421 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5422 | int __stdcall glGetUniformLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5423 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5424 | 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] | 5425 | |
| 5426 | try |
| 5427 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5428 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5429 | |
| 5430 | if (strstr(name, "gl_") == name) |
| 5431 | { |
| 5432 | return -1; |
| 5433 | } |
| 5434 | |
| 5435 | if (context) |
| 5436 | { |
| 5437 | gl::Program *programObject = context->getProgram(program); |
| 5438 | |
| 5439 | if (!programObject) |
| 5440 | { |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5441 | if (context->getShader(program)) |
| 5442 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5443 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5444 | } |
| 5445 | else |
| 5446 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5447 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5448 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5449 | } |
| 5450 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5451 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5452 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5453 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5454 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5455 | } |
| 5456 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5457 | return programBinary->getUniformLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5458 | } |
| 5459 | } |
| 5460 | catch(std::bad_alloc&) |
| 5461 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5462 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5463 | } |
| 5464 | |
| 5465 | return -1; |
| 5466 | } |
| 5467 | |
| 5468 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 5469 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5470 | 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] | 5471 | |
| 5472 | try |
| 5473 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5474 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5475 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5476 | if (context) |
| 5477 | { |
| 5478 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5479 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5480 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5481 | } |
| 5482 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5483 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5484 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5485 | switch (pname) |
| 5486 | { |
| 5487 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5488 | *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5489 | break; |
| 5490 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5491 | *params = (GLfloat)attribState.mSize; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5492 | break; |
| 5493 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5494 | *params = (GLfloat)attribState.mStride; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5495 | break; |
| 5496 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5497 | *params = (GLfloat)attribState.mType; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5498 | break; |
| 5499 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5500 | *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5501 | break; |
| 5502 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 5503 | *params = (GLfloat)attribState.mBoundBuffer.id(); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5504 | break; |
| 5505 | case GL_CURRENT_VERTEX_ATTRIB: |
| 5506 | for (int i = 0; i < 4; ++i) |
| 5507 | { |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame] | 5508 | params[i] = attribState.mCurrentValue.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5509 | } |
| 5510 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 5511 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 5512 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 5513 | // the same constant. |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 5514 | *params = (GLfloat)attribState.mDivisor; |
| 5515 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5516 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5517 | } |
| 5518 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5519 | } |
| 5520 | catch(std::bad_alloc&) |
| 5521 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5522 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5523 | } |
| 5524 | } |
| 5525 | |
| 5526 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 5527 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5528 | 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] | 5529 | |
| 5530 | try |
| 5531 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5532 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5533 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5534 | if (context) |
| 5535 | { |
| 5536 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5537 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5538 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5539 | } |
| 5540 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5541 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5542 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5543 | switch (pname) |
| 5544 | { |
| 5545 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5546 | *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5547 | break; |
| 5548 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5549 | *params = attribState.mSize; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5550 | break; |
| 5551 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5552 | *params = attribState.mStride; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5553 | break; |
| 5554 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5555 | *params = attribState.mType; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5556 | break; |
| 5557 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5558 | *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5559 | break; |
| 5560 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 5561 | *params = attribState.mBoundBuffer.id(); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5562 | break; |
| 5563 | case GL_CURRENT_VERTEX_ATTRIB: |
| 5564 | for (int i = 0; i < 4; ++i) |
| 5565 | { |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame] | 5566 | float currentValue = attribState.mCurrentValue.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5567 | params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f)); |
| 5568 | } |
| 5569 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 5570 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 5571 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 5572 | // the same constant. |
| 5573 | 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] | 5574 | *params = (GLint)attribState.mDivisor; |
| 5575 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5576 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5577 | } |
| 5578 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5579 | } |
| 5580 | catch(std::bad_alloc&) |
| 5581 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5582 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5583 | } |
| 5584 | } |
| 5585 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5586 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5587 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5588 | 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] | 5589 | |
| 5590 | try |
| 5591 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5592 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5593 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5594 | if (context) |
| 5595 | { |
| 5596 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5597 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5598 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5599 | } |
| 5600 | |
| 5601 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) |
| 5602 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5603 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5604 | } |
| 5605 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5606 | *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index)); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5607 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5608 | } |
| 5609 | catch(std::bad_alloc&) |
| 5610 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5611 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5612 | } |
| 5613 | } |
| 5614 | |
| 5615 | void __stdcall glHint(GLenum target, GLenum mode) |
| 5616 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5617 | EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5618 | |
| 5619 | try |
| 5620 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5621 | switch (mode) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5622 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5623 | case GL_FASTEST: |
| 5624 | case GL_NICEST: |
| 5625 | case GL_DONT_CARE: |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5626 | break; |
| 5627 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5628 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5629 | } |
| 5630 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5631 | gl::Context *context = gl::getNonLostContext(); |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5632 | switch (target) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5633 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5634 | case GL_GENERATE_MIPMAP_HINT: |
| 5635 | if (context) context->setGenerateMipmapHint(mode); |
| 5636 | break; |
| 5637 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 5638 | if (context) context->setFragmentShaderDerivativeHint(mode); |
| 5639 | break; |
| 5640 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5641 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5642 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5643 | } |
| 5644 | catch(std::bad_alloc&) |
| 5645 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5646 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5647 | } |
| 5648 | } |
| 5649 | |
| 5650 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 5651 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5652 | EVENT("(GLuint buffer = %d)", buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5653 | |
| 5654 | try |
| 5655 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5656 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5657 | |
| 5658 | if (context && buffer) |
| 5659 | { |
| 5660 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 5661 | |
| 5662 | if (bufferObject) |
| 5663 | { |
| 5664 | return GL_TRUE; |
| 5665 | } |
| 5666 | } |
| 5667 | } |
| 5668 | catch(std::bad_alloc&) |
| 5669 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5670 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5671 | } |
| 5672 | |
| 5673 | return GL_FALSE; |
| 5674 | } |
| 5675 | |
| 5676 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 5677 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5678 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5679 | |
| 5680 | try |
| 5681 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5682 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5683 | |
| 5684 | if (context) |
| 5685 | { |
| 5686 | switch (cap) |
| 5687 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5688 | case GL_CULL_FACE: return context->isCullFaceEnabled(); |
| 5689 | case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled(); |
| 5690 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled(); |
| 5691 | case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled(); |
| 5692 | case GL_SCISSOR_TEST: return context->isScissorTestEnabled(); |
| 5693 | case GL_STENCIL_TEST: return context->isStencilTestEnabled(); |
| 5694 | case GL_DEPTH_TEST: return context->isDepthTestEnabled(); |
| 5695 | case GL_BLEND: return context->isBlendEnabled(); |
| 5696 | case GL_DITHER: return context->isDitherEnabled(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5697 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5698 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5699 | } |
| 5700 | } |
| 5701 | } |
| 5702 | catch(std::bad_alloc&) |
| 5703 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5704 | return gl::error(GL_OUT_OF_MEMORY, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5705 | } |
| 5706 | |
| 5707 | return false; |
| 5708 | } |
| 5709 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 5710 | GLboolean __stdcall glIsFenceNV(GLuint fence) |
| 5711 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5712 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5713 | |
| 5714 | try |
| 5715 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5716 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5717 | |
| 5718 | if (context) |
| 5719 | { |
| 5720 | gl::Fence *fenceObject = context->getFence(fence); |
| 5721 | |
| 5722 | if (fenceObject == NULL) |
| 5723 | { |
| 5724 | return GL_FALSE; |
| 5725 | } |
| 5726 | |
| 5727 | return fenceObject->isFence(); |
| 5728 | } |
| 5729 | } |
| 5730 | catch(std::bad_alloc&) |
| 5731 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5732 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5733 | } |
| 5734 | |
| 5735 | return GL_FALSE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 5736 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 5737 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5738 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 5739 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5740 | EVENT("(GLuint framebuffer = %d)", framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5741 | |
| 5742 | try |
| 5743 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5744 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5745 | |
| 5746 | if (context && framebuffer) |
| 5747 | { |
| 5748 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 5749 | |
| 5750 | if (framebufferObject) |
| 5751 | { |
| 5752 | return GL_TRUE; |
| 5753 | } |
| 5754 | } |
| 5755 | } |
| 5756 | catch(std::bad_alloc&) |
| 5757 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5758 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5759 | } |
| 5760 | |
| 5761 | return GL_FALSE; |
| 5762 | } |
| 5763 | |
| 5764 | GLboolean __stdcall glIsProgram(GLuint program) |
| 5765 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5766 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5767 | |
| 5768 | try |
| 5769 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5770 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5771 | |
| 5772 | if (context && program) |
| 5773 | { |
| 5774 | gl::Program *programObject = context->getProgram(program); |
| 5775 | |
| 5776 | if (programObject) |
| 5777 | { |
| 5778 | return GL_TRUE; |
| 5779 | } |
| 5780 | } |
| 5781 | } |
| 5782 | catch(std::bad_alloc&) |
| 5783 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5784 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5785 | } |
| 5786 | |
| 5787 | return GL_FALSE; |
| 5788 | } |
| 5789 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5790 | GLboolean __stdcall glIsQueryEXT(GLuint id) |
| 5791 | { |
| 5792 | EVENT("(GLuint id = %d)", id); |
| 5793 | |
| 5794 | try |
| 5795 | { |
| 5796 | if (id == 0) |
| 5797 | { |
| 5798 | return GL_FALSE; |
| 5799 | } |
| 5800 | |
| 5801 | gl::Context *context = gl::getNonLostContext(); |
| 5802 | |
| 5803 | if (context) |
| 5804 | { |
| 5805 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 5806 | |
| 5807 | if (queryObject) |
| 5808 | { |
| 5809 | return GL_TRUE; |
| 5810 | } |
| 5811 | } |
| 5812 | } |
| 5813 | catch(std::bad_alloc&) |
| 5814 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5815 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5816 | } |
| 5817 | |
| 5818 | return GL_FALSE; |
| 5819 | } |
| 5820 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5821 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 5822 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5823 | EVENT("(GLuint renderbuffer = %d)", renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5824 | |
| 5825 | try |
| 5826 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5827 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5828 | |
| 5829 | if (context && renderbuffer) |
| 5830 | { |
| 5831 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 5832 | |
| 5833 | if (renderbufferObject) |
| 5834 | { |
| 5835 | return GL_TRUE; |
| 5836 | } |
| 5837 | } |
| 5838 | } |
| 5839 | catch(std::bad_alloc&) |
| 5840 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5841 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5842 | } |
| 5843 | |
| 5844 | return GL_FALSE; |
| 5845 | } |
| 5846 | |
| 5847 | GLboolean __stdcall glIsShader(GLuint shader) |
| 5848 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5849 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5850 | |
| 5851 | try |
| 5852 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5853 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5854 | |
| 5855 | if (context && shader) |
| 5856 | { |
| 5857 | gl::Shader *shaderObject = context->getShader(shader); |
| 5858 | |
| 5859 | if (shaderObject) |
| 5860 | { |
| 5861 | return GL_TRUE; |
| 5862 | } |
| 5863 | } |
| 5864 | } |
| 5865 | catch(std::bad_alloc&) |
| 5866 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5867 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5868 | } |
| 5869 | |
| 5870 | return GL_FALSE; |
| 5871 | } |
| 5872 | |
| 5873 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 5874 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5875 | EVENT("(GLuint texture = %d)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5876 | |
| 5877 | try |
| 5878 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5879 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5880 | |
| 5881 | if (context && texture) |
| 5882 | { |
| 5883 | gl::Texture *textureObject = context->getTexture(texture); |
| 5884 | |
| 5885 | if (textureObject) |
| 5886 | { |
| 5887 | return GL_TRUE; |
| 5888 | } |
| 5889 | } |
| 5890 | } |
| 5891 | catch(std::bad_alloc&) |
| 5892 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5893 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5894 | } |
| 5895 | |
| 5896 | return GL_FALSE; |
| 5897 | } |
| 5898 | |
| 5899 | void __stdcall glLineWidth(GLfloat width) |
| 5900 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5901 | EVENT("(GLfloat width = %f)", width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5902 | |
| 5903 | try |
| 5904 | { |
| 5905 | if (width <= 0.0f) |
| 5906 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5907 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5908 | } |
| 5909 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5910 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 5911 | |
| 5912 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5913 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5914 | context->setLineWidth(width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5915 | } |
| 5916 | } |
| 5917 | catch(std::bad_alloc&) |
| 5918 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5919 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5920 | } |
| 5921 | } |
| 5922 | |
| 5923 | void __stdcall glLinkProgram(GLuint program) |
| 5924 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5925 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5926 | |
| 5927 | try |
| 5928 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5929 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5930 | |
| 5931 | if (context) |
| 5932 | { |
| 5933 | gl::Program *programObject = context->getProgram(program); |
| 5934 | |
| 5935 | if (!programObject) |
| 5936 | { |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 5937 | if (context->getShader(program)) |
| 5938 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5939 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 5940 | } |
| 5941 | else |
| 5942 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5943 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 5944 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5945 | } |
| 5946 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 5947 | context->linkProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5948 | } |
| 5949 | } |
| 5950 | catch(std::bad_alloc&) |
| 5951 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5952 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5953 | } |
| 5954 | } |
| 5955 | |
| 5956 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 5957 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5958 | EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5959 | |
| 5960 | try |
| 5961 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5962 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 5963 | |
| 5964 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5965 | { |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 5966 | switch (pname) |
| 5967 | { |
| 5968 | case GL_UNPACK_ALIGNMENT: |
| 5969 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 5970 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5971 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 5972 | } |
| 5973 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5974 | context->setUnpackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 5975 | break; |
| 5976 | |
| 5977 | case GL_PACK_ALIGNMENT: |
| 5978 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 5979 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5980 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 5981 | } |
| 5982 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5983 | context->setPackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 5984 | break; |
| 5985 | |
bsalomon@google.com | 56d46ab | 2011-11-23 14:53:10 +0000 | [diff] [blame] | 5986 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 5987 | context->setPackReverseRowOrder(param != 0); |
| 5988 | break; |
| 5989 | |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 5990 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5991 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 5992 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5993 | } |
| 5994 | } |
| 5995 | catch(std::bad_alloc&) |
| 5996 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5997 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5998 | } |
| 5999 | } |
| 6000 | |
| 6001 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 6002 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6003 | EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6004 | |
| 6005 | try |
| 6006 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6007 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aede630 | 2010-04-29 03:35:48 +0000 | [diff] [blame] | 6008 | |
| 6009 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6010 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6011 | context->setPolygonOffsetParams(factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6012 | } |
| 6013 | } |
| 6014 | catch(std::bad_alloc&) |
| 6015 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6016 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6017 | } |
| 6018 | } |
| 6019 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6020 | void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6021 | GLenum format, GLenum type, GLsizei bufSize, |
| 6022 | GLvoid *data) |
| 6023 | { |
| 6024 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
| 6025 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)", |
| 6026 | x, y, width, height, format, type, bufSize, data); |
| 6027 | |
| 6028 | try |
| 6029 | { |
| 6030 | if (width < 0 || height < 0 || bufSize < 0) |
| 6031 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6032 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6033 | } |
| 6034 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6035 | gl::Context *context = gl::getNonLostContext(); |
| 6036 | |
| 6037 | if (context) |
| 6038 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6039 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6040 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6041 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6042 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6043 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6044 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6045 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6046 | return; |
| 6047 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6048 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6049 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6050 | |
| 6051 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6052 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6053 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6054 | } |
| 6055 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6056 | context->readPixels(x, y, width, height, format, type, &bufSize, data); |
| 6057 | } |
| 6058 | } |
| 6059 | catch(std::bad_alloc&) |
| 6060 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6061 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6062 | } |
| 6063 | } |
| 6064 | |
| 6065 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6066 | GLenum format, GLenum type, GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6067 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6068 | 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] | 6069 | "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] | 6070 | x, y, width, height, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6071 | |
| 6072 | try |
| 6073 | { |
| 6074 | if (width < 0 || height < 0) |
| 6075 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6076 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6077 | } |
| 6078 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6079 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6080 | |
| 6081 | if (context) |
| 6082 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6083 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6084 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6085 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6086 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6087 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6088 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6089 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6090 | return; |
| 6091 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6092 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6093 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6094 | |
| 6095 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6096 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6097 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6098 | } |
| 6099 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6100 | context->readPixels(x, y, width, height, format, type, NULL, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6101 | } |
| 6102 | } |
| 6103 | catch(std::bad_alloc&) |
| 6104 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6105 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6106 | } |
| 6107 | } |
| 6108 | |
| 6109 | void __stdcall glReleaseShaderCompiler(void) |
| 6110 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6111 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6112 | |
| 6113 | try |
| 6114 | { |
| 6115 | gl::Shader::releaseCompiler(); |
| 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 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6123 | 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] | 6124 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6125 | 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] | 6126 | target, samples, internalformat, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6127 | |
| 6128 | try |
| 6129 | { |
| 6130 | switch (target) |
| 6131 | { |
| 6132 | case GL_RENDERBUFFER: |
| 6133 | break; |
| 6134 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6135 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6136 | } |
| 6137 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6138 | if (width < 0 || height < 0 || samples < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6139 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6140 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6141 | } |
| 6142 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6143 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6144 | |
| 6145 | if (context) |
| 6146 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6147 | if (!gl::IsValidInternalFormat(internalformat, context)) |
| 6148 | { |
| 6149 | return gl::error(GL_INVALID_ENUM); |
| 6150 | } |
| 6151 | |
| 6152 | if (!gl::IsColorRenderingSupported(internalformat, context) && |
| 6153 | !gl::IsDepthRenderingSupported(internalformat, context) && |
| 6154 | !gl::IsStencilRenderingSupported(internalformat, context)) |
| 6155 | { |
| 6156 | return gl::error(GL_INVALID_ENUM); |
| 6157 | } |
| 6158 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6159 | if (width > context->getMaximumRenderbufferDimension() || |
| 6160 | height > context->getMaximumRenderbufferDimension() || |
| 6161 | samples > context->getMaxSupportedSamples()) |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6162 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6163 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6164 | } |
| 6165 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 6166 | GLuint handle = context->getRenderbufferHandle(); |
| 6167 | if (handle == 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6168 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6169 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6170 | } |
| 6171 | |
| 6172 | switch (internalformat) |
| 6173 | { |
| 6174 | case GL_DEPTH_COMPONENT16: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6175 | case GL_RGBA4: |
| 6176 | case GL_RGB5_A1: |
| 6177 | case GL_RGB565: |
daniel@transgaming.com | 6397754 | 2010-08-24 19:21:02 +0000 | [diff] [blame] | 6178 | case GL_RGB8_OES: |
| 6179 | case GL_RGBA8_OES: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6180 | case GL_STENCIL_INDEX8: |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 6181 | case GL_DEPTH24_STENCIL8_OES: |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 6182 | break; |
| 6183 | case GL_SRGB8_ALPHA8: |
| 6184 | case GL_RGB10_A2: |
| 6185 | case GL_RG8: |
| 6186 | case GL_R8: |
| 6187 | if (context->getClientVersion() < 3) |
| 6188 | { |
| 6189 | return gl::error(GL_INVALID_ENUM); |
| 6190 | } |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 6191 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6192 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6193 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6194 | } |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 6195 | |
| 6196 | context->setRenderbufferStorage(width, height, internalformat, samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6197 | } |
| 6198 | } |
| 6199 | catch(std::bad_alloc&) |
| 6200 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6201 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6202 | } |
| 6203 | } |
| 6204 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6205 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 6206 | { |
| 6207 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height); |
| 6208 | } |
| 6209 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6210 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 6211 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6212 | EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6213 | |
| 6214 | try |
| 6215 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6216 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6217 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6218 | if (context) |
| 6219 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 6220 | context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6221 | } |
| 6222 | } |
| 6223 | catch(std::bad_alloc&) |
| 6224 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6225 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6226 | } |
| 6227 | } |
| 6228 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6229 | void __stdcall glSetFenceNV(GLuint fence, GLenum condition) |
| 6230 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6231 | EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6232 | |
| 6233 | try |
| 6234 | { |
| 6235 | if (condition != GL_ALL_COMPLETED_NV) |
| 6236 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6237 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6238 | } |
| 6239 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6240 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6241 | |
| 6242 | if (context) |
| 6243 | { |
| 6244 | gl::Fence *fenceObject = context->getFence(fence); |
| 6245 | |
| 6246 | if (fenceObject == NULL) |
| 6247 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6248 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6249 | } |
| 6250 | |
| 6251 | fenceObject->setFence(condition); |
| 6252 | } |
| 6253 | } |
| 6254 | catch(std::bad_alloc&) |
| 6255 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6256 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6257 | } |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6258 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6259 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6260 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 6261 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6262 | 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] | 6263 | |
| 6264 | try |
| 6265 | { |
| 6266 | if (width < 0 || height < 0) |
| 6267 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6268 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6269 | } |
| 6270 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6271 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6272 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6273 | if (context) |
| 6274 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6275 | context->setScissorParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6276 | } |
| 6277 | } |
| 6278 | catch(std::bad_alloc&) |
| 6279 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6280 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6281 | } |
| 6282 | } |
| 6283 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6284 | 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] | 6285 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6286 | 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] | 6287 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 6288 | n, shaders, binaryformat, binary, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6289 | |
| 6290 | try |
| 6291 | { |
daniel@transgaming.com | d1f667f | 2010-04-29 03:38:52 +0000 | [diff] [blame] | 6292 | // No binary shader formats are supported. |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6293 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6294 | } |
| 6295 | catch(std::bad_alloc&) |
| 6296 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6297 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6298 | } |
| 6299 | } |
| 6300 | |
shannon.woods%transgaming.com@gtempaccount.com | 5f33933 | 2013-04-13 03:29:02 +0000 | [diff] [blame] | 6301 | 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] | 6302 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6303 | 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] | 6304 | shader, count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6305 | |
| 6306 | try |
| 6307 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6308 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6309 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6310 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6311 | } |
| 6312 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6313 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6314 | |
| 6315 | if (context) |
| 6316 | { |
| 6317 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6318 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6319 | if (!shaderObject) |
| 6320 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6321 | if (context->getProgram(shader)) |
| 6322 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6323 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6324 | } |
| 6325 | else |
| 6326 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6327 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6328 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6329 | } |
| 6330 | |
| 6331 | shaderObject->setSource(count, string, length); |
| 6332 | } |
| 6333 | } |
| 6334 | catch(std::bad_alloc&) |
| 6335 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6336 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6337 | } |
| 6338 | } |
| 6339 | |
| 6340 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 6341 | { |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6342 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6343 | } |
| 6344 | |
| 6345 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 6346 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6347 | 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] | 6348 | |
| 6349 | try |
| 6350 | { |
| 6351 | switch (face) |
| 6352 | { |
| 6353 | case GL_FRONT: |
| 6354 | case GL_BACK: |
| 6355 | case GL_FRONT_AND_BACK: |
| 6356 | break; |
| 6357 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6358 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6359 | } |
| 6360 | |
| 6361 | switch (func) |
| 6362 | { |
| 6363 | case GL_NEVER: |
| 6364 | case GL_ALWAYS: |
| 6365 | case GL_LESS: |
| 6366 | case GL_LEQUAL: |
| 6367 | case GL_EQUAL: |
| 6368 | case GL_GEQUAL: |
| 6369 | case GL_GREATER: |
| 6370 | case GL_NOTEQUAL: |
| 6371 | break; |
| 6372 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6373 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6374 | } |
| 6375 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6376 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6377 | |
| 6378 | if (context) |
| 6379 | { |
| 6380 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6381 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6382 | context->setStencilParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6383 | } |
| 6384 | |
| 6385 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6386 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6387 | context->setStencilBackParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6388 | } |
| 6389 | } |
| 6390 | } |
| 6391 | catch(std::bad_alloc&) |
| 6392 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6393 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6394 | } |
| 6395 | } |
| 6396 | |
| 6397 | void __stdcall glStencilMask(GLuint mask) |
| 6398 | { |
| 6399 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 6400 | } |
| 6401 | |
| 6402 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 6403 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6404 | EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6405 | |
| 6406 | try |
| 6407 | { |
| 6408 | switch (face) |
| 6409 | { |
| 6410 | case GL_FRONT: |
| 6411 | case GL_BACK: |
| 6412 | case GL_FRONT_AND_BACK: |
| 6413 | break; |
| 6414 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6415 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6416 | } |
| 6417 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6418 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6419 | |
| 6420 | if (context) |
| 6421 | { |
| 6422 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6423 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6424 | context->setStencilWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6425 | } |
| 6426 | |
| 6427 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6428 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6429 | context->setStencilBackWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6430 | } |
| 6431 | } |
| 6432 | } |
| 6433 | catch(std::bad_alloc&) |
| 6434 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6435 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6436 | } |
| 6437 | } |
| 6438 | |
| 6439 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 6440 | { |
| 6441 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 6442 | } |
| 6443 | |
| 6444 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 6445 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6446 | 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] | 6447 | face, fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6448 | |
| 6449 | try |
| 6450 | { |
| 6451 | switch (face) |
| 6452 | { |
| 6453 | case GL_FRONT: |
| 6454 | case GL_BACK: |
| 6455 | case GL_FRONT_AND_BACK: |
| 6456 | break; |
| 6457 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6458 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6459 | } |
| 6460 | |
| 6461 | switch (fail) |
| 6462 | { |
| 6463 | case GL_ZERO: |
| 6464 | case GL_KEEP: |
| 6465 | case GL_REPLACE: |
| 6466 | case GL_INCR: |
| 6467 | case GL_DECR: |
| 6468 | case GL_INVERT: |
| 6469 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6470 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6471 | break; |
| 6472 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6473 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6474 | } |
| 6475 | |
| 6476 | switch (zfail) |
| 6477 | { |
| 6478 | case GL_ZERO: |
| 6479 | case GL_KEEP: |
| 6480 | case GL_REPLACE: |
| 6481 | case GL_INCR: |
| 6482 | case GL_DECR: |
| 6483 | case GL_INVERT: |
| 6484 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6485 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6486 | break; |
| 6487 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6488 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6489 | } |
| 6490 | |
| 6491 | switch (zpass) |
| 6492 | { |
| 6493 | case GL_ZERO: |
| 6494 | case GL_KEEP: |
| 6495 | case GL_REPLACE: |
| 6496 | case GL_INCR: |
| 6497 | case GL_DECR: |
| 6498 | case GL_INVERT: |
| 6499 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6500 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6501 | break; |
| 6502 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6503 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6504 | } |
| 6505 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6506 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6507 | |
| 6508 | if (context) |
| 6509 | { |
| 6510 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6511 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6512 | context->setStencilOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6513 | } |
| 6514 | |
| 6515 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6516 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6517 | context->setStencilBackOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6518 | } |
| 6519 | } |
| 6520 | } |
| 6521 | catch(std::bad_alloc&) |
| 6522 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6523 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6524 | } |
| 6525 | } |
| 6526 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6527 | GLboolean __stdcall glTestFenceNV(GLuint fence) |
| 6528 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6529 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6530 | |
| 6531 | try |
| 6532 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6533 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6534 | |
| 6535 | if (context) |
| 6536 | { |
| 6537 | gl::Fence *fenceObject = context->getFence(fence); |
| 6538 | |
| 6539 | if (fenceObject == NULL) |
| 6540 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6541 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6542 | } |
| 6543 | |
| 6544 | return fenceObject->testFence(); |
| 6545 | } |
| 6546 | } |
| 6547 | catch(std::bad_alloc&) |
| 6548 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6549 | gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6550 | } |
| 6551 | |
| 6552 | return GL_TRUE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6553 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6554 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6555 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, |
| 6556 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6557 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6558 | 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] | 6559 | "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] | 6560 | target, level, internalformat, width, height, border, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6561 | |
| 6562 | try |
| 6563 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6564 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6565 | |
| 6566 | if (context) |
| 6567 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6568 | if (context->getClientVersion() < 3 && |
| 6569 | !validateES2TexImageParameters(context, target, level, internalformat, false, false, |
| 6570 | 0, 0, width, height, border, format, type, pixels)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 6571 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6572 | return; |
| 6573 | } |
| 6574 | |
| 6575 | if (context->getClientVersion() >= 3 && |
| 6576 | !validateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 6577 | 0, 0, 0, width, height, 1, border, format, type)) |
| 6578 | { |
| 6579 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 6580 | } |
| 6581 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6582 | switch (target) |
| 6583 | { |
| 6584 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6585 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6586 | gl::Texture2D *texture = context->getTexture2D(); |
| 6587 | texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6588 | } |
| 6589 | break; |
| 6590 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6591 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6592 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 6593 | texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6594 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6595 | break; |
| 6596 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 6597 | { |
| 6598 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6599 | texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6600 | } |
| 6601 | break; |
| 6602 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 6603 | { |
| 6604 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6605 | texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6606 | } |
| 6607 | break; |
| 6608 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 6609 | { |
| 6610 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6611 | texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6612 | } |
| 6613 | break; |
| 6614 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 6615 | { |
| 6616 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6617 | texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6618 | } |
| 6619 | break; |
| 6620 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 6621 | { |
| 6622 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6623 | texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6624 | } |
| 6625 | break; |
| 6626 | default: UNREACHABLE(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6627 | } |
| 6628 | } |
| 6629 | } |
| 6630 | catch(std::bad_alloc&) |
| 6631 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6632 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6633 | } |
| 6634 | } |
| 6635 | |
| 6636 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 6637 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6638 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param); |
| 6639 | |
| 6640 | try |
| 6641 | { |
| 6642 | gl::Context *context = gl::getNonLostContext(); |
| 6643 | |
| 6644 | if (context) |
| 6645 | { |
| 6646 | gl::Texture *texture; |
| 6647 | |
| 6648 | switch (target) |
| 6649 | { |
| 6650 | case GL_TEXTURE_2D: |
| 6651 | texture = context->getTexture2D(); |
| 6652 | break; |
| 6653 | case GL_TEXTURE_CUBE_MAP: |
| 6654 | texture = context->getTextureCubeMap(); |
| 6655 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 6656 | case GL_TEXTURE_3D: |
| 6657 | if (context->getClientVersion() < 3) |
| 6658 | { |
| 6659 | return gl::error(GL_INVALID_ENUM); |
| 6660 | } |
| 6661 | texture = context->getTexture3D(); |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 6662 | case GL_TEXTURE_2D_ARRAY: |
| 6663 | if (context->getClientVersion() < 3) |
| 6664 | { |
| 6665 | return gl::error(GL_INVALID_ENUM); |
| 6666 | } |
| 6667 | texture = context->getTexture2DArray(); |
| 6668 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6669 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6670 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6671 | } |
| 6672 | |
| 6673 | switch (pname) |
| 6674 | { |
| 6675 | case GL_TEXTURE_WRAP_S: |
| 6676 | if (!texture->setWrapS((GLenum)param)) |
| 6677 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6678 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6679 | } |
| 6680 | break; |
| 6681 | case GL_TEXTURE_WRAP_T: |
| 6682 | if (!texture->setWrapT((GLenum)param)) |
| 6683 | { |
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 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 6687 | case GL_TEXTURE_WRAP_R: |
| 6688 | if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param)) |
| 6689 | { |
| 6690 | return gl::error(GL_INVALID_ENUM); |
| 6691 | } |
| 6692 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6693 | case GL_TEXTURE_MIN_FILTER: |
| 6694 | if (!texture->setMinFilter((GLenum)param)) |
| 6695 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6696 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6697 | } |
| 6698 | break; |
| 6699 | case GL_TEXTURE_MAG_FILTER: |
| 6700 | if (!texture->setMagFilter((GLenum)param)) |
| 6701 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6702 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6703 | } |
| 6704 | break; |
| 6705 | case GL_TEXTURE_USAGE_ANGLE: |
| 6706 | if (!texture->setUsage((GLenum)param)) |
| 6707 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6708 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6709 | } |
| 6710 | break; |
| 6711 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 6712 | if (!context->supportsTextureFilterAnisotropy()) |
| 6713 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6714 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6715 | } |
| 6716 | if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy())) |
| 6717 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6718 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6719 | } |
| 6720 | break; |
| 6721 | default: |
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 | } |
| 6725 | } |
| 6726 | catch(std::bad_alloc&) |
| 6727 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6728 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6729 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6730 | } |
| 6731 | |
| 6732 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 6733 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6734 | glTexParameterf(target, pname, (GLfloat)*params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6735 | } |
| 6736 | |
| 6737 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 6738 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6739 | 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] | 6740 | |
| 6741 | try |
| 6742 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6743 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6744 | |
| 6745 | if (context) |
| 6746 | { |
| 6747 | gl::Texture *texture; |
| 6748 | |
| 6749 | switch (target) |
| 6750 | { |
| 6751 | case GL_TEXTURE_2D: |
| 6752 | texture = context->getTexture2D(); |
| 6753 | break; |
| 6754 | case GL_TEXTURE_CUBE_MAP: |
| 6755 | texture = context->getTextureCubeMap(); |
| 6756 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 6757 | case GL_TEXTURE_3D: |
| 6758 | if (context->getClientVersion() < 3) |
| 6759 | { |
| 6760 | return gl::error(GL_INVALID_ENUM); |
| 6761 | } |
| 6762 | texture = context->getTexture3D(); |
| 6763 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 6764 | case GL_TEXTURE_2D_ARRAY: |
| 6765 | if (context->getClientVersion() < 3) |
| 6766 | { |
| 6767 | return gl::error(GL_INVALID_ENUM); |
| 6768 | } |
| 6769 | texture = context->getTexture2DArray(); |
| 6770 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6771 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6772 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6773 | } |
| 6774 | |
| 6775 | switch (pname) |
| 6776 | { |
| 6777 | case GL_TEXTURE_WRAP_S: |
| 6778 | if (!texture->setWrapS((GLenum)param)) |
| 6779 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6780 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6781 | } |
| 6782 | break; |
| 6783 | case GL_TEXTURE_WRAP_T: |
| 6784 | if (!texture->setWrapT((GLenum)param)) |
| 6785 | { |
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 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 6789 | case GL_TEXTURE_WRAP_R: |
| 6790 | if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param)) |
| 6791 | { |
| 6792 | return gl::error(GL_INVALID_ENUM); |
| 6793 | } |
| 6794 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6795 | case GL_TEXTURE_MIN_FILTER: |
| 6796 | if (!texture->setMinFilter((GLenum)param)) |
| 6797 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6798 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6799 | } |
| 6800 | break; |
| 6801 | case GL_TEXTURE_MAG_FILTER: |
| 6802 | if (!texture->setMagFilter((GLenum)param)) |
| 6803 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6804 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6805 | } |
| 6806 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 6807 | case GL_TEXTURE_USAGE_ANGLE: |
| 6808 | if (!texture->setUsage((GLenum)param)) |
| 6809 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6810 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 6811 | } |
| 6812 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6813 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 6814 | if (!context->supportsTextureFilterAnisotropy()) |
| 6815 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6816 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6817 | } |
| 6818 | if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy())) |
| 6819 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6820 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6821 | } |
| 6822 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6823 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6824 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6825 | } |
| 6826 | } |
| 6827 | } |
| 6828 | catch(std::bad_alloc&) |
| 6829 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6830 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6831 | } |
| 6832 | } |
| 6833 | |
| 6834 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 6835 | { |
| 6836 | glTexParameteri(target, pname, *params); |
| 6837 | } |
| 6838 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6839 | void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 6840 | { |
| 6841 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 6842 | target, levels, internalformat, width, height); |
| 6843 | |
| 6844 | try |
| 6845 | { |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6846 | gl::Context *context = gl::getNonLostContext(); |
| 6847 | |
| 6848 | if (context) |
| 6849 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame^] | 6850 | if (context->getClientVersion() < 3 && |
| 6851 | !validateES2TexStorageParameters(context, target, levels, internalformat, width, height)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6852 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame^] | 6853 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6854 | } |
| 6855 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame^] | 6856 | if (context->getClientVersion() >= 3 && |
| 6857 | !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6858 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame^] | 6859 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6860 | } |
| 6861 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6862 | switch (target) |
| 6863 | { |
| 6864 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6865 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame^] | 6866 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 6867 | texture2d->storage(levels, internalformat, width, height); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6868 | } |
| 6869 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame^] | 6870 | |
| 6871 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 6872 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 6873 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 6874 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 6875 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 6876 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6877 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame^] | 6878 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 6879 | textureCube->storage(levels, internalformat, width); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6880 | } |
| 6881 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame^] | 6882 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6883 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6884 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 6885 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6886 | } |
| 6887 | } |
| 6888 | catch(std::bad_alloc&) |
| 6889 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6890 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 6891 | } |
| 6892 | } |
| 6893 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6894 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 6895 | GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6896 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6897 | 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] | 6898 | "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] | 6899 | "const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6900 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 6901 | |
| 6902 | try |
| 6903 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6904 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 6905 | |
| 6906 | if (context) |
| 6907 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6908 | if (context->getClientVersion() < 3 && |
| 6909 | !validateES2TexImageParameters(context, target, level, GL_NONE, false, true, |
| 6910 | 0, 0, width, height, 0, format, type, pixels)) |
daniel@transgaming.com | 1d2d3c4 | 2012-05-31 01:14:15 +0000 | [diff] [blame] | 6911 | { |
| 6912 | return; |
| 6913 | } |
| 6914 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6915 | if (context->getClientVersion() >= 3 && |
| 6916 | !validateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 6917 | 0, 0, 0, width, height, 1, 0, format, type)) |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 6918 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6919 | return; |
| 6920 | } |
| 6921 | |
| 6922 | switch (target) |
| 6923 | { |
| 6924 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 6925 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6926 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 6927 | 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] | 6928 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6929 | break; |
| 6930 | |
| 6931 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 6932 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 6933 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 6934 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 6935 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 6936 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 6937 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6938 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 6939 | 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] | 6940 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6941 | break; |
| 6942 | |
| 6943 | default: |
| 6944 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 6945 | } |
| 6946 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6947 | } |
| 6948 | catch(std::bad_alloc&) |
| 6949 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6950 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6951 | } |
| 6952 | } |
| 6953 | |
| 6954 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 6955 | { |
| 6956 | glUniform1fv(location, 1, &x); |
| 6957 | } |
| 6958 | |
| 6959 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 6960 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6961 | 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] | 6962 | |
| 6963 | try |
| 6964 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6965 | if (count < 0) |
| 6966 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6967 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6968 | } |
| 6969 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 6970 | if (location == -1) |
| 6971 | { |
| 6972 | return; |
| 6973 | } |
| 6974 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6975 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6976 | |
| 6977 | if (context) |
| 6978 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 6979 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6980 | if (!programBinary) |
| 6981 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6982 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6983 | } |
| 6984 | |
| 6985 | if (!programBinary->setUniform1fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6986 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6987 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6988 | } |
| 6989 | } |
| 6990 | } |
| 6991 | catch(std::bad_alloc&) |
| 6992 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6993 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6994 | } |
| 6995 | } |
| 6996 | |
| 6997 | void __stdcall glUniform1i(GLint location, GLint x) |
| 6998 | { |
| 6999 | glUniform1iv(location, 1, &x); |
| 7000 | } |
| 7001 | |
| 7002 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 7003 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7004 | 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] | 7005 | |
| 7006 | try |
| 7007 | { |
| 7008 | if (count < 0) |
| 7009 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7010 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7011 | } |
| 7012 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7013 | if (location == -1) |
| 7014 | { |
| 7015 | return; |
| 7016 | } |
| 7017 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7018 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7019 | |
| 7020 | if (context) |
| 7021 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7022 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7023 | if (!programBinary) |
| 7024 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7025 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7026 | } |
| 7027 | |
| 7028 | if (!programBinary->setUniform1iv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7029 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7030 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7031 | } |
| 7032 | } |
| 7033 | } |
| 7034 | catch(std::bad_alloc&) |
| 7035 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7036 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7037 | } |
| 7038 | } |
| 7039 | |
| 7040 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 7041 | { |
| 7042 | GLfloat xy[2] = {x, y}; |
| 7043 | |
| 7044 | glUniform2fv(location, 1, (GLfloat*)&xy); |
| 7045 | } |
| 7046 | |
| 7047 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 7048 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7049 | 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] | 7050 | |
| 7051 | try |
| 7052 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7053 | if (count < 0) |
| 7054 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7055 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7056 | } |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7057 | |
| 7058 | if (location == -1) |
| 7059 | { |
| 7060 | return; |
| 7061 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7062 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7063 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7064 | |
| 7065 | if (context) |
| 7066 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7067 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7068 | if (!programBinary) |
| 7069 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7070 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7071 | } |
| 7072 | |
| 7073 | if (!programBinary->setUniform2fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7074 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7075 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7076 | } |
| 7077 | } |
| 7078 | } |
| 7079 | catch(std::bad_alloc&) |
| 7080 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7081 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7082 | } |
| 7083 | } |
| 7084 | |
| 7085 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 7086 | { |
| 7087 | GLint xy[4] = {x, y}; |
| 7088 | |
| 7089 | glUniform2iv(location, 1, (GLint*)&xy); |
| 7090 | } |
| 7091 | |
| 7092 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 7093 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7094 | 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] | 7095 | |
| 7096 | try |
| 7097 | { |
| 7098 | if (count < 0) |
| 7099 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7100 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7101 | } |
| 7102 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7103 | if (location == -1) |
| 7104 | { |
| 7105 | return; |
| 7106 | } |
| 7107 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7108 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7109 | |
| 7110 | if (context) |
| 7111 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7112 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7113 | if (!programBinary) |
| 7114 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7115 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7116 | } |
| 7117 | |
| 7118 | if (!programBinary->setUniform2iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7119 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7120 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7121 | } |
| 7122 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7123 | } |
| 7124 | catch(std::bad_alloc&) |
| 7125 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7126 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7127 | } |
| 7128 | } |
| 7129 | |
| 7130 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 7131 | { |
| 7132 | GLfloat xyz[3] = {x, y, z}; |
| 7133 | |
| 7134 | glUniform3fv(location, 1, (GLfloat*)&xyz); |
| 7135 | } |
| 7136 | |
| 7137 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 7138 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7139 | 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] | 7140 | |
| 7141 | try |
| 7142 | { |
| 7143 | if (count < 0) |
| 7144 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7145 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7146 | } |
| 7147 | |
| 7148 | if (location == -1) |
| 7149 | { |
| 7150 | return; |
| 7151 | } |
| 7152 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7153 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7154 | |
| 7155 | if (context) |
| 7156 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7157 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7158 | if (!programBinary) |
| 7159 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7160 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7161 | } |
| 7162 | |
| 7163 | if (!programBinary->setUniform3fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7164 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7165 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7166 | } |
| 7167 | } |
| 7168 | } |
| 7169 | catch(std::bad_alloc&) |
| 7170 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7171 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7172 | } |
| 7173 | } |
| 7174 | |
| 7175 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 7176 | { |
| 7177 | GLint xyz[3] = {x, y, z}; |
| 7178 | |
| 7179 | glUniform3iv(location, 1, (GLint*)&xyz); |
| 7180 | } |
| 7181 | |
| 7182 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 7183 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7184 | 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] | 7185 | |
| 7186 | try |
| 7187 | { |
| 7188 | if (count < 0) |
| 7189 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7190 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7191 | } |
| 7192 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7193 | if (location == -1) |
| 7194 | { |
| 7195 | return; |
| 7196 | } |
| 7197 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7198 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7199 | |
| 7200 | if (context) |
| 7201 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7202 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7203 | if (!programBinary) |
| 7204 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7205 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7206 | } |
| 7207 | |
| 7208 | if (!programBinary->setUniform3iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7209 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7210 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7211 | } |
| 7212 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7213 | } |
| 7214 | catch(std::bad_alloc&) |
| 7215 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7216 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7217 | } |
| 7218 | } |
| 7219 | |
| 7220 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7221 | { |
| 7222 | GLfloat xyzw[4] = {x, y, z, w}; |
| 7223 | |
| 7224 | glUniform4fv(location, 1, (GLfloat*)&xyzw); |
| 7225 | } |
| 7226 | |
| 7227 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 7228 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7229 | 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] | 7230 | |
| 7231 | try |
| 7232 | { |
| 7233 | if (count < 0) |
| 7234 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7235 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7236 | } |
| 7237 | |
| 7238 | if (location == -1) |
| 7239 | { |
| 7240 | return; |
| 7241 | } |
| 7242 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7243 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7244 | |
| 7245 | if (context) |
| 7246 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7247 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7248 | if (!programBinary) |
| 7249 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7250 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7251 | } |
| 7252 | |
| 7253 | if (!programBinary->setUniform4fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7254 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7255 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7256 | } |
| 7257 | } |
| 7258 | } |
| 7259 | catch(std::bad_alloc&) |
| 7260 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7261 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7262 | } |
| 7263 | } |
| 7264 | |
| 7265 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 7266 | { |
| 7267 | GLint xyzw[4] = {x, y, z, w}; |
| 7268 | |
| 7269 | glUniform4iv(location, 1, (GLint*)&xyzw); |
| 7270 | } |
| 7271 | |
| 7272 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 7273 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7274 | 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] | 7275 | |
| 7276 | try |
| 7277 | { |
| 7278 | if (count < 0) |
| 7279 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7280 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7281 | } |
| 7282 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7283 | if (location == -1) |
| 7284 | { |
| 7285 | return; |
| 7286 | } |
| 7287 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7288 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7289 | |
| 7290 | if (context) |
| 7291 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7292 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7293 | if (!programBinary) |
| 7294 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7295 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7296 | } |
| 7297 | |
| 7298 | if (!programBinary->setUniform4iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7299 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7300 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7301 | } |
| 7302 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7303 | } |
| 7304 | catch(std::bad_alloc&) |
| 7305 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7306 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7307 | } |
| 7308 | } |
| 7309 | |
| 7310 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7311 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7312 | 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] | 7313 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7314 | |
| 7315 | try |
| 7316 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7317 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7318 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7319 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7320 | } |
| 7321 | |
| 7322 | if (location == -1) |
| 7323 | { |
| 7324 | return; |
| 7325 | } |
| 7326 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7327 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7328 | |
| 7329 | if (context) |
| 7330 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7331 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7332 | { |
| 7333 | return gl::error(GL_INVALID_VALUE); |
| 7334 | } |
| 7335 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7336 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7337 | if (!programBinary) |
| 7338 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7339 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7340 | } |
| 7341 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7342 | if (!programBinary->setUniformMatrix2fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7343 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7344 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7345 | } |
| 7346 | } |
| 7347 | } |
| 7348 | catch(std::bad_alloc&) |
| 7349 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7350 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7351 | } |
| 7352 | } |
| 7353 | |
| 7354 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7355 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7356 | 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] | 7357 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7358 | |
| 7359 | try |
| 7360 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7361 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7362 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7363 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7364 | } |
| 7365 | |
| 7366 | if (location == -1) |
| 7367 | { |
| 7368 | return; |
| 7369 | } |
| 7370 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7371 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7372 | |
| 7373 | if (context) |
| 7374 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7375 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7376 | { |
| 7377 | return gl::error(GL_INVALID_VALUE); |
| 7378 | } |
| 7379 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7380 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7381 | if (!programBinary) |
| 7382 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7383 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7384 | } |
| 7385 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7386 | if (!programBinary->setUniformMatrix3fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7387 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7388 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7389 | } |
| 7390 | } |
| 7391 | } |
| 7392 | catch(std::bad_alloc&) |
| 7393 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7394 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7395 | } |
| 7396 | } |
| 7397 | |
| 7398 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7399 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7400 | 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] | 7401 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7402 | |
| 7403 | try |
| 7404 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7405 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7406 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7407 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7408 | } |
| 7409 | |
| 7410 | if (location == -1) |
| 7411 | { |
| 7412 | return; |
| 7413 | } |
| 7414 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7415 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7416 | |
| 7417 | if (context) |
| 7418 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7419 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7420 | { |
| 7421 | return gl::error(GL_INVALID_VALUE); |
| 7422 | } |
| 7423 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7424 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7425 | if (!programBinary) |
| 7426 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7427 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7428 | } |
| 7429 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7430 | if (!programBinary->setUniformMatrix4fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7431 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7432 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7433 | } |
| 7434 | } |
| 7435 | } |
| 7436 | catch(std::bad_alloc&) |
| 7437 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7438 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7439 | } |
| 7440 | } |
| 7441 | |
| 7442 | void __stdcall glUseProgram(GLuint program) |
| 7443 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7444 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7445 | |
| 7446 | try |
| 7447 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7448 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7449 | |
| 7450 | if (context) |
| 7451 | { |
| 7452 | gl::Program *programObject = context->getProgram(program); |
| 7453 | |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7454 | if (!programObject && program != 0) |
| 7455 | { |
| 7456 | if (context->getShader(program)) |
| 7457 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7458 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7459 | } |
| 7460 | else |
| 7461 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7462 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7463 | } |
| 7464 | } |
| 7465 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 7466 | if (program != 0 && !programObject->isLinked()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7467 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7468 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7469 | } |
| 7470 | |
| 7471 | context->useProgram(program); |
| 7472 | } |
| 7473 | } |
| 7474 | catch(std::bad_alloc&) |
| 7475 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7476 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7477 | } |
| 7478 | } |
| 7479 | |
| 7480 | void __stdcall glValidateProgram(GLuint program) |
| 7481 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7482 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7483 | |
| 7484 | try |
| 7485 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7486 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7487 | |
| 7488 | if (context) |
| 7489 | { |
| 7490 | gl::Program *programObject = context->getProgram(program); |
| 7491 | |
| 7492 | if (!programObject) |
| 7493 | { |
| 7494 | if (context->getShader(program)) |
| 7495 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7496 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7497 | } |
| 7498 | else |
| 7499 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7500 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7501 | } |
| 7502 | } |
| 7503 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 7504 | programObject->validate(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7505 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7506 | } |
| 7507 | catch(std::bad_alloc&) |
| 7508 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7509 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7510 | } |
| 7511 | } |
| 7512 | |
| 7513 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 7514 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7515 | EVENT("(GLuint index = %d, GLfloat x = %f)", index, x); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7516 | |
| 7517 | try |
| 7518 | { |
| 7519 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7520 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7521 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7522 | } |
| 7523 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7524 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7525 | |
| 7526 | if (context) |
| 7527 | { |
| 7528 | GLfloat vals[4] = { x, 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7529 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7530 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7531 | } |
| 7532 | catch(std::bad_alloc&) |
| 7533 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7534 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7535 | } |
| 7536 | } |
| 7537 | |
| 7538 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 7539 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7540 | 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] | 7541 | |
| 7542 | try |
| 7543 | { |
| 7544 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7545 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7546 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7547 | } |
| 7548 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7549 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7550 | |
| 7551 | if (context) |
| 7552 | { |
| 7553 | GLfloat vals[4] = { values[0], 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7554 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7555 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7556 | } |
| 7557 | catch(std::bad_alloc&) |
| 7558 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7559 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7560 | } |
| 7561 | } |
| 7562 | |
| 7563 | void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 7564 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7565 | 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] | 7566 | |
| 7567 | try |
| 7568 | { |
| 7569 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7570 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7571 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7572 | } |
| 7573 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7574 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7575 | |
| 7576 | if (context) |
| 7577 | { |
| 7578 | GLfloat vals[4] = { x, y, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7579 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7580 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7581 | } |
| 7582 | catch(std::bad_alloc&) |
| 7583 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7584 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7585 | } |
| 7586 | } |
| 7587 | |
| 7588 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 7589 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7590 | 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] | 7591 | |
| 7592 | try |
| 7593 | { |
| 7594 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7595 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7596 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7597 | } |
| 7598 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7599 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7600 | |
| 7601 | if (context) |
| 7602 | { |
| 7603 | 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] | 7604 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7605 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7606 | } |
| 7607 | catch(std::bad_alloc&) |
| 7608 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7609 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7610 | } |
| 7611 | } |
| 7612 | |
| 7613 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 7614 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7615 | 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] | 7616 | |
| 7617 | try |
| 7618 | { |
| 7619 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7620 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7621 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7622 | } |
| 7623 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7624 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7625 | |
| 7626 | if (context) |
| 7627 | { |
| 7628 | GLfloat vals[4] = { x, y, z, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7629 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7630 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7631 | } |
| 7632 | catch(std::bad_alloc&) |
| 7633 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7634 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7635 | } |
| 7636 | } |
| 7637 | |
| 7638 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 7639 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7640 | 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] | 7641 | |
| 7642 | try |
| 7643 | { |
| 7644 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7645 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7646 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7647 | } |
| 7648 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7649 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7650 | |
| 7651 | if (context) |
| 7652 | { |
| 7653 | 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] | 7654 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7655 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7656 | } |
| 7657 | catch(std::bad_alloc&) |
| 7658 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7659 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7660 | } |
| 7661 | } |
| 7662 | |
| 7663 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7664 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7665 | 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] | 7666 | |
| 7667 | try |
| 7668 | { |
| 7669 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7670 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7671 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7672 | } |
| 7673 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7674 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7675 | |
| 7676 | if (context) |
| 7677 | { |
| 7678 | GLfloat vals[4] = { x, y, z, w }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7679 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7680 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7681 | } |
| 7682 | catch(std::bad_alloc&) |
| 7683 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7684 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7685 | } |
| 7686 | } |
| 7687 | |
| 7688 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 7689 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7690 | 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] | 7691 | |
| 7692 | try |
| 7693 | { |
| 7694 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7695 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7696 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7697 | } |
| 7698 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7699 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7700 | |
| 7701 | if (context) |
| 7702 | { |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7703 | context->setVertexAttribf(index, values); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7704 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7705 | } |
| 7706 | catch(std::bad_alloc&) |
| 7707 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7708 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7709 | } |
| 7710 | } |
| 7711 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 7712 | void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
| 7713 | { |
| 7714 | EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor); |
| 7715 | |
| 7716 | try |
| 7717 | { |
| 7718 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7719 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7720 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 7721 | } |
| 7722 | |
| 7723 | gl::Context *context = gl::getNonLostContext(); |
| 7724 | |
| 7725 | if (context) |
| 7726 | { |
| 7727 | context->setVertexAttribDivisor(index, divisor); |
| 7728 | } |
| 7729 | } |
| 7730 | catch(std::bad_alloc&) |
| 7731 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7732 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 7733 | } |
| 7734 | } |
| 7735 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7736 | 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] | 7737 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7738 | 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] | 7739 | "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] | 7740 | index, size, type, normalized, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7741 | |
| 7742 | try |
| 7743 | { |
| 7744 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7745 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7746 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7747 | } |
| 7748 | |
| 7749 | if (size < 1 || size > 4) |
| 7750 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7751 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7752 | } |
| 7753 | |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 7754 | gl::Context *context = gl::getNonLostContext(); |
| 7755 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7756 | switch (type) |
| 7757 | { |
| 7758 | case GL_BYTE: |
| 7759 | case GL_UNSIGNED_BYTE: |
| 7760 | case GL_SHORT: |
| 7761 | case GL_UNSIGNED_SHORT: |
| 7762 | case GL_FIXED: |
| 7763 | case GL_FLOAT: |
| 7764 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 7765 | case GL_HALF_FLOAT: |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7766 | case GL_INT: |
| 7767 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 7768 | case GL_INT_2_10_10_10_REV: |
| 7769 | 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] | 7770 | if (context && context->getClientVersion() < 3) |
| 7771 | { |
| 7772 | return gl::error(GL_INVALID_ENUM); |
| 7773 | } |
| 7774 | else |
| 7775 | { |
| 7776 | break; |
| 7777 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7778 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7779 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7780 | } |
| 7781 | |
| 7782 | if (stride < 0) |
| 7783 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7784 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7785 | } |
| 7786 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 7787 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 7788 | { |
| 7789 | return gl::error(GL_INVALID_OPERATION); |
| 7790 | } |
| 7791 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7792 | if (context) |
| 7793 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8de4e6a | 2013-04-13 03:37:44 +0000 | [diff] [blame] | 7794 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, |
| 7795 | normalized == GL_TRUE, false, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7796 | } |
| 7797 | } |
| 7798 | catch(std::bad_alloc&) |
| 7799 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7800 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7801 | } |
| 7802 | } |
| 7803 | |
| 7804 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 7805 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7806 | 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] | 7807 | |
| 7808 | try |
| 7809 | { |
| 7810 | if (width < 0 || height < 0) |
| 7811 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7812 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7813 | } |
| 7814 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7815 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7816 | |
| 7817 | if (context) |
| 7818 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7819 | context->setViewportParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7820 | } |
| 7821 | } |
| 7822 | catch(std::bad_alloc&) |
| 7823 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7824 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7825 | } |
| 7826 | } |
| 7827 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7828 | // OpenGL ES 3.0 functions |
| 7829 | |
| 7830 | void __stdcall glReadBuffer(GLenum mode) |
| 7831 | { |
| 7832 | EVENT("(GLenum mode = 0x%X)", mode); |
| 7833 | |
| 7834 | try |
| 7835 | { |
| 7836 | gl::Context *context = gl::getNonLostContext(); |
| 7837 | |
| 7838 | if (context) |
| 7839 | { |
| 7840 | if (context->getClientVersion() < 3) |
| 7841 | { |
| 7842 | return gl::error(GL_INVALID_OPERATION); |
| 7843 | } |
| 7844 | } |
| 7845 | |
| 7846 | UNIMPLEMENTED(); |
| 7847 | } |
| 7848 | catch(std::bad_alloc&) |
| 7849 | { |
| 7850 | return gl::error(GL_OUT_OF_MEMORY); |
| 7851 | } |
| 7852 | } |
| 7853 | |
| 7854 | void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) |
| 7855 | { |
| 7856 | EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, " |
| 7857 | "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices); |
| 7858 | |
| 7859 | try |
| 7860 | { |
| 7861 | gl::Context *context = gl::getNonLostContext(); |
| 7862 | |
| 7863 | if (context) |
| 7864 | { |
| 7865 | if (context->getClientVersion() < 3) |
| 7866 | { |
| 7867 | return gl::error(GL_INVALID_OPERATION); |
| 7868 | } |
| 7869 | } |
| 7870 | |
| 7871 | UNIMPLEMENTED(); |
| 7872 | } |
| 7873 | catch(std::bad_alloc&) |
| 7874 | { |
| 7875 | return gl::error(GL_OUT_OF_MEMORY); |
| 7876 | } |
| 7877 | } |
| 7878 | |
| 7879 | void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
| 7880 | { |
| 7881 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 7882 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " |
| 7883 | "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 7884 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 7885 | |
| 7886 | try |
| 7887 | { |
| 7888 | gl::Context *context = gl::getNonLostContext(); |
| 7889 | |
| 7890 | if (context) |
| 7891 | { |
| 7892 | if (context->getClientVersion() < 3) |
| 7893 | { |
| 7894 | return gl::error(GL_INVALID_OPERATION); |
| 7895 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7896 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 7897 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 7898 | if (!validateES3TexImageParameters(context, target, level, internalformat, false, false, |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 7899 | 0, 0, 0, width, height, depth, border, format, type)) |
| 7900 | { |
| 7901 | return; |
| 7902 | } |
| 7903 | |
| 7904 | switch(target) |
| 7905 | { |
| 7906 | case GL_TEXTURE_3D: |
| 7907 | { |
| 7908 | gl::Texture3D *texture = context->getTexture3D(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 7909 | 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] | 7910 | } |
| 7911 | break; |
| 7912 | |
| 7913 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 7914 | { |
| 7915 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 7916 | 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] | 7917 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 7918 | break; |
| 7919 | |
| 7920 | default: |
| 7921 | return gl::error(GL_INVALID_ENUM); |
| 7922 | } |
| 7923 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7924 | } |
| 7925 | catch(std::bad_alloc&) |
| 7926 | { |
| 7927 | return gl::error(GL_OUT_OF_MEMORY); |
| 7928 | } |
| 7929 | } |
| 7930 | |
| 7931 | 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) |
| 7932 | { |
| 7933 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 7934 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 7935 | "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 7936 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); |
| 7937 | |
| 7938 | try |
| 7939 | { |
| 7940 | gl::Context *context = gl::getNonLostContext(); |
| 7941 | |
| 7942 | if (context) |
| 7943 | { |
| 7944 | if (context->getClientVersion() < 3) |
| 7945 | { |
| 7946 | return gl::error(GL_INVALID_OPERATION); |
| 7947 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7948 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 7949 | if (!pixels) |
| 7950 | { |
| 7951 | return gl::error(GL_INVALID_VALUE); |
| 7952 | } |
| 7953 | |
| 7954 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 7955 | 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] | 7956 | xoffset, yoffset, zoffset, width, height, depth, 0, |
| 7957 | format, type)) |
| 7958 | { |
| 7959 | return; |
| 7960 | } |
| 7961 | |
| 7962 | switch(target) |
| 7963 | { |
| 7964 | case GL_TEXTURE_3D: |
| 7965 | { |
| 7966 | gl::Texture3D *texture = context->getTexture3D(); |
| 7967 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 7968 | } |
| 7969 | break; |
| 7970 | |
| 7971 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 7972 | { |
| 7973 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 7974 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 7975 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 7976 | break; |
| 7977 | |
| 7978 | default: |
| 7979 | return gl::error(GL_INVALID_ENUM); |
| 7980 | } |
| 7981 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7982 | } |
| 7983 | catch(std::bad_alloc&) |
| 7984 | { |
| 7985 | return gl::error(GL_OUT_OF_MEMORY); |
| 7986 | } |
| 7987 | } |
| 7988 | |
| 7989 | void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 7990 | { |
| 7991 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 7992 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 7993 | target, level, xoffset, yoffset, zoffset, x, y, width, height); |
| 7994 | |
| 7995 | try |
| 7996 | { |
| 7997 | gl::Context *context = gl::getNonLostContext(); |
| 7998 | |
| 7999 | if (context) |
| 8000 | { |
| 8001 | if (context->getClientVersion() < 3) |
| 8002 | { |
| 8003 | return gl::error(GL_INVALID_OPERATION); |
| 8004 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8005 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8006 | if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset, |
| 8007 | x, y, width, height, 0)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8008 | { |
| 8009 | return; |
| 8010 | } |
| 8011 | |
| 8012 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 8013 | gl::Texture *texture = NULL; |
| 8014 | switch (target) |
| 8015 | { |
| 8016 | case GL_TEXTURE_3D: |
| 8017 | texture = context->getTexture3D(); |
| 8018 | break; |
| 8019 | |
| 8020 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8021 | texture = context->getTexture2DArray(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8022 | break; |
| 8023 | |
| 8024 | default: |
| 8025 | return gl::error(GL_INVALID_ENUM); |
| 8026 | } |
| 8027 | |
| 8028 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer); |
| 8029 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8030 | } |
| 8031 | catch(std::bad_alloc&) |
| 8032 | { |
| 8033 | return gl::error(GL_OUT_OF_MEMORY); |
| 8034 | } |
| 8035 | } |
| 8036 | |
| 8037 | void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) |
| 8038 | { |
| 8039 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8040 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, " |
| 8041 | "const GLvoid* data = 0x%0.8p)", |
| 8042 | target, level, internalformat, width, height, depth, border, imageSize, data); |
| 8043 | |
| 8044 | try |
| 8045 | { |
| 8046 | gl::Context *context = gl::getNonLostContext(); |
| 8047 | |
| 8048 | if (context) |
| 8049 | { |
| 8050 | if (context->getClientVersion() < 3) |
| 8051 | { |
| 8052 | return gl::error(GL_INVALID_OPERATION); |
| 8053 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8054 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8055 | 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] | 8056 | { |
| 8057 | return gl::error(GL_INVALID_VALUE); |
| 8058 | } |
| 8059 | |
| 8060 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8061 | if (!validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 8062 | 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] | 8063 | { |
| 8064 | return; |
| 8065 | } |
| 8066 | |
| 8067 | switch(target) |
| 8068 | { |
| 8069 | case GL_TEXTURE_3D: |
| 8070 | { |
| 8071 | gl::Texture3D *texture = context->getTexture3D(); |
| 8072 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8073 | } |
| 8074 | break; |
| 8075 | |
| 8076 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8077 | { |
| 8078 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8079 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8080 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8081 | break; |
| 8082 | |
| 8083 | default: |
| 8084 | return gl::error(GL_INVALID_ENUM); |
| 8085 | } |
| 8086 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8087 | } |
| 8088 | catch(std::bad_alloc&) |
| 8089 | { |
| 8090 | return gl::error(GL_OUT_OF_MEMORY); |
| 8091 | } |
| 8092 | } |
| 8093 | |
| 8094 | 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) |
| 8095 | { |
| 8096 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8097 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8098 | "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 8099 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); |
| 8100 | |
| 8101 | try |
| 8102 | { |
| 8103 | gl::Context *context = gl::getNonLostContext(); |
| 8104 | |
| 8105 | if (context) |
| 8106 | { |
| 8107 | if (context->getClientVersion() < 3) |
| 8108 | { |
| 8109 | return gl::error(GL_INVALID_OPERATION); |
| 8110 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8111 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8112 | 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] | 8113 | { |
| 8114 | return gl::error(GL_INVALID_VALUE); |
| 8115 | } |
| 8116 | |
| 8117 | if (!data) |
| 8118 | { |
| 8119 | return gl::error(GL_INVALID_VALUE); |
| 8120 | } |
| 8121 | |
| 8122 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8123 | if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 8124 | 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] | 8125 | { |
| 8126 | return; |
| 8127 | } |
| 8128 | |
| 8129 | switch(target) |
| 8130 | { |
| 8131 | case GL_TEXTURE_3D: |
| 8132 | { |
| 8133 | gl::Texture3D *texture = context->getTexture3D(); |
| 8134 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8135 | format, imageSize, data); |
| 8136 | } |
| 8137 | break; |
| 8138 | |
| 8139 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8140 | { |
| 8141 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8142 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8143 | format, imageSize, data); |
| 8144 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8145 | break; |
| 8146 | |
| 8147 | default: |
| 8148 | return gl::error(GL_INVALID_ENUM); |
| 8149 | } |
| 8150 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8151 | } |
| 8152 | catch(std::bad_alloc&) |
| 8153 | { |
| 8154 | return gl::error(GL_OUT_OF_MEMORY); |
| 8155 | } |
| 8156 | } |
| 8157 | |
| 8158 | void __stdcall glGenQueries(GLsizei n, GLuint* ids) |
| 8159 | { |
| 8160 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8161 | |
| 8162 | try |
| 8163 | { |
| 8164 | gl::Context *context = gl::getNonLostContext(); |
| 8165 | |
| 8166 | if (context) |
| 8167 | { |
| 8168 | if (context->getClientVersion() < 3) |
| 8169 | { |
| 8170 | return gl::error(GL_INVALID_OPERATION); |
| 8171 | } |
| 8172 | } |
| 8173 | |
| 8174 | UNIMPLEMENTED(); |
| 8175 | } |
| 8176 | catch(std::bad_alloc&) |
| 8177 | { |
| 8178 | return gl::error(GL_OUT_OF_MEMORY); |
| 8179 | } |
| 8180 | } |
| 8181 | |
| 8182 | void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids) |
| 8183 | { |
| 8184 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8185 | |
| 8186 | try |
| 8187 | { |
| 8188 | gl::Context *context = gl::getNonLostContext(); |
| 8189 | |
| 8190 | if (context) |
| 8191 | { |
| 8192 | if (context->getClientVersion() < 3) |
| 8193 | { |
| 8194 | return gl::error(GL_INVALID_OPERATION); |
| 8195 | } |
| 8196 | } |
| 8197 | |
| 8198 | UNIMPLEMENTED(); |
| 8199 | } |
| 8200 | catch(std::bad_alloc&) |
| 8201 | { |
| 8202 | return gl::error(GL_OUT_OF_MEMORY); |
| 8203 | } |
| 8204 | } |
| 8205 | |
| 8206 | GLboolean __stdcall glIsQuery(GLuint id) |
| 8207 | { |
| 8208 | EVENT("(GLuint id = %u)", id); |
| 8209 | |
| 8210 | try |
| 8211 | { |
| 8212 | gl::Context *context = gl::getNonLostContext(); |
| 8213 | |
| 8214 | if (context) |
| 8215 | { |
| 8216 | if (context->getClientVersion() < 3) |
| 8217 | { |
| 8218 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8219 | } |
| 8220 | } |
| 8221 | |
| 8222 | UNIMPLEMENTED(); |
| 8223 | } |
| 8224 | catch(std::bad_alloc&) |
| 8225 | { |
| 8226 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8227 | } |
| 8228 | |
| 8229 | return GL_FALSE; |
| 8230 | } |
| 8231 | |
| 8232 | void __stdcall glBeginQuery(GLenum target, GLuint id) |
| 8233 | { |
| 8234 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 8235 | |
| 8236 | try |
| 8237 | { |
| 8238 | gl::Context *context = gl::getNonLostContext(); |
| 8239 | |
| 8240 | if (context) |
| 8241 | { |
| 8242 | if (context->getClientVersion() < 3) |
| 8243 | { |
| 8244 | return gl::error(GL_INVALID_OPERATION); |
| 8245 | } |
| 8246 | } |
| 8247 | |
| 8248 | UNIMPLEMENTED(); |
| 8249 | } |
| 8250 | catch(std::bad_alloc&) |
| 8251 | { |
| 8252 | return gl::error(GL_OUT_OF_MEMORY); |
| 8253 | } |
| 8254 | } |
| 8255 | |
| 8256 | void __stdcall glEndQuery(GLenum target) |
| 8257 | { |
| 8258 | EVENT("(GLenum target = 0x%X)", target); |
| 8259 | |
| 8260 | try |
| 8261 | { |
| 8262 | gl::Context *context = gl::getNonLostContext(); |
| 8263 | |
| 8264 | if (context) |
| 8265 | { |
| 8266 | if (context->getClientVersion() < 3) |
| 8267 | { |
| 8268 | return gl::error(GL_INVALID_OPERATION); |
| 8269 | } |
| 8270 | } |
| 8271 | |
| 8272 | UNIMPLEMENTED(); |
| 8273 | } |
| 8274 | catch(std::bad_alloc&) |
| 8275 | { |
| 8276 | return gl::error(GL_OUT_OF_MEMORY); |
| 8277 | } |
| 8278 | } |
| 8279 | |
| 8280 | void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params) |
| 8281 | { |
| 8282 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
| 8283 | |
| 8284 | try |
| 8285 | { |
| 8286 | gl::Context *context = gl::getNonLostContext(); |
| 8287 | |
| 8288 | if (context) |
| 8289 | { |
| 8290 | if (context->getClientVersion() < 3) |
| 8291 | { |
| 8292 | return gl::error(GL_INVALID_OPERATION); |
| 8293 | } |
| 8294 | } |
| 8295 | |
| 8296 | UNIMPLEMENTED(); |
| 8297 | } |
| 8298 | catch(std::bad_alloc&) |
| 8299 | { |
| 8300 | return gl::error(GL_OUT_OF_MEMORY); |
| 8301 | } |
| 8302 | } |
| 8303 | |
| 8304 | void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) |
| 8305 | { |
| 8306 | EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params); |
| 8307 | |
| 8308 | try |
| 8309 | { |
| 8310 | gl::Context *context = gl::getNonLostContext(); |
| 8311 | |
| 8312 | if (context) |
| 8313 | { |
| 8314 | if (context->getClientVersion() < 3) |
| 8315 | { |
| 8316 | return gl::error(GL_INVALID_OPERATION); |
| 8317 | } |
| 8318 | } |
| 8319 | |
| 8320 | UNIMPLEMENTED(); |
| 8321 | } |
| 8322 | catch(std::bad_alloc&) |
| 8323 | { |
| 8324 | return gl::error(GL_OUT_OF_MEMORY); |
| 8325 | } |
| 8326 | } |
| 8327 | |
| 8328 | GLboolean __stdcall glUnmapBuffer(GLenum target) |
| 8329 | { |
| 8330 | EVENT("(GLenum target = 0x%X)", target); |
| 8331 | |
| 8332 | try |
| 8333 | { |
| 8334 | gl::Context *context = gl::getNonLostContext(); |
| 8335 | |
| 8336 | if (context) |
| 8337 | { |
| 8338 | if (context->getClientVersion() < 3) |
| 8339 | { |
| 8340 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8341 | } |
| 8342 | } |
| 8343 | |
| 8344 | UNIMPLEMENTED(); |
| 8345 | } |
| 8346 | catch(std::bad_alloc&) |
| 8347 | { |
| 8348 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8349 | } |
| 8350 | |
| 8351 | return GL_FALSE; |
| 8352 | } |
| 8353 | |
| 8354 | void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) |
| 8355 | { |
| 8356 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 8357 | |
| 8358 | try |
| 8359 | { |
| 8360 | gl::Context *context = gl::getNonLostContext(); |
| 8361 | |
| 8362 | if (context) |
| 8363 | { |
| 8364 | if (context->getClientVersion() < 3) |
| 8365 | { |
| 8366 | return gl::error(GL_INVALID_OPERATION); |
| 8367 | } |
| 8368 | } |
| 8369 | |
| 8370 | UNIMPLEMENTED(); |
| 8371 | } |
| 8372 | catch(std::bad_alloc&) |
| 8373 | { |
| 8374 | return gl::error(GL_OUT_OF_MEMORY); |
| 8375 | } |
| 8376 | } |
| 8377 | |
| 8378 | void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs) |
| 8379 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8380 | try |
| 8381 | { |
| 8382 | gl::Context *context = gl::getNonLostContext(); |
| 8383 | |
| 8384 | if (context) |
| 8385 | { |
| 8386 | if (context->getClientVersion() < 3) |
| 8387 | { |
| 8388 | return gl::error(GL_INVALID_OPERATION); |
| 8389 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8390 | |
shannon.woods%transgaming.com@gtempaccount.com | 7948c5f | 2013-04-13 03:38:58 +0000 | [diff] [blame] | 8391 | glDrawBuffersEXT(n, bufs); |
| 8392 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8393 | } |
| 8394 | catch(std::bad_alloc&) |
| 8395 | { |
| 8396 | return gl::error(GL_OUT_OF_MEMORY); |
| 8397 | } |
| 8398 | } |
| 8399 | |
| 8400 | void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8401 | { |
| 8402 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8403 | location, count, transpose, value); |
| 8404 | |
| 8405 | try |
| 8406 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8407 | if (count < 0) |
| 8408 | { |
| 8409 | return gl::error(GL_INVALID_VALUE); |
| 8410 | } |
| 8411 | |
| 8412 | if (location == -1) |
| 8413 | { |
| 8414 | return; |
| 8415 | } |
| 8416 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8417 | gl::Context *context = gl::getNonLostContext(); |
| 8418 | |
| 8419 | if (context) |
| 8420 | { |
| 8421 | if (context->getClientVersion() < 3) |
| 8422 | { |
| 8423 | return gl::error(GL_INVALID_OPERATION); |
| 8424 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8425 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8426 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8427 | if (!programBinary) |
| 8428 | { |
| 8429 | return gl::error(GL_INVALID_OPERATION); |
| 8430 | } |
| 8431 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8432 | if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8433 | { |
| 8434 | return gl::error(GL_INVALID_OPERATION); |
| 8435 | } |
| 8436 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8437 | } |
| 8438 | catch(std::bad_alloc&) |
| 8439 | { |
| 8440 | return gl::error(GL_OUT_OF_MEMORY); |
| 8441 | } |
| 8442 | } |
| 8443 | |
| 8444 | void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8445 | { |
| 8446 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8447 | location, count, transpose, value); |
| 8448 | |
| 8449 | try |
| 8450 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8451 | if (count < 0) |
| 8452 | { |
| 8453 | return gl::error(GL_INVALID_VALUE); |
| 8454 | } |
| 8455 | |
| 8456 | if (location == -1) |
| 8457 | { |
| 8458 | return; |
| 8459 | } |
| 8460 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8461 | gl::Context *context = gl::getNonLostContext(); |
| 8462 | |
| 8463 | if (context) |
| 8464 | { |
| 8465 | if (context->getClientVersion() < 3) |
| 8466 | { |
| 8467 | return gl::error(GL_INVALID_OPERATION); |
| 8468 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8469 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8470 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8471 | if (!programBinary) |
| 8472 | { |
| 8473 | return gl::error(GL_INVALID_OPERATION); |
| 8474 | } |
| 8475 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8476 | if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8477 | { |
| 8478 | return gl::error(GL_INVALID_OPERATION); |
| 8479 | } |
| 8480 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8481 | } |
| 8482 | catch(std::bad_alloc&) |
| 8483 | { |
| 8484 | return gl::error(GL_OUT_OF_MEMORY); |
| 8485 | } |
| 8486 | } |
| 8487 | |
| 8488 | void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8489 | { |
| 8490 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8491 | location, count, transpose, value); |
| 8492 | |
| 8493 | try |
| 8494 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8495 | if (count < 0) |
| 8496 | { |
| 8497 | return gl::error(GL_INVALID_VALUE); |
| 8498 | } |
| 8499 | |
| 8500 | if (location == -1) |
| 8501 | { |
| 8502 | return; |
| 8503 | } |
| 8504 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8505 | gl::Context *context = gl::getNonLostContext(); |
| 8506 | |
| 8507 | if (context) |
| 8508 | { |
| 8509 | if (context->getClientVersion() < 3) |
| 8510 | { |
| 8511 | return gl::error(GL_INVALID_OPERATION); |
| 8512 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8513 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8514 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8515 | if (!programBinary) |
| 8516 | { |
| 8517 | return gl::error(GL_INVALID_OPERATION); |
| 8518 | } |
| 8519 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8520 | if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8521 | { |
| 8522 | return gl::error(GL_INVALID_OPERATION); |
| 8523 | } |
| 8524 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8525 | } |
| 8526 | catch(std::bad_alloc&) |
| 8527 | { |
| 8528 | return gl::error(GL_OUT_OF_MEMORY); |
| 8529 | } |
| 8530 | } |
| 8531 | |
| 8532 | void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8533 | { |
| 8534 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8535 | location, count, transpose, value); |
| 8536 | |
| 8537 | try |
| 8538 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8539 | if (count < 0) |
| 8540 | { |
| 8541 | return gl::error(GL_INVALID_VALUE); |
| 8542 | } |
| 8543 | |
| 8544 | if (location == -1) |
| 8545 | { |
| 8546 | return; |
| 8547 | } |
| 8548 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8549 | gl::Context *context = gl::getNonLostContext(); |
| 8550 | |
| 8551 | if (context) |
| 8552 | { |
| 8553 | if (context->getClientVersion() < 3) |
| 8554 | { |
| 8555 | return gl::error(GL_INVALID_OPERATION); |
| 8556 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8557 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8558 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8559 | if (!programBinary) |
| 8560 | { |
| 8561 | return gl::error(GL_INVALID_OPERATION); |
| 8562 | } |
| 8563 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8564 | if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8565 | { |
| 8566 | return gl::error(GL_INVALID_OPERATION); |
| 8567 | } |
| 8568 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8569 | } |
| 8570 | catch(std::bad_alloc&) |
| 8571 | { |
| 8572 | return gl::error(GL_OUT_OF_MEMORY); |
| 8573 | } |
| 8574 | } |
| 8575 | |
| 8576 | void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8577 | { |
| 8578 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8579 | location, count, transpose, value); |
| 8580 | |
| 8581 | try |
| 8582 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8583 | if (count < 0) |
| 8584 | { |
| 8585 | return gl::error(GL_INVALID_VALUE); |
| 8586 | } |
| 8587 | |
| 8588 | if (location == -1) |
| 8589 | { |
| 8590 | return; |
| 8591 | } |
| 8592 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8593 | gl::Context *context = gl::getNonLostContext(); |
| 8594 | |
| 8595 | if (context) |
| 8596 | { |
| 8597 | if (context->getClientVersion() < 3) |
| 8598 | { |
| 8599 | return gl::error(GL_INVALID_OPERATION); |
| 8600 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8601 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8602 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8603 | if (!programBinary) |
| 8604 | { |
| 8605 | return gl::error(GL_INVALID_OPERATION); |
| 8606 | } |
| 8607 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8608 | if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8609 | { |
| 8610 | return gl::error(GL_INVALID_OPERATION); |
| 8611 | } |
| 8612 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8613 | } |
| 8614 | catch(std::bad_alloc&) |
| 8615 | { |
| 8616 | return gl::error(GL_OUT_OF_MEMORY); |
| 8617 | } |
| 8618 | } |
| 8619 | |
| 8620 | void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8621 | { |
| 8622 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8623 | location, count, transpose, value); |
| 8624 | |
| 8625 | try |
| 8626 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8627 | if (count < 0) |
| 8628 | { |
| 8629 | return gl::error(GL_INVALID_VALUE); |
| 8630 | } |
| 8631 | |
| 8632 | if (location == -1) |
| 8633 | { |
| 8634 | return; |
| 8635 | } |
| 8636 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8637 | gl::Context *context = gl::getNonLostContext(); |
| 8638 | |
| 8639 | if (context) |
| 8640 | { |
| 8641 | if (context->getClientVersion() < 3) |
| 8642 | { |
| 8643 | return gl::error(GL_INVALID_OPERATION); |
| 8644 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8645 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8646 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8647 | if (!programBinary) |
| 8648 | { |
| 8649 | return gl::error(GL_INVALID_OPERATION); |
| 8650 | } |
| 8651 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8652 | if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8653 | { |
| 8654 | return gl::error(GL_INVALID_OPERATION); |
| 8655 | } |
| 8656 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8657 | } |
| 8658 | catch(std::bad_alloc&) |
| 8659 | { |
| 8660 | return gl::error(GL_OUT_OF_MEMORY); |
| 8661 | } |
| 8662 | } |
| 8663 | |
| 8664 | void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) |
| 8665 | { |
| 8666 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, " |
| 8667 | "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 8668 | srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 8669 | |
| 8670 | try |
| 8671 | { |
| 8672 | gl::Context *context = gl::getNonLostContext(); |
| 8673 | |
| 8674 | if (context) |
| 8675 | { |
| 8676 | if (context->getClientVersion() < 3) |
| 8677 | { |
| 8678 | return gl::error(GL_INVALID_OPERATION); |
| 8679 | } |
| 8680 | } |
| 8681 | |
| 8682 | UNIMPLEMENTED(); |
| 8683 | } |
| 8684 | catch(std::bad_alloc&) |
| 8685 | { |
| 8686 | return gl::error(GL_OUT_OF_MEMORY); |
| 8687 | } |
| 8688 | } |
| 8689 | |
| 8690 | void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| 8691 | { |
| 8692 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 8693 | target, samples, internalformat, width, height); |
| 8694 | |
| 8695 | try |
| 8696 | { |
| 8697 | gl::Context *context = gl::getNonLostContext(); |
| 8698 | |
| 8699 | if (context) |
| 8700 | { |
| 8701 | if (context->getClientVersion() < 3) |
| 8702 | { |
| 8703 | return gl::error(GL_INVALID_OPERATION); |
| 8704 | } |
| 8705 | } |
| 8706 | |
| 8707 | UNIMPLEMENTED(); |
| 8708 | } |
| 8709 | catch(std::bad_alloc&) |
| 8710 | { |
| 8711 | return gl::error(GL_OUT_OF_MEMORY); |
| 8712 | } |
| 8713 | } |
| 8714 | |
| 8715 | void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) |
| 8716 | { |
| 8717 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)", |
| 8718 | target, attachment, texture, level, layer); |
| 8719 | |
| 8720 | try |
| 8721 | { |
| 8722 | gl::Context *context = gl::getNonLostContext(); |
| 8723 | |
| 8724 | if (context) |
| 8725 | { |
| 8726 | if (context->getClientVersion() < 3) |
| 8727 | { |
| 8728 | return gl::error(GL_INVALID_OPERATION); |
| 8729 | } |
| 8730 | } |
| 8731 | |
| 8732 | UNIMPLEMENTED(); |
| 8733 | } |
| 8734 | catch(std::bad_alloc&) |
| 8735 | { |
| 8736 | return gl::error(GL_OUT_OF_MEMORY); |
| 8737 | } |
| 8738 | } |
| 8739 | |
| 8740 | GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 8741 | { |
| 8742 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 8743 | target, offset, length, access); |
| 8744 | |
| 8745 | try |
| 8746 | { |
| 8747 | gl::Context *context = gl::getNonLostContext(); |
| 8748 | |
| 8749 | if (context) |
| 8750 | { |
| 8751 | if (context->getClientVersion() < 3) |
| 8752 | { |
| 8753 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 8754 | } |
| 8755 | } |
| 8756 | |
| 8757 | UNIMPLEMENTED(); |
| 8758 | } |
| 8759 | catch(std::bad_alloc&) |
| 8760 | { |
| 8761 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL)); |
| 8762 | } |
| 8763 | |
| 8764 | return NULL; |
| 8765 | } |
| 8766 | |
| 8767 | void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) |
| 8768 | { |
| 8769 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 8770 | |
| 8771 | try |
| 8772 | { |
| 8773 | gl::Context *context = gl::getNonLostContext(); |
| 8774 | |
| 8775 | if (context) |
| 8776 | { |
| 8777 | if (context->getClientVersion() < 3) |
| 8778 | { |
| 8779 | return gl::error(GL_INVALID_OPERATION); |
| 8780 | } |
| 8781 | } |
| 8782 | |
| 8783 | UNIMPLEMENTED(); |
| 8784 | } |
| 8785 | catch(std::bad_alloc&) |
| 8786 | { |
| 8787 | return gl::error(GL_OUT_OF_MEMORY); |
| 8788 | } |
| 8789 | } |
| 8790 | |
| 8791 | void __stdcall glBindVertexArray(GLuint array) |
| 8792 | { |
| 8793 | EVENT("(GLuint array = %u)", array); |
| 8794 | |
| 8795 | try |
| 8796 | { |
| 8797 | gl::Context *context = gl::getNonLostContext(); |
| 8798 | |
| 8799 | if (context) |
| 8800 | { |
| 8801 | if (context->getClientVersion() < 3) |
| 8802 | { |
| 8803 | return gl::error(GL_INVALID_OPERATION); |
| 8804 | } |
| 8805 | } |
| 8806 | |
| 8807 | UNIMPLEMENTED(); |
| 8808 | } |
| 8809 | catch(std::bad_alloc&) |
| 8810 | { |
| 8811 | return gl::error(GL_OUT_OF_MEMORY); |
| 8812 | } |
| 8813 | } |
| 8814 | |
| 8815 | void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) |
| 8816 | { |
| 8817 | EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays); |
| 8818 | |
| 8819 | try |
| 8820 | { |
| 8821 | gl::Context *context = gl::getNonLostContext(); |
| 8822 | |
| 8823 | if (context) |
| 8824 | { |
| 8825 | if (context->getClientVersion() < 3) |
| 8826 | { |
| 8827 | return gl::error(GL_INVALID_OPERATION); |
| 8828 | } |
| 8829 | } |
| 8830 | |
| 8831 | UNIMPLEMENTED(); |
| 8832 | } |
| 8833 | catch(std::bad_alloc&) |
| 8834 | { |
| 8835 | return gl::error(GL_OUT_OF_MEMORY); |
| 8836 | } |
| 8837 | } |
| 8838 | |
| 8839 | void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) |
| 8840 | { |
| 8841 | EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays); |
| 8842 | |
| 8843 | try |
| 8844 | { |
| 8845 | gl::Context *context = gl::getNonLostContext(); |
| 8846 | |
| 8847 | if (context) |
| 8848 | { |
| 8849 | if (context->getClientVersion() < 3) |
| 8850 | { |
| 8851 | return gl::error(GL_INVALID_OPERATION); |
| 8852 | } |
| 8853 | } |
| 8854 | |
| 8855 | UNIMPLEMENTED(); |
| 8856 | } |
| 8857 | catch(std::bad_alloc&) |
| 8858 | { |
| 8859 | return gl::error(GL_OUT_OF_MEMORY); |
| 8860 | } |
| 8861 | } |
| 8862 | |
| 8863 | GLboolean __stdcall glIsVertexArray(GLuint array) |
| 8864 | { |
| 8865 | EVENT("(GLuint array = %u)", array); |
| 8866 | |
| 8867 | try |
| 8868 | { |
| 8869 | gl::Context *context = gl::getNonLostContext(); |
| 8870 | |
| 8871 | if (context) |
| 8872 | { |
| 8873 | if (context->getClientVersion() < 3) |
| 8874 | { |
| 8875 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8876 | } |
| 8877 | } |
| 8878 | |
| 8879 | UNIMPLEMENTED(); |
| 8880 | } |
| 8881 | catch(std::bad_alloc&) |
| 8882 | { |
| 8883 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8884 | } |
| 8885 | |
| 8886 | return GL_FALSE; |
| 8887 | } |
| 8888 | |
| 8889 | void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data) |
| 8890 | { |
| 8891 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)", |
| 8892 | target, index, data); |
| 8893 | |
| 8894 | try |
| 8895 | { |
| 8896 | gl::Context *context = gl::getNonLostContext(); |
| 8897 | |
| 8898 | if (context) |
| 8899 | { |
| 8900 | if (context->getClientVersion() < 3) |
| 8901 | { |
| 8902 | return gl::error(GL_INVALID_OPERATION); |
| 8903 | } |
| 8904 | } |
| 8905 | |
| 8906 | UNIMPLEMENTED(); |
| 8907 | } |
| 8908 | catch(std::bad_alloc&) |
| 8909 | { |
| 8910 | return gl::error(GL_OUT_OF_MEMORY); |
| 8911 | } |
| 8912 | } |
| 8913 | |
| 8914 | void __stdcall glBeginTransformFeedback(GLenum primitiveMode) |
| 8915 | { |
| 8916 | EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode); |
| 8917 | |
| 8918 | try |
| 8919 | { |
| 8920 | gl::Context *context = gl::getNonLostContext(); |
| 8921 | |
| 8922 | if (context) |
| 8923 | { |
| 8924 | if (context->getClientVersion() < 3) |
| 8925 | { |
| 8926 | return gl::error(GL_INVALID_OPERATION); |
| 8927 | } |
| 8928 | } |
| 8929 | |
| 8930 | UNIMPLEMENTED(); |
| 8931 | } |
| 8932 | catch(std::bad_alloc&) |
| 8933 | { |
| 8934 | return gl::error(GL_OUT_OF_MEMORY); |
| 8935 | } |
| 8936 | } |
| 8937 | |
| 8938 | void __stdcall glEndTransformFeedback(void) |
| 8939 | { |
| 8940 | EVENT("(void)"); |
| 8941 | |
| 8942 | try |
| 8943 | { |
| 8944 | gl::Context *context = gl::getNonLostContext(); |
| 8945 | |
| 8946 | if (context) |
| 8947 | { |
| 8948 | if (context->getClientVersion() < 3) |
| 8949 | { |
| 8950 | return gl::error(GL_INVALID_OPERATION); |
| 8951 | } |
| 8952 | } |
| 8953 | |
| 8954 | UNIMPLEMENTED(); |
| 8955 | } |
| 8956 | catch(std::bad_alloc&) |
| 8957 | { |
| 8958 | return gl::error(GL_OUT_OF_MEMORY); |
| 8959 | } |
| 8960 | } |
| 8961 | |
| 8962 | void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
| 8963 | { |
| 8964 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)", |
| 8965 | target, index, buffer, offset, size); |
| 8966 | |
| 8967 | try |
| 8968 | { |
| 8969 | gl::Context *context = gl::getNonLostContext(); |
| 8970 | |
| 8971 | if (context) |
| 8972 | { |
| 8973 | if (context->getClientVersion() < 3) |
| 8974 | { |
| 8975 | return gl::error(GL_INVALID_OPERATION); |
| 8976 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8977 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 8978 | switch (target) |
| 8979 | { |
| 8980 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 8981 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 8982 | { |
| 8983 | return gl::error(GL_INVALID_VALUE); |
| 8984 | } |
| 8985 | break; |
| 8986 | |
| 8987 | case GL_UNIFORM_BUFFER: |
| 8988 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 8989 | { |
| 8990 | return gl::error(GL_INVALID_VALUE); |
| 8991 | } |
| 8992 | break; |
| 8993 | |
| 8994 | default: |
| 8995 | return gl::error(GL_INVALID_ENUM); |
| 8996 | } |
| 8997 | |
shannonwoods@chromium.org | e6e0079 | 2013-05-30 00:06:07 +0000 | [diff] [blame] | 8998 | if (buffer != 0 && size <= 0) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 8999 | { |
| 9000 | return gl::error(GL_INVALID_VALUE); |
| 9001 | } |
| 9002 | |
| 9003 | switch (target) |
| 9004 | { |
| 9005 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | a26aeaf | 2013-05-30 00:06:13 +0000 | [diff] [blame] | 9006 | |
| 9007 | // size and offset must be a multiple of 4 |
| 9008 | if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) |
| 9009 | { |
| 9010 | return gl::error(GL_INVALID_VALUE); |
| 9011 | } |
| 9012 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9013 | context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 9014 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9015 | break; |
| 9016 | |
| 9017 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 97c3d50 | 2013-05-30 00:04:34 +0000 | [diff] [blame] | 9018 | |
| 9019 | // it is an error to bind an offset not a multiple of the alignment |
| 9020 | if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0) |
| 9021 | { |
| 9022 | return gl::error(GL_INVALID_VALUE); |
| 9023 | } |
| 9024 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9025 | context->bindIndexedUniformBuffer(buffer, index, offset, size); |
| 9026 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9027 | break; |
| 9028 | |
| 9029 | default: |
| 9030 | UNREACHABLE(); |
| 9031 | } |
| 9032 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9033 | } |
| 9034 | catch(std::bad_alloc&) |
| 9035 | { |
| 9036 | return gl::error(GL_OUT_OF_MEMORY); |
| 9037 | } |
| 9038 | } |
| 9039 | |
| 9040 | void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 9041 | { |
| 9042 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)", |
| 9043 | target, index, buffer); |
| 9044 | |
| 9045 | try |
| 9046 | { |
| 9047 | gl::Context *context = gl::getNonLostContext(); |
| 9048 | |
| 9049 | if (context) |
| 9050 | { |
| 9051 | if (context->getClientVersion() < 3) |
| 9052 | { |
| 9053 | return gl::error(GL_INVALID_OPERATION); |
| 9054 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9055 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9056 | switch (target) |
| 9057 | { |
| 9058 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9059 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9060 | { |
| 9061 | return gl::error(GL_INVALID_VALUE); |
| 9062 | } |
| 9063 | break; |
| 9064 | |
| 9065 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9066 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9067 | { |
| 9068 | return gl::error(GL_INVALID_VALUE); |
| 9069 | } |
| 9070 | break; |
| 9071 | |
| 9072 | default: |
| 9073 | return gl::error(GL_INVALID_ENUM); |
| 9074 | } |
| 9075 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9076 | switch (target) |
| 9077 | { |
| 9078 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9079 | context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9080 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9081 | break; |
| 9082 | |
| 9083 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9084 | context->bindIndexedUniformBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9085 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9086 | break; |
| 9087 | |
| 9088 | default: |
| 9089 | UNREACHABLE(); |
| 9090 | } |
| 9091 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9092 | } |
| 9093 | catch(std::bad_alloc&) |
| 9094 | { |
| 9095 | return gl::error(GL_OUT_OF_MEMORY); |
| 9096 | } |
| 9097 | } |
| 9098 | |
| 9099 | void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
| 9100 | { |
| 9101 | EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)", |
| 9102 | program, count, varyings, bufferMode); |
| 9103 | |
| 9104 | try |
| 9105 | { |
| 9106 | gl::Context *context = gl::getNonLostContext(); |
| 9107 | |
| 9108 | if (context) |
| 9109 | { |
| 9110 | if (context->getClientVersion() < 3) |
| 9111 | { |
| 9112 | return gl::error(GL_INVALID_OPERATION); |
| 9113 | } |
| 9114 | } |
| 9115 | |
| 9116 | UNIMPLEMENTED(); |
| 9117 | } |
| 9118 | catch(std::bad_alloc&) |
| 9119 | { |
| 9120 | return gl::error(GL_OUT_OF_MEMORY); |
| 9121 | } |
| 9122 | } |
| 9123 | |
| 9124 | void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
| 9125 | { |
| 9126 | EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, " |
| 9127 | "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
| 9128 | program, index, bufSize, length, size, type, name); |
| 9129 | |
| 9130 | try |
| 9131 | { |
| 9132 | gl::Context *context = gl::getNonLostContext(); |
| 9133 | |
| 9134 | if (context) |
| 9135 | { |
| 9136 | if (context->getClientVersion() < 3) |
| 9137 | { |
| 9138 | return gl::error(GL_INVALID_OPERATION); |
| 9139 | } |
| 9140 | } |
| 9141 | |
| 9142 | UNIMPLEMENTED(); |
| 9143 | } |
| 9144 | catch(std::bad_alloc&) |
| 9145 | { |
| 9146 | return gl::error(GL_OUT_OF_MEMORY); |
| 9147 | } |
| 9148 | } |
| 9149 | |
| 9150 | void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) |
| 9151 | { |
| 9152 | EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)", |
| 9153 | index, size, type, stride, pointer); |
| 9154 | |
| 9155 | try |
| 9156 | { |
| 9157 | gl::Context *context = gl::getNonLostContext(); |
| 9158 | |
| 9159 | if (context) |
| 9160 | { |
| 9161 | if (context->getClientVersion() < 3) |
| 9162 | { |
| 9163 | return gl::error(GL_INVALID_OPERATION); |
| 9164 | } |
| 9165 | } |
| 9166 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9167 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9168 | { |
| 9169 | return gl::error(GL_INVALID_VALUE); |
| 9170 | } |
| 9171 | |
| 9172 | if (size < 1 || size > 4) |
| 9173 | { |
| 9174 | return gl::error(GL_INVALID_VALUE); |
| 9175 | } |
| 9176 | |
| 9177 | switch (type) |
| 9178 | { |
| 9179 | case GL_BYTE: |
| 9180 | case GL_UNSIGNED_BYTE: |
| 9181 | case GL_SHORT: |
| 9182 | case GL_UNSIGNED_SHORT: |
| 9183 | case GL_INT: |
| 9184 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9185 | case GL_INT_2_10_10_10_REV: |
| 9186 | 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] | 9187 | break; |
| 9188 | default: |
| 9189 | return gl::error(GL_INVALID_ENUM); |
| 9190 | } |
| 9191 | |
| 9192 | if (stride < 0) |
| 9193 | { |
| 9194 | return gl::error(GL_INVALID_VALUE); |
| 9195 | } |
| 9196 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9197 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 9198 | { |
| 9199 | return gl::error(GL_INVALID_OPERATION); |
| 9200 | } |
| 9201 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9202 | if (context) |
| 9203 | { |
| 9204 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true, |
| 9205 | stride, pointer); |
| 9206 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9207 | } |
| 9208 | catch(std::bad_alloc&) |
| 9209 | { |
| 9210 | return gl::error(GL_OUT_OF_MEMORY); |
| 9211 | } |
| 9212 | } |
| 9213 | |
| 9214 | void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) |
| 9215 | { |
| 9216 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 9217 | index, pname, params); |
| 9218 | |
| 9219 | try |
| 9220 | { |
| 9221 | gl::Context *context = gl::getNonLostContext(); |
| 9222 | |
| 9223 | if (context) |
| 9224 | { |
| 9225 | if (context->getClientVersion() < 3) |
| 9226 | { |
| 9227 | return gl::error(GL_INVALID_OPERATION); |
| 9228 | } |
| 9229 | } |
| 9230 | |
| 9231 | UNIMPLEMENTED(); |
| 9232 | } |
| 9233 | catch(std::bad_alloc&) |
| 9234 | { |
| 9235 | return gl::error(GL_OUT_OF_MEMORY); |
| 9236 | } |
| 9237 | } |
| 9238 | |
| 9239 | void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) |
| 9240 | { |
| 9241 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)", |
| 9242 | index, pname, params); |
| 9243 | |
| 9244 | try |
| 9245 | { |
| 9246 | gl::Context *context = gl::getNonLostContext(); |
| 9247 | |
| 9248 | if (context) |
| 9249 | { |
| 9250 | if (context->getClientVersion() < 3) |
| 9251 | { |
| 9252 | return gl::error(GL_INVALID_OPERATION); |
| 9253 | } |
| 9254 | } |
| 9255 | |
| 9256 | UNIMPLEMENTED(); |
| 9257 | } |
| 9258 | catch(std::bad_alloc&) |
| 9259 | { |
| 9260 | return gl::error(GL_OUT_OF_MEMORY); |
| 9261 | } |
| 9262 | } |
| 9263 | |
| 9264 | void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 9265 | { |
| 9266 | EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)", |
| 9267 | index, x, y, z, w); |
| 9268 | |
| 9269 | try |
| 9270 | { |
| 9271 | gl::Context *context = gl::getNonLostContext(); |
| 9272 | |
| 9273 | if (context) |
| 9274 | { |
| 9275 | if (context->getClientVersion() < 3) |
| 9276 | { |
| 9277 | return gl::error(GL_INVALID_OPERATION); |
| 9278 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9279 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9280 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9281 | { |
| 9282 | return gl::error(GL_INVALID_VALUE); |
| 9283 | } |
| 9284 | |
| 9285 | GLint vals[4] = { x, y, z, w }; |
| 9286 | context->setVertexAttribi(index, vals); |
| 9287 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9288 | } |
| 9289 | catch(std::bad_alloc&) |
| 9290 | { |
| 9291 | return gl::error(GL_OUT_OF_MEMORY); |
| 9292 | } |
| 9293 | } |
| 9294 | |
| 9295 | void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 9296 | { |
| 9297 | EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)", |
| 9298 | index, x, y, z, w); |
| 9299 | |
| 9300 | try |
| 9301 | { |
| 9302 | gl::Context *context = gl::getNonLostContext(); |
| 9303 | |
| 9304 | if (context) |
| 9305 | { |
| 9306 | if (context->getClientVersion() < 3) |
| 9307 | { |
| 9308 | return gl::error(GL_INVALID_OPERATION); |
| 9309 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9310 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9311 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9312 | { |
| 9313 | return gl::error(GL_INVALID_VALUE); |
| 9314 | } |
| 9315 | |
| 9316 | GLuint vals[4] = { x, y, z, w }; |
| 9317 | context->setVertexAttribu(index, vals); |
| 9318 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9319 | } |
| 9320 | catch(std::bad_alloc&) |
| 9321 | { |
| 9322 | return gl::error(GL_OUT_OF_MEMORY); |
| 9323 | } |
| 9324 | } |
| 9325 | |
| 9326 | void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) |
| 9327 | { |
| 9328 | EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v); |
| 9329 | |
| 9330 | try |
| 9331 | { |
| 9332 | gl::Context *context = gl::getNonLostContext(); |
| 9333 | |
| 9334 | if (context) |
| 9335 | { |
| 9336 | if (context->getClientVersion() < 3) |
| 9337 | { |
| 9338 | return gl::error(GL_INVALID_OPERATION); |
| 9339 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9340 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9341 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9342 | { |
| 9343 | return gl::error(GL_INVALID_VALUE); |
| 9344 | } |
| 9345 | |
| 9346 | context->setVertexAttribi(index, v); |
| 9347 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9348 | } |
| 9349 | catch(std::bad_alloc&) |
| 9350 | { |
| 9351 | return gl::error(GL_OUT_OF_MEMORY); |
| 9352 | } |
| 9353 | } |
| 9354 | |
| 9355 | void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v) |
| 9356 | { |
| 9357 | EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v); |
| 9358 | |
| 9359 | try |
| 9360 | { |
| 9361 | gl::Context *context = gl::getNonLostContext(); |
| 9362 | |
| 9363 | if (context) |
| 9364 | { |
| 9365 | if (context->getClientVersion() < 3) |
| 9366 | { |
| 9367 | return gl::error(GL_INVALID_OPERATION); |
| 9368 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9369 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9370 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9371 | { |
| 9372 | return gl::error(GL_INVALID_VALUE); |
| 9373 | } |
| 9374 | |
| 9375 | context->setVertexAttribu(index, v); |
| 9376 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9377 | } |
| 9378 | catch(std::bad_alloc&) |
| 9379 | { |
| 9380 | return gl::error(GL_OUT_OF_MEMORY); |
| 9381 | } |
| 9382 | } |
| 9383 | |
| 9384 | void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) |
| 9385 | { |
| 9386 | EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)", |
| 9387 | program, location, params); |
| 9388 | |
| 9389 | try |
| 9390 | { |
| 9391 | gl::Context *context = gl::getNonLostContext(); |
| 9392 | |
| 9393 | if (context) |
| 9394 | { |
| 9395 | if (context->getClientVersion() < 3) |
| 9396 | { |
| 9397 | return gl::error(GL_INVALID_OPERATION); |
| 9398 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9399 | |
shannon.woods%transgaming.com@gtempaccount.com | e229012 | 2013-04-13 03:41:07 +0000 | [diff] [blame] | 9400 | if (program == 0) |
| 9401 | { |
| 9402 | return gl::error(GL_INVALID_VALUE); |
| 9403 | } |
| 9404 | |
| 9405 | gl::Program *programObject = context->getProgram(program); |
| 9406 | |
| 9407 | if (!programObject || !programObject->isLinked()) |
| 9408 | { |
| 9409 | return gl::error(GL_INVALID_OPERATION); |
| 9410 | } |
| 9411 | |
| 9412 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9413 | if (!programBinary) |
| 9414 | { |
| 9415 | return gl::error(GL_INVALID_OPERATION); |
| 9416 | } |
| 9417 | |
| 9418 | if (!programBinary->getUniformuiv(location, NULL, params)) |
| 9419 | { |
| 9420 | return gl::error(GL_INVALID_OPERATION); |
| 9421 | } |
| 9422 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9423 | } |
| 9424 | catch(std::bad_alloc&) |
| 9425 | { |
| 9426 | return gl::error(GL_OUT_OF_MEMORY); |
| 9427 | } |
| 9428 | } |
| 9429 | |
| 9430 | GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) |
| 9431 | { |
| 9432 | EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)", |
| 9433 | program, name); |
| 9434 | |
| 9435 | try |
| 9436 | { |
| 9437 | gl::Context *context = gl::getNonLostContext(); |
| 9438 | |
| 9439 | if (context) |
| 9440 | { |
| 9441 | if (context->getClientVersion() < 3) |
| 9442 | { |
| 9443 | return gl::error(GL_INVALID_OPERATION, 0); |
| 9444 | } |
| 9445 | } |
| 9446 | |
| 9447 | UNIMPLEMENTED(); |
| 9448 | } |
| 9449 | catch(std::bad_alloc&) |
| 9450 | { |
| 9451 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 9452 | } |
| 9453 | |
| 9454 | return 0; |
| 9455 | } |
| 9456 | |
| 9457 | void __stdcall glUniform1ui(GLint location, GLuint v0) |
| 9458 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9459 | glUniform1uiv(location, 1, &v0); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9460 | } |
| 9461 | |
| 9462 | void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1) |
| 9463 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9464 | const GLuint xy[] = { v0, v1 }; |
| 9465 | glUniform2uiv(location, 1, xy); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9466 | } |
| 9467 | |
| 9468 | void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 9469 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9470 | const GLuint xyz[] = { v0, v1, v2 }; |
| 9471 | glUniform3uiv(location, 1, xyz); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9472 | } |
| 9473 | |
| 9474 | void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 9475 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9476 | const GLuint xyzw[] = { v0, v1, v2, v3 }; |
| 9477 | glUniform4uiv(location, 1, xyzw); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9478 | } |
| 9479 | |
| 9480 | void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) |
| 9481 | { |
| 9482 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9483 | location, count, value); |
| 9484 | |
| 9485 | try |
| 9486 | { |
| 9487 | gl::Context *context = gl::getNonLostContext(); |
| 9488 | |
| 9489 | if (context) |
| 9490 | { |
| 9491 | if (context->getClientVersion() < 3) |
| 9492 | { |
| 9493 | return gl::error(GL_INVALID_OPERATION); |
| 9494 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9495 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9496 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9497 | if (!programBinary) |
| 9498 | { |
| 9499 | return gl::error(GL_INVALID_OPERATION); |
| 9500 | } |
| 9501 | |
| 9502 | if (!programBinary->setUniform1uiv(location, count, value)) |
| 9503 | { |
| 9504 | return gl::error(GL_INVALID_OPERATION); |
| 9505 | } |
| 9506 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9507 | } |
| 9508 | catch(std::bad_alloc&) |
| 9509 | { |
| 9510 | return gl::error(GL_OUT_OF_MEMORY); |
| 9511 | } |
| 9512 | } |
| 9513 | |
| 9514 | void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) |
| 9515 | { |
| 9516 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9517 | location, count, value); |
| 9518 | |
| 9519 | try |
| 9520 | { |
| 9521 | gl::Context *context = gl::getNonLostContext(); |
| 9522 | |
| 9523 | if (context) |
| 9524 | { |
| 9525 | if (context->getClientVersion() < 3) |
| 9526 | { |
| 9527 | return gl::error(GL_INVALID_OPERATION); |
| 9528 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9529 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9530 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9531 | if (!programBinary) |
| 9532 | { |
| 9533 | return gl::error(GL_INVALID_OPERATION); |
| 9534 | } |
| 9535 | |
| 9536 | if (!programBinary->setUniform2uiv(location, count, value)) |
| 9537 | { |
| 9538 | return gl::error(GL_INVALID_OPERATION); |
| 9539 | } |
| 9540 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9541 | } |
| 9542 | catch(std::bad_alloc&) |
| 9543 | { |
| 9544 | return gl::error(GL_OUT_OF_MEMORY); |
| 9545 | } |
| 9546 | } |
| 9547 | |
| 9548 | void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) |
| 9549 | { |
| 9550 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)", |
| 9551 | location, count, value); |
| 9552 | |
| 9553 | try |
| 9554 | { |
| 9555 | gl::Context *context = gl::getNonLostContext(); |
| 9556 | |
| 9557 | if (context) |
| 9558 | { |
| 9559 | if (context->getClientVersion() < 3) |
| 9560 | { |
| 9561 | return gl::error(GL_INVALID_OPERATION); |
| 9562 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9563 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9564 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9565 | if (!programBinary) |
| 9566 | { |
| 9567 | return gl::error(GL_INVALID_OPERATION); |
| 9568 | } |
| 9569 | |
| 9570 | if (!programBinary->setUniform3uiv(location, count, value)) |
| 9571 | { |
| 9572 | return gl::error(GL_INVALID_OPERATION); |
| 9573 | } |
| 9574 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9575 | } |
| 9576 | catch(std::bad_alloc&) |
| 9577 | { |
| 9578 | return gl::error(GL_OUT_OF_MEMORY); |
| 9579 | } |
| 9580 | } |
| 9581 | |
| 9582 | void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) |
| 9583 | { |
| 9584 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9585 | location, count, value); |
| 9586 | |
| 9587 | try |
| 9588 | { |
| 9589 | gl::Context *context = gl::getNonLostContext(); |
| 9590 | |
| 9591 | if (context) |
| 9592 | { |
| 9593 | if (context->getClientVersion() < 3) |
| 9594 | { |
| 9595 | return gl::error(GL_INVALID_OPERATION); |
| 9596 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9597 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9598 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9599 | if (!programBinary) |
| 9600 | { |
| 9601 | return gl::error(GL_INVALID_OPERATION); |
| 9602 | } |
| 9603 | |
| 9604 | if (!programBinary->setUniform4uiv(location, count, value)) |
| 9605 | { |
| 9606 | return gl::error(GL_INVALID_OPERATION); |
| 9607 | } |
| 9608 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9609 | } |
| 9610 | catch(std::bad_alloc&) |
| 9611 | { |
| 9612 | return gl::error(GL_OUT_OF_MEMORY); |
| 9613 | } |
| 9614 | } |
| 9615 | |
| 9616 | void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) |
| 9617 | { |
| 9618 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)", |
| 9619 | buffer, drawbuffer, value); |
| 9620 | |
| 9621 | try |
| 9622 | { |
| 9623 | gl::Context *context = gl::getNonLostContext(); |
| 9624 | |
| 9625 | if (context) |
| 9626 | { |
| 9627 | if (context->getClientVersion() < 3) |
| 9628 | { |
| 9629 | return gl::error(GL_INVALID_OPERATION); |
| 9630 | } |
| 9631 | } |
| 9632 | |
| 9633 | UNIMPLEMENTED(); |
| 9634 | } |
| 9635 | catch(std::bad_alloc&) |
| 9636 | { |
| 9637 | return gl::error(GL_OUT_OF_MEMORY); |
| 9638 | } |
| 9639 | } |
| 9640 | |
| 9641 | void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) |
| 9642 | { |
| 9643 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)", |
| 9644 | buffer, drawbuffer, value); |
| 9645 | |
| 9646 | try |
| 9647 | { |
| 9648 | gl::Context *context = gl::getNonLostContext(); |
| 9649 | |
| 9650 | if (context) |
| 9651 | { |
| 9652 | if (context->getClientVersion() < 3) |
| 9653 | { |
| 9654 | return gl::error(GL_INVALID_OPERATION); |
| 9655 | } |
| 9656 | } |
| 9657 | |
| 9658 | UNIMPLEMENTED(); |
| 9659 | } |
| 9660 | catch(std::bad_alloc&) |
| 9661 | { |
| 9662 | return gl::error(GL_OUT_OF_MEMORY); |
| 9663 | } |
| 9664 | } |
| 9665 | |
| 9666 | void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) |
| 9667 | { |
| 9668 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)", |
| 9669 | buffer, drawbuffer, value); |
| 9670 | |
| 9671 | try |
| 9672 | { |
| 9673 | gl::Context *context = gl::getNonLostContext(); |
| 9674 | |
| 9675 | if (context) |
| 9676 | { |
| 9677 | if (context->getClientVersion() < 3) |
| 9678 | { |
| 9679 | return gl::error(GL_INVALID_OPERATION); |
| 9680 | } |
| 9681 | } |
| 9682 | |
| 9683 | UNIMPLEMENTED(); |
| 9684 | } |
| 9685 | catch(std::bad_alloc&) |
| 9686 | { |
| 9687 | return gl::error(GL_OUT_OF_MEMORY); |
| 9688 | } |
| 9689 | } |
| 9690 | |
| 9691 | void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 9692 | { |
| 9693 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)", |
| 9694 | buffer, drawbuffer, depth, stencil); |
| 9695 | |
| 9696 | try |
| 9697 | { |
| 9698 | gl::Context *context = gl::getNonLostContext(); |
| 9699 | |
| 9700 | if (context) |
| 9701 | { |
| 9702 | if (context->getClientVersion() < 3) |
| 9703 | { |
| 9704 | return gl::error(GL_INVALID_OPERATION); |
| 9705 | } |
| 9706 | } |
| 9707 | |
| 9708 | UNIMPLEMENTED(); |
| 9709 | } |
| 9710 | catch(std::bad_alloc&) |
| 9711 | { |
| 9712 | return gl::error(GL_OUT_OF_MEMORY); |
| 9713 | } |
| 9714 | } |
| 9715 | |
| 9716 | const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) |
| 9717 | { |
| 9718 | EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index); |
| 9719 | |
| 9720 | try |
| 9721 | { |
| 9722 | gl::Context *context = gl::getNonLostContext(); |
| 9723 | |
| 9724 | if (context) |
| 9725 | { |
| 9726 | if (context->getClientVersion() < 3) |
| 9727 | { |
| 9728 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL)); |
| 9729 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9730 | |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 9731 | if (name != GL_EXTENSIONS) |
| 9732 | { |
| 9733 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL)); |
| 9734 | } |
| 9735 | |
| 9736 | if (index >= context->getNumExtensions()) |
| 9737 | { |
| 9738 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL)); |
| 9739 | } |
| 9740 | |
| 9741 | return reinterpret_cast<const GLubyte*>(context->getExtensionString(index)); |
| 9742 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9743 | } |
| 9744 | catch(std::bad_alloc&) |
| 9745 | { |
| 9746 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL)); |
| 9747 | } |
| 9748 | |
| 9749 | return NULL; |
| 9750 | } |
| 9751 | |
| 9752 | void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 9753 | { |
| 9754 | EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)", |
| 9755 | readTarget, writeTarget, readOffset, writeOffset, size); |
| 9756 | |
| 9757 | try |
| 9758 | { |
| 9759 | gl::Context *context = gl::getNonLostContext(); |
| 9760 | |
| 9761 | if (context) |
| 9762 | { |
| 9763 | if (context->getClientVersion() < 3) |
| 9764 | { |
| 9765 | return gl::error(GL_INVALID_OPERATION); |
| 9766 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9767 | |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 9768 | gl::Buffer *readBuffer = NULL; |
| 9769 | switch (readTarget) |
| 9770 | { |
| 9771 | case GL_ARRAY_BUFFER: |
| 9772 | readBuffer = context->getArrayBuffer(); |
| 9773 | break; |
| 9774 | case GL_COPY_READ_BUFFER: |
| 9775 | readBuffer = context->getCopyReadBuffer(); |
| 9776 | break; |
| 9777 | case GL_COPY_WRITE_BUFFER: |
| 9778 | readBuffer = context->getCopyWriteBuffer(); |
| 9779 | break; |
| 9780 | case GL_ELEMENT_ARRAY_BUFFER: |
| 9781 | readBuffer = context->getElementArrayBuffer(); |
| 9782 | break; |
| 9783 | case GL_PIXEL_PACK_BUFFER: |
| 9784 | readBuffer = context->getPixelPackBuffer(); |
| 9785 | break; |
| 9786 | case GL_PIXEL_UNPACK_BUFFER: |
| 9787 | readBuffer = context->getPixelUnpackBuffer(); |
| 9788 | break; |
| 9789 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 9790 | readBuffer = context->getGenericTransformFeedbackBuffer(); |
| 9791 | break; |
| 9792 | case GL_UNIFORM_BUFFER: |
| 9793 | readBuffer = context->getGenericUniformBuffer(); |
| 9794 | break; |
| 9795 | default: |
| 9796 | return gl::error(GL_INVALID_ENUM); |
| 9797 | } |
| 9798 | |
| 9799 | gl::Buffer *writeBuffer = NULL; |
| 9800 | switch (writeTarget) |
| 9801 | { |
| 9802 | case GL_ARRAY_BUFFER: |
| 9803 | writeBuffer = context->getArrayBuffer(); |
| 9804 | break; |
| 9805 | case GL_COPY_READ_BUFFER: |
| 9806 | writeBuffer = context->getCopyReadBuffer(); |
| 9807 | break; |
| 9808 | case GL_COPY_WRITE_BUFFER: |
| 9809 | writeBuffer = context->getCopyWriteBuffer(); |
| 9810 | break; |
| 9811 | case GL_ELEMENT_ARRAY_BUFFER: |
| 9812 | writeBuffer = context->getElementArrayBuffer(); |
| 9813 | break; |
| 9814 | case GL_PIXEL_PACK_BUFFER: |
| 9815 | writeBuffer = context->getPixelPackBuffer(); |
| 9816 | break; |
| 9817 | case GL_PIXEL_UNPACK_BUFFER: |
| 9818 | writeBuffer = context->getPixelUnpackBuffer(); |
| 9819 | break; |
| 9820 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 9821 | writeBuffer = context->getGenericTransformFeedbackBuffer(); |
| 9822 | break; |
| 9823 | case GL_UNIFORM_BUFFER: |
| 9824 | writeBuffer = context->getGenericUniformBuffer(); |
| 9825 | break; |
| 9826 | default: |
| 9827 | return gl::error(GL_INVALID_ENUM); |
| 9828 | } |
| 9829 | |
| 9830 | if (!readBuffer || !writeBuffer) |
| 9831 | { |
| 9832 | return gl::error(GL_INVALID_OPERATION); |
| 9833 | } |
| 9834 | |
| 9835 | if (readOffset < 0 || writeOffset < 0 || size < 0 || |
| 9836 | static_cast<unsigned int>(readOffset + size) > readBuffer->size() || |
| 9837 | static_cast<unsigned int>(writeOffset + size) > writeBuffer->size()) |
| 9838 | { |
| 9839 | return gl::error(GL_INVALID_VALUE); |
| 9840 | } |
| 9841 | |
| 9842 | if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size) |
| 9843 | { |
| 9844 | return gl::error(GL_INVALID_VALUE); |
| 9845 | } |
| 9846 | |
| 9847 | // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION) |
| 9848 | |
shannon.woods%transgaming.com@gtempaccount.com | c53376a | 2013-04-13 03:41:23 +0000 | [diff] [blame] | 9849 | // if size is zero, the copy is a successful no-op |
| 9850 | if (size > 0) |
| 9851 | { |
| 9852 | writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); |
| 9853 | } |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 9854 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9855 | } |
| 9856 | catch(std::bad_alloc&) |
| 9857 | { |
| 9858 | return gl::error(GL_OUT_OF_MEMORY); |
| 9859 | } |
| 9860 | } |
| 9861 | |
| 9862 | void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) |
| 9863 | { |
| 9864 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)", |
| 9865 | program, uniformCount, uniformNames, uniformIndices); |
| 9866 | |
| 9867 | try |
| 9868 | { |
| 9869 | gl::Context *context = gl::getNonLostContext(); |
| 9870 | |
| 9871 | if (context) |
| 9872 | { |
| 9873 | if (context->getClientVersion() < 3) |
| 9874 | { |
| 9875 | return gl::error(GL_INVALID_OPERATION); |
| 9876 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9877 | |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 9878 | if (uniformCount < 0) |
| 9879 | { |
| 9880 | return gl::error(GL_INVALID_VALUE); |
| 9881 | } |
| 9882 | |
| 9883 | gl::Program *programObject = context->getProgram(program); |
| 9884 | |
| 9885 | if (!programObject) |
| 9886 | { |
| 9887 | if (context->getShader(program)) |
| 9888 | { |
| 9889 | return gl::error(GL_INVALID_OPERATION); |
| 9890 | } |
| 9891 | else |
| 9892 | { |
| 9893 | return gl::error(GL_INVALID_VALUE); |
| 9894 | } |
| 9895 | } |
| 9896 | |
| 9897 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9898 | if (!programObject->isLinked() || !programBinary) |
| 9899 | { |
| 9900 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 9901 | { |
| 9902 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 9903 | } |
| 9904 | } |
| 9905 | else |
| 9906 | { |
| 9907 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 9908 | { |
| 9909 | uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]); |
| 9910 | } |
| 9911 | } |
| 9912 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9913 | } |
| 9914 | catch(std::bad_alloc&) |
| 9915 | { |
| 9916 | return gl::error(GL_OUT_OF_MEMORY); |
| 9917 | } |
| 9918 | } |
| 9919 | |
| 9920 | void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) |
| 9921 | { |
| 9922 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 9923 | program, uniformCount, uniformIndices, pname, params); |
| 9924 | |
| 9925 | try |
| 9926 | { |
| 9927 | gl::Context *context = gl::getNonLostContext(); |
| 9928 | |
| 9929 | if (context) |
| 9930 | { |
| 9931 | if (context->getClientVersion() < 3) |
| 9932 | { |
| 9933 | return gl::error(GL_INVALID_OPERATION); |
| 9934 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9935 | |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 9936 | if (uniformCount < 0) |
| 9937 | { |
| 9938 | return gl::error(GL_INVALID_VALUE); |
| 9939 | } |
| 9940 | |
| 9941 | gl::Program *programObject = context->getProgram(program); |
| 9942 | |
| 9943 | if (!programObject) |
| 9944 | { |
| 9945 | if (context->getShader(program)) |
| 9946 | { |
| 9947 | return gl::error(GL_INVALID_OPERATION); |
| 9948 | } |
| 9949 | else |
| 9950 | { |
| 9951 | return gl::error(GL_INVALID_VALUE); |
| 9952 | } |
| 9953 | } |
| 9954 | |
| 9955 | switch (pname) |
| 9956 | { |
| 9957 | case GL_UNIFORM_TYPE: |
| 9958 | case GL_UNIFORM_SIZE: |
| 9959 | case GL_UNIFORM_NAME_LENGTH: |
| 9960 | case GL_UNIFORM_BLOCK_INDEX: |
| 9961 | case GL_UNIFORM_OFFSET: |
| 9962 | case GL_UNIFORM_ARRAY_STRIDE: |
| 9963 | case GL_UNIFORM_MATRIX_STRIDE: |
| 9964 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 9965 | break; |
| 9966 | default: |
| 9967 | return gl::error(GL_INVALID_ENUM); |
| 9968 | } |
| 9969 | |
| 9970 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9971 | |
| 9972 | if (!programBinary && uniformCount > 0) |
| 9973 | { |
| 9974 | return gl::error(GL_INVALID_VALUE); |
| 9975 | } |
| 9976 | |
| 9977 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 9978 | { |
| 9979 | const GLuint index = uniformIndices[uniformId]; |
| 9980 | |
| 9981 | if (index >= (GLuint)programBinary->getActiveUniformCount()) |
| 9982 | { |
| 9983 | return gl::error(GL_INVALID_VALUE); |
| 9984 | } |
| 9985 | } |
| 9986 | |
| 9987 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 9988 | { |
| 9989 | const GLuint index = uniformIndices[uniformId]; |
| 9990 | params[uniformId] = programBinary->getActiveUniformi(index, pname); |
| 9991 | } |
| 9992 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9993 | } |
| 9994 | catch(std::bad_alloc&) |
| 9995 | { |
| 9996 | return gl::error(GL_OUT_OF_MEMORY); |
| 9997 | } |
| 9998 | } |
| 9999 | |
| 10000 | GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) |
| 10001 | { |
| 10002 | EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName); |
| 10003 | |
| 10004 | try |
| 10005 | { |
| 10006 | gl::Context *context = gl::getNonLostContext(); |
| 10007 | |
| 10008 | if (context) |
| 10009 | { |
| 10010 | if (context->getClientVersion() < 3) |
| 10011 | { |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10012 | 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] | 10013 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10014 | |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10015 | gl::Program *programObject = context->getProgram(program); |
| 10016 | |
| 10017 | if (!programObject) |
| 10018 | { |
| 10019 | if (context->getShader(program)) |
| 10020 | { |
| 10021 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
| 10022 | } |
| 10023 | else |
| 10024 | { |
| 10025 | return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX); |
| 10026 | } |
| 10027 | } |
| 10028 | |
| 10029 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10030 | if (!programBinary) |
| 10031 | { |
| 10032 | return GL_INVALID_INDEX; |
| 10033 | } |
| 10034 | |
| 10035 | return programBinary->getUniformBlockIndex(uniformBlockName); |
| 10036 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10037 | } |
| 10038 | catch(std::bad_alloc&) |
| 10039 | { |
| 10040 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10041 | } |
| 10042 | |
| 10043 | return 0; |
| 10044 | } |
| 10045 | |
| 10046 | void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) |
| 10047 | { |
| 10048 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10049 | program, uniformBlockIndex, pname, params); |
| 10050 | |
| 10051 | try |
| 10052 | { |
| 10053 | gl::Context *context = gl::getNonLostContext(); |
| 10054 | |
| 10055 | if (context) |
| 10056 | { |
| 10057 | if (context->getClientVersion() < 3) |
| 10058 | { |
| 10059 | return gl::error(GL_INVALID_OPERATION); |
| 10060 | } |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10061 | gl::Program *programObject = context->getProgram(program); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10062 | |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10063 | if (!programObject) |
| 10064 | { |
| 10065 | if (context->getShader(program)) |
| 10066 | { |
| 10067 | return gl::error(GL_INVALID_OPERATION); |
| 10068 | } |
| 10069 | else |
| 10070 | { |
| 10071 | return gl::error(GL_INVALID_VALUE); |
| 10072 | } |
| 10073 | } |
| 10074 | |
| 10075 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10076 | |
| 10077 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10078 | { |
| 10079 | return gl::error(GL_INVALID_VALUE); |
| 10080 | } |
| 10081 | |
| 10082 | switch (pname) |
| 10083 | { |
| 10084 | case GL_UNIFORM_BLOCK_BINDING: |
| 10085 | *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); |
| 10086 | break; |
| 10087 | |
| 10088 | case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 10089 | case GL_UNIFORM_BLOCK_NAME_LENGTH: |
| 10090 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 10091 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| 10092 | case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
| 10093 | case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
| 10094 | programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params); |
| 10095 | break; |
| 10096 | |
| 10097 | default: |
| 10098 | return gl::error(GL_INVALID_ENUM); |
| 10099 | } |
| 10100 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10101 | } |
| 10102 | catch(std::bad_alloc&) |
| 10103 | { |
| 10104 | return gl::error(GL_OUT_OF_MEMORY); |
| 10105 | } |
| 10106 | } |
| 10107 | |
| 10108 | void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) |
| 10109 | { |
| 10110 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)", |
| 10111 | program, uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10112 | |
| 10113 | try |
| 10114 | { |
| 10115 | gl::Context *context = gl::getNonLostContext(); |
| 10116 | |
| 10117 | if (context) |
| 10118 | { |
| 10119 | if (context->getClientVersion() < 3) |
| 10120 | { |
| 10121 | return gl::error(GL_INVALID_OPERATION); |
| 10122 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10123 | |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 10124 | gl::Program *programObject = context->getProgram(program); |
| 10125 | |
| 10126 | if (!programObject) |
| 10127 | { |
| 10128 | if (context->getShader(program)) |
| 10129 | { |
| 10130 | return gl::error(GL_INVALID_OPERATION); |
| 10131 | } |
| 10132 | else |
| 10133 | { |
| 10134 | return gl::error(GL_INVALID_VALUE); |
| 10135 | } |
| 10136 | } |
| 10137 | |
| 10138 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10139 | |
| 10140 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10141 | { |
| 10142 | return gl::error(GL_INVALID_VALUE); |
| 10143 | } |
| 10144 | |
| 10145 | programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10146 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10147 | } |
| 10148 | catch(std::bad_alloc&) |
| 10149 | { |
| 10150 | return gl::error(GL_OUT_OF_MEMORY); |
| 10151 | } |
| 10152 | } |
| 10153 | |
| 10154 | void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) |
| 10155 | { |
| 10156 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)", |
| 10157 | program, uniformBlockIndex, uniformBlockBinding); |
| 10158 | |
| 10159 | try |
| 10160 | { |
| 10161 | gl::Context *context = gl::getNonLostContext(); |
| 10162 | |
| 10163 | if (context) |
| 10164 | { |
| 10165 | if (context->getClientVersion() < 3) |
| 10166 | { |
| 10167 | return gl::error(GL_INVALID_OPERATION); |
| 10168 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10169 | |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 10170 | if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings()) |
| 10171 | { |
| 10172 | return gl::error(GL_INVALID_VALUE); |
| 10173 | } |
| 10174 | |
| 10175 | gl::Program *programObject = context->getProgram(program); |
| 10176 | |
| 10177 | if (!programObject) |
| 10178 | { |
| 10179 | if (context->getShader(program)) |
| 10180 | { |
| 10181 | return gl::error(GL_INVALID_OPERATION); |
| 10182 | } |
| 10183 | else |
| 10184 | { |
| 10185 | return gl::error(GL_INVALID_VALUE); |
| 10186 | } |
| 10187 | } |
| 10188 | |
| 10189 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10190 | |
| 10191 | // if never linked, there won't be any uniform blocks |
| 10192 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10193 | { |
| 10194 | return gl::error(GL_INVALID_VALUE); |
| 10195 | } |
| 10196 | |
| 10197 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
| 10198 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10199 | } |
| 10200 | catch(std::bad_alloc&) |
| 10201 | { |
| 10202 | return gl::error(GL_OUT_OF_MEMORY); |
| 10203 | } |
| 10204 | } |
| 10205 | |
| 10206 | void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 10207 | { |
| 10208 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)", |
| 10209 | mode, first, count, instanceCount); |
| 10210 | |
| 10211 | try |
| 10212 | { |
| 10213 | gl::Context *context = gl::getNonLostContext(); |
| 10214 | |
| 10215 | if (context) |
| 10216 | { |
| 10217 | if (context->getClientVersion() < 3) |
| 10218 | { |
| 10219 | return gl::error(GL_INVALID_OPERATION); |
| 10220 | } |
| 10221 | } |
| 10222 | |
| 10223 | UNIMPLEMENTED(); |
| 10224 | } |
| 10225 | catch(std::bad_alloc&) |
| 10226 | { |
| 10227 | return gl::error(GL_OUT_OF_MEMORY); |
| 10228 | } |
| 10229 | } |
| 10230 | |
| 10231 | void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) |
| 10232 | { |
| 10233 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)", |
| 10234 | mode, count, type, indices, instanceCount); |
| 10235 | |
| 10236 | try |
| 10237 | { |
| 10238 | gl::Context *context = gl::getNonLostContext(); |
| 10239 | |
| 10240 | if (context) |
| 10241 | { |
| 10242 | if (context->getClientVersion() < 3) |
| 10243 | { |
| 10244 | return gl::error(GL_INVALID_OPERATION); |
| 10245 | } |
| 10246 | } |
| 10247 | |
| 10248 | UNIMPLEMENTED(); |
| 10249 | } |
| 10250 | catch(std::bad_alloc&) |
| 10251 | { |
| 10252 | return gl::error(GL_OUT_OF_MEMORY); |
| 10253 | } |
| 10254 | } |
| 10255 | |
| 10256 | GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags) |
| 10257 | { |
| 10258 | EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags); |
| 10259 | |
| 10260 | try |
| 10261 | { |
| 10262 | gl::Context *context = gl::getNonLostContext(); |
| 10263 | |
| 10264 | if (context) |
| 10265 | { |
| 10266 | if (context->getClientVersion() < 3) |
| 10267 | { |
| 10268 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(NULL)); |
| 10269 | } |
| 10270 | } |
| 10271 | |
| 10272 | UNIMPLEMENTED(); |
| 10273 | } |
| 10274 | catch(std::bad_alloc&) |
| 10275 | { |
| 10276 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL)); |
| 10277 | } |
| 10278 | |
| 10279 | return NULL; |
| 10280 | } |
| 10281 | |
| 10282 | GLboolean __stdcall glIsSync(GLsync sync) |
| 10283 | { |
| 10284 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10285 | |
| 10286 | try |
| 10287 | { |
| 10288 | gl::Context *context = gl::getNonLostContext(); |
| 10289 | |
| 10290 | if (context) |
| 10291 | { |
| 10292 | if (context->getClientVersion() < 3) |
| 10293 | { |
| 10294 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10295 | } |
| 10296 | } |
| 10297 | |
| 10298 | UNIMPLEMENTED(); |
| 10299 | } |
| 10300 | catch(std::bad_alloc&) |
| 10301 | { |
| 10302 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10303 | } |
| 10304 | |
| 10305 | return GL_FALSE; |
| 10306 | } |
| 10307 | |
| 10308 | void __stdcall glDeleteSync(GLsync sync) |
| 10309 | { |
| 10310 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10311 | |
| 10312 | try |
| 10313 | { |
| 10314 | gl::Context *context = gl::getNonLostContext(); |
| 10315 | |
| 10316 | if (context) |
| 10317 | { |
| 10318 | if (context->getClientVersion() < 3) |
| 10319 | { |
| 10320 | return gl::error(GL_INVALID_OPERATION); |
| 10321 | } |
| 10322 | } |
| 10323 | |
| 10324 | UNIMPLEMENTED(); |
| 10325 | } |
| 10326 | catch(std::bad_alloc&) |
| 10327 | { |
| 10328 | return gl::error(GL_OUT_OF_MEMORY); |
| 10329 | } |
| 10330 | } |
| 10331 | |
| 10332 | GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10333 | { |
| 10334 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10335 | sync, flags, timeout); |
| 10336 | |
| 10337 | try |
| 10338 | { |
| 10339 | gl::Context *context = gl::getNonLostContext(); |
| 10340 | |
| 10341 | if (context) |
| 10342 | { |
| 10343 | if (context->getClientVersion() < 3) |
| 10344 | { |
| 10345 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10346 | } |
| 10347 | } |
| 10348 | |
| 10349 | UNIMPLEMENTED(); |
| 10350 | } |
| 10351 | catch(std::bad_alloc&) |
| 10352 | { |
| 10353 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10354 | } |
| 10355 | |
| 10356 | return GL_FALSE; |
| 10357 | } |
| 10358 | |
| 10359 | void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10360 | { |
| 10361 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10362 | sync, flags, timeout); |
| 10363 | |
| 10364 | try |
| 10365 | { |
| 10366 | gl::Context *context = gl::getNonLostContext(); |
| 10367 | |
| 10368 | if (context) |
| 10369 | { |
| 10370 | if (context->getClientVersion() < 3) |
| 10371 | { |
| 10372 | return gl::error(GL_INVALID_OPERATION); |
| 10373 | } |
| 10374 | } |
| 10375 | |
| 10376 | UNIMPLEMENTED(); |
| 10377 | } |
| 10378 | catch(std::bad_alloc&) |
| 10379 | { |
| 10380 | return gl::error(GL_OUT_OF_MEMORY); |
| 10381 | } |
| 10382 | } |
| 10383 | |
| 10384 | void __stdcall glGetInteger64v(GLenum pname, GLint64* params) |
| 10385 | { |
| 10386 | EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10387 | pname, params); |
| 10388 | |
| 10389 | try |
| 10390 | { |
| 10391 | gl::Context *context = gl::getNonLostContext(); |
| 10392 | |
| 10393 | if (context) |
| 10394 | { |
| 10395 | if (context->getClientVersion() < 3) |
| 10396 | { |
| 10397 | return gl::error(GL_INVALID_OPERATION); |
| 10398 | } |
| 10399 | } |
| 10400 | |
| 10401 | UNIMPLEMENTED(); |
| 10402 | } |
| 10403 | catch(std::bad_alloc&) |
| 10404 | { |
| 10405 | return gl::error(GL_OUT_OF_MEMORY); |
| 10406 | } |
| 10407 | } |
| 10408 | |
| 10409 | void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) |
| 10410 | { |
| 10411 | EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)", |
| 10412 | sync, pname, bufSize, length, values); |
| 10413 | |
| 10414 | try |
| 10415 | { |
| 10416 | gl::Context *context = gl::getNonLostContext(); |
| 10417 | |
| 10418 | if (context) |
| 10419 | { |
| 10420 | if (context->getClientVersion() < 3) |
| 10421 | { |
| 10422 | return gl::error(GL_INVALID_OPERATION); |
| 10423 | } |
| 10424 | } |
| 10425 | |
| 10426 | UNIMPLEMENTED(); |
| 10427 | } |
| 10428 | catch(std::bad_alloc&) |
| 10429 | { |
| 10430 | return gl::error(GL_OUT_OF_MEMORY); |
| 10431 | } |
| 10432 | } |
| 10433 | |
| 10434 | void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) |
| 10435 | { |
| 10436 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)", |
| 10437 | target, index, data); |
| 10438 | |
| 10439 | try |
| 10440 | { |
| 10441 | gl::Context *context = gl::getNonLostContext(); |
| 10442 | |
| 10443 | if (context) |
| 10444 | { |
| 10445 | if (context->getClientVersion() < 3) |
| 10446 | { |
| 10447 | return gl::error(GL_INVALID_OPERATION); |
| 10448 | } |
| 10449 | } |
| 10450 | |
| 10451 | UNIMPLEMENTED(); |
| 10452 | } |
| 10453 | catch(std::bad_alloc&) |
| 10454 | { |
| 10455 | return gl::error(GL_OUT_OF_MEMORY); |
| 10456 | } |
| 10457 | } |
| 10458 | |
| 10459 | void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) |
| 10460 | { |
| 10461 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10462 | target, pname, params); |
| 10463 | |
| 10464 | try |
| 10465 | { |
| 10466 | gl::Context *context = gl::getNonLostContext(); |
| 10467 | |
| 10468 | if (context) |
| 10469 | { |
| 10470 | if (context->getClientVersion() < 3) |
| 10471 | { |
| 10472 | return gl::error(GL_INVALID_OPERATION); |
| 10473 | } |
| 10474 | } |
| 10475 | |
| 10476 | UNIMPLEMENTED(); |
| 10477 | } |
| 10478 | catch(std::bad_alloc&) |
| 10479 | { |
| 10480 | return gl::error(GL_OUT_OF_MEMORY); |
| 10481 | } |
| 10482 | } |
| 10483 | |
| 10484 | void __stdcall glGenSamplers(GLsizei count, GLuint* samplers) |
| 10485 | { |
| 10486 | EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers); |
| 10487 | |
| 10488 | try |
| 10489 | { |
| 10490 | gl::Context *context = gl::getNonLostContext(); |
| 10491 | |
| 10492 | if (context) |
| 10493 | { |
| 10494 | if (context->getClientVersion() < 3) |
| 10495 | { |
| 10496 | return gl::error(GL_INVALID_OPERATION); |
| 10497 | } |
| 10498 | } |
| 10499 | |
| 10500 | UNIMPLEMENTED(); |
| 10501 | } |
| 10502 | catch(std::bad_alloc&) |
| 10503 | { |
| 10504 | return gl::error(GL_OUT_OF_MEMORY); |
| 10505 | } |
| 10506 | } |
| 10507 | |
| 10508 | void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers) |
| 10509 | { |
| 10510 | EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers); |
| 10511 | |
| 10512 | try |
| 10513 | { |
| 10514 | gl::Context *context = gl::getNonLostContext(); |
| 10515 | |
| 10516 | if (context) |
| 10517 | { |
| 10518 | if (context->getClientVersion() < 3) |
| 10519 | { |
| 10520 | return gl::error(GL_INVALID_OPERATION); |
| 10521 | } |
| 10522 | } |
| 10523 | |
| 10524 | UNIMPLEMENTED(); |
| 10525 | } |
| 10526 | catch(std::bad_alloc&) |
| 10527 | { |
| 10528 | return gl::error(GL_OUT_OF_MEMORY); |
| 10529 | } |
| 10530 | } |
| 10531 | |
| 10532 | GLboolean __stdcall glIsSampler(GLuint sampler) |
| 10533 | { |
| 10534 | EVENT("(GLuint sampler = %u)", sampler); |
| 10535 | |
| 10536 | try |
| 10537 | { |
| 10538 | gl::Context *context = gl::getNonLostContext(); |
| 10539 | |
| 10540 | if (context) |
| 10541 | { |
| 10542 | if (context->getClientVersion() < 3) |
| 10543 | { |
| 10544 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10545 | } |
| 10546 | } |
| 10547 | |
| 10548 | UNIMPLEMENTED(); |
| 10549 | } |
| 10550 | catch(std::bad_alloc&) |
| 10551 | { |
| 10552 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10553 | } |
| 10554 | |
| 10555 | return GL_FALSE; |
| 10556 | } |
| 10557 | |
| 10558 | void __stdcall glBindSampler(GLuint unit, GLuint sampler) |
| 10559 | { |
| 10560 | EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler); |
| 10561 | |
| 10562 | try |
| 10563 | { |
| 10564 | gl::Context *context = gl::getNonLostContext(); |
| 10565 | |
| 10566 | if (context) |
| 10567 | { |
| 10568 | if (context->getClientVersion() < 3) |
| 10569 | { |
| 10570 | return gl::error(GL_INVALID_OPERATION); |
| 10571 | } |
| 10572 | } |
| 10573 | |
| 10574 | UNIMPLEMENTED(); |
| 10575 | } |
| 10576 | catch(std::bad_alloc&) |
| 10577 | { |
| 10578 | return gl::error(GL_OUT_OF_MEMORY); |
| 10579 | } |
| 10580 | } |
| 10581 | |
| 10582 | void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 10583 | { |
| 10584 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param); |
| 10585 | |
| 10586 | try |
| 10587 | { |
| 10588 | gl::Context *context = gl::getNonLostContext(); |
| 10589 | |
| 10590 | if (context) |
| 10591 | { |
| 10592 | if (context->getClientVersion() < 3) |
| 10593 | { |
| 10594 | return gl::error(GL_INVALID_OPERATION); |
| 10595 | } |
| 10596 | } |
| 10597 | |
| 10598 | UNIMPLEMENTED(); |
| 10599 | } |
| 10600 | catch(std::bad_alloc&) |
| 10601 | { |
| 10602 | return gl::error(GL_OUT_OF_MEMORY); |
| 10603 | } |
| 10604 | } |
| 10605 | |
| 10606 | void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) |
| 10607 | { |
| 10608 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLint* param = 0x%0.8p)", |
| 10609 | sampler, pname, param); |
| 10610 | |
| 10611 | try |
| 10612 | { |
| 10613 | gl::Context *context = gl::getNonLostContext(); |
| 10614 | |
| 10615 | if (context) |
| 10616 | { |
| 10617 | if (context->getClientVersion() < 3) |
| 10618 | { |
| 10619 | return gl::error(GL_INVALID_OPERATION); |
| 10620 | } |
| 10621 | } |
| 10622 | |
| 10623 | UNIMPLEMENTED(); |
| 10624 | } |
| 10625 | catch(std::bad_alloc&) |
| 10626 | { |
| 10627 | return gl::error(GL_OUT_OF_MEMORY); |
| 10628 | } |
| 10629 | } |
| 10630 | |
| 10631 | void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 10632 | { |
| 10633 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param); |
| 10634 | |
| 10635 | try |
| 10636 | { |
| 10637 | gl::Context *context = gl::getNonLostContext(); |
| 10638 | |
| 10639 | if (context) |
| 10640 | { |
| 10641 | if (context->getClientVersion() < 3) |
| 10642 | { |
| 10643 | return gl::error(GL_INVALID_OPERATION); |
| 10644 | } |
| 10645 | } |
| 10646 | |
| 10647 | UNIMPLEMENTED(); |
| 10648 | } |
| 10649 | catch(std::bad_alloc&) |
| 10650 | { |
| 10651 | return gl::error(GL_OUT_OF_MEMORY); |
| 10652 | } |
| 10653 | } |
| 10654 | |
| 10655 | void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) |
| 10656 | { |
| 10657 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLfloat* param = 0x%0.8p)", sampler, pname, param); |
| 10658 | |
| 10659 | try |
| 10660 | { |
| 10661 | gl::Context *context = gl::getNonLostContext(); |
| 10662 | |
| 10663 | if (context) |
| 10664 | { |
| 10665 | if (context->getClientVersion() < 3) |
| 10666 | { |
| 10667 | return gl::error(GL_INVALID_OPERATION); |
| 10668 | } |
| 10669 | } |
| 10670 | |
| 10671 | UNIMPLEMENTED(); |
| 10672 | } |
| 10673 | catch(std::bad_alloc&) |
| 10674 | { |
| 10675 | return gl::error(GL_OUT_OF_MEMORY); |
| 10676 | } |
| 10677 | } |
| 10678 | |
| 10679 | void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) |
| 10680 | { |
| 10681 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); |
| 10682 | |
| 10683 | try |
| 10684 | { |
| 10685 | gl::Context *context = gl::getNonLostContext(); |
| 10686 | |
| 10687 | if (context) |
| 10688 | { |
| 10689 | if (context->getClientVersion() < 3) |
| 10690 | { |
| 10691 | return gl::error(GL_INVALID_OPERATION); |
| 10692 | } |
| 10693 | } |
| 10694 | |
| 10695 | UNIMPLEMENTED(); |
| 10696 | } |
| 10697 | catch(std::bad_alloc&) |
| 10698 | { |
| 10699 | return gl::error(GL_OUT_OF_MEMORY); |
| 10700 | } |
| 10701 | } |
| 10702 | |
| 10703 | void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) |
| 10704 | { |
| 10705 | EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params); |
| 10706 | |
| 10707 | try |
| 10708 | { |
| 10709 | gl::Context *context = gl::getNonLostContext(); |
| 10710 | |
| 10711 | if (context) |
| 10712 | { |
| 10713 | if (context->getClientVersion() < 3) |
| 10714 | { |
| 10715 | return gl::error(GL_INVALID_OPERATION); |
| 10716 | } |
| 10717 | } |
| 10718 | |
| 10719 | UNIMPLEMENTED(); |
| 10720 | } |
| 10721 | catch(std::bad_alloc&) |
| 10722 | { |
| 10723 | return gl::error(GL_OUT_OF_MEMORY); |
| 10724 | } |
| 10725 | } |
| 10726 | |
| 10727 | void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor) |
| 10728 | { |
| 10729 | EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor); |
| 10730 | |
| 10731 | try |
| 10732 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 10733 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 10734 | { |
| 10735 | return gl::error(GL_INVALID_VALUE); |
| 10736 | } |
| 10737 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10738 | gl::Context *context = gl::getNonLostContext(); |
| 10739 | |
| 10740 | if (context) |
| 10741 | { |
| 10742 | if (context->getClientVersion() < 3) |
| 10743 | { |
| 10744 | return gl::error(GL_INVALID_OPERATION); |
| 10745 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10746 | |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 10747 | context->setVertexAttribDivisor(index, divisor); |
| 10748 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10749 | } |
| 10750 | catch(std::bad_alloc&) |
| 10751 | { |
| 10752 | return gl::error(GL_OUT_OF_MEMORY); |
| 10753 | } |
| 10754 | } |
| 10755 | |
| 10756 | void __stdcall glBindTransformFeedback(GLenum target, GLuint id) |
| 10757 | { |
| 10758 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 10759 | |
| 10760 | try |
| 10761 | { |
| 10762 | gl::Context *context = gl::getNonLostContext(); |
| 10763 | |
| 10764 | if (context) |
| 10765 | { |
| 10766 | if (context->getClientVersion() < 3) |
| 10767 | { |
| 10768 | return gl::error(GL_INVALID_OPERATION); |
| 10769 | } |
| 10770 | } |
| 10771 | |
| 10772 | UNIMPLEMENTED(); |
| 10773 | } |
| 10774 | catch(std::bad_alloc&) |
| 10775 | { |
| 10776 | return gl::error(GL_OUT_OF_MEMORY); |
| 10777 | } |
| 10778 | } |
| 10779 | |
| 10780 | void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) |
| 10781 | { |
| 10782 | EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids); |
| 10783 | |
| 10784 | try |
| 10785 | { |
| 10786 | gl::Context *context = gl::getNonLostContext(); |
| 10787 | |
| 10788 | if (context) |
| 10789 | { |
| 10790 | if (context->getClientVersion() < 3) |
| 10791 | { |
| 10792 | return gl::error(GL_INVALID_OPERATION); |
| 10793 | } |
| 10794 | } |
| 10795 | |
| 10796 | UNIMPLEMENTED(); |
| 10797 | } |
| 10798 | catch(std::bad_alloc&) |
| 10799 | { |
| 10800 | return gl::error(GL_OUT_OF_MEMORY); |
| 10801 | } |
| 10802 | } |
| 10803 | |
| 10804 | void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids) |
| 10805 | { |
| 10806 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 10807 | |
| 10808 | try |
| 10809 | { |
| 10810 | gl::Context *context = gl::getNonLostContext(); |
| 10811 | |
| 10812 | if (context) |
| 10813 | { |
| 10814 | if (context->getClientVersion() < 3) |
| 10815 | { |
| 10816 | return gl::error(GL_INVALID_OPERATION); |
| 10817 | } |
| 10818 | } |
| 10819 | |
| 10820 | UNIMPLEMENTED(); |
| 10821 | } |
| 10822 | catch(std::bad_alloc&) |
| 10823 | { |
| 10824 | return gl::error(GL_OUT_OF_MEMORY); |
| 10825 | } |
| 10826 | } |
| 10827 | |
| 10828 | GLboolean __stdcall glIsTransformFeedback(GLuint id) |
| 10829 | { |
| 10830 | EVENT("(GLuint id = %u)", id); |
| 10831 | |
| 10832 | try |
| 10833 | { |
| 10834 | gl::Context *context = gl::getNonLostContext(); |
| 10835 | |
| 10836 | if (context) |
| 10837 | { |
| 10838 | if (context->getClientVersion() < 3) |
| 10839 | { |
| 10840 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10841 | } |
| 10842 | } |
| 10843 | |
| 10844 | UNIMPLEMENTED(); |
| 10845 | } |
| 10846 | catch(std::bad_alloc&) |
| 10847 | { |
| 10848 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10849 | } |
| 10850 | |
| 10851 | return GL_FALSE; |
| 10852 | } |
| 10853 | |
| 10854 | void __stdcall glPauseTransformFeedback(void) |
| 10855 | { |
| 10856 | EVENT("(void)"); |
| 10857 | |
| 10858 | try |
| 10859 | { |
| 10860 | gl::Context *context = gl::getNonLostContext(); |
| 10861 | |
| 10862 | if (context) |
| 10863 | { |
| 10864 | if (context->getClientVersion() < 3) |
| 10865 | { |
| 10866 | return gl::error(GL_INVALID_OPERATION); |
| 10867 | } |
| 10868 | } |
| 10869 | |
| 10870 | UNIMPLEMENTED(); |
| 10871 | } |
| 10872 | catch(std::bad_alloc&) |
| 10873 | { |
| 10874 | return gl::error(GL_OUT_OF_MEMORY); |
| 10875 | } |
| 10876 | } |
| 10877 | |
| 10878 | void __stdcall glResumeTransformFeedback(void) |
| 10879 | { |
| 10880 | EVENT("(void)"); |
| 10881 | |
| 10882 | try |
| 10883 | { |
| 10884 | gl::Context *context = gl::getNonLostContext(); |
| 10885 | |
| 10886 | if (context) |
| 10887 | { |
| 10888 | if (context->getClientVersion() < 3) |
| 10889 | { |
| 10890 | return gl::error(GL_INVALID_OPERATION); |
| 10891 | } |
| 10892 | } |
| 10893 | |
| 10894 | UNIMPLEMENTED(); |
| 10895 | } |
| 10896 | catch(std::bad_alloc&) |
| 10897 | { |
| 10898 | return gl::error(GL_OUT_OF_MEMORY); |
| 10899 | } |
| 10900 | } |
| 10901 | |
| 10902 | void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) |
| 10903 | { |
| 10904 | EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)", |
| 10905 | program, bufSize, length, binaryFormat, binary); |
| 10906 | |
| 10907 | try |
| 10908 | { |
| 10909 | gl::Context *context = gl::getNonLostContext(); |
| 10910 | |
| 10911 | if (context) |
| 10912 | { |
| 10913 | if (context->getClientVersion() < 3) |
| 10914 | { |
| 10915 | return gl::error(GL_INVALID_OPERATION); |
| 10916 | } |
| 10917 | } |
| 10918 | |
| 10919 | UNIMPLEMENTED(); |
| 10920 | } |
| 10921 | catch(std::bad_alloc&) |
| 10922 | { |
| 10923 | return gl::error(GL_OUT_OF_MEMORY); |
| 10924 | } |
| 10925 | } |
| 10926 | |
| 10927 | void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) |
| 10928 | { |
| 10929 | EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
| 10930 | program, binaryFormat, binary, length); |
| 10931 | |
| 10932 | try |
| 10933 | { |
| 10934 | gl::Context *context = gl::getNonLostContext(); |
| 10935 | |
| 10936 | if (context) |
| 10937 | { |
| 10938 | if (context->getClientVersion() < 3) |
| 10939 | { |
| 10940 | return gl::error(GL_INVALID_OPERATION); |
| 10941 | } |
| 10942 | } |
| 10943 | |
| 10944 | UNIMPLEMENTED(); |
| 10945 | } |
| 10946 | catch(std::bad_alloc&) |
| 10947 | { |
| 10948 | return gl::error(GL_OUT_OF_MEMORY); |
| 10949 | } |
| 10950 | } |
| 10951 | |
| 10952 | void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value) |
| 10953 | { |
| 10954 | EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)", |
| 10955 | program, pname, value); |
| 10956 | |
| 10957 | try |
| 10958 | { |
| 10959 | gl::Context *context = gl::getNonLostContext(); |
| 10960 | |
| 10961 | if (context) |
| 10962 | { |
| 10963 | if (context->getClientVersion() < 3) |
| 10964 | { |
| 10965 | return gl::error(GL_INVALID_OPERATION); |
| 10966 | } |
| 10967 | } |
| 10968 | |
| 10969 | UNIMPLEMENTED(); |
| 10970 | } |
| 10971 | catch(std::bad_alloc&) |
| 10972 | { |
| 10973 | return gl::error(GL_OUT_OF_MEMORY); |
| 10974 | } |
| 10975 | } |
| 10976 | |
| 10977 | void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) |
| 10978 | { |
| 10979 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)", |
| 10980 | target, numAttachments, attachments); |
| 10981 | |
| 10982 | try |
| 10983 | { |
| 10984 | gl::Context *context = gl::getNonLostContext(); |
| 10985 | |
| 10986 | if (context) |
| 10987 | { |
| 10988 | if (context->getClientVersion() < 3) |
| 10989 | { |
| 10990 | return gl::error(GL_INVALID_OPERATION); |
| 10991 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10992 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 10993 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 10994 | { |
| 10995 | return; |
| 10996 | } |
| 10997 | |
| 10998 | int maxDimension = context->getMaximumRenderbufferDimension(); |
| 10999 | context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension); |
| 11000 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11001 | } |
| 11002 | catch(std::bad_alloc&) |
| 11003 | { |
| 11004 | return gl::error(GL_OUT_OF_MEMORY); |
| 11005 | } |
| 11006 | } |
| 11007 | |
| 11008 | void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) |
| 11009 | { |
| 11010 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, " |
| 11011 | "GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 11012 | target, numAttachments, attachments, x, y, width, height); |
| 11013 | |
| 11014 | try |
| 11015 | { |
| 11016 | gl::Context *context = gl::getNonLostContext(); |
| 11017 | |
| 11018 | if (context) |
| 11019 | { |
| 11020 | if (context->getClientVersion() < 3) |
| 11021 | { |
| 11022 | return gl::error(GL_INVALID_OPERATION); |
| 11023 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11024 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11025 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11026 | { |
| 11027 | return; |
| 11028 | } |
| 11029 | |
| 11030 | context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height); |
| 11031 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11032 | } |
| 11033 | catch(std::bad_alloc&) |
| 11034 | { |
| 11035 | return gl::error(GL_OUT_OF_MEMORY); |
| 11036 | } |
| 11037 | } |
| 11038 | |
| 11039 | void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 11040 | { |
| 11041 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 11042 | target, levels, internalformat, width, height); |
| 11043 | |
| 11044 | try |
| 11045 | { |
| 11046 | gl::Context *context = gl::getNonLostContext(); |
| 11047 | |
| 11048 | if (context) |
| 11049 | { |
| 11050 | if (context->getClientVersion() < 3) |
| 11051 | { |
| 11052 | return gl::error(GL_INVALID_OPERATION); |
| 11053 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11054 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame^] | 11055 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 11056 | { |
| 11057 | return; |
| 11058 | } |
| 11059 | |
| 11060 | switch (target) |
| 11061 | { |
| 11062 | case GL_TEXTURE_2D: |
| 11063 | { |
| 11064 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 11065 | texture2d->storage(levels, internalformat, width, height); |
| 11066 | } |
| 11067 | break; |
| 11068 | |
| 11069 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 11070 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 11071 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 11072 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 11073 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 11074 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 11075 | { |
| 11076 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 11077 | textureCube->storage(levels, internalformat, width); |
| 11078 | } |
| 11079 | break; |
| 11080 | |
| 11081 | default: |
| 11082 | return gl::error(GL_INVALID_ENUM); |
| 11083 | } |
| 11084 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11085 | } |
| 11086 | catch(std::bad_alloc&) |
| 11087 | { |
| 11088 | return gl::error(GL_OUT_OF_MEMORY); |
| 11089 | } |
| 11090 | } |
| 11091 | |
| 11092 | void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
| 11093 | { |
| 11094 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 11095 | "GLsizei height = %d, GLsizei depth = %d)", |
| 11096 | target, levels, internalformat, width, height, depth); |
| 11097 | |
| 11098 | try |
| 11099 | { |
| 11100 | gl::Context *context = gl::getNonLostContext(); |
| 11101 | |
| 11102 | if (context) |
| 11103 | { |
| 11104 | if (context->getClientVersion() < 3) |
| 11105 | { |
| 11106 | return gl::error(GL_INVALID_OPERATION); |
| 11107 | } |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame^] | 11108 | |
| 11109 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) |
| 11110 | { |
| 11111 | return; |
| 11112 | } |
| 11113 | |
| 11114 | switch (target) |
| 11115 | { |
| 11116 | case GL_TEXTURE_3D: |
| 11117 | { |
| 11118 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 11119 | texture3d->storage(levels, internalformat, width, height, depth); |
| 11120 | } |
| 11121 | break; |
| 11122 | |
| 11123 | case GL_TEXTURE_2D_ARRAY: |
| 11124 | { |
| 11125 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 11126 | texture2darray->storage(levels, internalformat, width, height, depth); |
| 11127 | } |
| 11128 | break; |
| 11129 | |
| 11130 | default: |
| 11131 | return gl::error(GL_INVALID_ENUM); |
| 11132 | } |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 11133 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11134 | } |
| 11135 | catch(std::bad_alloc&) |
| 11136 | { |
| 11137 | return gl::error(GL_OUT_OF_MEMORY); |
| 11138 | } |
| 11139 | } |
| 11140 | |
| 11141 | void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) |
| 11142 | { |
| 11143 | EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, " |
| 11144 | "GLint* params = 0x%0.8p)", |
| 11145 | target, internalformat, pname, bufSize, params); |
| 11146 | |
| 11147 | try |
| 11148 | { |
| 11149 | gl::Context *context = gl::getNonLostContext(); |
| 11150 | |
| 11151 | if (context) |
| 11152 | { |
| 11153 | if (context->getClientVersion() < 3) |
| 11154 | { |
| 11155 | return gl::error(GL_INVALID_OPERATION); |
| 11156 | } |
| 11157 | } |
| 11158 | |
| 11159 | UNIMPLEMENTED(); |
| 11160 | } |
| 11161 | catch(std::bad_alloc&) |
| 11162 | { |
| 11163 | return gl::error(GL_OUT_OF_MEMORY); |
| 11164 | } |
| 11165 | } |
| 11166 | |
| 11167 | // Extension functions |
| 11168 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11169 | void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 11170 | GLbitfield mask, GLenum filter) |
| 11171 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11172 | 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] | 11173 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, " |
| 11174 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 11175 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 11176 | |
| 11177 | try |
| 11178 | { |
| 11179 | switch (filter) |
| 11180 | { |
| 11181 | case GL_NEAREST: |
| 11182 | break; |
| 11183 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11184 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11185 | } |
| 11186 | |
| 11187 | if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0) |
| 11188 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11189 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11190 | } |
| 11191 | |
| 11192 | if (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0) |
| 11193 | { |
| 11194 | 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] | 11195 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11196 | } |
| 11197 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11198 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11199 | |
| 11200 | if (context) |
| 11201 | { |
| 11202 | if (context->getReadFramebufferHandle() == context->getDrawFramebufferHandle()) |
| 11203 | { |
| 11204 | 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] | 11205 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11206 | } |
| 11207 | |
| 11208 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask); |
| 11209 | } |
| 11210 | } |
| 11211 | catch(std::bad_alloc&) |
| 11212 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11213 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11214 | } |
| 11215 | } |
| 11216 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 11217 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, |
| 11218 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11219 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11220 | 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] | 11221 | "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] | 11222 | "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] | 11223 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 11224 | |
| 11225 | try |
| 11226 | { |
| 11227 | UNIMPLEMENTED(); // FIXME |
| 11228 | } |
| 11229 | catch(std::bad_alloc&) |
| 11230 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11231 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11232 | } |
| 11233 | } |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11234 | |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11235 | void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, |
| 11236 | GLenum *binaryFormat, void *binary) |
| 11237 | { |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11238 | 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] | 11239 | program, bufSize, length, binaryFormat, binary); |
| 11240 | |
| 11241 | try |
| 11242 | { |
| 11243 | gl::Context *context = gl::getNonLostContext(); |
| 11244 | |
| 11245 | if (context) |
| 11246 | { |
| 11247 | gl::Program *programObject = context->getProgram(program); |
| 11248 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 11249 | if (!programObject || !programObject->isLinked()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11250 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11251 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11252 | } |
| 11253 | |
| 11254 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 11255 | |
| 11256 | if (!programBinary) |
| 11257 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11258 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11259 | } |
| 11260 | |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11261 | if (!programBinary->save(binary, bufSize, length)) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11262 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11263 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11264 | } |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11265 | |
| 11266 | *binaryFormat = GL_PROGRAM_BINARY_ANGLE; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11267 | } |
| 11268 | } |
| 11269 | catch(std::bad_alloc&) |
| 11270 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11271 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11272 | } |
| 11273 | } |
| 11274 | |
| 11275 | void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat, |
| 11276 | const void *binary, GLint length) |
| 11277 | { |
| 11278 | EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)", |
| 11279 | program, binaryFormat, binary, length); |
| 11280 | |
| 11281 | try |
| 11282 | { |
| 11283 | gl::Context *context = gl::getNonLostContext(); |
| 11284 | |
| 11285 | if (context) |
| 11286 | { |
| 11287 | if (binaryFormat != GL_PROGRAM_BINARY_ANGLE) |
| 11288 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11289 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11290 | } |
| 11291 | |
| 11292 | gl::Program *programObject = context->getProgram(program); |
| 11293 | |
| 11294 | if (!programObject) |
| 11295 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11296 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11297 | } |
| 11298 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 11299 | context->setProgramBinary(program, binary, length); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11300 | } |
| 11301 | } |
| 11302 | catch(std::bad_alloc&) |
| 11303 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11304 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11305 | } |
| 11306 | } |
| 11307 | |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11308 | void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) |
| 11309 | { |
| 11310 | EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs); |
| 11311 | |
| 11312 | try |
| 11313 | { |
| 11314 | gl::Context *context = gl::getNonLostContext(); |
| 11315 | |
| 11316 | if (context) |
| 11317 | { |
| 11318 | if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets()) |
| 11319 | { |
| 11320 | return gl::error(GL_INVALID_VALUE); |
| 11321 | } |
| 11322 | |
| 11323 | if (context->getDrawFramebufferHandle() == 0) |
| 11324 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11325 | if (n != 1) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11326 | { |
| 11327 | return gl::error(GL_INVALID_OPERATION); |
| 11328 | } |
| 11329 | |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11330 | 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] | 11331 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11332 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11333 | } |
| 11334 | } |
| 11335 | else |
| 11336 | { |
| 11337 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 11338 | { |
| 11339 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 11340 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment) |
| 11341 | { |
| 11342 | return gl::error(GL_INVALID_OPERATION); |
| 11343 | } |
| 11344 | } |
| 11345 | } |
| 11346 | |
| 11347 | gl::Framebuffer *framebuffer = context->getDrawFramebuffer(); |
| 11348 | |
| 11349 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 11350 | { |
| 11351 | framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]); |
| 11352 | } |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11353 | |
| 11354 | for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++) |
| 11355 | { |
| 11356 | framebuffer->setDrawBufferState(colorAttachment, GL_NONE); |
| 11357 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11358 | } |
| 11359 | } |
| 11360 | catch (std::bad_alloc&) |
| 11361 | { |
| 11362 | return gl::error(GL_OUT_OF_MEMORY); |
| 11363 | } |
| 11364 | } |
| 11365 | |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11366 | __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) |
| 11367 | { |
| 11368 | struct Extension |
| 11369 | { |
| 11370 | const char *name; |
| 11371 | __eglMustCastToProperFunctionPointerType address; |
| 11372 | }; |
| 11373 | |
| 11374 | static const Extension glExtensions[] = |
| 11375 | { |
| 11376 | {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 11377 | {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, |
daniel@transgaming.com | 1fe96c9 | 2011-01-14 15:08:44 +0000 | [diff] [blame] | 11378 | {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 11379 | {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, |
| 11380 | {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, |
| 11381 | {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, |
| 11382 | {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, |
| 11383 | {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, |
| 11384 | {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, |
| 11385 | {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 11386 | {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE}, |
daniel@transgaming.com | 0bd1f2f | 2011-11-11 04:19:03 +0000 | [diff] [blame] | 11387 | {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT}, |
daniel@transgaming.com | 709ed11 | 2011-11-12 03:18:10 +0000 | [diff] [blame] | 11388 | {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT}, |
| 11389 | {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT}, |
| 11390 | {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT}, |
| 11391 | {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT}, |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 11392 | {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT}, |
| 11393 | {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT}, |
| 11394 | {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT}, |
| 11395 | {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT}, |
| 11396 | {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT}, |
| 11397 | {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT}, |
| 11398 | {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT}, |
shannon.woods%transgaming.com@gtempaccount.com | 77d9472 | 2013-04-13 03:34:22 +0000 | [diff] [blame] | 11399 | {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT}, |
daniel@transgaming.com | dce02fd | 2012-01-27 15:39:51 +0000 | [diff] [blame] | 11400 | {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE}, |
| 11401 | {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, |
| 11402 | {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11403 | {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, |
| 11404 | {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, }; |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11405 | |
shannon.woods@transgaming.com | d438fd4 | 2013-02-28 23:17:45 +0000 | [diff] [blame] | 11406 | for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11407 | { |
| 11408 | if (strcmp(procname, glExtensions[ext].name) == 0) |
| 11409 | { |
| 11410 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address; |
| 11411 | } |
| 11412 | } |
| 11413 | |
| 11414 | return NULL; |
| 11415 | } |
| 11416 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 11417 | // Non-public functions used by EGL |
| 11418 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11419 | bool __stdcall glBindTexImage(egl::Surface *surface) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11420 | { |
| 11421 | EVENT("(egl::Surface* surface = 0x%0.8p)", |
| 11422 | surface); |
| 11423 | |
| 11424 | try |
| 11425 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11426 | gl::Context *context = gl::getNonLostContext(); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11427 | |
| 11428 | if (context) |
| 11429 | { |
| 11430 | gl::Texture2D *textureObject = context->getTexture2D(); |
| 11431 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11432 | if (textureObject->isImmutable()) |
| 11433 | { |
| 11434 | return false; |
| 11435 | } |
| 11436 | |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11437 | if (textureObject) |
| 11438 | { |
| 11439 | textureObject->bindTexImage(surface); |
| 11440 | } |
| 11441 | } |
| 11442 | } |
| 11443 | catch(std::bad_alloc&) |
| 11444 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11445 | return gl::error(GL_OUT_OF_MEMORY, false); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11446 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11447 | |
| 11448 | return true; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11449 | } |
| 11450 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11451 | } |