shannon.woods@transgaming.com | bdf2d80 | 2013-02-28 23:16:20 +0000 | [diff] [blame] | 1 | #include "precompiled.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2 | // |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 3 | // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4 | // Use of this source code is governed by a BSD-style license that can be |
| 5 | // found in the LICENSE file. |
| 6 | // |
| 7 | |
| 8 | // libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions. |
| 9 | |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 10 | #include "common/version.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 11 | |
| 12 | #include "libGLESv2/main.h" |
shannonwoods@chromium.org | a2ecfcc | 2013-05-30 00:11:59 +0000 | [diff] [blame] | 13 | #include "common/utilities.h" |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 14 | #include "libGLESv2/formatutils.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 15 | #include "libGLESv2/Buffer.h" |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 16 | #include "libGLESv2/Fence.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 17 | #include "libGLESv2/Framebuffer.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 18 | #include "libGLESv2/Renderbuffer.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 19 | #include "libGLESv2/Program.h" |
apatrick@chromium.org | ea09f9b | 2012-06-08 00:45:32 +0000 | [diff] [blame] | 20 | #include "libGLESv2/ProgramBinary.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 21 | #include "libGLESv2/Texture.h" |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 22 | #include "libGLESv2/Query.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 23 | #include "libGLESv2/Context.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 24 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 25 | bool validImageSize(const gl::Context *context, GLint level, GLsizei width, GLsizei height, GLsizei depth) |
daniel@transgaming.com | 4f9ef0d | 2011-05-30 23:51:19 +0000 | [diff] [blame] | 26 | { |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 27 | if (level < 0 || width < 0 || height < 0 || depth < 0) |
daniel@transgaming.com | 4f9ef0d | 2011-05-30 23:51:19 +0000 | [diff] [blame] | 28 | { |
| 29 | return false; |
| 30 | } |
| 31 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 32 | if (context->supportsNonPower2Texture()) |
daniel@transgaming.com | 4f9ef0d | 2011-05-30 23:51:19 +0000 | [diff] [blame] | 33 | { |
| 34 | return true; |
| 35 | } |
| 36 | |
| 37 | if (level == 0) |
| 38 | { |
| 39 | return true; |
| 40 | } |
| 41 | |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 42 | if (gl::isPow2(width) && gl::isPow2(height) && gl::isPow2(depth)) |
daniel@transgaming.com | 4f9ef0d | 2011-05-30 23:51:19 +0000 | [diff] [blame] | 43 | { |
| 44 | return true; |
| 45 | } |
| 46 | |
| 47 | return false; |
| 48 | } |
| 49 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 50 | bool validCompressedImageSize(GLsizei width, GLsizei height) |
| 51 | { |
| 52 | if (width != 1 && width != 2 && width % 4 != 0) |
| 53 | { |
| 54 | return false; |
| 55 | } |
| 56 | |
| 57 | if (height != 1 && height != 2 && height % 4 != 0) |
| 58 | { |
| 59 | return false; |
| 60 | } |
| 61 | |
| 62 | return true; |
| 63 | } |
| 64 | |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 65 | // Verify that format/type are one of the combinations from table 3.4. |
| 66 | bool checkTextureFormatType(GLenum format, GLenum type) |
| 67 | { |
| 68 | // validate <format> by itself (used as secondary key below) |
| 69 | switch (format) |
| 70 | { |
| 71 | case GL_RGBA: |
| 72 | case GL_BGRA_EXT: |
| 73 | case GL_RGB: |
| 74 | case GL_ALPHA: |
| 75 | case GL_LUMINANCE: |
| 76 | case GL_LUMINANCE_ALPHA: |
| 77 | case GL_DEPTH_COMPONENT: |
| 78 | case GL_DEPTH_STENCIL_OES: |
| 79 | break; |
| 80 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 81 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | // invalid <type> -> sets INVALID_ENUM |
| 85 | // invalid <format>+<type> combination -> sets INVALID_OPERATION |
| 86 | switch (type) |
| 87 | { |
| 88 | case GL_UNSIGNED_BYTE: |
| 89 | switch (format) |
| 90 | { |
| 91 | case GL_RGBA: |
| 92 | case GL_BGRA_EXT: |
| 93 | case GL_RGB: |
| 94 | case GL_ALPHA: |
| 95 | case GL_LUMINANCE: |
| 96 | case GL_LUMINANCE_ALPHA: |
| 97 | return true; |
| 98 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 99 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | case GL_FLOAT: |
| 103 | case GL_HALF_FLOAT_OES: |
| 104 | switch (format) |
| 105 | { |
| 106 | case GL_RGBA: |
| 107 | case GL_RGB: |
| 108 | case GL_ALPHA: |
| 109 | case GL_LUMINANCE: |
| 110 | case GL_LUMINANCE_ALPHA: |
| 111 | return true; |
| 112 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 113 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 117 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 118 | switch (format) |
| 119 | { |
| 120 | case GL_RGBA: |
| 121 | return true; |
| 122 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 123 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | case GL_UNSIGNED_SHORT_5_6_5: |
| 127 | switch (format) |
| 128 | { |
| 129 | case GL_RGB: |
| 130 | return true; |
| 131 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 132 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | case GL_UNSIGNED_SHORT: |
| 136 | case GL_UNSIGNED_INT: |
| 137 | switch (format) |
| 138 | { |
| 139 | case GL_DEPTH_COMPONENT: |
| 140 | return true; |
| 141 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 142 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | case GL_UNSIGNED_INT_24_8_OES: |
| 146 | switch (format) |
| 147 | { |
| 148 | case GL_DEPTH_STENCIL_OES: |
| 149 | return true; |
| 150 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 151 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 155 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 156 | } |
| 157 | } |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 158 | |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 159 | bool validateSubImageParams2D(bool compressed, GLsizei width, GLsizei height, |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 160 | GLint xoffset, GLint yoffset, GLint level, GLenum format, GLenum type, |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 161 | gl::Texture2D *texture) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 162 | { |
| 163 | if (!texture) |
| 164 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 165 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 166 | } |
| 167 | |
daniel@transgaming.com | 92f4992 | 2012-05-09 15:49:19 +0000 | [diff] [blame] | 168 | if (compressed != texture->isCompressed(level)) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 169 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 170 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 171 | } |
| 172 | |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 173 | if (format != GL_NONE) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 174 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 175 | GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 176 | if (internalformat != texture->getInternalFormat(level)) |
| 177 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 178 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 179 | } |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | if (compressed) |
| 183 | { |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 184 | if ((width % 4 != 0 && width != texture->getWidth(0)) || |
| 185 | (height % 4 != 0 && height != texture->getHeight(0))) |
| 186 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 187 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 188 | } |
| 189 | } |
| 190 | |
| 191 | if (xoffset + width > texture->getWidth(level) || |
| 192 | yoffset + height > texture->getHeight(level)) |
| 193 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 194 | return gl::error(GL_INVALID_VALUE, false); |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | return true; |
| 198 | } |
| 199 | |
| 200 | bool validateSubImageParamsCube(bool compressed, GLsizei width, GLsizei height, |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 201 | GLint xoffset, GLint yoffset, GLenum target, GLint level, GLenum format, GLenum type, |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 202 | gl::TextureCubeMap *texture) |
| 203 | { |
| 204 | if (!texture) |
| 205 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 206 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 207 | } |
| 208 | |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 209 | if (compressed != texture->isCompressed(target, level)) |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 210 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 211 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 212 | } |
| 213 | |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 214 | if (format != GL_NONE) |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 215 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 216 | GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 217 | if (internalformat != texture->getInternalFormat(target, level)) |
| 218 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 219 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 220 | } |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | if (compressed) |
| 224 | { |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 225 | if ((width % 4 != 0 && width != texture->getWidth(target, 0)) || |
| 226 | (height % 4 != 0 && height != texture->getHeight(target, 0))) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 227 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 228 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 229 | } |
| 230 | } |
| 231 | |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 232 | if (xoffset + width > texture->getWidth(target, level) || |
| 233 | yoffset + height > texture->getHeight(target, level)) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 234 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 235 | return gl::error(GL_INVALID_VALUE, false); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | return true; |
| 239 | } |
| 240 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 241 | bool validateES2TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage, |
| 242 | GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 243 | GLint border, GLenum format, GLenum type, const GLvoid *pixels) |
| 244 | { |
| 245 | if (!validImageSize(context, level, width, height, 1)) |
| 246 | { |
| 247 | return gl::error(GL_INVALID_VALUE, false); |
| 248 | } |
| 249 | |
| 250 | if (isCompressed && !validCompressedImageSize(width, height)) |
| 251 | { |
| 252 | return gl::error(GL_INVALID_OPERATION, false); |
| 253 | } |
| 254 | |
| 255 | if (level < 0 || xoffset < 0 || |
| 256 | std::numeric_limits<GLsizei>::max() - xoffset < width || |
| 257 | std::numeric_limits<GLsizei>::max() - yoffset < height) |
| 258 | { |
| 259 | return gl::error(GL_INVALID_VALUE, false); |
| 260 | } |
| 261 | |
| 262 | if (!isSubImage && !isCompressed && internalformat != GLint(format)) |
| 263 | { |
| 264 | return gl::error(GL_INVALID_OPERATION, false); |
| 265 | } |
| 266 | |
| 267 | gl::Texture *texture = NULL; |
| 268 | bool textureCompressed = false; |
| 269 | GLenum textureInternalFormat = GL_NONE; |
| 270 | GLint textureLevelWidth = 0; |
| 271 | GLint textureLevelHeight = 0; |
| 272 | switch (target) |
| 273 | { |
| 274 | case GL_TEXTURE_2D: |
| 275 | { |
| 276 | if (width > (context->getMaximum2DTextureDimension() >> level) || |
| 277 | height > (context->getMaximum2DTextureDimension() >> level)) |
| 278 | { |
| 279 | return gl::error(GL_INVALID_VALUE, false); |
| 280 | } |
| 281 | |
| 282 | gl::Texture2D *tex2d = context->getTexture2D(); |
| 283 | if (tex2d) |
| 284 | { |
| 285 | textureCompressed = tex2d->isCompressed(level); |
| 286 | textureInternalFormat = tex2d->getInternalFormat(level); |
| 287 | textureLevelWidth = tex2d->getWidth(level); |
| 288 | textureLevelHeight = tex2d->getHeight(level); |
| 289 | texture = tex2d; |
| 290 | } |
| 291 | |
| 292 | if (isSubImage && !validateSubImageParams2D(isCompressed, width, height, xoffset, yoffset, |
| 293 | level, format, type, tex2d)) |
| 294 | { |
| 295 | return false; |
| 296 | } |
| 297 | |
| 298 | texture = tex2d; |
| 299 | } |
| 300 | break; |
| 301 | |
| 302 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 303 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 304 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 305 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 306 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 307 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 308 | { |
| 309 | if (!isSubImage && width != height) |
| 310 | { |
| 311 | return gl::error(GL_INVALID_VALUE, false); |
| 312 | } |
| 313 | |
| 314 | if (width > (context->getMaximumCubeTextureDimension() >> level) || |
| 315 | height > (context->getMaximumCubeTextureDimension() >> level)) |
| 316 | { |
| 317 | return gl::error(GL_INVALID_VALUE, false); |
| 318 | } |
| 319 | |
| 320 | gl::TextureCubeMap *texCube = context->getTextureCubeMap(); |
| 321 | if (texCube) |
| 322 | { |
| 323 | textureCompressed = texCube->isCompressed(target, level); |
| 324 | textureInternalFormat = texCube->getInternalFormat(target, level); |
| 325 | textureLevelWidth = texCube->getWidth(target, level); |
| 326 | textureLevelHeight = texCube->getHeight(target, level); |
| 327 | texture = texCube; |
| 328 | } |
| 329 | |
| 330 | if (isSubImage && !validateSubImageParamsCube(isCompressed, width, height, xoffset, yoffset, |
| 331 | target, level, format, type, texCube)) |
| 332 | { |
| 333 | return false; |
| 334 | } |
| 335 | } |
| 336 | break; |
| 337 | |
| 338 | default: |
| 339 | return gl::error(GL_INVALID_ENUM, false); |
| 340 | } |
| 341 | |
| 342 | if (!texture) |
| 343 | { |
| 344 | return gl::error(GL_INVALID_OPERATION, false); |
| 345 | } |
| 346 | |
| 347 | if (!isSubImage && texture->isImmutable()) |
| 348 | { |
| 349 | return gl::error(GL_INVALID_OPERATION, false); |
| 350 | } |
| 351 | |
| 352 | // Verify zero border |
| 353 | if (border != 0) |
| 354 | { |
| 355 | return gl::error(GL_INVALID_VALUE, false); |
| 356 | } |
| 357 | |
| 358 | // Verify texture is not requesting more mip levels than are available. |
| 359 | if (level > context->getMaximumTextureLevel()) |
| 360 | { |
| 361 | return gl::error(GL_INVALID_VALUE, false); |
| 362 | } |
| 363 | |
| 364 | GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat; |
| 365 | if (isCompressed) |
| 366 | { |
| 367 | switch (actualInternalFormat) |
| 368 | { |
| 369 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 370 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 371 | if (!context->supportsDXT1Textures()) |
| 372 | { |
| 373 | return gl::error(GL_INVALID_ENUM, false); |
| 374 | } |
| 375 | break; |
| 376 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 377 | if (!context->supportsDXT3Textures()) |
| 378 | { |
| 379 | return gl::error(GL_INVALID_ENUM, false); |
| 380 | } |
| 381 | break; |
| 382 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 383 | if (!context->supportsDXT5Textures()) |
| 384 | { |
| 385 | return gl::error(GL_INVALID_ENUM, false); |
| 386 | } |
| 387 | break; |
| 388 | default: |
| 389 | return gl::error(GL_INVALID_ENUM, false); |
| 390 | } |
| 391 | } |
| 392 | else |
| 393 | { |
| 394 | // validate <type> by itself (used as secondary key below) |
| 395 | switch (type) |
| 396 | { |
| 397 | case GL_UNSIGNED_BYTE: |
| 398 | case GL_UNSIGNED_SHORT_5_6_5: |
| 399 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 400 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 401 | case GL_UNSIGNED_SHORT: |
| 402 | case GL_UNSIGNED_INT: |
| 403 | case GL_UNSIGNED_INT_24_8_OES: |
| 404 | case GL_HALF_FLOAT_OES: |
| 405 | case GL_FLOAT: |
| 406 | break; |
| 407 | default: |
| 408 | return gl::error(GL_INVALID_ENUM, false); |
| 409 | } |
| 410 | |
| 411 | // validate <format> + <type> combinations |
| 412 | // - invalid <format> -> sets INVALID_ENUM |
| 413 | // - invalid <format>+<type> combination -> sets INVALID_OPERATION |
| 414 | switch (format) |
| 415 | { |
| 416 | case GL_ALPHA: |
| 417 | case GL_LUMINANCE: |
| 418 | case GL_LUMINANCE_ALPHA: |
| 419 | switch (type) |
| 420 | { |
| 421 | case GL_UNSIGNED_BYTE: |
| 422 | case GL_FLOAT: |
| 423 | case GL_HALF_FLOAT_OES: |
| 424 | break; |
| 425 | default: |
| 426 | return gl::error(GL_INVALID_OPERATION, false); |
| 427 | } |
| 428 | break; |
| 429 | case GL_RGB: |
| 430 | switch (type) |
| 431 | { |
| 432 | case GL_UNSIGNED_BYTE: |
| 433 | case GL_UNSIGNED_SHORT_5_6_5: |
| 434 | case GL_FLOAT: |
| 435 | case GL_HALF_FLOAT_OES: |
| 436 | break; |
| 437 | default: |
| 438 | return gl::error(GL_INVALID_OPERATION, false); |
| 439 | } |
| 440 | break; |
| 441 | case GL_RGBA: |
| 442 | switch (type) |
| 443 | { |
| 444 | case GL_UNSIGNED_BYTE: |
| 445 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 446 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 447 | case GL_FLOAT: |
| 448 | case GL_HALF_FLOAT_OES: |
| 449 | break; |
| 450 | default: |
| 451 | return gl::error(GL_INVALID_OPERATION, false); |
| 452 | } |
| 453 | break; |
| 454 | case GL_BGRA_EXT: |
| 455 | switch (type) |
| 456 | { |
| 457 | case GL_UNSIGNED_BYTE: |
| 458 | break; |
| 459 | default: |
| 460 | return gl::error(GL_INVALID_OPERATION, false); |
| 461 | } |
| 462 | break; |
| 463 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below |
| 464 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 465 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 466 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 467 | break; |
| 468 | case GL_DEPTH_COMPONENT: |
| 469 | switch (type) |
| 470 | { |
| 471 | case GL_UNSIGNED_SHORT: |
| 472 | case GL_UNSIGNED_INT: |
| 473 | break; |
| 474 | default: |
| 475 | return gl::error(GL_INVALID_OPERATION, false); |
| 476 | } |
| 477 | break; |
| 478 | case GL_DEPTH_STENCIL_OES: |
| 479 | switch (type) |
| 480 | { |
| 481 | case GL_UNSIGNED_INT_24_8_OES: |
| 482 | break; |
| 483 | default: |
| 484 | return gl::error(GL_INVALID_OPERATION, false); |
| 485 | } |
| 486 | break; |
| 487 | default: |
| 488 | return gl::error(GL_INVALID_ENUM, false); |
| 489 | } |
| 490 | |
| 491 | switch (format) |
| 492 | { |
| 493 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 494 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 495 | if (context->supportsDXT1Textures()) |
| 496 | { |
| 497 | return gl::error(GL_INVALID_OPERATION, false); |
| 498 | } |
| 499 | else |
| 500 | { |
| 501 | return gl::error(GL_INVALID_ENUM, false); |
| 502 | } |
| 503 | break; |
| 504 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 505 | if (context->supportsDXT3Textures()) |
| 506 | { |
| 507 | return gl::error(GL_INVALID_OPERATION, false); |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | return gl::error(GL_INVALID_ENUM, false); |
| 512 | } |
| 513 | break; |
| 514 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 515 | if (context->supportsDXT5Textures()) |
| 516 | { |
| 517 | return gl::error(GL_INVALID_OPERATION, false); |
| 518 | } |
| 519 | else |
| 520 | { |
| 521 | return gl::error(GL_INVALID_ENUM, false); |
| 522 | } |
| 523 | break; |
| 524 | case GL_DEPTH_COMPONENT: |
| 525 | case GL_DEPTH_STENCIL_OES: |
| 526 | if (!context->supportsDepthTextures()) |
| 527 | { |
| 528 | return gl::error(GL_INVALID_VALUE, false); |
| 529 | } |
| 530 | if (target != GL_TEXTURE_2D) |
| 531 | { |
| 532 | return gl::error(GL_INVALID_OPERATION, false); |
| 533 | } |
| 534 | // OES_depth_texture supports loading depth data and multiple levels, |
| 535 | // but ANGLE_depth_texture does not |
| 536 | if (pixels != NULL || level != 0) |
| 537 | { |
| 538 | return gl::error(GL_INVALID_OPERATION, false); |
| 539 | } |
| 540 | break; |
| 541 | default: |
| 542 | break; |
| 543 | } |
| 544 | |
| 545 | if (type == GL_FLOAT) |
| 546 | { |
| 547 | if (!context->supportsFloat32Textures()) |
| 548 | { |
| 549 | return gl::error(GL_INVALID_ENUM, false); |
| 550 | } |
| 551 | } |
| 552 | else if (type == GL_HALF_FLOAT_OES) |
| 553 | { |
| 554 | if (!context->supportsFloat16Textures()) |
| 555 | { |
| 556 | return gl::error(GL_INVALID_ENUM, false); |
| 557 | } |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | return true; |
| 562 | } |
| 563 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 564 | bool validateES3TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage, |
| 565 | GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, |
| 566 | GLint border, GLenum format, GLenum type) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 567 | { |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 568 | // Validate image size |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 569 | if (!validImageSize(context, level, width, height, depth)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 570 | { |
| 571 | return gl::error(GL_INVALID_VALUE, false); |
| 572 | } |
| 573 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 574 | if (isCompressed && !validCompressedImageSize(width, height)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 575 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 576 | return gl::error(GL_INVALID_OPERATION, false); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | // Verify zero border |
| 580 | if (border != 0) |
| 581 | { |
| 582 | return gl::error(GL_INVALID_VALUE, false); |
| 583 | } |
| 584 | |
| 585 | // Validate dimensions based on Context limits and validate the texture |
| 586 | if (level > context->getMaximumTextureLevel()) |
| 587 | { |
| 588 | return gl::error(GL_INVALID_VALUE, false); |
| 589 | } |
| 590 | |
| 591 | gl::Texture *texture = NULL; |
| 592 | bool textureCompressed = false; |
| 593 | GLenum textureInternalFormat = GL_NONE; |
| 594 | GLint textureLevelWidth = 0; |
| 595 | GLint textureLevelHeight = 0; |
| 596 | GLint textureLevelDepth = 0; |
| 597 | switch (target) |
| 598 | { |
| 599 | case GL_TEXTURE_2D: |
| 600 | { |
| 601 | if (width > (context->getMaximum2DTextureDimension() >> level) || |
| 602 | height > (context->getMaximum2DTextureDimension() >> level)) |
| 603 | { |
| 604 | return gl::error(GL_INVALID_VALUE, false); |
| 605 | } |
| 606 | |
| 607 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 608 | if (texture2d) |
| 609 | { |
| 610 | textureCompressed = texture2d->isCompressed(level); |
| 611 | textureInternalFormat = texture2d->getInternalFormat(level); |
| 612 | textureLevelWidth = texture2d->getWidth(level); |
| 613 | textureLevelHeight = texture2d->getHeight(level); |
| 614 | textureLevelDepth = 1; |
| 615 | texture = texture2d; |
| 616 | } |
| 617 | } |
| 618 | break; |
| 619 | |
| 620 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 621 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 622 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 623 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 624 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 625 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 626 | { |
shannonwoods@chromium.org | 92852cf | 2013-05-30 00:14:12 +0000 | [diff] [blame] | 627 | if (!isSubImage && width != height) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 628 | { |
| 629 | return gl::error(GL_INVALID_VALUE, false); |
| 630 | } |
| 631 | |
| 632 | if (width > (context->getMaximumCubeTextureDimension() >> level)) |
| 633 | { |
| 634 | return gl::error(GL_INVALID_VALUE, false); |
| 635 | } |
| 636 | |
| 637 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 638 | if (textureCube) |
| 639 | { |
| 640 | textureCompressed = textureCube->isCompressed(target, level); |
| 641 | textureInternalFormat = textureCube->getInternalFormat(target, level); |
| 642 | textureLevelWidth = textureCube->getWidth(target, level); |
| 643 | textureLevelHeight = textureCube->getHeight(target, level); |
| 644 | textureLevelDepth = 1; |
| 645 | texture = textureCube; |
| 646 | } |
| 647 | } |
| 648 | break; |
| 649 | |
| 650 | case GL_TEXTURE_3D: |
| 651 | { |
| 652 | if (width > (context->getMaximum3DTextureDimension() >> level) || |
| 653 | height > (context->getMaximum3DTextureDimension() >> level) || |
| 654 | depth > (context->getMaximum3DTextureDimension() >> level)) |
| 655 | { |
| 656 | return gl::error(GL_INVALID_VALUE, false); |
| 657 | } |
| 658 | |
| 659 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 660 | if (texture3d) |
| 661 | { |
| 662 | textureCompressed = texture3d->isCompressed(level); |
| 663 | textureInternalFormat = texture3d->getInternalFormat(level); |
| 664 | textureLevelWidth = texture3d->getWidth(level); |
| 665 | textureLevelHeight = texture3d->getHeight(level); |
| 666 | textureLevelDepth = texture3d->getDepth(level); |
| 667 | texture = texture3d; |
| 668 | } |
| 669 | } |
| 670 | break; |
| 671 | |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 672 | case GL_TEXTURE_2D_ARRAY: |
| 673 | { |
| 674 | if (width > (context->getMaximum2DTextureDimension() >> level) || |
| 675 | height > (context->getMaximum2DTextureDimension() >> level) || |
| 676 | depth > (context->getMaximum2DArrayTextureLayers() >> level)) |
| 677 | { |
| 678 | return gl::error(GL_INVALID_VALUE, false); |
| 679 | } |
| 680 | |
| 681 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 682 | if (texture2darray) |
| 683 | { |
| 684 | textureCompressed = texture2darray->isCompressed(level); |
| 685 | textureInternalFormat = texture2darray->getInternalFormat(level); |
| 686 | textureLevelWidth = texture2darray->getWidth(level); |
| 687 | textureLevelHeight = texture2darray->getHeight(level); |
| 688 | textureLevelDepth = texture2darray->getDepth(level); |
| 689 | texture = texture2darray; |
| 690 | } |
| 691 | } |
| 692 | break; |
| 693 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 694 | default: |
| 695 | return gl::error(GL_INVALID_ENUM, false); |
| 696 | } |
| 697 | |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 698 | if (!texture) |
| 699 | { |
| 700 | return gl::error(GL_INVALID_OPERATION, false); |
| 701 | } |
| 702 | |
shannonwoods@chromium.org | cf2533c | 2013-05-30 00:14:18 +0000 | [diff] [blame] | 703 | if (texture->isImmutable() && !isSubImage) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 704 | { |
| 705 | return gl::error(GL_INVALID_OPERATION, false); |
| 706 | } |
| 707 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 708 | // Validate texture formats |
| 709 | GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat; |
| 710 | if (isCompressed) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 711 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 712 | if (!gl::IsFormatCompressed(actualInternalFormat, context->getClientVersion())) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 713 | { |
| 714 | return gl::error(GL_INVALID_ENUM, false); |
| 715 | } |
| 716 | |
| 717 | if (target == GL_TEXTURE_3D) |
| 718 | { |
| 719 | return gl::error(GL_INVALID_OPERATION, false); |
| 720 | } |
| 721 | } |
| 722 | else |
| 723 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 724 | if (!gl::IsValidInternalFormat(actualInternalFormat, context) || |
| 725 | !gl::IsValidFormat(format, context->getClientVersion()) || |
| 726 | !gl::IsValidType(type, context->getClientVersion())) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 727 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 728 | return gl::error(GL_INVALID_ENUM, false); |
| 729 | } |
| 730 | |
| 731 | if (!gl::IsValidFormatCombination(actualInternalFormat, format, type, context->getClientVersion())) |
| 732 | { |
| 733 | return gl::error(GL_INVALID_OPERATION, false); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 734 | } |
| 735 | |
| 736 | if ((target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) && |
| 737 | (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL)) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 738 | { |
| 739 | return gl::error(GL_INVALID_OPERATION, false); |
| 740 | } |
| 741 | } |
| 742 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 743 | // Validate sub image parameters |
| 744 | if (isSubImage) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 745 | { |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 746 | if (isCompressed != textureCompressed) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 747 | { |
| 748 | return gl::error(GL_INVALID_OPERATION, false); |
| 749 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 750 | |
| 751 | if (format != GL_NONE) |
| 752 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 753 | GLenum internalformat = gl::GetSizedInternalFormat(format, type, context->getClientVersion()); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 754 | if (internalformat != textureInternalFormat) |
| 755 | { |
| 756 | return gl::error(GL_INVALID_OPERATION, false); |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | if (isCompressed) |
| 761 | { |
| 762 | if ((width % 4 != 0 && width != textureLevelWidth) || |
| 763 | (height % 4 != 0 && height != textureLevelHeight)) |
| 764 | { |
| 765 | return gl::error(GL_INVALID_OPERATION, false); |
| 766 | } |
| 767 | } |
| 768 | |
| 769 | if (width == 0 || height == 0 || depth == 0) |
| 770 | { |
| 771 | return false; |
| 772 | } |
| 773 | |
| 774 | if (xoffset < 0 || yoffset < 0 || zoffset < 0) |
| 775 | { |
| 776 | return gl::error(GL_INVALID_VALUE, false); |
| 777 | } |
| 778 | |
| 779 | if (std::numeric_limits<GLsizei>::max() - xoffset < width || |
| 780 | std::numeric_limits<GLsizei>::max() - yoffset < height || |
| 781 | std::numeric_limits<GLsizei>::max() - zoffset < depth) |
| 782 | { |
| 783 | return gl::error(GL_INVALID_VALUE, false); |
| 784 | } |
| 785 | |
| 786 | if (xoffset + width > textureLevelWidth || |
| 787 | yoffset + height > textureLevelHeight || |
| 788 | zoffset + depth > textureLevelDepth) |
| 789 | { |
| 790 | return gl::error(GL_INVALID_VALUE, false); |
| 791 | } |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 792 | } |
| 793 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 794 | return true; |
| 795 | } |
| 796 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 797 | |
| 798 | bool validateES2CopyTexImageParameters(gl::Context* context, GLenum target, GLint level, GLenum internalformat, bool isSubImage, |
| 799 | GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, |
| 800 | GLint border) |
| 801 | { |
| 802 | if (!gl::IsInternalTextureTarget(target)) |
| 803 | { |
| 804 | return gl::error(GL_INVALID_ENUM, false); |
| 805 | } |
| 806 | |
| 807 | if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0) |
| 808 | { |
| 809 | return gl::error(GL_INVALID_VALUE, false); |
| 810 | } |
| 811 | |
| 812 | if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height) |
| 813 | { |
| 814 | return gl::error(GL_INVALID_VALUE, false); |
| 815 | } |
| 816 | |
| 817 | if (width == 0 || height == 0) |
| 818 | { |
| 819 | return false; |
| 820 | } |
| 821 | |
| 822 | // Verify zero border |
| 823 | if (border != 0) |
| 824 | { |
| 825 | return gl::error(GL_INVALID_VALUE, false); |
| 826 | } |
| 827 | |
| 828 | // Validate dimensions based on Context limits and validate the texture |
| 829 | if (level > context->getMaximumTextureLevel()) |
| 830 | { |
| 831 | return gl::error(GL_INVALID_VALUE, false); |
| 832 | } |
| 833 | |
| 834 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 835 | |
| 836 | if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) |
| 837 | { |
| 838 | return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); |
| 839 | } |
| 840 | |
| 841 | if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0) |
| 842 | { |
| 843 | return gl::error(GL_INVALID_OPERATION, false); |
| 844 | } |
| 845 | |
| 846 | GLenum colorbufferFormat = framebuffer->getReadColorbuffer()->getInternalFormat(); |
| 847 | gl::Texture *texture = NULL; |
| 848 | GLenum textureFormat = GL_RGBA; |
| 849 | |
| 850 | switch (target) |
| 851 | { |
| 852 | case GL_TEXTURE_2D: |
| 853 | { |
| 854 | if (width > (context->getMaximum2DTextureDimension() >> level) || |
| 855 | height > (context->getMaximum2DTextureDimension() >> level)) |
| 856 | { |
| 857 | return gl::error(GL_INVALID_VALUE, false); |
| 858 | } |
| 859 | |
| 860 | gl::Texture2D *tex2d = context->getTexture2D(); |
| 861 | if (tex2d) |
| 862 | { |
| 863 | if (isSubImage && !validateSubImageParams2D(false, width, height, xoffset, yoffset, level, GL_NONE, GL_NONE, tex2d)) |
| 864 | { |
| 865 | return false; // error already registered by validateSubImageParams |
| 866 | } |
| 867 | texture = tex2d; |
| 868 | textureFormat = gl::GetFormat(tex2d->getInternalFormat(level), context->getClientVersion()); |
| 869 | } |
| 870 | } |
| 871 | break; |
| 872 | |
| 873 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 874 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 875 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 876 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 877 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 878 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 879 | { |
| 880 | if (!isSubImage && width != height) |
| 881 | { |
| 882 | return gl::error(GL_INVALID_VALUE, false); |
| 883 | } |
| 884 | |
| 885 | if (width > (context->getMaximumCubeTextureDimension() >> level) || |
| 886 | height > (context->getMaximumCubeTextureDimension() >> level)) |
| 887 | { |
| 888 | return gl::error(GL_INVALID_VALUE, false); |
| 889 | } |
| 890 | |
| 891 | gl::TextureCubeMap *texcube = context->getTextureCubeMap(); |
| 892 | if (texcube) |
| 893 | { |
| 894 | if (isSubImage && !validateSubImageParamsCube(false, width, height, xoffset, yoffset, target, level, GL_NONE, GL_NONE, texcube)) |
| 895 | { |
| 896 | return false; // error already registered by validateSubImageParams |
| 897 | } |
| 898 | texture = texcube; |
| 899 | textureFormat = gl::GetFormat(texcube->getInternalFormat(target, level), context->getClientVersion()); |
| 900 | } |
| 901 | } |
| 902 | break; |
| 903 | |
| 904 | default: |
| 905 | return gl::error(GL_INVALID_ENUM, false); |
| 906 | } |
| 907 | |
| 908 | if (!texture) |
| 909 | { |
| 910 | return gl::error(GL_INVALID_OPERATION, false); |
| 911 | } |
| 912 | |
| 913 | if (texture->isImmutable() && !isSubImage) |
| 914 | { |
| 915 | return gl::error(GL_INVALID_OPERATION, false); |
| 916 | } |
| 917 | |
| 918 | |
| 919 | // [OpenGL ES 2.0.24] table 3.9 |
| 920 | if (isSubImage) |
| 921 | { |
| 922 | switch (textureFormat) |
| 923 | { |
| 924 | case GL_ALPHA: |
| 925 | if (colorbufferFormat != GL_ALPHA8_EXT && |
| 926 | colorbufferFormat != GL_RGBA4 && |
| 927 | colorbufferFormat != GL_RGB5_A1 && |
| 928 | colorbufferFormat != GL_RGBA8_OES) |
| 929 | { |
| 930 | return gl::error(GL_INVALID_OPERATION, false); |
| 931 | } |
| 932 | break; |
| 933 | case GL_LUMINANCE: |
| 934 | case GL_RGB: |
| 935 | if (colorbufferFormat != GL_RGB565 && |
| 936 | colorbufferFormat != GL_RGB8_OES && |
| 937 | colorbufferFormat != GL_RGBA4 && |
| 938 | colorbufferFormat != GL_RGB5_A1 && |
| 939 | colorbufferFormat != GL_RGBA8_OES) |
| 940 | { |
| 941 | return gl::error(GL_INVALID_OPERATION, false); |
| 942 | } |
| 943 | break; |
| 944 | case GL_LUMINANCE_ALPHA: |
| 945 | case GL_RGBA: |
| 946 | if (colorbufferFormat != GL_RGBA4 && |
| 947 | colorbufferFormat != GL_RGB5_A1 && |
| 948 | colorbufferFormat != GL_RGBA8_OES) |
| 949 | { |
| 950 | return gl::error(GL_INVALID_OPERATION, false); |
| 951 | } |
| 952 | break; |
| 953 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 954 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 955 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 956 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 957 | return gl::error(GL_INVALID_OPERATION, false); |
| 958 | case GL_DEPTH_COMPONENT: |
| 959 | case GL_DEPTH_STENCIL_OES: |
| 960 | return gl::error(GL_INVALID_OPERATION, false); |
| 961 | default: |
| 962 | return gl::error(GL_INVALID_OPERATION, false); |
| 963 | } |
| 964 | } |
| 965 | else |
| 966 | { |
| 967 | switch (internalformat) |
| 968 | { |
| 969 | case GL_ALPHA: |
| 970 | if (colorbufferFormat != GL_ALPHA8_EXT && |
| 971 | colorbufferFormat != GL_RGBA4 && |
| 972 | colorbufferFormat != GL_RGB5_A1 && |
| 973 | colorbufferFormat != GL_BGRA8_EXT && |
| 974 | colorbufferFormat != GL_RGBA8_OES) |
| 975 | { |
| 976 | return gl::error(GL_INVALID_OPERATION, false); |
| 977 | } |
| 978 | break; |
| 979 | case GL_LUMINANCE: |
| 980 | case GL_RGB: |
| 981 | if (colorbufferFormat != GL_RGB565 && |
| 982 | colorbufferFormat != GL_RGB8_OES && |
| 983 | colorbufferFormat != GL_RGBA4 && |
| 984 | colorbufferFormat != GL_RGB5_A1 && |
| 985 | colorbufferFormat != GL_BGRA8_EXT && |
| 986 | colorbufferFormat != GL_RGBA8_OES) |
| 987 | { |
| 988 | return gl::error(GL_INVALID_OPERATION, false); |
| 989 | } |
| 990 | break; |
| 991 | case GL_LUMINANCE_ALPHA: |
| 992 | case GL_RGBA: |
| 993 | if (colorbufferFormat != GL_RGBA4 && |
| 994 | colorbufferFormat != GL_RGB5_A1 && |
| 995 | colorbufferFormat != GL_BGRA8_EXT && |
| 996 | colorbufferFormat != GL_RGBA8_OES) |
| 997 | { |
| 998 | return gl::error(GL_INVALID_OPERATION, false); |
| 999 | } |
| 1000 | break; |
| 1001 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 1002 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 1003 | if (context->supportsDXT1Textures()) |
| 1004 | { |
| 1005 | return gl::error(GL_INVALID_OPERATION, false); |
| 1006 | } |
| 1007 | else |
| 1008 | { |
| 1009 | return gl::error(GL_INVALID_ENUM, false); |
| 1010 | } |
| 1011 | break; |
| 1012 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 1013 | if (context->supportsDXT3Textures()) |
| 1014 | { |
| 1015 | return gl::error(GL_INVALID_OPERATION, false); |
| 1016 | } |
| 1017 | else |
| 1018 | { |
| 1019 | return gl::error(GL_INVALID_ENUM, false); |
| 1020 | } |
| 1021 | break; |
| 1022 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 1023 | if (context->supportsDXT5Textures()) |
| 1024 | { |
| 1025 | return gl::error(GL_INVALID_OPERATION, false); |
| 1026 | } |
| 1027 | else |
| 1028 | { |
| 1029 | return gl::error(GL_INVALID_ENUM, false); |
| 1030 | } |
| 1031 | break; |
| 1032 | case GL_DEPTH_COMPONENT: |
| 1033 | case GL_DEPTH_COMPONENT16: |
| 1034 | case GL_DEPTH_COMPONENT32_OES: |
| 1035 | case GL_DEPTH_STENCIL_OES: |
| 1036 | case GL_DEPTH24_STENCIL8_OES: |
| 1037 | if (context->supportsDepthTextures()) |
| 1038 | { |
| 1039 | return gl::error(GL_INVALID_OPERATION, false); |
| 1040 | } |
| 1041 | else |
| 1042 | { |
| 1043 | return gl::error(GL_INVALID_ENUM, false); |
| 1044 | } |
| 1045 | default: |
| 1046 | return gl::error(GL_INVALID_ENUM, false); |
| 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | return true; |
| 1051 | } |
| 1052 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 1053 | bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLint level, GLenum internalformat, |
| 1054 | bool isSubImage, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, |
| 1055 | GLsizei width, GLsizei height, GLint border) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1056 | { |
| 1057 | if (level < 0 || xoffset < 0 || yoffset < 0 || zoffset < 0 || width < 0 || height < 0) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 1058 | { |
| 1059 | return gl::error(GL_INVALID_VALUE, false); |
| 1060 | } |
| 1061 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1062 | if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height) |
| 1063 | { |
| 1064 | return gl::error(GL_INVALID_VALUE, false); |
| 1065 | } |
| 1066 | |
| 1067 | if (width == 0 || height == 0) |
| 1068 | { |
| 1069 | return false; |
| 1070 | } |
| 1071 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 1072 | if (border != 0) |
| 1073 | { |
| 1074 | return gl::error(GL_INVALID_VALUE, false); |
| 1075 | } |
| 1076 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1077 | if (level > context->getMaximumTextureLevel()) |
| 1078 | { |
| 1079 | return gl::error(GL_INVALID_VALUE, false); |
| 1080 | } |
| 1081 | |
| 1082 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 1083 | |
| 1084 | if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) |
| 1085 | { |
| 1086 | return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); |
| 1087 | } |
| 1088 | |
| 1089 | if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0) |
| 1090 | { |
| 1091 | return gl::error(GL_INVALID_OPERATION, false); |
| 1092 | } |
| 1093 | |
| 1094 | gl::Renderbuffer *source = framebuffer->getReadColorbuffer(); |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1095 | GLenum colorbufferInternalFormat = source->getInternalFormat(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1096 | gl::Texture *texture = NULL; |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1097 | GLenum textureInternalFormat = GL_NONE; |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1098 | bool textureCompressed = false; |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame^] | 1099 | bool textureIsDepth = false; |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1100 | GLint textureLevelWidth = 0; |
| 1101 | GLint textureLevelHeight = 0; |
| 1102 | GLint textureLevelDepth = 0; |
| 1103 | switch (target) |
| 1104 | { |
| 1105 | case GL_TEXTURE_2D: |
| 1106 | { |
| 1107 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 1108 | if (texture2d) |
| 1109 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1110 | textureInternalFormat = texture2d->getInternalFormat(level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1111 | textureCompressed = texture2d->isCompressed(level); |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame^] | 1112 | textureIsDepth = texture2d->isDepth(level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1113 | textureLevelWidth = texture2d->getWidth(level); |
| 1114 | textureLevelHeight = texture2d->getHeight(level); |
| 1115 | textureLevelDepth = 1; |
| 1116 | texture = texture2d; |
| 1117 | } |
| 1118 | } |
| 1119 | break; |
| 1120 | |
| 1121 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 1122 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 1123 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 1124 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 1125 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 1126 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 1127 | { |
| 1128 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 1129 | if (textureCube) |
| 1130 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1131 | textureInternalFormat = textureCube->getInternalFormat(target, level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1132 | textureCompressed = textureCube->isCompressed(target, level); |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame^] | 1133 | textureIsDepth = false; |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1134 | textureLevelWidth = textureCube->getWidth(target, level); |
| 1135 | textureLevelHeight = textureCube->getHeight(target, level); |
| 1136 | textureLevelDepth = 1; |
| 1137 | texture = textureCube; |
| 1138 | } |
| 1139 | } |
| 1140 | break; |
| 1141 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1142 | case GL_TEXTURE_2D_ARRAY: |
| 1143 | { |
| 1144 | gl::Texture2DArray *texture2dArray = context->getTexture2DArray(); |
| 1145 | if (texture2dArray) |
| 1146 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1147 | textureInternalFormat = texture2dArray->getInternalFormat(level); |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1148 | textureCompressed = texture2dArray->isCompressed(level); |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame^] | 1149 | textureIsDepth = texture2dArray->isDepth(level); |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1150 | textureLevelWidth = texture2dArray->getWidth(level); |
| 1151 | textureLevelHeight = texture2dArray->getHeight(level); |
| 1152 | textureLevelDepth = texture2dArray->getDepth(level); |
| 1153 | texture = texture2dArray; |
| 1154 | } |
| 1155 | } |
| 1156 | break; |
| 1157 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1158 | case GL_TEXTURE_3D: |
| 1159 | { |
| 1160 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 1161 | if (texture3d) |
| 1162 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1163 | textureInternalFormat = texture3d->getInternalFormat(level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1164 | textureCompressed = texture3d->isCompressed(level); |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame^] | 1165 | textureIsDepth = texture3d->isDepth(level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1166 | textureLevelWidth = texture3d->getWidth(level); |
| 1167 | textureLevelHeight = texture3d->getHeight(level); |
| 1168 | textureLevelDepth = texture3d->getDepth(level); |
| 1169 | texture = texture3d; |
| 1170 | } |
| 1171 | } |
| 1172 | break; |
| 1173 | |
| 1174 | default: |
| 1175 | return gl::error(GL_INVALID_ENUM, false); |
| 1176 | } |
| 1177 | |
| 1178 | if (!texture) |
| 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 (texture->isImmutable() && !isSubImage) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1184 | { |
| 1185 | return gl::error(GL_INVALID_OPERATION, false); |
| 1186 | } |
| 1187 | |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame^] | 1188 | if (textureIsDepth) |
| 1189 | { |
| 1190 | return gl::error(GL_INVALID_OPERATION, false); |
| 1191 | } |
| 1192 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 1193 | if (textureCompressed) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1194 | { |
| 1195 | if ((width % 4 != 0 && width != textureLevelWidth) || |
| 1196 | (height % 4 != 0 && height != textureLevelHeight)) |
| 1197 | { |
| 1198 | return gl::error(GL_INVALID_OPERATION, false); |
| 1199 | } |
| 1200 | } |
| 1201 | |
Geoff Lang | a4d1332 | 2013-06-05 14:57:51 -0400 | [diff] [blame] | 1202 | if (isSubImage) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1203 | { |
Geoff Lang | a4d1332 | 2013-06-05 14:57:51 -0400 | [diff] [blame] | 1204 | if (xoffset + width > textureLevelWidth || |
| 1205 | yoffset + height > textureLevelHeight || |
| 1206 | zoffset >= textureLevelDepth) |
| 1207 | { |
| 1208 | return gl::error(GL_INVALID_VALUE, false); |
| 1209 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1210 | |
Geoff Lang | a4d1332 | 2013-06-05 14:57:51 -0400 | [diff] [blame] | 1211 | if (!gl::IsValidCopyTexImageCombination(textureInternalFormat, colorbufferInternalFormat, |
| 1212 | context->getClientVersion())) |
| 1213 | { |
| 1214 | return gl::error(GL_INVALID_OPERATION, false); |
| 1215 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1216 | } |
| 1217 | |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 1218 | return true; |
| 1219 | } |
| 1220 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 1221 | bool validateES2TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat, |
| 1222 | GLsizei width, GLsizei height) |
| 1223 | { |
| 1224 | if (target != GL_TEXTURE_2D && target != GL_TEXTURE_CUBE_MAP) |
| 1225 | { |
| 1226 | return gl::error(GL_INVALID_ENUM, false); |
| 1227 | } |
| 1228 | |
| 1229 | if (width < 1 || height < 1 || levels < 1) |
| 1230 | { |
| 1231 | return gl::error(GL_INVALID_VALUE, false); |
| 1232 | } |
| 1233 | |
| 1234 | if (target == GL_TEXTURE_CUBE_MAP && width != height) |
| 1235 | { |
| 1236 | return gl::error(GL_INVALID_VALUE, false); |
| 1237 | } |
| 1238 | |
| 1239 | if (levels != 1 && levels != gl::log2(std::max(width, height)) + 1) |
| 1240 | { |
| 1241 | return gl::error(GL_INVALID_OPERATION, false); |
| 1242 | } |
| 1243 | |
| 1244 | GLenum format = gl::GetFormat(internalformat, context->getClientVersion()); |
| 1245 | GLenum type = gl::GetType(internalformat, context->getClientVersion()); |
| 1246 | |
| 1247 | if (format == GL_NONE || type == GL_NONE) |
| 1248 | { |
| 1249 | return gl::error(GL_INVALID_ENUM, false); |
| 1250 | } |
| 1251 | |
| 1252 | switch (target) |
| 1253 | { |
| 1254 | case GL_TEXTURE_2D: |
| 1255 | if (width > context->getMaximum2DTextureDimension() || |
| 1256 | height > context->getMaximum2DTextureDimension()) |
| 1257 | { |
| 1258 | return gl::error(GL_INVALID_VALUE, false); |
| 1259 | } |
| 1260 | break; |
| 1261 | case GL_TEXTURE_CUBE_MAP: |
| 1262 | if (width > context->getMaximumCubeTextureDimension() || |
| 1263 | height > context->getMaximumCubeTextureDimension()) |
| 1264 | { |
| 1265 | return gl::error(GL_INVALID_VALUE, false); |
| 1266 | } |
| 1267 | break; |
| 1268 | default: |
| 1269 | return gl::error(GL_INVALID_ENUM, false); |
| 1270 | } |
| 1271 | |
| 1272 | if (levels != 1 && !context->supportsNonPower2Texture()) |
| 1273 | { |
| 1274 | if (!gl::isPow2(width) || !gl::isPow2(height)) |
| 1275 | { |
| 1276 | return gl::error(GL_INVALID_OPERATION, false); |
| 1277 | } |
| 1278 | } |
| 1279 | |
| 1280 | switch (internalformat) |
| 1281 | { |
| 1282 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 1283 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 1284 | if (!context->supportsDXT1Textures()) |
| 1285 | { |
| 1286 | return gl::error(GL_INVALID_ENUM, false); |
| 1287 | } |
| 1288 | break; |
| 1289 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 1290 | if (!context->supportsDXT3Textures()) |
| 1291 | { |
| 1292 | return gl::error(GL_INVALID_ENUM, false); |
| 1293 | } |
| 1294 | break; |
| 1295 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 1296 | if (!context->supportsDXT5Textures()) |
| 1297 | { |
| 1298 | return gl::error(GL_INVALID_ENUM, false); |
| 1299 | } |
| 1300 | break; |
| 1301 | case GL_RGBA32F_EXT: |
| 1302 | case GL_RGB32F_EXT: |
| 1303 | case GL_ALPHA32F_EXT: |
| 1304 | case GL_LUMINANCE32F_EXT: |
| 1305 | case GL_LUMINANCE_ALPHA32F_EXT: |
| 1306 | if (!context->supportsFloat32Textures()) |
| 1307 | { |
| 1308 | return gl::error(GL_INVALID_ENUM, false); |
| 1309 | } |
| 1310 | break; |
| 1311 | case GL_RGBA16F_EXT: |
| 1312 | case GL_RGB16F_EXT: |
| 1313 | case GL_ALPHA16F_EXT: |
| 1314 | case GL_LUMINANCE16F_EXT: |
| 1315 | case GL_LUMINANCE_ALPHA16F_EXT: |
| 1316 | if (!context->supportsFloat16Textures()) |
| 1317 | { |
| 1318 | return gl::error(GL_INVALID_ENUM, false); |
| 1319 | } |
| 1320 | break; |
| 1321 | case GL_DEPTH_COMPONENT16: |
| 1322 | case GL_DEPTH_COMPONENT32_OES: |
| 1323 | case GL_DEPTH24_STENCIL8_OES: |
| 1324 | if (!context->supportsDepthTextures()) |
| 1325 | { |
| 1326 | return gl::error(GL_INVALID_ENUM, false); |
| 1327 | } |
| 1328 | if (target != GL_TEXTURE_2D) |
| 1329 | { |
| 1330 | return gl::error(GL_INVALID_OPERATION, false); |
| 1331 | } |
| 1332 | // ANGLE_depth_texture only supports 1-level textures |
| 1333 | if (levels != 1) |
| 1334 | { |
| 1335 | return gl::error(GL_INVALID_OPERATION, false); |
| 1336 | } |
| 1337 | break; |
| 1338 | default: |
| 1339 | break; |
| 1340 | } |
| 1341 | |
| 1342 | gl::Texture *texture = NULL; |
| 1343 | switch(target) |
| 1344 | { |
| 1345 | case GL_TEXTURE_2D: |
| 1346 | texture = context->getTexture2D(); |
| 1347 | break; |
| 1348 | case GL_TEXTURE_CUBE_MAP: |
| 1349 | texture = context->getTextureCubeMap(); |
| 1350 | break; |
| 1351 | default: |
| 1352 | UNREACHABLE(); |
| 1353 | } |
| 1354 | |
| 1355 | if (!texture || texture->id() == 0) |
| 1356 | { |
| 1357 | return gl::error(GL_INVALID_OPERATION, false); |
| 1358 | } |
| 1359 | |
| 1360 | if (texture->isImmutable()) |
| 1361 | { |
| 1362 | return gl::error(GL_INVALID_OPERATION, false); |
| 1363 | } |
| 1364 | |
| 1365 | return true; |
| 1366 | } |
| 1367 | |
| 1368 | bool validateES3TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat, |
| 1369 | GLsizei width, GLsizei height, GLsizei depth) |
| 1370 | { |
| 1371 | if (width < 1 || height < 1 || depth < 1 || levels < 1) |
| 1372 | { |
| 1373 | return gl::error(GL_INVALID_VALUE, false); |
| 1374 | } |
| 1375 | |
| 1376 | if (levels > gl::log2(std::max(std::max(width, height), depth)) + 1) |
| 1377 | { |
| 1378 | return gl::error(GL_INVALID_OPERATION, false); |
| 1379 | } |
| 1380 | |
| 1381 | gl::Texture *texture = NULL; |
| 1382 | switch (target) |
| 1383 | { |
| 1384 | case GL_TEXTURE_2D: |
| 1385 | { |
| 1386 | texture = context->getTexture2D(); |
| 1387 | |
| 1388 | if (width > (context->getMaximum2DTextureDimension()) || |
| 1389 | height > (context->getMaximum2DTextureDimension())) |
| 1390 | { |
| 1391 | return gl::error(GL_INVALID_VALUE, false); |
| 1392 | } |
| 1393 | } |
| 1394 | break; |
| 1395 | |
| 1396 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 1397 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 1398 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 1399 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 1400 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 1401 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 1402 | { |
| 1403 | texture = context->getTextureCubeMap(); |
| 1404 | |
| 1405 | if (width != height) |
| 1406 | { |
| 1407 | return gl::error(GL_INVALID_VALUE, false); |
| 1408 | } |
| 1409 | |
| 1410 | if (width > (context->getMaximumCubeTextureDimension())) |
| 1411 | { |
| 1412 | return gl::error(GL_INVALID_VALUE, false); |
| 1413 | } |
| 1414 | } |
| 1415 | break; |
| 1416 | |
| 1417 | case GL_TEXTURE_3D: |
| 1418 | { |
| 1419 | texture = context->getTexture3D(); |
| 1420 | |
| 1421 | if (width > (context->getMaximum3DTextureDimension()) || |
| 1422 | height > (context->getMaximum3DTextureDimension()) || |
| 1423 | depth > (context->getMaximum3DTextureDimension())) |
| 1424 | { |
| 1425 | return gl::error(GL_INVALID_VALUE, false); |
| 1426 | } |
| 1427 | } |
| 1428 | break; |
| 1429 | |
| 1430 | case GL_TEXTURE_2D_ARRAY: |
| 1431 | { |
| 1432 | texture = context->getTexture2DArray(); |
| 1433 | |
| 1434 | if (width > (context->getMaximum2DTextureDimension()) || |
| 1435 | height > (context->getMaximum2DTextureDimension()) || |
| 1436 | depth > (context->getMaximum2DArrayTextureLayers())) |
| 1437 | { |
| 1438 | return gl::error(GL_INVALID_VALUE, false); |
| 1439 | } |
| 1440 | } |
| 1441 | break; |
| 1442 | |
| 1443 | default: |
| 1444 | return gl::error(GL_INVALID_ENUM, false); |
| 1445 | } |
| 1446 | |
| 1447 | if (!texture || texture->id() == 0) |
| 1448 | { |
| 1449 | return gl::error(GL_INVALID_OPERATION, false); |
| 1450 | } |
| 1451 | |
| 1452 | if (texture->isImmutable()) |
| 1453 | { |
| 1454 | return gl::error(GL_INVALID_OPERATION, false); |
| 1455 | } |
| 1456 | |
| 1457 | if (!gl::IsValidInternalFormat(internalformat, context)) |
| 1458 | { |
| 1459 | return gl::error(GL_INVALID_ENUM, false); |
| 1460 | } |
| 1461 | |
| 1462 | if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion())) |
| 1463 | { |
| 1464 | return gl::error(GL_INVALID_ENUM, false); |
| 1465 | } |
| 1466 | |
| 1467 | return true; |
| 1468 | } |
| 1469 | |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 1470 | bool validateRenderbufferStorageParameters(const gl::Context *context, GLenum target, GLsizei samples, |
| 1471 | GLenum internalformat, GLsizei width, GLsizei height, |
| 1472 | bool angleExtension) |
| 1473 | { |
| 1474 | switch (target) |
| 1475 | { |
| 1476 | case GL_RENDERBUFFER: |
| 1477 | break; |
| 1478 | default: |
| 1479 | return gl::error(GL_INVALID_ENUM, false); |
| 1480 | } |
| 1481 | |
| 1482 | if (width < 0 || height < 0 || samples < 0) |
| 1483 | { |
| 1484 | return gl::error(GL_INVALID_VALUE, false); |
| 1485 | } |
| 1486 | |
| 1487 | if (!gl::IsValidInternalFormat(internalformat, context)) |
| 1488 | { |
| 1489 | return gl::error(GL_INVALID_ENUM, false); |
| 1490 | } |
| 1491 | |
| 1492 | // ANGLE_framebuffer_multisample does not explicitly state that the internal format must be |
| 1493 | // sized but it does state that the format must be in the ES2.0 spec table 4.5 which contains |
| 1494 | // only sized internal formats. The ES3 spec (section 4.4.2) does, however, state that the |
| 1495 | // internal format must be sized and not an integer format if samples is greater than zero. |
| 1496 | if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion())) |
| 1497 | { |
| 1498 | return gl::error(GL_INVALID_ENUM, false); |
| 1499 | } |
| 1500 | |
| 1501 | if (gl::IsIntegerFormat(internalformat, context->getClientVersion()) && samples > 0) |
| 1502 | { |
| 1503 | return gl::error(GL_INVALID_OPERATION, false); |
| 1504 | } |
| 1505 | |
| 1506 | if (!gl::IsColorRenderingSupported(internalformat, context) && |
| 1507 | !gl::IsDepthRenderingSupported(internalformat, context) && |
| 1508 | !gl::IsStencilRenderingSupported(internalformat, context)) |
| 1509 | { |
| 1510 | return gl::error(GL_INVALID_ENUM, false); |
| 1511 | } |
| 1512 | |
| 1513 | if (std::max(width, height) > context->getMaximumRenderbufferDimension()) |
| 1514 | { |
| 1515 | return gl::error(GL_INVALID_VALUE, false); |
| 1516 | } |
| 1517 | |
| 1518 | // ANGLE_framebuffer_multisample states that the value of samples must be less than or equal |
| 1519 | // to MAX_SAMPLES_ANGLE (Context::getMaxSupportedSamples) while the ES3.0 spec (section 4.4.2) |
| 1520 | // states that samples must be less than or equal to the maximum samples for the specified |
| 1521 | // internal format. |
| 1522 | if (angleExtension) |
| 1523 | { |
| 1524 | if (samples > context->getMaxSupportedSamples()) |
| 1525 | { |
| 1526 | return gl::error(GL_INVALID_VALUE, false); |
| 1527 | } |
| 1528 | } |
| 1529 | else |
| 1530 | { |
| 1531 | if (samples > context->getMaxSupportedFormatSamples(internalformat)) |
| 1532 | { |
| 1533 | return gl::error(GL_INVALID_VALUE, false); |
| 1534 | } |
| 1535 | } |
| 1536 | |
| 1537 | GLuint handle = context->getRenderbufferHandle(); |
| 1538 | if (handle == 0) |
| 1539 | { |
| 1540 | return gl::error(GL_INVALID_OPERATION, false); |
| 1541 | } |
| 1542 | |
| 1543 | return true; |
| 1544 | } |
| 1545 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1546 | // 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] | 1547 | bool validES2ReadFormatType(GLenum format, GLenum type) |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1548 | { |
| 1549 | switch (format) |
| 1550 | { |
| 1551 | case GL_RGBA: |
| 1552 | switch (type) |
| 1553 | { |
| 1554 | case GL_UNSIGNED_BYTE: |
| 1555 | break; |
| 1556 | default: |
| 1557 | return false; |
| 1558 | } |
| 1559 | break; |
| 1560 | case GL_BGRA_EXT: |
| 1561 | switch (type) |
| 1562 | { |
| 1563 | case GL_UNSIGNED_BYTE: |
| 1564 | case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: |
| 1565 | case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: |
| 1566 | break; |
| 1567 | default: |
| 1568 | return false; |
| 1569 | } |
| 1570 | break; |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1571 | default: |
| 1572 | return false; |
| 1573 | } |
| 1574 | return true; |
| 1575 | } |
| 1576 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 1577 | bool validES3ReadFormatType(GLenum internalFormat, GLenum format, GLenum type) |
| 1578 | { |
| 1579 | switch (format) |
| 1580 | { |
| 1581 | case GL_RGBA: |
| 1582 | switch (type) |
| 1583 | { |
| 1584 | case GL_UNSIGNED_BYTE: |
| 1585 | break; |
| 1586 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 1587 | if (internalFormat != GL_RGB10_A2) |
| 1588 | { |
| 1589 | return false; |
| 1590 | } |
| 1591 | break; |
| 1592 | default: |
| 1593 | return false; |
| 1594 | } |
| 1595 | break; |
| 1596 | case GL_RGBA_INTEGER: |
| 1597 | switch (type) |
| 1598 | { |
| 1599 | case GL_INT: |
Geoff Lang | d384a94 | 2013-06-05 15:00:10 -0400 | [diff] [blame] | 1600 | if (!gl::IsSignedIntegerFormat(internalFormat, 3)) |
| 1601 | { |
| 1602 | return false; |
| 1603 | } |
| 1604 | break; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 1605 | case GL_UNSIGNED_INT: |
Geoff Lang | d384a94 | 2013-06-05 15:00:10 -0400 | [diff] [blame] | 1606 | if (!gl::IsUnsignedIntegerFormat(internalFormat, 3)) |
| 1607 | { |
| 1608 | return false; |
| 1609 | } |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 1610 | break; |
| 1611 | default: |
| 1612 | return false; |
| 1613 | } |
| 1614 | break; |
| 1615 | case GL_BGRA_EXT: |
| 1616 | switch (type) |
| 1617 | { |
| 1618 | case GL_UNSIGNED_BYTE: |
| 1619 | case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: |
| 1620 | case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: |
| 1621 | break; |
| 1622 | default: |
| 1623 | return false; |
| 1624 | } |
| 1625 | break; |
| 1626 | default: |
| 1627 | return false; |
| 1628 | } |
| 1629 | return true; |
| 1630 | } |
| 1631 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 1632 | bool validateInvalidateFramebufferParameters(gl::Context *context, GLenum target, GLsizei numAttachments, |
| 1633 | const GLenum* attachments) |
| 1634 | { |
| 1635 | bool defaultFramebuffer = false; |
| 1636 | |
| 1637 | switch (target) |
| 1638 | { |
| 1639 | case GL_DRAW_FRAMEBUFFER: |
| 1640 | case GL_FRAMEBUFFER: |
| 1641 | defaultFramebuffer = context->getDrawFramebufferHandle() == 0; |
| 1642 | break; |
| 1643 | case GL_READ_FRAMEBUFFER: |
| 1644 | defaultFramebuffer = context->getReadFramebufferHandle() == 0; |
| 1645 | break; |
| 1646 | default: |
| 1647 | return gl::error(GL_INVALID_ENUM, false); |
| 1648 | } |
| 1649 | |
| 1650 | for (int i = 0; i < numAttachments; ++i) |
| 1651 | { |
| 1652 | if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15) |
| 1653 | { |
| 1654 | if (defaultFramebuffer) |
| 1655 | { |
| 1656 | return gl::error(GL_INVALID_ENUM, false); |
| 1657 | } |
| 1658 | |
| 1659 | if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getMaximumRenderTargets()) |
| 1660 | { |
| 1661 | return gl::error(GL_INVALID_OPERATION, false); |
| 1662 | } |
| 1663 | } |
| 1664 | else |
| 1665 | { |
| 1666 | switch (attachments[i]) |
| 1667 | { |
| 1668 | case GL_DEPTH_ATTACHMENT: |
| 1669 | case GL_STENCIL_ATTACHMENT: |
| 1670 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 1671 | if (defaultFramebuffer) |
| 1672 | { |
| 1673 | return gl::error(GL_INVALID_ENUM, false); |
| 1674 | } |
| 1675 | break; |
| 1676 | case GL_COLOR: |
| 1677 | case GL_DEPTH: |
| 1678 | case GL_STENCIL: |
| 1679 | if (!defaultFramebuffer) |
| 1680 | { |
| 1681 | return gl::error(GL_INVALID_ENUM, false); |
| 1682 | } |
| 1683 | break; |
| 1684 | default: |
| 1685 | return gl::error(GL_INVALID_ENUM, false); |
| 1686 | } |
| 1687 | } |
| 1688 | } |
| 1689 | |
| 1690 | return true; |
| 1691 | } |
| 1692 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 1693 | bool validateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, |
| 1694 | GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, |
| 1695 | GLenum filter, bool fromAngleExtension) |
| 1696 | { |
| 1697 | switch (filter) |
| 1698 | { |
| 1699 | case GL_NEAREST: |
| 1700 | break; |
| 1701 | case GL_LINEAR: |
| 1702 | if (fromAngleExtension) |
| 1703 | { |
| 1704 | return gl::error(GL_INVALID_ENUM, false); |
| 1705 | } |
| 1706 | break; |
| 1707 | default: |
| 1708 | return gl::error(GL_INVALID_ENUM, false); |
| 1709 | } |
| 1710 | |
| 1711 | if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0) |
| 1712 | { |
| 1713 | return gl::error(GL_INVALID_VALUE, false); |
| 1714 | } |
| 1715 | |
| 1716 | if (mask == 0) |
| 1717 | { |
| 1718 | // ES3.0 spec, section 4.3.2 specifies that a mask of zero is valid and no |
| 1719 | // buffers are copied. |
| 1720 | return false; |
| 1721 | } |
| 1722 | |
| 1723 | if (fromAngleExtension && (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0)) |
| 1724 | { |
| 1725 | ERR("Scaling and flipping in BlitFramebufferANGLE not supported by this implementation."); |
| 1726 | return gl::error(GL_INVALID_OPERATION, false); |
| 1727 | } |
| 1728 | |
| 1729 | // ES3.0 spec, section 4.3.2 states that linear filtering is only available for the |
| 1730 | // color buffer, leaving only nearest being unfiltered from above |
| 1731 | if ((mask & ~GL_COLOR_BUFFER_BIT) != 0 && filter != GL_NEAREST) |
| 1732 | { |
| 1733 | return gl::error(GL_INVALID_OPERATION, false); |
| 1734 | } |
| 1735 | |
| 1736 | if (context->getReadFramebufferHandle() == context->getDrawFramebufferHandle()) |
| 1737 | { |
| 1738 | if (fromAngleExtension) |
| 1739 | { |
| 1740 | ERR("Blits with the same source and destination framebuffer are not supported by this " |
| 1741 | "implementation."); |
| 1742 | } |
| 1743 | return gl::error(GL_INVALID_OPERATION, false); |
| 1744 | } |
| 1745 | |
| 1746 | gl::Framebuffer *readFramebuffer = context->getReadFramebuffer(); |
| 1747 | gl::Framebuffer *drawFramebuffer = context->getDrawFramebuffer(); |
| 1748 | if (!readFramebuffer || readFramebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE || |
| 1749 | !drawFramebuffer || drawFramebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) |
| 1750 | { |
| 1751 | return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); |
| 1752 | } |
| 1753 | |
| 1754 | if (drawFramebuffer->getSamples() != 0) |
| 1755 | { |
| 1756 | return gl::error(GL_INVALID_OPERATION, false); |
| 1757 | } |
| 1758 | |
| 1759 | gl::Rectangle sourceClippedRect, destClippedRect; |
| 1760 | bool partialCopy; |
| 1761 | if (!context->clipBlitFramebufferCoordinates(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 1762 | &sourceClippedRect, &destClippedRect, &partialCopy)) |
| 1763 | { |
| 1764 | return gl::error(GL_INVALID_OPERATION, false); |
| 1765 | } |
| 1766 | |
| 1767 | bool sameBounds = srcX0 == dstX0 && srcY0 == dstY0 && srcX1 == dstX1 && srcY1 == dstY1; |
| 1768 | |
| 1769 | GLuint clientVersion = context->getClientVersion(); |
| 1770 | |
| 1771 | if (mask & GL_COLOR_BUFFER_BIT) |
| 1772 | { |
| 1773 | gl::Renderbuffer *readColorBuffer = readFramebuffer->getReadColorbuffer(); |
| 1774 | gl::Renderbuffer *drawColorBuffer = drawFramebuffer->getFirstColorbuffer(); |
| 1775 | |
| 1776 | if (readColorBuffer && drawColorBuffer) |
| 1777 | { |
| 1778 | GLint readInternalFormat = readColorBuffer->getActualFormat(); |
| 1779 | GLint drawInternalFormat = drawColorBuffer->getActualFormat(); |
| 1780 | |
| 1781 | for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; i++) |
| 1782 | { |
| 1783 | if (drawFramebuffer->isEnabledColorAttachment(i)) |
| 1784 | { |
| 1785 | GLint drawbufferAttachmentFormat = drawFramebuffer->getColorbuffer(i)->getActualFormat(); |
| 1786 | |
| 1787 | if (gl::IsNormalizedFixedPointFormat(readInternalFormat, clientVersion) && |
| 1788 | !gl::IsNormalizedFixedPointFormat(drawbufferAttachmentFormat, clientVersion)) |
| 1789 | { |
| 1790 | return gl::error(GL_INVALID_OPERATION, false); |
| 1791 | } |
| 1792 | |
| 1793 | if (gl::IsUnsignedIntegerFormat(readInternalFormat, clientVersion) && |
| 1794 | !gl::IsUnsignedIntegerFormat(drawbufferAttachmentFormat, clientVersion)) |
| 1795 | { |
| 1796 | return gl::error(GL_INVALID_OPERATION, false); |
| 1797 | } |
| 1798 | |
| 1799 | if (gl::IsSignedIntegerFormat(readInternalFormat, clientVersion) && |
| 1800 | !gl::IsSignedIntegerFormat(drawbufferAttachmentFormat, clientVersion)) |
| 1801 | { |
| 1802 | return gl::error(GL_INVALID_OPERATION, false); |
| 1803 | } |
| 1804 | |
| 1805 | if (readColorBuffer->getSamples() > 0 && (readInternalFormat != drawbufferAttachmentFormat || !sameBounds)) |
| 1806 | { |
| 1807 | return gl::error(GL_INVALID_OPERATION, false); |
| 1808 | } |
| 1809 | } |
| 1810 | } |
| 1811 | |
| 1812 | if (gl::IsIntegerFormat(readInternalFormat, clientVersion) && filter == GL_LINEAR) |
| 1813 | { |
| 1814 | return gl::error(GL_INVALID_OPERATION, false); |
| 1815 | } |
| 1816 | |
| 1817 | if (fromAngleExtension) |
| 1818 | { |
| 1819 | const GLenum readColorbufferType = readFramebuffer->getReadColorbufferType(); |
| 1820 | if (readColorbufferType != GL_TEXTURE_2D && readColorbufferType != GL_RENDERBUFFER) |
| 1821 | { |
| 1822 | return gl::error(GL_INVALID_OPERATION, false); |
| 1823 | } |
| 1824 | |
| 1825 | for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) |
| 1826 | { |
| 1827 | if (drawFramebuffer->isEnabledColorAttachment(colorAttachment)) |
| 1828 | { |
| 1829 | if (drawFramebuffer->getColorbufferType(colorAttachment) != GL_TEXTURE_2D && |
| 1830 | drawFramebuffer->getColorbufferType(colorAttachment) != GL_RENDERBUFFER) |
| 1831 | { |
| 1832 | return gl::error(GL_INVALID_OPERATION, false); |
| 1833 | } |
| 1834 | |
| 1835 | if (drawFramebuffer->getColorbuffer(colorAttachment)->getActualFormat() != readColorBuffer->getActualFormat()) |
| 1836 | { |
| 1837 | return gl::error(GL_INVALID_OPERATION, false); |
| 1838 | } |
| 1839 | } |
| 1840 | } |
| 1841 | |
| 1842 | if (partialCopy && readFramebuffer->getSamples() != 0) |
| 1843 | { |
| 1844 | return gl::error(GL_INVALID_OPERATION, false); |
| 1845 | } |
| 1846 | } |
| 1847 | } |
| 1848 | } |
| 1849 | |
| 1850 | if (mask & GL_DEPTH_BUFFER_BIT) |
| 1851 | { |
| 1852 | gl::Renderbuffer *readDepthBuffer = readFramebuffer->getDepthbuffer(); |
| 1853 | gl::Renderbuffer *drawDepthBuffer = drawFramebuffer->getDepthbuffer(); |
| 1854 | |
| 1855 | if (readDepthBuffer && drawDepthBuffer) |
| 1856 | { |
| 1857 | if (readDepthBuffer->getActualFormat() != drawDepthBuffer->getActualFormat()) |
| 1858 | { |
| 1859 | return gl::error(GL_INVALID_OPERATION, false); |
| 1860 | } |
| 1861 | |
| 1862 | if (readDepthBuffer->getSamples() > 0 && !sameBounds) |
| 1863 | { |
| 1864 | return gl::error(GL_INVALID_OPERATION, false); |
| 1865 | } |
| 1866 | |
| 1867 | if (fromAngleExtension) |
| 1868 | { |
| 1869 | if (partialCopy) |
| 1870 | { |
| 1871 | ERR("Only whole-buffer depth and stencil blits are supported by this implementation."); |
| 1872 | return gl::error(GL_INVALID_OPERATION, false); // only whole-buffer copies are permitted |
| 1873 | } |
| 1874 | |
| 1875 | if (readDepthBuffer->getSamples() != 0 || drawDepthBuffer->getSamples() != 0) |
| 1876 | { |
| 1877 | return gl::error(GL_INVALID_OPERATION, false); |
| 1878 | } |
| 1879 | } |
| 1880 | } |
| 1881 | } |
| 1882 | |
| 1883 | if (mask & GL_STENCIL_BUFFER_BIT) |
| 1884 | { |
| 1885 | gl::Renderbuffer *readStencilBuffer = readFramebuffer->getStencilbuffer(); |
| 1886 | gl::Renderbuffer *drawStencilBuffer = drawFramebuffer->getStencilbuffer(); |
| 1887 | |
| 1888 | if (fromAngleExtension && partialCopy) |
| 1889 | { |
| 1890 | ERR("Only whole-buffer depth and stencil blits are supported by this implementation."); |
| 1891 | return gl::error(GL_INVALID_OPERATION, false); // only whole-buffer copies are permitted |
| 1892 | } |
| 1893 | |
| 1894 | if (readStencilBuffer && drawStencilBuffer) |
| 1895 | { |
| 1896 | if (readStencilBuffer->getActualFormat() != drawStencilBuffer->getActualFormat()) |
| 1897 | { |
| 1898 | return gl::error(GL_INVALID_OPERATION, false); |
| 1899 | } |
| 1900 | |
| 1901 | if (readStencilBuffer->getSamples() > 0 && !sameBounds) |
| 1902 | { |
| 1903 | return gl::error(GL_INVALID_OPERATION, false); |
| 1904 | } |
| 1905 | |
| 1906 | if (fromAngleExtension) |
| 1907 | { |
| 1908 | if (partialCopy) |
| 1909 | { |
| 1910 | ERR("Only whole-buffer depth and stencil blits are supported by this implementation."); |
| 1911 | return gl::error(GL_INVALID_OPERATION, false); // only whole-buffer copies are permitted |
| 1912 | } |
| 1913 | |
| 1914 | if (readStencilBuffer->getSamples() != 0 || drawStencilBuffer->getSamples() != 0) |
| 1915 | { |
| 1916 | return gl::error(GL_INVALID_OPERATION, false); |
| 1917 | } |
| 1918 | } |
| 1919 | } |
| 1920 | } |
| 1921 | |
| 1922 | return true; |
| 1923 | } |
| 1924 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1925 | extern "C" |
| 1926 | { |
| 1927 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 1928 | // OpenGL ES 2.0 functions |
| 1929 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1930 | void __stdcall glActiveTexture(GLenum texture) |
| 1931 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1932 | EVENT("(GLenum texture = 0x%X)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1933 | |
| 1934 | try |
| 1935 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1936 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1937 | |
| 1938 | if (context) |
| 1939 | { |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 1940 | if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1) |
| 1941 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1942 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 1943 | } |
| 1944 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 1945 | context->setActiveSampler(texture - GL_TEXTURE0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1946 | } |
| 1947 | } |
| 1948 | catch(std::bad_alloc&) |
| 1949 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1950 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1951 | } |
| 1952 | } |
| 1953 | |
| 1954 | void __stdcall glAttachShader(GLuint program, GLuint shader) |
| 1955 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1956 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1957 | |
| 1958 | try |
| 1959 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1960 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1961 | |
| 1962 | if (context) |
| 1963 | { |
| 1964 | gl::Program *programObject = context->getProgram(program); |
| 1965 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 1966 | |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1967 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1968 | { |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1969 | if (context->getShader(program)) |
| 1970 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1971 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1972 | } |
| 1973 | else |
| 1974 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1975 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1976 | } |
| 1977 | } |
| 1978 | |
| 1979 | if (!shaderObject) |
| 1980 | { |
| 1981 | if (context->getProgram(shader)) |
| 1982 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1983 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1984 | } |
| 1985 | else |
| 1986 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1987 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1988 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1989 | } |
| 1990 | |
| 1991 | if (!programObject->attachShader(shaderObject)) |
| 1992 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1993 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1994 | } |
| 1995 | } |
| 1996 | } |
| 1997 | catch(std::bad_alloc&) |
| 1998 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1999 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2000 | } |
| 2001 | } |
| 2002 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2003 | void __stdcall glBeginQueryEXT(GLenum target, GLuint id) |
| 2004 | { |
| 2005 | EVENT("(GLenum target = 0x%X, GLuint %d)", target, id); |
| 2006 | |
| 2007 | try |
| 2008 | { |
| 2009 | switch (target) |
| 2010 | { |
| 2011 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 2012 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 2013 | break; |
| 2014 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2015 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2016 | } |
| 2017 | |
| 2018 | if (id == 0) |
| 2019 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2020 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2021 | } |
| 2022 | |
| 2023 | gl::Context *context = gl::getNonLostContext(); |
| 2024 | |
| 2025 | if (context) |
| 2026 | { |
| 2027 | context->beginQuery(target, id); |
| 2028 | } |
| 2029 | } |
| 2030 | catch(std::bad_alloc&) |
| 2031 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2032 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2033 | } |
| 2034 | } |
| 2035 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2036 | void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2037 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2038 | 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] | 2039 | |
| 2040 | try |
| 2041 | { |
| 2042 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 2043 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2044 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2045 | } |
| 2046 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2047 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2048 | |
| 2049 | if (context) |
| 2050 | { |
| 2051 | gl::Program *programObject = context->getProgram(program); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2052 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2053 | if (!programObject) |
| 2054 | { |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2055 | if (context->getShader(program)) |
| 2056 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2057 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2058 | } |
| 2059 | else |
| 2060 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2061 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2062 | } |
| 2063 | } |
| 2064 | |
| 2065 | if (strncmp(name, "gl_", 3) == 0) |
| 2066 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2067 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2068 | } |
| 2069 | |
| 2070 | programObject->bindAttributeLocation(index, name); |
| 2071 | } |
| 2072 | } |
| 2073 | catch(std::bad_alloc&) |
| 2074 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2075 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2076 | } |
| 2077 | } |
| 2078 | |
| 2079 | void __stdcall glBindBuffer(GLenum target, GLuint buffer) |
| 2080 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2081 | EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2082 | |
| 2083 | try |
| 2084 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2085 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2086 | |
| 2087 | if (context) |
| 2088 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2089 | // Check ES3 specific targets |
| 2090 | switch (target) |
| 2091 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2092 | case GL_COPY_READ_BUFFER: |
| 2093 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2094 | case GL_PIXEL_PACK_BUFFER: |
| 2095 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2096 | case GL_UNIFORM_BUFFER: |
| 2097 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2098 | if (context->getClientVersion() < 3) |
| 2099 | { |
| 2100 | return gl::error(GL_INVALID_ENUM); |
| 2101 | } |
| 2102 | } |
| 2103 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2104 | switch (target) |
| 2105 | { |
| 2106 | case GL_ARRAY_BUFFER: |
| 2107 | context->bindArrayBuffer(buffer); |
| 2108 | return; |
| 2109 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2110 | context->bindElementArrayBuffer(buffer); |
| 2111 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2112 | case GL_COPY_READ_BUFFER: |
| 2113 | context->bindCopyReadBuffer(buffer); |
| 2114 | return; |
| 2115 | case GL_COPY_WRITE_BUFFER: |
| 2116 | context->bindCopyWriteBuffer(buffer); |
| 2117 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2118 | case GL_PIXEL_PACK_BUFFER: |
| 2119 | context->bindPixelPackBuffer(buffer); |
| 2120 | return; |
| 2121 | case GL_PIXEL_UNPACK_BUFFER: |
| 2122 | context->bindPixelUnpackBuffer(buffer); |
| 2123 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2124 | case GL_UNIFORM_BUFFER: |
| 2125 | context->bindGenericUniformBuffer(buffer); |
| 2126 | return; |
| 2127 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 7a1ebad | 2013-05-30 00:05:20 +0000 | [diff] [blame] | 2128 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2129 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2130 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2131 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2132 | } |
| 2133 | } |
| 2134 | } |
| 2135 | catch(std::bad_alloc&) |
| 2136 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2137 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2138 | } |
| 2139 | } |
| 2140 | |
| 2141 | void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer) |
| 2142 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2143 | EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2144 | |
| 2145 | try |
| 2146 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2147 | 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] | 2148 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2149 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2150 | } |
| 2151 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2152 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2153 | |
| 2154 | if (context) |
| 2155 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2156 | if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 2157 | { |
| 2158 | context->bindReadFramebuffer(framebuffer); |
| 2159 | } |
| 2160 | |
| 2161 | if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 2162 | { |
| 2163 | context->bindDrawFramebuffer(framebuffer); |
| 2164 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2165 | } |
| 2166 | } |
| 2167 | catch(std::bad_alloc&) |
| 2168 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2169 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2170 | } |
| 2171 | } |
| 2172 | |
| 2173 | void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 2174 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2175 | EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2176 | |
| 2177 | try |
| 2178 | { |
| 2179 | if (target != GL_RENDERBUFFER) |
| 2180 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2181 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2182 | } |
| 2183 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2184 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2185 | |
| 2186 | if (context) |
| 2187 | { |
| 2188 | context->bindRenderbuffer(renderbuffer); |
| 2189 | } |
| 2190 | } |
| 2191 | catch(std::bad_alloc&) |
| 2192 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2193 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2194 | } |
| 2195 | } |
| 2196 | |
| 2197 | void __stdcall glBindTexture(GLenum target, GLuint texture) |
| 2198 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2199 | EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2200 | |
| 2201 | try |
| 2202 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2203 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2204 | |
| 2205 | if (context) |
| 2206 | { |
| 2207 | gl::Texture *textureObject = context->getTexture(texture); |
| 2208 | |
| 2209 | if (textureObject && textureObject->getTarget() != target && texture != 0) |
| 2210 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2211 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2212 | } |
| 2213 | |
| 2214 | switch (target) |
| 2215 | { |
| 2216 | case GL_TEXTURE_2D: |
| 2217 | context->bindTexture2D(texture); |
| 2218 | return; |
| 2219 | case GL_TEXTURE_CUBE_MAP: |
| 2220 | context->bindTextureCubeMap(texture); |
| 2221 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 2222 | case GL_TEXTURE_3D: |
| 2223 | if (context->getClientVersion() < 3) |
| 2224 | { |
| 2225 | return gl::error(GL_INVALID_ENUM); |
| 2226 | } |
| 2227 | context->bindTexture3D(texture); |
| 2228 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 2229 | case GL_TEXTURE_2D_ARRAY: |
| 2230 | if (context->getClientVersion() < 3) |
| 2231 | { |
| 2232 | return gl::error(GL_INVALID_ENUM); |
| 2233 | } |
| 2234 | context->bindTexture2DArray(texture); |
| 2235 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2236 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2237 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2238 | } |
| 2239 | } |
| 2240 | } |
| 2241 | catch(std::bad_alloc&) |
| 2242 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2243 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2244 | } |
| 2245 | } |
| 2246 | |
| 2247 | void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2248 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2249 | 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] | 2250 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2251 | |
| 2252 | try |
| 2253 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2254 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2255 | |
| 2256 | if (context) |
| 2257 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2258 | 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] | 2259 | } |
| 2260 | } |
| 2261 | catch(std::bad_alloc&) |
| 2262 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2263 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2264 | } |
| 2265 | } |
| 2266 | |
| 2267 | void __stdcall glBlendEquation(GLenum mode) |
| 2268 | { |
| 2269 | glBlendEquationSeparate(mode, mode); |
| 2270 | } |
| 2271 | |
| 2272 | void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 2273 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2274 | EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2275 | |
| 2276 | try |
| 2277 | { |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2278 | gl::Context *context = gl::getNonLostContext(); |
| 2279 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2280 | switch (modeRGB) |
| 2281 | { |
| 2282 | case GL_FUNC_ADD: |
| 2283 | case GL_FUNC_SUBTRACT: |
| 2284 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2285 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2286 | |
| 2287 | case GL_MIN: |
| 2288 | case GL_MAX: |
| 2289 | if (context && context->getClientVersion() < 3) |
| 2290 | { |
| 2291 | return gl::error(GL_INVALID_ENUM); |
| 2292 | } |
| 2293 | break; |
| 2294 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2295 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2296 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2297 | } |
| 2298 | |
| 2299 | switch (modeAlpha) |
| 2300 | { |
| 2301 | case GL_FUNC_ADD: |
| 2302 | case GL_FUNC_SUBTRACT: |
| 2303 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2304 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2305 | |
| 2306 | case GL_MIN: |
| 2307 | case GL_MAX: |
| 2308 | if (context && context->getClientVersion() < 3) |
| 2309 | { |
| 2310 | return gl::error(GL_INVALID_ENUM); |
| 2311 | } |
| 2312 | break; |
| 2313 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2314 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2315 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2316 | } |
| 2317 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2318 | if (context) |
| 2319 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2320 | context->setBlendEquation(modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2321 | } |
| 2322 | } |
| 2323 | catch(std::bad_alloc&) |
| 2324 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2325 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2326 | } |
| 2327 | } |
| 2328 | |
| 2329 | void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor) |
| 2330 | { |
| 2331 | glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor); |
| 2332 | } |
| 2333 | |
| 2334 | void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 2335 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2336 | 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] | 2337 | srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2338 | |
| 2339 | try |
| 2340 | { |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2341 | gl::Context *context = gl::getNonLostContext(); |
| 2342 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2343 | switch (srcRGB) |
| 2344 | { |
| 2345 | case GL_ZERO: |
| 2346 | case GL_ONE: |
| 2347 | case GL_SRC_COLOR: |
| 2348 | case GL_ONE_MINUS_SRC_COLOR: |
| 2349 | case GL_DST_COLOR: |
| 2350 | case GL_ONE_MINUS_DST_COLOR: |
| 2351 | case GL_SRC_ALPHA: |
| 2352 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2353 | case GL_DST_ALPHA: |
| 2354 | case GL_ONE_MINUS_DST_ALPHA: |
| 2355 | case GL_CONSTANT_COLOR: |
| 2356 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2357 | case GL_CONSTANT_ALPHA: |
| 2358 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2359 | case GL_SRC_ALPHA_SATURATE: |
| 2360 | break; |
| 2361 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2362 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2363 | } |
| 2364 | |
| 2365 | switch (dstRGB) |
| 2366 | { |
| 2367 | case GL_ZERO: |
| 2368 | case GL_ONE: |
| 2369 | case GL_SRC_COLOR: |
| 2370 | case GL_ONE_MINUS_SRC_COLOR: |
| 2371 | case GL_DST_COLOR: |
| 2372 | case GL_ONE_MINUS_DST_COLOR: |
| 2373 | case GL_SRC_ALPHA: |
| 2374 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2375 | case GL_DST_ALPHA: |
| 2376 | case GL_ONE_MINUS_DST_ALPHA: |
| 2377 | case GL_CONSTANT_COLOR: |
| 2378 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2379 | case GL_CONSTANT_ALPHA: |
| 2380 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2381 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2382 | |
| 2383 | case GL_SRC_ALPHA_SATURATE: |
| 2384 | if (!context || context->getClientVersion() < 3) |
| 2385 | { |
| 2386 | return gl::error(GL_INVALID_ENUM); |
| 2387 | } |
| 2388 | break; |
| 2389 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2390 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2391 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2392 | } |
| 2393 | |
| 2394 | switch (srcAlpha) |
| 2395 | { |
| 2396 | case GL_ZERO: |
| 2397 | case GL_ONE: |
| 2398 | case GL_SRC_COLOR: |
| 2399 | case GL_ONE_MINUS_SRC_COLOR: |
| 2400 | case GL_DST_COLOR: |
| 2401 | case GL_ONE_MINUS_DST_COLOR: |
| 2402 | case GL_SRC_ALPHA: |
| 2403 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2404 | case GL_DST_ALPHA: |
| 2405 | case GL_ONE_MINUS_DST_ALPHA: |
| 2406 | case GL_CONSTANT_COLOR: |
| 2407 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2408 | case GL_CONSTANT_ALPHA: |
| 2409 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2410 | case GL_SRC_ALPHA_SATURATE: |
| 2411 | break; |
| 2412 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2413 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2414 | } |
| 2415 | |
| 2416 | switch (dstAlpha) |
| 2417 | { |
| 2418 | case GL_ZERO: |
| 2419 | case GL_ONE: |
| 2420 | case GL_SRC_COLOR: |
| 2421 | case GL_ONE_MINUS_SRC_COLOR: |
| 2422 | case GL_DST_COLOR: |
| 2423 | case GL_ONE_MINUS_DST_COLOR: |
| 2424 | case GL_SRC_ALPHA: |
| 2425 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2426 | case GL_DST_ALPHA: |
| 2427 | case GL_ONE_MINUS_DST_ALPHA: |
| 2428 | case GL_CONSTANT_COLOR: |
| 2429 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2430 | case GL_CONSTANT_ALPHA: |
| 2431 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2432 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2433 | |
| 2434 | case GL_SRC_ALPHA_SATURATE: |
| 2435 | if (!context || context->getClientVersion() < 3) |
| 2436 | { |
| 2437 | return gl::error(GL_INVALID_ENUM); |
| 2438 | } |
| 2439 | break; |
| 2440 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2441 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2442 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2443 | } |
| 2444 | |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2445 | bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR || |
| 2446 | dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR); |
| 2447 | |
| 2448 | bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA || |
| 2449 | dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA); |
| 2450 | |
| 2451 | if (constantColorUsed && constantAlphaUsed) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2452 | { |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2453 | 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] | 2454 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2455 | } |
| 2456 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2457 | if (context) |
| 2458 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2459 | context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2460 | } |
| 2461 | } |
| 2462 | catch(std::bad_alloc&) |
| 2463 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2464 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2465 | } |
| 2466 | } |
| 2467 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2468 | 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] | 2469 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2470 | 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] | 2471 | target, size, data, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2472 | |
| 2473 | try |
| 2474 | { |
| 2475 | if (size < 0) |
| 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 | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2478 | } |
| 2479 | |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2480 | gl::Context *context = gl::getNonLostContext(); |
| 2481 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2482 | switch (usage) |
| 2483 | { |
| 2484 | case GL_STREAM_DRAW: |
| 2485 | case GL_STATIC_DRAW: |
| 2486 | case GL_DYNAMIC_DRAW: |
| 2487 | break; |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2488 | |
| 2489 | case GL_STREAM_READ: |
| 2490 | case GL_STREAM_COPY: |
| 2491 | case GL_STATIC_READ: |
| 2492 | case GL_STATIC_COPY: |
| 2493 | case GL_DYNAMIC_READ: |
| 2494 | case GL_DYNAMIC_COPY: |
| 2495 | if (context && context->getClientVersion() < 3) |
| 2496 | { |
| 2497 | return gl::error(GL_INVALID_ENUM); |
| 2498 | } |
| 2499 | break; |
| 2500 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2501 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2502 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2503 | } |
| 2504 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2505 | if (context) |
| 2506 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2507 | // Check ES3 specific targets |
| 2508 | switch (target) |
| 2509 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2510 | case GL_COPY_READ_BUFFER: |
| 2511 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2512 | case GL_PIXEL_PACK_BUFFER: |
| 2513 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2514 | case GL_UNIFORM_BUFFER: |
| 2515 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2516 | if (context->getClientVersion() < 3) |
| 2517 | { |
| 2518 | return gl::error(GL_INVALID_ENUM); |
| 2519 | } |
| 2520 | } |
| 2521 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2522 | gl::Buffer *buffer; |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2523 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2524 | switch (target) |
| 2525 | { |
| 2526 | case GL_ARRAY_BUFFER: |
| 2527 | buffer = context->getArrayBuffer(); |
| 2528 | break; |
| 2529 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2530 | buffer = context->getElementArrayBuffer(); |
| 2531 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2532 | case GL_COPY_READ_BUFFER: |
| 2533 | buffer = context->getCopyReadBuffer(); |
| 2534 | break; |
| 2535 | case GL_COPY_WRITE_BUFFER: |
| 2536 | buffer = context->getCopyWriteBuffer(); |
| 2537 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2538 | case GL_PIXEL_PACK_BUFFER: |
| 2539 | buffer = context->getPixelPackBuffer(); |
| 2540 | break; |
| 2541 | case GL_PIXEL_UNPACK_BUFFER: |
| 2542 | buffer = context->getPixelUnpackBuffer(); |
| 2543 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2544 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2545 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2546 | break; |
| 2547 | case GL_UNIFORM_BUFFER: |
| 2548 | buffer = context->getGenericUniformBuffer(); |
| 2549 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2550 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2551 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2552 | } |
| 2553 | |
| 2554 | if (!buffer) |
| 2555 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2556 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2557 | } |
| 2558 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2559 | buffer->bufferData(data, size, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2560 | } |
| 2561 | } |
| 2562 | catch(std::bad_alloc&) |
| 2563 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2564 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2565 | } |
| 2566 | } |
| 2567 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2568 | 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] | 2569 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2570 | 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] | 2571 | target, offset, size, data); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2572 | |
| 2573 | try |
| 2574 | { |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2575 | if (size < 0 || offset < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2576 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2577 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2578 | } |
| 2579 | |
daniel@transgaming.com | d4620a3 | 2010-03-21 04:31:28 +0000 | [diff] [blame] | 2580 | if (data == NULL) |
| 2581 | { |
| 2582 | return; |
| 2583 | } |
| 2584 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2585 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2586 | |
| 2587 | if (context) |
| 2588 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2589 | // Check ES3 specific targets |
| 2590 | switch (target) |
| 2591 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2592 | case GL_COPY_READ_BUFFER: |
| 2593 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2594 | case GL_PIXEL_PACK_BUFFER: |
| 2595 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2596 | case GL_UNIFORM_BUFFER: |
| 2597 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2598 | if (context->getClientVersion() < 3) |
| 2599 | { |
| 2600 | return gl::error(GL_INVALID_ENUM); |
| 2601 | } |
| 2602 | } |
| 2603 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2604 | gl::Buffer *buffer; |
| 2605 | |
| 2606 | switch (target) |
| 2607 | { |
| 2608 | case GL_ARRAY_BUFFER: |
| 2609 | buffer = context->getArrayBuffer(); |
| 2610 | break; |
| 2611 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2612 | buffer = context->getElementArrayBuffer(); |
| 2613 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2614 | case GL_COPY_READ_BUFFER: |
| 2615 | buffer = context->getCopyReadBuffer(); |
| 2616 | break; |
| 2617 | case GL_COPY_WRITE_BUFFER: |
| 2618 | buffer = context->getCopyWriteBuffer(); |
| 2619 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2620 | case GL_PIXEL_PACK_BUFFER: |
| 2621 | buffer = context->getPixelPackBuffer(); |
| 2622 | break; |
| 2623 | case GL_PIXEL_UNPACK_BUFFER: |
| 2624 | buffer = context->getPixelUnpackBuffer(); |
| 2625 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2626 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2627 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2628 | break; |
| 2629 | case GL_UNIFORM_BUFFER: |
| 2630 | buffer = context->getGenericUniformBuffer(); |
| 2631 | break; |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2632 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2633 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2634 | } |
| 2635 | |
| 2636 | if (!buffer) |
| 2637 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2638 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2639 | } |
| 2640 | |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2641 | if ((size_t)size + offset > buffer->size()) |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2642 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2643 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2644 | } |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2645 | |
| 2646 | buffer->bufferSubData(data, size, offset); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2647 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2648 | } |
| 2649 | catch(std::bad_alloc&) |
| 2650 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2651 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2652 | } |
| 2653 | } |
| 2654 | |
| 2655 | GLenum __stdcall glCheckFramebufferStatus(GLenum target) |
| 2656 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2657 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2658 | |
| 2659 | try |
| 2660 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2661 | 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] | 2662 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2663 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2664 | } |
| 2665 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2666 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2667 | |
| 2668 | if (context) |
| 2669 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2670 | gl::Framebuffer *framebuffer = NULL; |
| 2671 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 2672 | { |
| 2673 | framebuffer = context->getReadFramebuffer(); |
| 2674 | } |
| 2675 | else |
| 2676 | { |
| 2677 | framebuffer = context->getDrawFramebuffer(); |
| 2678 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2679 | |
| 2680 | return framebuffer->completeness(); |
| 2681 | } |
| 2682 | } |
| 2683 | catch(std::bad_alloc&) |
| 2684 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2685 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2686 | } |
| 2687 | |
| 2688 | return 0; |
| 2689 | } |
| 2690 | |
| 2691 | void __stdcall glClear(GLbitfield mask) |
| 2692 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2693 | EVENT("(GLbitfield mask = 0x%X)", mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2694 | |
| 2695 | try |
| 2696 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2697 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2698 | |
| 2699 | if (context) |
| 2700 | { |
| 2701 | context->clear(mask); |
| 2702 | } |
| 2703 | } |
| 2704 | catch(std::bad_alloc&) |
| 2705 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2706 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2707 | } |
| 2708 | } |
| 2709 | |
| 2710 | void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2711 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2712 | 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] | 2713 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2714 | |
| 2715 | try |
| 2716 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2717 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2718 | |
| 2719 | if (context) |
| 2720 | { |
| 2721 | context->setClearColor(red, green, blue, alpha); |
| 2722 | } |
| 2723 | } |
| 2724 | catch(std::bad_alloc&) |
| 2725 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2726 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2727 | } |
| 2728 | } |
| 2729 | |
| 2730 | void __stdcall glClearDepthf(GLclampf depth) |
| 2731 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2732 | EVENT("(GLclampf depth = %f)", depth); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2733 | |
| 2734 | try |
| 2735 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2736 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2737 | |
| 2738 | if (context) |
| 2739 | { |
| 2740 | context->setClearDepth(depth); |
| 2741 | } |
| 2742 | } |
| 2743 | catch(std::bad_alloc&) |
| 2744 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2745 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2746 | } |
| 2747 | } |
| 2748 | |
| 2749 | void __stdcall glClearStencil(GLint s) |
| 2750 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2751 | EVENT("(GLint s = %d)", s); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2752 | |
| 2753 | try |
| 2754 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2755 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2756 | |
| 2757 | if (context) |
| 2758 | { |
| 2759 | context->setClearStencil(s); |
| 2760 | } |
| 2761 | } |
| 2762 | catch(std::bad_alloc&) |
| 2763 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2764 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2765 | } |
| 2766 | } |
| 2767 | |
| 2768 | void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 2769 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2770 | 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] | 2771 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2772 | |
| 2773 | try |
| 2774 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2775 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2776 | |
| 2777 | if (context) |
| 2778 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 2779 | 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] | 2780 | } |
| 2781 | } |
| 2782 | catch(std::bad_alloc&) |
| 2783 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2784 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2785 | } |
| 2786 | } |
| 2787 | |
| 2788 | void __stdcall glCompileShader(GLuint shader) |
| 2789 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2790 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2791 | |
| 2792 | try |
| 2793 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2794 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2795 | |
| 2796 | if (context) |
| 2797 | { |
| 2798 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2799 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2800 | if (!shaderObject) |
| 2801 | { |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2802 | if (context->getProgram(shader)) |
| 2803 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2804 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2805 | } |
| 2806 | else |
| 2807 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2808 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2809 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2810 | } |
| 2811 | |
| 2812 | shaderObject->compile(); |
| 2813 | } |
| 2814 | } |
| 2815 | catch(std::bad_alloc&) |
| 2816 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2817 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2818 | } |
| 2819 | } |
| 2820 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2821 | void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, |
| 2822 | GLint border, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2823 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2824 | 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] | 2825 | "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] | 2826 | target, level, internalformat, width, height, border, imageSize, data); |
| 2827 | |
| 2828 | try |
| 2829 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2830 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2831 | |
| 2832 | if (context) |
| 2833 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2834 | if (context->getClientVersion() < 3 && |
| 2835 | !validateES2TexImageParameters(context, target, level, internalformat, true, false, |
| 2836 | 0, 0, width, height, 0, GL_NONE, GL_NONE, data)) |
| 2837 | { |
| 2838 | return; |
| 2839 | } |
| 2840 | |
| 2841 | if (context->getClientVersion() >= 3 && |
| 2842 | !validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 2843 | 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 2844 | { |
| 2845 | return; |
| 2846 | } |
| 2847 | |
| 2848 | 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] | 2849 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2850 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2851 | } |
| 2852 | |
| 2853 | switch (target) |
| 2854 | { |
| 2855 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2856 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2857 | gl::Texture2D *texture = context->getTexture2D(); |
| 2858 | texture->setCompressedImage(level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2859 | } |
| 2860 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2861 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2862 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2863 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2864 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2865 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2866 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2867 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2868 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2869 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 2870 | texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2871 | } |
| 2872 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2873 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2874 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2875 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2876 | } |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2877 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2878 | } |
| 2879 | catch(std::bad_alloc&) |
| 2880 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2881 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2882 | } |
| 2883 | } |
| 2884 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2885 | void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 2886 | GLenum format, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2887 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2888 | 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] | 2889 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2890 | "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2891 | target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 2892 | |
| 2893 | try |
| 2894 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2895 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2896 | |
| 2897 | if (context) |
| 2898 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2899 | if (context->getClientVersion() < 3 && |
| 2900 | !validateES2TexImageParameters(context, target, level, GL_NONE, true, true, |
| 2901 | xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data)) |
| 2902 | { |
| 2903 | return; |
| 2904 | } |
| 2905 | |
| 2906 | if (context->getClientVersion() >= 3 && |
| 2907 | !validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 2908 | xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 2909 | { |
| 2910 | return; |
| 2911 | } |
| 2912 | |
| 2913 | 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] | 2914 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2915 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2916 | } |
| 2917 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2918 | switch (target) |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2919 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2920 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2921 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2922 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 2923 | texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2924 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2925 | break; |
| 2926 | |
| 2927 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2928 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2929 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2930 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2931 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2932 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2933 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2934 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 2935 | texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2936 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2937 | break; |
| 2938 | |
| 2939 | default: |
| 2940 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2941 | } |
| 2942 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2943 | } |
| 2944 | catch(std::bad_alloc&) |
| 2945 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2946 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2947 | } |
| 2948 | } |
| 2949 | |
| 2950 | void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) |
| 2951 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2952 | 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] | 2953 | "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] | 2954 | target, level, internalformat, x, y, width, height, border); |
| 2955 | |
| 2956 | try |
| 2957 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2958 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2959 | |
| 2960 | if (context) |
| 2961 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2962 | if (context->getClientVersion() < 3 && |
| 2963 | !validateES2CopyTexImageParameters(context, target, level, internalformat, false, |
| 2964 | 0, 0, x, y, width, height, border)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 2965 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2966 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 2967 | } |
| 2968 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2969 | if (context->getClientVersion() >= 3 && |
| 2970 | !validateES3CopyTexImageParameters(context, target, level, internalformat, false, |
| 2971 | 0, 0, 0, x, y, width, height, border)) |
| 2972 | { |
| 2973 | return; |
| 2974 | } |
| 2975 | |
| 2976 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 2977 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2978 | switch (target) |
| 2979 | { |
| 2980 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2981 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2982 | gl::Texture2D *texture = context->getTexture2D(); |
| 2983 | texture->copyImage(level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2984 | } |
| 2985 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2986 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2987 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2988 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2989 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2990 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2991 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2992 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2993 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2994 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 2995 | texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2996 | } |
| 2997 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2998 | |
| 2999 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3000 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3001 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3002 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3003 | } |
| 3004 | catch(std::bad_alloc&) |
| 3005 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3006 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3007 | } |
| 3008 | } |
| 3009 | |
| 3010 | void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 3011 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3012 | 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] | 3013 | "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] | 3014 | target, level, xoffset, yoffset, x, y, width, height); |
| 3015 | |
| 3016 | try |
| 3017 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3018 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3019 | |
| 3020 | if (context) |
| 3021 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3022 | if (context->getClientVersion() < 3 && |
| 3023 | !validateES2CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 3024 | xoffset, yoffset, x, y, width, height, 0)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3025 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3026 | return; |
| 3027 | } |
| 3028 | |
| 3029 | if (context->getClientVersion() >= 3 && |
| 3030 | !validateES3CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 3031 | xoffset, yoffset, 0, x, y, width, height, 0)) |
| 3032 | { |
| 3033 | return; |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3034 | } |
| 3035 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3036 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3037 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3038 | switch (target) |
daniel@transgaming.com | bbc5779 | 2010-07-28 19:21:05 +0000 | [diff] [blame] | 3039 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3040 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 3041 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3042 | gl::Texture2D *texture = context->getTexture2D(); |
| 3043 | 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] | 3044 | } |
| 3045 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3046 | |
| 3047 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3048 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3049 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3050 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3051 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3052 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 3053 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3054 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3055 | 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] | 3056 | } |
| 3057 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3058 | |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3059 | default: |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3060 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3061 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3062 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3063 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3064 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3065 | catch(std::bad_alloc&) |
| 3066 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3067 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3068 | } |
| 3069 | } |
| 3070 | |
| 3071 | GLuint __stdcall glCreateProgram(void) |
| 3072 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3073 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3074 | |
| 3075 | try |
| 3076 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3077 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3078 | |
| 3079 | if (context) |
| 3080 | { |
| 3081 | return context->createProgram(); |
| 3082 | } |
| 3083 | } |
| 3084 | catch(std::bad_alloc&) |
| 3085 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3086 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3087 | } |
| 3088 | |
| 3089 | return 0; |
| 3090 | } |
| 3091 | |
| 3092 | GLuint __stdcall glCreateShader(GLenum type) |
| 3093 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3094 | EVENT("(GLenum type = 0x%X)", type); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3095 | |
| 3096 | try |
| 3097 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3098 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3099 | |
| 3100 | if (context) |
| 3101 | { |
| 3102 | switch (type) |
| 3103 | { |
| 3104 | case GL_FRAGMENT_SHADER: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 3105 | case GL_VERTEX_SHADER: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3106 | return context->createShader(type); |
| 3107 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3108 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3109 | } |
| 3110 | } |
| 3111 | } |
| 3112 | catch(std::bad_alloc&) |
| 3113 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3114 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3115 | } |
| 3116 | |
| 3117 | return 0; |
| 3118 | } |
| 3119 | |
| 3120 | void __stdcall glCullFace(GLenum mode) |
| 3121 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3122 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3123 | |
| 3124 | try |
| 3125 | { |
| 3126 | switch (mode) |
| 3127 | { |
| 3128 | case GL_FRONT: |
| 3129 | case GL_BACK: |
| 3130 | case GL_FRONT_AND_BACK: |
| 3131 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3132 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3133 | |
| 3134 | if (context) |
| 3135 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3136 | context->setCullMode(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3137 | } |
| 3138 | } |
| 3139 | break; |
| 3140 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3141 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3142 | } |
| 3143 | } |
| 3144 | catch(std::bad_alloc&) |
| 3145 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3146 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3147 | } |
| 3148 | } |
| 3149 | |
| 3150 | void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers) |
| 3151 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3152 | 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] | 3153 | |
| 3154 | try |
| 3155 | { |
| 3156 | if (n < 0) |
| 3157 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3158 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3159 | } |
| 3160 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3161 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3162 | |
| 3163 | if (context) |
| 3164 | { |
| 3165 | for (int i = 0; i < n; i++) |
| 3166 | { |
| 3167 | context->deleteBuffer(buffers[i]); |
| 3168 | } |
| 3169 | } |
| 3170 | } |
| 3171 | catch(std::bad_alloc&) |
| 3172 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3173 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3174 | } |
| 3175 | } |
| 3176 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3177 | void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences) |
| 3178 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3179 | 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] | 3180 | |
| 3181 | try |
| 3182 | { |
| 3183 | if (n < 0) |
| 3184 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3185 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3186 | } |
| 3187 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3188 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3189 | |
| 3190 | if (context) |
| 3191 | { |
| 3192 | for (int i = 0; i < n; i++) |
| 3193 | { |
| 3194 | context->deleteFence(fences[i]); |
| 3195 | } |
| 3196 | } |
| 3197 | } |
| 3198 | catch(std::bad_alloc&) |
| 3199 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3200 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3201 | } |
| 3202 | } |
| 3203 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3204 | void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) |
| 3205 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3206 | 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] | 3207 | |
| 3208 | try |
| 3209 | { |
| 3210 | if (n < 0) |
| 3211 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3212 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3213 | } |
| 3214 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3215 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3216 | |
| 3217 | if (context) |
| 3218 | { |
| 3219 | for (int i = 0; i < n; i++) |
| 3220 | { |
| 3221 | if (framebuffers[i] != 0) |
| 3222 | { |
| 3223 | context->deleteFramebuffer(framebuffers[i]); |
| 3224 | } |
| 3225 | } |
| 3226 | } |
| 3227 | } |
| 3228 | catch(std::bad_alloc&) |
| 3229 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3230 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3231 | } |
| 3232 | } |
| 3233 | |
| 3234 | void __stdcall glDeleteProgram(GLuint program) |
| 3235 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3236 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3237 | |
| 3238 | try |
| 3239 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3240 | if (program == 0) |
| 3241 | { |
| 3242 | return; |
| 3243 | } |
| 3244 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3245 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3246 | |
| 3247 | if (context) |
| 3248 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3249 | if (!context->getProgram(program)) |
| 3250 | { |
| 3251 | if(context->getShader(program)) |
| 3252 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3253 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3254 | } |
| 3255 | else |
| 3256 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3257 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3258 | } |
| 3259 | } |
| 3260 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3261 | context->deleteProgram(program); |
| 3262 | } |
| 3263 | } |
| 3264 | catch(std::bad_alloc&) |
| 3265 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3266 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3267 | } |
| 3268 | } |
| 3269 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3270 | void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids) |
| 3271 | { |
| 3272 | EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids); |
| 3273 | |
| 3274 | try |
| 3275 | { |
| 3276 | if (n < 0) |
| 3277 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3278 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3279 | } |
| 3280 | |
| 3281 | gl::Context *context = gl::getNonLostContext(); |
| 3282 | |
| 3283 | if (context) |
| 3284 | { |
| 3285 | for (int i = 0; i < n; i++) |
| 3286 | { |
| 3287 | context->deleteQuery(ids[i]); |
| 3288 | } |
| 3289 | } |
| 3290 | } |
| 3291 | catch(std::bad_alloc&) |
| 3292 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3293 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3294 | } |
| 3295 | } |
| 3296 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3297 | void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) |
| 3298 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3299 | 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] | 3300 | |
| 3301 | try |
| 3302 | { |
| 3303 | if (n < 0) |
| 3304 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3305 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3306 | } |
| 3307 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3308 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3309 | |
| 3310 | if (context) |
| 3311 | { |
daniel@transgaming.com | e2b2212 | 2010-03-11 19:22:14 +0000 | [diff] [blame] | 3312 | for (int i = 0; i < n; i++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3313 | { |
| 3314 | context->deleteRenderbuffer(renderbuffers[i]); |
| 3315 | } |
| 3316 | } |
| 3317 | } |
| 3318 | catch(std::bad_alloc&) |
| 3319 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3320 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3321 | } |
| 3322 | } |
| 3323 | |
| 3324 | void __stdcall glDeleteShader(GLuint shader) |
| 3325 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3326 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3327 | |
| 3328 | try |
| 3329 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3330 | if (shader == 0) |
| 3331 | { |
| 3332 | return; |
| 3333 | } |
| 3334 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3335 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3336 | |
| 3337 | if (context) |
| 3338 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3339 | if (!context->getShader(shader)) |
| 3340 | { |
| 3341 | if(context->getProgram(shader)) |
| 3342 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3343 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3344 | } |
| 3345 | else |
| 3346 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3347 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3348 | } |
| 3349 | } |
| 3350 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3351 | context->deleteShader(shader); |
| 3352 | } |
| 3353 | } |
| 3354 | catch(std::bad_alloc&) |
| 3355 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3356 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3357 | } |
| 3358 | } |
| 3359 | |
| 3360 | void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures) |
| 3361 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3362 | 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] | 3363 | |
| 3364 | try |
| 3365 | { |
| 3366 | if (n < 0) |
| 3367 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3368 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3369 | } |
| 3370 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3371 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3372 | |
| 3373 | if (context) |
| 3374 | { |
| 3375 | for (int i = 0; i < n; i++) |
| 3376 | { |
| 3377 | if (textures[i] != 0) |
| 3378 | { |
| 3379 | context->deleteTexture(textures[i]); |
| 3380 | } |
| 3381 | } |
| 3382 | } |
| 3383 | } |
| 3384 | catch(std::bad_alloc&) |
| 3385 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3386 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3387 | } |
| 3388 | } |
| 3389 | |
| 3390 | void __stdcall glDepthFunc(GLenum func) |
| 3391 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3392 | EVENT("(GLenum func = 0x%X)", func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3393 | |
| 3394 | try |
| 3395 | { |
| 3396 | switch (func) |
| 3397 | { |
| 3398 | case GL_NEVER: |
| 3399 | case GL_ALWAYS: |
| 3400 | case GL_LESS: |
| 3401 | case GL_LEQUAL: |
| 3402 | case GL_EQUAL: |
| 3403 | case GL_GREATER: |
| 3404 | case GL_GEQUAL: |
| 3405 | case GL_NOTEQUAL: |
| 3406 | break; |
| 3407 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3408 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3409 | } |
| 3410 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3411 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3412 | |
| 3413 | if (context) |
| 3414 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3415 | context->setDepthFunc(func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3416 | } |
| 3417 | } |
| 3418 | catch(std::bad_alloc&) |
| 3419 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3420 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3421 | } |
| 3422 | } |
| 3423 | |
| 3424 | void __stdcall glDepthMask(GLboolean flag) |
| 3425 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 3426 | EVENT("(GLboolean flag = %u)", flag); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3427 | |
| 3428 | try |
| 3429 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3430 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3431 | |
| 3432 | if (context) |
| 3433 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3434 | context->setDepthMask(flag != GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3435 | } |
| 3436 | } |
| 3437 | catch(std::bad_alloc&) |
| 3438 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3439 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3440 | } |
| 3441 | } |
| 3442 | |
| 3443 | void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar) |
| 3444 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3445 | EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3446 | |
| 3447 | try |
| 3448 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3449 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3450 | |
| 3451 | if (context) |
| 3452 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3453 | context->setDepthRange(zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3454 | } |
| 3455 | } |
| 3456 | catch(std::bad_alloc&) |
| 3457 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3458 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3459 | } |
| 3460 | } |
| 3461 | |
| 3462 | void __stdcall glDetachShader(GLuint program, GLuint shader) |
| 3463 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3464 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3465 | |
| 3466 | try |
| 3467 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3468 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3469 | |
| 3470 | if (context) |
| 3471 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3472 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3473 | gl::Program *programObject = context->getProgram(program); |
| 3474 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3475 | |
| 3476 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3477 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3478 | gl::Shader *shaderByProgramHandle; |
| 3479 | shaderByProgramHandle = context->getShader(program); |
| 3480 | if (!shaderByProgramHandle) |
| 3481 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3482 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3483 | } |
| 3484 | else |
| 3485 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3486 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3487 | } |
| 3488 | } |
| 3489 | |
| 3490 | if (!shaderObject) |
| 3491 | { |
| 3492 | gl::Program *programByShaderHandle = context->getProgram(shader); |
| 3493 | if (!programByShaderHandle) |
| 3494 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3495 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3496 | } |
| 3497 | else |
| 3498 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3499 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3500 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3501 | } |
| 3502 | |
| 3503 | if (!programObject->detachShader(shaderObject)) |
| 3504 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3505 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3506 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3507 | } |
| 3508 | } |
| 3509 | catch(std::bad_alloc&) |
| 3510 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3511 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3512 | } |
| 3513 | } |
| 3514 | |
| 3515 | void __stdcall glDisable(GLenum cap) |
| 3516 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3517 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3518 | |
| 3519 | try |
| 3520 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3521 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3522 | |
| 3523 | if (context) |
| 3524 | { |
| 3525 | switch (cap) |
| 3526 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3527 | case GL_CULL_FACE: context->setCullFace(false); break; |
| 3528 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break; |
| 3529 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break; |
| 3530 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break; |
| 3531 | case GL_SCISSOR_TEST: context->setScissorTest(false); break; |
| 3532 | case GL_STENCIL_TEST: context->setStencilTest(false); break; |
| 3533 | case GL_DEPTH_TEST: context->setDepthTest(false); break; |
| 3534 | case GL_BLEND: context->setBlend(false); break; |
| 3535 | case GL_DITHER: context->setDither(false); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 3536 | |
| 3537 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 3538 | case GL_RASTERIZER_DISCARD: |
| 3539 | if (context->getClientVersion() < 3) |
| 3540 | { |
| 3541 | return gl::error(GL_INVALID_ENUM); |
| 3542 | } |
| 3543 | UNIMPLEMENTED(); |
| 3544 | break; |
| 3545 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3546 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3547 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3548 | } |
| 3549 | } |
| 3550 | } |
| 3551 | catch(std::bad_alloc&) |
| 3552 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3553 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3554 | } |
| 3555 | } |
| 3556 | |
| 3557 | void __stdcall glDisableVertexAttribArray(GLuint index) |
| 3558 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3559 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3560 | |
| 3561 | try |
| 3562 | { |
| 3563 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3564 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3565 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3566 | } |
| 3567 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3568 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3569 | |
| 3570 | if (context) |
| 3571 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3572 | context->setEnableVertexAttribArray(index, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3573 | } |
| 3574 | } |
| 3575 | catch(std::bad_alloc&) |
| 3576 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3577 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3578 | } |
| 3579 | } |
| 3580 | |
| 3581 | void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count) |
| 3582 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3583 | 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] | 3584 | |
| 3585 | try |
| 3586 | { |
| 3587 | if (count < 0 || first < 0) |
| 3588 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3589 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3590 | } |
| 3591 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3592 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3593 | |
| 3594 | if (context) |
| 3595 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3596 | context->drawArrays(mode, first, count, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3597 | } |
| 3598 | } |
| 3599 | catch(std::bad_alloc&) |
| 3600 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3601 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3602 | } |
| 3603 | } |
| 3604 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3605 | void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
| 3606 | { |
| 3607 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount); |
| 3608 | |
| 3609 | try |
| 3610 | { |
| 3611 | if (count < 0 || first < 0 || primcount < 0) |
| 3612 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3613 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3614 | } |
| 3615 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3616 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3617 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3618 | gl::Context *context = gl::getNonLostContext(); |
| 3619 | |
| 3620 | if (context) |
| 3621 | { |
| 3622 | context->drawArrays(mode, first, count, primcount); |
| 3623 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3624 | } |
| 3625 | } |
| 3626 | catch(std::bad_alloc&) |
| 3627 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3628 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3629 | } |
| 3630 | } |
| 3631 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3632 | 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] | 3633 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3634 | 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] | 3635 | mode, count, type, indices); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3636 | |
| 3637 | try |
| 3638 | { |
| 3639 | if (count < 0) |
| 3640 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3641 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3642 | } |
| 3643 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3644 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3645 | |
| 3646 | if (context) |
| 3647 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3648 | switch (type) |
| 3649 | { |
| 3650 | case GL_UNSIGNED_BYTE: |
| 3651 | case GL_UNSIGNED_SHORT: |
| 3652 | break; |
| 3653 | case GL_UNSIGNED_INT: |
| 3654 | if (!context->supports32bitIndices()) |
| 3655 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3656 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3657 | } |
| 3658 | break; |
| 3659 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3660 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3661 | } |
| 3662 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3663 | context->drawElements(mode, count, type, indices, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3664 | } |
| 3665 | } |
| 3666 | catch(std::bad_alloc&) |
| 3667 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3668 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3669 | } |
| 3670 | } |
| 3671 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3672 | void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount) |
| 3673 | { |
| 3674 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)", |
| 3675 | mode, count, type, indices, primcount); |
| 3676 | |
| 3677 | try |
| 3678 | { |
| 3679 | if (count < 0 || primcount < 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 | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3682 | } |
| 3683 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3684 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3685 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3686 | gl::Context *context = gl::getNonLostContext(); |
| 3687 | |
| 3688 | if (context) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3689 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3690 | switch (type) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3691 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3692 | case GL_UNSIGNED_BYTE: |
| 3693 | case GL_UNSIGNED_SHORT: |
| 3694 | break; |
| 3695 | case GL_UNSIGNED_INT: |
| 3696 | if (!context->supports32bitIndices()) |
| 3697 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3698 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3699 | } |
| 3700 | break; |
| 3701 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3702 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3703 | } |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3704 | |
| 3705 | context->drawElements(mode, count, type, indices, primcount); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3706 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3707 | } |
| 3708 | } |
| 3709 | catch(std::bad_alloc&) |
| 3710 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3711 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3712 | } |
| 3713 | } |
| 3714 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3715 | void __stdcall glEnable(GLenum cap) |
| 3716 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3717 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3718 | |
| 3719 | try |
| 3720 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3721 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3722 | |
| 3723 | if (context) |
| 3724 | { |
| 3725 | switch (cap) |
| 3726 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3727 | case GL_CULL_FACE: context->setCullFace(true); break; |
| 3728 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break; |
| 3729 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break; |
| 3730 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break; |
| 3731 | case GL_SCISSOR_TEST: context->setScissorTest(true); break; |
| 3732 | case GL_STENCIL_TEST: context->setStencilTest(true); break; |
| 3733 | case GL_DEPTH_TEST: context->setDepthTest(true); break; |
| 3734 | case GL_BLEND: context->setBlend(true); break; |
| 3735 | case GL_DITHER: context->setDither(true); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3736 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3737 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3738 | } |
| 3739 | } |
| 3740 | } |
| 3741 | catch(std::bad_alloc&) |
| 3742 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3743 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3744 | } |
| 3745 | } |
| 3746 | |
| 3747 | void __stdcall glEnableVertexAttribArray(GLuint index) |
| 3748 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3749 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3750 | |
| 3751 | try |
| 3752 | { |
| 3753 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3754 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3755 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3756 | } |
| 3757 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3758 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3759 | |
| 3760 | if (context) |
| 3761 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3762 | context->setEnableVertexAttribArray(index, true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3763 | } |
| 3764 | } |
| 3765 | catch(std::bad_alloc&) |
| 3766 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3767 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3768 | } |
| 3769 | } |
| 3770 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3771 | void __stdcall glEndQueryEXT(GLenum target) |
| 3772 | { |
| 3773 | EVENT("GLenum target = 0x%X)", target); |
| 3774 | |
| 3775 | try |
| 3776 | { |
| 3777 | switch (target) |
| 3778 | { |
| 3779 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 3780 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 3781 | break; |
| 3782 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3783 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3784 | } |
| 3785 | |
| 3786 | gl::Context *context = gl::getNonLostContext(); |
| 3787 | |
| 3788 | if (context) |
| 3789 | { |
| 3790 | context->endQuery(target); |
| 3791 | } |
| 3792 | } |
| 3793 | catch(std::bad_alloc&) |
| 3794 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3795 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3796 | } |
| 3797 | } |
| 3798 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3799 | void __stdcall glFinishFenceNV(GLuint fence) |
| 3800 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3801 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3802 | |
| 3803 | try |
| 3804 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3805 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3806 | |
| 3807 | if (context) |
| 3808 | { |
| 3809 | gl::Fence* fenceObject = context->getFence(fence); |
| 3810 | |
| 3811 | if (fenceObject == NULL) |
| 3812 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3813 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3814 | } |
| 3815 | |
| 3816 | fenceObject->finishFence(); |
| 3817 | } |
| 3818 | } |
| 3819 | catch(std::bad_alloc&) |
| 3820 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3821 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3822 | } |
| 3823 | } |
| 3824 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3825 | void __stdcall glFinish(void) |
| 3826 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3827 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3828 | |
| 3829 | try |
| 3830 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3831 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3832 | |
| 3833 | if (context) |
| 3834 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 3835 | context->sync(true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3836 | } |
| 3837 | } |
| 3838 | catch(std::bad_alloc&) |
| 3839 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3840 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3841 | } |
| 3842 | } |
| 3843 | |
| 3844 | void __stdcall glFlush(void) |
| 3845 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3846 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3847 | |
| 3848 | try |
| 3849 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3850 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3851 | |
| 3852 | if (context) |
| 3853 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 3854 | context->sync(false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3855 | } |
| 3856 | } |
| 3857 | catch(std::bad_alloc&) |
| 3858 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3859 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3860 | } |
| 3861 | } |
| 3862 | |
| 3863 | void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) |
| 3864 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3865 | 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] | 3866 | "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3867 | |
| 3868 | try |
| 3869 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3870 | 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] | 3871 | || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3872 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3873 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3874 | } |
| 3875 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3876 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3877 | |
| 3878 | if (context) |
| 3879 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3880 | gl::Framebuffer *framebuffer = NULL; |
| 3881 | GLuint framebufferHandle = 0; |
| 3882 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 3883 | { |
| 3884 | framebuffer = context->getReadFramebuffer(); |
| 3885 | framebufferHandle = context->getReadFramebufferHandle(); |
| 3886 | } |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 3887 | else |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3888 | { |
| 3889 | framebuffer = context->getDrawFramebuffer(); |
| 3890 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 3891 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3892 | |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 3893 | if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3894 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3895 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3896 | } |
| 3897 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3898 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3899 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3900 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 3901 | |
| 3902 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 3903 | { |
| 3904 | return gl::error(GL_INVALID_VALUE); |
| 3905 | } |
| 3906 | |
| 3907 | framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer); |
| 3908 | } |
| 3909 | else |
| 3910 | { |
| 3911 | switch (attachment) |
| 3912 | { |
| 3913 | case GL_DEPTH_ATTACHMENT: |
| 3914 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer); |
| 3915 | break; |
| 3916 | case GL_STENCIL_ATTACHMENT: |
| 3917 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer); |
| 3918 | break; |
| 3919 | default: |
| 3920 | return gl::error(GL_INVALID_ENUM); |
| 3921 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3922 | } |
| 3923 | } |
| 3924 | } |
| 3925 | catch(std::bad_alloc&) |
| 3926 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3927 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3928 | } |
| 3929 | } |
| 3930 | |
| 3931 | void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) |
| 3932 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3933 | 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] | 3934 | "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3935 | |
| 3936 | try |
| 3937 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3938 | 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] | 3939 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3940 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3941 | } |
| 3942 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3943 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3944 | |
| 3945 | if (context) |
| 3946 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3947 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 3948 | { |
| 3949 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 3950 | |
| 3951 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 3952 | { |
| 3953 | return gl::error(GL_INVALID_VALUE); |
| 3954 | } |
| 3955 | } |
| 3956 | else |
| 3957 | { |
| 3958 | switch (attachment) |
| 3959 | { |
| 3960 | case GL_DEPTH_ATTACHMENT: |
| 3961 | case GL_STENCIL_ATTACHMENT: |
| 3962 | break; |
| 3963 | default: |
| 3964 | return gl::error(GL_INVALID_ENUM); |
| 3965 | } |
| 3966 | } |
| 3967 | |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3968 | if (texture == 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3969 | { |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3970 | textarget = GL_NONE; |
| 3971 | } |
| 3972 | else |
| 3973 | { |
| 3974 | gl::Texture *tex = context->getTexture(texture); |
| 3975 | |
| 3976 | if (tex == NULL) |
| 3977 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3978 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3979 | } |
| 3980 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3981 | switch (textarget) |
| 3982 | { |
| 3983 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3984 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3985 | if (tex->getTarget() != GL_TEXTURE_2D) |
| 3986 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3987 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3988 | } |
| 3989 | gl::Texture2D *tex2d = static_cast<gl::Texture2D *>(tex); |
daniel@transgaming.com | 92f4992 | 2012-05-09 15:49:19 +0000 | [diff] [blame] | 3990 | if (tex2d->isCompressed(0)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3991 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3992 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3993 | } |
| 3994 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3995 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3996 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3997 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3998 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3999 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4000 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4001 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4002 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4003 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4004 | if (tex->getTarget() != GL_TEXTURE_CUBE_MAP) |
| 4005 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4006 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4007 | } |
| 4008 | gl::TextureCubeMap *texcube = static_cast<gl::TextureCubeMap *>(tex); |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 4009 | if (texcube->isCompressed(textarget, level)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4010 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4011 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4012 | } |
| 4013 | break; |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4014 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4015 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4016 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4017 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4018 | } |
| 4019 | |
| 4020 | if (level != 0) |
| 4021 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4022 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4023 | } |
| 4024 | } |
| 4025 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4026 | gl::Framebuffer *framebuffer = NULL; |
| 4027 | GLuint framebufferHandle = 0; |
| 4028 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4029 | { |
| 4030 | framebuffer = context->getReadFramebuffer(); |
| 4031 | framebufferHandle = context->getReadFramebufferHandle(); |
| 4032 | } |
| 4033 | else |
| 4034 | { |
| 4035 | framebuffer = context->getDrawFramebuffer(); |
| 4036 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 4037 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4038 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4039 | if (framebufferHandle == 0 || !framebuffer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4040 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4041 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4042 | } |
| 4043 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4044 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4045 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4046 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4047 | |
| 4048 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4049 | { |
| 4050 | return gl::error(GL_INVALID_VALUE); |
| 4051 | } |
| 4052 | |
| 4053 | framebuffer->setColorbuffer(colorAttachment, textarget, texture); |
| 4054 | } |
| 4055 | else |
| 4056 | { |
| 4057 | switch (attachment) |
| 4058 | { |
| 4059 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break; |
| 4060 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break; |
| 4061 | } |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4062 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4063 | } |
| 4064 | } |
| 4065 | catch(std::bad_alloc&) |
| 4066 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4067 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4068 | } |
| 4069 | } |
| 4070 | |
| 4071 | void __stdcall glFrontFace(GLenum mode) |
| 4072 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4073 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4074 | |
| 4075 | try |
| 4076 | { |
| 4077 | switch (mode) |
| 4078 | { |
| 4079 | case GL_CW: |
| 4080 | case GL_CCW: |
| 4081 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4082 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4083 | |
| 4084 | if (context) |
| 4085 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4086 | context->setFrontFace(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4087 | } |
| 4088 | } |
| 4089 | break; |
| 4090 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4091 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4092 | } |
| 4093 | } |
| 4094 | catch(std::bad_alloc&) |
| 4095 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4096 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4097 | } |
| 4098 | } |
| 4099 | |
| 4100 | void __stdcall glGenBuffers(GLsizei n, GLuint* buffers) |
| 4101 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4102 | EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4103 | |
| 4104 | try |
| 4105 | { |
| 4106 | if (n < 0) |
| 4107 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4108 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4109 | } |
| 4110 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4111 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4112 | |
| 4113 | if (context) |
| 4114 | { |
| 4115 | for (int i = 0; i < n; i++) |
| 4116 | { |
| 4117 | buffers[i] = context->createBuffer(); |
| 4118 | } |
| 4119 | } |
| 4120 | } |
| 4121 | catch(std::bad_alloc&) |
| 4122 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4123 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4124 | } |
| 4125 | } |
| 4126 | |
| 4127 | void __stdcall glGenerateMipmap(GLenum target) |
| 4128 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4129 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4130 | |
| 4131 | try |
| 4132 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4133 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4134 | |
| 4135 | if (context) |
| 4136 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4137 | gl::Texture *texture = NULL; |
| 4138 | GLint internalFormat = GL_NONE; |
| 4139 | bool isCompressed = false; |
| 4140 | bool isDepth = false; |
| 4141 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4142 | switch (target) |
| 4143 | { |
| 4144 | case GL_TEXTURE_2D: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4145 | { |
| 4146 | gl::Texture2D *tex2d = context->getTexture2D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4147 | if (tex2d) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4148 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4149 | internalFormat = tex2d->getInternalFormat(0); |
| 4150 | isCompressed = tex2d->isCompressed(0); |
| 4151 | isDepth = tex2d->isDepth(0); |
| 4152 | texture = tex2d; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4153 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4154 | break; |
| 4155 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4156 | |
| 4157 | case GL_TEXTURE_CUBE_MAP: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4158 | { |
| 4159 | gl::TextureCubeMap *texcube = context->getTextureCubeMap(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4160 | if (texcube) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4161 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4162 | internalFormat = texcube->getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 4163 | isCompressed = texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 4164 | isDepth = false; |
| 4165 | texture = texcube; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4166 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4167 | break; |
| 4168 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4169 | |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4170 | case GL_TEXTURE_3D: |
| 4171 | { |
| 4172 | if (context->getClientVersion() < 3) |
| 4173 | { |
| 4174 | return gl::error(GL_INVALID_ENUM); |
| 4175 | } |
| 4176 | |
| 4177 | gl::Texture3D *tex3D = context->getTexture3D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4178 | if (tex3D) |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4179 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4180 | internalFormat = tex3D->getInternalFormat(0); |
| 4181 | isCompressed = tex3D->isCompressed(0); |
| 4182 | isDepth = tex3D->isDepth(0); |
| 4183 | texture = tex3D; |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4184 | } |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4185 | break; |
| 4186 | } |
| 4187 | |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4188 | case GL_TEXTURE_2D_ARRAY: |
| 4189 | { |
| 4190 | if (context->getClientVersion() < 3) |
| 4191 | { |
| 4192 | return gl::error(GL_INVALID_ENUM); |
| 4193 | } |
| 4194 | |
| 4195 | gl::Texture2DArray *tex2darr = context->getTexture2DArray(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4196 | if (tex2darr) |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4197 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4198 | internalFormat = tex2darr->getInternalFormat(0); |
| 4199 | isCompressed = tex2darr->isCompressed(0); |
| 4200 | isDepth = tex2darr->isDepth(0); |
| 4201 | texture = tex2darr; |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4202 | } |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4203 | break; |
| 4204 | } |
| 4205 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4206 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4207 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4208 | } |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4209 | |
| 4210 | if (!texture) |
| 4211 | { |
| 4212 | return gl::error(GL_INVALID_OPERATION); |
| 4213 | } |
| 4214 | |
| 4215 | // Internally, all texture formats are sized so checking if the format |
| 4216 | // is color renderable and filterable will not fail. |
| 4217 | if (isDepth || isCompressed || |
| 4218 | !gl::IsColorRenderingSupported(internalFormat, context) || |
| 4219 | !gl::IsTextureFilteringSupported(internalFormat, context)) |
| 4220 | { |
| 4221 | return gl::error(GL_INVALID_OPERATION); |
| 4222 | } |
| 4223 | |
| 4224 | texture->generateMipmaps(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4225 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4226 | } |
| 4227 | catch(std::bad_alloc&) |
| 4228 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4229 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4230 | } |
| 4231 | } |
| 4232 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4233 | void __stdcall glGenFencesNV(GLsizei n, GLuint* fences) |
| 4234 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4235 | EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4236 | |
| 4237 | try |
| 4238 | { |
| 4239 | if (n < 0) |
| 4240 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4241 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4242 | } |
| 4243 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4244 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4245 | |
| 4246 | if (context) |
| 4247 | { |
| 4248 | for (int i = 0; i < n; i++) |
| 4249 | { |
| 4250 | fences[i] = context->createFence(); |
| 4251 | } |
| 4252 | } |
| 4253 | } |
| 4254 | catch(std::bad_alloc&) |
| 4255 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4256 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4257 | } |
| 4258 | } |
| 4259 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4260 | void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers) |
| 4261 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4262 | EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4263 | |
| 4264 | try |
| 4265 | { |
| 4266 | if (n < 0) |
| 4267 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4268 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4269 | } |
| 4270 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4271 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4272 | |
| 4273 | if (context) |
| 4274 | { |
| 4275 | for (int i = 0; i < n; i++) |
| 4276 | { |
| 4277 | framebuffers[i] = context->createFramebuffer(); |
| 4278 | } |
| 4279 | } |
| 4280 | } |
| 4281 | catch(std::bad_alloc&) |
| 4282 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4283 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4284 | } |
| 4285 | } |
| 4286 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4287 | void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids) |
| 4288 | { |
| 4289 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 4290 | |
| 4291 | try |
| 4292 | { |
| 4293 | if (n < 0) |
| 4294 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4295 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4296 | } |
| 4297 | |
| 4298 | gl::Context *context = gl::getNonLostContext(); |
| 4299 | |
| 4300 | if (context) |
| 4301 | { |
| 4302 | for (int i = 0; i < n; i++) |
| 4303 | { |
| 4304 | ids[i] = context->createQuery(); |
| 4305 | } |
| 4306 | } |
| 4307 | } |
| 4308 | catch(std::bad_alloc&) |
| 4309 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4310 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4311 | } |
| 4312 | } |
| 4313 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4314 | void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) |
| 4315 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4316 | EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4317 | |
| 4318 | try |
| 4319 | { |
| 4320 | if (n < 0) |
| 4321 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4322 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4323 | } |
| 4324 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4325 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4326 | |
| 4327 | if (context) |
| 4328 | { |
| 4329 | for (int i = 0; i < n; i++) |
| 4330 | { |
| 4331 | renderbuffers[i] = context->createRenderbuffer(); |
| 4332 | } |
| 4333 | } |
| 4334 | } |
| 4335 | catch(std::bad_alloc&) |
| 4336 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4337 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4338 | } |
| 4339 | } |
| 4340 | |
| 4341 | void __stdcall glGenTextures(GLsizei n, GLuint* textures) |
| 4342 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4343 | EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4344 | |
| 4345 | try |
| 4346 | { |
| 4347 | if (n < 0) |
| 4348 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4349 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4350 | } |
| 4351 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4352 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4353 | |
| 4354 | if (context) |
| 4355 | { |
| 4356 | for (int i = 0; i < n; i++) |
| 4357 | { |
| 4358 | textures[i] = context->createTexture(); |
| 4359 | } |
| 4360 | } |
| 4361 | } |
| 4362 | catch(std::bad_alloc&) |
| 4363 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4364 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4365 | } |
| 4366 | } |
| 4367 | |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4368 | 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] | 4369 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4370 | 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] | 4371 | "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] | 4372 | program, index, bufsize, length, size, type, name); |
| 4373 | |
| 4374 | try |
| 4375 | { |
| 4376 | if (bufsize < 0) |
| 4377 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4378 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4379 | } |
| 4380 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4381 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4382 | |
| 4383 | if (context) |
| 4384 | { |
| 4385 | gl::Program *programObject = context->getProgram(program); |
| 4386 | |
| 4387 | if (!programObject) |
| 4388 | { |
| 4389 | if (context->getShader(program)) |
| 4390 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4391 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4392 | } |
| 4393 | else |
| 4394 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4395 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4396 | } |
| 4397 | } |
| 4398 | |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4399 | if (index >= (GLuint)programObject->getActiveAttributeCount()) |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4400 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4401 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4402 | } |
| 4403 | |
| 4404 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 4405 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4406 | } |
| 4407 | catch(std::bad_alloc&) |
| 4408 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4409 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4410 | } |
| 4411 | } |
| 4412 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4413 | 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] | 4414 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4415 | EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4416 | "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] | 4417 | program, index, bufsize, length, size, type, name); |
| 4418 | |
| 4419 | try |
| 4420 | { |
| 4421 | if (bufsize < 0) |
| 4422 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4423 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4424 | } |
| 4425 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4426 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4427 | |
| 4428 | if (context) |
| 4429 | { |
| 4430 | gl::Program *programObject = context->getProgram(program); |
| 4431 | |
| 4432 | if (!programObject) |
| 4433 | { |
| 4434 | if (context->getShader(program)) |
| 4435 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4436 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4437 | } |
| 4438 | else |
| 4439 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4440 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4441 | } |
| 4442 | } |
| 4443 | |
| 4444 | if (index >= (GLuint)programObject->getActiveUniformCount()) |
| 4445 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4446 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4447 | } |
| 4448 | |
| 4449 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 4450 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4451 | } |
| 4452 | catch(std::bad_alloc&) |
| 4453 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4454 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4455 | } |
| 4456 | } |
| 4457 | |
| 4458 | void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) |
| 4459 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4460 | 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] | 4461 | program, maxcount, count, shaders); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4462 | |
| 4463 | try |
| 4464 | { |
| 4465 | if (maxcount < 0) |
| 4466 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4467 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4468 | } |
| 4469 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4470 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4471 | |
| 4472 | if (context) |
| 4473 | { |
| 4474 | gl::Program *programObject = context->getProgram(program); |
| 4475 | |
| 4476 | if (!programObject) |
| 4477 | { |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4478 | if (context->getShader(program)) |
| 4479 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4480 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4481 | } |
| 4482 | else |
| 4483 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4484 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4485 | } |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4486 | } |
| 4487 | |
| 4488 | return programObject->getAttachedShaders(maxcount, count, shaders); |
| 4489 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4490 | } |
| 4491 | catch(std::bad_alloc&) |
| 4492 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4493 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4494 | } |
| 4495 | } |
| 4496 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4497 | int __stdcall glGetAttribLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4498 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4499 | EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4500 | |
| 4501 | try |
| 4502 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4503 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4504 | |
| 4505 | if (context) |
| 4506 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4507 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4508 | gl::Program *programObject = context->getProgram(program); |
| 4509 | |
| 4510 | if (!programObject) |
| 4511 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4512 | if (context->getShader(program)) |
| 4513 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4514 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4515 | } |
| 4516 | else |
| 4517 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4518 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4519 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4520 | } |
| 4521 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4522 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 4523 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4524 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4525 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4526 | } |
| 4527 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4528 | return programBinary->getAttributeLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4529 | } |
| 4530 | } |
| 4531 | catch(std::bad_alloc&) |
| 4532 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4533 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4534 | } |
| 4535 | |
| 4536 | return -1; |
| 4537 | } |
| 4538 | |
| 4539 | void __stdcall glGetBooleanv(GLenum pname, GLboolean* params) |
| 4540 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4541 | 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] | 4542 | |
| 4543 | try |
| 4544 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4545 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4546 | |
| 4547 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4548 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4549 | if (!(context->getBooleanv(pname, params))) |
| 4550 | { |
| 4551 | GLenum nativeType; |
| 4552 | unsigned int numParams = 0; |
| 4553 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4554 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4555 | |
| 4556 | if (numParams == 0) |
| 4557 | return; // it is known that the pname is valid, but there are no parameters to return |
| 4558 | |
| 4559 | if (nativeType == GL_FLOAT) |
| 4560 | { |
| 4561 | GLfloat *floatParams = NULL; |
| 4562 | floatParams = new GLfloat[numParams]; |
| 4563 | |
| 4564 | context->getFloatv(pname, floatParams); |
| 4565 | |
| 4566 | for (unsigned int i = 0; i < numParams; ++i) |
| 4567 | { |
| 4568 | if (floatParams[i] == 0.0f) |
| 4569 | params[i] = GL_FALSE; |
| 4570 | else |
| 4571 | params[i] = GL_TRUE; |
| 4572 | } |
| 4573 | |
| 4574 | delete [] floatParams; |
| 4575 | } |
| 4576 | else if (nativeType == GL_INT) |
| 4577 | { |
| 4578 | GLint *intParams = NULL; |
| 4579 | intParams = new GLint[numParams]; |
| 4580 | |
| 4581 | context->getIntegerv(pname, intParams); |
| 4582 | |
| 4583 | for (unsigned int i = 0; i < numParams; ++i) |
| 4584 | { |
| 4585 | if (intParams[i] == 0) |
| 4586 | params[i] = GL_FALSE; |
| 4587 | else |
| 4588 | params[i] = GL_TRUE; |
| 4589 | } |
| 4590 | |
| 4591 | delete [] intParams; |
| 4592 | } |
| 4593 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4594 | } |
| 4595 | } |
| 4596 | catch(std::bad_alloc&) |
| 4597 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4598 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4599 | } |
| 4600 | } |
| 4601 | |
| 4602 | void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 4603 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4604 | 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] | 4605 | |
| 4606 | try |
| 4607 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4608 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4609 | |
| 4610 | if (context) |
| 4611 | { |
| 4612 | gl::Buffer *buffer; |
| 4613 | |
| 4614 | switch (target) |
| 4615 | { |
| 4616 | case GL_ARRAY_BUFFER: |
| 4617 | buffer = context->getArrayBuffer(); |
| 4618 | break; |
| 4619 | case GL_ELEMENT_ARRAY_BUFFER: |
| 4620 | buffer = context->getElementArrayBuffer(); |
| 4621 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4622 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4623 | } |
| 4624 | |
| 4625 | if (!buffer) |
| 4626 | { |
| 4627 | // 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] | 4628 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4629 | } |
| 4630 | |
| 4631 | switch (pname) |
| 4632 | { |
| 4633 | case GL_BUFFER_USAGE: |
| 4634 | *params = buffer->usage(); |
| 4635 | break; |
| 4636 | case GL_BUFFER_SIZE: |
| 4637 | *params = buffer->size(); |
| 4638 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4639 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4640 | } |
| 4641 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4642 | } |
| 4643 | catch(std::bad_alloc&) |
| 4644 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4645 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4646 | } |
| 4647 | } |
| 4648 | |
| 4649 | GLenum __stdcall glGetError(void) |
| 4650 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4651 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4652 | |
| 4653 | gl::Context *context = gl::getContext(); |
| 4654 | |
| 4655 | if (context) |
| 4656 | { |
daniel@transgaming.com | 82b2891 | 2011-12-12 21:01:35 +0000 | [diff] [blame] | 4657 | return context->getError(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4658 | } |
| 4659 | |
| 4660 | return GL_NO_ERROR; |
| 4661 | } |
| 4662 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4663 | void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 4664 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4665 | 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] | 4666 | |
| 4667 | try |
| 4668 | { |
| 4669 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4670 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4671 | |
| 4672 | if (context) |
| 4673 | { |
| 4674 | gl::Fence *fenceObject = context->getFence(fence); |
| 4675 | |
| 4676 | if (fenceObject == NULL) |
| 4677 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4678 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4679 | } |
| 4680 | |
| 4681 | fenceObject->getFenceiv(pname, params); |
| 4682 | } |
| 4683 | } |
| 4684 | catch(std::bad_alloc&) |
| 4685 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4686 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4687 | } |
| 4688 | } |
| 4689 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4690 | void __stdcall glGetFloatv(GLenum pname, GLfloat* params) |
| 4691 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4692 | 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] | 4693 | |
| 4694 | try |
| 4695 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4696 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4697 | |
| 4698 | if (context) |
| 4699 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4700 | if (!(context->getFloatv(pname, params))) |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4701 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4702 | GLenum nativeType; |
| 4703 | unsigned int numParams = 0; |
| 4704 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4705 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4706 | |
| 4707 | if (numParams == 0) |
| 4708 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 4709 | |
| 4710 | if (nativeType == GL_BOOL) |
| 4711 | { |
| 4712 | GLboolean *boolParams = NULL; |
| 4713 | boolParams = new GLboolean[numParams]; |
| 4714 | |
| 4715 | context->getBooleanv(pname, boolParams); |
| 4716 | |
| 4717 | for (unsigned int i = 0; i < numParams; ++i) |
| 4718 | { |
| 4719 | if (boolParams[i] == GL_FALSE) |
| 4720 | params[i] = 0.0f; |
| 4721 | else |
| 4722 | params[i] = 1.0f; |
| 4723 | } |
| 4724 | |
| 4725 | delete [] boolParams; |
| 4726 | } |
| 4727 | else if (nativeType == GL_INT) |
| 4728 | { |
| 4729 | GLint *intParams = NULL; |
| 4730 | intParams = new GLint[numParams]; |
| 4731 | |
| 4732 | context->getIntegerv(pname, intParams); |
| 4733 | |
| 4734 | for (unsigned int i = 0; i < numParams; ++i) |
| 4735 | { |
| 4736 | params[i] = (GLfloat)intParams[i]; |
| 4737 | } |
| 4738 | |
| 4739 | delete [] intParams; |
| 4740 | } |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4741 | } |
| 4742 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4743 | } |
| 4744 | catch(std::bad_alloc&) |
| 4745 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4746 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4747 | } |
| 4748 | } |
| 4749 | |
| 4750 | void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) |
| 4751 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4752 | 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] | 4753 | target, attachment, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4754 | |
| 4755 | try |
| 4756 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4757 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4758 | |
| 4759 | if (context) |
| 4760 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4761 | 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] | 4762 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4763 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4764 | } |
| 4765 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4766 | gl::Framebuffer *framebuffer = NULL; |
| 4767 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4768 | { |
| 4769 | if(context->getReadFramebufferHandle() == 0) |
| 4770 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4771 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4772 | } |
| 4773 | |
| 4774 | framebuffer = context->getReadFramebuffer(); |
| 4775 | } |
| 4776 | else |
| 4777 | { |
| 4778 | if (context->getDrawFramebufferHandle() == 0) |
| 4779 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4780 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4781 | } |
| 4782 | |
| 4783 | framebuffer = context->getDrawFramebuffer(); |
| 4784 | } |
| 4785 | |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4786 | GLenum attachmentType; |
| 4787 | GLuint attachmentHandle; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4788 | |
| 4789 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4790 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4791 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4792 | |
| 4793 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4794 | { |
| 4795 | return gl::error(GL_INVALID_ENUM); |
| 4796 | } |
| 4797 | |
| 4798 | attachmentType = framebuffer->getColorbufferType(colorAttachment); |
| 4799 | attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment); |
| 4800 | } |
| 4801 | else |
| 4802 | { |
| 4803 | switch (attachment) |
| 4804 | { |
| 4805 | case GL_DEPTH_ATTACHMENT: |
| 4806 | attachmentType = framebuffer->getDepthbufferType(); |
| 4807 | attachmentHandle = framebuffer->getDepthbufferHandle(); |
| 4808 | break; |
| 4809 | case GL_STENCIL_ATTACHMENT: |
| 4810 | attachmentType = framebuffer->getStencilbufferType(); |
| 4811 | attachmentHandle = framebuffer->getStencilbufferHandle(); |
| 4812 | break; |
| 4813 | default: return gl::error(GL_INVALID_ENUM); |
| 4814 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4815 | } |
| 4816 | |
| 4817 | GLenum attachmentObjectType; // Type category |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4818 | if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4819 | { |
| 4820 | attachmentObjectType = attachmentType; |
| 4821 | } |
apatrick@chromium.org | 551022e | 2012-01-23 19:56:54 +0000 | [diff] [blame] | 4822 | else if (gl::IsInternalTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4823 | { |
| 4824 | attachmentObjectType = GL_TEXTURE; |
| 4825 | } |
apatrick@chromium.org | a1d8059 | 2012-01-25 21:52:10 +0000 | [diff] [blame] | 4826 | else |
| 4827 | { |
| 4828 | UNREACHABLE(); |
| 4829 | return; |
| 4830 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4831 | |
| 4832 | switch (pname) |
| 4833 | { |
| 4834 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 4835 | *params = attachmentObjectType; |
| 4836 | break; |
| 4837 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 4838 | if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE) |
| 4839 | { |
| 4840 | *params = attachmentHandle; |
| 4841 | } |
| 4842 | else |
| 4843 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4844 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4845 | } |
| 4846 | break; |
| 4847 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 4848 | if (attachmentObjectType == GL_TEXTURE) |
| 4849 | { |
| 4850 | *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0 |
| 4851 | } |
| 4852 | else |
| 4853 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4854 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4855 | } |
| 4856 | break; |
| 4857 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 4858 | if (attachmentObjectType == GL_TEXTURE) |
| 4859 | { |
daniel@transgaming.com | 19ffc24 | 2010-05-04 03:35:21 +0000 | [diff] [blame] | 4860 | if (gl::IsCubemapTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4861 | { |
| 4862 | *params = attachmentType; |
| 4863 | } |
| 4864 | else |
| 4865 | { |
| 4866 | *params = 0; |
| 4867 | } |
| 4868 | } |
| 4869 | else |
| 4870 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4871 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4872 | } |
| 4873 | break; |
| 4874 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4875 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4876 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4877 | } |
| 4878 | } |
| 4879 | catch(std::bad_alloc&) |
| 4880 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4881 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4882 | } |
| 4883 | } |
| 4884 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 4885 | GLenum __stdcall glGetGraphicsResetStatusEXT(void) |
| 4886 | { |
| 4887 | EVENT("()"); |
| 4888 | |
| 4889 | try |
| 4890 | { |
| 4891 | gl::Context *context = gl::getContext(); |
| 4892 | |
| 4893 | if (context) |
| 4894 | { |
| 4895 | return context->getResetStatus(); |
| 4896 | } |
| 4897 | |
| 4898 | return GL_NO_ERROR; |
| 4899 | } |
| 4900 | catch(std::bad_alloc&) |
| 4901 | { |
| 4902 | return GL_OUT_OF_MEMORY; |
| 4903 | } |
| 4904 | } |
| 4905 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4906 | void __stdcall glGetIntegerv(GLenum pname, GLint* params) |
| 4907 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4908 | 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] | 4909 | |
| 4910 | try |
| 4911 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4912 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4913 | |
| 4914 | if (context) |
| 4915 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4916 | if (!(context->getIntegerv(pname, params))) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4917 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4918 | GLenum nativeType; |
| 4919 | unsigned int numParams = 0; |
| 4920 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4921 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4922 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4923 | if (numParams == 0) |
| 4924 | return; // it is known that pname is valid, but there are no parameters to return |
| 4925 | |
| 4926 | if (nativeType == GL_BOOL) |
| 4927 | { |
| 4928 | GLboolean *boolParams = NULL; |
| 4929 | boolParams = new GLboolean[numParams]; |
| 4930 | |
| 4931 | context->getBooleanv(pname, boolParams); |
| 4932 | |
| 4933 | for (unsigned int i = 0; i < numParams; ++i) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4934 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4935 | if (boolParams[i] == GL_FALSE) |
| 4936 | params[i] = 0; |
| 4937 | else |
| 4938 | params[i] = 1; |
| 4939 | } |
| 4940 | |
| 4941 | delete [] boolParams; |
| 4942 | } |
| 4943 | else if (nativeType == GL_FLOAT) |
| 4944 | { |
| 4945 | GLfloat *floatParams = NULL; |
| 4946 | floatParams = new GLfloat[numParams]; |
| 4947 | |
| 4948 | context->getFloatv(pname, floatParams); |
| 4949 | |
| 4950 | for (unsigned int i = 0; i < numParams; ++i) |
| 4951 | { |
daniel@transgaming.com | c164135 | 2010-04-26 15:33:36 +0000 | [diff] [blame] | 4952 | 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] | 4953 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4954 | params[i] = (GLint)(((GLfloat)(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4955 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4956 | else |
| 4957 | 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] | 4958 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4959 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4960 | delete [] floatParams; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4961 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4962 | } |
| 4963 | } |
| 4964 | } |
| 4965 | catch(std::bad_alloc&) |
| 4966 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4967 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4968 | } |
| 4969 | } |
| 4970 | |
| 4971 | void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params) |
| 4972 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4973 | 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] | 4974 | |
| 4975 | try |
| 4976 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4977 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4978 | |
| 4979 | if (context) |
| 4980 | { |
| 4981 | gl::Program *programObject = context->getProgram(program); |
| 4982 | |
| 4983 | if (!programObject) |
| 4984 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4985 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4986 | } |
| 4987 | |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 4988 | if (context->getClientVersion() < 3) |
| 4989 | { |
| 4990 | switch (pname) |
| 4991 | { |
| 4992 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 4993 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 4994 | return gl::error(GL_INVALID_ENUM); |
| 4995 | } |
| 4996 | } |
| 4997 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4998 | switch (pname) |
| 4999 | { |
| 5000 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5001 | *params = programObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5002 | return; |
| 5003 | case GL_LINK_STATUS: |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5004 | *params = programObject->isLinked(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5005 | return; |
| 5006 | case GL_VALIDATE_STATUS: |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 5007 | *params = programObject->isValidated(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5008 | return; |
| 5009 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5010 | *params = programObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5011 | return; |
| 5012 | case GL_ATTACHED_SHADERS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5013 | *params = programObject->getAttachedShadersCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5014 | return; |
| 5015 | case GL_ACTIVE_ATTRIBUTES: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 5016 | *params = programObject->getActiveAttributeCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5017 | return; |
| 5018 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 5019 | *params = programObject->getActiveAttributeMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5020 | return; |
| 5021 | case GL_ACTIVE_UNIFORMS: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 5022 | *params = programObject->getActiveUniformCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5023 | return; |
| 5024 | case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 5025 | *params = programObject->getActiveUniformMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5026 | return; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 5027 | case GL_PROGRAM_BINARY_LENGTH_OES: |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 5028 | *params = programObject->getProgramBinaryLength(); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 5029 | return; |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 5030 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 5031 | *params = programObject->getActiveUniformBlockCount(); |
| 5032 | return; |
| 5033 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 5034 | *params = programObject->getActiveUniformBlockMaxLength(); |
| 5035 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5036 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5037 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5038 | } |
| 5039 | } |
| 5040 | } |
| 5041 | catch(std::bad_alloc&) |
| 5042 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5043 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5044 | } |
| 5045 | } |
| 5046 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5047 | void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5048 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5049 | 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] | 5050 | program, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5051 | |
| 5052 | try |
| 5053 | { |
| 5054 | if (bufsize < 0) |
| 5055 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5056 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5057 | } |
| 5058 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5059 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5060 | |
| 5061 | if (context) |
| 5062 | { |
| 5063 | gl::Program *programObject = context->getProgram(program); |
| 5064 | |
| 5065 | if (!programObject) |
| 5066 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5067 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5068 | } |
| 5069 | |
| 5070 | programObject->getInfoLog(bufsize, length, infolog); |
| 5071 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5072 | } |
| 5073 | catch(std::bad_alloc&) |
| 5074 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5075 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5076 | } |
| 5077 | } |
| 5078 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5079 | void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params) |
| 5080 | { |
| 5081 | EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params); |
| 5082 | |
| 5083 | try |
| 5084 | { |
| 5085 | switch (pname) |
| 5086 | { |
| 5087 | case GL_CURRENT_QUERY_EXT: |
| 5088 | break; |
| 5089 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5090 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5091 | } |
| 5092 | |
| 5093 | gl::Context *context = gl::getNonLostContext(); |
| 5094 | |
| 5095 | if (context) |
| 5096 | { |
| 5097 | params[0] = context->getActiveQuery(target); |
| 5098 | } |
| 5099 | } |
| 5100 | catch(std::bad_alloc&) |
| 5101 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5102 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5103 | } |
| 5104 | } |
| 5105 | |
| 5106 | void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) |
| 5107 | { |
| 5108 | EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params); |
| 5109 | |
| 5110 | try |
| 5111 | { |
| 5112 | switch (pname) |
| 5113 | { |
| 5114 | case GL_QUERY_RESULT_EXT: |
| 5115 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5116 | break; |
| 5117 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5118 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5119 | } |
| 5120 | gl::Context *context = gl::getNonLostContext(); |
| 5121 | |
| 5122 | if (context) |
| 5123 | { |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5124 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 5125 | |
| 5126 | if (!queryObject) |
| 5127 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5128 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5129 | } |
| 5130 | |
| 5131 | if (context->getActiveQuery(queryObject->getType()) == id) |
| 5132 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5133 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5134 | } |
| 5135 | |
| 5136 | switch(pname) |
| 5137 | { |
| 5138 | case GL_QUERY_RESULT_EXT: |
| 5139 | params[0] = queryObject->getResult(); |
| 5140 | break; |
| 5141 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5142 | params[0] = queryObject->isResultAvailable(); |
| 5143 | break; |
| 5144 | default: |
| 5145 | ASSERT(false); |
| 5146 | } |
| 5147 | } |
| 5148 | } |
| 5149 | catch(std::bad_alloc&) |
| 5150 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5151 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5152 | } |
| 5153 | } |
| 5154 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5155 | void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5156 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5157 | 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] | 5158 | |
| 5159 | try |
| 5160 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5161 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5162 | |
| 5163 | if (context) |
| 5164 | { |
| 5165 | if (target != GL_RENDERBUFFER) |
| 5166 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5167 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5168 | } |
| 5169 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5170 | if (context->getRenderbufferHandle() == 0) |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5171 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5172 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5173 | } |
| 5174 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5175 | gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle()); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5176 | |
| 5177 | switch (pname) |
| 5178 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5179 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break; |
| 5180 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break; |
| 5181 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break; |
| 5182 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break; |
| 5183 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break; |
| 5184 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break; |
| 5185 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break; |
| 5186 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break; |
| 5187 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break; |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5188 | case GL_RENDERBUFFER_SAMPLES_ANGLE: |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5189 | if (context->getMaxSupportedSamples() != 0) |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5190 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5191 | *params = renderbuffer->getSamples(); |
| 5192 | } |
| 5193 | else |
| 5194 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5195 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5196 | } |
| 5197 | break; |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5198 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5199 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5200 | } |
| 5201 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5202 | } |
| 5203 | catch(std::bad_alloc&) |
| 5204 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5205 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5206 | } |
| 5207 | } |
| 5208 | |
| 5209 | void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params) |
| 5210 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5211 | 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] | 5212 | |
| 5213 | try |
| 5214 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5215 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5216 | |
| 5217 | if (context) |
| 5218 | { |
| 5219 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 5220 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5221 | if (!shaderObject) |
| 5222 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5223 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5224 | } |
| 5225 | |
| 5226 | switch (pname) |
| 5227 | { |
| 5228 | case GL_SHADER_TYPE: |
| 5229 | *params = shaderObject->getType(); |
| 5230 | return; |
| 5231 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5232 | *params = shaderObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5233 | return; |
| 5234 | case GL_COMPILE_STATUS: |
| 5235 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; |
| 5236 | return; |
| 5237 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5238 | *params = shaderObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5239 | return; |
| 5240 | case GL_SHADER_SOURCE_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5241 | *params = shaderObject->getSourceLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5242 | return; |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5243 | case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: |
| 5244 | *params = shaderObject->getTranslatedSourceLength(); |
| 5245 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5246 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5247 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5248 | } |
| 5249 | } |
| 5250 | } |
| 5251 | catch(std::bad_alloc&) |
| 5252 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5253 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5254 | } |
| 5255 | } |
| 5256 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5257 | void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5258 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5259 | 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] | 5260 | shader, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5261 | |
| 5262 | try |
| 5263 | { |
| 5264 | if (bufsize < 0) |
| 5265 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5266 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5267 | } |
| 5268 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5269 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5270 | |
| 5271 | if (context) |
| 5272 | { |
| 5273 | gl::Shader *shaderObject = context->getShader(shader); |
| 5274 | |
| 5275 | if (!shaderObject) |
| 5276 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5277 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5278 | } |
| 5279 | |
| 5280 | shaderObject->getInfoLog(bufsize, length, infolog); |
| 5281 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5282 | } |
| 5283 | catch(std::bad_alloc&) |
| 5284 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5285 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5286 | } |
| 5287 | } |
| 5288 | |
| 5289 | void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) |
| 5290 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5291 | 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] | 5292 | shadertype, precisiontype, range, precision); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5293 | |
| 5294 | try |
| 5295 | { |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5296 | switch (shadertype) |
| 5297 | { |
| 5298 | case GL_VERTEX_SHADER: |
| 5299 | case GL_FRAGMENT_SHADER: |
| 5300 | break; |
| 5301 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5302 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5303 | } |
| 5304 | |
| 5305 | switch (precisiontype) |
| 5306 | { |
| 5307 | case GL_LOW_FLOAT: |
| 5308 | case GL_MEDIUM_FLOAT: |
| 5309 | case GL_HIGH_FLOAT: |
| 5310 | // Assume IEEE 754 precision |
| 5311 | range[0] = 127; |
| 5312 | range[1] = 127; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5313 | *precision = 23; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5314 | break; |
| 5315 | case GL_LOW_INT: |
| 5316 | case GL_MEDIUM_INT: |
| 5317 | case GL_HIGH_INT: |
| 5318 | // Some (most) hardware only supports single-precision floating-point numbers, |
| 5319 | // which can accurately represent integers up to +/-16777216 |
| 5320 | range[0] = 24; |
| 5321 | range[1] = 24; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5322 | *precision = 0; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5323 | break; |
| 5324 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5325 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5326 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5327 | } |
| 5328 | catch(std::bad_alloc&) |
| 5329 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5330 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5331 | } |
| 5332 | } |
| 5333 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5334 | void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5335 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5336 | 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] | 5337 | shader, bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5338 | |
| 5339 | try |
| 5340 | { |
| 5341 | if (bufsize < 0) |
| 5342 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5343 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5344 | } |
| 5345 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5346 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5347 | |
| 5348 | if (context) |
| 5349 | { |
| 5350 | gl::Shader *shaderObject = context->getShader(shader); |
| 5351 | |
| 5352 | if (!shaderObject) |
| 5353 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5354 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5355 | } |
| 5356 | |
| 5357 | shaderObject->getSource(bufsize, length, source); |
| 5358 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5359 | } |
| 5360 | catch(std::bad_alloc&) |
| 5361 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5362 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5363 | } |
| 5364 | } |
| 5365 | |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5366 | void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
| 5367 | { |
| 5368 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)", |
| 5369 | shader, bufsize, length, source); |
| 5370 | |
| 5371 | try |
| 5372 | { |
| 5373 | if (bufsize < 0) |
| 5374 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5375 | return gl::error(GL_INVALID_VALUE); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5376 | } |
| 5377 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5378 | gl::Context *context = gl::getNonLostContext(); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5379 | |
| 5380 | if (context) |
| 5381 | { |
| 5382 | gl::Shader *shaderObject = context->getShader(shader); |
| 5383 | |
| 5384 | if (!shaderObject) |
| 5385 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5386 | return gl::error(GL_INVALID_OPERATION); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5387 | } |
| 5388 | |
| 5389 | shaderObject->getTranslatedSource(bufsize, length, source); |
| 5390 | } |
| 5391 | } |
| 5392 | catch(std::bad_alloc&) |
| 5393 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5394 | return gl::error(GL_OUT_OF_MEMORY); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5395 | } |
| 5396 | } |
| 5397 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5398 | const GLubyte* __stdcall glGetString(GLenum name) |
| 5399 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5400 | EVENT("(GLenum name = 0x%X)", name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5401 | |
| 5402 | try |
| 5403 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5404 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3e4c600 | 2010-05-05 18:50:13 +0000 | [diff] [blame] | 5405 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5406 | switch (name) |
| 5407 | { |
| 5408 | case GL_VENDOR: |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 5409 | return (GLubyte*)"Google Inc."; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5410 | case GL_RENDERER: |
daniel@transgaming.com | c23ff64 | 2011-08-16 20:28:45 +0000 | [diff] [blame] | 5411 | return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5412 | case GL_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5413 | if (context->getClientVersion() == 2) |
| 5414 | { |
| 5415 | return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")"; |
| 5416 | } |
| 5417 | else |
| 5418 | { |
| 5419 | return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")"; |
| 5420 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5421 | case GL_SHADING_LANGUAGE_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5422 | if (context->getClientVersion() == 2) |
| 5423 | { |
| 5424 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")"; |
| 5425 | } |
| 5426 | else |
| 5427 | { |
| 5428 | return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")"; |
| 5429 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5430 | case GL_EXTENSIONS: |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 5431 | return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : ""); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5432 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5433 | return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5434 | } |
| 5435 | } |
| 5436 | catch(std::bad_alloc&) |
| 5437 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5438 | return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5439 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5440 | } |
| 5441 | |
| 5442 | void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) |
| 5443 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5444 | 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] | 5445 | |
| 5446 | try |
| 5447 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5448 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5449 | |
| 5450 | if (context) |
| 5451 | { |
| 5452 | gl::Texture *texture; |
| 5453 | |
| 5454 | switch (target) |
| 5455 | { |
| 5456 | case GL_TEXTURE_2D: |
| 5457 | texture = context->getTexture2D(); |
| 5458 | break; |
| 5459 | case GL_TEXTURE_CUBE_MAP: |
| 5460 | texture = context->getTextureCubeMap(); |
| 5461 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5462 | case GL_TEXTURE_3D: |
| 5463 | if (context->getClientVersion() < 3) |
| 5464 | { |
| 5465 | return gl::error(GL_INVALID_ENUM); |
| 5466 | } |
| 5467 | texture = context->getTexture3D(); |
| 5468 | break; |
shannonwoods@chromium.org | 0c611d1 | 2013-05-30 00:15:05 +0000 | [diff] [blame] | 5469 | case GL_TEXTURE_2D_ARRAY: |
| 5470 | if (context->getClientVersion() < 3) |
| 5471 | { |
| 5472 | return gl::error(GL_INVALID_ENUM); |
| 5473 | } |
| 5474 | texture = context->getTexture2DArray(); |
| 5475 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5476 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5477 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5478 | } |
| 5479 | |
| 5480 | switch (pname) |
| 5481 | { |
| 5482 | case GL_TEXTURE_MAG_FILTER: |
| 5483 | *params = (GLfloat)texture->getMagFilter(); |
| 5484 | break; |
| 5485 | case GL_TEXTURE_MIN_FILTER: |
| 5486 | *params = (GLfloat)texture->getMinFilter(); |
| 5487 | break; |
| 5488 | case GL_TEXTURE_WRAP_S: |
| 5489 | *params = (GLfloat)texture->getWrapS(); |
| 5490 | break; |
| 5491 | case GL_TEXTURE_WRAP_T: |
| 5492 | *params = (GLfloat)texture->getWrapT(); |
| 5493 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5494 | case GL_TEXTURE_WRAP_R: |
| 5495 | if (context->getClientVersion() < 3) |
| 5496 | { |
| 5497 | return gl::error(GL_INVALID_ENUM); |
| 5498 | } |
| 5499 | *params = (GLfloat)texture->getWrapR(); |
| 5500 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5501 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5502 | // 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] | 5503 | *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE); |
| 5504 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5505 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5506 | if (context->getClientVersion() < 3) |
| 5507 | { |
| 5508 | return gl::error(GL_INVALID_ENUM); |
| 5509 | } |
| 5510 | *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0); |
| 5511 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5512 | case GL_TEXTURE_USAGE_ANGLE: |
| 5513 | *params = (GLfloat)texture->getUsage(); |
| 5514 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5515 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5516 | if (!context->supportsTextureFilterAnisotropy()) |
| 5517 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5518 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5519 | } |
| 5520 | *params = (GLfloat)texture->getMaxAnisotropy(); |
| 5521 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5522 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5523 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5524 | } |
| 5525 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5526 | } |
| 5527 | catch(std::bad_alloc&) |
| 5528 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5529 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5530 | } |
| 5531 | } |
| 5532 | |
| 5533 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5534 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5535 | 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] | 5536 | |
| 5537 | try |
| 5538 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5539 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5540 | |
| 5541 | if (context) |
| 5542 | { |
| 5543 | gl::Texture *texture; |
| 5544 | |
| 5545 | switch (target) |
| 5546 | { |
| 5547 | case GL_TEXTURE_2D: |
| 5548 | texture = context->getTexture2D(); |
| 5549 | break; |
| 5550 | case GL_TEXTURE_CUBE_MAP: |
| 5551 | texture = context->getTextureCubeMap(); |
| 5552 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5553 | case GL_TEXTURE_3D: |
| 5554 | if (context->getClientVersion() < 3) |
| 5555 | { |
| 5556 | return gl::error(GL_INVALID_ENUM); |
| 5557 | } |
| 5558 | texture = context->getTexture3D(); |
| 5559 | break; |
shannonwoods@chromium.org | 0c611d1 | 2013-05-30 00:15:05 +0000 | [diff] [blame] | 5560 | case GL_TEXTURE_2D_ARRAY: |
| 5561 | if (context->getClientVersion() < 3) |
| 5562 | { |
| 5563 | return gl::error(GL_INVALID_ENUM); |
| 5564 | } |
| 5565 | texture = context->getTexture2DArray(); |
| 5566 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5567 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5568 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5569 | } |
| 5570 | |
| 5571 | switch (pname) |
| 5572 | { |
| 5573 | case GL_TEXTURE_MAG_FILTER: |
| 5574 | *params = texture->getMagFilter(); |
| 5575 | break; |
| 5576 | case GL_TEXTURE_MIN_FILTER: |
| 5577 | *params = texture->getMinFilter(); |
| 5578 | break; |
| 5579 | case GL_TEXTURE_WRAP_S: |
| 5580 | *params = texture->getWrapS(); |
| 5581 | break; |
| 5582 | case GL_TEXTURE_WRAP_T: |
| 5583 | *params = texture->getWrapT(); |
| 5584 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5585 | case GL_TEXTURE_WRAP_R: |
| 5586 | if (context->getClientVersion() < 3) |
| 5587 | { |
| 5588 | return gl::error(GL_INVALID_ENUM); |
| 5589 | } |
| 5590 | *params = texture->getWrapR(); |
| 5591 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5592 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5593 | // 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] | 5594 | *params = texture->isImmutable() ? GL_TRUE : GL_FALSE; |
| 5595 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5596 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5597 | if (context->getClientVersion() < 3) |
| 5598 | { |
| 5599 | return gl::error(GL_INVALID_ENUM); |
| 5600 | } |
| 5601 | *params = texture->isImmutable() ? texture->levelCount() : 0; |
| 5602 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5603 | case GL_TEXTURE_USAGE_ANGLE: |
| 5604 | *params = texture->getUsage(); |
| 5605 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5606 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5607 | if (!context->supportsTextureFilterAnisotropy()) |
| 5608 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5609 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5610 | } |
| 5611 | *params = (GLint)texture->getMaxAnisotropy(); |
| 5612 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 5613 | |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5614 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5615 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5616 | } |
| 5617 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5618 | } |
| 5619 | catch(std::bad_alloc&) |
| 5620 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5621 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5622 | } |
| 5623 | } |
| 5624 | |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5625 | void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
| 5626 | { |
| 5627 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)", |
| 5628 | program, location, bufSize, params); |
| 5629 | |
| 5630 | try |
| 5631 | { |
| 5632 | if (bufSize < 0) |
| 5633 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5634 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5635 | } |
| 5636 | |
| 5637 | gl::Context *context = gl::getNonLostContext(); |
| 5638 | |
| 5639 | if (context) |
| 5640 | { |
| 5641 | if (program == 0) |
| 5642 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5643 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5644 | } |
| 5645 | |
| 5646 | gl::Program *programObject = context->getProgram(program); |
| 5647 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5648 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5649 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5650 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5651 | } |
| 5652 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5653 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5654 | if (!programBinary) |
| 5655 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5656 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5657 | } |
| 5658 | |
| 5659 | if (!programBinary->getUniformfv(location, &bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5660 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5661 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5662 | } |
| 5663 | } |
| 5664 | } |
| 5665 | catch(std::bad_alloc&) |
| 5666 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5667 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5668 | } |
| 5669 | } |
| 5670 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5671 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 5672 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5673 | 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] | 5674 | |
| 5675 | try |
| 5676 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5677 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5678 | |
| 5679 | if (context) |
| 5680 | { |
| 5681 | if (program == 0) |
| 5682 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5683 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5684 | } |
| 5685 | |
| 5686 | gl::Program *programObject = context->getProgram(program); |
| 5687 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5688 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5689 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5690 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5691 | } |
| 5692 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5693 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5694 | if (!programBinary) |
| 5695 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5696 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5697 | } |
| 5698 | |
| 5699 | if (!programBinary->getUniformfv(location, NULL, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5700 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5701 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5702 | } |
| 5703 | } |
| 5704 | } |
| 5705 | catch(std::bad_alloc&) |
| 5706 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5707 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5708 | } |
| 5709 | } |
| 5710 | |
| 5711 | void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) |
| 5712 | { |
| 5713 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)", |
| 5714 | program, location, bufSize, params); |
| 5715 | |
| 5716 | try |
| 5717 | { |
| 5718 | if (bufSize < 0) |
| 5719 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5720 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5721 | } |
| 5722 | |
| 5723 | gl::Context *context = gl::getNonLostContext(); |
| 5724 | |
| 5725 | if (context) |
| 5726 | { |
| 5727 | if (program == 0) |
| 5728 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5729 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5730 | } |
| 5731 | |
| 5732 | gl::Program *programObject = context->getProgram(program); |
| 5733 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5734 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5735 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5736 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5737 | } |
| 5738 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5739 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5740 | if (!programBinary) |
| 5741 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5742 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5743 | } |
| 5744 | |
| 5745 | if (!programBinary->getUniformiv(location, &bufSize, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5746 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5747 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5748 | } |
| 5749 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5750 | } |
| 5751 | catch(std::bad_alloc&) |
| 5752 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5753 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5754 | } |
| 5755 | } |
| 5756 | |
| 5757 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 5758 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5759 | 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] | 5760 | |
| 5761 | try |
| 5762 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5763 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5764 | |
| 5765 | if (context) |
| 5766 | { |
| 5767 | if (program == 0) |
| 5768 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5769 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5770 | } |
| 5771 | |
| 5772 | gl::Program *programObject = context->getProgram(program); |
| 5773 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5774 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5775 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5776 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5777 | } |
| 5778 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5779 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5780 | if (!programBinary) |
| 5781 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5782 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5783 | } |
| 5784 | |
| 5785 | if (!programBinary->getUniformiv(location, NULL, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5786 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5787 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5788 | } |
| 5789 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5790 | } |
| 5791 | catch(std::bad_alloc&) |
| 5792 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5793 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5794 | } |
| 5795 | } |
| 5796 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5797 | int __stdcall glGetUniformLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5798 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5799 | 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] | 5800 | |
| 5801 | try |
| 5802 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5803 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5804 | |
| 5805 | if (strstr(name, "gl_") == name) |
| 5806 | { |
| 5807 | return -1; |
| 5808 | } |
| 5809 | |
| 5810 | if (context) |
| 5811 | { |
| 5812 | gl::Program *programObject = context->getProgram(program); |
| 5813 | |
| 5814 | if (!programObject) |
| 5815 | { |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5816 | if (context->getShader(program)) |
| 5817 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5818 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5819 | } |
| 5820 | else |
| 5821 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5822 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5823 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5824 | } |
| 5825 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5826 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5827 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5828 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5829 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5830 | } |
| 5831 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5832 | return programBinary->getUniformLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5833 | } |
| 5834 | } |
| 5835 | catch(std::bad_alloc&) |
| 5836 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5837 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5838 | } |
| 5839 | |
| 5840 | return -1; |
| 5841 | } |
| 5842 | |
| 5843 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 5844 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5845 | 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] | 5846 | |
| 5847 | try |
| 5848 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5849 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5850 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5851 | if (context) |
| 5852 | { |
| 5853 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5854 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5855 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5856 | } |
| 5857 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5858 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5859 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5860 | switch (pname) |
| 5861 | { |
| 5862 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5863 | *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5864 | break; |
| 5865 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5866 | *params = (GLfloat)attribState.mSize; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5867 | break; |
| 5868 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5869 | *params = (GLfloat)attribState.mStride; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5870 | break; |
| 5871 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5872 | *params = (GLfloat)attribState.mType; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5873 | break; |
| 5874 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5875 | *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5876 | break; |
| 5877 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 5878 | *params = (GLfloat)attribState.mBoundBuffer.id(); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5879 | break; |
| 5880 | case GL_CURRENT_VERTEX_ATTRIB: |
| 5881 | for (int i = 0; i < 4; ++i) |
| 5882 | { |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame] | 5883 | params[i] = attribState.mCurrentValue.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5884 | } |
| 5885 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 5886 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 5887 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 5888 | // the same constant. |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 5889 | *params = (GLfloat)attribState.mDivisor; |
| 5890 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5891 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5892 | } |
| 5893 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5894 | } |
| 5895 | catch(std::bad_alloc&) |
| 5896 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5897 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5898 | } |
| 5899 | } |
| 5900 | |
| 5901 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 5902 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5903 | 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] | 5904 | |
| 5905 | try |
| 5906 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5907 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5908 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5909 | if (context) |
| 5910 | { |
| 5911 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5912 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5913 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5914 | } |
| 5915 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5916 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5917 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5918 | switch (pname) |
| 5919 | { |
| 5920 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5921 | *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5922 | break; |
| 5923 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5924 | *params = attribState.mSize; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5925 | break; |
| 5926 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5927 | *params = attribState.mStride; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5928 | break; |
| 5929 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5930 | *params = attribState.mType; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5931 | break; |
| 5932 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5933 | *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5934 | break; |
| 5935 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 5936 | *params = attribState.mBoundBuffer.id(); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5937 | break; |
| 5938 | case GL_CURRENT_VERTEX_ATTRIB: |
| 5939 | for (int i = 0; i < 4; ++i) |
| 5940 | { |
shannon.woods%transgaming.com@gtempaccount.com | 3026dc7 | 2013-04-13 03:37:27 +0000 | [diff] [blame] | 5941 | float currentValue = attribState.mCurrentValue.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5942 | params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f)); |
| 5943 | } |
| 5944 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 5945 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 5946 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 5947 | // the same constant. |
| 5948 | 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] | 5949 | *params = (GLint)attribState.mDivisor; |
| 5950 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5951 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5952 | } |
| 5953 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5954 | } |
| 5955 | catch(std::bad_alloc&) |
| 5956 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5957 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5958 | } |
| 5959 | } |
| 5960 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5961 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5962 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5963 | 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] | 5964 | |
| 5965 | try |
| 5966 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5967 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5968 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5969 | if (context) |
| 5970 | { |
| 5971 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5972 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5973 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5974 | } |
| 5975 | |
| 5976 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) |
| 5977 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5978 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5979 | } |
| 5980 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5981 | *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index)); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5982 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5983 | } |
| 5984 | catch(std::bad_alloc&) |
| 5985 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5986 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5987 | } |
| 5988 | } |
| 5989 | |
| 5990 | void __stdcall glHint(GLenum target, GLenum mode) |
| 5991 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5992 | EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5993 | |
| 5994 | try |
| 5995 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5996 | switch (mode) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 5997 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 5998 | case GL_FASTEST: |
| 5999 | case GL_NICEST: |
| 6000 | case GL_DONT_CARE: |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6001 | break; |
| 6002 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6003 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6004 | } |
| 6005 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6006 | gl::Context *context = gl::getNonLostContext(); |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6007 | switch (target) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6008 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6009 | case GL_GENERATE_MIPMAP_HINT: |
| 6010 | if (context) context->setGenerateMipmapHint(mode); |
| 6011 | break; |
| 6012 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 6013 | if (context) context->setFragmentShaderDerivativeHint(mode); |
| 6014 | break; |
| 6015 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6016 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6017 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6018 | } |
| 6019 | catch(std::bad_alloc&) |
| 6020 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6021 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6022 | } |
| 6023 | } |
| 6024 | |
| 6025 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 6026 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6027 | EVENT("(GLuint buffer = %d)", buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6028 | |
| 6029 | try |
| 6030 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6031 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6032 | |
| 6033 | if (context && buffer) |
| 6034 | { |
| 6035 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 6036 | |
| 6037 | if (bufferObject) |
| 6038 | { |
| 6039 | return GL_TRUE; |
| 6040 | } |
| 6041 | } |
| 6042 | } |
| 6043 | catch(std::bad_alloc&) |
| 6044 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6045 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6046 | } |
| 6047 | |
| 6048 | return GL_FALSE; |
| 6049 | } |
| 6050 | |
| 6051 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 6052 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6053 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6054 | |
| 6055 | try |
| 6056 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6057 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6058 | |
| 6059 | if (context) |
| 6060 | { |
| 6061 | switch (cap) |
| 6062 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6063 | case GL_CULL_FACE: return context->isCullFaceEnabled(); |
| 6064 | case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled(); |
| 6065 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled(); |
| 6066 | case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled(); |
| 6067 | case GL_SCISSOR_TEST: return context->isScissorTestEnabled(); |
| 6068 | case GL_STENCIL_TEST: return context->isStencilTestEnabled(); |
| 6069 | case GL_DEPTH_TEST: return context->isDepthTestEnabled(); |
| 6070 | case GL_BLEND: return context->isBlendEnabled(); |
| 6071 | case GL_DITHER: return context->isDitherEnabled(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6072 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6073 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6074 | } |
| 6075 | } |
| 6076 | } |
| 6077 | catch(std::bad_alloc&) |
| 6078 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6079 | return gl::error(GL_OUT_OF_MEMORY, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6080 | } |
| 6081 | |
| 6082 | return false; |
| 6083 | } |
| 6084 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6085 | GLboolean __stdcall glIsFenceNV(GLuint fence) |
| 6086 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6087 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6088 | |
| 6089 | try |
| 6090 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6091 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6092 | |
| 6093 | if (context) |
| 6094 | { |
| 6095 | gl::Fence *fenceObject = context->getFence(fence); |
| 6096 | |
| 6097 | if (fenceObject == NULL) |
| 6098 | { |
| 6099 | return GL_FALSE; |
| 6100 | } |
| 6101 | |
| 6102 | return fenceObject->isFence(); |
| 6103 | } |
| 6104 | } |
| 6105 | catch(std::bad_alloc&) |
| 6106 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6107 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6108 | } |
| 6109 | |
| 6110 | return GL_FALSE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6111 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6112 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6113 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 6114 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6115 | EVENT("(GLuint framebuffer = %d)", framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6116 | |
| 6117 | try |
| 6118 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6119 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6120 | |
| 6121 | if (context && framebuffer) |
| 6122 | { |
| 6123 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 6124 | |
| 6125 | if (framebufferObject) |
| 6126 | { |
| 6127 | return GL_TRUE; |
| 6128 | } |
| 6129 | } |
| 6130 | } |
| 6131 | catch(std::bad_alloc&) |
| 6132 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6133 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6134 | } |
| 6135 | |
| 6136 | return GL_FALSE; |
| 6137 | } |
| 6138 | |
| 6139 | GLboolean __stdcall glIsProgram(GLuint program) |
| 6140 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6141 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6142 | |
| 6143 | try |
| 6144 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6145 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6146 | |
| 6147 | if (context && program) |
| 6148 | { |
| 6149 | gl::Program *programObject = context->getProgram(program); |
| 6150 | |
| 6151 | if (programObject) |
| 6152 | { |
| 6153 | return GL_TRUE; |
| 6154 | } |
| 6155 | } |
| 6156 | } |
| 6157 | catch(std::bad_alloc&) |
| 6158 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6159 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6160 | } |
| 6161 | |
| 6162 | return GL_FALSE; |
| 6163 | } |
| 6164 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 6165 | GLboolean __stdcall glIsQueryEXT(GLuint id) |
| 6166 | { |
| 6167 | EVENT("(GLuint id = %d)", id); |
| 6168 | |
| 6169 | try |
| 6170 | { |
| 6171 | if (id == 0) |
| 6172 | { |
| 6173 | return GL_FALSE; |
| 6174 | } |
| 6175 | |
| 6176 | gl::Context *context = gl::getNonLostContext(); |
| 6177 | |
| 6178 | if (context) |
| 6179 | { |
| 6180 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 6181 | |
| 6182 | if (queryObject) |
| 6183 | { |
| 6184 | return GL_TRUE; |
| 6185 | } |
| 6186 | } |
| 6187 | } |
| 6188 | catch(std::bad_alloc&) |
| 6189 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6190 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 6191 | } |
| 6192 | |
| 6193 | return GL_FALSE; |
| 6194 | } |
| 6195 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6196 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 6197 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6198 | EVENT("(GLuint renderbuffer = %d)", renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6199 | |
| 6200 | try |
| 6201 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6202 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6203 | |
| 6204 | if (context && renderbuffer) |
| 6205 | { |
| 6206 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 6207 | |
| 6208 | if (renderbufferObject) |
| 6209 | { |
| 6210 | return GL_TRUE; |
| 6211 | } |
| 6212 | } |
| 6213 | } |
| 6214 | catch(std::bad_alloc&) |
| 6215 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6216 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6217 | } |
| 6218 | |
| 6219 | return GL_FALSE; |
| 6220 | } |
| 6221 | |
| 6222 | GLboolean __stdcall glIsShader(GLuint shader) |
| 6223 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6224 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6225 | |
| 6226 | try |
| 6227 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6228 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6229 | |
| 6230 | if (context && shader) |
| 6231 | { |
| 6232 | gl::Shader *shaderObject = context->getShader(shader); |
| 6233 | |
| 6234 | if (shaderObject) |
| 6235 | { |
| 6236 | return GL_TRUE; |
| 6237 | } |
| 6238 | } |
| 6239 | } |
| 6240 | catch(std::bad_alloc&) |
| 6241 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6242 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6243 | } |
| 6244 | |
| 6245 | return GL_FALSE; |
| 6246 | } |
| 6247 | |
| 6248 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 6249 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6250 | EVENT("(GLuint texture = %d)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6251 | |
| 6252 | try |
| 6253 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6254 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6255 | |
| 6256 | if (context && texture) |
| 6257 | { |
| 6258 | gl::Texture *textureObject = context->getTexture(texture); |
| 6259 | |
| 6260 | if (textureObject) |
| 6261 | { |
| 6262 | return GL_TRUE; |
| 6263 | } |
| 6264 | } |
| 6265 | } |
| 6266 | catch(std::bad_alloc&) |
| 6267 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6268 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6269 | } |
| 6270 | |
| 6271 | return GL_FALSE; |
| 6272 | } |
| 6273 | |
| 6274 | void __stdcall glLineWidth(GLfloat width) |
| 6275 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6276 | EVENT("(GLfloat width = %f)", width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6277 | |
| 6278 | try |
| 6279 | { |
| 6280 | if (width <= 0.0f) |
| 6281 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6282 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6283 | } |
| 6284 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6285 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 6286 | |
| 6287 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6288 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6289 | context->setLineWidth(width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6290 | } |
| 6291 | } |
| 6292 | catch(std::bad_alloc&) |
| 6293 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6294 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6295 | } |
| 6296 | } |
| 6297 | |
| 6298 | void __stdcall glLinkProgram(GLuint program) |
| 6299 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6300 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6301 | |
| 6302 | try |
| 6303 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6304 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6305 | |
| 6306 | if (context) |
| 6307 | { |
| 6308 | gl::Program *programObject = context->getProgram(program); |
| 6309 | |
| 6310 | if (!programObject) |
| 6311 | { |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6312 | if (context->getShader(program)) |
| 6313 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6314 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6315 | } |
| 6316 | else |
| 6317 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6318 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6319 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6320 | } |
| 6321 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 6322 | context->linkProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6323 | } |
| 6324 | } |
| 6325 | catch(std::bad_alloc&) |
| 6326 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6327 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6328 | } |
| 6329 | } |
| 6330 | |
| 6331 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 6332 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6333 | EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6334 | |
| 6335 | try |
| 6336 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6337 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6338 | |
| 6339 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6340 | { |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6341 | switch (pname) |
| 6342 | { |
| 6343 | case GL_UNPACK_ALIGNMENT: |
| 6344 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6345 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6346 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6347 | } |
| 6348 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6349 | context->setUnpackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6350 | break; |
| 6351 | |
| 6352 | case GL_PACK_ALIGNMENT: |
| 6353 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6354 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6355 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6356 | } |
| 6357 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6358 | context->setPackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6359 | break; |
| 6360 | |
bsalomon@google.com | 56d46ab | 2011-11-23 14:53:10 +0000 | [diff] [blame] | 6361 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 6362 | context->setPackReverseRowOrder(param != 0); |
| 6363 | break; |
| 6364 | |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6365 | case GL_UNPACK_IMAGE_HEIGHT: |
| 6366 | case GL_UNPACK_SKIP_IMAGES: |
| 6367 | case GL_UNPACK_ROW_LENGTH: |
| 6368 | case GL_UNPACK_SKIP_ROWS: |
| 6369 | case GL_UNPACK_SKIP_PIXELS: |
| 6370 | case GL_PACK_ROW_LENGTH: |
| 6371 | case GL_PACK_SKIP_ROWS: |
| 6372 | case GL_PACK_SKIP_PIXELS: |
| 6373 | if (context->getClientVersion() < 3) |
| 6374 | { |
| 6375 | return gl::error(GL_INVALID_ENUM); |
| 6376 | } |
| 6377 | UNIMPLEMENTED(); |
| 6378 | break; |
| 6379 | |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6380 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6381 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6382 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6383 | } |
| 6384 | } |
| 6385 | catch(std::bad_alloc&) |
| 6386 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6387 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6388 | } |
| 6389 | } |
| 6390 | |
| 6391 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 6392 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6393 | EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6394 | |
| 6395 | try |
| 6396 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6397 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aede630 | 2010-04-29 03:35:48 +0000 | [diff] [blame] | 6398 | |
| 6399 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6400 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6401 | context->setPolygonOffsetParams(factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6402 | } |
| 6403 | } |
| 6404 | catch(std::bad_alloc&) |
| 6405 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6406 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6407 | } |
| 6408 | } |
| 6409 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6410 | void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6411 | GLenum format, GLenum type, GLsizei bufSize, |
| 6412 | GLvoid *data) |
| 6413 | { |
| 6414 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
| 6415 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)", |
| 6416 | x, y, width, height, format, type, bufSize, data); |
| 6417 | |
| 6418 | try |
| 6419 | { |
| 6420 | if (width < 0 || height < 0 || bufSize < 0) |
| 6421 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6422 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6423 | } |
| 6424 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6425 | gl::Context *context = gl::getNonLostContext(); |
| 6426 | |
| 6427 | if (context) |
| 6428 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6429 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6430 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6431 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6432 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6433 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6434 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6435 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6436 | return; |
| 6437 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6438 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6439 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6440 | |
| 6441 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6442 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6443 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6444 | } |
| 6445 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6446 | context->readPixels(x, y, width, height, format, type, &bufSize, data); |
| 6447 | } |
| 6448 | } |
| 6449 | catch(std::bad_alloc&) |
| 6450 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6451 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6452 | } |
| 6453 | } |
| 6454 | |
| 6455 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6456 | GLenum format, GLenum type, GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6457 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6458 | 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] | 6459 | "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] | 6460 | x, y, width, height, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6461 | |
| 6462 | try |
| 6463 | { |
| 6464 | if (width < 0 || height < 0) |
| 6465 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6466 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6467 | } |
| 6468 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6469 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6470 | |
| 6471 | if (context) |
| 6472 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6473 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6474 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6475 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6476 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6477 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6478 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6479 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6480 | return; |
| 6481 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6482 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6483 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6484 | |
| 6485 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6486 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6487 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6488 | } |
| 6489 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6490 | context->readPixels(x, y, width, height, format, type, NULL, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6491 | } |
| 6492 | } |
| 6493 | catch(std::bad_alloc&) |
| 6494 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6495 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6496 | } |
| 6497 | } |
| 6498 | |
| 6499 | void __stdcall glReleaseShaderCompiler(void) |
| 6500 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6501 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6502 | |
| 6503 | try |
| 6504 | { |
| 6505 | gl::Shader::releaseCompiler(); |
| 6506 | } |
| 6507 | catch(std::bad_alloc&) |
| 6508 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6509 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6510 | } |
| 6511 | } |
| 6512 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6513 | 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] | 6514 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6515 | 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] | 6516 | target, samples, internalformat, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6517 | |
| 6518 | try |
| 6519 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6520 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6521 | |
| 6522 | if (context) |
| 6523 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6524 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 6525 | width, height, true)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6526 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6527 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6528 | } |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 6529 | |
| 6530 | context->setRenderbufferStorage(width, height, internalformat, samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6531 | } |
| 6532 | } |
| 6533 | catch(std::bad_alloc&) |
| 6534 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6535 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6536 | } |
| 6537 | } |
| 6538 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6539 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 6540 | { |
| 6541 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height); |
| 6542 | } |
| 6543 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6544 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 6545 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6546 | EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6547 | |
| 6548 | try |
| 6549 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6550 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6551 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6552 | if (context) |
| 6553 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 6554 | context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6555 | } |
| 6556 | } |
| 6557 | catch(std::bad_alloc&) |
| 6558 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6559 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6560 | } |
| 6561 | } |
| 6562 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6563 | void __stdcall glSetFenceNV(GLuint fence, GLenum condition) |
| 6564 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6565 | EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6566 | |
| 6567 | try |
| 6568 | { |
| 6569 | if (condition != GL_ALL_COMPLETED_NV) |
| 6570 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6571 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6572 | } |
| 6573 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6574 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6575 | |
| 6576 | if (context) |
| 6577 | { |
| 6578 | gl::Fence *fenceObject = context->getFence(fence); |
| 6579 | |
| 6580 | if (fenceObject == NULL) |
| 6581 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6582 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6583 | } |
| 6584 | |
| 6585 | fenceObject->setFence(condition); |
| 6586 | } |
| 6587 | } |
| 6588 | catch(std::bad_alloc&) |
| 6589 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6590 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6591 | } |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6592 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6593 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6594 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 6595 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6596 | 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] | 6597 | |
| 6598 | try |
| 6599 | { |
| 6600 | if (width < 0 || height < 0) |
| 6601 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6602 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6603 | } |
| 6604 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6605 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6606 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6607 | if (context) |
| 6608 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6609 | context->setScissorParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6610 | } |
| 6611 | } |
| 6612 | catch(std::bad_alloc&) |
| 6613 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6614 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6615 | } |
| 6616 | } |
| 6617 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6618 | 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] | 6619 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6620 | 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] | 6621 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 6622 | n, shaders, binaryformat, binary, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6623 | |
| 6624 | try |
| 6625 | { |
daniel@transgaming.com | d1f667f | 2010-04-29 03:38:52 +0000 | [diff] [blame] | 6626 | // No binary shader formats are supported. |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6627 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6628 | } |
| 6629 | catch(std::bad_alloc&) |
| 6630 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6631 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6632 | } |
| 6633 | } |
| 6634 | |
shannon.woods%transgaming.com@gtempaccount.com | 5f33933 | 2013-04-13 03:29:02 +0000 | [diff] [blame] | 6635 | 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] | 6636 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6637 | 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] | 6638 | shader, count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6639 | |
| 6640 | try |
| 6641 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6642 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6643 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6644 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6645 | } |
| 6646 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6647 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6648 | |
| 6649 | if (context) |
| 6650 | { |
| 6651 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6652 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6653 | if (!shaderObject) |
| 6654 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6655 | if (context->getProgram(shader)) |
| 6656 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6657 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6658 | } |
| 6659 | else |
| 6660 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6661 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6662 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6663 | } |
| 6664 | |
| 6665 | shaderObject->setSource(count, string, length); |
| 6666 | } |
| 6667 | } |
| 6668 | catch(std::bad_alloc&) |
| 6669 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6670 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6671 | } |
| 6672 | } |
| 6673 | |
| 6674 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 6675 | { |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6676 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6677 | } |
| 6678 | |
| 6679 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 6680 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6681 | 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] | 6682 | |
| 6683 | try |
| 6684 | { |
| 6685 | switch (face) |
| 6686 | { |
| 6687 | case GL_FRONT: |
| 6688 | case GL_BACK: |
| 6689 | case GL_FRONT_AND_BACK: |
| 6690 | break; |
| 6691 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6692 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6693 | } |
| 6694 | |
| 6695 | switch (func) |
| 6696 | { |
| 6697 | case GL_NEVER: |
| 6698 | case GL_ALWAYS: |
| 6699 | case GL_LESS: |
| 6700 | case GL_LEQUAL: |
| 6701 | case GL_EQUAL: |
| 6702 | case GL_GEQUAL: |
| 6703 | case GL_GREATER: |
| 6704 | case GL_NOTEQUAL: |
| 6705 | break; |
| 6706 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6707 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6708 | } |
| 6709 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6710 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6711 | |
| 6712 | if (context) |
| 6713 | { |
| 6714 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6715 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6716 | context->setStencilParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6717 | } |
| 6718 | |
| 6719 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6720 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6721 | context->setStencilBackParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6722 | } |
| 6723 | } |
| 6724 | } |
| 6725 | catch(std::bad_alloc&) |
| 6726 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6727 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6728 | } |
| 6729 | } |
| 6730 | |
| 6731 | void __stdcall glStencilMask(GLuint mask) |
| 6732 | { |
| 6733 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 6734 | } |
| 6735 | |
| 6736 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 6737 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6738 | EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6739 | |
| 6740 | try |
| 6741 | { |
| 6742 | switch (face) |
| 6743 | { |
| 6744 | case GL_FRONT: |
| 6745 | case GL_BACK: |
| 6746 | case GL_FRONT_AND_BACK: |
| 6747 | break; |
| 6748 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6749 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6750 | } |
| 6751 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6752 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6753 | |
| 6754 | if (context) |
| 6755 | { |
| 6756 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6757 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6758 | context->setStencilWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6759 | } |
| 6760 | |
| 6761 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6762 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6763 | context->setStencilBackWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6764 | } |
| 6765 | } |
| 6766 | } |
| 6767 | catch(std::bad_alloc&) |
| 6768 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6769 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6770 | } |
| 6771 | } |
| 6772 | |
| 6773 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 6774 | { |
| 6775 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 6776 | } |
| 6777 | |
| 6778 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 6779 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6780 | 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] | 6781 | face, fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6782 | |
| 6783 | try |
| 6784 | { |
| 6785 | switch (face) |
| 6786 | { |
| 6787 | case GL_FRONT: |
| 6788 | case GL_BACK: |
| 6789 | case GL_FRONT_AND_BACK: |
| 6790 | break; |
| 6791 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6792 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6793 | } |
| 6794 | |
| 6795 | switch (fail) |
| 6796 | { |
| 6797 | case GL_ZERO: |
| 6798 | case GL_KEEP: |
| 6799 | case GL_REPLACE: |
| 6800 | case GL_INCR: |
| 6801 | case GL_DECR: |
| 6802 | case GL_INVERT: |
| 6803 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6804 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6805 | break; |
| 6806 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6807 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6808 | } |
| 6809 | |
| 6810 | switch (zfail) |
| 6811 | { |
| 6812 | case GL_ZERO: |
| 6813 | case GL_KEEP: |
| 6814 | case GL_REPLACE: |
| 6815 | case GL_INCR: |
| 6816 | case GL_DECR: |
| 6817 | case GL_INVERT: |
| 6818 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6819 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6820 | break; |
| 6821 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6822 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6823 | } |
| 6824 | |
| 6825 | switch (zpass) |
| 6826 | { |
| 6827 | case GL_ZERO: |
| 6828 | case GL_KEEP: |
| 6829 | case GL_REPLACE: |
| 6830 | case GL_INCR: |
| 6831 | case GL_DECR: |
| 6832 | case GL_INVERT: |
| 6833 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6834 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6835 | break; |
| 6836 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6837 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6838 | } |
| 6839 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6840 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6841 | |
| 6842 | if (context) |
| 6843 | { |
| 6844 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6845 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6846 | context->setStencilOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6847 | } |
| 6848 | |
| 6849 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6850 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6851 | context->setStencilBackOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6852 | } |
| 6853 | } |
| 6854 | } |
| 6855 | catch(std::bad_alloc&) |
| 6856 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6857 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6858 | } |
| 6859 | } |
| 6860 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6861 | GLboolean __stdcall glTestFenceNV(GLuint fence) |
| 6862 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6863 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6864 | |
| 6865 | try |
| 6866 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6867 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6868 | |
| 6869 | if (context) |
| 6870 | { |
| 6871 | gl::Fence *fenceObject = context->getFence(fence); |
| 6872 | |
| 6873 | if (fenceObject == NULL) |
| 6874 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6875 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6876 | } |
| 6877 | |
| 6878 | return fenceObject->testFence(); |
| 6879 | } |
| 6880 | } |
| 6881 | catch(std::bad_alloc&) |
| 6882 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6883 | gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6884 | } |
| 6885 | |
| 6886 | return GL_TRUE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6887 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6888 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6889 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, |
| 6890 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6891 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6892 | 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] | 6893 | "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] | 6894 | target, level, internalformat, width, height, border, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6895 | |
| 6896 | try |
| 6897 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6898 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6899 | |
| 6900 | if (context) |
| 6901 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6902 | if (context->getClientVersion() < 3 && |
| 6903 | !validateES2TexImageParameters(context, target, level, internalformat, false, false, |
| 6904 | 0, 0, width, height, border, format, type, pixels)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 6905 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6906 | return; |
| 6907 | } |
| 6908 | |
| 6909 | if (context->getClientVersion() >= 3 && |
| 6910 | !validateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 6911 | 0, 0, 0, width, height, 1, border, format, type)) |
| 6912 | { |
| 6913 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 6914 | } |
| 6915 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6916 | switch (target) |
| 6917 | { |
| 6918 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6919 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6920 | gl::Texture2D *texture = context->getTexture2D(); |
| 6921 | texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6922 | } |
| 6923 | break; |
| 6924 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6925 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6926 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 6927 | texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6928 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6929 | break; |
| 6930 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 6931 | { |
| 6932 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6933 | texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6934 | } |
| 6935 | break; |
| 6936 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 6937 | { |
| 6938 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6939 | texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6940 | } |
| 6941 | break; |
| 6942 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 6943 | { |
| 6944 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6945 | texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6946 | } |
| 6947 | break; |
| 6948 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 6949 | { |
| 6950 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6951 | texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6952 | } |
| 6953 | break; |
| 6954 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 6955 | { |
| 6956 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6957 | texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6958 | } |
| 6959 | break; |
| 6960 | default: UNREACHABLE(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6961 | } |
| 6962 | } |
| 6963 | } |
| 6964 | catch(std::bad_alloc&) |
| 6965 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6966 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6967 | } |
| 6968 | } |
| 6969 | |
| 6970 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 6971 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6972 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param); |
| 6973 | |
| 6974 | try |
| 6975 | { |
| 6976 | gl::Context *context = gl::getNonLostContext(); |
| 6977 | |
| 6978 | if (context) |
| 6979 | { |
| 6980 | gl::Texture *texture; |
| 6981 | |
| 6982 | switch (target) |
| 6983 | { |
| 6984 | case GL_TEXTURE_2D: |
| 6985 | texture = context->getTexture2D(); |
| 6986 | break; |
| 6987 | case GL_TEXTURE_CUBE_MAP: |
| 6988 | texture = context->getTextureCubeMap(); |
| 6989 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 6990 | case GL_TEXTURE_3D: |
| 6991 | if (context->getClientVersion() < 3) |
| 6992 | { |
| 6993 | return gl::error(GL_INVALID_ENUM); |
| 6994 | } |
| 6995 | texture = context->getTexture3D(); |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 6996 | case GL_TEXTURE_2D_ARRAY: |
| 6997 | if (context->getClientVersion() < 3) |
| 6998 | { |
| 6999 | return gl::error(GL_INVALID_ENUM); |
| 7000 | } |
| 7001 | texture = context->getTexture2DArray(); |
| 7002 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7003 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7004 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7005 | } |
| 7006 | |
| 7007 | switch (pname) |
| 7008 | { |
| 7009 | case GL_TEXTURE_WRAP_S: |
| 7010 | if (!texture->setWrapS((GLenum)param)) |
| 7011 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7012 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7013 | } |
| 7014 | break; |
| 7015 | case GL_TEXTURE_WRAP_T: |
| 7016 | if (!texture->setWrapT((GLenum)param)) |
| 7017 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7018 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7019 | } |
| 7020 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 7021 | case GL_TEXTURE_WRAP_R: |
| 7022 | if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param)) |
| 7023 | { |
| 7024 | return gl::error(GL_INVALID_ENUM); |
| 7025 | } |
| 7026 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7027 | case GL_TEXTURE_MIN_FILTER: |
| 7028 | if (!texture->setMinFilter((GLenum)param)) |
| 7029 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7030 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7031 | } |
| 7032 | break; |
| 7033 | case GL_TEXTURE_MAG_FILTER: |
| 7034 | if (!texture->setMagFilter((GLenum)param)) |
| 7035 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7036 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7037 | } |
| 7038 | break; |
| 7039 | case GL_TEXTURE_USAGE_ANGLE: |
| 7040 | if (!texture->setUsage((GLenum)param)) |
| 7041 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7042 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7043 | } |
| 7044 | break; |
| 7045 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 7046 | if (!context->supportsTextureFilterAnisotropy()) |
| 7047 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7048 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7049 | } |
| 7050 | if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy())) |
| 7051 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7052 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7053 | } |
| 7054 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7055 | |
| 7056 | case GL_TEXTURE_MIN_LOD: |
| 7057 | case GL_TEXTURE_MAX_LOD: |
| 7058 | if (context->getClientVersion() < 3) |
| 7059 | { |
| 7060 | return gl::error(GL_INVALID_ENUM); |
| 7061 | } |
| 7062 | UNIMPLEMENTED(); |
| 7063 | break; |
| 7064 | |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7065 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7066 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7067 | } |
| 7068 | } |
| 7069 | } |
| 7070 | catch(std::bad_alloc&) |
| 7071 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7072 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7073 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7074 | } |
| 7075 | |
| 7076 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 7077 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7078 | glTexParameterf(target, pname, (GLfloat)*params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7079 | } |
| 7080 | |
| 7081 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 7082 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7083 | 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] | 7084 | |
| 7085 | try |
| 7086 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7087 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7088 | |
| 7089 | if (context) |
| 7090 | { |
| 7091 | gl::Texture *texture; |
| 7092 | |
| 7093 | switch (target) |
| 7094 | { |
| 7095 | case GL_TEXTURE_2D: |
| 7096 | texture = context->getTexture2D(); |
| 7097 | break; |
| 7098 | case GL_TEXTURE_CUBE_MAP: |
| 7099 | texture = context->getTextureCubeMap(); |
| 7100 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 7101 | case GL_TEXTURE_3D: |
| 7102 | if (context->getClientVersion() < 3) |
| 7103 | { |
| 7104 | return gl::error(GL_INVALID_ENUM); |
| 7105 | } |
| 7106 | texture = context->getTexture3D(); |
| 7107 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 7108 | case GL_TEXTURE_2D_ARRAY: |
| 7109 | if (context->getClientVersion() < 3) |
| 7110 | { |
| 7111 | return gl::error(GL_INVALID_ENUM); |
| 7112 | } |
| 7113 | texture = context->getTexture2DArray(); |
| 7114 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7115 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7116 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7117 | } |
| 7118 | |
| 7119 | switch (pname) |
| 7120 | { |
| 7121 | case GL_TEXTURE_WRAP_S: |
| 7122 | if (!texture->setWrapS((GLenum)param)) |
| 7123 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7124 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7125 | } |
| 7126 | break; |
| 7127 | case GL_TEXTURE_WRAP_T: |
| 7128 | if (!texture->setWrapT((GLenum)param)) |
| 7129 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7130 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7131 | } |
| 7132 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 7133 | case GL_TEXTURE_WRAP_R: |
| 7134 | if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param)) |
| 7135 | { |
| 7136 | return gl::error(GL_INVALID_ENUM); |
| 7137 | } |
| 7138 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7139 | case GL_TEXTURE_MIN_FILTER: |
| 7140 | if (!texture->setMinFilter((GLenum)param)) |
| 7141 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7142 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7143 | } |
| 7144 | break; |
| 7145 | case GL_TEXTURE_MAG_FILTER: |
| 7146 | if (!texture->setMagFilter((GLenum)param)) |
| 7147 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7148 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7149 | } |
| 7150 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 7151 | case GL_TEXTURE_USAGE_ANGLE: |
| 7152 | if (!texture->setUsage((GLenum)param)) |
| 7153 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7154 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 7155 | } |
| 7156 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7157 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 7158 | if (!context->supportsTextureFilterAnisotropy()) |
| 7159 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7160 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7161 | } |
| 7162 | if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy())) |
| 7163 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7164 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7165 | } |
| 7166 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7167 | |
| 7168 | case GL_TEXTURE_SWIZZLE_R: |
| 7169 | case GL_TEXTURE_SWIZZLE_G: |
| 7170 | case GL_TEXTURE_SWIZZLE_B: |
| 7171 | case GL_TEXTURE_SWIZZLE_A: |
| 7172 | case GL_TEXTURE_BASE_LEVEL: |
| 7173 | case GL_TEXTURE_MAX_LEVEL: |
| 7174 | case GL_TEXTURE_COMPARE_MODE: |
| 7175 | case GL_TEXTURE_COMPARE_FUNC: |
| 7176 | if (context->getClientVersion() < 3) |
| 7177 | { |
| 7178 | return gl::error(GL_INVALID_ENUM); |
| 7179 | } |
| 7180 | UNIMPLEMENTED(); |
| 7181 | break; |
| 7182 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7183 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7184 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7185 | } |
| 7186 | } |
| 7187 | } |
| 7188 | catch(std::bad_alloc&) |
| 7189 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7190 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7191 | } |
| 7192 | } |
| 7193 | |
| 7194 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 7195 | { |
| 7196 | glTexParameteri(target, pname, *params); |
| 7197 | } |
| 7198 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7199 | void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 7200 | { |
| 7201 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 7202 | target, levels, internalformat, width, height); |
| 7203 | |
| 7204 | try |
| 7205 | { |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7206 | gl::Context *context = gl::getNonLostContext(); |
| 7207 | |
| 7208 | if (context) |
| 7209 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7210 | if (context->getClientVersion() < 3 && |
| 7211 | !validateES2TexStorageParameters(context, target, levels, internalformat, width, height)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7212 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7213 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7214 | } |
| 7215 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7216 | if (context->getClientVersion() >= 3 && |
| 7217 | !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7218 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7219 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7220 | } |
| 7221 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7222 | switch (target) |
| 7223 | { |
| 7224 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7225 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7226 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 7227 | texture2d->storage(levels, internalformat, width, height); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7228 | } |
| 7229 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7230 | |
| 7231 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7232 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7233 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7234 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7235 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7236 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7237 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7238 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 7239 | textureCube->storage(levels, internalformat, width); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7240 | } |
| 7241 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7242 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7243 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7244 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7245 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7246 | } |
| 7247 | } |
| 7248 | catch(std::bad_alloc&) |
| 7249 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7250 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7251 | } |
| 7252 | } |
| 7253 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7254 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 7255 | GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7256 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7257 | 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] | 7258 | "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] | 7259 | "const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7260 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 7261 | |
| 7262 | try |
| 7263 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7264 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7265 | |
| 7266 | if (context) |
| 7267 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7268 | if (context->getClientVersion() < 3 && |
| 7269 | !validateES2TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7270 | 0, 0, width, height, 0, format, type, pixels)) |
daniel@transgaming.com | 1d2d3c4 | 2012-05-31 01:14:15 +0000 | [diff] [blame] | 7271 | { |
| 7272 | return; |
| 7273 | } |
| 7274 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7275 | if (context->getClientVersion() >= 3 && |
| 7276 | !validateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7277 | 0, 0, 0, width, height, 1, 0, format, type)) |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7278 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7279 | return; |
| 7280 | } |
| 7281 | |
| 7282 | switch (target) |
| 7283 | { |
| 7284 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7285 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7286 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7287 | 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] | 7288 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7289 | break; |
| 7290 | |
| 7291 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7292 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7293 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7294 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7295 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7296 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7297 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7298 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7299 | 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] | 7300 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7301 | break; |
| 7302 | |
| 7303 | default: |
| 7304 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7305 | } |
| 7306 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7307 | } |
| 7308 | catch(std::bad_alloc&) |
| 7309 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7310 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7311 | } |
| 7312 | } |
| 7313 | |
| 7314 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 7315 | { |
| 7316 | glUniform1fv(location, 1, &x); |
| 7317 | } |
| 7318 | |
| 7319 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 7320 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7321 | 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] | 7322 | |
| 7323 | try |
| 7324 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7325 | if (count < 0) |
| 7326 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7327 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7328 | } |
| 7329 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7330 | if (location == -1) |
| 7331 | { |
| 7332 | return; |
| 7333 | } |
| 7334 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7335 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7336 | |
| 7337 | if (context) |
| 7338 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7339 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7340 | if (!programBinary) |
| 7341 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7342 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7343 | } |
| 7344 | |
| 7345 | if (!programBinary->setUniform1fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7346 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7347 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7348 | } |
| 7349 | } |
| 7350 | } |
| 7351 | catch(std::bad_alloc&) |
| 7352 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7353 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7354 | } |
| 7355 | } |
| 7356 | |
| 7357 | void __stdcall glUniform1i(GLint location, GLint x) |
| 7358 | { |
| 7359 | glUniform1iv(location, 1, &x); |
| 7360 | } |
| 7361 | |
| 7362 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 7363 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7364 | 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] | 7365 | |
| 7366 | try |
| 7367 | { |
| 7368 | if (count < 0) |
| 7369 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7370 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7371 | } |
| 7372 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7373 | if (location == -1) |
| 7374 | { |
| 7375 | return; |
| 7376 | } |
| 7377 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7378 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7379 | |
| 7380 | if (context) |
| 7381 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7382 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7383 | if (!programBinary) |
| 7384 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7385 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7386 | } |
| 7387 | |
| 7388 | if (!programBinary->setUniform1iv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7389 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7390 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7391 | } |
| 7392 | } |
| 7393 | } |
| 7394 | catch(std::bad_alloc&) |
| 7395 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7396 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7397 | } |
| 7398 | } |
| 7399 | |
| 7400 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 7401 | { |
| 7402 | GLfloat xy[2] = {x, y}; |
| 7403 | |
| 7404 | glUniform2fv(location, 1, (GLfloat*)&xy); |
| 7405 | } |
| 7406 | |
| 7407 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 7408 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7409 | 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] | 7410 | |
| 7411 | try |
| 7412 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7413 | if (count < 0) |
| 7414 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7415 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7416 | } |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7417 | |
| 7418 | if (location == -1) |
| 7419 | { |
| 7420 | return; |
| 7421 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7422 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7423 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7424 | |
| 7425 | if (context) |
| 7426 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7427 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7428 | if (!programBinary) |
| 7429 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7430 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7431 | } |
| 7432 | |
| 7433 | if (!programBinary->setUniform2fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7434 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7435 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7436 | } |
| 7437 | } |
| 7438 | } |
| 7439 | catch(std::bad_alloc&) |
| 7440 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7441 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7442 | } |
| 7443 | } |
| 7444 | |
| 7445 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 7446 | { |
| 7447 | GLint xy[4] = {x, y}; |
| 7448 | |
| 7449 | glUniform2iv(location, 1, (GLint*)&xy); |
| 7450 | } |
| 7451 | |
| 7452 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 7453 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7454 | 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] | 7455 | |
| 7456 | try |
| 7457 | { |
| 7458 | if (count < 0) |
| 7459 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7460 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7461 | } |
| 7462 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7463 | if (location == -1) |
| 7464 | { |
| 7465 | return; |
| 7466 | } |
| 7467 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7468 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7469 | |
| 7470 | if (context) |
| 7471 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7472 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7473 | if (!programBinary) |
| 7474 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7475 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7476 | } |
| 7477 | |
| 7478 | if (!programBinary->setUniform2iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7479 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7480 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7481 | } |
| 7482 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7483 | } |
| 7484 | catch(std::bad_alloc&) |
| 7485 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7486 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7487 | } |
| 7488 | } |
| 7489 | |
| 7490 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 7491 | { |
| 7492 | GLfloat xyz[3] = {x, y, z}; |
| 7493 | |
| 7494 | glUniform3fv(location, 1, (GLfloat*)&xyz); |
| 7495 | } |
| 7496 | |
| 7497 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 7498 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7499 | 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] | 7500 | |
| 7501 | try |
| 7502 | { |
| 7503 | if (count < 0) |
| 7504 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7505 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7506 | } |
| 7507 | |
| 7508 | if (location == -1) |
| 7509 | { |
| 7510 | return; |
| 7511 | } |
| 7512 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7513 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7514 | |
| 7515 | if (context) |
| 7516 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7517 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7518 | if (!programBinary) |
| 7519 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7520 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7521 | } |
| 7522 | |
| 7523 | if (!programBinary->setUniform3fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7524 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7525 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7526 | } |
| 7527 | } |
| 7528 | } |
| 7529 | catch(std::bad_alloc&) |
| 7530 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7531 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7532 | } |
| 7533 | } |
| 7534 | |
| 7535 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 7536 | { |
| 7537 | GLint xyz[3] = {x, y, z}; |
| 7538 | |
| 7539 | glUniform3iv(location, 1, (GLint*)&xyz); |
| 7540 | } |
| 7541 | |
| 7542 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 7543 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7544 | 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] | 7545 | |
| 7546 | try |
| 7547 | { |
| 7548 | if (count < 0) |
| 7549 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7550 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7551 | } |
| 7552 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7553 | if (location == -1) |
| 7554 | { |
| 7555 | return; |
| 7556 | } |
| 7557 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7558 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7559 | |
| 7560 | if (context) |
| 7561 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7562 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7563 | if (!programBinary) |
| 7564 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7565 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7566 | } |
| 7567 | |
| 7568 | if (!programBinary->setUniform3iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7569 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7570 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7571 | } |
| 7572 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7573 | } |
| 7574 | catch(std::bad_alloc&) |
| 7575 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7576 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7577 | } |
| 7578 | } |
| 7579 | |
| 7580 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7581 | { |
| 7582 | GLfloat xyzw[4] = {x, y, z, w}; |
| 7583 | |
| 7584 | glUniform4fv(location, 1, (GLfloat*)&xyzw); |
| 7585 | } |
| 7586 | |
| 7587 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 7588 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7589 | 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] | 7590 | |
| 7591 | try |
| 7592 | { |
| 7593 | if (count < 0) |
| 7594 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7595 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7596 | } |
| 7597 | |
| 7598 | if (location == -1) |
| 7599 | { |
| 7600 | return; |
| 7601 | } |
| 7602 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7603 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7604 | |
| 7605 | if (context) |
| 7606 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7607 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7608 | if (!programBinary) |
| 7609 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7610 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7611 | } |
| 7612 | |
| 7613 | if (!programBinary->setUniform4fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7614 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7615 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7616 | } |
| 7617 | } |
| 7618 | } |
| 7619 | catch(std::bad_alloc&) |
| 7620 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7621 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7622 | } |
| 7623 | } |
| 7624 | |
| 7625 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 7626 | { |
| 7627 | GLint xyzw[4] = {x, y, z, w}; |
| 7628 | |
| 7629 | glUniform4iv(location, 1, (GLint*)&xyzw); |
| 7630 | } |
| 7631 | |
| 7632 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 7633 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7634 | 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] | 7635 | |
| 7636 | try |
| 7637 | { |
| 7638 | if (count < 0) |
| 7639 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7640 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7641 | } |
| 7642 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7643 | if (location == -1) |
| 7644 | { |
| 7645 | return; |
| 7646 | } |
| 7647 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7648 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7649 | |
| 7650 | if (context) |
| 7651 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7652 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7653 | if (!programBinary) |
| 7654 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7655 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7656 | } |
| 7657 | |
| 7658 | if (!programBinary->setUniform4iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7659 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7660 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7661 | } |
| 7662 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7663 | } |
| 7664 | catch(std::bad_alloc&) |
| 7665 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7666 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7667 | } |
| 7668 | } |
| 7669 | |
| 7670 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7671 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7672 | 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] | 7673 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7674 | |
| 7675 | try |
| 7676 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7677 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7678 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7679 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7680 | } |
| 7681 | |
| 7682 | if (location == -1) |
| 7683 | { |
| 7684 | return; |
| 7685 | } |
| 7686 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7687 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7688 | |
| 7689 | if (context) |
| 7690 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7691 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7692 | { |
| 7693 | return gl::error(GL_INVALID_VALUE); |
| 7694 | } |
| 7695 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7696 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7697 | if (!programBinary) |
| 7698 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7699 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7700 | } |
| 7701 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7702 | if (!programBinary->setUniformMatrix2fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7703 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7704 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7705 | } |
| 7706 | } |
| 7707 | } |
| 7708 | catch(std::bad_alloc&) |
| 7709 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7710 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7711 | } |
| 7712 | } |
| 7713 | |
| 7714 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7715 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7716 | 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] | 7717 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7718 | |
| 7719 | try |
| 7720 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7721 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7722 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7723 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7724 | } |
| 7725 | |
| 7726 | if (location == -1) |
| 7727 | { |
| 7728 | return; |
| 7729 | } |
| 7730 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7731 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7732 | |
| 7733 | if (context) |
| 7734 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7735 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7736 | { |
| 7737 | return gl::error(GL_INVALID_VALUE); |
| 7738 | } |
| 7739 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7740 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7741 | if (!programBinary) |
| 7742 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7743 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7744 | } |
| 7745 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7746 | if (!programBinary->setUniformMatrix3fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7747 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7748 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7749 | } |
| 7750 | } |
| 7751 | } |
| 7752 | catch(std::bad_alloc&) |
| 7753 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7754 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7755 | } |
| 7756 | } |
| 7757 | |
| 7758 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7759 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7760 | 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] | 7761 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7762 | |
| 7763 | try |
| 7764 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7765 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7766 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7767 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7768 | } |
| 7769 | |
| 7770 | if (location == -1) |
| 7771 | { |
| 7772 | return; |
| 7773 | } |
| 7774 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7775 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7776 | |
| 7777 | if (context) |
| 7778 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7779 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7780 | { |
| 7781 | return gl::error(GL_INVALID_VALUE); |
| 7782 | } |
| 7783 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7784 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7785 | if (!programBinary) |
| 7786 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7787 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7788 | } |
| 7789 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7790 | if (!programBinary->setUniformMatrix4fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7791 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7792 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7793 | } |
| 7794 | } |
| 7795 | } |
| 7796 | catch(std::bad_alloc&) |
| 7797 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7798 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7799 | } |
| 7800 | } |
| 7801 | |
| 7802 | void __stdcall glUseProgram(GLuint program) |
| 7803 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7804 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7805 | |
| 7806 | try |
| 7807 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7808 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7809 | |
| 7810 | if (context) |
| 7811 | { |
| 7812 | gl::Program *programObject = context->getProgram(program); |
| 7813 | |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7814 | if (!programObject && program != 0) |
| 7815 | { |
| 7816 | if (context->getShader(program)) |
| 7817 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7818 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7819 | } |
| 7820 | else |
| 7821 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7822 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7823 | } |
| 7824 | } |
| 7825 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 7826 | if (program != 0 && !programObject->isLinked()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7827 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7828 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7829 | } |
| 7830 | |
| 7831 | context->useProgram(program); |
| 7832 | } |
| 7833 | } |
| 7834 | catch(std::bad_alloc&) |
| 7835 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7836 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7837 | } |
| 7838 | } |
| 7839 | |
| 7840 | void __stdcall glValidateProgram(GLuint program) |
| 7841 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7842 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7843 | |
| 7844 | try |
| 7845 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7846 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7847 | |
| 7848 | if (context) |
| 7849 | { |
| 7850 | gl::Program *programObject = context->getProgram(program); |
| 7851 | |
| 7852 | if (!programObject) |
| 7853 | { |
| 7854 | if (context->getShader(program)) |
| 7855 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7856 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7857 | } |
| 7858 | else |
| 7859 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7860 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7861 | } |
| 7862 | } |
| 7863 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 7864 | programObject->validate(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7865 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7866 | } |
| 7867 | catch(std::bad_alloc&) |
| 7868 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7869 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7870 | } |
| 7871 | } |
| 7872 | |
| 7873 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 7874 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7875 | EVENT("(GLuint index = %d, GLfloat x = %f)", index, x); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7876 | |
| 7877 | try |
| 7878 | { |
| 7879 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7880 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7881 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7882 | } |
| 7883 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7884 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7885 | |
| 7886 | if (context) |
| 7887 | { |
| 7888 | GLfloat vals[4] = { x, 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7889 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7890 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7891 | } |
| 7892 | catch(std::bad_alloc&) |
| 7893 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7894 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7895 | } |
| 7896 | } |
| 7897 | |
| 7898 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 7899 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7900 | 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] | 7901 | |
| 7902 | try |
| 7903 | { |
| 7904 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7905 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7906 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7907 | } |
| 7908 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7909 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7910 | |
| 7911 | if (context) |
| 7912 | { |
| 7913 | GLfloat vals[4] = { values[0], 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7914 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7915 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7916 | } |
| 7917 | catch(std::bad_alloc&) |
| 7918 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7919 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7920 | } |
| 7921 | } |
| 7922 | |
| 7923 | void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 7924 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7925 | 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] | 7926 | |
| 7927 | try |
| 7928 | { |
| 7929 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7930 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7931 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7932 | } |
| 7933 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7934 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7935 | |
| 7936 | if (context) |
| 7937 | { |
| 7938 | GLfloat vals[4] = { x, y, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7939 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7940 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7941 | } |
| 7942 | catch(std::bad_alloc&) |
| 7943 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7944 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7945 | } |
| 7946 | } |
| 7947 | |
| 7948 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 7949 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7950 | 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] | 7951 | |
| 7952 | try |
| 7953 | { |
| 7954 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7955 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7956 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7957 | } |
| 7958 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7959 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7960 | |
| 7961 | if (context) |
| 7962 | { |
| 7963 | 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] | 7964 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7965 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7966 | } |
| 7967 | catch(std::bad_alloc&) |
| 7968 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7969 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7970 | } |
| 7971 | } |
| 7972 | |
| 7973 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 7974 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7975 | 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] | 7976 | |
| 7977 | try |
| 7978 | { |
| 7979 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7980 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7981 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7982 | } |
| 7983 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7984 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7985 | |
| 7986 | if (context) |
| 7987 | { |
| 7988 | GLfloat vals[4] = { x, y, z, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7989 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7990 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7991 | } |
| 7992 | catch(std::bad_alloc&) |
| 7993 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7994 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7995 | } |
| 7996 | } |
| 7997 | |
| 7998 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 7999 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8000 | 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] | 8001 | |
| 8002 | try |
| 8003 | { |
| 8004 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8005 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8006 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8007 | } |
| 8008 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8009 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8010 | |
| 8011 | if (context) |
| 8012 | { |
| 8013 | 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] | 8014 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8015 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8016 | } |
| 8017 | catch(std::bad_alloc&) |
| 8018 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8019 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8020 | } |
| 8021 | } |
| 8022 | |
| 8023 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 8024 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8025 | 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] | 8026 | |
| 8027 | try |
| 8028 | { |
| 8029 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8030 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8031 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8032 | } |
| 8033 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8034 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8035 | |
| 8036 | if (context) |
| 8037 | { |
| 8038 | GLfloat vals[4] = { x, y, z, w }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8039 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8040 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8041 | } |
| 8042 | catch(std::bad_alloc&) |
| 8043 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8044 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8045 | } |
| 8046 | } |
| 8047 | |
| 8048 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 8049 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8050 | 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] | 8051 | |
| 8052 | try |
| 8053 | { |
| 8054 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8055 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8056 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8057 | } |
| 8058 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8059 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8060 | |
| 8061 | if (context) |
| 8062 | { |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8063 | context->setVertexAttribf(index, values); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8064 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8065 | } |
| 8066 | catch(std::bad_alloc&) |
| 8067 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8068 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8069 | } |
| 8070 | } |
| 8071 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8072 | void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
| 8073 | { |
| 8074 | EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor); |
| 8075 | |
| 8076 | try |
| 8077 | { |
| 8078 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8079 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8080 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8081 | } |
| 8082 | |
| 8083 | gl::Context *context = gl::getNonLostContext(); |
| 8084 | |
| 8085 | if (context) |
| 8086 | { |
| 8087 | context->setVertexAttribDivisor(index, divisor); |
| 8088 | } |
| 8089 | } |
| 8090 | catch(std::bad_alloc&) |
| 8091 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8092 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8093 | } |
| 8094 | } |
| 8095 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 8096 | 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] | 8097 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8098 | 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] | 8099 | "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] | 8100 | index, size, type, normalized, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8101 | |
| 8102 | try |
| 8103 | { |
| 8104 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8105 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8106 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8107 | } |
| 8108 | |
| 8109 | if (size < 1 || size > 4) |
| 8110 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8111 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8112 | } |
| 8113 | |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 8114 | gl::Context *context = gl::getNonLostContext(); |
| 8115 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8116 | switch (type) |
| 8117 | { |
| 8118 | case GL_BYTE: |
| 8119 | case GL_UNSIGNED_BYTE: |
| 8120 | case GL_SHORT: |
| 8121 | case GL_UNSIGNED_SHORT: |
| 8122 | case GL_FIXED: |
| 8123 | case GL_FLOAT: |
| 8124 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 8125 | case GL_HALF_FLOAT: |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8126 | case GL_INT: |
| 8127 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 8128 | case GL_INT_2_10_10_10_REV: |
| 8129 | 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] | 8130 | if (context && context->getClientVersion() < 3) |
| 8131 | { |
| 8132 | return gl::error(GL_INVALID_ENUM); |
| 8133 | } |
| 8134 | else |
| 8135 | { |
| 8136 | break; |
| 8137 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8138 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8139 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8140 | } |
| 8141 | |
| 8142 | if (stride < 0) |
| 8143 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8144 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8145 | } |
| 8146 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 8147 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 8148 | { |
| 8149 | return gl::error(GL_INVALID_OPERATION); |
| 8150 | } |
| 8151 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8152 | if (context) |
| 8153 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8de4e6a | 2013-04-13 03:37:44 +0000 | [diff] [blame] | 8154 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, |
| 8155 | normalized == GL_TRUE, false, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8156 | } |
| 8157 | } |
| 8158 | catch(std::bad_alloc&) |
| 8159 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8160 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8161 | } |
| 8162 | } |
| 8163 | |
| 8164 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 8165 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8166 | 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] | 8167 | |
| 8168 | try |
| 8169 | { |
| 8170 | if (width < 0 || height < 0) |
| 8171 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8172 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8173 | } |
| 8174 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8175 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8176 | |
| 8177 | if (context) |
| 8178 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 8179 | context->setViewportParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8180 | } |
| 8181 | } |
| 8182 | catch(std::bad_alloc&) |
| 8183 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8184 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8185 | } |
| 8186 | } |
| 8187 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8188 | // OpenGL ES 3.0 functions |
| 8189 | |
| 8190 | void __stdcall glReadBuffer(GLenum mode) |
| 8191 | { |
| 8192 | EVENT("(GLenum mode = 0x%X)", mode); |
| 8193 | |
| 8194 | try |
| 8195 | { |
| 8196 | gl::Context *context = gl::getNonLostContext(); |
| 8197 | |
| 8198 | if (context) |
| 8199 | { |
| 8200 | if (context->getClientVersion() < 3) |
| 8201 | { |
| 8202 | return gl::error(GL_INVALID_OPERATION); |
| 8203 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8204 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8205 | UNIMPLEMENTED(); |
| 8206 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8207 | } |
| 8208 | catch(std::bad_alloc&) |
| 8209 | { |
| 8210 | return gl::error(GL_OUT_OF_MEMORY); |
| 8211 | } |
| 8212 | } |
| 8213 | |
| 8214 | void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) |
| 8215 | { |
| 8216 | EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, " |
| 8217 | "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices); |
| 8218 | |
| 8219 | try |
| 8220 | { |
| 8221 | gl::Context *context = gl::getNonLostContext(); |
| 8222 | |
| 8223 | if (context) |
| 8224 | { |
| 8225 | if (context->getClientVersion() < 3) |
| 8226 | { |
| 8227 | return gl::error(GL_INVALID_OPERATION); |
| 8228 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8229 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8230 | UNIMPLEMENTED(); |
| 8231 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8232 | } |
| 8233 | catch(std::bad_alloc&) |
| 8234 | { |
| 8235 | return gl::error(GL_OUT_OF_MEMORY); |
| 8236 | } |
| 8237 | } |
| 8238 | |
| 8239 | void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
| 8240 | { |
| 8241 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8242 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " |
| 8243 | "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8244 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 8245 | |
| 8246 | try |
| 8247 | { |
| 8248 | gl::Context *context = gl::getNonLostContext(); |
| 8249 | |
| 8250 | if (context) |
| 8251 | { |
| 8252 | if (context->getClientVersion() < 3) |
| 8253 | { |
| 8254 | return gl::error(GL_INVALID_OPERATION); |
| 8255 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8256 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8257 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8258 | if (!validateES3TexImageParameters(context, target, level, internalformat, false, false, |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8259 | 0, 0, 0, width, height, depth, border, format, type)) |
| 8260 | { |
| 8261 | return; |
| 8262 | } |
| 8263 | |
| 8264 | switch(target) |
| 8265 | { |
| 8266 | case GL_TEXTURE_3D: |
| 8267 | { |
| 8268 | gl::Texture3D *texture = context->getTexture3D(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8269 | 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] | 8270 | } |
| 8271 | break; |
| 8272 | |
| 8273 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8274 | { |
| 8275 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8276 | 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] | 8277 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8278 | break; |
| 8279 | |
| 8280 | default: |
| 8281 | return gl::error(GL_INVALID_ENUM); |
| 8282 | } |
| 8283 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8284 | } |
| 8285 | catch(std::bad_alloc&) |
| 8286 | { |
| 8287 | return gl::error(GL_OUT_OF_MEMORY); |
| 8288 | } |
| 8289 | } |
| 8290 | |
| 8291 | 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) |
| 8292 | { |
| 8293 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8294 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8295 | "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8296 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); |
| 8297 | |
| 8298 | try |
| 8299 | { |
| 8300 | gl::Context *context = gl::getNonLostContext(); |
| 8301 | |
| 8302 | if (context) |
| 8303 | { |
| 8304 | if (context->getClientVersion() < 3) |
| 8305 | { |
| 8306 | return gl::error(GL_INVALID_OPERATION); |
| 8307 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8308 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8309 | if (!pixels) |
| 8310 | { |
| 8311 | return gl::error(GL_INVALID_VALUE); |
| 8312 | } |
| 8313 | |
| 8314 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8315 | 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] | 8316 | xoffset, yoffset, zoffset, width, height, depth, 0, |
| 8317 | format, type)) |
| 8318 | { |
| 8319 | return; |
| 8320 | } |
| 8321 | |
| 8322 | switch(target) |
| 8323 | { |
| 8324 | case GL_TEXTURE_3D: |
| 8325 | { |
| 8326 | gl::Texture3D *texture = context->getTexture3D(); |
| 8327 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8328 | } |
| 8329 | break; |
| 8330 | |
| 8331 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8332 | { |
| 8333 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8334 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8335 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8336 | break; |
| 8337 | |
| 8338 | default: |
| 8339 | return gl::error(GL_INVALID_ENUM); |
| 8340 | } |
| 8341 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8342 | } |
| 8343 | catch(std::bad_alloc&) |
| 8344 | { |
| 8345 | return gl::error(GL_OUT_OF_MEMORY); |
| 8346 | } |
| 8347 | } |
| 8348 | |
| 8349 | void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 8350 | { |
| 8351 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8352 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 8353 | target, level, xoffset, yoffset, zoffset, x, y, width, height); |
| 8354 | |
| 8355 | try |
| 8356 | { |
| 8357 | gl::Context *context = gl::getNonLostContext(); |
| 8358 | |
| 8359 | if (context) |
| 8360 | { |
| 8361 | if (context->getClientVersion() < 3) |
| 8362 | { |
| 8363 | return gl::error(GL_INVALID_OPERATION); |
| 8364 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8365 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8366 | if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset, |
| 8367 | x, y, width, height, 0)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8368 | { |
| 8369 | return; |
| 8370 | } |
| 8371 | |
| 8372 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 8373 | gl::Texture *texture = NULL; |
| 8374 | switch (target) |
| 8375 | { |
| 8376 | case GL_TEXTURE_3D: |
| 8377 | texture = context->getTexture3D(); |
| 8378 | break; |
| 8379 | |
| 8380 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8381 | texture = context->getTexture2DArray(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8382 | break; |
| 8383 | |
| 8384 | default: |
| 8385 | return gl::error(GL_INVALID_ENUM); |
| 8386 | } |
| 8387 | |
| 8388 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer); |
| 8389 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8390 | } |
| 8391 | catch(std::bad_alloc&) |
| 8392 | { |
| 8393 | return gl::error(GL_OUT_OF_MEMORY); |
| 8394 | } |
| 8395 | } |
| 8396 | |
| 8397 | void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) |
| 8398 | { |
| 8399 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8400 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, " |
| 8401 | "const GLvoid* data = 0x%0.8p)", |
| 8402 | target, level, internalformat, width, height, depth, border, imageSize, data); |
| 8403 | |
| 8404 | try |
| 8405 | { |
| 8406 | gl::Context *context = gl::getNonLostContext(); |
| 8407 | |
| 8408 | if (context) |
| 8409 | { |
| 8410 | if (context->getClientVersion() < 3) |
| 8411 | { |
| 8412 | return gl::error(GL_INVALID_OPERATION); |
| 8413 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8414 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8415 | 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] | 8416 | { |
| 8417 | return gl::error(GL_INVALID_VALUE); |
| 8418 | } |
| 8419 | |
| 8420 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8421 | if (!validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 8422 | 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] | 8423 | { |
| 8424 | return; |
| 8425 | } |
| 8426 | |
| 8427 | switch(target) |
| 8428 | { |
| 8429 | case GL_TEXTURE_3D: |
| 8430 | { |
| 8431 | gl::Texture3D *texture = context->getTexture3D(); |
| 8432 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8433 | } |
| 8434 | break; |
| 8435 | |
| 8436 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8437 | { |
| 8438 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8439 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8440 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8441 | break; |
| 8442 | |
| 8443 | default: |
| 8444 | return gl::error(GL_INVALID_ENUM); |
| 8445 | } |
| 8446 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8447 | } |
| 8448 | catch(std::bad_alloc&) |
| 8449 | { |
| 8450 | return gl::error(GL_OUT_OF_MEMORY); |
| 8451 | } |
| 8452 | } |
| 8453 | |
| 8454 | 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) |
| 8455 | { |
| 8456 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8457 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8458 | "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 8459 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); |
| 8460 | |
| 8461 | try |
| 8462 | { |
| 8463 | gl::Context *context = gl::getNonLostContext(); |
| 8464 | |
| 8465 | if (context) |
| 8466 | { |
| 8467 | if (context->getClientVersion() < 3) |
| 8468 | { |
| 8469 | return gl::error(GL_INVALID_OPERATION); |
| 8470 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8471 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8472 | 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] | 8473 | { |
| 8474 | return gl::error(GL_INVALID_VALUE); |
| 8475 | } |
| 8476 | |
| 8477 | if (!data) |
| 8478 | { |
| 8479 | return gl::error(GL_INVALID_VALUE); |
| 8480 | } |
| 8481 | |
| 8482 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8483 | if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 8484 | 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] | 8485 | { |
| 8486 | return; |
| 8487 | } |
| 8488 | |
| 8489 | switch(target) |
| 8490 | { |
| 8491 | case GL_TEXTURE_3D: |
| 8492 | { |
| 8493 | gl::Texture3D *texture = context->getTexture3D(); |
| 8494 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8495 | format, imageSize, data); |
| 8496 | } |
| 8497 | break; |
| 8498 | |
| 8499 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8500 | { |
| 8501 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8502 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8503 | format, imageSize, data); |
| 8504 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8505 | break; |
| 8506 | |
| 8507 | default: |
| 8508 | return gl::error(GL_INVALID_ENUM); |
| 8509 | } |
| 8510 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8511 | } |
| 8512 | catch(std::bad_alloc&) |
| 8513 | { |
| 8514 | return gl::error(GL_OUT_OF_MEMORY); |
| 8515 | } |
| 8516 | } |
| 8517 | |
| 8518 | void __stdcall glGenQueries(GLsizei n, GLuint* ids) |
| 8519 | { |
| 8520 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8521 | |
| 8522 | try |
| 8523 | { |
| 8524 | gl::Context *context = gl::getNonLostContext(); |
| 8525 | |
| 8526 | if (context) |
| 8527 | { |
| 8528 | if (context->getClientVersion() < 3) |
| 8529 | { |
| 8530 | return gl::error(GL_INVALID_OPERATION); |
| 8531 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8532 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8533 | UNIMPLEMENTED(); |
| 8534 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8535 | } |
| 8536 | catch(std::bad_alloc&) |
| 8537 | { |
| 8538 | return gl::error(GL_OUT_OF_MEMORY); |
| 8539 | } |
| 8540 | } |
| 8541 | |
| 8542 | void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids) |
| 8543 | { |
| 8544 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8545 | |
| 8546 | try |
| 8547 | { |
| 8548 | gl::Context *context = gl::getNonLostContext(); |
| 8549 | |
| 8550 | if (context) |
| 8551 | { |
| 8552 | if (context->getClientVersion() < 3) |
| 8553 | { |
| 8554 | return gl::error(GL_INVALID_OPERATION); |
| 8555 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8556 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8557 | UNIMPLEMENTED(); |
| 8558 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8559 | } |
| 8560 | catch(std::bad_alloc&) |
| 8561 | { |
| 8562 | return gl::error(GL_OUT_OF_MEMORY); |
| 8563 | } |
| 8564 | } |
| 8565 | |
| 8566 | GLboolean __stdcall glIsQuery(GLuint id) |
| 8567 | { |
| 8568 | EVENT("(GLuint id = %u)", id); |
| 8569 | |
| 8570 | try |
| 8571 | { |
| 8572 | gl::Context *context = gl::getNonLostContext(); |
| 8573 | |
| 8574 | if (context) |
| 8575 | { |
| 8576 | if (context->getClientVersion() < 3) |
| 8577 | { |
| 8578 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8579 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8580 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8581 | UNIMPLEMENTED(); |
| 8582 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8583 | } |
| 8584 | catch(std::bad_alloc&) |
| 8585 | { |
| 8586 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8587 | } |
| 8588 | |
| 8589 | return GL_FALSE; |
| 8590 | } |
| 8591 | |
| 8592 | void __stdcall glBeginQuery(GLenum target, GLuint id) |
| 8593 | { |
| 8594 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 8595 | |
| 8596 | try |
| 8597 | { |
| 8598 | gl::Context *context = gl::getNonLostContext(); |
| 8599 | |
| 8600 | if (context) |
| 8601 | { |
| 8602 | if (context->getClientVersion() < 3) |
| 8603 | { |
| 8604 | return gl::error(GL_INVALID_OPERATION); |
| 8605 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8606 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8607 | UNIMPLEMENTED(); |
| 8608 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8609 | } |
| 8610 | catch(std::bad_alloc&) |
| 8611 | { |
| 8612 | return gl::error(GL_OUT_OF_MEMORY); |
| 8613 | } |
| 8614 | } |
| 8615 | |
| 8616 | void __stdcall glEndQuery(GLenum target) |
| 8617 | { |
| 8618 | EVENT("(GLenum target = 0x%X)", target); |
| 8619 | |
| 8620 | try |
| 8621 | { |
| 8622 | gl::Context *context = gl::getNonLostContext(); |
| 8623 | |
| 8624 | if (context) |
| 8625 | { |
| 8626 | if (context->getClientVersion() < 3) |
| 8627 | { |
| 8628 | return gl::error(GL_INVALID_OPERATION); |
| 8629 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8630 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8631 | UNIMPLEMENTED(); |
| 8632 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8633 | } |
| 8634 | catch(std::bad_alloc&) |
| 8635 | { |
| 8636 | return gl::error(GL_OUT_OF_MEMORY); |
| 8637 | } |
| 8638 | } |
| 8639 | |
| 8640 | void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params) |
| 8641 | { |
| 8642 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
| 8643 | |
| 8644 | try |
| 8645 | { |
| 8646 | gl::Context *context = gl::getNonLostContext(); |
| 8647 | |
| 8648 | if (context) |
| 8649 | { |
| 8650 | if (context->getClientVersion() < 3) |
| 8651 | { |
| 8652 | return gl::error(GL_INVALID_OPERATION); |
| 8653 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8654 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8655 | UNIMPLEMENTED(); |
| 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 glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) |
| 8665 | { |
| 8666 | EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params); |
| 8667 | |
| 8668 | try |
| 8669 | { |
| 8670 | gl::Context *context = gl::getNonLostContext(); |
| 8671 | |
| 8672 | if (context) |
| 8673 | { |
| 8674 | if (context->getClientVersion() < 3) |
| 8675 | { |
| 8676 | return gl::error(GL_INVALID_OPERATION); |
| 8677 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8678 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8679 | UNIMPLEMENTED(); |
| 8680 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8681 | } |
| 8682 | catch(std::bad_alloc&) |
| 8683 | { |
| 8684 | return gl::error(GL_OUT_OF_MEMORY); |
| 8685 | } |
| 8686 | } |
| 8687 | |
| 8688 | GLboolean __stdcall glUnmapBuffer(GLenum target) |
| 8689 | { |
| 8690 | EVENT("(GLenum target = 0x%X)", target); |
| 8691 | |
| 8692 | try |
| 8693 | { |
| 8694 | gl::Context *context = gl::getNonLostContext(); |
| 8695 | |
| 8696 | if (context) |
| 8697 | { |
| 8698 | if (context->getClientVersion() < 3) |
| 8699 | { |
| 8700 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8701 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8702 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8703 | UNIMPLEMENTED(); |
| 8704 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8705 | } |
| 8706 | catch(std::bad_alloc&) |
| 8707 | { |
| 8708 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8709 | } |
| 8710 | |
| 8711 | return GL_FALSE; |
| 8712 | } |
| 8713 | |
| 8714 | void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) |
| 8715 | { |
| 8716 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 8717 | |
| 8718 | try |
| 8719 | { |
| 8720 | gl::Context *context = gl::getNonLostContext(); |
| 8721 | |
| 8722 | if (context) |
| 8723 | { |
| 8724 | if (context->getClientVersion() < 3) |
| 8725 | { |
| 8726 | return gl::error(GL_INVALID_OPERATION); |
| 8727 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8728 | |
shannonwoods@chromium.org | 2d2190a | 2013-05-30 00:17:35 +0000 | [diff] [blame] | 8729 | UNIMPLEMENTED(); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8730 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8731 | } |
| 8732 | catch(std::bad_alloc&) |
| 8733 | { |
| 8734 | return gl::error(GL_OUT_OF_MEMORY); |
| 8735 | } |
| 8736 | } |
| 8737 | |
| 8738 | void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs) |
| 8739 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8740 | try |
| 8741 | { |
| 8742 | gl::Context *context = gl::getNonLostContext(); |
| 8743 | |
| 8744 | if (context) |
| 8745 | { |
| 8746 | if (context->getClientVersion() < 3) |
| 8747 | { |
| 8748 | return gl::error(GL_INVALID_OPERATION); |
| 8749 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8750 | |
shannon.woods%transgaming.com@gtempaccount.com | 7948c5f | 2013-04-13 03:38:58 +0000 | [diff] [blame] | 8751 | glDrawBuffersEXT(n, bufs); |
| 8752 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8753 | } |
| 8754 | catch(std::bad_alloc&) |
| 8755 | { |
| 8756 | return gl::error(GL_OUT_OF_MEMORY); |
| 8757 | } |
| 8758 | } |
| 8759 | |
| 8760 | void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8761 | { |
| 8762 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8763 | location, count, transpose, value); |
| 8764 | |
| 8765 | try |
| 8766 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8767 | if (count < 0) |
| 8768 | { |
| 8769 | return gl::error(GL_INVALID_VALUE); |
| 8770 | } |
| 8771 | |
| 8772 | if (location == -1) |
| 8773 | { |
| 8774 | return; |
| 8775 | } |
| 8776 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8777 | gl::Context *context = gl::getNonLostContext(); |
| 8778 | |
| 8779 | if (context) |
| 8780 | { |
| 8781 | if (context->getClientVersion() < 3) |
| 8782 | { |
| 8783 | return gl::error(GL_INVALID_OPERATION); |
| 8784 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8785 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8786 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8787 | if (!programBinary) |
| 8788 | { |
| 8789 | return gl::error(GL_INVALID_OPERATION); |
| 8790 | } |
| 8791 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8792 | if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8793 | { |
| 8794 | return gl::error(GL_INVALID_OPERATION); |
| 8795 | } |
| 8796 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8797 | } |
| 8798 | catch(std::bad_alloc&) |
| 8799 | { |
| 8800 | return gl::error(GL_OUT_OF_MEMORY); |
| 8801 | } |
| 8802 | } |
| 8803 | |
| 8804 | void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8805 | { |
| 8806 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8807 | location, count, transpose, value); |
| 8808 | |
| 8809 | try |
| 8810 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8811 | if (count < 0) |
| 8812 | { |
| 8813 | return gl::error(GL_INVALID_VALUE); |
| 8814 | } |
| 8815 | |
| 8816 | if (location == -1) |
| 8817 | { |
| 8818 | return; |
| 8819 | } |
| 8820 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 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 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8829 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8830 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8831 | if (!programBinary) |
| 8832 | { |
| 8833 | return gl::error(GL_INVALID_OPERATION); |
| 8834 | } |
| 8835 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8836 | if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8837 | { |
| 8838 | return gl::error(GL_INVALID_OPERATION); |
| 8839 | } |
| 8840 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8841 | } |
| 8842 | catch(std::bad_alloc&) |
| 8843 | { |
| 8844 | return gl::error(GL_OUT_OF_MEMORY); |
| 8845 | } |
| 8846 | } |
| 8847 | |
| 8848 | void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8849 | { |
| 8850 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8851 | location, count, transpose, value); |
| 8852 | |
| 8853 | try |
| 8854 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8855 | if (count < 0) |
| 8856 | { |
| 8857 | return gl::error(GL_INVALID_VALUE); |
| 8858 | } |
| 8859 | |
| 8860 | if (location == -1) |
| 8861 | { |
| 8862 | return; |
| 8863 | } |
| 8864 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8865 | gl::Context *context = gl::getNonLostContext(); |
| 8866 | |
| 8867 | if (context) |
| 8868 | { |
| 8869 | if (context->getClientVersion() < 3) |
| 8870 | { |
| 8871 | return gl::error(GL_INVALID_OPERATION); |
| 8872 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8873 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8874 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8875 | if (!programBinary) |
| 8876 | { |
| 8877 | return gl::error(GL_INVALID_OPERATION); |
| 8878 | } |
| 8879 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8880 | if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8881 | { |
| 8882 | return gl::error(GL_INVALID_OPERATION); |
| 8883 | } |
| 8884 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8885 | } |
| 8886 | catch(std::bad_alloc&) |
| 8887 | { |
| 8888 | return gl::error(GL_OUT_OF_MEMORY); |
| 8889 | } |
| 8890 | } |
| 8891 | |
| 8892 | void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8893 | { |
| 8894 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8895 | location, count, transpose, value); |
| 8896 | |
| 8897 | try |
| 8898 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8899 | if (count < 0) |
| 8900 | { |
| 8901 | return gl::error(GL_INVALID_VALUE); |
| 8902 | } |
| 8903 | |
| 8904 | if (location == -1) |
| 8905 | { |
| 8906 | return; |
| 8907 | } |
| 8908 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8909 | gl::Context *context = gl::getNonLostContext(); |
| 8910 | |
| 8911 | if (context) |
| 8912 | { |
| 8913 | if (context->getClientVersion() < 3) |
| 8914 | { |
| 8915 | return gl::error(GL_INVALID_OPERATION); |
| 8916 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8917 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8918 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8919 | if (!programBinary) |
| 8920 | { |
| 8921 | return gl::error(GL_INVALID_OPERATION); |
| 8922 | } |
| 8923 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8924 | if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8925 | { |
| 8926 | return gl::error(GL_INVALID_OPERATION); |
| 8927 | } |
| 8928 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8929 | } |
| 8930 | catch(std::bad_alloc&) |
| 8931 | { |
| 8932 | return gl::error(GL_OUT_OF_MEMORY); |
| 8933 | } |
| 8934 | } |
| 8935 | |
| 8936 | void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8937 | { |
| 8938 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8939 | location, count, transpose, value); |
| 8940 | |
| 8941 | try |
| 8942 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8943 | if (count < 0) |
| 8944 | { |
| 8945 | return gl::error(GL_INVALID_VALUE); |
| 8946 | } |
| 8947 | |
| 8948 | if (location == -1) |
| 8949 | { |
| 8950 | return; |
| 8951 | } |
| 8952 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8953 | gl::Context *context = gl::getNonLostContext(); |
| 8954 | |
| 8955 | if (context) |
| 8956 | { |
| 8957 | if (context->getClientVersion() < 3) |
| 8958 | { |
| 8959 | return gl::error(GL_INVALID_OPERATION); |
| 8960 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8961 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8962 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8963 | if (!programBinary) |
| 8964 | { |
| 8965 | return gl::error(GL_INVALID_OPERATION); |
| 8966 | } |
| 8967 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8968 | if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8969 | { |
| 8970 | return gl::error(GL_INVALID_OPERATION); |
| 8971 | } |
| 8972 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8973 | } |
| 8974 | catch(std::bad_alloc&) |
| 8975 | { |
| 8976 | return gl::error(GL_OUT_OF_MEMORY); |
| 8977 | } |
| 8978 | } |
| 8979 | |
| 8980 | void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8981 | { |
| 8982 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8983 | location, count, transpose, value); |
| 8984 | |
| 8985 | try |
| 8986 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8987 | if (count < 0) |
| 8988 | { |
| 8989 | return gl::error(GL_INVALID_VALUE); |
| 8990 | } |
| 8991 | |
| 8992 | if (location == -1) |
| 8993 | { |
| 8994 | return; |
| 8995 | } |
| 8996 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8997 | gl::Context *context = gl::getNonLostContext(); |
| 8998 | |
| 8999 | if (context) |
| 9000 | { |
| 9001 | if (context->getClientVersion() < 3) |
| 9002 | { |
| 9003 | return gl::error(GL_INVALID_OPERATION); |
| 9004 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9005 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9006 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9007 | if (!programBinary) |
| 9008 | { |
| 9009 | return gl::error(GL_INVALID_OPERATION); |
| 9010 | } |
| 9011 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9012 | if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9013 | { |
| 9014 | return gl::error(GL_INVALID_OPERATION); |
| 9015 | } |
| 9016 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9017 | } |
| 9018 | catch(std::bad_alloc&) |
| 9019 | { |
| 9020 | return gl::error(GL_OUT_OF_MEMORY); |
| 9021 | } |
| 9022 | } |
| 9023 | |
| 9024 | void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) |
| 9025 | { |
| 9026 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, " |
| 9027 | "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 9028 | srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 9029 | |
| 9030 | try |
| 9031 | { |
| 9032 | gl::Context *context = gl::getNonLostContext(); |
| 9033 | |
| 9034 | if (context) |
| 9035 | { |
| 9036 | if (context->getClientVersion() < 3) |
| 9037 | { |
| 9038 | return gl::error(GL_INVALID_OPERATION); |
| 9039 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9040 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 9041 | if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 9042 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 9043 | false)) |
| 9044 | { |
| 9045 | return; |
| 9046 | } |
| 9047 | |
| 9048 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 9049 | mask, filter); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9050 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9051 | } |
| 9052 | catch(std::bad_alloc&) |
| 9053 | { |
| 9054 | return gl::error(GL_OUT_OF_MEMORY); |
| 9055 | } |
| 9056 | } |
| 9057 | |
| 9058 | void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| 9059 | { |
| 9060 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 9061 | target, samples, internalformat, width, height); |
| 9062 | |
| 9063 | try |
| 9064 | { |
| 9065 | gl::Context *context = gl::getNonLostContext(); |
| 9066 | |
| 9067 | if (context) |
| 9068 | { |
| 9069 | if (context->getClientVersion() < 3) |
| 9070 | { |
| 9071 | return gl::error(GL_INVALID_OPERATION); |
| 9072 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9073 | |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 9074 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 9075 | width, height, false)) |
| 9076 | { |
| 9077 | return; |
| 9078 | } |
| 9079 | |
| 9080 | context->setRenderbufferStorage(width, height, internalformat, samples); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9081 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9082 | } |
| 9083 | catch(std::bad_alloc&) |
| 9084 | { |
| 9085 | return gl::error(GL_OUT_OF_MEMORY); |
| 9086 | } |
| 9087 | } |
| 9088 | |
| 9089 | void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) |
| 9090 | { |
| 9091 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)", |
| 9092 | target, attachment, texture, level, layer); |
| 9093 | |
| 9094 | try |
| 9095 | { |
| 9096 | gl::Context *context = gl::getNonLostContext(); |
| 9097 | |
| 9098 | if (context) |
| 9099 | { |
| 9100 | if (context->getClientVersion() < 3) |
| 9101 | { |
| 9102 | return gl::error(GL_INVALID_OPERATION); |
| 9103 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9104 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9105 | UNIMPLEMENTED(); |
| 9106 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9107 | } |
| 9108 | catch(std::bad_alloc&) |
| 9109 | { |
| 9110 | return gl::error(GL_OUT_OF_MEMORY); |
| 9111 | } |
| 9112 | } |
| 9113 | |
| 9114 | GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 9115 | { |
| 9116 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 9117 | target, offset, length, access); |
| 9118 | |
| 9119 | try |
| 9120 | { |
| 9121 | gl::Context *context = gl::getNonLostContext(); |
| 9122 | |
| 9123 | if (context) |
| 9124 | { |
| 9125 | if (context->getClientVersion() < 3) |
| 9126 | { |
| 9127 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 9128 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9129 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9130 | UNIMPLEMENTED(); |
| 9131 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9132 | } |
| 9133 | catch(std::bad_alloc&) |
| 9134 | { |
| 9135 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL)); |
| 9136 | } |
| 9137 | |
| 9138 | return NULL; |
| 9139 | } |
| 9140 | |
| 9141 | void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) |
| 9142 | { |
| 9143 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 9144 | |
| 9145 | try |
| 9146 | { |
| 9147 | gl::Context *context = gl::getNonLostContext(); |
| 9148 | |
| 9149 | if (context) |
| 9150 | { |
| 9151 | if (context->getClientVersion() < 3) |
| 9152 | { |
| 9153 | return gl::error(GL_INVALID_OPERATION); |
| 9154 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9155 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9156 | UNIMPLEMENTED(); |
| 9157 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9158 | } |
| 9159 | catch(std::bad_alloc&) |
| 9160 | { |
| 9161 | return gl::error(GL_OUT_OF_MEMORY); |
| 9162 | } |
| 9163 | } |
| 9164 | |
| 9165 | void __stdcall glBindVertexArray(GLuint array) |
| 9166 | { |
| 9167 | EVENT("(GLuint array = %u)", array); |
| 9168 | |
| 9169 | try |
| 9170 | { |
| 9171 | gl::Context *context = gl::getNonLostContext(); |
| 9172 | |
| 9173 | if (context) |
| 9174 | { |
| 9175 | if (context->getClientVersion() < 3) |
| 9176 | { |
| 9177 | return gl::error(GL_INVALID_OPERATION); |
| 9178 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9179 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9180 | UNIMPLEMENTED(); |
| 9181 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9182 | } |
| 9183 | catch(std::bad_alloc&) |
| 9184 | { |
| 9185 | return gl::error(GL_OUT_OF_MEMORY); |
| 9186 | } |
| 9187 | } |
| 9188 | |
| 9189 | void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) |
| 9190 | { |
| 9191 | EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays); |
| 9192 | |
| 9193 | try |
| 9194 | { |
| 9195 | gl::Context *context = gl::getNonLostContext(); |
| 9196 | |
| 9197 | if (context) |
| 9198 | { |
| 9199 | if (context->getClientVersion() < 3) |
| 9200 | { |
| 9201 | return gl::error(GL_INVALID_OPERATION); |
| 9202 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9203 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9204 | UNIMPLEMENTED(); |
| 9205 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9206 | } |
| 9207 | catch(std::bad_alloc&) |
| 9208 | { |
| 9209 | return gl::error(GL_OUT_OF_MEMORY); |
| 9210 | } |
| 9211 | } |
| 9212 | |
| 9213 | void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) |
| 9214 | { |
| 9215 | EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays); |
| 9216 | |
| 9217 | try |
| 9218 | { |
| 9219 | gl::Context *context = gl::getNonLostContext(); |
| 9220 | |
| 9221 | if (context) |
| 9222 | { |
| 9223 | if (context->getClientVersion() < 3) |
| 9224 | { |
| 9225 | return gl::error(GL_INVALID_OPERATION); |
| 9226 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9227 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9228 | UNIMPLEMENTED(); |
| 9229 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9230 | } |
| 9231 | catch(std::bad_alloc&) |
| 9232 | { |
| 9233 | return gl::error(GL_OUT_OF_MEMORY); |
| 9234 | } |
| 9235 | } |
| 9236 | |
| 9237 | GLboolean __stdcall glIsVertexArray(GLuint array) |
| 9238 | { |
| 9239 | EVENT("(GLuint array = %u)", array); |
| 9240 | |
| 9241 | try |
| 9242 | { |
| 9243 | gl::Context *context = gl::getNonLostContext(); |
| 9244 | |
| 9245 | if (context) |
| 9246 | { |
| 9247 | if (context->getClientVersion() < 3) |
| 9248 | { |
| 9249 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 9250 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9251 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9252 | UNIMPLEMENTED(); |
| 9253 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9254 | } |
| 9255 | catch(std::bad_alloc&) |
| 9256 | { |
| 9257 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 9258 | } |
| 9259 | |
| 9260 | return GL_FALSE; |
| 9261 | } |
| 9262 | |
| 9263 | void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data) |
| 9264 | { |
| 9265 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)", |
| 9266 | target, index, data); |
| 9267 | |
| 9268 | try |
| 9269 | { |
| 9270 | gl::Context *context = gl::getNonLostContext(); |
| 9271 | |
| 9272 | if (context) |
| 9273 | { |
| 9274 | if (context->getClientVersion() < 3) |
| 9275 | { |
| 9276 | return gl::error(GL_INVALID_OPERATION); |
| 9277 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9278 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9279 | UNIMPLEMENTED(); |
| 9280 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9281 | } |
| 9282 | catch(std::bad_alloc&) |
| 9283 | { |
| 9284 | return gl::error(GL_OUT_OF_MEMORY); |
| 9285 | } |
| 9286 | } |
| 9287 | |
| 9288 | void __stdcall glBeginTransformFeedback(GLenum primitiveMode) |
| 9289 | { |
| 9290 | EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode); |
| 9291 | |
| 9292 | try |
| 9293 | { |
| 9294 | gl::Context *context = gl::getNonLostContext(); |
| 9295 | |
| 9296 | if (context) |
| 9297 | { |
| 9298 | if (context->getClientVersion() < 3) |
| 9299 | { |
| 9300 | return gl::error(GL_INVALID_OPERATION); |
| 9301 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9302 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9303 | UNIMPLEMENTED(); |
| 9304 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9305 | } |
| 9306 | catch(std::bad_alloc&) |
| 9307 | { |
| 9308 | return gl::error(GL_OUT_OF_MEMORY); |
| 9309 | } |
| 9310 | } |
| 9311 | |
| 9312 | void __stdcall glEndTransformFeedback(void) |
| 9313 | { |
| 9314 | EVENT("(void)"); |
| 9315 | |
| 9316 | try |
| 9317 | { |
| 9318 | gl::Context *context = gl::getNonLostContext(); |
| 9319 | |
| 9320 | if (context) |
| 9321 | { |
| 9322 | if (context->getClientVersion() < 3) |
| 9323 | { |
| 9324 | return gl::error(GL_INVALID_OPERATION); |
| 9325 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9326 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9327 | UNIMPLEMENTED(); |
| 9328 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9329 | } |
| 9330 | catch(std::bad_alloc&) |
| 9331 | { |
| 9332 | return gl::error(GL_OUT_OF_MEMORY); |
| 9333 | } |
| 9334 | } |
| 9335 | |
| 9336 | void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
| 9337 | { |
| 9338 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)", |
| 9339 | target, index, buffer, offset, size); |
| 9340 | |
| 9341 | try |
| 9342 | { |
| 9343 | gl::Context *context = gl::getNonLostContext(); |
| 9344 | |
| 9345 | if (context) |
| 9346 | { |
| 9347 | if (context->getClientVersion() < 3) |
| 9348 | { |
| 9349 | return gl::error(GL_INVALID_OPERATION); |
| 9350 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9351 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9352 | switch (target) |
| 9353 | { |
| 9354 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9355 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9356 | { |
| 9357 | return gl::error(GL_INVALID_VALUE); |
| 9358 | } |
| 9359 | break; |
| 9360 | |
| 9361 | case GL_UNIFORM_BUFFER: |
| 9362 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 9363 | { |
| 9364 | return gl::error(GL_INVALID_VALUE); |
| 9365 | } |
| 9366 | break; |
| 9367 | |
| 9368 | default: |
| 9369 | return gl::error(GL_INVALID_ENUM); |
| 9370 | } |
| 9371 | |
shannonwoods@chromium.org | e6e0079 | 2013-05-30 00:06:07 +0000 | [diff] [blame] | 9372 | if (buffer != 0 && size <= 0) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9373 | { |
| 9374 | return gl::error(GL_INVALID_VALUE); |
| 9375 | } |
| 9376 | |
| 9377 | switch (target) |
| 9378 | { |
| 9379 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | a26aeaf | 2013-05-30 00:06:13 +0000 | [diff] [blame] | 9380 | |
| 9381 | // size and offset must be a multiple of 4 |
| 9382 | if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) |
| 9383 | { |
| 9384 | return gl::error(GL_INVALID_VALUE); |
| 9385 | } |
| 9386 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9387 | context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 9388 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9389 | break; |
| 9390 | |
| 9391 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 97c3d50 | 2013-05-30 00:04:34 +0000 | [diff] [blame] | 9392 | |
| 9393 | // it is an error to bind an offset not a multiple of the alignment |
| 9394 | if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0) |
| 9395 | { |
| 9396 | return gl::error(GL_INVALID_VALUE); |
| 9397 | } |
| 9398 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9399 | context->bindIndexedUniformBuffer(buffer, index, offset, size); |
| 9400 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9401 | break; |
| 9402 | |
| 9403 | default: |
| 9404 | UNREACHABLE(); |
| 9405 | } |
| 9406 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9407 | } |
| 9408 | catch(std::bad_alloc&) |
| 9409 | { |
| 9410 | return gl::error(GL_OUT_OF_MEMORY); |
| 9411 | } |
| 9412 | } |
| 9413 | |
| 9414 | void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 9415 | { |
| 9416 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)", |
| 9417 | target, index, buffer); |
| 9418 | |
| 9419 | try |
| 9420 | { |
| 9421 | gl::Context *context = gl::getNonLostContext(); |
| 9422 | |
| 9423 | if (context) |
| 9424 | { |
| 9425 | if (context->getClientVersion() < 3) |
| 9426 | { |
| 9427 | return gl::error(GL_INVALID_OPERATION); |
| 9428 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9429 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9430 | switch (target) |
| 9431 | { |
| 9432 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9433 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9434 | { |
| 9435 | return gl::error(GL_INVALID_VALUE); |
| 9436 | } |
| 9437 | break; |
| 9438 | |
| 9439 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9440 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9441 | { |
| 9442 | return gl::error(GL_INVALID_VALUE); |
| 9443 | } |
| 9444 | break; |
| 9445 | |
| 9446 | default: |
| 9447 | return gl::error(GL_INVALID_ENUM); |
| 9448 | } |
| 9449 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9450 | switch (target) |
| 9451 | { |
| 9452 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9453 | context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9454 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9455 | break; |
| 9456 | |
| 9457 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9458 | context->bindIndexedUniformBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9459 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9460 | break; |
| 9461 | |
| 9462 | default: |
| 9463 | UNREACHABLE(); |
| 9464 | } |
| 9465 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9466 | } |
| 9467 | catch(std::bad_alloc&) |
| 9468 | { |
| 9469 | return gl::error(GL_OUT_OF_MEMORY); |
| 9470 | } |
| 9471 | } |
| 9472 | |
| 9473 | void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
| 9474 | { |
| 9475 | EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)", |
| 9476 | program, count, varyings, bufferMode); |
| 9477 | |
| 9478 | try |
| 9479 | { |
| 9480 | gl::Context *context = gl::getNonLostContext(); |
| 9481 | |
| 9482 | if (context) |
| 9483 | { |
| 9484 | if (context->getClientVersion() < 3) |
| 9485 | { |
| 9486 | return gl::error(GL_INVALID_OPERATION); |
| 9487 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9488 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9489 | UNIMPLEMENTED(); |
| 9490 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9491 | } |
| 9492 | catch(std::bad_alloc&) |
| 9493 | { |
| 9494 | return gl::error(GL_OUT_OF_MEMORY); |
| 9495 | } |
| 9496 | } |
| 9497 | |
| 9498 | void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
| 9499 | { |
| 9500 | EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, " |
| 9501 | "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
| 9502 | program, index, bufSize, length, size, type, name); |
| 9503 | |
| 9504 | try |
| 9505 | { |
| 9506 | gl::Context *context = gl::getNonLostContext(); |
| 9507 | |
| 9508 | if (context) |
| 9509 | { |
| 9510 | if (context->getClientVersion() < 3) |
| 9511 | { |
| 9512 | return gl::error(GL_INVALID_OPERATION); |
| 9513 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9514 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9515 | UNIMPLEMENTED(); |
| 9516 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9517 | } |
| 9518 | catch(std::bad_alloc&) |
| 9519 | { |
| 9520 | return gl::error(GL_OUT_OF_MEMORY); |
| 9521 | } |
| 9522 | } |
| 9523 | |
| 9524 | void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) |
| 9525 | { |
| 9526 | EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)", |
| 9527 | index, size, type, stride, pointer); |
| 9528 | |
| 9529 | try |
| 9530 | { |
| 9531 | gl::Context *context = gl::getNonLostContext(); |
| 9532 | |
| 9533 | if (context) |
| 9534 | { |
| 9535 | if (context->getClientVersion() < 3) |
| 9536 | { |
| 9537 | return gl::error(GL_INVALID_OPERATION); |
| 9538 | } |
| 9539 | } |
| 9540 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9541 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9542 | { |
| 9543 | return gl::error(GL_INVALID_VALUE); |
| 9544 | } |
| 9545 | |
| 9546 | if (size < 1 || size > 4) |
| 9547 | { |
| 9548 | return gl::error(GL_INVALID_VALUE); |
| 9549 | } |
| 9550 | |
| 9551 | switch (type) |
| 9552 | { |
| 9553 | case GL_BYTE: |
| 9554 | case GL_UNSIGNED_BYTE: |
| 9555 | case GL_SHORT: |
| 9556 | case GL_UNSIGNED_SHORT: |
| 9557 | case GL_INT: |
| 9558 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9559 | case GL_INT_2_10_10_10_REV: |
| 9560 | 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] | 9561 | break; |
| 9562 | default: |
| 9563 | return gl::error(GL_INVALID_ENUM); |
| 9564 | } |
| 9565 | |
| 9566 | if (stride < 0) |
| 9567 | { |
| 9568 | return gl::error(GL_INVALID_VALUE); |
| 9569 | } |
| 9570 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9571 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 9572 | { |
| 9573 | return gl::error(GL_INVALID_OPERATION); |
| 9574 | } |
| 9575 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9576 | if (context) |
| 9577 | { |
| 9578 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true, |
| 9579 | stride, pointer); |
| 9580 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9581 | } |
| 9582 | catch(std::bad_alloc&) |
| 9583 | { |
| 9584 | return gl::error(GL_OUT_OF_MEMORY); |
| 9585 | } |
| 9586 | } |
| 9587 | |
| 9588 | void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) |
| 9589 | { |
| 9590 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 9591 | index, pname, params); |
| 9592 | |
| 9593 | try |
| 9594 | { |
| 9595 | gl::Context *context = gl::getNonLostContext(); |
| 9596 | |
| 9597 | if (context) |
| 9598 | { |
| 9599 | if (context->getClientVersion() < 3) |
| 9600 | { |
| 9601 | return gl::error(GL_INVALID_OPERATION); |
| 9602 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9603 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9604 | UNIMPLEMENTED(); |
| 9605 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9606 | } |
| 9607 | catch(std::bad_alloc&) |
| 9608 | { |
| 9609 | return gl::error(GL_OUT_OF_MEMORY); |
| 9610 | } |
| 9611 | } |
| 9612 | |
| 9613 | void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) |
| 9614 | { |
| 9615 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)", |
| 9616 | index, pname, params); |
| 9617 | |
| 9618 | try |
| 9619 | { |
| 9620 | gl::Context *context = gl::getNonLostContext(); |
| 9621 | |
| 9622 | if (context) |
| 9623 | { |
| 9624 | if (context->getClientVersion() < 3) |
| 9625 | { |
| 9626 | return gl::error(GL_INVALID_OPERATION); |
| 9627 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9628 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9629 | UNIMPLEMENTED(); |
| 9630 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9631 | } |
| 9632 | catch(std::bad_alloc&) |
| 9633 | { |
| 9634 | return gl::error(GL_OUT_OF_MEMORY); |
| 9635 | } |
| 9636 | } |
| 9637 | |
| 9638 | void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 9639 | { |
| 9640 | EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)", |
| 9641 | index, x, y, z, w); |
| 9642 | |
| 9643 | try |
| 9644 | { |
| 9645 | gl::Context *context = gl::getNonLostContext(); |
| 9646 | |
| 9647 | if (context) |
| 9648 | { |
| 9649 | if (context->getClientVersion() < 3) |
| 9650 | { |
| 9651 | return gl::error(GL_INVALID_OPERATION); |
| 9652 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9653 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9654 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9655 | { |
| 9656 | return gl::error(GL_INVALID_VALUE); |
| 9657 | } |
| 9658 | |
| 9659 | GLint vals[4] = { x, y, z, w }; |
| 9660 | context->setVertexAttribi(index, vals); |
| 9661 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9662 | } |
| 9663 | catch(std::bad_alloc&) |
| 9664 | { |
| 9665 | return gl::error(GL_OUT_OF_MEMORY); |
| 9666 | } |
| 9667 | } |
| 9668 | |
| 9669 | void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 9670 | { |
| 9671 | EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)", |
| 9672 | index, x, y, z, w); |
| 9673 | |
| 9674 | try |
| 9675 | { |
| 9676 | gl::Context *context = gl::getNonLostContext(); |
| 9677 | |
| 9678 | if (context) |
| 9679 | { |
| 9680 | if (context->getClientVersion() < 3) |
| 9681 | { |
| 9682 | return gl::error(GL_INVALID_OPERATION); |
| 9683 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9684 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9685 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9686 | { |
| 9687 | return gl::error(GL_INVALID_VALUE); |
| 9688 | } |
| 9689 | |
| 9690 | GLuint vals[4] = { x, y, z, w }; |
| 9691 | context->setVertexAttribu(index, vals); |
| 9692 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9693 | } |
| 9694 | catch(std::bad_alloc&) |
| 9695 | { |
| 9696 | return gl::error(GL_OUT_OF_MEMORY); |
| 9697 | } |
| 9698 | } |
| 9699 | |
| 9700 | void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) |
| 9701 | { |
| 9702 | EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v); |
| 9703 | |
| 9704 | try |
| 9705 | { |
| 9706 | gl::Context *context = gl::getNonLostContext(); |
| 9707 | |
| 9708 | if (context) |
| 9709 | { |
| 9710 | if (context->getClientVersion() < 3) |
| 9711 | { |
| 9712 | return gl::error(GL_INVALID_OPERATION); |
| 9713 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9714 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9715 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9716 | { |
| 9717 | return gl::error(GL_INVALID_VALUE); |
| 9718 | } |
| 9719 | |
| 9720 | context->setVertexAttribi(index, v); |
| 9721 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9722 | } |
| 9723 | catch(std::bad_alloc&) |
| 9724 | { |
| 9725 | return gl::error(GL_OUT_OF_MEMORY); |
| 9726 | } |
| 9727 | } |
| 9728 | |
| 9729 | void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v) |
| 9730 | { |
| 9731 | EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v); |
| 9732 | |
| 9733 | try |
| 9734 | { |
| 9735 | gl::Context *context = gl::getNonLostContext(); |
| 9736 | |
| 9737 | if (context) |
| 9738 | { |
| 9739 | if (context->getClientVersion() < 3) |
| 9740 | { |
| 9741 | return gl::error(GL_INVALID_OPERATION); |
| 9742 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9743 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9744 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9745 | { |
| 9746 | return gl::error(GL_INVALID_VALUE); |
| 9747 | } |
| 9748 | |
| 9749 | context->setVertexAttribu(index, v); |
| 9750 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9751 | } |
| 9752 | catch(std::bad_alloc&) |
| 9753 | { |
| 9754 | return gl::error(GL_OUT_OF_MEMORY); |
| 9755 | } |
| 9756 | } |
| 9757 | |
| 9758 | void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) |
| 9759 | { |
| 9760 | EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)", |
| 9761 | program, location, params); |
| 9762 | |
| 9763 | try |
| 9764 | { |
| 9765 | gl::Context *context = gl::getNonLostContext(); |
| 9766 | |
| 9767 | if (context) |
| 9768 | { |
| 9769 | if (context->getClientVersion() < 3) |
| 9770 | { |
| 9771 | return gl::error(GL_INVALID_OPERATION); |
| 9772 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9773 | |
shannon.woods%transgaming.com@gtempaccount.com | e229012 | 2013-04-13 03:41:07 +0000 | [diff] [blame] | 9774 | if (program == 0) |
| 9775 | { |
| 9776 | return gl::error(GL_INVALID_VALUE); |
| 9777 | } |
| 9778 | |
| 9779 | gl::Program *programObject = context->getProgram(program); |
| 9780 | |
| 9781 | if (!programObject || !programObject->isLinked()) |
| 9782 | { |
| 9783 | return gl::error(GL_INVALID_OPERATION); |
| 9784 | } |
| 9785 | |
| 9786 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9787 | if (!programBinary) |
| 9788 | { |
| 9789 | return gl::error(GL_INVALID_OPERATION); |
| 9790 | } |
| 9791 | |
| 9792 | if (!programBinary->getUniformuiv(location, NULL, params)) |
| 9793 | { |
| 9794 | return gl::error(GL_INVALID_OPERATION); |
| 9795 | } |
| 9796 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9797 | } |
| 9798 | catch(std::bad_alloc&) |
| 9799 | { |
| 9800 | return gl::error(GL_OUT_OF_MEMORY); |
| 9801 | } |
| 9802 | } |
| 9803 | |
| 9804 | GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) |
| 9805 | { |
| 9806 | EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)", |
| 9807 | program, name); |
| 9808 | |
| 9809 | try |
| 9810 | { |
| 9811 | gl::Context *context = gl::getNonLostContext(); |
| 9812 | |
| 9813 | if (context) |
| 9814 | { |
| 9815 | if (context->getClientVersion() < 3) |
| 9816 | { |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame] | 9817 | return gl::error(GL_INVALID_OPERATION, -1); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9818 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9819 | |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame] | 9820 | if (program == 0) |
| 9821 | { |
| 9822 | return gl::error(GL_INVALID_VALUE, -1); |
| 9823 | } |
| 9824 | |
| 9825 | gl::Program *programObject = context->getProgram(program); |
| 9826 | |
| 9827 | if (!programObject || !programObject->isLinked()) |
| 9828 | { |
| 9829 | return gl::error(GL_INVALID_OPERATION, -1); |
| 9830 | } |
| 9831 | |
| 9832 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9833 | if (!programBinary) |
| 9834 | { |
| 9835 | return gl::error(GL_INVALID_OPERATION, -1); |
| 9836 | } |
| 9837 | |
| 9838 | return programBinary->getFragDataLocation(name); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9839 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9840 | } |
| 9841 | catch(std::bad_alloc&) |
| 9842 | { |
| 9843 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 9844 | } |
| 9845 | |
| 9846 | return 0; |
| 9847 | } |
| 9848 | |
| 9849 | void __stdcall glUniform1ui(GLint location, GLuint v0) |
| 9850 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9851 | glUniform1uiv(location, 1, &v0); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9852 | } |
| 9853 | |
| 9854 | void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1) |
| 9855 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9856 | const GLuint xy[] = { v0, v1 }; |
| 9857 | glUniform2uiv(location, 1, xy); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9858 | } |
| 9859 | |
| 9860 | void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 9861 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9862 | const GLuint xyz[] = { v0, v1, v2 }; |
| 9863 | glUniform3uiv(location, 1, xyz); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9864 | } |
| 9865 | |
| 9866 | void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 9867 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9868 | const GLuint xyzw[] = { v0, v1, v2, v3 }; |
| 9869 | glUniform4uiv(location, 1, xyzw); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9870 | } |
| 9871 | |
| 9872 | void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) |
| 9873 | { |
| 9874 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9875 | location, count, value); |
| 9876 | |
| 9877 | try |
| 9878 | { |
| 9879 | gl::Context *context = gl::getNonLostContext(); |
| 9880 | |
| 9881 | if (context) |
| 9882 | { |
| 9883 | if (context->getClientVersion() < 3) |
| 9884 | { |
| 9885 | return gl::error(GL_INVALID_OPERATION); |
| 9886 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9887 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9888 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9889 | if (!programBinary) |
| 9890 | { |
| 9891 | return gl::error(GL_INVALID_OPERATION); |
| 9892 | } |
| 9893 | |
| 9894 | if (!programBinary->setUniform1uiv(location, count, value)) |
| 9895 | { |
| 9896 | return gl::error(GL_INVALID_OPERATION); |
| 9897 | } |
| 9898 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9899 | } |
| 9900 | catch(std::bad_alloc&) |
| 9901 | { |
| 9902 | return gl::error(GL_OUT_OF_MEMORY); |
| 9903 | } |
| 9904 | } |
| 9905 | |
| 9906 | void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) |
| 9907 | { |
| 9908 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9909 | location, count, value); |
| 9910 | |
| 9911 | try |
| 9912 | { |
| 9913 | gl::Context *context = gl::getNonLostContext(); |
| 9914 | |
| 9915 | if (context) |
| 9916 | { |
| 9917 | if (context->getClientVersion() < 3) |
| 9918 | { |
| 9919 | return gl::error(GL_INVALID_OPERATION); |
| 9920 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9921 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9922 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9923 | if (!programBinary) |
| 9924 | { |
| 9925 | return gl::error(GL_INVALID_OPERATION); |
| 9926 | } |
| 9927 | |
| 9928 | if (!programBinary->setUniform2uiv(location, count, value)) |
| 9929 | { |
| 9930 | return gl::error(GL_INVALID_OPERATION); |
| 9931 | } |
| 9932 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9933 | } |
| 9934 | catch(std::bad_alloc&) |
| 9935 | { |
| 9936 | return gl::error(GL_OUT_OF_MEMORY); |
| 9937 | } |
| 9938 | } |
| 9939 | |
| 9940 | void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) |
| 9941 | { |
| 9942 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)", |
| 9943 | location, count, value); |
| 9944 | |
| 9945 | try |
| 9946 | { |
| 9947 | gl::Context *context = gl::getNonLostContext(); |
| 9948 | |
| 9949 | if (context) |
| 9950 | { |
| 9951 | if (context->getClientVersion() < 3) |
| 9952 | { |
| 9953 | return gl::error(GL_INVALID_OPERATION); |
| 9954 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9955 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9956 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9957 | if (!programBinary) |
| 9958 | { |
| 9959 | return gl::error(GL_INVALID_OPERATION); |
| 9960 | } |
| 9961 | |
| 9962 | if (!programBinary->setUniform3uiv(location, count, value)) |
| 9963 | { |
| 9964 | return gl::error(GL_INVALID_OPERATION); |
| 9965 | } |
| 9966 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9967 | } |
| 9968 | catch(std::bad_alloc&) |
| 9969 | { |
| 9970 | return gl::error(GL_OUT_OF_MEMORY); |
| 9971 | } |
| 9972 | } |
| 9973 | |
| 9974 | void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) |
| 9975 | { |
| 9976 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9977 | location, count, value); |
| 9978 | |
| 9979 | try |
| 9980 | { |
| 9981 | gl::Context *context = gl::getNonLostContext(); |
| 9982 | |
| 9983 | if (context) |
| 9984 | { |
| 9985 | if (context->getClientVersion() < 3) |
| 9986 | { |
| 9987 | return gl::error(GL_INVALID_OPERATION); |
| 9988 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9989 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9990 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9991 | if (!programBinary) |
| 9992 | { |
| 9993 | return gl::error(GL_INVALID_OPERATION); |
| 9994 | } |
| 9995 | |
| 9996 | if (!programBinary->setUniform4uiv(location, count, value)) |
| 9997 | { |
| 9998 | return gl::error(GL_INVALID_OPERATION); |
| 9999 | } |
| 10000 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10001 | } |
| 10002 | catch(std::bad_alloc&) |
| 10003 | { |
| 10004 | return gl::error(GL_OUT_OF_MEMORY); |
| 10005 | } |
| 10006 | } |
| 10007 | |
| 10008 | void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) |
| 10009 | { |
| 10010 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)", |
| 10011 | buffer, drawbuffer, value); |
| 10012 | |
| 10013 | try |
| 10014 | { |
| 10015 | gl::Context *context = gl::getNonLostContext(); |
| 10016 | |
| 10017 | if (context) |
| 10018 | { |
| 10019 | if (context->getClientVersion() < 3) |
| 10020 | { |
| 10021 | return gl::error(GL_INVALID_OPERATION); |
| 10022 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10023 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10024 | UNIMPLEMENTED(); |
| 10025 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10026 | } |
| 10027 | catch(std::bad_alloc&) |
| 10028 | { |
| 10029 | return gl::error(GL_OUT_OF_MEMORY); |
| 10030 | } |
| 10031 | } |
| 10032 | |
| 10033 | void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) |
| 10034 | { |
| 10035 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)", |
| 10036 | buffer, drawbuffer, value); |
| 10037 | |
| 10038 | try |
| 10039 | { |
| 10040 | gl::Context *context = gl::getNonLostContext(); |
| 10041 | |
| 10042 | if (context) |
| 10043 | { |
| 10044 | if (context->getClientVersion() < 3) |
| 10045 | { |
| 10046 | return gl::error(GL_INVALID_OPERATION); |
| 10047 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10048 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10049 | UNIMPLEMENTED(); |
| 10050 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10051 | } |
| 10052 | catch(std::bad_alloc&) |
| 10053 | { |
| 10054 | return gl::error(GL_OUT_OF_MEMORY); |
| 10055 | } |
| 10056 | } |
| 10057 | |
| 10058 | void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) |
| 10059 | { |
| 10060 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)", |
| 10061 | buffer, drawbuffer, value); |
| 10062 | |
| 10063 | try |
| 10064 | { |
| 10065 | gl::Context *context = gl::getNonLostContext(); |
| 10066 | |
| 10067 | if (context) |
| 10068 | { |
| 10069 | if (context->getClientVersion() < 3) |
| 10070 | { |
| 10071 | return gl::error(GL_INVALID_OPERATION); |
| 10072 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10073 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10074 | UNIMPLEMENTED(); |
| 10075 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10076 | } |
| 10077 | catch(std::bad_alloc&) |
| 10078 | { |
| 10079 | return gl::error(GL_OUT_OF_MEMORY); |
| 10080 | } |
| 10081 | } |
| 10082 | |
| 10083 | void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 10084 | { |
| 10085 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)", |
| 10086 | buffer, drawbuffer, depth, stencil); |
| 10087 | |
| 10088 | try |
| 10089 | { |
| 10090 | gl::Context *context = gl::getNonLostContext(); |
| 10091 | |
| 10092 | if (context) |
| 10093 | { |
| 10094 | if (context->getClientVersion() < 3) |
| 10095 | { |
| 10096 | return gl::error(GL_INVALID_OPERATION); |
| 10097 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10098 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10099 | UNIMPLEMENTED(); |
| 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 | const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) |
| 10109 | { |
| 10110 | EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index); |
| 10111 | |
| 10112 | try |
| 10113 | { |
| 10114 | gl::Context *context = gl::getNonLostContext(); |
| 10115 | |
| 10116 | if (context) |
| 10117 | { |
| 10118 | if (context->getClientVersion() < 3) |
| 10119 | { |
| 10120 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL)); |
| 10121 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10122 | |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 10123 | if (name != GL_EXTENSIONS) |
| 10124 | { |
| 10125 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL)); |
| 10126 | } |
| 10127 | |
| 10128 | if (index >= context->getNumExtensions()) |
| 10129 | { |
| 10130 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL)); |
| 10131 | } |
| 10132 | |
| 10133 | return reinterpret_cast<const GLubyte*>(context->getExtensionString(index)); |
| 10134 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10135 | } |
| 10136 | catch(std::bad_alloc&) |
| 10137 | { |
| 10138 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL)); |
| 10139 | } |
| 10140 | |
| 10141 | return NULL; |
| 10142 | } |
| 10143 | |
| 10144 | void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 10145 | { |
| 10146 | EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)", |
| 10147 | readTarget, writeTarget, readOffset, writeOffset, size); |
| 10148 | |
| 10149 | try |
| 10150 | { |
| 10151 | gl::Context *context = gl::getNonLostContext(); |
| 10152 | |
| 10153 | if (context) |
| 10154 | { |
| 10155 | if (context->getClientVersion() < 3) |
| 10156 | { |
| 10157 | return gl::error(GL_INVALID_OPERATION); |
| 10158 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10159 | |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 10160 | gl::Buffer *readBuffer = NULL; |
| 10161 | switch (readTarget) |
| 10162 | { |
| 10163 | case GL_ARRAY_BUFFER: |
| 10164 | readBuffer = context->getArrayBuffer(); |
| 10165 | break; |
| 10166 | case GL_COPY_READ_BUFFER: |
| 10167 | readBuffer = context->getCopyReadBuffer(); |
| 10168 | break; |
| 10169 | case GL_COPY_WRITE_BUFFER: |
| 10170 | readBuffer = context->getCopyWriteBuffer(); |
| 10171 | break; |
| 10172 | case GL_ELEMENT_ARRAY_BUFFER: |
| 10173 | readBuffer = context->getElementArrayBuffer(); |
| 10174 | break; |
| 10175 | case GL_PIXEL_PACK_BUFFER: |
| 10176 | readBuffer = context->getPixelPackBuffer(); |
| 10177 | break; |
| 10178 | case GL_PIXEL_UNPACK_BUFFER: |
| 10179 | readBuffer = context->getPixelUnpackBuffer(); |
| 10180 | break; |
| 10181 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 10182 | readBuffer = context->getGenericTransformFeedbackBuffer(); |
| 10183 | break; |
| 10184 | case GL_UNIFORM_BUFFER: |
| 10185 | readBuffer = context->getGenericUniformBuffer(); |
| 10186 | break; |
| 10187 | default: |
| 10188 | return gl::error(GL_INVALID_ENUM); |
| 10189 | } |
| 10190 | |
| 10191 | gl::Buffer *writeBuffer = NULL; |
| 10192 | switch (writeTarget) |
| 10193 | { |
| 10194 | case GL_ARRAY_BUFFER: |
| 10195 | writeBuffer = context->getArrayBuffer(); |
| 10196 | break; |
| 10197 | case GL_COPY_READ_BUFFER: |
| 10198 | writeBuffer = context->getCopyReadBuffer(); |
| 10199 | break; |
| 10200 | case GL_COPY_WRITE_BUFFER: |
| 10201 | writeBuffer = context->getCopyWriteBuffer(); |
| 10202 | break; |
| 10203 | case GL_ELEMENT_ARRAY_BUFFER: |
| 10204 | writeBuffer = context->getElementArrayBuffer(); |
| 10205 | break; |
| 10206 | case GL_PIXEL_PACK_BUFFER: |
| 10207 | writeBuffer = context->getPixelPackBuffer(); |
| 10208 | break; |
| 10209 | case GL_PIXEL_UNPACK_BUFFER: |
| 10210 | writeBuffer = context->getPixelUnpackBuffer(); |
| 10211 | break; |
| 10212 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 10213 | writeBuffer = context->getGenericTransformFeedbackBuffer(); |
| 10214 | break; |
| 10215 | case GL_UNIFORM_BUFFER: |
| 10216 | writeBuffer = context->getGenericUniformBuffer(); |
| 10217 | break; |
| 10218 | default: |
| 10219 | return gl::error(GL_INVALID_ENUM); |
| 10220 | } |
| 10221 | |
| 10222 | if (!readBuffer || !writeBuffer) |
| 10223 | { |
| 10224 | return gl::error(GL_INVALID_OPERATION); |
| 10225 | } |
| 10226 | |
| 10227 | if (readOffset < 0 || writeOffset < 0 || size < 0 || |
| 10228 | static_cast<unsigned int>(readOffset + size) > readBuffer->size() || |
| 10229 | static_cast<unsigned int>(writeOffset + size) > writeBuffer->size()) |
| 10230 | { |
| 10231 | return gl::error(GL_INVALID_VALUE); |
| 10232 | } |
| 10233 | |
| 10234 | if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size) |
| 10235 | { |
| 10236 | return gl::error(GL_INVALID_VALUE); |
| 10237 | } |
| 10238 | |
| 10239 | // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION) |
| 10240 | |
shannon.woods%transgaming.com@gtempaccount.com | c53376a | 2013-04-13 03:41:23 +0000 | [diff] [blame] | 10241 | // if size is zero, the copy is a successful no-op |
| 10242 | if (size > 0) |
| 10243 | { |
| 10244 | writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); |
| 10245 | } |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 10246 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10247 | } |
| 10248 | catch(std::bad_alloc&) |
| 10249 | { |
| 10250 | return gl::error(GL_OUT_OF_MEMORY); |
| 10251 | } |
| 10252 | } |
| 10253 | |
| 10254 | void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) |
| 10255 | { |
| 10256 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)", |
| 10257 | program, uniformCount, uniformNames, uniformIndices); |
| 10258 | |
| 10259 | try |
| 10260 | { |
| 10261 | gl::Context *context = gl::getNonLostContext(); |
| 10262 | |
| 10263 | if (context) |
| 10264 | { |
| 10265 | if (context->getClientVersion() < 3) |
| 10266 | { |
| 10267 | return gl::error(GL_INVALID_OPERATION); |
| 10268 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10269 | |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 10270 | if (uniformCount < 0) |
| 10271 | { |
| 10272 | return gl::error(GL_INVALID_VALUE); |
| 10273 | } |
| 10274 | |
| 10275 | gl::Program *programObject = context->getProgram(program); |
| 10276 | |
| 10277 | if (!programObject) |
| 10278 | { |
| 10279 | if (context->getShader(program)) |
| 10280 | { |
| 10281 | return gl::error(GL_INVALID_OPERATION); |
| 10282 | } |
| 10283 | else |
| 10284 | { |
| 10285 | return gl::error(GL_INVALID_VALUE); |
| 10286 | } |
| 10287 | } |
| 10288 | |
| 10289 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10290 | if (!programObject->isLinked() || !programBinary) |
| 10291 | { |
| 10292 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10293 | { |
| 10294 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 10295 | } |
| 10296 | } |
| 10297 | else |
| 10298 | { |
| 10299 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10300 | { |
| 10301 | uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]); |
| 10302 | } |
| 10303 | } |
| 10304 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10305 | } |
| 10306 | catch(std::bad_alloc&) |
| 10307 | { |
| 10308 | return gl::error(GL_OUT_OF_MEMORY); |
| 10309 | } |
| 10310 | } |
| 10311 | |
| 10312 | void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) |
| 10313 | { |
| 10314 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10315 | program, uniformCount, uniformIndices, pname, params); |
| 10316 | |
| 10317 | try |
| 10318 | { |
| 10319 | gl::Context *context = gl::getNonLostContext(); |
| 10320 | |
| 10321 | if (context) |
| 10322 | { |
| 10323 | if (context->getClientVersion() < 3) |
| 10324 | { |
| 10325 | return gl::error(GL_INVALID_OPERATION); |
| 10326 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10327 | |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 10328 | if (uniformCount < 0) |
| 10329 | { |
| 10330 | return gl::error(GL_INVALID_VALUE); |
| 10331 | } |
| 10332 | |
| 10333 | gl::Program *programObject = context->getProgram(program); |
| 10334 | |
| 10335 | if (!programObject) |
| 10336 | { |
| 10337 | if (context->getShader(program)) |
| 10338 | { |
| 10339 | return gl::error(GL_INVALID_OPERATION); |
| 10340 | } |
| 10341 | else |
| 10342 | { |
| 10343 | return gl::error(GL_INVALID_VALUE); |
| 10344 | } |
| 10345 | } |
| 10346 | |
| 10347 | switch (pname) |
| 10348 | { |
| 10349 | case GL_UNIFORM_TYPE: |
| 10350 | case GL_UNIFORM_SIZE: |
| 10351 | case GL_UNIFORM_NAME_LENGTH: |
| 10352 | case GL_UNIFORM_BLOCK_INDEX: |
| 10353 | case GL_UNIFORM_OFFSET: |
| 10354 | case GL_UNIFORM_ARRAY_STRIDE: |
| 10355 | case GL_UNIFORM_MATRIX_STRIDE: |
| 10356 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 10357 | break; |
| 10358 | default: |
| 10359 | return gl::error(GL_INVALID_ENUM); |
| 10360 | } |
| 10361 | |
| 10362 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10363 | |
| 10364 | if (!programBinary && uniformCount > 0) |
| 10365 | { |
| 10366 | return gl::error(GL_INVALID_VALUE); |
| 10367 | } |
| 10368 | |
| 10369 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10370 | { |
| 10371 | const GLuint index = uniformIndices[uniformId]; |
| 10372 | |
| 10373 | if (index >= (GLuint)programBinary->getActiveUniformCount()) |
| 10374 | { |
| 10375 | return gl::error(GL_INVALID_VALUE); |
| 10376 | } |
| 10377 | } |
| 10378 | |
| 10379 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10380 | { |
| 10381 | const GLuint index = uniformIndices[uniformId]; |
| 10382 | params[uniformId] = programBinary->getActiveUniformi(index, pname); |
| 10383 | } |
| 10384 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10385 | } |
| 10386 | catch(std::bad_alloc&) |
| 10387 | { |
| 10388 | return gl::error(GL_OUT_OF_MEMORY); |
| 10389 | } |
| 10390 | } |
| 10391 | |
| 10392 | GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) |
| 10393 | { |
| 10394 | EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName); |
| 10395 | |
| 10396 | try |
| 10397 | { |
| 10398 | gl::Context *context = gl::getNonLostContext(); |
| 10399 | |
| 10400 | if (context) |
| 10401 | { |
| 10402 | if (context->getClientVersion() < 3) |
| 10403 | { |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10404 | 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] | 10405 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10406 | |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10407 | gl::Program *programObject = context->getProgram(program); |
| 10408 | |
| 10409 | if (!programObject) |
| 10410 | { |
| 10411 | if (context->getShader(program)) |
| 10412 | { |
| 10413 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
| 10414 | } |
| 10415 | else |
| 10416 | { |
| 10417 | return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX); |
| 10418 | } |
| 10419 | } |
| 10420 | |
| 10421 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10422 | if (!programBinary) |
| 10423 | { |
| 10424 | return GL_INVALID_INDEX; |
| 10425 | } |
| 10426 | |
| 10427 | return programBinary->getUniformBlockIndex(uniformBlockName); |
| 10428 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10429 | } |
| 10430 | catch(std::bad_alloc&) |
| 10431 | { |
| 10432 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10433 | } |
| 10434 | |
| 10435 | return 0; |
| 10436 | } |
| 10437 | |
| 10438 | void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) |
| 10439 | { |
| 10440 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10441 | program, uniformBlockIndex, pname, params); |
| 10442 | |
| 10443 | try |
| 10444 | { |
| 10445 | gl::Context *context = gl::getNonLostContext(); |
| 10446 | |
| 10447 | if (context) |
| 10448 | { |
| 10449 | if (context->getClientVersion() < 3) |
| 10450 | { |
| 10451 | return gl::error(GL_INVALID_OPERATION); |
| 10452 | } |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10453 | gl::Program *programObject = context->getProgram(program); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10454 | |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10455 | if (!programObject) |
| 10456 | { |
| 10457 | if (context->getShader(program)) |
| 10458 | { |
| 10459 | return gl::error(GL_INVALID_OPERATION); |
| 10460 | } |
| 10461 | else |
| 10462 | { |
| 10463 | return gl::error(GL_INVALID_VALUE); |
| 10464 | } |
| 10465 | } |
| 10466 | |
| 10467 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10468 | |
| 10469 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10470 | { |
| 10471 | return gl::error(GL_INVALID_VALUE); |
| 10472 | } |
| 10473 | |
| 10474 | switch (pname) |
| 10475 | { |
| 10476 | case GL_UNIFORM_BLOCK_BINDING: |
| 10477 | *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); |
| 10478 | break; |
| 10479 | |
| 10480 | case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 10481 | case GL_UNIFORM_BLOCK_NAME_LENGTH: |
| 10482 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 10483 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| 10484 | case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
| 10485 | case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
| 10486 | programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params); |
| 10487 | break; |
| 10488 | |
| 10489 | default: |
| 10490 | return gl::error(GL_INVALID_ENUM); |
| 10491 | } |
| 10492 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10493 | } |
| 10494 | catch(std::bad_alloc&) |
| 10495 | { |
| 10496 | return gl::error(GL_OUT_OF_MEMORY); |
| 10497 | } |
| 10498 | } |
| 10499 | |
| 10500 | void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) |
| 10501 | { |
| 10502 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)", |
| 10503 | program, uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10504 | |
| 10505 | try |
| 10506 | { |
| 10507 | gl::Context *context = gl::getNonLostContext(); |
| 10508 | |
| 10509 | if (context) |
| 10510 | { |
| 10511 | if (context->getClientVersion() < 3) |
| 10512 | { |
| 10513 | return gl::error(GL_INVALID_OPERATION); |
| 10514 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10515 | |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 10516 | gl::Program *programObject = context->getProgram(program); |
| 10517 | |
| 10518 | if (!programObject) |
| 10519 | { |
| 10520 | if (context->getShader(program)) |
| 10521 | { |
| 10522 | return gl::error(GL_INVALID_OPERATION); |
| 10523 | } |
| 10524 | else |
| 10525 | { |
| 10526 | return gl::error(GL_INVALID_VALUE); |
| 10527 | } |
| 10528 | } |
| 10529 | |
| 10530 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10531 | |
| 10532 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10533 | { |
| 10534 | return gl::error(GL_INVALID_VALUE); |
| 10535 | } |
| 10536 | |
| 10537 | programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10538 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10539 | } |
| 10540 | catch(std::bad_alloc&) |
| 10541 | { |
| 10542 | return gl::error(GL_OUT_OF_MEMORY); |
| 10543 | } |
| 10544 | } |
| 10545 | |
| 10546 | void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) |
| 10547 | { |
| 10548 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)", |
| 10549 | program, uniformBlockIndex, uniformBlockBinding); |
| 10550 | |
| 10551 | try |
| 10552 | { |
| 10553 | gl::Context *context = gl::getNonLostContext(); |
| 10554 | |
| 10555 | if (context) |
| 10556 | { |
| 10557 | if (context->getClientVersion() < 3) |
| 10558 | { |
| 10559 | return gl::error(GL_INVALID_OPERATION); |
| 10560 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10561 | |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 10562 | if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings()) |
| 10563 | { |
| 10564 | return gl::error(GL_INVALID_VALUE); |
| 10565 | } |
| 10566 | |
| 10567 | gl::Program *programObject = context->getProgram(program); |
| 10568 | |
| 10569 | if (!programObject) |
| 10570 | { |
| 10571 | if (context->getShader(program)) |
| 10572 | { |
| 10573 | return gl::error(GL_INVALID_OPERATION); |
| 10574 | } |
| 10575 | else |
| 10576 | { |
| 10577 | return gl::error(GL_INVALID_VALUE); |
| 10578 | } |
| 10579 | } |
| 10580 | |
| 10581 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10582 | |
| 10583 | // if never linked, there won't be any uniform blocks |
| 10584 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10585 | { |
| 10586 | return gl::error(GL_INVALID_VALUE); |
| 10587 | } |
| 10588 | |
| 10589 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
| 10590 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10591 | } |
| 10592 | catch(std::bad_alloc&) |
| 10593 | { |
| 10594 | return gl::error(GL_OUT_OF_MEMORY); |
| 10595 | } |
| 10596 | } |
| 10597 | |
| 10598 | void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 10599 | { |
| 10600 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)", |
| 10601 | mode, first, count, instanceCount); |
| 10602 | |
| 10603 | try |
| 10604 | { |
| 10605 | gl::Context *context = gl::getNonLostContext(); |
| 10606 | |
| 10607 | if (context) |
| 10608 | { |
| 10609 | if (context->getClientVersion() < 3) |
| 10610 | { |
| 10611 | return gl::error(GL_INVALID_OPERATION); |
| 10612 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10613 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10614 | UNIMPLEMENTED(); |
| 10615 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10616 | } |
| 10617 | catch(std::bad_alloc&) |
| 10618 | { |
| 10619 | return gl::error(GL_OUT_OF_MEMORY); |
| 10620 | } |
| 10621 | } |
| 10622 | |
| 10623 | void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) |
| 10624 | { |
| 10625 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)", |
| 10626 | mode, count, type, indices, instanceCount); |
| 10627 | |
| 10628 | try |
| 10629 | { |
| 10630 | gl::Context *context = gl::getNonLostContext(); |
| 10631 | |
| 10632 | if (context) |
| 10633 | { |
| 10634 | if (context->getClientVersion() < 3) |
| 10635 | { |
| 10636 | return gl::error(GL_INVALID_OPERATION); |
| 10637 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10638 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10639 | UNIMPLEMENTED(); |
| 10640 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10641 | } |
| 10642 | catch(std::bad_alloc&) |
| 10643 | { |
| 10644 | return gl::error(GL_OUT_OF_MEMORY); |
| 10645 | } |
| 10646 | } |
| 10647 | |
| 10648 | GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags) |
| 10649 | { |
| 10650 | EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags); |
| 10651 | |
| 10652 | try |
| 10653 | { |
| 10654 | gl::Context *context = gl::getNonLostContext(); |
| 10655 | |
| 10656 | if (context) |
| 10657 | { |
| 10658 | if (context->getClientVersion() < 3) |
| 10659 | { |
| 10660 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(NULL)); |
| 10661 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10662 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10663 | UNIMPLEMENTED(); |
| 10664 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10665 | } |
| 10666 | catch(std::bad_alloc&) |
| 10667 | { |
| 10668 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL)); |
| 10669 | } |
| 10670 | |
| 10671 | return NULL; |
| 10672 | } |
| 10673 | |
| 10674 | GLboolean __stdcall glIsSync(GLsync sync) |
| 10675 | { |
| 10676 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10677 | |
| 10678 | try |
| 10679 | { |
| 10680 | gl::Context *context = gl::getNonLostContext(); |
| 10681 | |
| 10682 | if (context) |
| 10683 | { |
| 10684 | if (context->getClientVersion() < 3) |
| 10685 | { |
| 10686 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10687 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10688 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10689 | UNIMPLEMENTED(); |
| 10690 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10691 | } |
| 10692 | catch(std::bad_alloc&) |
| 10693 | { |
| 10694 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10695 | } |
| 10696 | |
| 10697 | return GL_FALSE; |
| 10698 | } |
| 10699 | |
| 10700 | void __stdcall glDeleteSync(GLsync sync) |
| 10701 | { |
| 10702 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10703 | |
| 10704 | try |
| 10705 | { |
| 10706 | gl::Context *context = gl::getNonLostContext(); |
| 10707 | |
| 10708 | if (context) |
| 10709 | { |
| 10710 | if (context->getClientVersion() < 3) |
| 10711 | { |
| 10712 | return gl::error(GL_INVALID_OPERATION); |
| 10713 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10714 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10715 | UNIMPLEMENTED(); |
| 10716 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10717 | } |
| 10718 | catch(std::bad_alloc&) |
| 10719 | { |
| 10720 | return gl::error(GL_OUT_OF_MEMORY); |
| 10721 | } |
| 10722 | } |
| 10723 | |
| 10724 | GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10725 | { |
| 10726 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10727 | sync, flags, timeout); |
| 10728 | |
| 10729 | try |
| 10730 | { |
| 10731 | gl::Context *context = gl::getNonLostContext(); |
| 10732 | |
| 10733 | if (context) |
| 10734 | { |
| 10735 | if (context->getClientVersion() < 3) |
| 10736 | { |
| 10737 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10738 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10739 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10740 | UNIMPLEMENTED(); |
| 10741 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10742 | } |
| 10743 | catch(std::bad_alloc&) |
| 10744 | { |
| 10745 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10746 | } |
| 10747 | |
| 10748 | return GL_FALSE; |
| 10749 | } |
| 10750 | |
| 10751 | void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10752 | { |
| 10753 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10754 | sync, flags, timeout); |
| 10755 | |
| 10756 | try |
| 10757 | { |
| 10758 | gl::Context *context = gl::getNonLostContext(); |
| 10759 | |
| 10760 | if (context) |
| 10761 | { |
| 10762 | if (context->getClientVersion() < 3) |
| 10763 | { |
| 10764 | return gl::error(GL_INVALID_OPERATION); |
| 10765 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10766 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10767 | UNIMPLEMENTED(); |
| 10768 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10769 | } |
| 10770 | catch(std::bad_alloc&) |
| 10771 | { |
| 10772 | return gl::error(GL_OUT_OF_MEMORY); |
| 10773 | } |
| 10774 | } |
| 10775 | |
| 10776 | void __stdcall glGetInteger64v(GLenum pname, GLint64* params) |
| 10777 | { |
| 10778 | EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10779 | pname, params); |
| 10780 | |
| 10781 | try |
| 10782 | { |
| 10783 | gl::Context *context = gl::getNonLostContext(); |
| 10784 | |
| 10785 | if (context) |
| 10786 | { |
| 10787 | if (context->getClientVersion() < 3) |
| 10788 | { |
| 10789 | return gl::error(GL_INVALID_OPERATION); |
| 10790 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10791 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10792 | UNIMPLEMENTED(); |
| 10793 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10794 | } |
| 10795 | catch(std::bad_alloc&) |
| 10796 | { |
| 10797 | return gl::error(GL_OUT_OF_MEMORY); |
| 10798 | } |
| 10799 | } |
| 10800 | |
| 10801 | void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) |
| 10802 | { |
| 10803 | EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)", |
| 10804 | sync, pname, bufSize, length, values); |
| 10805 | |
| 10806 | try |
| 10807 | { |
| 10808 | gl::Context *context = gl::getNonLostContext(); |
| 10809 | |
| 10810 | if (context) |
| 10811 | { |
| 10812 | if (context->getClientVersion() < 3) |
| 10813 | { |
| 10814 | return gl::error(GL_INVALID_OPERATION); |
| 10815 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10816 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10817 | UNIMPLEMENTED(); |
| 10818 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10819 | } |
| 10820 | catch(std::bad_alloc&) |
| 10821 | { |
| 10822 | return gl::error(GL_OUT_OF_MEMORY); |
| 10823 | } |
| 10824 | } |
| 10825 | |
| 10826 | void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) |
| 10827 | { |
| 10828 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)", |
| 10829 | target, index, data); |
| 10830 | |
| 10831 | try |
| 10832 | { |
| 10833 | gl::Context *context = gl::getNonLostContext(); |
| 10834 | |
| 10835 | if (context) |
| 10836 | { |
| 10837 | if (context->getClientVersion() < 3) |
| 10838 | { |
| 10839 | return gl::error(GL_INVALID_OPERATION); |
| 10840 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10841 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10842 | UNIMPLEMENTED(); |
| 10843 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10844 | } |
| 10845 | catch(std::bad_alloc&) |
| 10846 | { |
| 10847 | return gl::error(GL_OUT_OF_MEMORY); |
| 10848 | } |
| 10849 | } |
| 10850 | |
| 10851 | void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) |
| 10852 | { |
| 10853 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10854 | target, pname, params); |
| 10855 | |
| 10856 | try |
| 10857 | { |
| 10858 | gl::Context *context = gl::getNonLostContext(); |
| 10859 | |
| 10860 | if (context) |
| 10861 | { |
| 10862 | if (context->getClientVersion() < 3) |
| 10863 | { |
| 10864 | return gl::error(GL_INVALID_OPERATION); |
| 10865 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10866 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10867 | UNIMPLEMENTED(); |
| 10868 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10869 | } |
| 10870 | catch(std::bad_alloc&) |
| 10871 | { |
| 10872 | return gl::error(GL_OUT_OF_MEMORY); |
| 10873 | } |
| 10874 | } |
| 10875 | |
| 10876 | void __stdcall glGenSamplers(GLsizei count, GLuint* samplers) |
| 10877 | { |
| 10878 | EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers); |
| 10879 | |
| 10880 | try |
| 10881 | { |
| 10882 | gl::Context *context = gl::getNonLostContext(); |
| 10883 | |
| 10884 | if (context) |
| 10885 | { |
| 10886 | if (context->getClientVersion() < 3) |
| 10887 | { |
| 10888 | return gl::error(GL_INVALID_OPERATION); |
| 10889 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10890 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10891 | UNIMPLEMENTED(); |
| 10892 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10893 | } |
| 10894 | catch(std::bad_alloc&) |
| 10895 | { |
| 10896 | return gl::error(GL_OUT_OF_MEMORY); |
| 10897 | } |
| 10898 | } |
| 10899 | |
| 10900 | void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers) |
| 10901 | { |
| 10902 | EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers); |
| 10903 | |
| 10904 | try |
| 10905 | { |
| 10906 | gl::Context *context = gl::getNonLostContext(); |
| 10907 | |
| 10908 | if (context) |
| 10909 | { |
| 10910 | if (context->getClientVersion() < 3) |
| 10911 | { |
| 10912 | return gl::error(GL_INVALID_OPERATION); |
| 10913 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10914 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10915 | UNIMPLEMENTED(); |
| 10916 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10917 | } |
| 10918 | catch(std::bad_alloc&) |
| 10919 | { |
| 10920 | return gl::error(GL_OUT_OF_MEMORY); |
| 10921 | } |
| 10922 | } |
| 10923 | |
| 10924 | GLboolean __stdcall glIsSampler(GLuint sampler) |
| 10925 | { |
| 10926 | EVENT("(GLuint sampler = %u)", sampler); |
| 10927 | |
| 10928 | try |
| 10929 | { |
| 10930 | gl::Context *context = gl::getNonLostContext(); |
| 10931 | |
| 10932 | if (context) |
| 10933 | { |
| 10934 | if (context->getClientVersion() < 3) |
| 10935 | { |
| 10936 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10937 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10938 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10939 | UNIMPLEMENTED(); |
| 10940 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10941 | } |
| 10942 | catch(std::bad_alloc&) |
| 10943 | { |
| 10944 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10945 | } |
| 10946 | |
| 10947 | return GL_FALSE; |
| 10948 | } |
| 10949 | |
| 10950 | void __stdcall glBindSampler(GLuint unit, GLuint sampler) |
| 10951 | { |
| 10952 | EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler); |
| 10953 | |
| 10954 | try |
| 10955 | { |
| 10956 | gl::Context *context = gl::getNonLostContext(); |
| 10957 | |
| 10958 | if (context) |
| 10959 | { |
| 10960 | if (context->getClientVersion() < 3) |
| 10961 | { |
| 10962 | return gl::error(GL_INVALID_OPERATION); |
| 10963 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10964 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10965 | UNIMPLEMENTED(); |
| 10966 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10967 | } |
| 10968 | catch(std::bad_alloc&) |
| 10969 | { |
| 10970 | return gl::error(GL_OUT_OF_MEMORY); |
| 10971 | } |
| 10972 | } |
| 10973 | |
| 10974 | void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 10975 | { |
| 10976 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param); |
| 10977 | |
| 10978 | try |
| 10979 | { |
| 10980 | gl::Context *context = gl::getNonLostContext(); |
| 10981 | |
| 10982 | if (context) |
| 10983 | { |
| 10984 | if (context->getClientVersion() < 3) |
| 10985 | { |
| 10986 | return gl::error(GL_INVALID_OPERATION); |
| 10987 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10988 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10989 | UNIMPLEMENTED(); |
| 10990 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10991 | } |
| 10992 | catch(std::bad_alloc&) |
| 10993 | { |
| 10994 | return gl::error(GL_OUT_OF_MEMORY); |
| 10995 | } |
| 10996 | } |
| 10997 | |
| 10998 | void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) |
| 10999 | { |
| 11000 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLint* param = 0x%0.8p)", |
| 11001 | sampler, pname, param); |
| 11002 | |
| 11003 | try |
| 11004 | { |
| 11005 | gl::Context *context = gl::getNonLostContext(); |
| 11006 | |
| 11007 | if (context) |
| 11008 | { |
| 11009 | if (context->getClientVersion() < 3) |
| 11010 | { |
| 11011 | return gl::error(GL_INVALID_OPERATION); |
| 11012 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11013 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11014 | UNIMPLEMENTED(); |
| 11015 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11016 | } |
| 11017 | catch(std::bad_alloc&) |
| 11018 | { |
| 11019 | return gl::error(GL_OUT_OF_MEMORY); |
| 11020 | } |
| 11021 | } |
| 11022 | |
| 11023 | void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 11024 | { |
| 11025 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param); |
| 11026 | |
| 11027 | try |
| 11028 | { |
| 11029 | gl::Context *context = gl::getNonLostContext(); |
| 11030 | |
| 11031 | if (context) |
| 11032 | { |
| 11033 | if (context->getClientVersion() < 3) |
| 11034 | { |
| 11035 | return gl::error(GL_INVALID_OPERATION); |
| 11036 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11037 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11038 | UNIMPLEMENTED(); |
| 11039 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11040 | } |
| 11041 | catch(std::bad_alloc&) |
| 11042 | { |
| 11043 | return gl::error(GL_OUT_OF_MEMORY); |
| 11044 | } |
| 11045 | } |
| 11046 | |
| 11047 | void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) |
| 11048 | { |
| 11049 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLfloat* param = 0x%0.8p)", sampler, pname, param); |
| 11050 | |
| 11051 | try |
| 11052 | { |
| 11053 | gl::Context *context = gl::getNonLostContext(); |
| 11054 | |
| 11055 | if (context) |
| 11056 | { |
| 11057 | if (context->getClientVersion() < 3) |
| 11058 | { |
| 11059 | return gl::error(GL_INVALID_OPERATION); |
| 11060 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11061 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11062 | UNIMPLEMENTED(); |
| 11063 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11064 | } |
| 11065 | catch(std::bad_alloc&) |
| 11066 | { |
| 11067 | return gl::error(GL_OUT_OF_MEMORY); |
| 11068 | } |
| 11069 | } |
| 11070 | |
| 11071 | void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) |
| 11072 | { |
| 11073 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); |
| 11074 | |
| 11075 | try |
| 11076 | { |
| 11077 | gl::Context *context = gl::getNonLostContext(); |
| 11078 | |
| 11079 | if (context) |
| 11080 | { |
| 11081 | if (context->getClientVersion() < 3) |
| 11082 | { |
| 11083 | return gl::error(GL_INVALID_OPERATION); |
| 11084 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11085 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11086 | UNIMPLEMENTED(); |
| 11087 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11088 | } |
| 11089 | catch(std::bad_alloc&) |
| 11090 | { |
| 11091 | return gl::error(GL_OUT_OF_MEMORY); |
| 11092 | } |
| 11093 | } |
| 11094 | |
| 11095 | void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) |
| 11096 | { |
| 11097 | EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params); |
| 11098 | |
| 11099 | try |
| 11100 | { |
| 11101 | gl::Context *context = gl::getNonLostContext(); |
| 11102 | |
| 11103 | if (context) |
| 11104 | { |
| 11105 | if (context->getClientVersion() < 3) |
| 11106 | { |
| 11107 | return gl::error(GL_INVALID_OPERATION); |
| 11108 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11109 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11110 | UNIMPLEMENTED(); |
| 11111 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11112 | } |
| 11113 | catch(std::bad_alloc&) |
| 11114 | { |
| 11115 | return gl::error(GL_OUT_OF_MEMORY); |
| 11116 | } |
| 11117 | } |
| 11118 | |
| 11119 | void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor) |
| 11120 | { |
| 11121 | EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor); |
| 11122 | |
| 11123 | try |
| 11124 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 11125 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 11126 | { |
| 11127 | return gl::error(GL_INVALID_VALUE); |
| 11128 | } |
| 11129 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11130 | gl::Context *context = gl::getNonLostContext(); |
| 11131 | |
| 11132 | if (context) |
| 11133 | { |
| 11134 | if (context->getClientVersion() < 3) |
| 11135 | { |
| 11136 | return gl::error(GL_INVALID_OPERATION); |
| 11137 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11138 | |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 11139 | context->setVertexAttribDivisor(index, divisor); |
| 11140 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11141 | } |
| 11142 | catch(std::bad_alloc&) |
| 11143 | { |
| 11144 | return gl::error(GL_OUT_OF_MEMORY); |
| 11145 | } |
| 11146 | } |
| 11147 | |
| 11148 | void __stdcall glBindTransformFeedback(GLenum target, GLuint id) |
| 11149 | { |
| 11150 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 11151 | |
| 11152 | try |
| 11153 | { |
| 11154 | gl::Context *context = gl::getNonLostContext(); |
| 11155 | |
| 11156 | if (context) |
| 11157 | { |
| 11158 | if (context->getClientVersion() < 3) |
| 11159 | { |
| 11160 | return gl::error(GL_INVALID_OPERATION); |
| 11161 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11162 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11163 | UNIMPLEMENTED(); |
| 11164 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11165 | } |
| 11166 | catch(std::bad_alloc&) |
| 11167 | { |
| 11168 | return gl::error(GL_OUT_OF_MEMORY); |
| 11169 | } |
| 11170 | } |
| 11171 | |
| 11172 | void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) |
| 11173 | { |
| 11174 | EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids); |
| 11175 | |
| 11176 | try |
| 11177 | { |
| 11178 | gl::Context *context = gl::getNonLostContext(); |
| 11179 | |
| 11180 | if (context) |
| 11181 | { |
| 11182 | if (context->getClientVersion() < 3) |
| 11183 | { |
| 11184 | return gl::error(GL_INVALID_OPERATION); |
| 11185 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11186 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11187 | UNIMPLEMENTED(); |
| 11188 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11189 | } |
| 11190 | catch(std::bad_alloc&) |
| 11191 | { |
| 11192 | return gl::error(GL_OUT_OF_MEMORY); |
| 11193 | } |
| 11194 | } |
| 11195 | |
| 11196 | void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids) |
| 11197 | { |
| 11198 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 11199 | |
| 11200 | try |
| 11201 | { |
| 11202 | gl::Context *context = gl::getNonLostContext(); |
| 11203 | |
| 11204 | if (context) |
| 11205 | { |
| 11206 | if (context->getClientVersion() < 3) |
| 11207 | { |
| 11208 | return gl::error(GL_INVALID_OPERATION); |
| 11209 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11210 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11211 | UNIMPLEMENTED(); |
| 11212 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11213 | } |
| 11214 | catch(std::bad_alloc&) |
| 11215 | { |
| 11216 | return gl::error(GL_OUT_OF_MEMORY); |
| 11217 | } |
| 11218 | } |
| 11219 | |
| 11220 | GLboolean __stdcall glIsTransformFeedback(GLuint id) |
| 11221 | { |
| 11222 | EVENT("(GLuint id = %u)", id); |
| 11223 | |
| 11224 | try |
| 11225 | { |
| 11226 | gl::Context *context = gl::getNonLostContext(); |
| 11227 | |
| 11228 | if (context) |
| 11229 | { |
| 11230 | if (context->getClientVersion() < 3) |
| 11231 | { |
| 11232 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 11233 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11234 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11235 | UNIMPLEMENTED(); |
| 11236 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11237 | } |
| 11238 | catch(std::bad_alloc&) |
| 11239 | { |
| 11240 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 11241 | } |
| 11242 | |
| 11243 | return GL_FALSE; |
| 11244 | } |
| 11245 | |
| 11246 | void __stdcall glPauseTransformFeedback(void) |
| 11247 | { |
| 11248 | EVENT("(void)"); |
| 11249 | |
| 11250 | try |
| 11251 | { |
| 11252 | gl::Context *context = gl::getNonLostContext(); |
| 11253 | |
| 11254 | if (context) |
| 11255 | { |
| 11256 | if (context->getClientVersion() < 3) |
| 11257 | { |
| 11258 | return gl::error(GL_INVALID_OPERATION); |
| 11259 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11260 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11261 | UNIMPLEMENTED(); |
| 11262 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11263 | } |
| 11264 | catch(std::bad_alloc&) |
| 11265 | { |
| 11266 | return gl::error(GL_OUT_OF_MEMORY); |
| 11267 | } |
| 11268 | } |
| 11269 | |
| 11270 | void __stdcall glResumeTransformFeedback(void) |
| 11271 | { |
| 11272 | EVENT("(void)"); |
| 11273 | |
| 11274 | try |
| 11275 | { |
| 11276 | gl::Context *context = gl::getNonLostContext(); |
| 11277 | |
| 11278 | if (context) |
| 11279 | { |
| 11280 | if (context->getClientVersion() < 3) |
| 11281 | { |
| 11282 | return gl::error(GL_INVALID_OPERATION); |
| 11283 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11284 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11285 | UNIMPLEMENTED(); |
| 11286 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11287 | } |
| 11288 | catch(std::bad_alloc&) |
| 11289 | { |
| 11290 | return gl::error(GL_OUT_OF_MEMORY); |
| 11291 | } |
| 11292 | } |
| 11293 | |
| 11294 | void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) |
| 11295 | { |
| 11296 | EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)", |
| 11297 | program, bufSize, length, binaryFormat, binary); |
| 11298 | |
| 11299 | try |
| 11300 | { |
| 11301 | gl::Context *context = gl::getNonLostContext(); |
| 11302 | |
| 11303 | if (context) |
| 11304 | { |
| 11305 | if (context->getClientVersion() < 3) |
| 11306 | { |
| 11307 | return gl::error(GL_INVALID_OPERATION); |
| 11308 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11309 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11310 | UNIMPLEMENTED(); |
| 11311 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11312 | } |
| 11313 | catch(std::bad_alloc&) |
| 11314 | { |
| 11315 | return gl::error(GL_OUT_OF_MEMORY); |
| 11316 | } |
| 11317 | } |
| 11318 | |
| 11319 | void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) |
| 11320 | { |
| 11321 | EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
| 11322 | program, binaryFormat, binary, length); |
| 11323 | |
| 11324 | try |
| 11325 | { |
| 11326 | gl::Context *context = gl::getNonLostContext(); |
| 11327 | |
| 11328 | if (context) |
| 11329 | { |
| 11330 | if (context->getClientVersion() < 3) |
| 11331 | { |
| 11332 | return gl::error(GL_INVALID_OPERATION); |
| 11333 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11334 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11335 | UNIMPLEMENTED(); |
| 11336 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11337 | } |
| 11338 | catch(std::bad_alloc&) |
| 11339 | { |
| 11340 | return gl::error(GL_OUT_OF_MEMORY); |
| 11341 | } |
| 11342 | } |
| 11343 | |
| 11344 | void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value) |
| 11345 | { |
| 11346 | EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)", |
| 11347 | program, pname, value); |
| 11348 | |
| 11349 | try |
| 11350 | { |
| 11351 | gl::Context *context = gl::getNonLostContext(); |
| 11352 | |
| 11353 | if (context) |
| 11354 | { |
| 11355 | if (context->getClientVersion() < 3) |
| 11356 | { |
| 11357 | return gl::error(GL_INVALID_OPERATION); |
| 11358 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11359 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11360 | UNIMPLEMENTED(); |
| 11361 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11362 | } |
| 11363 | catch(std::bad_alloc&) |
| 11364 | { |
| 11365 | return gl::error(GL_OUT_OF_MEMORY); |
| 11366 | } |
| 11367 | } |
| 11368 | |
| 11369 | void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) |
| 11370 | { |
| 11371 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)", |
| 11372 | target, numAttachments, attachments); |
| 11373 | |
| 11374 | try |
| 11375 | { |
| 11376 | gl::Context *context = gl::getNonLostContext(); |
| 11377 | |
| 11378 | if (context) |
| 11379 | { |
| 11380 | if (context->getClientVersion() < 3) |
| 11381 | { |
| 11382 | return gl::error(GL_INVALID_OPERATION); |
| 11383 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11384 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11385 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11386 | { |
| 11387 | return; |
| 11388 | } |
| 11389 | |
| 11390 | int maxDimension = context->getMaximumRenderbufferDimension(); |
| 11391 | context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension); |
| 11392 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11393 | } |
| 11394 | catch(std::bad_alloc&) |
| 11395 | { |
| 11396 | return gl::error(GL_OUT_OF_MEMORY); |
| 11397 | } |
| 11398 | } |
| 11399 | |
| 11400 | void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) |
| 11401 | { |
| 11402 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, " |
| 11403 | "GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 11404 | target, numAttachments, attachments, x, y, width, height); |
| 11405 | |
| 11406 | try |
| 11407 | { |
| 11408 | gl::Context *context = gl::getNonLostContext(); |
| 11409 | |
| 11410 | if (context) |
| 11411 | { |
| 11412 | if (context->getClientVersion() < 3) |
| 11413 | { |
| 11414 | return gl::error(GL_INVALID_OPERATION); |
| 11415 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11416 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11417 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11418 | { |
| 11419 | return; |
| 11420 | } |
| 11421 | |
| 11422 | context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height); |
| 11423 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11424 | } |
| 11425 | catch(std::bad_alloc&) |
| 11426 | { |
| 11427 | return gl::error(GL_OUT_OF_MEMORY); |
| 11428 | } |
| 11429 | } |
| 11430 | |
| 11431 | void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 11432 | { |
| 11433 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 11434 | target, levels, internalformat, width, height); |
| 11435 | |
| 11436 | try |
| 11437 | { |
| 11438 | gl::Context *context = gl::getNonLostContext(); |
| 11439 | |
| 11440 | if (context) |
| 11441 | { |
| 11442 | if (context->getClientVersion() < 3) |
| 11443 | { |
| 11444 | return gl::error(GL_INVALID_OPERATION); |
| 11445 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11446 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11447 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 11448 | { |
| 11449 | return; |
| 11450 | } |
| 11451 | |
| 11452 | switch (target) |
| 11453 | { |
| 11454 | case GL_TEXTURE_2D: |
| 11455 | { |
| 11456 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 11457 | texture2d->storage(levels, internalformat, width, height); |
| 11458 | } |
| 11459 | break; |
| 11460 | |
| 11461 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 11462 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 11463 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 11464 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 11465 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 11466 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 11467 | { |
| 11468 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 11469 | textureCube->storage(levels, internalformat, width); |
| 11470 | } |
| 11471 | break; |
| 11472 | |
| 11473 | default: |
| 11474 | return gl::error(GL_INVALID_ENUM); |
| 11475 | } |
| 11476 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11477 | } |
| 11478 | catch(std::bad_alloc&) |
| 11479 | { |
| 11480 | return gl::error(GL_OUT_OF_MEMORY); |
| 11481 | } |
| 11482 | } |
| 11483 | |
| 11484 | void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
| 11485 | { |
| 11486 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 11487 | "GLsizei height = %d, GLsizei depth = %d)", |
| 11488 | target, levels, internalformat, width, height, depth); |
| 11489 | |
| 11490 | try |
| 11491 | { |
| 11492 | gl::Context *context = gl::getNonLostContext(); |
| 11493 | |
| 11494 | if (context) |
| 11495 | { |
| 11496 | if (context->getClientVersion() < 3) |
| 11497 | { |
| 11498 | return gl::error(GL_INVALID_OPERATION); |
| 11499 | } |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11500 | |
| 11501 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) |
| 11502 | { |
| 11503 | return; |
| 11504 | } |
| 11505 | |
| 11506 | switch (target) |
| 11507 | { |
| 11508 | case GL_TEXTURE_3D: |
| 11509 | { |
| 11510 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 11511 | texture3d->storage(levels, internalformat, width, height, depth); |
| 11512 | } |
| 11513 | break; |
| 11514 | |
| 11515 | case GL_TEXTURE_2D_ARRAY: |
| 11516 | { |
| 11517 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 11518 | texture2darray->storage(levels, internalformat, width, height, depth); |
| 11519 | } |
| 11520 | break; |
| 11521 | |
| 11522 | default: |
| 11523 | return gl::error(GL_INVALID_ENUM); |
| 11524 | } |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 11525 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11526 | } |
| 11527 | catch(std::bad_alloc&) |
| 11528 | { |
| 11529 | return gl::error(GL_OUT_OF_MEMORY); |
| 11530 | } |
| 11531 | } |
| 11532 | |
| 11533 | void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) |
| 11534 | { |
| 11535 | EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, " |
| 11536 | "GLint* params = 0x%0.8p)", |
| 11537 | target, internalformat, pname, bufSize, params); |
| 11538 | |
| 11539 | try |
| 11540 | { |
| 11541 | gl::Context *context = gl::getNonLostContext(); |
| 11542 | |
| 11543 | if (context) |
| 11544 | { |
| 11545 | if (context->getClientVersion() < 3) |
| 11546 | { |
| 11547 | return gl::error(GL_INVALID_OPERATION); |
| 11548 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11549 | |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11550 | UNIMPLEMENTED(); |
| 11551 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11552 | } |
| 11553 | catch(std::bad_alloc&) |
| 11554 | { |
| 11555 | return gl::error(GL_OUT_OF_MEMORY); |
| 11556 | } |
| 11557 | } |
| 11558 | |
| 11559 | // Extension functions |
| 11560 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11561 | void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 11562 | GLbitfield mask, GLenum filter) |
| 11563 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11564 | 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] | 11565 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, " |
| 11566 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 11567 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 11568 | |
| 11569 | try |
| 11570 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11571 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11572 | |
| 11573 | if (context) |
| 11574 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11575 | if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 11576 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 11577 | true)) |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11578 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11579 | return; |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11580 | } |
| 11581 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11582 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 11583 | mask, filter); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11584 | } |
| 11585 | } |
| 11586 | catch(std::bad_alloc&) |
| 11587 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11588 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11589 | } |
| 11590 | } |
| 11591 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 11592 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, |
| 11593 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11594 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11595 | 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] | 11596 | "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] | 11597 | "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] | 11598 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 11599 | |
| 11600 | try |
| 11601 | { |
| 11602 | UNIMPLEMENTED(); // FIXME |
| 11603 | } |
| 11604 | catch(std::bad_alloc&) |
| 11605 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11606 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11607 | } |
| 11608 | } |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11609 | |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11610 | void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, |
| 11611 | GLenum *binaryFormat, void *binary) |
| 11612 | { |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11613 | 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] | 11614 | program, bufSize, length, binaryFormat, binary); |
| 11615 | |
| 11616 | try |
| 11617 | { |
| 11618 | gl::Context *context = gl::getNonLostContext(); |
| 11619 | |
| 11620 | if (context) |
| 11621 | { |
| 11622 | gl::Program *programObject = context->getProgram(program); |
| 11623 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 11624 | if (!programObject || !programObject->isLinked()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11625 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11626 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11627 | } |
| 11628 | |
| 11629 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 11630 | |
| 11631 | if (!programBinary) |
| 11632 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11633 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11634 | } |
| 11635 | |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11636 | if (!programBinary->save(binary, bufSize, length)) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11637 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11638 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11639 | } |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11640 | |
| 11641 | *binaryFormat = GL_PROGRAM_BINARY_ANGLE; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11642 | } |
| 11643 | } |
| 11644 | catch(std::bad_alloc&) |
| 11645 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11646 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11647 | } |
| 11648 | } |
| 11649 | |
| 11650 | void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat, |
| 11651 | const void *binary, GLint length) |
| 11652 | { |
| 11653 | EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)", |
| 11654 | program, binaryFormat, binary, length); |
| 11655 | |
| 11656 | try |
| 11657 | { |
| 11658 | gl::Context *context = gl::getNonLostContext(); |
| 11659 | |
| 11660 | if (context) |
| 11661 | { |
| 11662 | if (binaryFormat != GL_PROGRAM_BINARY_ANGLE) |
| 11663 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11664 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11665 | } |
| 11666 | |
| 11667 | gl::Program *programObject = context->getProgram(program); |
| 11668 | |
| 11669 | if (!programObject) |
| 11670 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11671 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11672 | } |
| 11673 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 11674 | context->setProgramBinary(program, binary, length); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11675 | } |
| 11676 | } |
| 11677 | catch(std::bad_alloc&) |
| 11678 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11679 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11680 | } |
| 11681 | } |
| 11682 | |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11683 | void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) |
| 11684 | { |
| 11685 | EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs); |
| 11686 | |
| 11687 | try |
| 11688 | { |
| 11689 | gl::Context *context = gl::getNonLostContext(); |
| 11690 | |
| 11691 | if (context) |
| 11692 | { |
| 11693 | if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets()) |
| 11694 | { |
| 11695 | return gl::error(GL_INVALID_VALUE); |
| 11696 | } |
| 11697 | |
| 11698 | if (context->getDrawFramebufferHandle() == 0) |
| 11699 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11700 | if (n != 1) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11701 | { |
| 11702 | return gl::error(GL_INVALID_OPERATION); |
| 11703 | } |
| 11704 | |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11705 | 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] | 11706 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11707 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11708 | } |
| 11709 | } |
| 11710 | else |
| 11711 | { |
| 11712 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 11713 | { |
| 11714 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 11715 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment) |
| 11716 | { |
| 11717 | return gl::error(GL_INVALID_OPERATION); |
| 11718 | } |
| 11719 | } |
| 11720 | } |
| 11721 | |
| 11722 | gl::Framebuffer *framebuffer = context->getDrawFramebuffer(); |
| 11723 | |
| 11724 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 11725 | { |
| 11726 | framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]); |
| 11727 | } |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11728 | |
| 11729 | for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++) |
| 11730 | { |
| 11731 | framebuffer->setDrawBufferState(colorAttachment, GL_NONE); |
| 11732 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11733 | } |
| 11734 | } |
| 11735 | catch (std::bad_alloc&) |
| 11736 | { |
| 11737 | return gl::error(GL_OUT_OF_MEMORY); |
| 11738 | } |
| 11739 | } |
| 11740 | |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11741 | __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) |
| 11742 | { |
| 11743 | struct Extension |
| 11744 | { |
| 11745 | const char *name; |
| 11746 | __eglMustCastToProperFunctionPointerType address; |
| 11747 | }; |
| 11748 | |
| 11749 | static const Extension glExtensions[] = |
| 11750 | { |
| 11751 | {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 11752 | {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, |
daniel@transgaming.com | 1fe96c9 | 2011-01-14 15:08:44 +0000 | [diff] [blame] | 11753 | {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 11754 | {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, |
| 11755 | {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, |
| 11756 | {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, |
| 11757 | {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, |
| 11758 | {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, |
| 11759 | {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, |
| 11760 | {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 11761 | {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE}, |
daniel@transgaming.com | 0bd1f2f | 2011-11-11 04:19:03 +0000 | [diff] [blame] | 11762 | {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT}, |
daniel@transgaming.com | 709ed11 | 2011-11-12 03:18:10 +0000 | [diff] [blame] | 11763 | {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT}, |
| 11764 | {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT}, |
| 11765 | {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT}, |
| 11766 | {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT}, |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 11767 | {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT}, |
| 11768 | {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT}, |
| 11769 | {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT}, |
| 11770 | {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT}, |
| 11771 | {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT}, |
| 11772 | {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT}, |
| 11773 | {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT}, |
shannon.woods%transgaming.com@gtempaccount.com | 77d9472 | 2013-04-13 03:34:22 +0000 | [diff] [blame] | 11774 | {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT}, |
daniel@transgaming.com | dce02fd | 2012-01-27 15:39:51 +0000 | [diff] [blame] | 11775 | {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE}, |
| 11776 | {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, |
| 11777 | {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11778 | {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, |
| 11779 | {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, }; |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11780 | |
shannon.woods@transgaming.com | d438fd4 | 2013-02-28 23:17:45 +0000 | [diff] [blame] | 11781 | for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11782 | { |
| 11783 | if (strcmp(procname, glExtensions[ext].name) == 0) |
| 11784 | { |
| 11785 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address; |
| 11786 | } |
| 11787 | } |
| 11788 | |
| 11789 | return NULL; |
| 11790 | } |
| 11791 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 11792 | // Non-public functions used by EGL |
| 11793 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11794 | bool __stdcall glBindTexImage(egl::Surface *surface) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11795 | { |
| 11796 | EVENT("(egl::Surface* surface = 0x%0.8p)", |
| 11797 | surface); |
| 11798 | |
| 11799 | try |
| 11800 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11801 | gl::Context *context = gl::getNonLostContext(); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11802 | |
| 11803 | if (context) |
| 11804 | { |
| 11805 | gl::Texture2D *textureObject = context->getTexture2D(); |
| 11806 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11807 | if (textureObject->isImmutable()) |
| 11808 | { |
| 11809 | return false; |
| 11810 | } |
| 11811 | |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11812 | if (textureObject) |
| 11813 | { |
| 11814 | textureObject->bindTexImage(surface); |
| 11815 | } |
| 11816 | } |
| 11817 | } |
| 11818 | catch(std::bad_alloc&) |
| 11819 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11820 | return gl::error(GL_OUT_OF_MEMORY, false); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11821 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11822 | |
| 11823 | return true; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11824 | } |
| 11825 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11826 | } |