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" |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 24 | #include "libGLESv2/VertexArray.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 25 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 26 | 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] | 27 | { |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 28 | if (level < 0 || width < 0 || height < 0 || depth < 0) |
daniel@transgaming.com | 4f9ef0d | 2011-05-30 23:51:19 +0000 | [diff] [blame] | 29 | { |
| 30 | return false; |
| 31 | } |
| 32 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 33 | if (context->supportsNonPower2Texture()) |
daniel@transgaming.com | 4f9ef0d | 2011-05-30 23:51:19 +0000 | [diff] [blame] | 34 | { |
| 35 | return true; |
| 36 | } |
| 37 | |
| 38 | if (level == 0) |
| 39 | { |
| 40 | return true; |
| 41 | } |
| 42 | |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 43 | if (gl::isPow2(width) && gl::isPow2(height) && gl::isPow2(depth)) |
daniel@transgaming.com | 4f9ef0d | 2011-05-30 23:51:19 +0000 | [diff] [blame] | 44 | { |
| 45 | return true; |
| 46 | } |
| 47 | |
| 48 | return false; |
| 49 | } |
| 50 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 51 | bool validCompressedImageSize(GLsizei width, GLsizei height) |
| 52 | { |
| 53 | if (width != 1 && width != 2 && width % 4 != 0) |
| 54 | { |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | if (height != 1 && height != 2 && height % 4 != 0) |
| 59 | { |
| 60 | return false; |
| 61 | } |
| 62 | |
| 63 | return true; |
| 64 | } |
| 65 | |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 66 | // Verify that format/type are one of the combinations from table 3.4. |
| 67 | bool checkTextureFormatType(GLenum format, GLenum type) |
| 68 | { |
| 69 | // validate <format> by itself (used as secondary key below) |
| 70 | switch (format) |
| 71 | { |
| 72 | case GL_RGBA: |
| 73 | case GL_BGRA_EXT: |
| 74 | case GL_RGB: |
| 75 | case GL_ALPHA: |
| 76 | case GL_LUMINANCE: |
| 77 | case GL_LUMINANCE_ALPHA: |
| 78 | case GL_DEPTH_COMPONENT: |
| 79 | case GL_DEPTH_STENCIL_OES: |
| 80 | break; |
| 81 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 82 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | // invalid <type> -> sets INVALID_ENUM |
| 86 | // invalid <format>+<type> combination -> sets INVALID_OPERATION |
| 87 | switch (type) |
| 88 | { |
| 89 | case GL_UNSIGNED_BYTE: |
| 90 | switch (format) |
| 91 | { |
| 92 | case GL_RGBA: |
| 93 | case GL_BGRA_EXT: |
| 94 | case GL_RGB: |
| 95 | case GL_ALPHA: |
| 96 | case GL_LUMINANCE: |
| 97 | case GL_LUMINANCE_ALPHA: |
| 98 | return true; |
| 99 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 100 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | case GL_FLOAT: |
| 104 | case GL_HALF_FLOAT_OES: |
| 105 | switch (format) |
| 106 | { |
| 107 | case GL_RGBA: |
| 108 | case GL_RGB: |
| 109 | case GL_ALPHA: |
| 110 | case GL_LUMINANCE: |
| 111 | case GL_LUMINANCE_ALPHA: |
| 112 | return true; |
| 113 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 114 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 118 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 119 | switch (format) |
| 120 | { |
| 121 | case GL_RGBA: |
| 122 | return true; |
| 123 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 124 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | case GL_UNSIGNED_SHORT_5_6_5: |
| 128 | switch (format) |
| 129 | { |
| 130 | case GL_RGB: |
| 131 | return true; |
| 132 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 133 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | case GL_UNSIGNED_SHORT: |
| 137 | case GL_UNSIGNED_INT: |
| 138 | switch (format) |
| 139 | { |
| 140 | case GL_DEPTH_COMPONENT: |
| 141 | return true; |
| 142 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 143 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | case GL_UNSIGNED_INT_24_8_OES: |
| 147 | switch (format) |
| 148 | { |
| 149 | case GL_DEPTH_STENCIL_OES: |
| 150 | return true; |
| 151 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 152 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 156 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 157 | } |
| 158 | } |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 159 | |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 160 | bool validateSubImageParams2D(bool compressed, GLsizei width, GLsizei height, |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 161 | GLint xoffset, GLint yoffset, GLint level, GLenum format, GLenum type, |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 162 | gl::Texture2D *texture) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 163 | { |
| 164 | if (!texture) |
| 165 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 166 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 167 | } |
| 168 | |
daniel@transgaming.com | 92f4992 | 2012-05-09 15:49:19 +0000 | [diff] [blame] | 169 | if (compressed != texture->isCompressed(level)) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 170 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 171 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 172 | } |
| 173 | |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 174 | if (format != GL_NONE) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 175 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 176 | GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 177 | if (internalformat != texture->getInternalFormat(level)) |
| 178 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 179 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 180 | } |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | if (compressed) |
| 184 | { |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 185 | if ((width % 4 != 0 && width != texture->getWidth(0)) || |
| 186 | (height % 4 != 0 && height != texture->getHeight(0))) |
| 187 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 188 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 189 | } |
| 190 | } |
| 191 | |
| 192 | if (xoffset + width > texture->getWidth(level) || |
| 193 | yoffset + height > texture->getHeight(level)) |
| 194 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 195 | return gl::error(GL_INVALID_VALUE, false); |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | return true; |
| 199 | } |
| 200 | |
| 201 | bool validateSubImageParamsCube(bool compressed, GLsizei width, GLsizei height, |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 202 | 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] | 203 | gl::TextureCubeMap *texture) |
| 204 | { |
| 205 | if (!texture) |
| 206 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 207 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 208 | } |
| 209 | |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 210 | if (compressed != texture->isCompressed(target, level)) |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 211 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 212 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 213 | } |
| 214 | |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 215 | if (format != GL_NONE) |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 216 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 217 | GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 218 | if (internalformat != texture->getInternalFormat(target, level)) |
| 219 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 220 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 221 | } |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | if (compressed) |
| 225 | { |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 226 | if ((width % 4 != 0 && width != texture->getWidth(target, 0)) || |
| 227 | (height % 4 != 0 && height != texture->getHeight(target, 0))) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 228 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 229 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 230 | } |
| 231 | } |
| 232 | |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 233 | if (xoffset + width > texture->getWidth(target, level) || |
| 234 | yoffset + height > texture->getHeight(target, level)) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 235 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 236 | return gl::error(GL_INVALID_VALUE, false); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | return true; |
| 240 | } |
| 241 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 242 | bool validateES2TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage, |
| 243 | GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 244 | GLint border, GLenum format, GLenum type, const GLvoid *pixels) |
| 245 | { |
| 246 | if (!validImageSize(context, level, width, height, 1)) |
| 247 | { |
| 248 | return gl::error(GL_INVALID_VALUE, false); |
| 249 | } |
| 250 | |
| 251 | if (isCompressed && !validCompressedImageSize(width, height)) |
| 252 | { |
| 253 | return gl::error(GL_INVALID_OPERATION, false); |
| 254 | } |
| 255 | |
| 256 | if (level < 0 || xoffset < 0 || |
| 257 | std::numeric_limits<GLsizei>::max() - xoffset < width || |
| 258 | std::numeric_limits<GLsizei>::max() - yoffset < height) |
| 259 | { |
| 260 | return gl::error(GL_INVALID_VALUE, false); |
| 261 | } |
| 262 | |
| 263 | if (!isSubImage && !isCompressed && internalformat != GLint(format)) |
| 264 | { |
| 265 | return gl::error(GL_INVALID_OPERATION, false); |
| 266 | } |
| 267 | |
| 268 | gl::Texture *texture = NULL; |
| 269 | bool textureCompressed = false; |
| 270 | GLenum textureInternalFormat = GL_NONE; |
| 271 | GLint textureLevelWidth = 0; |
| 272 | GLint textureLevelHeight = 0; |
| 273 | switch (target) |
| 274 | { |
| 275 | case GL_TEXTURE_2D: |
| 276 | { |
| 277 | if (width > (context->getMaximum2DTextureDimension() >> level) || |
| 278 | height > (context->getMaximum2DTextureDimension() >> level)) |
| 279 | { |
| 280 | return gl::error(GL_INVALID_VALUE, false); |
| 281 | } |
| 282 | |
| 283 | gl::Texture2D *tex2d = context->getTexture2D(); |
| 284 | if (tex2d) |
| 285 | { |
| 286 | textureCompressed = tex2d->isCompressed(level); |
| 287 | textureInternalFormat = tex2d->getInternalFormat(level); |
| 288 | textureLevelWidth = tex2d->getWidth(level); |
| 289 | textureLevelHeight = tex2d->getHeight(level); |
| 290 | texture = tex2d; |
| 291 | } |
| 292 | |
| 293 | if (isSubImage && !validateSubImageParams2D(isCompressed, width, height, xoffset, yoffset, |
| 294 | level, format, type, tex2d)) |
| 295 | { |
| 296 | return false; |
| 297 | } |
| 298 | |
| 299 | texture = tex2d; |
| 300 | } |
| 301 | break; |
| 302 | |
| 303 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 304 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 305 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 306 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 307 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 308 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 309 | { |
| 310 | if (!isSubImage && width != height) |
| 311 | { |
| 312 | return gl::error(GL_INVALID_VALUE, false); |
| 313 | } |
| 314 | |
| 315 | if (width > (context->getMaximumCubeTextureDimension() >> level) || |
| 316 | height > (context->getMaximumCubeTextureDimension() >> level)) |
| 317 | { |
| 318 | return gl::error(GL_INVALID_VALUE, false); |
| 319 | } |
| 320 | |
| 321 | gl::TextureCubeMap *texCube = context->getTextureCubeMap(); |
| 322 | if (texCube) |
| 323 | { |
| 324 | textureCompressed = texCube->isCompressed(target, level); |
| 325 | textureInternalFormat = texCube->getInternalFormat(target, level); |
| 326 | textureLevelWidth = texCube->getWidth(target, level); |
| 327 | textureLevelHeight = texCube->getHeight(target, level); |
| 328 | texture = texCube; |
| 329 | } |
| 330 | |
| 331 | if (isSubImage && !validateSubImageParamsCube(isCompressed, width, height, xoffset, yoffset, |
| 332 | target, level, format, type, texCube)) |
| 333 | { |
| 334 | return false; |
| 335 | } |
| 336 | } |
| 337 | break; |
| 338 | |
| 339 | default: |
| 340 | return gl::error(GL_INVALID_ENUM, false); |
| 341 | } |
| 342 | |
| 343 | if (!texture) |
| 344 | { |
| 345 | return gl::error(GL_INVALID_OPERATION, false); |
| 346 | } |
| 347 | |
| 348 | if (!isSubImage && texture->isImmutable()) |
| 349 | { |
| 350 | return gl::error(GL_INVALID_OPERATION, false); |
| 351 | } |
| 352 | |
| 353 | // Verify zero border |
| 354 | if (border != 0) |
| 355 | { |
| 356 | return gl::error(GL_INVALID_VALUE, false); |
| 357 | } |
| 358 | |
| 359 | // Verify texture is not requesting more mip levels than are available. |
| 360 | if (level > context->getMaximumTextureLevel()) |
| 361 | { |
| 362 | return gl::error(GL_INVALID_VALUE, false); |
| 363 | } |
| 364 | |
| 365 | GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat; |
| 366 | if (isCompressed) |
| 367 | { |
| 368 | switch (actualInternalFormat) |
| 369 | { |
| 370 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 371 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 372 | if (!context->supportsDXT1Textures()) |
| 373 | { |
| 374 | return gl::error(GL_INVALID_ENUM, false); |
| 375 | } |
| 376 | break; |
| 377 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 378 | if (!context->supportsDXT3Textures()) |
| 379 | { |
| 380 | return gl::error(GL_INVALID_ENUM, false); |
| 381 | } |
| 382 | break; |
| 383 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 384 | if (!context->supportsDXT5Textures()) |
| 385 | { |
| 386 | return gl::error(GL_INVALID_ENUM, false); |
| 387 | } |
| 388 | break; |
| 389 | default: |
| 390 | return gl::error(GL_INVALID_ENUM, false); |
| 391 | } |
| 392 | } |
| 393 | else |
| 394 | { |
| 395 | // validate <type> by itself (used as secondary key below) |
| 396 | switch (type) |
| 397 | { |
| 398 | case GL_UNSIGNED_BYTE: |
| 399 | case GL_UNSIGNED_SHORT_5_6_5: |
| 400 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 401 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 402 | case GL_UNSIGNED_SHORT: |
| 403 | case GL_UNSIGNED_INT: |
| 404 | case GL_UNSIGNED_INT_24_8_OES: |
| 405 | case GL_HALF_FLOAT_OES: |
| 406 | case GL_FLOAT: |
| 407 | break; |
| 408 | default: |
| 409 | return gl::error(GL_INVALID_ENUM, false); |
| 410 | } |
| 411 | |
| 412 | // validate <format> + <type> combinations |
| 413 | // - invalid <format> -> sets INVALID_ENUM |
| 414 | // - invalid <format>+<type> combination -> sets INVALID_OPERATION |
| 415 | switch (format) |
| 416 | { |
| 417 | case GL_ALPHA: |
| 418 | case GL_LUMINANCE: |
| 419 | case GL_LUMINANCE_ALPHA: |
| 420 | switch (type) |
| 421 | { |
| 422 | case GL_UNSIGNED_BYTE: |
| 423 | case GL_FLOAT: |
| 424 | case GL_HALF_FLOAT_OES: |
| 425 | break; |
| 426 | default: |
| 427 | return gl::error(GL_INVALID_OPERATION, false); |
| 428 | } |
| 429 | break; |
| 430 | case GL_RGB: |
| 431 | switch (type) |
| 432 | { |
| 433 | case GL_UNSIGNED_BYTE: |
| 434 | case GL_UNSIGNED_SHORT_5_6_5: |
| 435 | case GL_FLOAT: |
| 436 | case GL_HALF_FLOAT_OES: |
| 437 | break; |
| 438 | default: |
| 439 | return gl::error(GL_INVALID_OPERATION, false); |
| 440 | } |
| 441 | break; |
| 442 | case GL_RGBA: |
| 443 | switch (type) |
| 444 | { |
| 445 | case GL_UNSIGNED_BYTE: |
| 446 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 447 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 448 | case GL_FLOAT: |
| 449 | case GL_HALF_FLOAT_OES: |
| 450 | break; |
| 451 | default: |
| 452 | return gl::error(GL_INVALID_OPERATION, false); |
| 453 | } |
| 454 | break; |
| 455 | case GL_BGRA_EXT: |
| 456 | switch (type) |
| 457 | { |
| 458 | case GL_UNSIGNED_BYTE: |
| 459 | break; |
| 460 | default: |
| 461 | return gl::error(GL_INVALID_OPERATION, false); |
| 462 | } |
| 463 | break; |
| 464 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below |
| 465 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 466 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 467 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 468 | break; |
| 469 | case GL_DEPTH_COMPONENT: |
| 470 | switch (type) |
| 471 | { |
| 472 | case GL_UNSIGNED_SHORT: |
| 473 | case GL_UNSIGNED_INT: |
| 474 | break; |
| 475 | default: |
| 476 | return gl::error(GL_INVALID_OPERATION, false); |
| 477 | } |
| 478 | break; |
| 479 | case GL_DEPTH_STENCIL_OES: |
| 480 | switch (type) |
| 481 | { |
| 482 | case GL_UNSIGNED_INT_24_8_OES: |
| 483 | break; |
| 484 | default: |
| 485 | return gl::error(GL_INVALID_OPERATION, false); |
| 486 | } |
| 487 | break; |
| 488 | default: |
| 489 | return gl::error(GL_INVALID_ENUM, false); |
| 490 | } |
| 491 | |
| 492 | switch (format) |
| 493 | { |
| 494 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 495 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 496 | if (context->supportsDXT1Textures()) |
| 497 | { |
| 498 | return gl::error(GL_INVALID_OPERATION, false); |
| 499 | } |
| 500 | else |
| 501 | { |
| 502 | return gl::error(GL_INVALID_ENUM, false); |
| 503 | } |
| 504 | break; |
| 505 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 506 | if (context->supportsDXT3Textures()) |
| 507 | { |
| 508 | return gl::error(GL_INVALID_OPERATION, false); |
| 509 | } |
| 510 | else |
| 511 | { |
| 512 | return gl::error(GL_INVALID_ENUM, false); |
| 513 | } |
| 514 | break; |
| 515 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 516 | if (context->supportsDXT5Textures()) |
| 517 | { |
| 518 | return gl::error(GL_INVALID_OPERATION, false); |
| 519 | } |
| 520 | else |
| 521 | { |
| 522 | return gl::error(GL_INVALID_ENUM, false); |
| 523 | } |
| 524 | break; |
| 525 | case GL_DEPTH_COMPONENT: |
| 526 | case GL_DEPTH_STENCIL_OES: |
| 527 | if (!context->supportsDepthTextures()) |
| 528 | { |
| 529 | return gl::error(GL_INVALID_VALUE, false); |
| 530 | } |
| 531 | if (target != GL_TEXTURE_2D) |
| 532 | { |
| 533 | return gl::error(GL_INVALID_OPERATION, false); |
| 534 | } |
| 535 | // OES_depth_texture supports loading depth data and multiple levels, |
| 536 | // but ANGLE_depth_texture does not |
| 537 | if (pixels != NULL || level != 0) |
| 538 | { |
| 539 | return gl::error(GL_INVALID_OPERATION, false); |
| 540 | } |
| 541 | break; |
| 542 | default: |
| 543 | break; |
| 544 | } |
| 545 | |
| 546 | if (type == GL_FLOAT) |
| 547 | { |
| 548 | if (!context->supportsFloat32Textures()) |
| 549 | { |
| 550 | return gl::error(GL_INVALID_ENUM, false); |
| 551 | } |
| 552 | } |
| 553 | else if (type == GL_HALF_FLOAT_OES) |
| 554 | { |
| 555 | if (!context->supportsFloat16Textures()) |
| 556 | { |
| 557 | return gl::error(GL_INVALID_ENUM, false); |
| 558 | } |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | return true; |
| 563 | } |
| 564 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 565 | bool validateES3TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage, |
| 566 | GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, |
| 567 | GLint border, GLenum format, GLenum type) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 568 | { |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 569 | // Validate image size |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 570 | if (!validImageSize(context, level, width, height, depth)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 571 | { |
| 572 | return gl::error(GL_INVALID_VALUE, false); |
| 573 | } |
| 574 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 575 | if (isCompressed && !validCompressedImageSize(width, height)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 576 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 577 | return gl::error(GL_INVALID_OPERATION, false); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | // Verify zero border |
| 581 | if (border != 0) |
| 582 | { |
| 583 | return gl::error(GL_INVALID_VALUE, false); |
| 584 | } |
| 585 | |
| 586 | // Validate dimensions based on Context limits and validate the texture |
| 587 | if (level > context->getMaximumTextureLevel()) |
| 588 | { |
| 589 | return gl::error(GL_INVALID_VALUE, false); |
| 590 | } |
| 591 | |
| 592 | gl::Texture *texture = NULL; |
| 593 | bool textureCompressed = false; |
| 594 | GLenum textureInternalFormat = GL_NONE; |
| 595 | GLint textureLevelWidth = 0; |
| 596 | GLint textureLevelHeight = 0; |
| 597 | GLint textureLevelDepth = 0; |
| 598 | switch (target) |
| 599 | { |
| 600 | case GL_TEXTURE_2D: |
| 601 | { |
| 602 | if (width > (context->getMaximum2DTextureDimension() >> level) || |
| 603 | height > (context->getMaximum2DTextureDimension() >> level)) |
| 604 | { |
| 605 | return gl::error(GL_INVALID_VALUE, false); |
| 606 | } |
| 607 | |
| 608 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 609 | if (texture2d) |
| 610 | { |
| 611 | textureCompressed = texture2d->isCompressed(level); |
| 612 | textureInternalFormat = texture2d->getInternalFormat(level); |
| 613 | textureLevelWidth = texture2d->getWidth(level); |
| 614 | textureLevelHeight = texture2d->getHeight(level); |
| 615 | textureLevelDepth = 1; |
| 616 | texture = texture2d; |
| 617 | } |
| 618 | } |
| 619 | break; |
| 620 | |
| 621 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 622 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 623 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 624 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 625 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 626 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 627 | { |
shannonwoods@chromium.org | 92852cf | 2013-05-30 00:14:12 +0000 | [diff] [blame] | 628 | if (!isSubImage && width != height) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 629 | { |
| 630 | return gl::error(GL_INVALID_VALUE, false); |
| 631 | } |
| 632 | |
| 633 | if (width > (context->getMaximumCubeTextureDimension() >> level)) |
| 634 | { |
| 635 | return gl::error(GL_INVALID_VALUE, false); |
| 636 | } |
| 637 | |
| 638 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 639 | if (textureCube) |
| 640 | { |
| 641 | textureCompressed = textureCube->isCompressed(target, level); |
| 642 | textureInternalFormat = textureCube->getInternalFormat(target, level); |
| 643 | textureLevelWidth = textureCube->getWidth(target, level); |
| 644 | textureLevelHeight = textureCube->getHeight(target, level); |
| 645 | textureLevelDepth = 1; |
| 646 | texture = textureCube; |
| 647 | } |
| 648 | } |
| 649 | break; |
| 650 | |
| 651 | case GL_TEXTURE_3D: |
| 652 | { |
| 653 | if (width > (context->getMaximum3DTextureDimension() >> level) || |
| 654 | height > (context->getMaximum3DTextureDimension() >> level) || |
| 655 | depth > (context->getMaximum3DTextureDimension() >> level)) |
| 656 | { |
| 657 | return gl::error(GL_INVALID_VALUE, false); |
| 658 | } |
| 659 | |
| 660 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 661 | if (texture3d) |
| 662 | { |
| 663 | textureCompressed = texture3d->isCompressed(level); |
| 664 | textureInternalFormat = texture3d->getInternalFormat(level); |
| 665 | textureLevelWidth = texture3d->getWidth(level); |
| 666 | textureLevelHeight = texture3d->getHeight(level); |
| 667 | textureLevelDepth = texture3d->getDepth(level); |
| 668 | texture = texture3d; |
| 669 | } |
| 670 | } |
| 671 | break; |
| 672 | |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 673 | case GL_TEXTURE_2D_ARRAY: |
| 674 | { |
| 675 | if (width > (context->getMaximum2DTextureDimension() >> level) || |
| 676 | height > (context->getMaximum2DTextureDimension() >> level) || |
| 677 | depth > (context->getMaximum2DArrayTextureLayers() >> level)) |
| 678 | { |
| 679 | return gl::error(GL_INVALID_VALUE, false); |
| 680 | } |
| 681 | |
| 682 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 683 | if (texture2darray) |
| 684 | { |
| 685 | textureCompressed = texture2darray->isCompressed(level); |
| 686 | textureInternalFormat = texture2darray->getInternalFormat(level); |
| 687 | textureLevelWidth = texture2darray->getWidth(level); |
| 688 | textureLevelHeight = texture2darray->getHeight(level); |
| 689 | textureLevelDepth = texture2darray->getDepth(level); |
| 690 | texture = texture2darray; |
| 691 | } |
| 692 | } |
| 693 | break; |
| 694 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 695 | default: |
| 696 | return gl::error(GL_INVALID_ENUM, false); |
| 697 | } |
| 698 | |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 699 | if (!texture) |
| 700 | { |
| 701 | return gl::error(GL_INVALID_OPERATION, false); |
| 702 | } |
| 703 | |
shannonwoods@chromium.org | cf2533c | 2013-05-30 00:14:18 +0000 | [diff] [blame] | 704 | if (texture->isImmutable() && !isSubImage) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 705 | { |
| 706 | return gl::error(GL_INVALID_OPERATION, false); |
| 707 | } |
| 708 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 709 | // Validate texture formats |
| 710 | GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat; |
| 711 | if (isCompressed) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 712 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 713 | if (!gl::IsFormatCompressed(actualInternalFormat, context->getClientVersion())) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 714 | { |
| 715 | return gl::error(GL_INVALID_ENUM, false); |
| 716 | } |
| 717 | |
| 718 | if (target == GL_TEXTURE_3D) |
| 719 | { |
| 720 | return gl::error(GL_INVALID_OPERATION, false); |
| 721 | } |
| 722 | } |
| 723 | else |
| 724 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 725 | if (!gl::IsValidInternalFormat(actualInternalFormat, context) || |
| 726 | !gl::IsValidFormat(format, context->getClientVersion()) || |
| 727 | !gl::IsValidType(type, context->getClientVersion())) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 728 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 729 | return gl::error(GL_INVALID_ENUM, false); |
| 730 | } |
| 731 | |
| 732 | if (!gl::IsValidFormatCombination(actualInternalFormat, format, type, context->getClientVersion())) |
| 733 | { |
| 734 | return gl::error(GL_INVALID_OPERATION, false); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 735 | } |
| 736 | |
| 737 | if ((target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) && |
| 738 | (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL)) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 739 | { |
| 740 | return gl::error(GL_INVALID_OPERATION, false); |
| 741 | } |
| 742 | } |
| 743 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 744 | // Validate sub image parameters |
| 745 | if (isSubImage) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 746 | { |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 747 | if (isCompressed != textureCompressed) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 748 | { |
| 749 | return gl::error(GL_INVALID_OPERATION, false); |
| 750 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 751 | |
| 752 | if (format != GL_NONE) |
| 753 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 754 | GLenum internalformat = gl::GetSizedInternalFormat(format, type, context->getClientVersion()); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 755 | if (internalformat != textureInternalFormat) |
| 756 | { |
| 757 | return gl::error(GL_INVALID_OPERATION, false); |
| 758 | } |
| 759 | } |
| 760 | |
| 761 | if (isCompressed) |
| 762 | { |
| 763 | if ((width % 4 != 0 && width != textureLevelWidth) || |
| 764 | (height % 4 != 0 && height != textureLevelHeight)) |
| 765 | { |
| 766 | return gl::error(GL_INVALID_OPERATION, false); |
| 767 | } |
| 768 | } |
| 769 | |
| 770 | if (width == 0 || height == 0 || depth == 0) |
| 771 | { |
| 772 | return false; |
| 773 | } |
| 774 | |
| 775 | if (xoffset < 0 || yoffset < 0 || zoffset < 0) |
| 776 | { |
| 777 | return gl::error(GL_INVALID_VALUE, false); |
| 778 | } |
| 779 | |
| 780 | if (std::numeric_limits<GLsizei>::max() - xoffset < width || |
| 781 | std::numeric_limits<GLsizei>::max() - yoffset < height || |
| 782 | std::numeric_limits<GLsizei>::max() - zoffset < depth) |
| 783 | { |
| 784 | return gl::error(GL_INVALID_VALUE, false); |
| 785 | } |
| 786 | |
| 787 | if (xoffset + width > textureLevelWidth || |
| 788 | yoffset + height > textureLevelHeight || |
| 789 | zoffset + depth > textureLevelDepth) |
| 790 | { |
| 791 | return gl::error(GL_INVALID_VALUE, false); |
| 792 | } |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 793 | } |
| 794 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 795 | return true; |
| 796 | } |
| 797 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 798 | |
| 799 | bool validateES2CopyTexImageParameters(gl::Context* context, GLenum target, GLint level, GLenum internalformat, bool isSubImage, |
| 800 | GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, |
| 801 | GLint border) |
| 802 | { |
| 803 | if (!gl::IsInternalTextureTarget(target)) |
| 804 | { |
| 805 | return gl::error(GL_INVALID_ENUM, false); |
| 806 | } |
| 807 | |
| 808 | if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0) |
| 809 | { |
| 810 | return gl::error(GL_INVALID_VALUE, false); |
| 811 | } |
| 812 | |
| 813 | if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height) |
| 814 | { |
| 815 | return gl::error(GL_INVALID_VALUE, false); |
| 816 | } |
| 817 | |
| 818 | if (width == 0 || height == 0) |
| 819 | { |
| 820 | return false; |
| 821 | } |
| 822 | |
| 823 | // Verify zero border |
| 824 | if (border != 0) |
| 825 | { |
| 826 | return gl::error(GL_INVALID_VALUE, false); |
| 827 | } |
| 828 | |
| 829 | // Validate dimensions based on Context limits and validate the texture |
| 830 | if (level > context->getMaximumTextureLevel()) |
| 831 | { |
| 832 | return gl::error(GL_INVALID_VALUE, false); |
| 833 | } |
| 834 | |
| 835 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 836 | |
| 837 | if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) |
| 838 | { |
| 839 | return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); |
| 840 | } |
| 841 | |
| 842 | if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0) |
| 843 | { |
| 844 | return gl::error(GL_INVALID_OPERATION, false); |
| 845 | } |
| 846 | |
| 847 | GLenum colorbufferFormat = framebuffer->getReadColorbuffer()->getInternalFormat(); |
| 848 | gl::Texture *texture = NULL; |
| 849 | GLenum textureFormat = GL_RGBA; |
| 850 | |
| 851 | switch (target) |
| 852 | { |
| 853 | case GL_TEXTURE_2D: |
| 854 | { |
| 855 | if (width > (context->getMaximum2DTextureDimension() >> level) || |
| 856 | height > (context->getMaximum2DTextureDimension() >> level)) |
| 857 | { |
| 858 | return gl::error(GL_INVALID_VALUE, false); |
| 859 | } |
| 860 | |
| 861 | gl::Texture2D *tex2d = context->getTexture2D(); |
| 862 | if (tex2d) |
| 863 | { |
| 864 | if (isSubImage && !validateSubImageParams2D(false, width, height, xoffset, yoffset, level, GL_NONE, GL_NONE, tex2d)) |
| 865 | { |
| 866 | return false; // error already registered by validateSubImageParams |
| 867 | } |
| 868 | texture = tex2d; |
| 869 | textureFormat = gl::GetFormat(tex2d->getInternalFormat(level), context->getClientVersion()); |
| 870 | } |
| 871 | } |
| 872 | break; |
| 873 | |
| 874 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 875 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 876 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 877 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 878 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 879 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 880 | { |
| 881 | if (!isSubImage && width != height) |
| 882 | { |
| 883 | return gl::error(GL_INVALID_VALUE, false); |
| 884 | } |
| 885 | |
| 886 | if (width > (context->getMaximumCubeTextureDimension() >> level) || |
| 887 | height > (context->getMaximumCubeTextureDimension() >> level)) |
| 888 | { |
| 889 | return gl::error(GL_INVALID_VALUE, false); |
| 890 | } |
| 891 | |
| 892 | gl::TextureCubeMap *texcube = context->getTextureCubeMap(); |
| 893 | if (texcube) |
| 894 | { |
| 895 | if (isSubImage && !validateSubImageParamsCube(false, width, height, xoffset, yoffset, target, level, GL_NONE, GL_NONE, texcube)) |
| 896 | { |
| 897 | return false; // error already registered by validateSubImageParams |
| 898 | } |
| 899 | texture = texcube; |
| 900 | textureFormat = gl::GetFormat(texcube->getInternalFormat(target, level), context->getClientVersion()); |
| 901 | } |
| 902 | } |
| 903 | break; |
| 904 | |
| 905 | default: |
| 906 | return gl::error(GL_INVALID_ENUM, false); |
| 907 | } |
| 908 | |
| 909 | if (!texture) |
| 910 | { |
| 911 | return gl::error(GL_INVALID_OPERATION, false); |
| 912 | } |
| 913 | |
| 914 | if (texture->isImmutable() && !isSubImage) |
| 915 | { |
| 916 | return gl::error(GL_INVALID_OPERATION, false); |
| 917 | } |
| 918 | |
| 919 | |
| 920 | // [OpenGL ES 2.0.24] table 3.9 |
| 921 | if (isSubImage) |
| 922 | { |
| 923 | switch (textureFormat) |
| 924 | { |
| 925 | case GL_ALPHA: |
| 926 | if (colorbufferFormat != GL_ALPHA8_EXT && |
| 927 | colorbufferFormat != GL_RGBA4 && |
| 928 | colorbufferFormat != GL_RGB5_A1 && |
| 929 | colorbufferFormat != GL_RGBA8_OES) |
| 930 | { |
| 931 | return gl::error(GL_INVALID_OPERATION, false); |
| 932 | } |
| 933 | break; |
| 934 | case GL_LUMINANCE: |
| 935 | case GL_RGB: |
| 936 | if (colorbufferFormat != GL_RGB565 && |
| 937 | colorbufferFormat != GL_RGB8_OES && |
| 938 | colorbufferFormat != GL_RGBA4 && |
| 939 | colorbufferFormat != GL_RGB5_A1 && |
| 940 | colorbufferFormat != GL_RGBA8_OES) |
| 941 | { |
| 942 | return gl::error(GL_INVALID_OPERATION, false); |
| 943 | } |
| 944 | break; |
| 945 | case GL_LUMINANCE_ALPHA: |
| 946 | case GL_RGBA: |
| 947 | if (colorbufferFormat != GL_RGBA4 && |
| 948 | colorbufferFormat != GL_RGB5_A1 && |
| 949 | colorbufferFormat != GL_RGBA8_OES) |
| 950 | { |
| 951 | return gl::error(GL_INVALID_OPERATION, false); |
| 952 | } |
| 953 | break; |
| 954 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 955 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 956 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 957 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 958 | return gl::error(GL_INVALID_OPERATION, false); |
| 959 | case GL_DEPTH_COMPONENT: |
| 960 | case GL_DEPTH_STENCIL_OES: |
| 961 | return gl::error(GL_INVALID_OPERATION, false); |
| 962 | default: |
| 963 | return gl::error(GL_INVALID_OPERATION, false); |
| 964 | } |
| 965 | } |
| 966 | else |
| 967 | { |
| 968 | switch (internalformat) |
| 969 | { |
| 970 | case GL_ALPHA: |
| 971 | if (colorbufferFormat != GL_ALPHA8_EXT && |
| 972 | colorbufferFormat != GL_RGBA4 && |
| 973 | colorbufferFormat != GL_RGB5_A1 && |
| 974 | colorbufferFormat != GL_BGRA8_EXT && |
| 975 | colorbufferFormat != GL_RGBA8_OES) |
| 976 | { |
| 977 | return gl::error(GL_INVALID_OPERATION, false); |
| 978 | } |
| 979 | break; |
| 980 | case GL_LUMINANCE: |
| 981 | case GL_RGB: |
| 982 | if (colorbufferFormat != GL_RGB565 && |
| 983 | colorbufferFormat != GL_RGB8_OES && |
| 984 | colorbufferFormat != GL_RGBA4 && |
| 985 | colorbufferFormat != GL_RGB5_A1 && |
| 986 | colorbufferFormat != GL_BGRA8_EXT && |
| 987 | colorbufferFormat != GL_RGBA8_OES) |
| 988 | { |
| 989 | return gl::error(GL_INVALID_OPERATION, false); |
| 990 | } |
| 991 | break; |
| 992 | case GL_LUMINANCE_ALPHA: |
| 993 | case GL_RGBA: |
| 994 | if (colorbufferFormat != GL_RGBA4 && |
| 995 | colorbufferFormat != GL_RGB5_A1 && |
| 996 | colorbufferFormat != GL_BGRA8_EXT && |
| 997 | colorbufferFormat != GL_RGBA8_OES) |
| 998 | { |
| 999 | return gl::error(GL_INVALID_OPERATION, false); |
| 1000 | } |
| 1001 | break; |
| 1002 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 1003 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 1004 | if (context->supportsDXT1Textures()) |
| 1005 | { |
| 1006 | return gl::error(GL_INVALID_OPERATION, false); |
| 1007 | } |
| 1008 | else |
| 1009 | { |
| 1010 | return gl::error(GL_INVALID_ENUM, false); |
| 1011 | } |
| 1012 | break; |
| 1013 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 1014 | if (context->supportsDXT3Textures()) |
| 1015 | { |
| 1016 | return gl::error(GL_INVALID_OPERATION, false); |
| 1017 | } |
| 1018 | else |
| 1019 | { |
| 1020 | return gl::error(GL_INVALID_ENUM, false); |
| 1021 | } |
| 1022 | break; |
| 1023 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 1024 | if (context->supportsDXT5Textures()) |
| 1025 | { |
| 1026 | return gl::error(GL_INVALID_OPERATION, false); |
| 1027 | } |
| 1028 | else |
| 1029 | { |
| 1030 | return gl::error(GL_INVALID_ENUM, false); |
| 1031 | } |
| 1032 | break; |
| 1033 | case GL_DEPTH_COMPONENT: |
| 1034 | case GL_DEPTH_COMPONENT16: |
| 1035 | case GL_DEPTH_COMPONENT32_OES: |
| 1036 | case GL_DEPTH_STENCIL_OES: |
| 1037 | case GL_DEPTH24_STENCIL8_OES: |
| 1038 | if (context->supportsDepthTextures()) |
| 1039 | { |
| 1040 | return gl::error(GL_INVALID_OPERATION, false); |
| 1041 | } |
| 1042 | else |
| 1043 | { |
| 1044 | return gl::error(GL_INVALID_ENUM, false); |
| 1045 | } |
| 1046 | default: |
| 1047 | return gl::error(GL_INVALID_ENUM, false); |
| 1048 | } |
| 1049 | } |
| 1050 | |
| 1051 | return true; |
| 1052 | } |
| 1053 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 1054 | bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLint level, GLenum internalformat, |
| 1055 | bool isSubImage, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, |
| 1056 | GLsizei width, GLsizei height, GLint border) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1057 | { |
| 1058 | 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] | 1059 | { |
| 1060 | return gl::error(GL_INVALID_VALUE, false); |
| 1061 | } |
| 1062 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1063 | if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height) |
| 1064 | { |
| 1065 | return gl::error(GL_INVALID_VALUE, false); |
| 1066 | } |
| 1067 | |
| 1068 | if (width == 0 || height == 0) |
| 1069 | { |
| 1070 | return false; |
| 1071 | } |
| 1072 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 1073 | if (border != 0) |
| 1074 | { |
| 1075 | return gl::error(GL_INVALID_VALUE, false); |
| 1076 | } |
| 1077 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1078 | if (level > context->getMaximumTextureLevel()) |
| 1079 | { |
| 1080 | return gl::error(GL_INVALID_VALUE, false); |
| 1081 | } |
| 1082 | |
| 1083 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 1084 | |
| 1085 | if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) |
| 1086 | { |
| 1087 | return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); |
| 1088 | } |
| 1089 | |
| 1090 | if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0) |
| 1091 | { |
| 1092 | return gl::error(GL_INVALID_OPERATION, false); |
| 1093 | } |
| 1094 | |
| 1095 | gl::Renderbuffer *source = framebuffer->getReadColorbuffer(); |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1096 | GLenum colorbufferInternalFormat = source->getInternalFormat(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1097 | gl::Texture *texture = NULL; |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1098 | GLenum textureInternalFormat = GL_NONE; |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1099 | bool textureCompressed = false; |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame] | 1100 | bool textureIsDepth = false; |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1101 | GLint textureLevelWidth = 0; |
| 1102 | GLint textureLevelHeight = 0; |
| 1103 | GLint textureLevelDepth = 0; |
| 1104 | switch (target) |
| 1105 | { |
| 1106 | case GL_TEXTURE_2D: |
| 1107 | { |
| 1108 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 1109 | if (texture2d) |
| 1110 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1111 | textureInternalFormat = texture2d->getInternalFormat(level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1112 | textureCompressed = texture2d->isCompressed(level); |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame] | 1113 | textureIsDepth = texture2d->isDepth(level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1114 | textureLevelWidth = texture2d->getWidth(level); |
| 1115 | textureLevelHeight = texture2d->getHeight(level); |
| 1116 | textureLevelDepth = 1; |
| 1117 | texture = texture2d; |
| 1118 | } |
| 1119 | } |
| 1120 | break; |
| 1121 | |
| 1122 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 1123 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 1124 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 1125 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 1126 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 1127 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 1128 | { |
| 1129 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 1130 | if (textureCube) |
| 1131 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1132 | textureInternalFormat = textureCube->getInternalFormat(target, level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1133 | textureCompressed = textureCube->isCompressed(target, level); |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame] | 1134 | textureIsDepth = false; |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1135 | textureLevelWidth = textureCube->getWidth(target, level); |
| 1136 | textureLevelHeight = textureCube->getHeight(target, level); |
| 1137 | textureLevelDepth = 1; |
| 1138 | texture = textureCube; |
| 1139 | } |
| 1140 | } |
| 1141 | break; |
| 1142 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1143 | case GL_TEXTURE_2D_ARRAY: |
| 1144 | { |
| 1145 | gl::Texture2DArray *texture2dArray = context->getTexture2DArray(); |
| 1146 | if (texture2dArray) |
| 1147 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1148 | textureInternalFormat = texture2dArray->getInternalFormat(level); |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1149 | textureCompressed = texture2dArray->isCompressed(level); |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame] | 1150 | textureIsDepth = texture2dArray->isDepth(level); |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1151 | textureLevelWidth = texture2dArray->getWidth(level); |
| 1152 | textureLevelHeight = texture2dArray->getHeight(level); |
| 1153 | textureLevelDepth = texture2dArray->getDepth(level); |
| 1154 | texture = texture2dArray; |
| 1155 | } |
| 1156 | } |
| 1157 | break; |
| 1158 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1159 | case GL_TEXTURE_3D: |
| 1160 | { |
| 1161 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 1162 | if (texture3d) |
| 1163 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1164 | textureInternalFormat = texture3d->getInternalFormat(level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1165 | textureCompressed = texture3d->isCompressed(level); |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame] | 1166 | textureIsDepth = texture3d->isDepth(level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1167 | textureLevelWidth = texture3d->getWidth(level); |
| 1168 | textureLevelHeight = texture3d->getHeight(level); |
| 1169 | textureLevelDepth = texture3d->getDepth(level); |
| 1170 | texture = texture3d; |
| 1171 | } |
| 1172 | } |
| 1173 | break; |
| 1174 | |
| 1175 | default: |
| 1176 | return gl::error(GL_INVALID_ENUM, false); |
| 1177 | } |
| 1178 | |
| 1179 | if (!texture) |
| 1180 | { |
| 1181 | return gl::error(GL_INVALID_OPERATION, false); |
| 1182 | } |
| 1183 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 1184 | if (texture->isImmutable() && !isSubImage) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1185 | { |
| 1186 | return gl::error(GL_INVALID_OPERATION, false); |
| 1187 | } |
| 1188 | |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame] | 1189 | if (textureIsDepth) |
| 1190 | { |
| 1191 | return gl::error(GL_INVALID_OPERATION, false); |
| 1192 | } |
| 1193 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 1194 | if (textureCompressed) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1195 | { |
| 1196 | if ((width % 4 != 0 && width != textureLevelWidth) || |
| 1197 | (height % 4 != 0 && height != textureLevelHeight)) |
| 1198 | { |
| 1199 | return gl::error(GL_INVALID_OPERATION, false); |
| 1200 | } |
| 1201 | } |
| 1202 | |
Geoff Lang | a4d1332 | 2013-06-05 14:57:51 -0400 | [diff] [blame] | 1203 | if (isSubImage) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1204 | { |
Geoff Lang | a4d1332 | 2013-06-05 14:57:51 -0400 | [diff] [blame] | 1205 | if (xoffset + width > textureLevelWidth || |
| 1206 | yoffset + height > textureLevelHeight || |
| 1207 | zoffset >= textureLevelDepth) |
| 1208 | { |
| 1209 | return gl::error(GL_INVALID_VALUE, false); |
| 1210 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1211 | |
Geoff Lang | a4d1332 | 2013-06-05 14:57:51 -0400 | [diff] [blame] | 1212 | if (!gl::IsValidCopyTexImageCombination(textureInternalFormat, colorbufferInternalFormat, |
| 1213 | context->getClientVersion())) |
| 1214 | { |
| 1215 | return gl::error(GL_INVALID_OPERATION, false); |
| 1216 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1217 | } |
| 1218 | |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 1219 | return true; |
| 1220 | } |
| 1221 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 1222 | bool validateES2TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat, |
| 1223 | GLsizei width, GLsizei height) |
| 1224 | { |
| 1225 | if (target != GL_TEXTURE_2D && target != GL_TEXTURE_CUBE_MAP) |
| 1226 | { |
| 1227 | return gl::error(GL_INVALID_ENUM, false); |
| 1228 | } |
| 1229 | |
| 1230 | if (width < 1 || height < 1 || levels < 1) |
| 1231 | { |
| 1232 | return gl::error(GL_INVALID_VALUE, false); |
| 1233 | } |
| 1234 | |
| 1235 | if (target == GL_TEXTURE_CUBE_MAP && width != height) |
| 1236 | { |
| 1237 | return gl::error(GL_INVALID_VALUE, false); |
| 1238 | } |
| 1239 | |
| 1240 | if (levels != 1 && levels != gl::log2(std::max(width, height)) + 1) |
| 1241 | { |
| 1242 | return gl::error(GL_INVALID_OPERATION, false); |
| 1243 | } |
| 1244 | |
| 1245 | GLenum format = gl::GetFormat(internalformat, context->getClientVersion()); |
| 1246 | GLenum type = gl::GetType(internalformat, context->getClientVersion()); |
| 1247 | |
| 1248 | if (format == GL_NONE || type == GL_NONE) |
| 1249 | { |
| 1250 | return gl::error(GL_INVALID_ENUM, false); |
| 1251 | } |
| 1252 | |
| 1253 | switch (target) |
| 1254 | { |
| 1255 | case GL_TEXTURE_2D: |
| 1256 | if (width > context->getMaximum2DTextureDimension() || |
| 1257 | height > context->getMaximum2DTextureDimension()) |
| 1258 | { |
| 1259 | return gl::error(GL_INVALID_VALUE, false); |
| 1260 | } |
| 1261 | break; |
| 1262 | case GL_TEXTURE_CUBE_MAP: |
| 1263 | if (width > context->getMaximumCubeTextureDimension() || |
| 1264 | height > context->getMaximumCubeTextureDimension()) |
| 1265 | { |
| 1266 | return gl::error(GL_INVALID_VALUE, false); |
| 1267 | } |
| 1268 | break; |
| 1269 | default: |
| 1270 | return gl::error(GL_INVALID_ENUM, false); |
| 1271 | } |
| 1272 | |
| 1273 | if (levels != 1 && !context->supportsNonPower2Texture()) |
| 1274 | { |
| 1275 | if (!gl::isPow2(width) || !gl::isPow2(height)) |
| 1276 | { |
| 1277 | return gl::error(GL_INVALID_OPERATION, false); |
| 1278 | } |
| 1279 | } |
| 1280 | |
| 1281 | switch (internalformat) |
| 1282 | { |
| 1283 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 1284 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 1285 | if (!context->supportsDXT1Textures()) |
| 1286 | { |
| 1287 | return gl::error(GL_INVALID_ENUM, false); |
| 1288 | } |
| 1289 | break; |
| 1290 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 1291 | if (!context->supportsDXT3Textures()) |
| 1292 | { |
| 1293 | return gl::error(GL_INVALID_ENUM, false); |
| 1294 | } |
| 1295 | break; |
| 1296 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 1297 | if (!context->supportsDXT5Textures()) |
| 1298 | { |
| 1299 | return gl::error(GL_INVALID_ENUM, false); |
| 1300 | } |
| 1301 | break; |
| 1302 | case GL_RGBA32F_EXT: |
| 1303 | case GL_RGB32F_EXT: |
| 1304 | case GL_ALPHA32F_EXT: |
| 1305 | case GL_LUMINANCE32F_EXT: |
| 1306 | case GL_LUMINANCE_ALPHA32F_EXT: |
| 1307 | if (!context->supportsFloat32Textures()) |
| 1308 | { |
| 1309 | return gl::error(GL_INVALID_ENUM, false); |
| 1310 | } |
| 1311 | break; |
| 1312 | case GL_RGBA16F_EXT: |
| 1313 | case GL_RGB16F_EXT: |
| 1314 | case GL_ALPHA16F_EXT: |
| 1315 | case GL_LUMINANCE16F_EXT: |
| 1316 | case GL_LUMINANCE_ALPHA16F_EXT: |
| 1317 | if (!context->supportsFloat16Textures()) |
| 1318 | { |
| 1319 | return gl::error(GL_INVALID_ENUM, false); |
| 1320 | } |
| 1321 | break; |
| 1322 | case GL_DEPTH_COMPONENT16: |
| 1323 | case GL_DEPTH_COMPONENT32_OES: |
| 1324 | case GL_DEPTH24_STENCIL8_OES: |
| 1325 | if (!context->supportsDepthTextures()) |
| 1326 | { |
| 1327 | return gl::error(GL_INVALID_ENUM, false); |
| 1328 | } |
| 1329 | if (target != GL_TEXTURE_2D) |
| 1330 | { |
| 1331 | return gl::error(GL_INVALID_OPERATION, false); |
| 1332 | } |
| 1333 | // ANGLE_depth_texture only supports 1-level textures |
| 1334 | if (levels != 1) |
| 1335 | { |
| 1336 | return gl::error(GL_INVALID_OPERATION, false); |
| 1337 | } |
| 1338 | break; |
| 1339 | default: |
| 1340 | break; |
| 1341 | } |
| 1342 | |
| 1343 | gl::Texture *texture = NULL; |
| 1344 | switch(target) |
| 1345 | { |
| 1346 | case GL_TEXTURE_2D: |
| 1347 | texture = context->getTexture2D(); |
| 1348 | break; |
| 1349 | case GL_TEXTURE_CUBE_MAP: |
| 1350 | texture = context->getTextureCubeMap(); |
| 1351 | break; |
| 1352 | default: |
| 1353 | UNREACHABLE(); |
| 1354 | } |
| 1355 | |
| 1356 | if (!texture || texture->id() == 0) |
| 1357 | { |
| 1358 | return gl::error(GL_INVALID_OPERATION, false); |
| 1359 | } |
| 1360 | |
| 1361 | if (texture->isImmutable()) |
| 1362 | { |
| 1363 | return gl::error(GL_INVALID_OPERATION, false); |
| 1364 | } |
| 1365 | |
| 1366 | return true; |
| 1367 | } |
| 1368 | |
| 1369 | bool validateES3TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat, |
| 1370 | GLsizei width, GLsizei height, GLsizei depth) |
| 1371 | { |
| 1372 | if (width < 1 || height < 1 || depth < 1 || levels < 1) |
| 1373 | { |
| 1374 | return gl::error(GL_INVALID_VALUE, false); |
| 1375 | } |
| 1376 | |
| 1377 | if (levels > gl::log2(std::max(std::max(width, height), depth)) + 1) |
| 1378 | { |
| 1379 | return gl::error(GL_INVALID_OPERATION, false); |
| 1380 | } |
| 1381 | |
| 1382 | gl::Texture *texture = NULL; |
| 1383 | switch (target) |
| 1384 | { |
| 1385 | case GL_TEXTURE_2D: |
| 1386 | { |
| 1387 | texture = context->getTexture2D(); |
| 1388 | |
| 1389 | if (width > (context->getMaximum2DTextureDimension()) || |
| 1390 | height > (context->getMaximum2DTextureDimension())) |
| 1391 | { |
| 1392 | return gl::error(GL_INVALID_VALUE, false); |
| 1393 | } |
| 1394 | } |
| 1395 | break; |
| 1396 | |
| 1397 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 1398 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 1399 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 1400 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 1401 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 1402 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 1403 | { |
| 1404 | texture = context->getTextureCubeMap(); |
| 1405 | |
| 1406 | if (width != height) |
| 1407 | { |
| 1408 | return gl::error(GL_INVALID_VALUE, false); |
| 1409 | } |
| 1410 | |
| 1411 | if (width > (context->getMaximumCubeTextureDimension())) |
| 1412 | { |
| 1413 | return gl::error(GL_INVALID_VALUE, false); |
| 1414 | } |
| 1415 | } |
| 1416 | break; |
| 1417 | |
| 1418 | case GL_TEXTURE_3D: |
| 1419 | { |
| 1420 | texture = context->getTexture3D(); |
| 1421 | |
| 1422 | if (width > (context->getMaximum3DTextureDimension()) || |
| 1423 | height > (context->getMaximum3DTextureDimension()) || |
| 1424 | depth > (context->getMaximum3DTextureDimension())) |
| 1425 | { |
| 1426 | return gl::error(GL_INVALID_VALUE, false); |
| 1427 | } |
| 1428 | } |
| 1429 | break; |
| 1430 | |
| 1431 | case GL_TEXTURE_2D_ARRAY: |
| 1432 | { |
| 1433 | texture = context->getTexture2DArray(); |
| 1434 | |
| 1435 | if (width > (context->getMaximum2DTextureDimension()) || |
| 1436 | height > (context->getMaximum2DTextureDimension()) || |
| 1437 | depth > (context->getMaximum2DArrayTextureLayers())) |
| 1438 | { |
| 1439 | return gl::error(GL_INVALID_VALUE, false); |
| 1440 | } |
| 1441 | } |
| 1442 | break; |
| 1443 | |
| 1444 | default: |
| 1445 | return gl::error(GL_INVALID_ENUM, false); |
| 1446 | } |
| 1447 | |
| 1448 | if (!texture || texture->id() == 0) |
| 1449 | { |
| 1450 | return gl::error(GL_INVALID_OPERATION, false); |
| 1451 | } |
| 1452 | |
| 1453 | if (texture->isImmutable()) |
| 1454 | { |
| 1455 | return gl::error(GL_INVALID_OPERATION, false); |
| 1456 | } |
| 1457 | |
| 1458 | if (!gl::IsValidInternalFormat(internalformat, context)) |
| 1459 | { |
| 1460 | return gl::error(GL_INVALID_ENUM, false); |
| 1461 | } |
| 1462 | |
| 1463 | if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion())) |
| 1464 | { |
| 1465 | return gl::error(GL_INVALID_ENUM, false); |
| 1466 | } |
| 1467 | |
| 1468 | return true; |
| 1469 | } |
| 1470 | |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 1471 | bool validateRenderbufferStorageParameters(const gl::Context *context, GLenum target, GLsizei samples, |
| 1472 | GLenum internalformat, GLsizei width, GLsizei height, |
| 1473 | bool angleExtension) |
| 1474 | { |
| 1475 | switch (target) |
| 1476 | { |
| 1477 | case GL_RENDERBUFFER: |
| 1478 | break; |
| 1479 | default: |
| 1480 | return gl::error(GL_INVALID_ENUM, false); |
| 1481 | } |
| 1482 | |
| 1483 | if (width < 0 || height < 0 || samples < 0) |
| 1484 | { |
| 1485 | return gl::error(GL_INVALID_VALUE, false); |
| 1486 | } |
| 1487 | |
| 1488 | if (!gl::IsValidInternalFormat(internalformat, context)) |
| 1489 | { |
| 1490 | return gl::error(GL_INVALID_ENUM, false); |
| 1491 | } |
| 1492 | |
| 1493 | // ANGLE_framebuffer_multisample does not explicitly state that the internal format must be |
| 1494 | // sized but it does state that the format must be in the ES2.0 spec table 4.5 which contains |
| 1495 | // only sized internal formats. The ES3 spec (section 4.4.2) does, however, state that the |
| 1496 | // internal format must be sized and not an integer format if samples is greater than zero. |
| 1497 | if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion())) |
| 1498 | { |
| 1499 | return gl::error(GL_INVALID_ENUM, false); |
| 1500 | } |
| 1501 | |
| 1502 | if (gl::IsIntegerFormat(internalformat, context->getClientVersion()) && samples > 0) |
| 1503 | { |
| 1504 | return gl::error(GL_INVALID_OPERATION, false); |
| 1505 | } |
| 1506 | |
| 1507 | if (!gl::IsColorRenderingSupported(internalformat, context) && |
| 1508 | !gl::IsDepthRenderingSupported(internalformat, context) && |
| 1509 | !gl::IsStencilRenderingSupported(internalformat, context)) |
| 1510 | { |
| 1511 | return gl::error(GL_INVALID_ENUM, false); |
| 1512 | } |
| 1513 | |
| 1514 | if (std::max(width, height) > context->getMaximumRenderbufferDimension()) |
| 1515 | { |
| 1516 | return gl::error(GL_INVALID_VALUE, false); |
| 1517 | } |
| 1518 | |
| 1519 | // ANGLE_framebuffer_multisample states that the value of samples must be less than or equal |
| 1520 | // to MAX_SAMPLES_ANGLE (Context::getMaxSupportedSamples) while the ES3.0 spec (section 4.4.2) |
| 1521 | // states that samples must be less than or equal to the maximum samples for the specified |
| 1522 | // internal format. |
| 1523 | if (angleExtension) |
| 1524 | { |
| 1525 | if (samples > context->getMaxSupportedSamples()) |
| 1526 | { |
| 1527 | return gl::error(GL_INVALID_VALUE, false); |
| 1528 | } |
| 1529 | } |
| 1530 | else |
| 1531 | { |
| 1532 | if (samples > context->getMaxSupportedFormatSamples(internalformat)) |
| 1533 | { |
| 1534 | return gl::error(GL_INVALID_VALUE, false); |
| 1535 | } |
| 1536 | } |
| 1537 | |
| 1538 | GLuint handle = context->getRenderbufferHandle(); |
| 1539 | if (handle == 0) |
| 1540 | { |
| 1541 | return gl::error(GL_INVALID_OPERATION, false); |
| 1542 | } |
| 1543 | |
| 1544 | return true; |
| 1545 | } |
| 1546 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1547 | // 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] | 1548 | bool validES2ReadFormatType(GLenum format, GLenum type) |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1549 | { |
| 1550 | switch (format) |
| 1551 | { |
| 1552 | case GL_RGBA: |
| 1553 | switch (type) |
| 1554 | { |
| 1555 | case GL_UNSIGNED_BYTE: |
| 1556 | break; |
| 1557 | default: |
| 1558 | return false; |
| 1559 | } |
| 1560 | break; |
| 1561 | case GL_BGRA_EXT: |
| 1562 | switch (type) |
| 1563 | { |
| 1564 | case GL_UNSIGNED_BYTE: |
| 1565 | case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: |
| 1566 | case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: |
| 1567 | break; |
| 1568 | default: |
| 1569 | return false; |
| 1570 | } |
| 1571 | break; |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1572 | default: |
| 1573 | return false; |
| 1574 | } |
| 1575 | return true; |
| 1576 | } |
| 1577 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 1578 | bool validES3ReadFormatType(GLenum internalFormat, GLenum format, GLenum type) |
| 1579 | { |
| 1580 | switch (format) |
| 1581 | { |
| 1582 | case GL_RGBA: |
| 1583 | switch (type) |
| 1584 | { |
| 1585 | case GL_UNSIGNED_BYTE: |
| 1586 | break; |
| 1587 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 1588 | if (internalFormat != GL_RGB10_A2) |
| 1589 | { |
| 1590 | return false; |
| 1591 | } |
| 1592 | break; |
| 1593 | default: |
| 1594 | return false; |
| 1595 | } |
| 1596 | break; |
| 1597 | case GL_RGBA_INTEGER: |
| 1598 | switch (type) |
| 1599 | { |
| 1600 | case GL_INT: |
Geoff Lang | d384a94 | 2013-06-05 15:00:10 -0400 | [diff] [blame] | 1601 | if (!gl::IsSignedIntegerFormat(internalFormat, 3)) |
| 1602 | { |
| 1603 | return false; |
| 1604 | } |
| 1605 | break; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 1606 | case GL_UNSIGNED_INT: |
Geoff Lang | d384a94 | 2013-06-05 15:00:10 -0400 | [diff] [blame] | 1607 | if (!gl::IsUnsignedIntegerFormat(internalFormat, 3)) |
| 1608 | { |
| 1609 | return false; |
| 1610 | } |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 1611 | break; |
| 1612 | default: |
| 1613 | return false; |
| 1614 | } |
| 1615 | break; |
| 1616 | case GL_BGRA_EXT: |
| 1617 | switch (type) |
| 1618 | { |
| 1619 | case GL_UNSIGNED_BYTE: |
| 1620 | case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: |
| 1621 | case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: |
| 1622 | break; |
| 1623 | default: |
| 1624 | return false; |
| 1625 | } |
| 1626 | break; |
| 1627 | default: |
| 1628 | return false; |
| 1629 | } |
| 1630 | return true; |
| 1631 | } |
| 1632 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 1633 | bool validateInvalidateFramebufferParameters(gl::Context *context, GLenum target, GLsizei numAttachments, |
| 1634 | const GLenum* attachments) |
| 1635 | { |
| 1636 | bool defaultFramebuffer = false; |
| 1637 | |
| 1638 | switch (target) |
| 1639 | { |
| 1640 | case GL_DRAW_FRAMEBUFFER: |
| 1641 | case GL_FRAMEBUFFER: |
| 1642 | defaultFramebuffer = context->getDrawFramebufferHandle() == 0; |
| 1643 | break; |
| 1644 | case GL_READ_FRAMEBUFFER: |
| 1645 | defaultFramebuffer = context->getReadFramebufferHandle() == 0; |
| 1646 | break; |
| 1647 | default: |
| 1648 | return gl::error(GL_INVALID_ENUM, false); |
| 1649 | } |
| 1650 | |
| 1651 | for (int i = 0; i < numAttachments; ++i) |
| 1652 | { |
| 1653 | if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15) |
| 1654 | { |
| 1655 | if (defaultFramebuffer) |
| 1656 | { |
| 1657 | return gl::error(GL_INVALID_ENUM, false); |
| 1658 | } |
| 1659 | |
| 1660 | if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getMaximumRenderTargets()) |
| 1661 | { |
| 1662 | return gl::error(GL_INVALID_OPERATION, false); |
| 1663 | } |
| 1664 | } |
| 1665 | else |
| 1666 | { |
| 1667 | switch (attachments[i]) |
| 1668 | { |
| 1669 | case GL_DEPTH_ATTACHMENT: |
| 1670 | case GL_STENCIL_ATTACHMENT: |
| 1671 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 1672 | if (defaultFramebuffer) |
| 1673 | { |
| 1674 | return gl::error(GL_INVALID_ENUM, false); |
| 1675 | } |
| 1676 | break; |
| 1677 | case GL_COLOR: |
| 1678 | case GL_DEPTH: |
| 1679 | case GL_STENCIL: |
| 1680 | if (!defaultFramebuffer) |
| 1681 | { |
| 1682 | return gl::error(GL_INVALID_ENUM, false); |
| 1683 | } |
| 1684 | break; |
| 1685 | default: |
| 1686 | return gl::error(GL_INVALID_ENUM, false); |
| 1687 | } |
| 1688 | } |
| 1689 | } |
| 1690 | |
| 1691 | return true; |
| 1692 | } |
| 1693 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 1694 | bool validateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, |
| 1695 | GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, |
| 1696 | GLenum filter, bool fromAngleExtension) |
| 1697 | { |
| 1698 | switch (filter) |
| 1699 | { |
| 1700 | case GL_NEAREST: |
| 1701 | break; |
| 1702 | case GL_LINEAR: |
| 1703 | if (fromAngleExtension) |
| 1704 | { |
| 1705 | return gl::error(GL_INVALID_ENUM, false); |
| 1706 | } |
| 1707 | break; |
| 1708 | default: |
| 1709 | return gl::error(GL_INVALID_ENUM, false); |
| 1710 | } |
| 1711 | |
| 1712 | if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0) |
| 1713 | { |
| 1714 | return gl::error(GL_INVALID_VALUE, false); |
| 1715 | } |
| 1716 | |
| 1717 | if (mask == 0) |
| 1718 | { |
| 1719 | // ES3.0 spec, section 4.3.2 specifies that a mask of zero is valid and no |
| 1720 | // buffers are copied. |
| 1721 | return false; |
| 1722 | } |
| 1723 | |
| 1724 | if (fromAngleExtension && (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0)) |
| 1725 | { |
| 1726 | ERR("Scaling and flipping in BlitFramebufferANGLE not supported by this implementation."); |
| 1727 | return gl::error(GL_INVALID_OPERATION, false); |
| 1728 | } |
| 1729 | |
| 1730 | // ES3.0 spec, section 4.3.2 states that linear filtering is only available for the |
| 1731 | // color buffer, leaving only nearest being unfiltered from above |
| 1732 | if ((mask & ~GL_COLOR_BUFFER_BIT) != 0 && filter != GL_NEAREST) |
| 1733 | { |
| 1734 | return gl::error(GL_INVALID_OPERATION, false); |
| 1735 | } |
| 1736 | |
| 1737 | if (context->getReadFramebufferHandle() == context->getDrawFramebufferHandle()) |
| 1738 | { |
| 1739 | if (fromAngleExtension) |
| 1740 | { |
| 1741 | ERR("Blits with the same source and destination framebuffer are not supported by this " |
| 1742 | "implementation."); |
| 1743 | } |
| 1744 | return gl::error(GL_INVALID_OPERATION, false); |
| 1745 | } |
| 1746 | |
| 1747 | gl::Framebuffer *readFramebuffer = context->getReadFramebuffer(); |
| 1748 | gl::Framebuffer *drawFramebuffer = context->getDrawFramebuffer(); |
| 1749 | if (!readFramebuffer || readFramebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE || |
| 1750 | !drawFramebuffer || drawFramebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) |
| 1751 | { |
| 1752 | return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); |
| 1753 | } |
| 1754 | |
| 1755 | if (drawFramebuffer->getSamples() != 0) |
| 1756 | { |
| 1757 | return gl::error(GL_INVALID_OPERATION, false); |
| 1758 | } |
| 1759 | |
| 1760 | gl::Rectangle sourceClippedRect, destClippedRect; |
| 1761 | bool partialCopy; |
| 1762 | if (!context->clipBlitFramebufferCoordinates(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 1763 | &sourceClippedRect, &destClippedRect, &partialCopy)) |
| 1764 | { |
| 1765 | return gl::error(GL_INVALID_OPERATION, false); |
| 1766 | } |
| 1767 | |
| 1768 | bool sameBounds = srcX0 == dstX0 && srcY0 == dstY0 && srcX1 == dstX1 && srcY1 == dstY1; |
| 1769 | |
| 1770 | GLuint clientVersion = context->getClientVersion(); |
| 1771 | |
| 1772 | if (mask & GL_COLOR_BUFFER_BIT) |
| 1773 | { |
| 1774 | gl::Renderbuffer *readColorBuffer = readFramebuffer->getReadColorbuffer(); |
| 1775 | gl::Renderbuffer *drawColorBuffer = drawFramebuffer->getFirstColorbuffer(); |
| 1776 | |
| 1777 | if (readColorBuffer && drawColorBuffer) |
| 1778 | { |
| 1779 | GLint readInternalFormat = readColorBuffer->getActualFormat(); |
| 1780 | GLint drawInternalFormat = drawColorBuffer->getActualFormat(); |
| 1781 | |
| 1782 | for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; i++) |
| 1783 | { |
| 1784 | if (drawFramebuffer->isEnabledColorAttachment(i)) |
| 1785 | { |
| 1786 | GLint drawbufferAttachmentFormat = drawFramebuffer->getColorbuffer(i)->getActualFormat(); |
| 1787 | |
| 1788 | if (gl::IsNormalizedFixedPointFormat(readInternalFormat, clientVersion) && |
| 1789 | !gl::IsNormalizedFixedPointFormat(drawbufferAttachmentFormat, clientVersion)) |
| 1790 | { |
| 1791 | return gl::error(GL_INVALID_OPERATION, false); |
| 1792 | } |
| 1793 | |
| 1794 | if (gl::IsUnsignedIntegerFormat(readInternalFormat, clientVersion) && |
| 1795 | !gl::IsUnsignedIntegerFormat(drawbufferAttachmentFormat, clientVersion)) |
| 1796 | { |
| 1797 | return gl::error(GL_INVALID_OPERATION, false); |
| 1798 | } |
| 1799 | |
| 1800 | if (gl::IsSignedIntegerFormat(readInternalFormat, clientVersion) && |
| 1801 | !gl::IsSignedIntegerFormat(drawbufferAttachmentFormat, clientVersion)) |
| 1802 | { |
| 1803 | return gl::error(GL_INVALID_OPERATION, false); |
| 1804 | } |
| 1805 | |
| 1806 | if (readColorBuffer->getSamples() > 0 && (readInternalFormat != drawbufferAttachmentFormat || !sameBounds)) |
| 1807 | { |
| 1808 | return gl::error(GL_INVALID_OPERATION, false); |
| 1809 | } |
| 1810 | } |
| 1811 | } |
| 1812 | |
| 1813 | if (gl::IsIntegerFormat(readInternalFormat, clientVersion) && filter == GL_LINEAR) |
| 1814 | { |
| 1815 | return gl::error(GL_INVALID_OPERATION, false); |
| 1816 | } |
| 1817 | |
| 1818 | if (fromAngleExtension) |
| 1819 | { |
| 1820 | const GLenum readColorbufferType = readFramebuffer->getReadColorbufferType(); |
| 1821 | if (readColorbufferType != GL_TEXTURE_2D && readColorbufferType != GL_RENDERBUFFER) |
| 1822 | { |
| 1823 | return gl::error(GL_INVALID_OPERATION, false); |
| 1824 | } |
| 1825 | |
| 1826 | for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) |
| 1827 | { |
| 1828 | if (drawFramebuffer->isEnabledColorAttachment(colorAttachment)) |
| 1829 | { |
| 1830 | if (drawFramebuffer->getColorbufferType(colorAttachment) != GL_TEXTURE_2D && |
| 1831 | drawFramebuffer->getColorbufferType(colorAttachment) != GL_RENDERBUFFER) |
| 1832 | { |
| 1833 | return gl::error(GL_INVALID_OPERATION, false); |
| 1834 | } |
| 1835 | |
| 1836 | if (drawFramebuffer->getColorbuffer(colorAttachment)->getActualFormat() != readColorBuffer->getActualFormat()) |
| 1837 | { |
| 1838 | return gl::error(GL_INVALID_OPERATION, false); |
| 1839 | } |
| 1840 | } |
| 1841 | } |
| 1842 | |
| 1843 | if (partialCopy && readFramebuffer->getSamples() != 0) |
| 1844 | { |
| 1845 | return gl::error(GL_INVALID_OPERATION, false); |
| 1846 | } |
| 1847 | } |
| 1848 | } |
| 1849 | } |
| 1850 | |
| 1851 | if (mask & GL_DEPTH_BUFFER_BIT) |
| 1852 | { |
| 1853 | gl::Renderbuffer *readDepthBuffer = readFramebuffer->getDepthbuffer(); |
| 1854 | gl::Renderbuffer *drawDepthBuffer = drawFramebuffer->getDepthbuffer(); |
| 1855 | |
| 1856 | if (readDepthBuffer && drawDepthBuffer) |
| 1857 | { |
| 1858 | if (readDepthBuffer->getActualFormat() != drawDepthBuffer->getActualFormat()) |
| 1859 | { |
| 1860 | return gl::error(GL_INVALID_OPERATION, false); |
| 1861 | } |
| 1862 | |
| 1863 | if (readDepthBuffer->getSamples() > 0 && !sameBounds) |
| 1864 | { |
| 1865 | return gl::error(GL_INVALID_OPERATION, false); |
| 1866 | } |
| 1867 | |
| 1868 | if (fromAngleExtension) |
| 1869 | { |
| 1870 | if (partialCopy) |
| 1871 | { |
| 1872 | ERR("Only whole-buffer depth and stencil blits are supported by this implementation."); |
| 1873 | return gl::error(GL_INVALID_OPERATION, false); // only whole-buffer copies are permitted |
| 1874 | } |
| 1875 | |
| 1876 | if (readDepthBuffer->getSamples() != 0 || drawDepthBuffer->getSamples() != 0) |
| 1877 | { |
| 1878 | return gl::error(GL_INVALID_OPERATION, false); |
| 1879 | } |
| 1880 | } |
| 1881 | } |
| 1882 | } |
| 1883 | |
| 1884 | if (mask & GL_STENCIL_BUFFER_BIT) |
| 1885 | { |
| 1886 | gl::Renderbuffer *readStencilBuffer = readFramebuffer->getStencilbuffer(); |
| 1887 | gl::Renderbuffer *drawStencilBuffer = drawFramebuffer->getStencilbuffer(); |
| 1888 | |
| 1889 | if (fromAngleExtension && partialCopy) |
| 1890 | { |
| 1891 | ERR("Only whole-buffer depth and stencil blits are supported by this implementation."); |
| 1892 | return gl::error(GL_INVALID_OPERATION, false); // only whole-buffer copies are permitted |
| 1893 | } |
| 1894 | |
| 1895 | if (readStencilBuffer && drawStencilBuffer) |
| 1896 | { |
| 1897 | if (readStencilBuffer->getActualFormat() != drawStencilBuffer->getActualFormat()) |
| 1898 | { |
| 1899 | return gl::error(GL_INVALID_OPERATION, false); |
| 1900 | } |
| 1901 | |
| 1902 | if (readStencilBuffer->getSamples() > 0 && !sameBounds) |
| 1903 | { |
| 1904 | return gl::error(GL_INVALID_OPERATION, false); |
| 1905 | } |
| 1906 | |
| 1907 | if (fromAngleExtension) |
| 1908 | { |
| 1909 | if (partialCopy) |
| 1910 | { |
| 1911 | ERR("Only whole-buffer depth and stencil blits are supported by this implementation."); |
| 1912 | return gl::error(GL_INVALID_OPERATION, false); // only whole-buffer copies are permitted |
| 1913 | } |
| 1914 | |
| 1915 | if (readStencilBuffer->getSamples() != 0 || drawStencilBuffer->getSamples() != 0) |
| 1916 | { |
| 1917 | return gl::error(GL_INVALID_OPERATION, false); |
| 1918 | } |
| 1919 | } |
| 1920 | } |
| 1921 | } |
| 1922 | |
| 1923 | return true; |
| 1924 | } |
| 1925 | |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 1926 | bool validateGetVertexAttribParameters(GLenum pname, int clientVersion) |
| 1927 | { |
| 1928 | switch (pname) |
| 1929 | { |
| 1930 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
| 1931 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
| 1932 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
| 1933 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
| 1934 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
| 1935 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
| 1936 | case GL_CURRENT_VERTEX_ATTRIB: |
| 1937 | return true; |
| 1938 | |
| 1939 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 1940 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 1941 | // the same constant. |
| 1942 | META_ASSERT(GL_VERTEX_ATTRIB_ARRAY_DIVISOR == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE); |
| 1943 | return true; |
| 1944 | |
Jamie Madill | 30855b3 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 1945 | case GL_VERTEX_ATTRIB_ARRAY_INTEGER: |
| 1946 | return ((clientVersion >= 3) ? true : gl::error(GL_INVALID_ENUM, false)); |
| 1947 | |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 1948 | default: |
| 1949 | return gl::error(GL_INVALID_ENUM, false); |
| 1950 | } |
| 1951 | } |
| 1952 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 1953 | bool validateTexParamParameters(gl::Context *context, GLenum pname, GLint param) |
| 1954 | { |
| 1955 | switch (pname) |
| 1956 | { |
| 1957 | case GL_TEXTURE_WRAP_R: |
| 1958 | case GL_TEXTURE_SWIZZLE_R: |
| 1959 | case GL_TEXTURE_SWIZZLE_G: |
| 1960 | case GL_TEXTURE_SWIZZLE_B: |
| 1961 | case GL_TEXTURE_SWIZZLE_A: |
| 1962 | case GL_TEXTURE_BASE_LEVEL: |
| 1963 | case GL_TEXTURE_MAX_LEVEL: |
| 1964 | case GL_TEXTURE_COMPARE_MODE: |
| 1965 | case GL_TEXTURE_COMPARE_FUNC: |
| 1966 | case GL_TEXTURE_MIN_LOD: |
| 1967 | case GL_TEXTURE_MAX_LOD: |
| 1968 | if (context->getClientVersion() < 3) |
| 1969 | { |
| 1970 | return gl::error(GL_INVALID_ENUM, false); |
| 1971 | } |
| 1972 | break; |
| 1973 | |
| 1974 | default: break; |
| 1975 | } |
| 1976 | |
| 1977 | switch (pname) |
| 1978 | { |
| 1979 | case GL_TEXTURE_WRAP_S: |
| 1980 | case GL_TEXTURE_WRAP_T: |
| 1981 | case GL_TEXTURE_WRAP_R: |
| 1982 | switch (param) |
| 1983 | { |
| 1984 | case GL_REPEAT: |
| 1985 | case GL_CLAMP_TO_EDGE: |
| 1986 | case GL_MIRRORED_REPEAT: |
| 1987 | return true; |
| 1988 | default: |
| 1989 | return gl::error(GL_INVALID_ENUM, false); |
| 1990 | } |
| 1991 | |
| 1992 | case GL_TEXTURE_MIN_FILTER: |
| 1993 | switch (param) |
| 1994 | { |
| 1995 | case GL_NEAREST: |
| 1996 | case GL_LINEAR: |
| 1997 | case GL_NEAREST_MIPMAP_NEAREST: |
| 1998 | case GL_LINEAR_MIPMAP_NEAREST: |
| 1999 | case GL_NEAREST_MIPMAP_LINEAR: |
| 2000 | case GL_LINEAR_MIPMAP_LINEAR: |
| 2001 | return true; |
| 2002 | default: |
| 2003 | return gl::error(GL_INVALID_ENUM, false); |
| 2004 | } |
| 2005 | break; |
| 2006 | |
| 2007 | case GL_TEXTURE_MAG_FILTER: |
| 2008 | switch (param) |
| 2009 | { |
| 2010 | case GL_NEAREST: |
| 2011 | case GL_LINEAR: |
| 2012 | return true; |
| 2013 | default: |
| 2014 | return gl::error(GL_INVALID_ENUM, false); |
| 2015 | } |
| 2016 | break; |
| 2017 | |
| 2018 | case GL_TEXTURE_USAGE_ANGLE: |
| 2019 | switch (param) |
| 2020 | { |
| 2021 | case GL_NONE: |
| 2022 | case GL_FRAMEBUFFER_ATTACHMENT_ANGLE: |
| 2023 | return true; |
| 2024 | default: |
| 2025 | return gl::error(GL_INVALID_ENUM, false); |
| 2026 | } |
| 2027 | break; |
| 2028 | |
| 2029 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 2030 | if (!context->supportsTextureFilterAnisotropy()) |
| 2031 | { |
| 2032 | return gl::error(GL_INVALID_ENUM, false); |
| 2033 | } |
| 2034 | |
| 2035 | // we assume the parameter passed to this validation method is truncated, not rounded |
| 2036 | if (param < 1) |
| 2037 | { |
| 2038 | return gl::error(GL_INVALID_VALUE, false); |
| 2039 | } |
| 2040 | return true; |
| 2041 | |
| 2042 | case GL_TEXTURE_MIN_LOD: |
| 2043 | case GL_TEXTURE_MAX_LOD: |
| 2044 | // any value is permissible |
| 2045 | return true; |
| 2046 | |
| 2047 | case GL_TEXTURE_COMPARE_MODE: |
| 2048 | switch (param) |
| 2049 | { |
| 2050 | case GL_NONE: |
| 2051 | case GL_COMPARE_REF_TO_TEXTURE: |
| 2052 | return true; |
| 2053 | default: |
| 2054 | return gl::error(GL_INVALID_ENUM, false); |
| 2055 | } |
| 2056 | break; |
| 2057 | |
| 2058 | case GL_TEXTURE_COMPARE_FUNC: |
| 2059 | switch (param) |
| 2060 | { |
| 2061 | case GL_LEQUAL: |
| 2062 | case GL_GEQUAL: |
| 2063 | case GL_LESS: |
| 2064 | case GL_GREATER: |
| 2065 | case GL_EQUAL: |
| 2066 | case GL_NOTEQUAL: |
| 2067 | case GL_ALWAYS: |
| 2068 | case GL_NEVER: |
| 2069 | return true; |
| 2070 | default: |
| 2071 | return gl::error(GL_INVALID_ENUM, false); |
| 2072 | } |
| 2073 | break; |
| 2074 | |
| 2075 | case GL_TEXTURE_SWIZZLE_R: |
| 2076 | case GL_TEXTURE_SWIZZLE_G: |
| 2077 | case GL_TEXTURE_SWIZZLE_B: |
| 2078 | case GL_TEXTURE_SWIZZLE_A: |
| 2079 | case GL_TEXTURE_BASE_LEVEL: |
| 2080 | case GL_TEXTURE_MAX_LEVEL: |
| 2081 | UNIMPLEMENTED(); |
| 2082 | return true; |
| 2083 | |
| 2084 | default: |
| 2085 | return gl::error(GL_INVALID_ENUM, false); |
| 2086 | } |
| 2087 | } |
| 2088 | |
| 2089 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 2090 | gl::Texture *getTargetTexture(gl::Context *context, GLenum target) |
| 2091 | { |
| 2092 | if (context->getClientVersion() < 3) |
| 2093 | { |
| 2094 | if (target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) |
| 2095 | { |
| 2096 | return NULL; |
| 2097 | } |
| 2098 | } |
| 2099 | |
| 2100 | switch (target) |
| 2101 | { |
| 2102 | case GL_TEXTURE_2D: return context->getTexture2D(); |
| 2103 | case GL_TEXTURE_CUBE_MAP: return context->getTextureCubeMap(); |
| 2104 | case GL_TEXTURE_3D: return context->getTexture3D(); |
| 2105 | case GL_TEXTURE_2D_ARRAY: return context->getTexture2DArray(); |
| 2106 | default: return NULL; |
| 2107 | } |
| 2108 | } |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2109 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame^] | 2110 | bool validateSamplerObjectParameter(GLenum pname) |
| 2111 | { |
| 2112 | switch (pname) |
| 2113 | { |
| 2114 | case GL_TEXTURE_MIN_FILTER: |
| 2115 | case GL_TEXTURE_MAG_FILTER: |
| 2116 | case GL_TEXTURE_WRAP_S: |
| 2117 | case GL_TEXTURE_WRAP_T: |
| 2118 | case GL_TEXTURE_WRAP_R: |
| 2119 | case GL_TEXTURE_MIN_LOD: |
| 2120 | case GL_TEXTURE_MAX_LOD: |
| 2121 | case GL_TEXTURE_COMPARE_MODE: |
| 2122 | case GL_TEXTURE_COMPARE_FUNC: |
| 2123 | return true; |
| 2124 | |
| 2125 | default: |
| 2126 | return gl::error(GL_INVALID_ENUM, false); |
| 2127 | } |
| 2128 | } |
| 2129 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2130 | extern "C" |
| 2131 | { |
| 2132 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2133 | // OpenGL ES 2.0 functions |
| 2134 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2135 | void __stdcall glActiveTexture(GLenum texture) |
| 2136 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2137 | EVENT("(GLenum texture = 0x%X)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2138 | |
| 2139 | try |
| 2140 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2141 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2142 | |
| 2143 | if (context) |
| 2144 | { |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 2145 | if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1) |
| 2146 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2147 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 2148 | } |
| 2149 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2150 | context->setActiveSampler(texture - GL_TEXTURE0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2151 | } |
| 2152 | } |
| 2153 | catch(std::bad_alloc&) |
| 2154 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2155 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2156 | } |
| 2157 | } |
| 2158 | |
| 2159 | void __stdcall glAttachShader(GLuint program, GLuint shader) |
| 2160 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2161 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2162 | |
| 2163 | try |
| 2164 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2165 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2166 | |
| 2167 | if (context) |
| 2168 | { |
| 2169 | gl::Program *programObject = context->getProgram(program); |
| 2170 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2171 | |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2172 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2173 | { |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2174 | if (context->getShader(program)) |
| 2175 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2176 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2177 | } |
| 2178 | else |
| 2179 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2180 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2181 | } |
| 2182 | } |
| 2183 | |
| 2184 | if (!shaderObject) |
| 2185 | { |
| 2186 | if (context->getProgram(shader)) |
| 2187 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2188 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2189 | } |
| 2190 | else |
| 2191 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2192 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2193 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2194 | } |
| 2195 | |
| 2196 | if (!programObject->attachShader(shaderObject)) |
| 2197 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2198 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2199 | } |
| 2200 | } |
| 2201 | } |
| 2202 | catch(std::bad_alloc&) |
| 2203 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2204 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2205 | } |
| 2206 | } |
| 2207 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2208 | void __stdcall glBeginQueryEXT(GLenum target, GLuint id) |
| 2209 | { |
| 2210 | EVENT("(GLenum target = 0x%X, GLuint %d)", target, id); |
| 2211 | |
| 2212 | try |
| 2213 | { |
| 2214 | switch (target) |
| 2215 | { |
| 2216 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 2217 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 2218 | break; |
| 2219 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2220 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2221 | } |
| 2222 | |
| 2223 | if (id == 0) |
| 2224 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2225 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2226 | } |
| 2227 | |
| 2228 | gl::Context *context = gl::getNonLostContext(); |
| 2229 | |
| 2230 | if (context) |
| 2231 | { |
| 2232 | context->beginQuery(target, id); |
| 2233 | } |
| 2234 | } |
| 2235 | catch(std::bad_alloc&) |
| 2236 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2237 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2238 | } |
| 2239 | } |
| 2240 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2241 | void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2242 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2243 | 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] | 2244 | |
| 2245 | try |
| 2246 | { |
| 2247 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 2248 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2249 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2250 | } |
| 2251 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2252 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2253 | |
| 2254 | if (context) |
| 2255 | { |
| 2256 | gl::Program *programObject = context->getProgram(program); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2257 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2258 | if (!programObject) |
| 2259 | { |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2260 | if (context->getShader(program)) |
| 2261 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2262 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2263 | } |
| 2264 | else |
| 2265 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2266 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2267 | } |
| 2268 | } |
| 2269 | |
| 2270 | if (strncmp(name, "gl_", 3) == 0) |
| 2271 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2272 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2273 | } |
| 2274 | |
| 2275 | programObject->bindAttributeLocation(index, name); |
| 2276 | } |
| 2277 | } |
| 2278 | catch(std::bad_alloc&) |
| 2279 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2280 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2281 | } |
| 2282 | } |
| 2283 | |
| 2284 | void __stdcall glBindBuffer(GLenum target, GLuint buffer) |
| 2285 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2286 | EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2287 | |
| 2288 | try |
| 2289 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2290 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2291 | |
| 2292 | if (context) |
| 2293 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2294 | // Check ES3 specific targets |
| 2295 | switch (target) |
| 2296 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2297 | case GL_COPY_READ_BUFFER: |
| 2298 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2299 | case GL_PIXEL_PACK_BUFFER: |
| 2300 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2301 | case GL_UNIFORM_BUFFER: |
| 2302 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2303 | if (context->getClientVersion() < 3) |
| 2304 | { |
| 2305 | return gl::error(GL_INVALID_ENUM); |
| 2306 | } |
| 2307 | } |
| 2308 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2309 | switch (target) |
| 2310 | { |
| 2311 | case GL_ARRAY_BUFFER: |
| 2312 | context->bindArrayBuffer(buffer); |
| 2313 | return; |
| 2314 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2315 | context->bindElementArrayBuffer(buffer); |
| 2316 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2317 | case GL_COPY_READ_BUFFER: |
| 2318 | context->bindCopyReadBuffer(buffer); |
| 2319 | return; |
| 2320 | case GL_COPY_WRITE_BUFFER: |
| 2321 | context->bindCopyWriteBuffer(buffer); |
| 2322 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2323 | case GL_PIXEL_PACK_BUFFER: |
| 2324 | context->bindPixelPackBuffer(buffer); |
| 2325 | return; |
| 2326 | case GL_PIXEL_UNPACK_BUFFER: |
| 2327 | context->bindPixelUnpackBuffer(buffer); |
| 2328 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2329 | case GL_UNIFORM_BUFFER: |
| 2330 | context->bindGenericUniformBuffer(buffer); |
| 2331 | return; |
| 2332 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 7a1ebad | 2013-05-30 00:05:20 +0000 | [diff] [blame] | 2333 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2334 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2335 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2336 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2337 | } |
| 2338 | } |
| 2339 | } |
| 2340 | catch(std::bad_alloc&) |
| 2341 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2342 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2343 | } |
| 2344 | } |
| 2345 | |
| 2346 | void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer) |
| 2347 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2348 | EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2349 | |
| 2350 | try |
| 2351 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2352 | 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] | 2353 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2354 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2355 | } |
| 2356 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2357 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2358 | |
| 2359 | if (context) |
| 2360 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2361 | if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 2362 | { |
| 2363 | context->bindReadFramebuffer(framebuffer); |
| 2364 | } |
| 2365 | |
| 2366 | if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 2367 | { |
| 2368 | context->bindDrawFramebuffer(framebuffer); |
| 2369 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2370 | } |
| 2371 | } |
| 2372 | catch(std::bad_alloc&) |
| 2373 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2374 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2375 | } |
| 2376 | } |
| 2377 | |
| 2378 | void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 2379 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2380 | EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2381 | |
| 2382 | try |
| 2383 | { |
| 2384 | if (target != GL_RENDERBUFFER) |
| 2385 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2386 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2387 | } |
| 2388 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2389 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2390 | |
| 2391 | if (context) |
| 2392 | { |
| 2393 | context->bindRenderbuffer(renderbuffer); |
| 2394 | } |
| 2395 | } |
| 2396 | catch(std::bad_alloc&) |
| 2397 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2398 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2399 | } |
| 2400 | } |
| 2401 | |
| 2402 | void __stdcall glBindTexture(GLenum target, GLuint texture) |
| 2403 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2404 | EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2405 | |
| 2406 | try |
| 2407 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2408 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2409 | |
| 2410 | if (context) |
| 2411 | { |
| 2412 | gl::Texture *textureObject = context->getTexture(texture); |
| 2413 | |
| 2414 | if (textureObject && textureObject->getTarget() != target && texture != 0) |
| 2415 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2416 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2417 | } |
| 2418 | |
| 2419 | switch (target) |
| 2420 | { |
| 2421 | case GL_TEXTURE_2D: |
| 2422 | context->bindTexture2D(texture); |
| 2423 | return; |
| 2424 | case GL_TEXTURE_CUBE_MAP: |
| 2425 | context->bindTextureCubeMap(texture); |
| 2426 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 2427 | case GL_TEXTURE_3D: |
| 2428 | if (context->getClientVersion() < 3) |
| 2429 | { |
| 2430 | return gl::error(GL_INVALID_ENUM); |
| 2431 | } |
| 2432 | context->bindTexture3D(texture); |
| 2433 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 2434 | case GL_TEXTURE_2D_ARRAY: |
| 2435 | if (context->getClientVersion() < 3) |
| 2436 | { |
| 2437 | return gl::error(GL_INVALID_ENUM); |
| 2438 | } |
| 2439 | context->bindTexture2DArray(texture); |
| 2440 | return; |
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 | } |
| 2445 | } |
| 2446 | catch(std::bad_alloc&) |
| 2447 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2448 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2449 | } |
| 2450 | } |
| 2451 | |
| 2452 | void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2453 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2454 | 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] | 2455 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2456 | |
| 2457 | try |
| 2458 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2459 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2460 | |
| 2461 | if (context) |
| 2462 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2463 | 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] | 2464 | } |
| 2465 | } |
| 2466 | catch(std::bad_alloc&) |
| 2467 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2468 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2469 | } |
| 2470 | } |
| 2471 | |
| 2472 | void __stdcall glBlendEquation(GLenum mode) |
| 2473 | { |
| 2474 | glBlendEquationSeparate(mode, mode); |
| 2475 | } |
| 2476 | |
| 2477 | void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 2478 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2479 | EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2480 | |
| 2481 | try |
| 2482 | { |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2483 | gl::Context *context = gl::getNonLostContext(); |
| 2484 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2485 | switch (modeRGB) |
| 2486 | { |
| 2487 | case GL_FUNC_ADD: |
| 2488 | case GL_FUNC_SUBTRACT: |
| 2489 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2490 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2491 | |
| 2492 | case GL_MIN: |
| 2493 | case GL_MAX: |
| 2494 | if (context && context->getClientVersion() < 3) |
| 2495 | { |
| 2496 | return gl::error(GL_INVALID_ENUM); |
| 2497 | } |
| 2498 | break; |
| 2499 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2500 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2501 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2502 | } |
| 2503 | |
| 2504 | switch (modeAlpha) |
| 2505 | { |
| 2506 | case GL_FUNC_ADD: |
| 2507 | case GL_FUNC_SUBTRACT: |
| 2508 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2509 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2510 | |
| 2511 | case GL_MIN: |
| 2512 | case GL_MAX: |
| 2513 | if (context && context->getClientVersion() < 3) |
| 2514 | { |
| 2515 | return gl::error(GL_INVALID_ENUM); |
| 2516 | } |
| 2517 | break; |
| 2518 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2519 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2520 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2521 | } |
| 2522 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2523 | if (context) |
| 2524 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2525 | context->setBlendEquation(modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2526 | } |
| 2527 | } |
| 2528 | catch(std::bad_alloc&) |
| 2529 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2530 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2531 | } |
| 2532 | } |
| 2533 | |
| 2534 | void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor) |
| 2535 | { |
| 2536 | glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor); |
| 2537 | } |
| 2538 | |
| 2539 | void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 2540 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2541 | 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] | 2542 | srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2543 | |
| 2544 | try |
| 2545 | { |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2546 | gl::Context *context = gl::getNonLostContext(); |
| 2547 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2548 | switch (srcRGB) |
| 2549 | { |
| 2550 | case GL_ZERO: |
| 2551 | case GL_ONE: |
| 2552 | case GL_SRC_COLOR: |
| 2553 | case GL_ONE_MINUS_SRC_COLOR: |
| 2554 | case GL_DST_COLOR: |
| 2555 | case GL_ONE_MINUS_DST_COLOR: |
| 2556 | case GL_SRC_ALPHA: |
| 2557 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2558 | case GL_DST_ALPHA: |
| 2559 | case GL_ONE_MINUS_DST_ALPHA: |
| 2560 | case GL_CONSTANT_COLOR: |
| 2561 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2562 | case GL_CONSTANT_ALPHA: |
| 2563 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2564 | case GL_SRC_ALPHA_SATURATE: |
| 2565 | break; |
| 2566 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2567 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2568 | } |
| 2569 | |
| 2570 | switch (dstRGB) |
| 2571 | { |
| 2572 | case GL_ZERO: |
| 2573 | case GL_ONE: |
| 2574 | case GL_SRC_COLOR: |
| 2575 | case GL_ONE_MINUS_SRC_COLOR: |
| 2576 | case GL_DST_COLOR: |
| 2577 | case GL_ONE_MINUS_DST_COLOR: |
| 2578 | case GL_SRC_ALPHA: |
| 2579 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2580 | case GL_DST_ALPHA: |
| 2581 | case GL_ONE_MINUS_DST_ALPHA: |
| 2582 | case GL_CONSTANT_COLOR: |
| 2583 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2584 | case GL_CONSTANT_ALPHA: |
| 2585 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2586 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2587 | |
| 2588 | case GL_SRC_ALPHA_SATURATE: |
| 2589 | if (!context || context->getClientVersion() < 3) |
| 2590 | { |
| 2591 | return gl::error(GL_INVALID_ENUM); |
| 2592 | } |
| 2593 | break; |
| 2594 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2595 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2596 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2597 | } |
| 2598 | |
| 2599 | switch (srcAlpha) |
| 2600 | { |
| 2601 | case GL_ZERO: |
| 2602 | case GL_ONE: |
| 2603 | case GL_SRC_COLOR: |
| 2604 | case GL_ONE_MINUS_SRC_COLOR: |
| 2605 | case GL_DST_COLOR: |
| 2606 | case GL_ONE_MINUS_DST_COLOR: |
| 2607 | case GL_SRC_ALPHA: |
| 2608 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2609 | case GL_DST_ALPHA: |
| 2610 | case GL_ONE_MINUS_DST_ALPHA: |
| 2611 | case GL_CONSTANT_COLOR: |
| 2612 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2613 | case GL_CONSTANT_ALPHA: |
| 2614 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2615 | case GL_SRC_ALPHA_SATURATE: |
| 2616 | break; |
| 2617 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2618 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2619 | } |
| 2620 | |
| 2621 | switch (dstAlpha) |
| 2622 | { |
| 2623 | case GL_ZERO: |
| 2624 | case GL_ONE: |
| 2625 | case GL_SRC_COLOR: |
| 2626 | case GL_ONE_MINUS_SRC_COLOR: |
| 2627 | case GL_DST_COLOR: |
| 2628 | case GL_ONE_MINUS_DST_COLOR: |
| 2629 | case GL_SRC_ALPHA: |
| 2630 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2631 | case GL_DST_ALPHA: |
| 2632 | case GL_ONE_MINUS_DST_ALPHA: |
| 2633 | case GL_CONSTANT_COLOR: |
| 2634 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2635 | case GL_CONSTANT_ALPHA: |
| 2636 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2637 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2638 | |
| 2639 | case GL_SRC_ALPHA_SATURATE: |
| 2640 | if (!context || context->getClientVersion() < 3) |
| 2641 | { |
| 2642 | return gl::error(GL_INVALID_ENUM); |
| 2643 | } |
| 2644 | break; |
| 2645 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2646 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2647 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2648 | } |
| 2649 | |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2650 | bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR || |
| 2651 | dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR); |
| 2652 | |
| 2653 | bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA || |
| 2654 | dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA); |
| 2655 | |
| 2656 | if (constantColorUsed && constantAlphaUsed) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2657 | { |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2658 | 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] | 2659 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2660 | } |
| 2661 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2662 | if (context) |
| 2663 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2664 | context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2665 | } |
| 2666 | } |
| 2667 | catch(std::bad_alloc&) |
| 2668 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2669 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2670 | } |
| 2671 | } |
| 2672 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2673 | 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] | 2674 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2675 | 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] | 2676 | target, size, data, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2677 | |
| 2678 | try |
| 2679 | { |
| 2680 | if (size < 0) |
| 2681 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2682 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2683 | } |
| 2684 | |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2685 | gl::Context *context = gl::getNonLostContext(); |
| 2686 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2687 | switch (usage) |
| 2688 | { |
| 2689 | case GL_STREAM_DRAW: |
| 2690 | case GL_STATIC_DRAW: |
| 2691 | case GL_DYNAMIC_DRAW: |
| 2692 | break; |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2693 | |
| 2694 | case GL_STREAM_READ: |
| 2695 | case GL_STREAM_COPY: |
| 2696 | case GL_STATIC_READ: |
| 2697 | case GL_STATIC_COPY: |
| 2698 | case GL_DYNAMIC_READ: |
| 2699 | case GL_DYNAMIC_COPY: |
| 2700 | if (context && context->getClientVersion() < 3) |
| 2701 | { |
| 2702 | return gl::error(GL_INVALID_ENUM); |
| 2703 | } |
| 2704 | break; |
| 2705 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2706 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2707 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2708 | } |
| 2709 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2710 | if (context) |
| 2711 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2712 | // Check ES3 specific targets |
| 2713 | switch (target) |
| 2714 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2715 | case GL_COPY_READ_BUFFER: |
| 2716 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2717 | case GL_PIXEL_PACK_BUFFER: |
| 2718 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2719 | case GL_UNIFORM_BUFFER: |
| 2720 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2721 | if (context->getClientVersion() < 3) |
| 2722 | { |
| 2723 | return gl::error(GL_INVALID_ENUM); |
| 2724 | } |
| 2725 | } |
| 2726 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2727 | gl::Buffer *buffer; |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2728 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2729 | switch (target) |
| 2730 | { |
| 2731 | case GL_ARRAY_BUFFER: |
| 2732 | buffer = context->getArrayBuffer(); |
| 2733 | break; |
| 2734 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2735 | buffer = context->getElementArrayBuffer(); |
| 2736 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2737 | case GL_COPY_READ_BUFFER: |
| 2738 | buffer = context->getCopyReadBuffer(); |
| 2739 | break; |
| 2740 | case GL_COPY_WRITE_BUFFER: |
| 2741 | buffer = context->getCopyWriteBuffer(); |
| 2742 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2743 | case GL_PIXEL_PACK_BUFFER: |
| 2744 | buffer = context->getPixelPackBuffer(); |
| 2745 | break; |
| 2746 | case GL_PIXEL_UNPACK_BUFFER: |
| 2747 | buffer = context->getPixelUnpackBuffer(); |
| 2748 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2749 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2750 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2751 | break; |
| 2752 | case GL_UNIFORM_BUFFER: |
| 2753 | buffer = context->getGenericUniformBuffer(); |
| 2754 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2755 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2756 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2757 | } |
| 2758 | |
| 2759 | if (!buffer) |
| 2760 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2761 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2762 | } |
| 2763 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2764 | buffer->bufferData(data, size, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2765 | } |
| 2766 | } |
| 2767 | catch(std::bad_alloc&) |
| 2768 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2769 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2770 | } |
| 2771 | } |
| 2772 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2773 | 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] | 2774 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2775 | 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] | 2776 | target, offset, size, data); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2777 | |
| 2778 | try |
| 2779 | { |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2780 | if (size < 0 || offset < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2781 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2782 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2783 | } |
| 2784 | |
daniel@transgaming.com | d4620a3 | 2010-03-21 04:31:28 +0000 | [diff] [blame] | 2785 | if (data == NULL) |
| 2786 | { |
| 2787 | return; |
| 2788 | } |
| 2789 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2790 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2791 | |
| 2792 | if (context) |
| 2793 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2794 | // Check ES3 specific targets |
| 2795 | switch (target) |
| 2796 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2797 | case GL_COPY_READ_BUFFER: |
| 2798 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2799 | case GL_PIXEL_PACK_BUFFER: |
| 2800 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2801 | case GL_UNIFORM_BUFFER: |
| 2802 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2803 | if (context->getClientVersion() < 3) |
| 2804 | { |
| 2805 | return gl::error(GL_INVALID_ENUM); |
| 2806 | } |
| 2807 | } |
| 2808 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2809 | gl::Buffer *buffer; |
| 2810 | |
| 2811 | switch (target) |
| 2812 | { |
| 2813 | case GL_ARRAY_BUFFER: |
| 2814 | buffer = context->getArrayBuffer(); |
| 2815 | break; |
| 2816 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2817 | buffer = context->getElementArrayBuffer(); |
| 2818 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2819 | case GL_COPY_READ_BUFFER: |
| 2820 | buffer = context->getCopyReadBuffer(); |
| 2821 | break; |
| 2822 | case GL_COPY_WRITE_BUFFER: |
| 2823 | buffer = context->getCopyWriteBuffer(); |
| 2824 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2825 | case GL_PIXEL_PACK_BUFFER: |
| 2826 | buffer = context->getPixelPackBuffer(); |
| 2827 | break; |
| 2828 | case GL_PIXEL_UNPACK_BUFFER: |
| 2829 | buffer = context->getPixelUnpackBuffer(); |
| 2830 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2831 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2832 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2833 | break; |
| 2834 | case GL_UNIFORM_BUFFER: |
| 2835 | buffer = context->getGenericUniformBuffer(); |
| 2836 | break; |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2837 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2838 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2839 | } |
| 2840 | |
| 2841 | if (!buffer) |
| 2842 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2843 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2844 | } |
| 2845 | |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2846 | if ((size_t)size + offset > buffer->size()) |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2847 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2848 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2849 | } |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2850 | |
| 2851 | buffer->bufferSubData(data, size, offset); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2852 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2853 | } |
| 2854 | catch(std::bad_alloc&) |
| 2855 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2856 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2857 | } |
| 2858 | } |
| 2859 | |
| 2860 | GLenum __stdcall glCheckFramebufferStatus(GLenum target) |
| 2861 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2862 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2863 | |
| 2864 | try |
| 2865 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2866 | 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] | 2867 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2868 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2869 | } |
| 2870 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2871 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2872 | |
| 2873 | if (context) |
| 2874 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2875 | gl::Framebuffer *framebuffer = NULL; |
| 2876 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 2877 | { |
| 2878 | framebuffer = context->getReadFramebuffer(); |
| 2879 | } |
| 2880 | else |
| 2881 | { |
| 2882 | framebuffer = context->getDrawFramebuffer(); |
| 2883 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2884 | |
| 2885 | return framebuffer->completeness(); |
| 2886 | } |
| 2887 | } |
| 2888 | catch(std::bad_alloc&) |
| 2889 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2890 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2891 | } |
| 2892 | |
| 2893 | return 0; |
| 2894 | } |
| 2895 | |
| 2896 | void __stdcall glClear(GLbitfield mask) |
| 2897 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2898 | EVENT("(GLbitfield mask = 0x%X)", mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2899 | |
| 2900 | try |
| 2901 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2902 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2903 | |
| 2904 | if (context) |
| 2905 | { |
| 2906 | context->clear(mask); |
| 2907 | } |
| 2908 | } |
| 2909 | catch(std::bad_alloc&) |
| 2910 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2911 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2912 | } |
| 2913 | } |
| 2914 | |
| 2915 | void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2916 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2917 | 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] | 2918 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2919 | |
| 2920 | try |
| 2921 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2922 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2923 | |
| 2924 | if (context) |
| 2925 | { |
| 2926 | context->setClearColor(red, green, blue, alpha); |
| 2927 | } |
| 2928 | } |
| 2929 | catch(std::bad_alloc&) |
| 2930 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2931 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2932 | } |
| 2933 | } |
| 2934 | |
| 2935 | void __stdcall glClearDepthf(GLclampf depth) |
| 2936 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2937 | EVENT("(GLclampf depth = %f)", depth); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2938 | |
| 2939 | try |
| 2940 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2941 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2942 | |
| 2943 | if (context) |
| 2944 | { |
| 2945 | context->setClearDepth(depth); |
| 2946 | } |
| 2947 | } |
| 2948 | catch(std::bad_alloc&) |
| 2949 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2950 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2951 | } |
| 2952 | } |
| 2953 | |
| 2954 | void __stdcall glClearStencil(GLint s) |
| 2955 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2956 | EVENT("(GLint s = %d)", s); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2957 | |
| 2958 | try |
| 2959 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2960 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2961 | |
| 2962 | if (context) |
| 2963 | { |
| 2964 | context->setClearStencil(s); |
| 2965 | } |
| 2966 | } |
| 2967 | catch(std::bad_alloc&) |
| 2968 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2969 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2970 | } |
| 2971 | } |
| 2972 | |
| 2973 | void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 2974 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2975 | 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] | 2976 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2977 | |
| 2978 | try |
| 2979 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2980 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2981 | |
| 2982 | if (context) |
| 2983 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 2984 | 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] | 2985 | } |
| 2986 | } |
| 2987 | catch(std::bad_alloc&) |
| 2988 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2989 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2990 | } |
| 2991 | } |
| 2992 | |
| 2993 | void __stdcall glCompileShader(GLuint shader) |
| 2994 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2995 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2996 | |
| 2997 | try |
| 2998 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2999 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3000 | |
| 3001 | if (context) |
| 3002 | { |
| 3003 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 3004 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3005 | if (!shaderObject) |
| 3006 | { |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 3007 | if (context->getProgram(shader)) |
| 3008 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3009 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 3010 | } |
| 3011 | else |
| 3012 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3013 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 3014 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3015 | } |
| 3016 | |
| 3017 | shaderObject->compile(); |
| 3018 | } |
| 3019 | } |
| 3020 | catch(std::bad_alloc&) |
| 3021 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3022 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3023 | } |
| 3024 | } |
| 3025 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3026 | void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, |
| 3027 | GLint border, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3028 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3029 | 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] | 3030 | "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] | 3031 | target, level, internalformat, width, height, border, imageSize, data); |
| 3032 | |
| 3033 | try |
| 3034 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3035 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3036 | |
| 3037 | if (context) |
| 3038 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3039 | if (context->getClientVersion() < 3 && |
| 3040 | !validateES2TexImageParameters(context, target, level, internalformat, true, false, |
| 3041 | 0, 0, width, height, 0, GL_NONE, GL_NONE, data)) |
| 3042 | { |
| 3043 | return; |
| 3044 | } |
| 3045 | |
| 3046 | if (context->getClientVersion() >= 3 && |
| 3047 | !validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 3048 | 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 3049 | { |
| 3050 | return; |
| 3051 | } |
| 3052 | |
| 3053 | 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] | 3054 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3055 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3056 | } |
| 3057 | |
| 3058 | switch (target) |
| 3059 | { |
| 3060 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3061 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3062 | gl::Texture2D *texture = context->getTexture2D(); |
| 3063 | texture->setCompressedImage(level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3064 | } |
| 3065 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3066 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3067 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3068 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3069 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3070 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3071 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3072 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3073 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3074 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3075 | texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3076 | } |
| 3077 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3078 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3079 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3080 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3081 | } |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3082 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 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); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3087 | } |
| 3088 | } |
| 3089 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3090 | void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 3091 | GLenum format, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3092 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3093 | 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] | 3094 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3095 | "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3096 | target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 3097 | |
| 3098 | try |
| 3099 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3100 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3101 | |
| 3102 | if (context) |
| 3103 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3104 | if (context->getClientVersion() < 3 && |
| 3105 | !validateES2TexImageParameters(context, target, level, GL_NONE, true, true, |
| 3106 | xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data)) |
| 3107 | { |
| 3108 | return; |
| 3109 | } |
| 3110 | |
| 3111 | if (context->getClientVersion() >= 3 && |
| 3112 | !validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 3113 | xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 3114 | { |
| 3115 | return; |
| 3116 | } |
| 3117 | |
| 3118 | 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] | 3119 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3120 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3121 | } |
| 3122 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3123 | switch (target) |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3124 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3125 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3126 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3127 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 3128 | texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3129 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3130 | break; |
| 3131 | |
| 3132 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3133 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3134 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3135 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3136 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3137 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3138 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3139 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 3140 | texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3141 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3142 | break; |
| 3143 | |
| 3144 | default: |
| 3145 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3146 | } |
| 3147 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3148 | } |
| 3149 | catch(std::bad_alloc&) |
| 3150 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3151 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3152 | } |
| 3153 | } |
| 3154 | |
| 3155 | void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) |
| 3156 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3157 | 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] | 3158 | "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] | 3159 | target, level, internalformat, x, y, width, height, border); |
| 3160 | |
| 3161 | try |
| 3162 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3163 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3164 | |
| 3165 | if (context) |
| 3166 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3167 | if (context->getClientVersion() < 3 && |
| 3168 | !validateES2CopyTexImageParameters(context, target, level, internalformat, false, |
| 3169 | 0, 0, x, y, width, height, border)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 3170 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3171 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 3172 | } |
| 3173 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3174 | if (context->getClientVersion() >= 3 && |
| 3175 | !validateES3CopyTexImageParameters(context, target, level, internalformat, false, |
| 3176 | 0, 0, 0, x, y, width, height, border)) |
| 3177 | { |
| 3178 | return; |
| 3179 | } |
| 3180 | |
| 3181 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 3182 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3183 | switch (target) |
| 3184 | { |
| 3185 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3186 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3187 | gl::Texture2D *texture = context->getTexture2D(); |
| 3188 | texture->copyImage(level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3189 | } |
| 3190 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3191 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3192 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3193 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3194 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3195 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3196 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3197 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3198 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3199 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3200 | texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3201 | } |
| 3202 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3203 | |
| 3204 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3205 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3206 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3207 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3208 | } |
| 3209 | catch(std::bad_alloc&) |
| 3210 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3211 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3212 | } |
| 3213 | } |
| 3214 | |
| 3215 | void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 3216 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3217 | 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] | 3218 | "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] | 3219 | target, level, xoffset, yoffset, x, y, width, height); |
| 3220 | |
| 3221 | try |
| 3222 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3223 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3224 | |
| 3225 | if (context) |
| 3226 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3227 | if (context->getClientVersion() < 3 && |
| 3228 | !validateES2CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 3229 | xoffset, yoffset, x, y, width, height, 0)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3230 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3231 | return; |
| 3232 | } |
| 3233 | |
| 3234 | if (context->getClientVersion() >= 3 && |
| 3235 | !validateES3CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 3236 | xoffset, yoffset, 0, x, y, width, height, 0)) |
| 3237 | { |
| 3238 | return; |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3239 | } |
| 3240 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3241 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3242 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3243 | switch (target) |
daniel@transgaming.com | bbc5779 | 2010-07-28 19:21:05 +0000 | [diff] [blame] | 3244 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3245 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 3246 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3247 | gl::Texture2D *texture = context->getTexture2D(); |
| 3248 | 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] | 3249 | } |
| 3250 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3251 | |
| 3252 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3253 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3254 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3255 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3256 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3257 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 3258 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3259 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3260 | 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] | 3261 | } |
| 3262 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3263 | |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3264 | default: |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3265 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3266 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3267 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3268 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3269 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3270 | catch(std::bad_alloc&) |
| 3271 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3272 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3273 | } |
| 3274 | } |
| 3275 | |
| 3276 | GLuint __stdcall glCreateProgram(void) |
| 3277 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3278 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3279 | |
| 3280 | try |
| 3281 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3282 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3283 | |
| 3284 | if (context) |
| 3285 | { |
| 3286 | return context->createProgram(); |
| 3287 | } |
| 3288 | } |
| 3289 | catch(std::bad_alloc&) |
| 3290 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3291 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3292 | } |
| 3293 | |
| 3294 | return 0; |
| 3295 | } |
| 3296 | |
| 3297 | GLuint __stdcall glCreateShader(GLenum type) |
| 3298 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3299 | EVENT("(GLenum type = 0x%X)", type); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3300 | |
| 3301 | try |
| 3302 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3303 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3304 | |
| 3305 | if (context) |
| 3306 | { |
| 3307 | switch (type) |
| 3308 | { |
| 3309 | case GL_FRAGMENT_SHADER: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 3310 | case GL_VERTEX_SHADER: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3311 | return context->createShader(type); |
| 3312 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3313 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3314 | } |
| 3315 | } |
| 3316 | } |
| 3317 | catch(std::bad_alloc&) |
| 3318 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3319 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3320 | } |
| 3321 | |
| 3322 | return 0; |
| 3323 | } |
| 3324 | |
| 3325 | void __stdcall glCullFace(GLenum mode) |
| 3326 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3327 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3328 | |
| 3329 | try |
| 3330 | { |
| 3331 | switch (mode) |
| 3332 | { |
| 3333 | case GL_FRONT: |
| 3334 | case GL_BACK: |
| 3335 | case GL_FRONT_AND_BACK: |
| 3336 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3337 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3338 | |
| 3339 | if (context) |
| 3340 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3341 | context->setCullMode(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3342 | } |
| 3343 | } |
| 3344 | break; |
| 3345 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3346 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3347 | } |
| 3348 | } |
| 3349 | catch(std::bad_alloc&) |
| 3350 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3351 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3352 | } |
| 3353 | } |
| 3354 | |
| 3355 | void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers) |
| 3356 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3357 | 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] | 3358 | |
| 3359 | try |
| 3360 | { |
| 3361 | if (n < 0) |
| 3362 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3363 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3364 | } |
| 3365 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3366 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3367 | |
| 3368 | if (context) |
| 3369 | { |
| 3370 | for (int i = 0; i < n; i++) |
| 3371 | { |
| 3372 | context->deleteBuffer(buffers[i]); |
| 3373 | } |
| 3374 | } |
| 3375 | } |
| 3376 | catch(std::bad_alloc&) |
| 3377 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3378 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3379 | } |
| 3380 | } |
| 3381 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3382 | void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences) |
| 3383 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3384 | 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] | 3385 | |
| 3386 | try |
| 3387 | { |
| 3388 | if (n < 0) |
| 3389 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3390 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3391 | } |
| 3392 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3393 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3394 | |
| 3395 | if (context) |
| 3396 | { |
| 3397 | for (int i = 0; i < n; i++) |
| 3398 | { |
| 3399 | context->deleteFence(fences[i]); |
| 3400 | } |
| 3401 | } |
| 3402 | } |
| 3403 | catch(std::bad_alloc&) |
| 3404 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3405 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3406 | } |
| 3407 | } |
| 3408 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3409 | void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) |
| 3410 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3411 | 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] | 3412 | |
| 3413 | try |
| 3414 | { |
| 3415 | if (n < 0) |
| 3416 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3417 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3418 | } |
| 3419 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3420 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3421 | |
| 3422 | if (context) |
| 3423 | { |
| 3424 | for (int i = 0; i < n; i++) |
| 3425 | { |
| 3426 | if (framebuffers[i] != 0) |
| 3427 | { |
| 3428 | context->deleteFramebuffer(framebuffers[i]); |
| 3429 | } |
| 3430 | } |
| 3431 | } |
| 3432 | } |
| 3433 | catch(std::bad_alloc&) |
| 3434 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3435 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3436 | } |
| 3437 | } |
| 3438 | |
| 3439 | void __stdcall glDeleteProgram(GLuint program) |
| 3440 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3441 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3442 | |
| 3443 | try |
| 3444 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3445 | if (program == 0) |
| 3446 | { |
| 3447 | return; |
| 3448 | } |
| 3449 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3450 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3451 | |
| 3452 | if (context) |
| 3453 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3454 | if (!context->getProgram(program)) |
| 3455 | { |
| 3456 | if(context->getShader(program)) |
| 3457 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3458 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3459 | } |
| 3460 | else |
| 3461 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3462 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3463 | } |
| 3464 | } |
| 3465 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3466 | context->deleteProgram(program); |
| 3467 | } |
| 3468 | } |
| 3469 | catch(std::bad_alloc&) |
| 3470 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3471 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3472 | } |
| 3473 | } |
| 3474 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3475 | void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids) |
| 3476 | { |
| 3477 | EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids); |
| 3478 | |
| 3479 | try |
| 3480 | { |
| 3481 | if (n < 0) |
| 3482 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3483 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3484 | } |
| 3485 | |
| 3486 | gl::Context *context = gl::getNonLostContext(); |
| 3487 | |
| 3488 | if (context) |
| 3489 | { |
| 3490 | for (int i = 0; i < n; i++) |
| 3491 | { |
| 3492 | context->deleteQuery(ids[i]); |
| 3493 | } |
| 3494 | } |
| 3495 | } |
| 3496 | catch(std::bad_alloc&) |
| 3497 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3498 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3499 | } |
| 3500 | } |
| 3501 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3502 | void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) |
| 3503 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3504 | 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] | 3505 | |
| 3506 | try |
| 3507 | { |
| 3508 | if (n < 0) |
| 3509 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3510 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3511 | } |
| 3512 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3513 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3514 | |
| 3515 | if (context) |
| 3516 | { |
daniel@transgaming.com | e2b2212 | 2010-03-11 19:22:14 +0000 | [diff] [blame] | 3517 | for (int i = 0; i < n; i++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3518 | { |
| 3519 | context->deleteRenderbuffer(renderbuffers[i]); |
| 3520 | } |
| 3521 | } |
| 3522 | } |
| 3523 | catch(std::bad_alloc&) |
| 3524 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3525 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3526 | } |
| 3527 | } |
| 3528 | |
| 3529 | void __stdcall glDeleteShader(GLuint shader) |
| 3530 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3531 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3532 | |
| 3533 | try |
| 3534 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3535 | if (shader == 0) |
| 3536 | { |
| 3537 | return; |
| 3538 | } |
| 3539 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3540 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3541 | |
| 3542 | if (context) |
| 3543 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3544 | if (!context->getShader(shader)) |
| 3545 | { |
| 3546 | if(context->getProgram(shader)) |
| 3547 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3548 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3549 | } |
| 3550 | else |
| 3551 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3552 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3553 | } |
| 3554 | } |
| 3555 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3556 | context->deleteShader(shader); |
| 3557 | } |
| 3558 | } |
| 3559 | catch(std::bad_alloc&) |
| 3560 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3561 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3562 | } |
| 3563 | } |
| 3564 | |
| 3565 | void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures) |
| 3566 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3567 | 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] | 3568 | |
| 3569 | try |
| 3570 | { |
| 3571 | if (n < 0) |
| 3572 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3573 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3574 | } |
| 3575 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3576 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3577 | |
| 3578 | if (context) |
| 3579 | { |
| 3580 | for (int i = 0; i < n; i++) |
| 3581 | { |
| 3582 | if (textures[i] != 0) |
| 3583 | { |
| 3584 | context->deleteTexture(textures[i]); |
| 3585 | } |
| 3586 | } |
| 3587 | } |
| 3588 | } |
| 3589 | catch(std::bad_alloc&) |
| 3590 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3591 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3592 | } |
| 3593 | } |
| 3594 | |
| 3595 | void __stdcall glDepthFunc(GLenum func) |
| 3596 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3597 | EVENT("(GLenum func = 0x%X)", func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3598 | |
| 3599 | try |
| 3600 | { |
| 3601 | switch (func) |
| 3602 | { |
| 3603 | case GL_NEVER: |
| 3604 | case GL_ALWAYS: |
| 3605 | case GL_LESS: |
| 3606 | case GL_LEQUAL: |
| 3607 | case GL_EQUAL: |
| 3608 | case GL_GREATER: |
| 3609 | case GL_GEQUAL: |
| 3610 | case GL_NOTEQUAL: |
| 3611 | break; |
| 3612 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3613 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3614 | } |
| 3615 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3616 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3617 | |
| 3618 | if (context) |
| 3619 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3620 | context->setDepthFunc(func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3621 | } |
| 3622 | } |
| 3623 | catch(std::bad_alloc&) |
| 3624 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3625 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3626 | } |
| 3627 | } |
| 3628 | |
| 3629 | void __stdcall glDepthMask(GLboolean flag) |
| 3630 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 3631 | EVENT("(GLboolean flag = %u)", flag); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3632 | |
| 3633 | try |
| 3634 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3635 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3636 | |
| 3637 | if (context) |
| 3638 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3639 | context->setDepthMask(flag != GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3640 | } |
| 3641 | } |
| 3642 | catch(std::bad_alloc&) |
| 3643 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3644 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3645 | } |
| 3646 | } |
| 3647 | |
| 3648 | void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar) |
| 3649 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3650 | EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3651 | |
| 3652 | try |
| 3653 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3654 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3655 | |
| 3656 | if (context) |
| 3657 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3658 | context->setDepthRange(zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3659 | } |
| 3660 | } |
| 3661 | catch(std::bad_alloc&) |
| 3662 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3663 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3664 | } |
| 3665 | } |
| 3666 | |
| 3667 | void __stdcall glDetachShader(GLuint program, GLuint shader) |
| 3668 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3669 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3670 | |
| 3671 | try |
| 3672 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3673 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3674 | |
| 3675 | if (context) |
| 3676 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3677 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3678 | gl::Program *programObject = context->getProgram(program); |
| 3679 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3680 | |
| 3681 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3682 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3683 | gl::Shader *shaderByProgramHandle; |
| 3684 | shaderByProgramHandle = context->getShader(program); |
| 3685 | if (!shaderByProgramHandle) |
| 3686 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3687 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3688 | } |
| 3689 | else |
| 3690 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3691 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3692 | } |
| 3693 | } |
| 3694 | |
| 3695 | if (!shaderObject) |
| 3696 | { |
| 3697 | gl::Program *programByShaderHandle = context->getProgram(shader); |
| 3698 | if (!programByShaderHandle) |
| 3699 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3700 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3701 | } |
| 3702 | else |
| 3703 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3704 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3705 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3706 | } |
| 3707 | |
| 3708 | if (!programObject->detachShader(shaderObject)) |
| 3709 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3710 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3711 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3712 | } |
| 3713 | } |
| 3714 | catch(std::bad_alloc&) |
| 3715 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3716 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3717 | } |
| 3718 | } |
| 3719 | |
| 3720 | void __stdcall glDisable(GLenum cap) |
| 3721 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3722 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3723 | |
| 3724 | try |
| 3725 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3726 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3727 | |
| 3728 | if (context) |
| 3729 | { |
| 3730 | switch (cap) |
| 3731 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3732 | case GL_CULL_FACE: context->setCullFace(false); break; |
| 3733 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break; |
| 3734 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break; |
| 3735 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break; |
| 3736 | case GL_SCISSOR_TEST: context->setScissorTest(false); break; |
| 3737 | case GL_STENCIL_TEST: context->setStencilTest(false); break; |
| 3738 | case GL_DEPTH_TEST: context->setDepthTest(false); break; |
| 3739 | case GL_BLEND: context->setBlend(false); break; |
| 3740 | case GL_DITHER: context->setDither(false); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 3741 | |
| 3742 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 3743 | case GL_RASTERIZER_DISCARD: |
| 3744 | if (context->getClientVersion() < 3) |
| 3745 | { |
| 3746 | return gl::error(GL_INVALID_ENUM); |
| 3747 | } |
| 3748 | UNIMPLEMENTED(); |
| 3749 | break; |
| 3750 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3751 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3752 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3753 | } |
| 3754 | } |
| 3755 | } |
| 3756 | catch(std::bad_alloc&) |
| 3757 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3758 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3759 | } |
| 3760 | } |
| 3761 | |
| 3762 | void __stdcall glDisableVertexAttribArray(GLuint index) |
| 3763 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3764 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3765 | |
| 3766 | try |
| 3767 | { |
| 3768 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3769 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3770 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3771 | } |
| 3772 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3773 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3774 | |
| 3775 | if (context) |
| 3776 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3777 | context->setEnableVertexAttribArray(index, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3778 | } |
| 3779 | } |
| 3780 | catch(std::bad_alloc&) |
| 3781 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3782 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3783 | } |
| 3784 | } |
| 3785 | |
| 3786 | void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count) |
| 3787 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3788 | 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] | 3789 | |
| 3790 | try |
| 3791 | { |
| 3792 | if (count < 0 || first < 0) |
| 3793 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3794 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3795 | } |
| 3796 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3797 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3798 | |
| 3799 | if (context) |
| 3800 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3801 | context->drawArrays(mode, first, count, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3802 | } |
| 3803 | } |
| 3804 | catch(std::bad_alloc&) |
| 3805 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3806 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3807 | } |
| 3808 | } |
| 3809 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3810 | void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
| 3811 | { |
| 3812 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount); |
| 3813 | |
| 3814 | try |
| 3815 | { |
| 3816 | if (count < 0 || first < 0 || primcount < 0) |
| 3817 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3818 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3819 | } |
| 3820 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3821 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3822 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3823 | gl::Context *context = gl::getNonLostContext(); |
| 3824 | |
| 3825 | if (context) |
| 3826 | { |
| 3827 | context->drawArrays(mode, first, count, primcount); |
| 3828 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3829 | } |
| 3830 | } |
| 3831 | catch(std::bad_alloc&) |
| 3832 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3833 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3834 | } |
| 3835 | } |
| 3836 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3837 | 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] | 3838 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3839 | 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] | 3840 | mode, count, type, indices); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3841 | |
| 3842 | try |
| 3843 | { |
| 3844 | if (count < 0) |
| 3845 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3846 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3847 | } |
| 3848 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3849 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3850 | |
| 3851 | if (context) |
| 3852 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3853 | switch (type) |
| 3854 | { |
| 3855 | case GL_UNSIGNED_BYTE: |
| 3856 | case GL_UNSIGNED_SHORT: |
| 3857 | break; |
| 3858 | case GL_UNSIGNED_INT: |
| 3859 | if (!context->supports32bitIndices()) |
| 3860 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3861 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3862 | } |
| 3863 | break; |
| 3864 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3865 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3866 | } |
| 3867 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3868 | context->drawElements(mode, count, type, indices, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3869 | } |
| 3870 | } |
| 3871 | catch(std::bad_alloc&) |
| 3872 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3873 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3874 | } |
| 3875 | } |
| 3876 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3877 | void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount) |
| 3878 | { |
| 3879 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)", |
| 3880 | mode, count, type, indices, primcount); |
| 3881 | |
| 3882 | try |
| 3883 | { |
| 3884 | if (count < 0 || primcount < 0) |
| 3885 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3886 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3887 | } |
| 3888 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3889 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3890 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3891 | gl::Context *context = gl::getNonLostContext(); |
| 3892 | |
| 3893 | if (context) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3894 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3895 | switch (type) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3896 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3897 | case GL_UNSIGNED_BYTE: |
| 3898 | case GL_UNSIGNED_SHORT: |
| 3899 | break; |
| 3900 | case GL_UNSIGNED_INT: |
| 3901 | if (!context->supports32bitIndices()) |
| 3902 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3903 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3904 | } |
| 3905 | break; |
| 3906 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3907 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3908 | } |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3909 | |
| 3910 | context->drawElements(mode, count, type, indices, primcount); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3911 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3912 | } |
| 3913 | } |
| 3914 | catch(std::bad_alloc&) |
| 3915 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3916 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3917 | } |
| 3918 | } |
| 3919 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3920 | void __stdcall glEnable(GLenum cap) |
| 3921 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3922 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3923 | |
| 3924 | try |
| 3925 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3926 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3927 | |
| 3928 | if (context) |
| 3929 | { |
| 3930 | switch (cap) |
| 3931 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3932 | case GL_CULL_FACE: context->setCullFace(true); break; |
| 3933 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break; |
| 3934 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break; |
| 3935 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break; |
| 3936 | case GL_SCISSOR_TEST: context->setScissorTest(true); break; |
| 3937 | case GL_STENCIL_TEST: context->setStencilTest(true); break; |
| 3938 | case GL_DEPTH_TEST: context->setDepthTest(true); break; |
| 3939 | case GL_BLEND: context->setBlend(true); break; |
| 3940 | case GL_DITHER: context->setDither(true); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3941 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3942 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3943 | } |
| 3944 | } |
| 3945 | } |
| 3946 | catch(std::bad_alloc&) |
| 3947 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3948 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3949 | } |
| 3950 | } |
| 3951 | |
| 3952 | void __stdcall glEnableVertexAttribArray(GLuint index) |
| 3953 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3954 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3955 | |
| 3956 | try |
| 3957 | { |
| 3958 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3959 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3960 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3961 | } |
| 3962 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3963 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3964 | |
| 3965 | if (context) |
| 3966 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3967 | context->setEnableVertexAttribArray(index, true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3968 | } |
| 3969 | } |
| 3970 | catch(std::bad_alloc&) |
| 3971 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3972 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3973 | } |
| 3974 | } |
| 3975 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3976 | void __stdcall glEndQueryEXT(GLenum target) |
| 3977 | { |
| 3978 | EVENT("GLenum target = 0x%X)", target); |
| 3979 | |
| 3980 | try |
| 3981 | { |
| 3982 | switch (target) |
| 3983 | { |
| 3984 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 3985 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 3986 | break; |
| 3987 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3988 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3989 | } |
| 3990 | |
| 3991 | gl::Context *context = gl::getNonLostContext(); |
| 3992 | |
| 3993 | if (context) |
| 3994 | { |
| 3995 | context->endQuery(target); |
| 3996 | } |
| 3997 | } |
| 3998 | catch(std::bad_alloc&) |
| 3999 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4000 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4001 | } |
| 4002 | } |
| 4003 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4004 | void __stdcall glFinishFenceNV(GLuint fence) |
| 4005 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4006 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4007 | |
| 4008 | try |
| 4009 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4010 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4011 | |
| 4012 | if (context) |
| 4013 | { |
| 4014 | gl::Fence* fenceObject = context->getFence(fence); |
| 4015 | |
| 4016 | if (fenceObject == NULL) |
| 4017 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4018 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4019 | } |
| 4020 | |
| 4021 | fenceObject->finishFence(); |
| 4022 | } |
| 4023 | } |
| 4024 | catch(std::bad_alloc&) |
| 4025 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4026 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4027 | } |
| 4028 | } |
| 4029 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4030 | void __stdcall glFinish(void) |
| 4031 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4032 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4033 | |
| 4034 | try |
| 4035 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4036 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4037 | |
| 4038 | if (context) |
| 4039 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 4040 | context->sync(true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4041 | } |
| 4042 | } |
| 4043 | catch(std::bad_alloc&) |
| 4044 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4045 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4046 | } |
| 4047 | } |
| 4048 | |
| 4049 | void __stdcall glFlush(void) |
| 4050 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4051 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4052 | |
| 4053 | try |
| 4054 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4055 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4056 | |
| 4057 | if (context) |
| 4058 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 4059 | context->sync(false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4060 | } |
| 4061 | } |
| 4062 | catch(std::bad_alloc&) |
| 4063 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4064 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4065 | } |
| 4066 | } |
| 4067 | |
| 4068 | void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) |
| 4069 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4070 | 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] | 4071 | "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4072 | |
| 4073 | try |
| 4074 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4075 | 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] | 4076 | || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4077 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4078 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4079 | } |
| 4080 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4081 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4082 | |
| 4083 | if (context) |
| 4084 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4085 | gl::Framebuffer *framebuffer = NULL; |
| 4086 | GLuint framebufferHandle = 0; |
| 4087 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4088 | { |
| 4089 | framebuffer = context->getReadFramebuffer(); |
| 4090 | framebufferHandle = context->getReadFramebufferHandle(); |
| 4091 | } |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 4092 | else |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4093 | { |
| 4094 | framebuffer = context->getDrawFramebuffer(); |
| 4095 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 4096 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4097 | |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 4098 | if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4099 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4100 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4101 | } |
| 4102 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4103 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4104 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4105 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4106 | |
| 4107 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4108 | { |
| 4109 | return gl::error(GL_INVALID_VALUE); |
| 4110 | } |
| 4111 | |
| 4112 | framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer); |
| 4113 | } |
| 4114 | else |
| 4115 | { |
| 4116 | switch (attachment) |
| 4117 | { |
| 4118 | case GL_DEPTH_ATTACHMENT: |
| 4119 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer); |
| 4120 | break; |
| 4121 | case GL_STENCIL_ATTACHMENT: |
| 4122 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer); |
| 4123 | break; |
| 4124 | default: |
| 4125 | return gl::error(GL_INVALID_ENUM); |
| 4126 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4127 | } |
| 4128 | } |
| 4129 | } |
| 4130 | catch(std::bad_alloc&) |
| 4131 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4132 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4133 | } |
| 4134 | } |
| 4135 | |
| 4136 | void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) |
| 4137 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4138 | 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] | 4139 | "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4140 | |
| 4141 | try |
| 4142 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4143 | 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] | 4144 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4145 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4146 | } |
| 4147 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4148 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4149 | |
| 4150 | if (context) |
| 4151 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4152 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 4153 | { |
| 4154 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4155 | |
| 4156 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4157 | { |
| 4158 | return gl::error(GL_INVALID_VALUE); |
| 4159 | } |
| 4160 | } |
| 4161 | else |
| 4162 | { |
| 4163 | switch (attachment) |
| 4164 | { |
| 4165 | case GL_DEPTH_ATTACHMENT: |
| 4166 | case GL_STENCIL_ATTACHMENT: |
| 4167 | break; |
| 4168 | default: |
| 4169 | return gl::error(GL_INVALID_ENUM); |
| 4170 | } |
| 4171 | } |
| 4172 | |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4173 | if (texture == 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4174 | { |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4175 | textarget = GL_NONE; |
| 4176 | } |
| 4177 | else |
| 4178 | { |
| 4179 | gl::Texture *tex = context->getTexture(texture); |
| 4180 | |
| 4181 | if (tex == NULL) |
| 4182 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4183 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4184 | } |
| 4185 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4186 | switch (textarget) |
| 4187 | { |
| 4188 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4189 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4190 | if (tex->getTarget() != GL_TEXTURE_2D) |
| 4191 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4192 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4193 | } |
| 4194 | gl::Texture2D *tex2d = static_cast<gl::Texture2D *>(tex); |
daniel@transgaming.com | 92f4992 | 2012-05-09 15:49:19 +0000 | [diff] [blame] | 4195 | if (tex2d->isCompressed(0)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4196 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4197 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4198 | } |
| 4199 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4200 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4201 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4202 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4203 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4204 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4205 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4206 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4207 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4208 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4209 | if (tex->getTarget() != GL_TEXTURE_CUBE_MAP) |
| 4210 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4211 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4212 | } |
| 4213 | gl::TextureCubeMap *texcube = static_cast<gl::TextureCubeMap *>(tex); |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 4214 | if (texcube->isCompressed(textarget, level)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4215 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4216 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4217 | } |
| 4218 | break; |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4219 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4220 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4221 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4222 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4223 | } |
| 4224 | |
| 4225 | if (level != 0) |
| 4226 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4227 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4228 | } |
| 4229 | } |
| 4230 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4231 | gl::Framebuffer *framebuffer = NULL; |
| 4232 | GLuint framebufferHandle = 0; |
| 4233 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4234 | { |
| 4235 | framebuffer = context->getReadFramebuffer(); |
| 4236 | framebufferHandle = context->getReadFramebufferHandle(); |
| 4237 | } |
| 4238 | else |
| 4239 | { |
| 4240 | framebuffer = context->getDrawFramebuffer(); |
| 4241 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 4242 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4243 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4244 | if (framebufferHandle == 0 || !framebuffer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4245 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4246 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4247 | } |
| 4248 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4249 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4250 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4251 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4252 | |
| 4253 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4254 | { |
| 4255 | return gl::error(GL_INVALID_VALUE); |
| 4256 | } |
| 4257 | |
| 4258 | framebuffer->setColorbuffer(colorAttachment, textarget, texture); |
| 4259 | } |
| 4260 | else |
| 4261 | { |
| 4262 | switch (attachment) |
| 4263 | { |
| 4264 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break; |
| 4265 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break; |
| 4266 | } |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4267 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4268 | } |
| 4269 | } |
| 4270 | catch(std::bad_alloc&) |
| 4271 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4272 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4273 | } |
| 4274 | } |
| 4275 | |
| 4276 | void __stdcall glFrontFace(GLenum mode) |
| 4277 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4278 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4279 | |
| 4280 | try |
| 4281 | { |
| 4282 | switch (mode) |
| 4283 | { |
| 4284 | case GL_CW: |
| 4285 | case GL_CCW: |
| 4286 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4287 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4288 | |
| 4289 | if (context) |
| 4290 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4291 | context->setFrontFace(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4292 | } |
| 4293 | } |
| 4294 | break; |
| 4295 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4296 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4297 | } |
| 4298 | } |
| 4299 | catch(std::bad_alloc&) |
| 4300 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4301 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4302 | } |
| 4303 | } |
| 4304 | |
| 4305 | void __stdcall glGenBuffers(GLsizei n, GLuint* buffers) |
| 4306 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4307 | EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4308 | |
| 4309 | try |
| 4310 | { |
| 4311 | if (n < 0) |
| 4312 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4313 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4314 | } |
| 4315 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4316 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4317 | |
| 4318 | if (context) |
| 4319 | { |
| 4320 | for (int i = 0; i < n; i++) |
| 4321 | { |
| 4322 | buffers[i] = context->createBuffer(); |
| 4323 | } |
| 4324 | } |
| 4325 | } |
| 4326 | catch(std::bad_alloc&) |
| 4327 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4328 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4329 | } |
| 4330 | } |
| 4331 | |
| 4332 | void __stdcall glGenerateMipmap(GLenum target) |
| 4333 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4334 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4335 | |
| 4336 | try |
| 4337 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4338 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4339 | |
| 4340 | if (context) |
| 4341 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4342 | gl::Texture *texture = NULL; |
| 4343 | GLint internalFormat = GL_NONE; |
| 4344 | bool isCompressed = false; |
| 4345 | bool isDepth = false; |
| 4346 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4347 | switch (target) |
| 4348 | { |
| 4349 | case GL_TEXTURE_2D: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4350 | { |
| 4351 | gl::Texture2D *tex2d = context->getTexture2D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4352 | if (tex2d) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4353 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4354 | internalFormat = tex2d->getInternalFormat(0); |
| 4355 | isCompressed = tex2d->isCompressed(0); |
| 4356 | isDepth = tex2d->isDepth(0); |
| 4357 | texture = tex2d; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4358 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4359 | break; |
| 4360 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4361 | |
| 4362 | case GL_TEXTURE_CUBE_MAP: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4363 | { |
| 4364 | gl::TextureCubeMap *texcube = context->getTextureCubeMap(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4365 | if (texcube) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4366 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4367 | internalFormat = texcube->getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 4368 | isCompressed = texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 4369 | isDepth = false; |
| 4370 | texture = texcube; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4371 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4372 | break; |
| 4373 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4374 | |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4375 | case GL_TEXTURE_3D: |
| 4376 | { |
| 4377 | if (context->getClientVersion() < 3) |
| 4378 | { |
| 4379 | return gl::error(GL_INVALID_ENUM); |
| 4380 | } |
| 4381 | |
| 4382 | gl::Texture3D *tex3D = context->getTexture3D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4383 | if (tex3D) |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4384 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4385 | internalFormat = tex3D->getInternalFormat(0); |
| 4386 | isCompressed = tex3D->isCompressed(0); |
| 4387 | isDepth = tex3D->isDepth(0); |
| 4388 | texture = tex3D; |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4389 | } |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4390 | break; |
| 4391 | } |
| 4392 | |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4393 | case GL_TEXTURE_2D_ARRAY: |
| 4394 | { |
| 4395 | if (context->getClientVersion() < 3) |
| 4396 | { |
| 4397 | return gl::error(GL_INVALID_ENUM); |
| 4398 | } |
| 4399 | |
| 4400 | gl::Texture2DArray *tex2darr = context->getTexture2DArray(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4401 | if (tex2darr) |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4402 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4403 | internalFormat = tex2darr->getInternalFormat(0); |
| 4404 | isCompressed = tex2darr->isCompressed(0); |
| 4405 | isDepth = tex2darr->isDepth(0); |
| 4406 | texture = tex2darr; |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4407 | } |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4408 | break; |
| 4409 | } |
| 4410 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4411 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4412 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4413 | } |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4414 | |
| 4415 | if (!texture) |
| 4416 | { |
| 4417 | return gl::error(GL_INVALID_OPERATION); |
| 4418 | } |
| 4419 | |
| 4420 | // Internally, all texture formats are sized so checking if the format |
| 4421 | // is color renderable and filterable will not fail. |
| 4422 | if (isDepth || isCompressed || |
| 4423 | !gl::IsColorRenderingSupported(internalFormat, context) || |
| 4424 | !gl::IsTextureFilteringSupported(internalFormat, context)) |
| 4425 | { |
| 4426 | return gl::error(GL_INVALID_OPERATION); |
| 4427 | } |
| 4428 | |
| 4429 | texture->generateMipmaps(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4430 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4431 | } |
| 4432 | catch(std::bad_alloc&) |
| 4433 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4434 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4435 | } |
| 4436 | } |
| 4437 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4438 | void __stdcall glGenFencesNV(GLsizei n, GLuint* fences) |
| 4439 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4440 | EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4441 | |
| 4442 | try |
| 4443 | { |
| 4444 | if (n < 0) |
| 4445 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4446 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4447 | } |
| 4448 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4449 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4450 | |
| 4451 | if (context) |
| 4452 | { |
| 4453 | for (int i = 0; i < n; i++) |
| 4454 | { |
| 4455 | fences[i] = context->createFence(); |
| 4456 | } |
| 4457 | } |
| 4458 | } |
| 4459 | catch(std::bad_alloc&) |
| 4460 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4461 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4462 | } |
| 4463 | } |
| 4464 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4465 | void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers) |
| 4466 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4467 | EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4468 | |
| 4469 | try |
| 4470 | { |
| 4471 | if (n < 0) |
| 4472 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4473 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4474 | } |
| 4475 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4476 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4477 | |
| 4478 | if (context) |
| 4479 | { |
| 4480 | for (int i = 0; i < n; i++) |
| 4481 | { |
| 4482 | framebuffers[i] = context->createFramebuffer(); |
| 4483 | } |
| 4484 | } |
| 4485 | } |
| 4486 | catch(std::bad_alloc&) |
| 4487 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4488 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4489 | } |
| 4490 | } |
| 4491 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4492 | void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids) |
| 4493 | { |
| 4494 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 4495 | |
| 4496 | try |
| 4497 | { |
| 4498 | if (n < 0) |
| 4499 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4500 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4501 | } |
| 4502 | |
| 4503 | gl::Context *context = gl::getNonLostContext(); |
| 4504 | |
| 4505 | if (context) |
| 4506 | { |
| 4507 | for (int i = 0; i < n; i++) |
| 4508 | { |
| 4509 | ids[i] = context->createQuery(); |
| 4510 | } |
| 4511 | } |
| 4512 | } |
| 4513 | catch(std::bad_alloc&) |
| 4514 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4515 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4516 | } |
| 4517 | } |
| 4518 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4519 | void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) |
| 4520 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4521 | EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4522 | |
| 4523 | try |
| 4524 | { |
| 4525 | if (n < 0) |
| 4526 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4527 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4528 | } |
| 4529 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4530 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4531 | |
| 4532 | if (context) |
| 4533 | { |
| 4534 | for (int i = 0; i < n; i++) |
| 4535 | { |
| 4536 | renderbuffers[i] = context->createRenderbuffer(); |
| 4537 | } |
| 4538 | } |
| 4539 | } |
| 4540 | catch(std::bad_alloc&) |
| 4541 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4542 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4543 | } |
| 4544 | } |
| 4545 | |
| 4546 | void __stdcall glGenTextures(GLsizei n, GLuint* textures) |
| 4547 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4548 | EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4549 | |
| 4550 | try |
| 4551 | { |
| 4552 | if (n < 0) |
| 4553 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4554 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4555 | } |
| 4556 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4557 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4558 | |
| 4559 | if (context) |
| 4560 | { |
| 4561 | for (int i = 0; i < n; i++) |
| 4562 | { |
| 4563 | textures[i] = context->createTexture(); |
| 4564 | } |
| 4565 | } |
| 4566 | } |
| 4567 | catch(std::bad_alloc&) |
| 4568 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4569 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4570 | } |
| 4571 | } |
| 4572 | |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4573 | 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] | 4574 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4575 | 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] | 4576 | "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] | 4577 | program, index, bufsize, length, size, type, name); |
| 4578 | |
| 4579 | try |
| 4580 | { |
| 4581 | if (bufsize < 0) |
| 4582 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4583 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4584 | } |
| 4585 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4586 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4587 | |
| 4588 | if (context) |
| 4589 | { |
| 4590 | gl::Program *programObject = context->getProgram(program); |
| 4591 | |
| 4592 | if (!programObject) |
| 4593 | { |
| 4594 | if (context->getShader(program)) |
| 4595 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4596 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4597 | } |
| 4598 | else |
| 4599 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4600 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4601 | } |
| 4602 | } |
| 4603 | |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4604 | if (index >= (GLuint)programObject->getActiveAttributeCount()) |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4605 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4606 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4607 | } |
| 4608 | |
| 4609 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 4610 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4611 | } |
| 4612 | catch(std::bad_alloc&) |
| 4613 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4614 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4615 | } |
| 4616 | } |
| 4617 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4618 | 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] | 4619 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4620 | EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4621 | "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] | 4622 | program, index, bufsize, length, size, type, name); |
| 4623 | |
| 4624 | try |
| 4625 | { |
| 4626 | if (bufsize < 0) |
| 4627 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4628 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4629 | } |
| 4630 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4631 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4632 | |
| 4633 | if (context) |
| 4634 | { |
| 4635 | gl::Program *programObject = context->getProgram(program); |
| 4636 | |
| 4637 | if (!programObject) |
| 4638 | { |
| 4639 | if (context->getShader(program)) |
| 4640 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4641 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4642 | } |
| 4643 | else |
| 4644 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4645 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4646 | } |
| 4647 | } |
| 4648 | |
| 4649 | if (index >= (GLuint)programObject->getActiveUniformCount()) |
| 4650 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4651 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4652 | } |
| 4653 | |
| 4654 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 4655 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4656 | } |
| 4657 | catch(std::bad_alloc&) |
| 4658 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4659 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4660 | } |
| 4661 | } |
| 4662 | |
| 4663 | void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) |
| 4664 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4665 | 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] | 4666 | program, maxcount, count, shaders); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4667 | |
| 4668 | try |
| 4669 | { |
| 4670 | if (maxcount < 0) |
| 4671 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4672 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4673 | } |
| 4674 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4675 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4676 | |
| 4677 | if (context) |
| 4678 | { |
| 4679 | gl::Program *programObject = context->getProgram(program); |
| 4680 | |
| 4681 | if (!programObject) |
| 4682 | { |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4683 | if (context->getShader(program)) |
| 4684 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4685 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4686 | } |
| 4687 | else |
| 4688 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4689 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4690 | } |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4691 | } |
| 4692 | |
| 4693 | return programObject->getAttachedShaders(maxcount, count, shaders); |
| 4694 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4695 | } |
| 4696 | catch(std::bad_alloc&) |
| 4697 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4698 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4699 | } |
| 4700 | } |
| 4701 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4702 | int __stdcall glGetAttribLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4703 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4704 | EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4705 | |
| 4706 | try |
| 4707 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4708 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4709 | |
| 4710 | if (context) |
| 4711 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4712 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4713 | gl::Program *programObject = context->getProgram(program); |
| 4714 | |
| 4715 | if (!programObject) |
| 4716 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4717 | if (context->getShader(program)) |
| 4718 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4719 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4720 | } |
| 4721 | else |
| 4722 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4723 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4724 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4725 | } |
| 4726 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4727 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 4728 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4729 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4730 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4731 | } |
| 4732 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4733 | return programBinary->getAttributeLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4734 | } |
| 4735 | } |
| 4736 | catch(std::bad_alloc&) |
| 4737 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4738 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4739 | } |
| 4740 | |
| 4741 | return -1; |
| 4742 | } |
| 4743 | |
| 4744 | void __stdcall glGetBooleanv(GLenum pname, GLboolean* params) |
| 4745 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4746 | 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] | 4747 | |
| 4748 | try |
| 4749 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4750 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4751 | |
| 4752 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4753 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4754 | if (!(context->getBooleanv(pname, params))) |
| 4755 | { |
| 4756 | GLenum nativeType; |
| 4757 | unsigned int numParams = 0; |
| 4758 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4759 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4760 | |
| 4761 | if (numParams == 0) |
| 4762 | return; // it is known that the pname is valid, but there are no parameters to return |
| 4763 | |
| 4764 | if (nativeType == GL_FLOAT) |
| 4765 | { |
| 4766 | GLfloat *floatParams = NULL; |
| 4767 | floatParams = new GLfloat[numParams]; |
| 4768 | |
| 4769 | context->getFloatv(pname, floatParams); |
| 4770 | |
| 4771 | for (unsigned int i = 0; i < numParams; ++i) |
| 4772 | { |
| 4773 | if (floatParams[i] == 0.0f) |
| 4774 | params[i] = GL_FALSE; |
| 4775 | else |
| 4776 | params[i] = GL_TRUE; |
| 4777 | } |
| 4778 | |
| 4779 | delete [] floatParams; |
| 4780 | } |
| 4781 | else if (nativeType == GL_INT) |
| 4782 | { |
| 4783 | GLint *intParams = NULL; |
| 4784 | intParams = new GLint[numParams]; |
| 4785 | |
| 4786 | context->getIntegerv(pname, intParams); |
| 4787 | |
| 4788 | for (unsigned int i = 0; i < numParams; ++i) |
| 4789 | { |
| 4790 | if (intParams[i] == 0) |
| 4791 | params[i] = GL_FALSE; |
| 4792 | else |
| 4793 | params[i] = GL_TRUE; |
| 4794 | } |
| 4795 | |
| 4796 | delete [] intParams; |
| 4797 | } |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 4798 | else if (nativeType == GL_INT_64_ANGLEX) |
| 4799 | { |
| 4800 | GLint64 *int64Params = NULL; |
| 4801 | int64Params = new GLint64[numParams]; |
| 4802 | |
| 4803 | context->getInteger64v(pname, int64Params); |
| 4804 | |
| 4805 | for (unsigned int i = 0; i < numParams; ++i) |
| 4806 | { |
| 4807 | if (int64Params[i] == 0) |
| 4808 | params[i] = GL_FALSE; |
| 4809 | else |
| 4810 | params[i] = GL_TRUE; |
| 4811 | } |
| 4812 | |
| 4813 | delete [] int64Params; |
| 4814 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4815 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4816 | } |
| 4817 | } |
| 4818 | catch(std::bad_alloc&) |
| 4819 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4820 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4821 | } |
| 4822 | } |
| 4823 | |
| 4824 | void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 4825 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4826 | 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] | 4827 | |
| 4828 | try |
| 4829 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4830 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4831 | |
| 4832 | if (context) |
| 4833 | { |
| 4834 | gl::Buffer *buffer; |
| 4835 | |
| 4836 | switch (target) |
| 4837 | { |
| 4838 | case GL_ARRAY_BUFFER: |
| 4839 | buffer = context->getArrayBuffer(); |
| 4840 | break; |
| 4841 | case GL_ELEMENT_ARRAY_BUFFER: |
| 4842 | buffer = context->getElementArrayBuffer(); |
| 4843 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4844 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4845 | } |
| 4846 | |
| 4847 | if (!buffer) |
| 4848 | { |
| 4849 | // 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] | 4850 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4851 | } |
| 4852 | |
| 4853 | switch (pname) |
| 4854 | { |
| 4855 | case GL_BUFFER_USAGE: |
| 4856 | *params = buffer->usage(); |
| 4857 | break; |
| 4858 | case GL_BUFFER_SIZE: |
| 4859 | *params = buffer->size(); |
| 4860 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4861 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4862 | } |
| 4863 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4864 | } |
| 4865 | catch(std::bad_alloc&) |
| 4866 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4867 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4868 | } |
| 4869 | } |
| 4870 | |
| 4871 | GLenum __stdcall glGetError(void) |
| 4872 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4873 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4874 | |
| 4875 | gl::Context *context = gl::getContext(); |
| 4876 | |
| 4877 | if (context) |
| 4878 | { |
daniel@transgaming.com | 82b2891 | 2011-12-12 21:01:35 +0000 | [diff] [blame] | 4879 | return context->getError(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4880 | } |
| 4881 | |
| 4882 | return GL_NO_ERROR; |
| 4883 | } |
| 4884 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4885 | void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 4886 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4887 | 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] | 4888 | |
| 4889 | try |
| 4890 | { |
| 4891 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4892 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4893 | |
| 4894 | if (context) |
| 4895 | { |
| 4896 | gl::Fence *fenceObject = context->getFence(fence); |
| 4897 | |
| 4898 | if (fenceObject == NULL) |
| 4899 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4900 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4901 | } |
| 4902 | |
| 4903 | fenceObject->getFenceiv(pname, params); |
| 4904 | } |
| 4905 | } |
| 4906 | catch(std::bad_alloc&) |
| 4907 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4908 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4909 | } |
| 4910 | } |
| 4911 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4912 | void __stdcall glGetFloatv(GLenum pname, GLfloat* params) |
| 4913 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4914 | 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] | 4915 | |
| 4916 | try |
| 4917 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4918 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4919 | |
| 4920 | if (context) |
| 4921 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4922 | if (!(context->getFloatv(pname, params))) |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4923 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4924 | GLenum nativeType; |
| 4925 | unsigned int numParams = 0; |
| 4926 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4927 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4928 | |
| 4929 | if (numParams == 0) |
| 4930 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 4931 | |
| 4932 | if (nativeType == GL_BOOL) |
| 4933 | { |
| 4934 | GLboolean *boolParams = NULL; |
| 4935 | boolParams = new GLboolean[numParams]; |
| 4936 | |
| 4937 | context->getBooleanv(pname, boolParams); |
| 4938 | |
| 4939 | for (unsigned int i = 0; i < numParams; ++i) |
| 4940 | { |
| 4941 | if (boolParams[i] == GL_FALSE) |
| 4942 | params[i] = 0.0f; |
| 4943 | else |
| 4944 | params[i] = 1.0f; |
| 4945 | } |
| 4946 | |
| 4947 | delete [] boolParams; |
| 4948 | } |
| 4949 | else if (nativeType == GL_INT) |
| 4950 | { |
| 4951 | GLint *intParams = NULL; |
| 4952 | intParams = new GLint[numParams]; |
| 4953 | |
| 4954 | context->getIntegerv(pname, intParams); |
| 4955 | |
| 4956 | for (unsigned int i = 0; i < numParams; ++i) |
| 4957 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 4958 | params[i] = static_cast<GLfloat>(intParams[i]); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4959 | } |
| 4960 | |
| 4961 | delete [] intParams; |
| 4962 | } |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 4963 | else if (nativeType == GL_INT_64_ANGLEX) |
| 4964 | { |
| 4965 | GLint64 *int64Params = NULL; |
| 4966 | int64Params = new GLint64[numParams]; |
| 4967 | |
| 4968 | context->getInteger64v(pname, int64Params); |
| 4969 | |
| 4970 | for (unsigned int i = 0; i < numParams; ++i) |
| 4971 | { |
| 4972 | params[i] = static_cast<GLfloat>(int64Params[i]); |
| 4973 | } |
| 4974 | |
| 4975 | delete [] int64Params; |
| 4976 | } |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4977 | } |
| 4978 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4979 | } |
| 4980 | catch(std::bad_alloc&) |
| 4981 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4982 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4983 | } |
| 4984 | } |
| 4985 | |
| 4986 | void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) |
| 4987 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4988 | 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] | 4989 | target, attachment, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4990 | |
| 4991 | try |
| 4992 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4993 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4994 | |
| 4995 | if (context) |
| 4996 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4997 | 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] | 4998 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4999 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5000 | } |
| 5001 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 5002 | gl::Framebuffer *framebuffer = NULL; |
| 5003 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 5004 | { |
| 5005 | if(context->getReadFramebufferHandle() == 0) |
| 5006 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5007 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 5008 | } |
| 5009 | |
| 5010 | framebuffer = context->getReadFramebuffer(); |
| 5011 | } |
| 5012 | else |
| 5013 | { |
| 5014 | if (context->getDrawFramebufferHandle() == 0) |
| 5015 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5016 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 5017 | } |
| 5018 | |
| 5019 | framebuffer = context->getDrawFramebuffer(); |
| 5020 | } |
| 5021 | |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5022 | GLenum attachmentType; |
| 5023 | GLuint attachmentHandle; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 5024 | |
| 5025 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5026 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 5027 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 5028 | |
| 5029 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 5030 | { |
| 5031 | return gl::error(GL_INVALID_ENUM); |
| 5032 | } |
| 5033 | |
| 5034 | attachmentType = framebuffer->getColorbufferType(colorAttachment); |
| 5035 | attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment); |
| 5036 | } |
| 5037 | else |
| 5038 | { |
| 5039 | switch (attachment) |
| 5040 | { |
| 5041 | case GL_DEPTH_ATTACHMENT: |
| 5042 | attachmentType = framebuffer->getDepthbufferType(); |
| 5043 | attachmentHandle = framebuffer->getDepthbufferHandle(); |
| 5044 | break; |
| 5045 | case GL_STENCIL_ATTACHMENT: |
| 5046 | attachmentType = framebuffer->getStencilbufferType(); |
| 5047 | attachmentHandle = framebuffer->getStencilbufferHandle(); |
| 5048 | break; |
| 5049 | default: return gl::error(GL_INVALID_ENUM); |
| 5050 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5051 | } |
| 5052 | |
| 5053 | GLenum attachmentObjectType; // Type category |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 5054 | if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5055 | { |
| 5056 | attachmentObjectType = attachmentType; |
| 5057 | } |
apatrick@chromium.org | 551022e | 2012-01-23 19:56:54 +0000 | [diff] [blame] | 5058 | else if (gl::IsInternalTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5059 | { |
| 5060 | attachmentObjectType = GL_TEXTURE; |
| 5061 | } |
apatrick@chromium.org | a1d8059 | 2012-01-25 21:52:10 +0000 | [diff] [blame] | 5062 | else |
| 5063 | { |
| 5064 | UNREACHABLE(); |
| 5065 | return; |
| 5066 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5067 | |
| 5068 | switch (pname) |
| 5069 | { |
| 5070 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 5071 | *params = attachmentObjectType; |
| 5072 | break; |
| 5073 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 5074 | if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE) |
| 5075 | { |
| 5076 | *params = attachmentHandle; |
| 5077 | } |
| 5078 | else |
| 5079 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5080 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5081 | } |
| 5082 | break; |
| 5083 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 5084 | if (attachmentObjectType == GL_TEXTURE) |
| 5085 | { |
| 5086 | *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0 |
| 5087 | } |
| 5088 | else |
| 5089 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5090 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5091 | } |
| 5092 | break; |
| 5093 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 5094 | if (attachmentObjectType == GL_TEXTURE) |
| 5095 | { |
daniel@transgaming.com | 19ffc24 | 2010-05-04 03:35:21 +0000 | [diff] [blame] | 5096 | if (gl::IsCubemapTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5097 | { |
| 5098 | *params = attachmentType; |
| 5099 | } |
| 5100 | else |
| 5101 | { |
| 5102 | *params = 0; |
| 5103 | } |
| 5104 | } |
| 5105 | else |
| 5106 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5107 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5108 | } |
| 5109 | break; |
| 5110 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5111 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5112 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5113 | } |
| 5114 | } |
| 5115 | catch(std::bad_alloc&) |
| 5116 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5117 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5118 | } |
| 5119 | } |
| 5120 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 5121 | GLenum __stdcall glGetGraphicsResetStatusEXT(void) |
| 5122 | { |
| 5123 | EVENT("()"); |
| 5124 | |
| 5125 | try |
| 5126 | { |
| 5127 | gl::Context *context = gl::getContext(); |
| 5128 | |
| 5129 | if (context) |
| 5130 | { |
| 5131 | return context->getResetStatus(); |
| 5132 | } |
| 5133 | |
| 5134 | return GL_NO_ERROR; |
| 5135 | } |
| 5136 | catch(std::bad_alloc&) |
| 5137 | { |
| 5138 | return GL_OUT_OF_MEMORY; |
| 5139 | } |
| 5140 | } |
| 5141 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5142 | void __stdcall glGetIntegerv(GLenum pname, GLint* params) |
| 5143 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5144 | 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] | 5145 | |
| 5146 | try |
| 5147 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5148 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5149 | |
| 5150 | if (context) |
| 5151 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5152 | if (!(context->getIntegerv(pname, params))) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5153 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5154 | GLenum nativeType; |
| 5155 | unsigned int numParams = 0; |
| 5156 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5157 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5158 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5159 | if (numParams == 0) |
| 5160 | return; // it is known that pname is valid, but there are no parameters to return |
| 5161 | |
| 5162 | if (nativeType == GL_BOOL) |
| 5163 | { |
| 5164 | GLboolean *boolParams = NULL; |
| 5165 | boolParams = new GLboolean[numParams]; |
| 5166 | |
| 5167 | context->getBooleanv(pname, boolParams); |
| 5168 | |
| 5169 | for (unsigned int i = 0; i < numParams; ++i) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5170 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5171 | if (boolParams[i] == GL_FALSE) |
| 5172 | params[i] = 0; |
| 5173 | else |
| 5174 | params[i] = 1; |
| 5175 | } |
| 5176 | |
| 5177 | delete [] boolParams; |
| 5178 | } |
| 5179 | else if (nativeType == GL_FLOAT) |
| 5180 | { |
| 5181 | GLfloat *floatParams = NULL; |
| 5182 | floatParams = new GLfloat[numParams]; |
| 5183 | |
| 5184 | context->getFloatv(pname, floatParams); |
| 5185 | |
| 5186 | for (unsigned int i = 0; i < numParams; ++i) |
| 5187 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5188 | // RGBA color values and DepthRangeF values are converted to integer using Equation 2.4 from Table 4.5 |
daniel@transgaming.com | c164135 | 2010-04-26 15:33:36 +0000 | [diff] [blame] | 5189 | 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] | 5190 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5191 | params[i] = static_cast<GLint>((static_cast<GLfloat>(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5192 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5193 | else |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5194 | { |
Jamie Madill | af49691 | 2013-07-19 16:36:54 -0400 | [diff] [blame] | 5195 | params[i] = gl::iround<GLint>(floatParams[i]); |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5196 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5197 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5198 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5199 | delete [] floatParams; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5200 | } |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5201 | else if (nativeType == GL_INT_64_ANGLEX) |
| 5202 | { |
| 5203 | GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min()); |
| 5204 | GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max()); |
| 5205 | GLint64 *int64Params = NULL; |
| 5206 | int64Params = new GLint64[numParams]; |
| 5207 | |
| 5208 | context->getInteger64v(pname, int64Params); |
| 5209 | |
| 5210 | for (unsigned int i = 0; i < numParams; ++i) |
| 5211 | { |
| 5212 | GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue); |
| 5213 | params[i] = static_cast<GLint>(clampedValue); |
| 5214 | } |
| 5215 | |
| 5216 | delete [] int64Params; |
| 5217 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5218 | } |
| 5219 | } |
| 5220 | } |
| 5221 | catch(std::bad_alloc&) |
| 5222 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5223 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5224 | } |
| 5225 | } |
| 5226 | |
| 5227 | void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params) |
| 5228 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5229 | 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] | 5230 | |
| 5231 | try |
| 5232 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5233 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5234 | |
| 5235 | if (context) |
| 5236 | { |
| 5237 | gl::Program *programObject = context->getProgram(program); |
| 5238 | |
| 5239 | if (!programObject) |
| 5240 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5241 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5242 | } |
| 5243 | |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 5244 | if (context->getClientVersion() < 3) |
| 5245 | { |
| 5246 | switch (pname) |
| 5247 | { |
| 5248 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 5249 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 5250 | return gl::error(GL_INVALID_ENUM); |
| 5251 | } |
| 5252 | } |
| 5253 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5254 | switch (pname) |
| 5255 | { |
| 5256 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5257 | *params = programObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5258 | return; |
| 5259 | case GL_LINK_STATUS: |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5260 | *params = programObject->isLinked(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5261 | return; |
| 5262 | case GL_VALIDATE_STATUS: |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 5263 | *params = programObject->isValidated(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5264 | return; |
| 5265 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5266 | *params = programObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5267 | return; |
| 5268 | case GL_ATTACHED_SHADERS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5269 | *params = programObject->getAttachedShadersCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5270 | return; |
| 5271 | case GL_ACTIVE_ATTRIBUTES: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 5272 | *params = programObject->getActiveAttributeCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5273 | return; |
| 5274 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 5275 | *params = programObject->getActiveAttributeMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5276 | return; |
| 5277 | case GL_ACTIVE_UNIFORMS: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 5278 | *params = programObject->getActiveUniformCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5279 | return; |
| 5280 | case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 5281 | *params = programObject->getActiveUniformMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5282 | return; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 5283 | case GL_PROGRAM_BINARY_LENGTH_OES: |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 5284 | *params = programObject->getProgramBinaryLength(); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 5285 | return; |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 5286 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 5287 | *params = programObject->getActiveUniformBlockCount(); |
| 5288 | return; |
| 5289 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 5290 | *params = programObject->getActiveUniformBlockMaxLength(); |
| 5291 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5292 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5293 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5294 | } |
| 5295 | } |
| 5296 | } |
| 5297 | catch(std::bad_alloc&) |
| 5298 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5299 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5300 | } |
| 5301 | } |
| 5302 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5303 | void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5304 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5305 | 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] | 5306 | program, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5307 | |
| 5308 | try |
| 5309 | { |
| 5310 | if (bufsize < 0) |
| 5311 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5312 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5313 | } |
| 5314 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5315 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5316 | |
| 5317 | if (context) |
| 5318 | { |
| 5319 | gl::Program *programObject = context->getProgram(program); |
| 5320 | |
| 5321 | if (!programObject) |
| 5322 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5323 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5324 | } |
| 5325 | |
| 5326 | programObject->getInfoLog(bufsize, length, infolog); |
| 5327 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5328 | } |
| 5329 | catch(std::bad_alloc&) |
| 5330 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5331 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5332 | } |
| 5333 | } |
| 5334 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5335 | void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params) |
| 5336 | { |
| 5337 | EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params); |
| 5338 | |
| 5339 | try |
| 5340 | { |
| 5341 | switch (pname) |
| 5342 | { |
| 5343 | case GL_CURRENT_QUERY_EXT: |
| 5344 | break; |
| 5345 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5346 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5347 | } |
| 5348 | |
| 5349 | gl::Context *context = gl::getNonLostContext(); |
| 5350 | |
| 5351 | if (context) |
| 5352 | { |
| 5353 | params[0] = context->getActiveQuery(target); |
| 5354 | } |
| 5355 | } |
| 5356 | catch(std::bad_alloc&) |
| 5357 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5358 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5359 | } |
| 5360 | } |
| 5361 | |
| 5362 | void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) |
| 5363 | { |
| 5364 | EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params); |
| 5365 | |
| 5366 | try |
| 5367 | { |
| 5368 | switch (pname) |
| 5369 | { |
| 5370 | case GL_QUERY_RESULT_EXT: |
| 5371 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5372 | break; |
| 5373 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5374 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5375 | } |
| 5376 | gl::Context *context = gl::getNonLostContext(); |
| 5377 | |
| 5378 | if (context) |
| 5379 | { |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5380 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 5381 | |
| 5382 | if (!queryObject) |
| 5383 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5384 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5385 | } |
| 5386 | |
| 5387 | if (context->getActiveQuery(queryObject->getType()) == id) |
| 5388 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5389 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5390 | } |
| 5391 | |
| 5392 | switch(pname) |
| 5393 | { |
| 5394 | case GL_QUERY_RESULT_EXT: |
| 5395 | params[0] = queryObject->getResult(); |
| 5396 | break; |
| 5397 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5398 | params[0] = queryObject->isResultAvailable(); |
| 5399 | break; |
| 5400 | default: |
| 5401 | ASSERT(false); |
| 5402 | } |
| 5403 | } |
| 5404 | } |
| 5405 | catch(std::bad_alloc&) |
| 5406 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5407 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5408 | } |
| 5409 | } |
| 5410 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5411 | void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5412 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5413 | 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] | 5414 | |
| 5415 | try |
| 5416 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5417 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5418 | |
| 5419 | if (context) |
| 5420 | { |
| 5421 | if (target != GL_RENDERBUFFER) |
| 5422 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5423 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5424 | } |
| 5425 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5426 | if (context->getRenderbufferHandle() == 0) |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5427 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5428 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5429 | } |
| 5430 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5431 | gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle()); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5432 | |
| 5433 | switch (pname) |
| 5434 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5435 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break; |
| 5436 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break; |
| 5437 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break; |
| 5438 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break; |
| 5439 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break; |
| 5440 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break; |
| 5441 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break; |
| 5442 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break; |
| 5443 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break; |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5444 | case GL_RENDERBUFFER_SAMPLES_ANGLE: |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5445 | if (context->getMaxSupportedSamples() != 0) |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5446 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5447 | *params = renderbuffer->getSamples(); |
| 5448 | } |
| 5449 | else |
| 5450 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5451 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5452 | } |
| 5453 | break; |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5454 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5455 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5456 | } |
| 5457 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5458 | } |
| 5459 | catch(std::bad_alloc&) |
| 5460 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5461 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5462 | } |
| 5463 | } |
| 5464 | |
| 5465 | void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params) |
| 5466 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5467 | 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] | 5468 | |
| 5469 | try |
| 5470 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5471 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5472 | |
| 5473 | if (context) |
| 5474 | { |
| 5475 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 5476 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5477 | if (!shaderObject) |
| 5478 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5479 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5480 | } |
| 5481 | |
| 5482 | switch (pname) |
| 5483 | { |
| 5484 | case GL_SHADER_TYPE: |
| 5485 | *params = shaderObject->getType(); |
| 5486 | return; |
| 5487 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5488 | *params = shaderObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5489 | return; |
| 5490 | case GL_COMPILE_STATUS: |
| 5491 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; |
| 5492 | return; |
| 5493 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5494 | *params = shaderObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5495 | return; |
| 5496 | case GL_SHADER_SOURCE_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5497 | *params = shaderObject->getSourceLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5498 | return; |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5499 | case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: |
| 5500 | *params = shaderObject->getTranslatedSourceLength(); |
| 5501 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5502 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5503 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5504 | } |
| 5505 | } |
| 5506 | } |
| 5507 | catch(std::bad_alloc&) |
| 5508 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5509 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5510 | } |
| 5511 | } |
| 5512 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5513 | void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5514 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5515 | 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] | 5516 | shader, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5517 | |
| 5518 | try |
| 5519 | { |
| 5520 | if (bufsize < 0) |
| 5521 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5522 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5523 | } |
| 5524 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5525 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5526 | |
| 5527 | if (context) |
| 5528 | { |
| 5529 | gl::Shader *shaderObject = context->getShader(shader); |
| 5530 | |
| 5531 | if (!shaderObject) |
| 5532 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5533 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5534 | } |
| 5535 | |
| 5536 | shaderObject->getInfoLog(bufsize, length, infolog); |
| 5537 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5538 | } |
| 5539 | catch(std::bad_alloc&) |
| 5540 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5541 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5542 | } |
| 5543 | } |
| 5544 | |
| 5545 | void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) |
| 5546 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5547 | 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] | 5548 | shadertype, precisiontype, range, precision); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5549 | |
| 5550 | try |
| 5551 | { |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5552 | switch (shadertype) |
| 5553 | { |
| 5554 | case GL_VERTEX_SHADER: |
| 5555 | case GL_FRAGMENT_SHADER: |
| 5556 | break; |
| 5557 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5558 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5559 | } |
| 5560 | |
| 5561 | switch (precisiontype) |
| 5562 | { |
| 5563 | case GL_LOW_FLOAT: |
| 5564 | case GL_MEDIUM_FLOAT: |
| 5565 | case GL_HIGH_FLOAT: |
| 5566 | // Assume IEEE 754 precision |
| 5567 | range[0] = 127; |
| 5568 | range[1] = 127; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5569 | *precision = 23; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5570 | break; |
| 5571 | case GL_LOW_INT: |
| 5572 | case GL_MEDIUM_INT: |
| 5573 | case GL_HIGH_INT: |
| 5574 | // Some (most) hardware only supports single-precision floating-point numbers, |
| 5575 | // which can accurately represent integers up to +/-16777216 |
| 5576 | range[0] = 24; |
| 5577 | range[1] = 24; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5578 | *precision = 0; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5579 | break; |
| 5580 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5581 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5582 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5583 | } |
| 5584 | catch(std::bad_alloc&) |
| 5585 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5586 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5587 | } |
| 5588 | } |
| 5589 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5590 | void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5591 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5592 | 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] | 5593 | shader, bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5594 | |
| 5595 | try |
| 5596 | { |
| 5597 | if (bufsize < 0) |
| 5598 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5599 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5600 | } |
| 5601 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5602 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5603 | |
| 5604 | if (context) |
| 5605 | { |
| 5606 | gl::Shader *shaderObject = context->getShader(shader); |
| 5607 | |
| 5608 | if (!shaderObject) |
| 5609 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5610 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5611 | } |
| 5612 | |
| 5613 | shaderObject->getSource(bufsize, length, source); |
| 5614 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5615 | } |
| 5616 | catch(std::bad_alloc&) |
| 5617 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5618 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5619 | } |
| 5620 | } |
| 5621 | |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5622 | void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
| 5623 | { |
| 5624 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)", |
| 5625 | shader, bufsize, length, source); |
| 5626 | |
| 5627 | try |
| 5628 | { |
| 5629 | if (bufsize < 0) |
| 5630 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5631 | return gl::error(GL_INVALID_VALUE); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5632 | } |
| 5633 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5634 | gl::Context *context = gl::getNonLostContext(); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5635 | |
| 5636 | if (context) |
| 5637 | { |
| 5638 | gl::Shader *shaderObject = context->getShader(shader); |
| 5639 | |
| 5640 | if (!shaderObject) |
| 5641 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5642 | return gl::error(GL_INVALID_OPERATION); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5643 | } |
| 5644 | |
| 5645 | shaderObject->getTranslatedSource(bufsize, length, source); |
| 5646 | } |
| 5647 | } |
| 5648 | catch(std::bad_alloc&) |
| 5649 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5650 | return gl::error(GL_OUT_OF_MEMORY); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5651 | } |
| 5652 | } |
| 5653 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5654 | const GLubyte* __stdcall glGetString(GLenum name) |
| 5655 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5656 | EVENT("(GLenum name = 0x%X)", name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5657 | |
| 5658 | try |
| 5659 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5660 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3e4c600 | 2010-05-05 18:50:13 +0000 | [diff] [blame] | 5661 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5662 | switch (name) |
| 5663 | { |
| 5664 | case GL_VENDOR: |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 5665 | return (GLubyte*)"Google Inc."; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5666 | case GL_RENDERER: |
daniel@transgaming.com | c23ff64 | 2011-08-16 20:28:45 +0000 | [diff] [blame] | 5667 | return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5668 | case GL_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5669 | if (context->getClientVersion() == 2) |
| 5670 | { |
| 5671 | return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")"; |
| 5672 | } |
| 5673 | else |
| 5674 | { |
| 5675 | return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")"; |
| 5676 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5677 | case GL_SHADING_LANGUAGE_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5678 | if (context->getClientVersion() == 2) |
| 5679 | { |
| 5680 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")"; |
| 5681 | } |
| 5682 | else |
| 5683 | { |
| 5684 | return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")"; |
| 5685 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5686 | case GL_EXTENSIONS: |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 5687 | return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : ""); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5688 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5689 | return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5690 | } |
| 5691 | } |
| 5692 | catch(std::bad_alloc&) |
| 5693 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5694 | return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5695 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5696 | } |
| 5697 | |
| 5698 | void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) |
| 5699 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5700 | 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] | 5701 | |
| 5702 | try |
| 5703 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5704 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5705 | |
| 5706 | if (context) |
| 5707 | { |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 5708 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5709 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 5710 | if (!texture) |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5711 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5712 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5713 | } |
| 5714 | |
| 5715 | switch (pname) |
| 5716 | { |
| 5717 | case GL_TEXTURE_MAG_FILTER: |
| 5718 | *params = (GLfloat)texture->getMagFilter(); |
| 5719 | break; |
| 5720 | case GL_TEXTURE_MIN_FILTER: |
| 5721 | *params = (GLfloat)texture->getMinFilter(); |
| 5722 | break; |
| 5723 | case GL_TEXTURE_WRAP_S: |
| 5724 | *params = (GLfloat)texture->getWrapS(); |
| 5725 | break; |
| 5726 | case GL_TEXTURE_WRAP_T: |
| 5727 | *params = (GLfloat)texture->getWrapT(); |
| 5728 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5729 | case GL_TEXTURE_WRAP_R: |
| 5730 | if (context->getClientVersion() < 3) |
| 5731 | { |
| 5732 | return gl::error(GL_INVALID_ENUM); |
| 5733 | } |
| 5734 | *params = (GLfloat)texture->getWrapR(); |
| 5735 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5736 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5737 | // 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] | 5738 | *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE); |
| 5739 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5740 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5741 | if (context->getClientVersion() < 3) |
| 5742 | { |
| 5743 | return gl::error(GL_INVALID_ENUM); |
| 5744 | } |
| 5745 | *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0); |
| 5746 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5747 | case GL_TEXTURE_USAGE_ANGLE: |
| 5748 | *params = (GLfloat)texture->getUsage(); |
| 5749 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5750 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5751 | if (!context->supportsTextureFilterAnisotropy()) |
| 5752 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5753 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5754 | } |
| 5755 | *params = (GLfloat)texture->getMaxAnisotropy(); |
| 5756 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5757 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5758 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5759 | } |
| 5760 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5761 | } |
| 5762 | catch(std::bad_alloc&) |
| 5763 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5764 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5765 | } |
| 5766 | } |
| 5767 | |
| 5768 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5769 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5770 | 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] | 5771 | |
| 5772 | try |
| 5773 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5774 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5775 | |
| 5776 | if (context) |
| 5777 | { |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 5778 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5779 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 5780 | if (!texture) |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5781 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5782 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5783 | } |
| 5784 | |
| 5785 | switch (pname) |
| 5786 | { |
| 5787 | case GL_TEXTURE_MAG_FILTER: |
| 5788 | *params = texture->getMagFilter(); |
| 5789 | break; |
| 5790 | case GL_TEXTURE_MIN_FILTER: |
| 5791 | *params = texture->getMinFilter(); |
| 5792 | break; |
| 5793 | case GL_TEXTURE_WRAP_S: |
| 5794 | *params = texture->getWrapS(); |
| 5795 | break; |
| 5796 | case GL_TEXTURE_WRAP_T: |
| 5797 | *params = texture->getWrapT(); |
| 5798 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5799 | case GL_TEXTURE_WRAP_R: |
| 5800 | if (context->getClientVersion() < 3) |
| 5801 | { |
| 5802 | return gl::error(GL_INVALID_ENUM); |
| 5803 | } |
| 5804 | *params = texture->getWrapR(); |
| 5805 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5806 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5807 | // 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] | 5808 | *params = texture->isImmutable() ? GL_TRUE : GL_FALSE; |
| 5809 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5810 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5811 | if (context->getClientVersion() < 3) |
| 5812 | { |
| 5813 | return gl::error(GL_INVALID_ENUM); |
| 5814 | } |
| 5815 | *params = texture->isImmutable() ? texture->levelCount() : 0; |
| 5816 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5817 | case GL_TEXTURE_USAGE_ANGLE: |
| 5818 | *params = texture->getUsage(); |
| 5819 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5820 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5821 | if (!context->supportsTextureFilterAnisotropy()) |
| 5822 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5823 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5824 | } |
| 5825 | *params = (GLint)texture->getMaxAnisotropy(); |
| 5826 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 5827 | |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5828 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5829 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5830 | } |
| 5831 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5832 | } |
| 5833 | catch(std::bad_alloc&) |
| 5834 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5835 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5836 | } |
| 5837 | } |
| 5838 | |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5839 | void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
| 5840 | { |
| 5841 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)", |
| 5842 | program, location, bufSize, params); |
| 5843 | |
| 5844 | try |
| 5845 | { |
| 5846 | if (bufSize < 0) |
| 5847 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5848 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5849 | } |
| 5850 | |
| 5851 | gl::Context *context = gl::getNonLostContext(); |
| 5852 | |
| 5853 | if (context) |
| 5854 | { |
| 5855 | if (program == 0) |
| 5856 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5857 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5858 | } |
| 5859 | |
| 5860 | gl::Program *programObject = context->getProgram(program); |
| 5861 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5862 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5863 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5864 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5865 | } |
| 5866 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5867 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5868 | if (!programBinary) |
| 5869 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5870 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5871 | } |
| 5872 | |
| 5873 | if (!programBinary->getUniformfv(location, &bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5874 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5875 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5876 | } |
| 5877 | } |
| 5878 | } |
| 5879 | catch(std::bad_alloc&) |
| 5880 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5881 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5882 | } |
| 5883 | } |
| 5884 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5885 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 5886 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5887 | 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] | 5888 | |
| 5889 | try |
| 5890 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5891 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5892 | |
| 5893 | if (context) |
| 5894 | { |
| 5895 | if (program == 0) |
| 5896 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5897 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5898 | } |
| 5899 | |
| 5900 | gl::Program *programObject = context->getProgram(program); |
| 5901 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5902 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5903 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5904 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5905 | } |
| 5906 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5907 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5908 | if (!programBinary) |
| 5909 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5910 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5911 | } |
| 5912 | |
| 5913 | if (!programBinary->getUniformfv(location, NULL, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5914 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5915 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5916 | } |
| 5917 | } |
| 5918 | } |
| 5919 | catch(std::bad_alloc&) |
| 5920 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5921 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5922 | } |
| 5923 | } |
| 5924 | |
| 5925 | void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) |
| 5926 | { |
| 5927 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)", |
| 5928 | program, location, bufSize, params); |
| 5929 | |
| 5930 | try |
| 5931 | { |
| 5932 | if (bufSize < 0) |
| 5933 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5934 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5935 | } |
| 5936 | |
| 5937 | gl::Context *context = gl::getNonLostContext(); |
| 5938 | |
| 5939 | if (context) |
| 5940 | { |
| 5941 | if (program == 0) |
| 5942 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5943 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5944 | } |
| 5945 | |
| 5946 | gl::Program *programObject = context->getProgram(program); |
| 5947 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5948 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5949 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5950 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5951 | } |
| 5952 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5953 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5954 | if (!programBinary) |
| 5955 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5956 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5957 | } |
| 5958 | |
| 5959 | if (!programBinary->getUniformiv(location, &bufSize, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5960 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5961 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5962 | } |
| 5963 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5964 | } |
| 5965 | catch(std::bad_alloc&) |
| 5966 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5967 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5968 | } |
| 5969 | } |
| 5970 | |
| 5971 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 5972 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5973 | 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] | 5974 | |
| 5975 | try |
| 5976 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5977 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5978 | |
| 5979 | if (context) |
| 5980 | { |
| 5981 | if (program == 0) |
| 5982 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5983 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5984 | } |
| 5985 | |
| 5986 | gl::Program *programObject = context->getProgram(program); |
| 5987 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5988 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5989 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5990 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5991 | } |
| 5992 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5993 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5994 | if (!programBinary) |
| 5995 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5996 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5997 | } |
| 5998 | |
| 5999 | if (!programBinary->getUniformiv(location, NULL, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6000 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6001 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6002 | } |
| 6003 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6004 | } |
| 6005 | catch(std::bad_alloc&) |
| 6006 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6007 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6008 | } |
| 6009 | } |
| 6010 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6011 | int __stdcall glGetUniformLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6012 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6013 | 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] | 6014 | |
| 6015 | try |
| 6016 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6017 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6018 | |
| 6019 | if (strstr(name, "gl_") == name) |
| 6020 | { |
| 6021 | return -1; |
| 6022 | } |
| 6023 | |
| 6024 | if (context) |
| 6025 | { |
| 6026 | gl::Program *programObject = context->getProgram(program); |
| 6027 | |
| 6028 | if (!programObject) |
| 6029 | { |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 6030 | if (context->getShader(program)) |
| 6031 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6032 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 6033 | } |
| 6034 | else |
| 6035 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6036 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 6037 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6038 | } |
| 6039 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6040 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 6041 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6042 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6043 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6044 | } |
| 6045 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6046 | return programBinary->getUniformLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6047 | } |
| 6048 | } |
| 6049 | catch(std::bad_alloc&) |
| 6050 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6051 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6052 | } |
| 6053 | |
| 6054 | return -1; |
| 6055 | } |
| 6056 | |
| 6057 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 6058 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6059 | 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] | 6060 | |
| 6061 | try |
| 6062 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6063 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6064 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6065 | if (context) |
| 6066 | { |
| 6067 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6068 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6069 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6070 | } |
| 6071 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 6072 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6073 | |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6074 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6075 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6076 | return; |
| 6077 | } |
| 6078 | |
| 6079 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 6080 | { |
| 6081 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 6082 | for (int i = 0; i < 4; ++i) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6083 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6084 | params[i] = currentValueData.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6085 | } |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6086 | } |
| 6087 | else |
| 6088 | { |
| 6089 | *params = attribState.querySingleParameter<GLfloat>(pname); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6090 | } |
| 6091 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6092 | } |
| 6093 | catch(std::bad_alloc&) |
| 6094 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6095 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6096 | } |
| 6097 | } |
| 6098 | |
| 6099 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 6100 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6101 | 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] | 6102 | |
| 6103 | try |
| 6104 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6105 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6106 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6107 | if (context) |
| 6108 | { |
| 6109 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6110 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6111 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6112 | } |
| 6113 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 6114 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6115 | |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6116 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6117 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6118 | return; |
| 6119 | } |
| 6120 | |
| 6121 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 6122 | { |
| 6123 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 6124 | for (int i = 0; i < 4; ++i) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6125 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6126 | float currentValue = currentValueData.FloatValues[i]; |
Jamie Madill | af49691 | 2013-07-19 16:36:54 -0400 | [diff] [blame] | 6127 | params[i] = gl::iround<GLint>(currentValue); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6128 | } |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6129 | } |
| 6130 | else |
| 6131 | { |
| 6132 | *params = attribState.querySingleParameter<GLint>(pname); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6133 | } |
| 6134 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6135 | } |
| 6136 | catch(std::bad_alloc&) |
| 6137 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6138 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6139 | } |
| 6140 | } |
| 6141 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6142 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6143 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6144 | 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] | 6145 | |
| 6146 | try |
| 6147 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6148 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6149 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6150 | if (context) |
| 6151 | { |
| 6152 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6153 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6154 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6155 | } |
| 6156 | |
| 6157 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) |
| 6158 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6159 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6160 | } |
| 6161 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6162 | *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index)); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6163 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6164 | } |
| 6165 | catch(std::bad_alloc&) |
| 6166 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6167 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6168 | } |
| 6169 | } |
| 6170 | |
| 6171 | void __stdcall glHint(GLenum target, GLenum mode) |
| 6172 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6173 | EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6174 | |
| 6175 | try |
| 6176 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6177 | switch (mode) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6178 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6179 | case GL_FASTEST: |
| 6180 | case GL_NICEST: |
| 6181 | case GL_DONT_CARE: |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6182 | break; |
| 6183 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6184 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6185 | } |
| 6186 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6187 | gl::Context *context = gl::getNonLostContext(); |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6188 | switch (target) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6189 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6190 | case GL_GENERATE_MIPMAP_HINT: |
| 6191 | if (context) context->setGenerateMipmapHint(mode); |
| 6192 | break; |
| 6193 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 6194 | if (context) context->setFragmentShaderDerivativeHint(mode); |
| 6195 | break; |
| 6196 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6197 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6198 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6199 | } |
| 6200 | catch(std::bad_alloc&) |
| 6201 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6202 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6203 | } |
| 6204 | } |
| 6205 | |
| 6206 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 6207 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6208 | EVENT("(GLuint buffer = %d)", buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6209 | |
| 6210 | try |
| 6211 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6212 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6213 | |
| 6214 | if (context && buffer) |
| 6215 | { |
| 6216 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 6217 | |
| 6218 | if (bufferObject) |
| 6219 | { |
| 6220 | return GL_TRUE; |
| 6221 | } |
| 6222 | } |
| 6223 | } |
| 6224 | catch(std::bad_alloc&) |
| 6225 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6226 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6227 | } |
| 6228 | |
| 6229 | return GL_FALSE; |
| 6230 | } |
| 6231 | |
| 6232 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 6233 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6234 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6235 | |
| 6236 | try |
| 6237 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6238 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6239 | |
| 6240 | if (context) |
| 6241 | { |
| 6242 | switch (cap) |
| 6243 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6244 | case GL_CULL_FACE: return context->isCullFaceEnabled(); |
| 6245 | case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled(); |
| 6246 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled(); |
| 6247 | case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled(); |
| 6248 | case GL_SCISSOR_TEST: return context->isScissorTestEnabled(); |
| 6249 | case GL_STENCIL_TEST: return context->isStencilTestEnabled(); |
| 6250 | case GL_DEPTH_TEST: return context->isDepthTestEnabled(); |
| 6251 | case GL_BLEND: return context->isBlendEnabled(); |
| 6252 | case GL_DITHER: return context->isDitherEnabled(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6253 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6254 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6255 | } |
| 6256 | } |
| 6257 | } |
| 6258 | catch(std::bad_alloc&) |
| 6259 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6260 | return gl::error(GL_OUT_OF_MEMORY, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6261 | } |
| 6262 | |
| 6263 | return false; |
| 6264 | } |
| 6265 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6266 | GLboolean __stdcall glIsFenceNV(GLuint fence) |
| 6267 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6268 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6269 | |
| 6270 | try |
| 6271 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6272 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6273 | |
| 6274 | if (context) |
| 6275 | { |
| 6276 | gl::Fence *fenceObject = context->getFence(fence); |
| 6277 | |
| 6278 | if (fenceObject == NULL) |
| 6279 | { |
| 6280 | return GL_FALSE; |
| 6281 | } |
| 6282 | |
| 6283 | return fenceObject->isFence(); |
| 6284 | } |
| 6285 | } |
| 6286 | catch(std::bad_alloc&) |
| 6287 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6288 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6289 | } |
| 6290 | |
| 6291 | return GL_FALSE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6292 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6293 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6294 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 6295 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6296 | EVENT("(GLuint framebuffer = %d)", framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6297 | |
| 6298 | try |
| 6299 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6300 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6301 | |
| 6302 | if (context && framebuffer) |
| 6303 | { |
| 6304 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 6305 | |
| 6306 | if (framebufferObject) |
| 6307 | { |
| 6308 | return GL_TRUE; |
| 6309 | } |
| 6310 | } |
| 6311 | } |
| 6312 | catch(std::bad_alloc&) |
| 6313 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6314 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6315 | } |
| 6316 | |
| 6317 | return GL_FALSE; |
| 6318 | } |
| 6319 | |
| 6320 | GLboolean __stdcall glIsProgram(GLuint program) |
| 6321 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6322 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6323 | |
| 6324 | try |
| 6325 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6326 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6327 | |
| 6328 | if (context && program) |
| 6329 | { |
| 6330 | gl::Program *programObject = context->getProgram(program); |
| 6331 | |
| 6332 | if (programObject) |
| 6333 | { |
| 6334 | return GL_TRUE; |
| 6335 | } |
| 6336 | } |
| 6337 | } |
| 6338 | catch(std::bad_alloc&) |
| 6339 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6340 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6341 | } |
| 6342 | |
| 6343 | return GL_FALSE; |
| 6344 | } |
| 6345 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 6346 | GLboolean __stdcall glIsQueryEXT(GLuint id) |
| 6347 | { |
| 6348 | EVENT("(GLuint id = %d)", id); |
| 6349 | |
| 6350 | try |
| 6351 | { |
| 6352 | if (id == 0) |
| 6353 | { |
| 6354 | return GL_FALSE; |
| 6355 | } |
| 6356 | |
| 6357 | gl::Context *context = gl::getNonLostContext(); |
| 6358 | |
| 6359 | if (context) |
| 6360 | { |
| 6361 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 6362 | |
| 6363 | if (queryObject) |
| 6364 | { |
| 6365 | return GL_TRUE; |
| 6366 | } |
| 6367 | } |
| 6368 | } |
| 6369 | catch(std::bad_alloc&) |
| 6370 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6371 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 6372 | } |
| 6373 | |
| 6374 | return GL_FALSE; |
| 6375 | } |
| 6376 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6377 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 6378 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6379 | EVENT("(GLuint renderbuffer = %d)", renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6380 | |
| 6381 | try |
| 6382 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6383 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6384 | |
| 6385 | if (context && renderbuffer) |
| 6386 | { |
| 6387 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 6388 | |
| 6389 | if (renderbufferObject) |
| 6390 | { |
| 6391 | return GL_TRUE; |
| 6392 | } |
| 6393 | } |
| 6394 | } |
| 6395 | catch(std::bad_alloc&) |
| 6396 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6397 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6398 | } |
| 6399 | |
| 6400 | return GL_FALSE; |
| 6401 | } |
| 6402 | |
| 6403 | GLboolean __stdcall glIsShader(GLuint shader) |
| 6404 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6405 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6406 | |
| 6407 | try |
| 6408 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6409 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6410 | |
| 6411 | if (context && shader) |
| 6412 | { |
| 6413 | gl::Shader *shaderObject = context->getShader(shader); |
| 6414 | |
| 6415 | if (shaderObject) |
| 6416 | { |
| 6417 | return GL_TRUE; |
| 6418 | } |
| 6419 | } |
| 6420 | } |
| 6421 | catch(std::bad_alloc&) |
| 6422 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6423 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6424 | } |
| 6425 | |
| 6426 | return GL_FALSE; |
| 6427 | } |
| 6428 | |
| 6429 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 6430 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6431 | EVENT("(GLuint texture = %d)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6432 | |
| 6433 | try |
| 6434 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6435 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6436 | |
| 6437 | if (context && texture) |
| 6438 | { |
| 6439 | gl::Texture *textureObject = context->getTexture(texture); |
| 6440 | |
| 6441 | if (textureObject) |
| 6442 | { |
| 6443 | return GL_TRUE; |
| 6444 | } |
| 6445 | } |
| 6446 | } |
| 6447 | catch(std::bad_alloc&) |
| 6448 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6449 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6450 | } |
| 6451 | |
| 6452 | return GL_FALSE; |
| 6453 | } |
| 6454 | |
| 6455 | void __stdcall glLineWidth(GLfloat width) |
| 6456 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6457 | EVENT("(GLfloat width = %f)", width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6458 | |
| 6459 | try |
| 6460 | { |
| 6461 | if (width <= 0.0f) |
| 6462 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6463 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6464 | } |
| 6465 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6466 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 6467 | |
| 6468 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6469 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6470 | context->setLineWidth(width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6471 | } |
| 6472 | } |
| 6473 | catch(std::bad_alloc&) |
| 6474 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6475 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6476 | } |
| 6477 | } |
| 6478 | |
| 6479 | void __stdcall glLinkProgram(GLuint program) |
| 6480 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6481 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6482 | |
| 6483 | try |
| 6484 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6485 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6486 | |
| 6487 | if (context) |
| 6488 | { |
| 6489 | gl::Program *programObject = context->getProgram(program); |
| 6490 | |
| 6491 | if (!programObject) |
| 6492 | { |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6493 | if (context->getShader(program)) |
| 6494 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6495 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6496 | } |
| 6497 | else |
| 6498 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6499 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6500 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6501 | } |
| 6502 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 6503 | context->linkProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6504 | } |
| 6505 | } |
| 6506 | catch(std::bad_alloc&) |
| 6507 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6508 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6509 | } |
| 6510 | } |
| 6511 | |
| 6512 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 6513 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6514 | EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6515 | |
| 6516 | try |
| 6517 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6518 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6519 | |
| 6520 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6521 | { |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6522 | switch (pname) |
| 6523 | { |
| 6524 | case GL_UNPACK_ALIGNMENT: |
| 6525 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6526 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6527 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6528 | } |
| 6529 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6530 | context->setUnpackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6531 | break; |
| 6532 | |
| 6533 | case GL_PACK_ALIGNMENT: |
| 6534 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6535 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6536 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6537 | } |
| 6538 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6539 | context->setPackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6540 | break; |
| 6541 | |
bsalomon@google.com | 56d46ab | 2011-11-23 14:53:10 +0000 | [diff] [blame] | 6542 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 6543 | context->setPackReverseRowOrder(param != 0); |
| 6544 | break; |
| 6545 | |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6546 | case GL_UNPACK_IMAGE_HEIGHT: |
| 6547 | case GL_UNPACK_SKIP_IMAGES: |
| 6548 | case GL_UNPACK_ROW_LENGTH: |
| 6549 | case GL_UNPACK_SKIP_ROWS: |
| 6550 | case GL_UNPACK_SKIP_PIXELS: |
| 6551 | case GL_PACK_ROW_LENGTH: |
| 6552 | case GL_PACK_SKIP_ROWS: |
| 6553 | case GL_PACK_SKIP_PIXELS: |
| 6554 | if (context->getClientVersion() < 3) |
| 6555 | { |
| 6556 | return gl::error(GL_INVALID_ENUM); |
| 6557 | } |
| 6558 | UNIMPLEMENTED(); |
| 6559 | break; |
| 6560 | |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6561 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6562 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6563 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6564 | } |
| 6565 | } |
| 6566 | catch(std::bad_alloc&) |
| 6567 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6568 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6569 | } |
| 6570 | } |
| 6571 | |
| 6572 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 6573 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6574 | EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6575 | |
| 6576 | try |
| 6577 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6578 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aede630 | 2010-04-29 03:35:48 +0000 | [diff] [blame] | 6579 | |
| 6580 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6581 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6582 | context->setPolygonOffsetParams(factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6583 | } |
| 6584 | } |
| 6585 | catch(std::bad_alloc&) |
| 6586 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6587 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6588 | } |
| 6589 | } |
| 6590 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6591 | void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6592 | GLenum format, GLenum type, GLsizei bufSize, |
| 6593 | GLvoid *data) |
| 6594 | { |
| 6595 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
| 6596 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)", |
| 6597 | x, y, width, height, format, type, bufSize, data); |
| 6598 | |
| 6599 | try |
| 6600 | { |
| 6601 | if (width < 0 || height < 0 || bufSize < 0) |
| 6602 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6603 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6604 | } |
| 6605 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6606 | gl::Context *context = gl::getNonLostContext(); |
| 6607 | |
| 6608 | if (context) |
| 6609 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6610 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6611 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6612 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6613 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6614 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6615 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6616 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6617 | return; |
| 6618 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6619 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6620 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6621 | |
| 6622 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6623 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6624 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6625 | } |
| 6626 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6627 | context->readPixels(x, y, width, height, format, type, &bufSize, data); |
| 6628 | } |
| 6629 | } |
| 6630 | catch(std::bad_alloc&) |
| 6631 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6632 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6633 | } |
| 6634 | } |
| 6635 | |
| 6636 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6637 | GLenum format, GLenum type, GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6638 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6639 | 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] | 6640 | "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] | 6641 | x, y, width, height, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6642 | |
| 6643 | try |
| 6644 | { |
| 6645 | if (width < 0 || height < 0) |
| 6646 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6647 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6648 | } |
| 6649 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6650 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6651 | |
| 6652 | if (context) |
| 6653 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6654 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6655 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6656 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6657 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6658 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6659 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6660 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6661 | return; |
| 6662 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6663 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6664 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6665 | |
| 6666 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6667 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6668 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6669 | } |
| 6670 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6671 | context->readPixels(x, y, width, height, format, type, NULL, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6672 | } |
| 6673 | } |
| 6674 | catch(std::bad_alloc&) |
| 6675 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6676 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6677 | } |
| 6678 | } |
| 6679 | |
| 6680 | void __stdcall glReleaseShaderCompiler(void) |
| 6681 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6682 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6683 | |
| 6684 | try |
| 6685 | { |
| 6686 | gl::Shader::releaseCompiler(); |
| 6687 | } |
| 6688 | catch(std::bad_alloc&) |
| 6689 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6690 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6691 | } |
| 6692 | } |
| 6693 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6694 | 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] | 6695 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6696 | 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] | 6697 | target, samples, internalformat, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6698 | |
| 6699 | try |
| 6700 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6701 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6702 | |
| 6703 | if (context) |
| 6704 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6705 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 6706 | width, height, true)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6707 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6708 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6709 | } |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 6710 | |
| 6711 | context->setRenderbufferStorage(width, height, internalformat, samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6712 | } |
| 6713 | } |
| 6714 | catch(std::bad_alloc&) |
| 6715 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6716 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6717 | } |
| 6718 | } |
| 6719 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6720 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 6721 | { |
| 6722 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height); |
| 6723 | } |
| 6724 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6725 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 6726 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6727 | EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6728 | |
| 6729 | try |
| 6730 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6731 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6732 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6733 | if (context) |
| 6734 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 6735 | context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6736 | } |
| 6737 | } |
| 6738 | catch(std::bad_alloc&) |
| 6739 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6740 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6741 | } |
| 6742 | } |
| 6743 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6744 | void __stdcall glSetFenceNV(GLuint fence, GLenum condition) |
| 6745 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6746 | EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6747 | |
| 6748 | try |
| 6749 | { |
| 6750 | if (condition != GL_ALL_COMPLETED_NV) |
| 6751 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6752 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6753 | } |
| 6754 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6755 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6756 | |
| 6757 | if (context) |
| 6758 | { |
| 6759 | gl::Fence *fenceObject = context->getFence(fence); |
| 6760 | |
| 6761 | if (fenceObject == NULL) |
| 6762 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6763 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6764 | } |
| 6765 | |
| 6766 | fenceObject->setFence(condition); |
| 6767 | } |
| 6768 | } |
| 6769 | catch(std::bad_alloc&) |
| 6770 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6771 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6772 | } |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6773 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6774 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6775 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 6776 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6777 | 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] | 6778 | |
| 6779 | try |
| 6780 | { |
| 6781 | if (width < 0 || height < 0) |
| 6782 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6783 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6784 | } |
| 6785 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6786 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6787 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6788 | if (context) |
| 6789 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6790 | context->setScissorParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6791 | } |
| 6792 | } |
| 6793 | catch(std::bad_alloc&) |
| 6794 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6795 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6796 | } |
| 6797 | } |
| 6798 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6799 | 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] | 6800 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6801 | 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] | 6802 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 6803 | n, shaders, binaryformat, binary, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6804 | |
| 6805 | try |
| 6806 | { |
daniel@transgaming.com | d1f667f | 2010-04-29 03:38:52 +0000 | [diff] [blame] | 6807 | // No binary shader formats are supported. |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6808 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6809 | } |
| 6810 | catch(std::bad_alloc&) |
| 6811 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6812 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6813 | } |
| 6814 | } |
| 6815 | |
shannon.woods%transgaming.com@gtempaccount.com | 5f33933 | 2013-04-13 03:29:02 +0000 | [diff] [blame] | 6816 | 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] | 6817 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6818 | 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] | 6819 | shader, count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6820 | |
| 6821 | try |
| 6822 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6823 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6824 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6825 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6826 | } |
| 6827 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6828 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6829 | |
| 6830 | if (context) |
| 6831 | { |
| 6832 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6833 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6834 | if (!shaderObject) |
| 6835 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6836 | if (context->getProgram(shader)) |
| 6837 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6838 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6839 | } |
| 6840 | else |
| 6841 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6842 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6843 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6844 | } |
| 6845 | |
| 6846 | shaderObject->setSource(count, string, length); |
| 6847 | } |
| 6848 | } |
| 6849 | catch(std::bad_alloc&) |
| 6850 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6851 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6852 | } |
| 6853 | } |
| 6854 | |
| 6855 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 6856 | { |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6857 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6858 | } |
| 6859 | |
| 6860 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 6861 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6862 | 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] | 6863 | |
| 6864 | try |
| 6865 | { |
| 6866 | switch (face) |
| 6867 | { |
| 6868 | case GL_FRONT: |
| 6869 | case GL_BACK: |
| 6870 | case GL_FRONT_AND_BACK: |
| 6871 | break; |
| 6872 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6873 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6874 | } |
| 6875 | |
| 6876 | switch (func) |
| 6877 | { |
| 6878 | case GL_NEVER: |
| 6879 | case GL_ALWAYS: |
| 6880 | case GL_LESS: |
| 6881 | case GL_LEQUAL: |
| 6882 | case GL_EQUAL: |
| 6883 | case GL_GEQUAL: |
| 6884 | case GL_GREATER: |
| 6885 | case GL_NOTEQUAL: |
| 6886 | break; |
| 6887 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6888 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6889 | } |
| 6890 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6891 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6892 | |
| 6893 | if (context) |
| 6894 | { |
| 6895 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6896 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6897 | context->setStencilParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6898 | } |
| 6899 | |
| 6900 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6901 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6902 | context->setStencilBackParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6903 | } |
| 6904 | } |
| 6905 | } |
| 6906 | catch(std::bad_alloc&) |
| 6907 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6908 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6909 | } |
| 6910 | } |
| 6911 | |
| 6912 | void __stdcall glStencilMask(GLuint mask) |
| 6913 | { |
| 6914 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 6915 | } |
| 6916 | |
| 6917 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 6918 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6919 | EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6920 | |
| 6921 | try |
| 6922 | { |
| 6923 | switch (face) |
| 6924 | { |
| 6925 | case GL_FRONT: |
| 6926 | case GL_BACK: |
| 6927 | case GL_FRONT_AND_BACK: |
| 6928 | break; |
| 6929 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6930 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6931 | } |
| 6932 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6933 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6934 | |
| 6935 | if (context) |
| 6936 | { |
| 6937 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6938 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6939 | context->setStencilWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6940 | } |
| 6941 | |
| 6942 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6943 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6944 | context->setStencilBackWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6945 | } |
| 6946 | } |
| 6947 | } |
| 6948 | catch(std::bad_alloc&) |
| 6949 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6950 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6951 | } |
| 6952 | } |
| 6953 | |
| 6954 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 6955 | { |
| 6956 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 6957 | } |
| 6958 | |
| 6959 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 6960 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6961 | 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] | 6962 | face, fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6963 | |
| 6964 | try |
| 6965 | { |
| 6966 | switch (face) |
| 6967 | { |
| 6968 | case GL_FRONT: |
| 6969 | case GL_BACK: |
| 6970 | case GL_FRONT_AND_BACK: |
| 6971 | break; |
| 6972 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6973 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6974 | } |
| 6975 | |
| 6976 | switch (fail) |
| 6977 | { |
| 6978 | case GL_ZERO: |
| 6979 | case GL_KEEP: |
| 6980 | case GL_REPLACE: |
| 6981 | case GL_INCR: |
| 6982 | case GL_DECR: |
| 6983 | case GL_INVERT: |
| 6984 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6985 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6986 | break; |
| 6987 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6988 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6989 | } |
| 6990 | |
| 6991 | switch (zfail) |
| 6992 | { |
| 6993 | case GL_ZERO: |
| 6994 | case GL_KEEP: |
| 6995 | case GL_REPLACE: |
| 6996 | case GL_INCR: |
| 6997 | case GL_DECR: |
| 6998 | case GL_INVERT: |
| 6999 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 7000 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7001 | break; |
| 7002 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7003 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7004 | } |
| 7005 | |
| 7006 | switch (zpass) |
| 7007 | { |
| 7008 | case GL_ZERO: |
| 7009 | case GL_KEEP: |
| 7010 | case GL_REPLACE: |
| 7011 | case GL_INCR: |
| 7012 | case GL_DECR: |
| 7013 | case GL_INVERT: |
| 7014 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 7015 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7016 | break; |
| 7017 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7018 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7019 | } |
| 7020 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7021 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7022 | |
| 7023 | if (context) |
| 7024 | { |
| 7025 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 7026 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7027 | context->setStencilOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7028 | } |
| 7029 | |
| 7030 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 7031 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7032 | context->setStencilBackOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7033 | } |
| 7034 | } |
| 7035 | } |
| 7036 | catch(std::bad_alloc&) |
| 7037 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7038 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7039 | } |
| 7040 | } |
| 7041 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 7042 | GLboolean __stdcall glTestFenceNV(GLuint fence) |
| 7043 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7044 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7045 | |
| 7046 | try |
| 7047 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7048 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7049 | |
| 7050 | if (context) |
| 7051 | { |
| 7052 | gl::Fence *fenceObject = context->getFence(fence); |
| 7053 | |
| 7054 | if (fenceObject == NULL) |
| 7055 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7056 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7057 | } |
| 7058 | |
| 7059 | return fenceObject->testFence(); |
| 7060 | } |
| 7061 | } |
| 7062 | catch(std::bad_alloc&) |
| 7063 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7064 | gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7065 | } |
| 7066 | |
| 7067 | return GL_TRUE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 7068 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7069 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7070 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, |
| 7071 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7072 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7073 | 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] | 7074 | "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] | 7075 | target, level, internalformat, width, height, border, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7076 | |
| 7077 | try |
| 7078 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7079 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7080 | |
| 7081 | if (context) |
| 7082 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7083 | if (context->getClientVersion() < 3 && |
| 7084 | !validateES2TexImageParameters(context, target, level, internalformat, false, false, |
| 7085 | 0, 0, width, height, border, format, type, pixels)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 7086 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7087 | return; |
| 7088 | } |
| 7089 | |
| 7090 | if (context->getClientVersion() >= 3 && |
| 7091 | !validateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 7092 | 0, 0, 0, width, height, 1, border, format, type)) |
| 7093 | { |
| 7094 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 7095 | } |
| 7096 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7097 | switch (target) |
| 7098 | { |
| 7099 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7100 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7101 | gl::Texture2D *texture = context->getTexture2D(); |
| 7102 | texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7103 | } |
| 7104 | break; |
| 7105 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7106 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7107 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 7108 | texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7109 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7110 | break; |
| 7111 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7112 | { |
| 7113 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7114 | texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7115 | } |
| 7116 | break; |
| 7117 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7118 | { |
| 7119 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7120 | texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7121 | } |
| 7122 | break; |
| 7123 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7124 | { |
| 7125 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7126 | texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7127 | } |
| 7128 | break; |
| 7129 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7130 | { |
| 7131 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7132 | texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7133 | } |
| 7134 | break; |
| 7135 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 7136 | { |
| 7137 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7138 | texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7139 | } |
| 7140 | break; |
| 7141 | default: UNREACHABLE(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7142 | } |
| 7143 | } |
| 7144 | } |
| 7145 | catch(std::bad_alloc&) |
| 7146 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7147 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7148 | } |
| 7149 | } |
| 7150 | |
| 7151 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 7152 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7153 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param); |
| 7154 | |
| 7155 | try |
| 7156 | { |
| 7157 | gl::Context *context = gl::getNonLostContext(); |
| 7158 | |
| 7159 | if (context) |
| 7160 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7161 | if (!validateTexParamParameters(context, pname, static_cast<GLint>(param))) |
| 7162 | { |
| 7163 | return; |
| 7164 | } |
| 7165 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 7166 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7167 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 7168 | if (!texture) |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7169 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7170 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7171 | } |
| 7172 | |
| 7173 | switch (pname) |
| 7174 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7175 | case GL_TEXTURE_WRAP_S: texture->setWrapS(gl::uiround<GLenum>(param)); break; |
| 7176 | case GL_TEXTURE_WRAP_T: texture->setWrapT(gl::uiround<GLenum>(param)); break; |
| 7177 | case GL_TEXTURE_WRAP_R: texture->setWrapR(gl::uiround<GLenum>(param)); break; |
| 7178 | case GL_TEXTURE_MIN_FILTER: texture->setMinFilter(gl::uiround<GLenum>(param)); break; |
| 7179 | case GL_TEXTURE_MAG_FILTER: texture->setMagFilter(gl::uiround<GLenum>(param)); break; |
| 7180 | case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break; |
| 7181 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy(static_cast<GLfloat>(param), context->getTextureMaxAnisotropy()); break; |
| 7182 | case GL_TEXTURE_COMPARE_MODE: texture->setCompareMode(gl::uiround<GLenum>(param)); break; |
| 7183 | case GL_TEXTURE_COMPARE_FUNC: texture->setCompareFunc(gl::uiround<GLenum>(param)); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7184 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7185 | case GL_TEXTURE_SWIZZLE_R: |
| 7186 | case GL_TEXTURE_SWIZZLE_G: |
| 7187 | case GL_TEXTURE_SWIZZLE_B: |
| 7188 | case GL_TEXTURE_SWIZZLE_A: |
| 7189 | case GL_TEXTURE_BASE_LEVEL: |
| 7190 | case GL_TEXTURE_MAX_LEVEL: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7191 | case GL_TEXTURE_MIN_LOD: |
| 7192 | case GL_TEXTURE_MAX_LOD: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7193 | UNIMPLEMENTED(); |
| 7194 | break; |
| 7195 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7196 | default: UNREACHABLE(); break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7197 | } |
| 7198 | } |
| 7199 | } |
| 7200 | catch(std::bad_alloc&) |
| 7201 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7202 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7203 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7204 | } |
| 7205 | |
| 7206 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 7207 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7208 | glTexParameterf(target, pname, (GLfloat)*params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7209 | } |
| 7210 | |
| 7211 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 7212 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7213 | 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] | 7214 | |
| 7215 | try |
| 7216 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7217 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7218 | |
| 7219 | if (context) |
| 7220 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7221 | if (!validateTexParamParameters(context, pname, param)) |
| 7222 | { |
| 7223 | return; |
| 7224 | } |
| 7225 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 7226 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7227 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 7228 | if (!texture) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7229 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7230 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7231 | } |
| 7232 | |
| 7233 | switch (pname) |
| 7234 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7235 | case GL_TEXTURE_WRAP_S: texture->setWrapS((GLenum)param); break; |
| 7236 | case GL_TEXTURE_WRAP_T: texture->setWrapT((GLenum)param); break; |
| 7237 | case GL_TEXTURE_WRAP_R: texture->setWrapR((GLenum)param); break; |
| 7238 | case GL_TEXTURE_MIN_FILTER: texture->setMinFilter((GLenum)param); break; |
| 7239 | case GL_TEXTURE_MAG_FILTER: texture->setMagFilter((GLenum)param); break; |
| 7240 | case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break; |
| 7241 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()); break; |
| 7242 | case GL_TEXTURE_COMPARE_MODE: texture->setCompareMode((GLenum)param); break; |
| 7243 | case GL_TEXTURE_COMPARE_FUNC: texture->setCompareFunc((GLenum)param); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7244 | |
| 7245 | case GL_TEXTURE_SWIZZLE_R: |
| 7246 | case GL_TEXTURE_SWIZZLE_G: |
| 7247 | case GL_TEXTURE_SWIZZLE_B: |
| 7248 | case GL_TEXTURE_SWIZZLE_A: |
| 7249 | case GL_TEXTURE_BASE_LEVEL: |
| 7250 | case GL_TEXTURE_MAX_LEVEL: |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7251 | case GL_TEXTURE_MIN_LOD: |
| 7252 | case GL_TEXTURE_MAX_LOD: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7253 | UNIMPLEMENTED(); |
| 7254 | break; |
| 7255 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7256 | default: UNREACHABLE(); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7257 | } |
| 7258 | } |
| 7259 | } |
| 7260 | catch(std::bad_alloc&) |
| 7261 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7262 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7263 | } |
| 7264 | } |
| 7265 | |
| 7266 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 7267 | { |
| 7268 | glTexParameteri(target, pname, *params); |
| 7269 | } |
| 7270 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7271 | void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 7272 | { |
| 7273 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 7274 | target, levels, internalformat, width, height); |
| 7275 | |
| 7276 | try |
| 7277 | { |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7278 | gl::Context *context = gl::getNonLostContext(); |
| 7279 | |
| 7280 | if (context) |
| 7281 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7282 | if (context->getClientVersion() < 3 && |
| 7283 | !validateES2TexStorageParameters(context, target, levels, internalformat, width, height)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7284 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7285 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7286 | } |
| 7287 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7288 | if (context->getClientVersion() >= 3 && |
| 7289 | !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7290 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7291 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7292 | } |
| 7293 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7294 | switch (target) |
| 7295 | { |
| 7296 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7297 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7298 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 7299 | texture2d->storage(levels, internalformat, width, height); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7300 | } |
| 7301 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7302 | |
| 7303 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7304 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7305 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7306 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7307 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7308 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7309 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7310 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 7311 | textureCube->storage(levels, internalformat, width); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7312 | } |
| 7313 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7314 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7315 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7316 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7317 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7318 | } |
| 7319 | } |
| 7320 | catch(std::bad_alloc&) |
| 7321 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7322 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7323 | } |
| 7324 | } |
| 7325 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7326 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 7327 | GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7328 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7329 | 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] | 7330 | "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] | 7331 | "const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7332 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 7333 | |
| 7334 | try |
| 7335 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7336 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7337 | |
| 7338 | if (context) |
| 7339 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7340 | if (context->getClientVersion() < 3 && |
| 7341 | !validateES2TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7342 | 0, 0, width, height, 0, format, type, pixels)) |
daniel@transgaming.com | 1d2d3c4 | 2012-05-31 01:14:15 +0000 | [diff] [blame] | 7343 | { |
| 7344 | return; |
| 7345 | } |
| 7346 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7347 | if (context->getClientVersion() >= 3 && |
| 7348 | !validateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7349 | 0, 0, 0, width, height, 1, 0, format, type)) |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7350 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7351 | return; |
| 7352 | } |
| 7353 | |
| 7354 | switch (target) |
| 7355 | { |
| 7356 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7357 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7358 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7359 | 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] | 7360 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7361 | break; |
| 7362 | |
| 7363 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7364 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7365 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7366 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7367 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7368 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7369 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7370 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7371 | 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] | 7372 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7373 | break; |
| 7374 | |
| 7375 | default: |
| 7376 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7377 | } |
| 7378 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7379 | } |
| 7380 | catch(std::bad_alloc&) |
| 7381 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7382 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7383 | } |
| 7384 | } |
| 7385 | |
| 7386 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 7387 | { |
| 7388 | glUniform1fv(location, 1, &x); |
| 7389 | } |
| 7390 | |
| 7391 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 7392 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7393 | 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] | 7394 | |
| 7395 | try |
| 7396 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7397 | if (count < 0) |
| 7398 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7399 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7400 | } |
| 7401 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7402 | if (location == -1) |
| 7403 | { |
| 7404 | return; |
| 7405 | } |
| 7406 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7407 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7408 | |
| 7409 | if (context) |
| 7410 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7411 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7412 | if (!programBinary) |
| 7413 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7414 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7415 | } |
| 7416 | |
| 7417 | if (!programBinary->setUniform1fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7418 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7419 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7420 | } |
| 7421 | } |
| 7422 | } |
| 7423 | catch(std::bad_alloc&) |
| 7424 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7425 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7426 | } |
| 7427 | } |
| 7428 | |
| 7429 | void __stdcall glUniform1i(GLint location, GLint x) |
| 7430 | { |
| 7431 | glUniform1iv(location, 1, &x); |
| 7432 | } |
| 7433 | |
| 7434 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 7435 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7436 | 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] | 7437 | |
| 7438 | try |
| 7439 | { |
| 7440 | if (count < 0) |
| 7441 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7442 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7443 | } |
| 7444 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7445 | if (location == -1) |
| 7446 | { |
| 7447 | return; |
| 7448 | } |
| 7449 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7450 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7451 | |
| 7452 | if (context) |
| 7453 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7454 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7455 | if (!programBinary) |
| 7456 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7457 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7458 | } |
| 7459 | |
| 7460 | if (!programBinary->setUniform1iv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7461 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7462 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7463 | } |
| 7464 | } |
| 7465 | } |
| 7466 | catch(std::bad_alloc&) |
| 7467 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7468 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7469 | } |
| 7470 | } |
| 7471 | |
| 7472 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 7473 | { |
| 7474 | GLfloat xy[2] = {x, y}; |
| 7475 | |
| 7476 | glUniform2fv(location, 1, (GLfloat*)&xy); |
| 7477 | } |
| 7478 | |
| 7479 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 7480 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7481 | 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] | 7482 | |
| 7483 | try |
| 7484 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7485 | if (count < 0) |
| 7486 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7487 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7488 | } |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7489 | |
| 7490 | if (location == -1) |
| 7491 | { |
| 7492 | return; |
| 7493 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7494 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7495 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7496 | |
| 7497 | if (context) |
| 7498 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7499 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7500 | if (!programBinary) |
| 7501 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7502 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7503 | } |
| 7504 | |
| 7505 | if (!programBinary->setUniform2fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7506 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7507 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7508 | } |
| 7509 | } |
| 7510 | } |
| 7511 | catch(std::bad_alloc&) |
| 7512 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7513 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7514 | } |
| 7515 | } |
| 7516 | |
| 7517 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 7518 | { |
| 7519 | GLint xy[4] = {x, y}; |
| 7520 | |
| 7521 | glUniform2iv(location, 1, (GLint*)&xy); |
| 7522 | } |
| 7523 | |
| 7524 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 7525 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7526 | 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] | 7527 | |
| 7528 | try |
| 7529 | { |
| 7530 | if (count < 0) |
| 7531 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7532 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7533 | } |
| 7534 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7535 | if (location == -1) |
| 7536 | { |
| 7537 | return; |
| 7538 | } |
| 7539 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7540 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7541 | |
| 7542 | if (context) |
| 7543 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7544 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7545 | if (!programBinary) |
| 7546 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7547 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7548 | } |
| 7549 | |
| 7550 | if (!programBinary->setUniform2iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7551 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7552 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7553 | } |
| 7554 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7555 | } |
| 7556 | catch(std::bad_alloc&) |
| 7557 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7558 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7559 | } |
| 7560 | } |
| 7561 | |
| 7562 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 7563 | { |
| 7564 | GLfloat xyz[3] = {x, y, z}; |
| 7565 | |
| 7566 | glUniform3fv(location, 1, (GLfloat*)&xyz); |
| 7567 | } |
| 7568 | |
| 7569 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 7570 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7571 | 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] | 7572 | |
| 7573 | try |
| 7574 | { |
| 7575 | if (count < 0) |
| 7576 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7577 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7578 | } |
| 7579 | |
| 7580 | if (location == -1) |
| 7581 | { |
| 7582 | return; |
| 7583 | } |
| 7584 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7585 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7586 | |
| 7587 | if (context) |
| 7588 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7589 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7590 | if (!programBinary) |
| 7591 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7592 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7593 | } |
| 7594 | |
| 7595 | if (!programBinary->setUniform3fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7596 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7597 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7598 | } |
| 7599 | } |
| 7600 | } |
| 7601 | catch(std::bad_alloc&) |
| 7602 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7603 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7604 | } |
| 7605 | } |
| 7606 | |
| 7607 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 7608 | { |
| 7609 | GLint xyz[3] = {x, y, z}; |
| 7610 | |
| 7611 | glUniform3iv(location, 1, (GLint*)&xyz); |
| 7612 | } |
| 7613 | |
| 7614 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 7615 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7616 | 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] | 7617 | |
| 7618 | try |
| 7619 | { |
| 7620 | if (count < 0) |
| 7621 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7622 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7623 | } |
| 7624 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7625 | if (location == -1) |
| 7626 | { |
| 7627 | return; |
| 7628 | } |
| 7629 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7630 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7631 | |
| 7632 | if (context) |
| 7633 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7634 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7635 | if (!programBinary) |
| 7636 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7637 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7638 | } |
| 7639 | |
| 7640 | if (!programBinary->setUniform3iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7641 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7642 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7643 | } |
| 7644 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7645 | } |
| 7646 | catch(std::bad_alloc&) |
| 7647 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7648 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7649 | } |
| 7650 | } |
| 7651 | |
| 7652 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7653 | { |
| 7654 | GLfloat xyzw[4] = {x, y, z, w}; |
| 7655 | |
| 7656 | glUniform4fv(location, 1, (GLfloat*)&xyzw); |
| 7657 | } |
| 7658 | |
| 7659 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 7660 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7661 | 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] | 7662 | |
| 7663 | try |
| 7664 | { |
| 7665 | if (count < 0) |
| 7666 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7667 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7668 | } |
| 7669 | |
| 7670 | if (location == -1) |
| 7671 | { |
| 7672 | return; |
| 7673 | } |
| 7674 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7675 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7676 | |
| 7677 | if (context) |
| 7678 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7679 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7680 | if (!programBinary) |
| 7681 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7682 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7683 | } |
| 7684 | |
| 7685 | if (!programBinary->setUniform4fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7686 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7687 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7688 | } |
| 7689 | } |
| 7690 | } |
| 7691 | catch(std::bad_alloc&) |
| 7692 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7693 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7694 | } |
| 7695 | } |
| 7696 | |
| 7697 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 7698 | { |
| 7699 | GLint xyzw[4] = {x, y, z, w}; |
| 7700 | |
| 7701 | glUniform4iv(location, 1, (GLint*)&xyzw); |
| 7702 | } |
| 7703 | |
| 7704 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 7705 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7706 | 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] | 7707 | |
| 7708 | try |
| 7709 | { |
| 7710 | if (count < 0) |
| 7711 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7712 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7713 | } |
| 7714 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7715 | if (location == -1) |
| 7716 | { |
| 7717 | return; |
| 7718 | } |
| 7719 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7720 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7721 | |
| 7722 | if (context) |
| 7723 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7724 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7725 | if (!programBinary) |
| 7726 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7727 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7728 | } |
| 7729 | |
| 7730 | if (!programBinary->setUniform4iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7731 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7732 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7733 | } |
| 7734 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7735 | } |
| 7736 | catch(std::bad_alloc&) |
| 7737 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7738 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7739 | } |
| 7740 | } |
| 7741 | |
| 7742 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7743 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7744 | 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] | 7745 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7746 | |
| 7747 | try |
| 7748 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7749 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7750 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7751 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7752 | } |
| 7753 | |
| 7754 | if (location == -1) |
| 7755 | { |
| 7756 | return; |
| 7757 | } |
| 7758 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7759 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7760 | |
| 7761 | if (context) |
| 7762 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7763 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7764 | { |
| 7765 | return gl::error(GL_INVALID_VALUE); |
| 7766 | } |
| 7767 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7768 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7769 | if (!programBinary) |
| 7770 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7771 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7772 | } |
| 7773 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7774 | if (!programBinary->setUniformMatrix2fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7775 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7776 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7777 | } |
| 7778 | } |
| 7779 | } |
| 7780 | catch(std::bad_alloc&) |
| 7781 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7782 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7783 | } |
| 7784 | } |
| 7785 | |
| 7786 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7787 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7788 | 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] | 7789 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7790 | |
| 7791 | try |
| 7792 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7793 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7794 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7795 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7796 | } |
| 7797 | |
| 7798 | if (location == -1) |
| 7799 | { |
| 7800 | return; |
| 7801 | } |
| 7802 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7803 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7804 | |
| 7805 | if (context) |
| 7806 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7807 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7808 | { |
| 7809 | return gl::error(GL_INVALID_VALUE); |
| 7810 | } |
| 7811 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7812 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7813 | if (!programBinary) |
| 7814 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7815 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7816 | } |
| 7817 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7818 | if (!programBinary->setUniformMatrix3fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7819 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7820 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7821 | } |
| 7822 | } |
| 7823 | } |
| 7824 | catch(std::bad_alloc&) |
| 7825 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7826 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7827 | } |
| 7828 | } |
| 7829 | |
| 7830 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7831 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7832 | 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] | 7833 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7834 | |
| 7835 | try |
| 7836 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7837 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7838 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7839 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7840 | } |
| 7841 | |
| 7842 | if (location == -1) |
| 7843 | { |
| 7844 | return; |
| 7845 | } |
| 7846 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7847 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7848 | |
| 7849 | if (context) |
| 7850 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7851 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7852 | { |
| 7853 | return gl::error(GL_INVALID_VALUE); |
| 7854 | } |
| 7855 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7856 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7857 | if (!programBinary) |
| 7858 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7859 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7860 | } |
| 7861 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7862 | if (!programBinary->setUniformMatrix4fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7863 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7864 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7865 | } |
| 7866 | } |
| 7867 | } |
| 7868 | catch(std::bad_alloc&) |
| 7869 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7870 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7871 | } |
| 7872 | } |
| 7873 | |
| 7874 | void __stdcall glUseProgram(GLuint program) |
| 7875 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7876 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7877 | |
| 7878 | try |
| 7879 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7880 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7881 | |
| 7882 | if (context) |
| 7883 | { |
| 7884 | gl::Program *programObject = context->getProgram(program); |
| 7885 | |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7886 | if (!programObject && program != 0) |
| 7887 | { |
| 7888 | if (context->getShader(program)) |
| 7889 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7890 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7891 | } |
| 7892 | else |
| 7893 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7894 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7895 | } |
| 7896 | } |
| 7897 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 7898 | if (program != 0 && !programObject->isLinked()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7899 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7900 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7901 | } |
| 7902 | |
| 7903 | context->useProgram(program); |
| 7904 | } |
| 7905 | } |
| 7906 | catch(std::bad_alloc&) |
| 7907 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7908 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7909 | } |
| 7910 | } |
| 7911 | |
| 7912 | void __stdcall glValidateProgram(GLuint program) |
| 7913 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7914 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7915 | |
| 7916 | try |
| 7917 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7918 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7919 | |
| 7920 | if (context) |
| 7921 | { |
| 7922 | gl::Program *programObject = context->getProgram(program); |
| 7923 | |
| 7924 | if (!programObject) |
| 7925 | { |
| 7926 | if (context->getShader(program)) |
| 7927 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7928 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7929 | } |
| 7930 | else |
| 7931 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7932 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7933 | } |
| 7934 | } |
| 7935 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 7936 | programObject->validate(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7937 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7938 | } |
| 7939 | catch(std::bad_alloc&) |
| 7940 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7941 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7942 | } |
| 7943 | } |
| 7944 | |
| 7945 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 7946 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7947 | EVENT("(GLuint index = %d, GLfloat x = %f)", index, x); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7948 | |
| 7949 | try |
| 7950 | { |
| 7951 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7952 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7953 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7954 | } |
| 7955 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7956 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7957 | |
| 7958 | if (context) |
| 7959 | { |
| 7960 | GLfloat vals[4] = { x, 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7961 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7962 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7963 | } |
| 7964 | catch(std::bad_alloc&) |
| 7965 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7966 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7967 | } |
| 7968 | } |
| 7969 | |
| 7970 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 7971 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7972 | 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] | 7973 | |
| 7974 | try |
| 7975 | { |
| 7976 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7977 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7978 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7979 | } |
| 7980 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7981 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7982 | |
| 7983 | if (context) |
| 7984 | { |
| 7985 | GLfloat vals[4] = { values[0], 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7986 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7987 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7988 | } |
| 7989 | catch(std::bad_alloc&) |
| 7990 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7991 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7992 | } |
| 7993 | } |
| 7994 | |
| 7995 | void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 7996 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7997 | 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] | 7998 | |
| 7999 | try |
| 8000 | { |
| 8001 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8002 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8003 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8004 | } |
| 8005 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8006 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8007 | |
| 8008 | if (context) |
| 8009 | { |
| 8010 | GLfloat vals[4] = { x, y, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8011 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8012 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8013 | } |
| 8014 | catch(std::bad_alloc&) |
| 8015 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8016 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8017 | } |
| 8018 | } |
| 8019 | |
| 8020 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 8021 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8022 | 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] | 8023 | |
| 8024 | try |
| 8025 | { |
| 8026 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8027 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8028 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8029 | } |
| 8030 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8031 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8032 | |
| 8033 | if (context) |
| 8034 | { |
| 8035 | 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] | 8036 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8037 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8038 | } |
| 8039 | catch(std::bad_alloc&) |
| 8040 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8041 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8042 | } |
| 8043 | } |
| 8044 | |
| 8045 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 8046 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8047 | 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] | 8048 | |
| 8049 | try |
| 8050 | { |
| 8051 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8052 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8053 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8054 | } |
| 8055 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8056 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8057 | |
| 8058 | if (context) |
| 8059 | { |
| 8060 | GLfloat vals[4] = { x, y, z, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8061 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8062 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8063 | } |
| 8064 | catch(std::bad_alloc&) |
| 8065 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8066 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8067 | } |
| 8068 | } |
| 8069 | |
| 8070 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 8071 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8072 | 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] | 8073 | |
| 8074 | try |
| 8075 | { |
| 8076 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8077 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8078 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8079 | } |
| 8080 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8081 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8082 | |
| 8083 | if (context) |
| 8084 | { |
| 8085 | 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] | 8086 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8087 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8088 | } |
| 8089 | catch(std::bad_alloc&) |
| 8090 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8091 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8092 | } |
| 8093 | } |
| 8094 | |
| 8095 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 8096 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8097 | 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] | 8098 | |
| 8099 | try |
| 8100 | { |
| 8101 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8102 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8103 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8104 | } |
| 8105 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8106 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8107 | |
| 8108 | if (context) |
| 8109 | { |
| 8110 | GLfloat vals[4] = { x, y, z, w }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8111 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8112 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8113 | } |
| 8114 | catch(std::bad_alloc&) |
| 8115 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8116 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8117 | } |
| 8118 | } |
| 8119 | |
| 8120 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 8121 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8122 | 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] | 8123 | |
| 8124 | try |
| 8125 | { |
| 8126 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8127 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8128 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8129 | } |
| 8130 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8131 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8132 | |
| 8133 | if (context) |
| 8134 | { |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8135 | context->setVertexAttribf(index, values); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8136 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8137 | } |
| 8138 | catch(std::bad_alloc&) |
| 8139 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8140 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8141 | } |
| 8142 | } |
| 8143 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8144 | void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
| 8145 | { |
| 8146 | EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor); |
| 8147 | |
| 8148 | try |
| 8149 | { |
| 8150 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8151 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8152 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8153 | } |
| 8154 | |
| 8155 | gl::Context *context = gl::getNonLostContext(); |
| 8156 | |
| 8157 | if (context) |
| 8158 | { |
| 8159 | context->setVertexAttribDivisor(index, divisor); |
| 8160 | } |
| 8161 | } |
| 8162 | catch(std::bad_alloc&) |
| 8163 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8164 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8165 | } |
| 8166 | } |
| 8167 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 8168 | 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] | 8169 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8170 | 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] | 8171 | "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] | 8172 | index, size, type, normalized, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8173 | |
| 8174 | try |
| 8175 | { |
| 8176 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8177 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8178 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8179 | } |
| 8180 | |
| 8181 | if (size < 1 || size > 4) |
| 8182 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8183 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8184 | } |
| 8185 | |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 8186 | gl::Context *context = gl::getNonLostContext(); |
| 8187 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8188 | switch (type) |
| 8189 | { |
| 8190 | case GL_BYTE: |
| 8191 | case GL_UNSIGNED_BYTE: |
| 8192 | case GL_SHORT: |
| 8193 | case GL_UNSIGNED_SHORT: |
| 8194 | case GL_FIXED: |
| 8195 | case GL_FLOAT: |
| 8196 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 8197 | case GL_HALF_FLOAT: |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8198 | case GL_INT: |
| 8199 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 8200 | case GL_INT_2_10_10_10_REV: |
| 8201 | 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] | 8202 | if (context && context->getClientVersion() < 3) |
| 8203 | { |
| 8204 | return gl::error(GL_INVALID_ENUM); |
| 8205 | } |
| 8206 | else |
| 8207 | { |
| 8208 | break; |
| 8209 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8210 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8211 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8212 | } |
| 8213 | |
| 8214 | if (stride < 0) |
| 8215 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8216 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8217 | } |
| 8218 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 8219 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 8220 | { |
| 8221 | return gl::error(GL_INVALID_OPERATION); |
| 8222 | } |
| 8223 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8224 | if (context) |
| 8225 | { |
Jamie Madill | d8db866 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 8226 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 8227 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 8228 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 8229 | // and the pointer argument is not NULL. |
| 8230 | if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && ptr != NULL) |
| 8231 | { |
| 8232 | return gl::error(GL_INVALID_OPERATION); |
| 8233 | } |
| 8234 | |
shannon.woods%transgaming.com@gtempaccount.com | 8de4e6a | 2013-04-13 03:37:44 +0000 | [diff] [blame] | 8235 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, |
| 8236 | normalized == GL_TRUE, false, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8237 | } |
| 8238 | } |
| 8239 | catch(std::bad_alloc&) |
| 8240 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8241 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8242 | } |
| 8243 | } |
| 8244 | |
| 8245 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 8246 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8247 | 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] | 8248 | |
| 8249 | try |
| 8250 | { |
| 8251 | if (width < 0 || height < 0) |
| 8252 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8253 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8254 | } |
| 8255 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8256 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8257 | |
| 8258 | if (context) |
| 8259 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 8260 | context->setViewportParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8261 | } |
| 8262 | } |
| 8263 | catch(std::bad_alloc&) |
| 8264 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8265 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8266 | } |
| 8267 | } |
| 8268 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8269 | // OpenGL ES 3.0 functions |
| 8270 | |
| 8271 | void __stdcall glReadBuffer(GLenum mode) |
| 8272 | { |
| 8273 | EVENT("(GLenum mode = 0x%X)", mode); |
| 8274 | |
| 8275 | try |
| 8276 | { |
| 8277 | gl::Context *context = gl::getNonLostContext(); |
| 8278 | |
| 8279 | if (context) |
| 8280 | { |
| 8281 | if (context->getClientVersion() < 3) |
| 8282 | { |
| 8283 | return gl::error(GL_INVALID_OPERATION); |
| 8284 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8285 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8286 | // glReadBuffer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8287 | UNIMPLEMENTED(); |
| 8288 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8289 | } |
| 8290 | catch(std::bad_alloc&) |
| 8291 | { |
| 8292 | return gl::error(GL_OUT_OF_MEMORY); |
| 8293 | } |
| 8294 | } |
| 8295 | |
| 8296 | void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) |
| 8297 | { |
| 8298 | EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, " |
| 8299 | "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices); |
| 8300 | |
| 8301 | try |
| 8302 | { |
| 8303 | gl::Context *context = gl::getNonLostContext(); |
| 8304 | |
| 8305 | if (context) |
| 8306 | { |
| 8307 | if (context->getClientVersion() < 3) |
| 8308 | { |
| 8309 | return gl::error(GL_INVALID_OPERATION); |
| 8310 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8311 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8312 | // glDrawRangeElements |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8313 | UNIMPLEMENTED(); |
| 8314 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8315 | } |
| 8316 | catch(std::bad_alloc&) |
| 8317 | { |
| 8318 | return gl::error(GL_OUT_OF_MEMORY); |
| 8319 | } |
| 8320 | } |
| 8321 | |
| 8322 | void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
| 8323 | { |
| 8324 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8325 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " |
| 8326 | "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8327 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 8328 | |
| 8329 | try |
| 8330 | { |
| 8331 | gl::Context *context = gl::getNonLostContext(); |
| 8332 | |
| 8333 | if (context) |
| 8334 | { |
| 8335 | if (context->getClientVersion() < 3) |
| 8336 | { |
| 8337 | return gl::error(GL_INVALID_OPERATION); |
| 8338 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8339 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8340 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8341 | if (!validateES3TexImageParameters(context, target, level, internalformat, false, false, |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8342 | 0, 0, 0, width, height, depth, border, format, type)) |
| 8343 | { |
| 8344 | return; |
| 8345 | } |
| 8346 | |
| 8347 | switch(target) |
| 8348 | { |
| 8349 | case GL_TEXTURE_3D: |
| 8350 | { |
| 8351 | gl::Texture3D *texture = context->getTexture3D(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8352 | 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] | 8353 | } |
| 8354 | break; |
| 8355 | |
| 8356 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8357 | { |
| 8358 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8359 | 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] | 8360 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8361 | break; |
| 8362 | |
| 8363 | default: |
| 8364 | return gl::error(GL_INVALID_ENUM); |
| 8365 | } |
| 8366 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8367 | } |
| 8368 | catch(std::bad_alloc&) |
| 8369 | { |
| 8370 | return gl::error(GL_OUT_OF_MEMORY); |
| 8371 | } |
| 8372 | } |
| 8373 | |
| 8374 | 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) |
| 8375 | { |
| 8376 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8377 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8378 | "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8379 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); |
| 8380 | |
| 8381 | try |
| 8382 | { |
| 8383 | gl::Context *context = gl::getNonLostContext(); |
| 8384 | |
| 8385 | if (context) |
| 8386 | { |
| 8387 | if (context->getClientVersion() < 3) |
| 8388 | { |
| 8389 | return gl::error(GL_INVALID_OPERATION); |
| 8390 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8391 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8392 | if (!pixels) |
| 8393 | { |
| 8394 | return gl::error(GL_INVALID_VALUE); |
| 8395 | } |
| 8396 | |
| 8397 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8398 | 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] | 8399 | xoffset, yoffset, zoffset, width, height, depth, 0, |
| 8400 | format, type)) |
| 8401 | { |
| 8402 | return; |
| 8403 | } |
| 8404 | |
| 8405 | switch(target) |
| 8406 | { |
| 8407 | case GL_TEXTURE_3D: |
| 8408 | { |
| 8409 | gl::Texture3D *texture = context->getTexture3D(); |
| 8410 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8411 | } |
| 8412 | break; |
| 8413 | |
| 8414 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8415 | { |
| 8416 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8417 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8418 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8419 | break; |
| 8420 | |
| 8421 | default: |
| 8422 | return gl::error(GL_INVALID_ENUM); |
| 8423 | } |
| 8424 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8425 | } |
| 8426 | catch(std::bad_alloc&) |
| 8427 | { |
| 8428 | return gl::error(GL_OUT_OF_MEMORY); |
| 8429 | } |
| 8430 | } |
| 8431 | |
| 8432 | void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 8433 | { |
| 8434 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8435 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 8436 | target, level, xoffset, yoffset, zoffset, x, y, width, height); |
| 8437 | |
| 8438 | try |
| 8439 | { |
| 8440 | gl::Context *context = gl::getNonLostContext(); |
| 8441 | |
| 8442 | if (context) |
| 8443 | { |
| 8444 | if (context->getClientVersion() < 3) |
| 8445 | { |
| 8446 | return gl::error(GL_INVALID_OPERATION); |
| 8447 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8448 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8449 | if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset, |
| 8450 | x, y, width, height, 0)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8451 | { |
| 8452 | return; |
| 8453 | } |
| 8454 | |
| 8455 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 8456 | gl::Texture *texture = NULL; |
| 8457 | switch (target) |
| 8458 | { |
| 8459 | case GL_TEXTURE_3D: |
| 8460 | texture = context->getTexture3D(); |
| 8461 | break; |
| 8462 | |
| 8463 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8464 | texture = context->getTexture2DArray(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8465 | break; |
| 8466 | |
| 8467 | default: |
| 8468 | return gl::error(GL_INVALID_ENUM); |
| 8469 | } |
| 8470 | |
| 8471 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer); |
| 8472 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8473 | } |
| 8474 | catch(std::bad_alloc&) |
| 8475 | { |
| 8476 | return gl::error(GL_OUT_OF_MEMORY); |
| 8477 | } |
| 8478 | } |
| 8479 | |
| 8480 | void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) |
| 8481 | { |
| 8482 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8483 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, " |
| 8484 | "const GLvoid* data = 0x%0.8p)", |
| 8485 | target, level, internalformat, width, height, depth, border, imageSize, data); |
| 8486 | |
| 8487 | try |
| 8488 | { |
| 8489 | gl::Context *context = gl::getNonLostContext(); |
| 8490 | |
| 8491 | if (context) |
| 8492 | { |
| 8493 | if (context->getClientVersion() < 3) |
| 8494 | { |
| 8495 | return gl::error(GL_INVALID_OPERATION); |
| 8496 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8497 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8498 | 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] | 8499 | { |
| 8500 | return gl::error(GL_INVALID_VALUE); |
| 8501 | } |
| 8502 | |
| 8503 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8504 | if (!validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 8505 | 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] | 8506 | { |
| 8507 | return; |
| 8508 | } |
| 8509 | |
| 8510 | switch(target) |
| 8511 | { |
| 8512 | case GL_TEXTURE_3D: |
| 8513 | { |
| 8514 | gl::Texture3D *texture = context->getTexture3D(); |
| 8515 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8516 | } |
| 8517 | break; |
| 8518 | |
| 8519 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8520 | { |
| 8521 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8522 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8523 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8524 | break; |
| 8525 | |
| 8526 | default: |
| 8527 | return gl::error(GL_INVALID_ENUM); |
| 8528 | } |
| 8529 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8530 | } |
| 8531 | catch(std::bad_alloc&) |
| 8532 | { |
| 8533 | return gl::error(GL_OUT_OF_MEMORY); |
| 8534 | } |
| 8535 | } |
| 8536 | |
| 8537 | 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) |
| 8538 | { |
| 8539 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8540 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8541 | "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 8542 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); |
| 8543 | |
| 8544 | try |
| 8545 | { |
| 8546 | gl::Context *context = gl::getNonLostContext(); |
| 8547 | |
| 8548 | if (context) |
| 8549 | { |
| 8550 | if (context->getClientVersion() < 3) |
| 8551 | { |
| 8552 | return gl::error(GL_INVALID_OPERATION); |
| 8553 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8554 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8555 | 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] | 8556 | { |
| 8557 | return gl::error(GL_INVALID_VALUE); |
| 8558 | } |
| 8559 | |
| 8560 | if (!data) |
| 8561 | { |
| 8562 | return gl::error(GL_INVALID_VALUE); |
| 8563 | } |
| 8564 | |
| 8565 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8566 | if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 8567 | 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] | 8568 | { |
| 8569 | return; |
| 8570 | } |
| 8571 | |
| 8572 | switch(target) |
| 8573 | { |
| 8574 | case GL_TEXTURE_3D: |
| 8575 | { |
| 8576 | gl::Texture3D *texture = context->getTexture3D(); |
| 8577 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8578 | format, imageSize, data); |
| 8579 | } |
| 8580 | break; |
| 8581 | |
| 8582 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8583 | { |
| 8584 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8585 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8586 | format, imageSize, data); |
| 8587 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8588 | break; |
| 8589 | |
| 8590 | default: |
| 8591 | return gl::error(GL_INVALID_ENUM); |
| 8592 | } |
| 8593 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8594 | } |
| 8595 | catch(std::bad_alloc&) |
| 8596 | { |
| 8597 | return gl::error(GL_OUT_OF_MEMORY); |
| 8598 | } |
| 8599 | } |
| 8600 | |
| 8601 | void __stdcall glGenQueries(GLsizei n, GLuint* ids) |
| 8602 | { |
| 8603 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8604 | |
| 8605 | try |
| 8606 | { |
| 8607 | gl::Context *context = gl::getNonLostContext(); |
| 8608 | |
| 8609 | if (context) |
| 8610 | { |
| 8611 | if (context->getClientVersion() < 3) |
| 8612 | { |
| 8613 | return gl::error(GL_INVALID_OPERATION); |
| 8614 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8615 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8616 | // glGenQueries |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8617 | UNIMPLEMENTED(); |
| 8618 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8619 | } |
| 8620 | catch(std::bad_alloc&) |
| 8621 | { |
| 8622 | return gl::error(GL_OUT_OF_MEMORY); |
| 8623 | } |
| 8624 | } |
| 8625 | |
| 8626 | void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids) |
| 8627 | { |
| 8628 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8629 | |
| 8630 | try |
| 8631 | { |
| 8632 | gl::Context *context = gl::getNonLostContext(); |
| 8633 | |
| 8634 | if (context) |
| 8635 | { |
| 8636 | if (context->getClientVersion() < 3) |
| 8637 | { |
| 8638 | return gl::error(GL_INVALID_OPERATION); |
| 8639 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8640 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8641 | // glDeleteQueries |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8642 | UNIMPLEMENTED(); |
| 8643 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8644 | } |
| 8645 | catch(std::bad_alloc&) |
| 8646 | { |
| 8647 | return gl::error(GL_OUT_OF_MEMORY); |
| 8648 | } |
| 8649 | } |
| 8650 | |
| 8651 | GLboolean __stdcall glIsQuery(GLuint id) |
| 8652 | { |
| 8653 | EVENT("(GLuint id = %u)", id); |
| 8654 | |
| 8655 | try |
| 8656 | { |
| 8657 | gl::Context *context = gl::getNonLostContext(); |
| 8658 | |
| 8659 | if (context) |
| 8660 | { |
| 8661 | if (context->getClientVersion() < 3) |
| 8662 | { |
| 8663 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8664 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8665 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8666 | // glIsQuery |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8667 | UNIMPLEMENTED(); |
| 8668 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8669 | } |
| 8670 | catch(std::bad_alloc&) |
| 8671 | { |
| 8672 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8673 | } |
| 8674 | |
| 8675 | return GL_FALSE; |
| 8676 | } |
| 8677 | |
| 8678 | void __stdcall glBeginQuery(GLenum target, GLuint id) |
| 8679 | { |
| 8680 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 8681 | |
| 8682 | try |
| 8683 | { |
| 8684 | gl::Context *context = gl::getNonLostContext(); |
| 8685 | |
| 8686 | if (context) |
| 8687 | { |
| 8688 | if (context->getClientVersion() < 3) |
| 8689 | { |
| 8690 | return gl::error(GL_INVALID_OPERATION); |
| 8691 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8692 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8693 | // glBeginQuery |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8694 | UNIMPLEMENTED(); |
| 8695 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8696 | } |
| 8697 | catch(std::bad_alloc&) |
| 8698 | { |
| 8699 | return gl::error(GL_OUT_OF_MEMORY); |
| 8700 | } |
| 8701 | } |
| 8702 | |
| 8703 | void __stdcall glEndQuery(GLenum target) |
| 8704 | { |
| 8705 | EVENT("(GLenum target = 0x%X)", target); |
| 8706 | |
| 8707 | try |
| 8708 | { |
| 8709 | gl::Context *context = gl::getNonLostContext(); |
| 8710 | |
| 8711 | if (context) |
| 8712 | { |
| 8713 | if (context->getClientVersion() < 3) |
| 8714 | { |
| 8715 | return gl::error(GL_INVALID_OPERATION); |
| 8716 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8717 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8718 | // glEndQuery |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8719 | UNIMPLEMENTED(); |
| 8720 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8721 | } |
| 8722 | catch(std::bad_alloc&) |
| 8723 | { |
| 8724 | return gl::error(GL_OUT_OF_MEMORY); |
| 8725 | } |
| 8726 | } |
| 8727 | |
| 8728 | void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params) |
| 8729 | { |
| 8730 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
| 8731 | |
| 8732 | try |
| 8733 | { |
| 8734 | gl::Context *context = gl::getNonLostContext(); |
| 8735 | |
| 8736 | if (context) |
| 8737 | { |
| 8738 | if (context->getClientVersion() < 3) |
| 8739 | { |
| 8740 | return gl::error(GL_INVALID_OPERATION); |
| 8741 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8742 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8743 | // glGetQueryiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8744 | UNIMPLEMENTED(); |
| 8745 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8746 | } |
| 8747 | catch(std::bad_alloc&) |
| 8748 | { |
| 8749 | return gl::error(GL_OUT_OF_MEMORY); |
| 8750 | } |
| 8751 | } |
| 8752 | |
| 8753 | void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) |
| 8754 | { |
| 8755 | EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params); |
| 8756 | |
| 8757 | try |
| 8758 | { |
| 8759 | gl::Context *context = gl::getNonLostContext(); |
| 8760 | |
| 8761 | if (context) |
| 8762 | { |
| 8763 | if (context->getClientVersion() < 3) |
| 8764 | { |
| 8765 | return gl::error(GL_INVALID_OPERATION); |
| 8766 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8767 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8768 | // glGetQueryObjectuiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8769 | UNIMPLEMENTED(); |
| 8770 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8771 | } |
| 8772 | catch(std::bad_alloc&) |
| 8773 | { |
| 8774 | return gl::error(GL_OUT_OF_MEMORY); |
| 8775 | } |
| 8776 | } |
| 8777 | |
| 8778 | GLboolean __stdcall glUnmapBuffer(GLenum target) |
| 8779 | { |
| 8780 | EVENT("(GLenum target = 0x%X)", target); |
| 8781 | |
| 8782 | try |
| 8783 | { |
| 8784 | gl::Context *context = gl::getNonLostContext(); |
| 8785 | |
| 8786 | if (context) |
| 8787 | { |
| 8788 | if (context->getClientVersion() < 3) |
| 8789 | { |
| 8790 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8791 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8792 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8793 | // glUnmapBuffer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8794 | UNIMPLEMENTED(); |
| 8795 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8796 | } |
| 8797 | catch(std::bad_alloc&) |
| 8798 | { |
| 8799 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8800 | } |
| 8801 | |
| 8802 | return GL_FALSE; |
| 8803 | } |
| 8804 | |
| 8805 | void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) |
| 8806 | { |
| 8807 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 8808 | |
| 8809 | try |
| 8810 | { |
| 8811 | gl::Context *context = gl::getNonLostContext(); |
| 8812 | |
| 8813 | if (context) |
| 8814 | { |
| 8815 | if (context->getClientVersion() < 3) |
| 8816 | { |
| 8817 | return gl::error(GL_INVALID_OPERATION); |
| 8818 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8819 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8820 | // glGetBufferPointerv |
shannonwoods@chromium.org | 2d2190a | 2013-05-30 00:17:35 +0000 | [diff] [blame] | 8821 | UNIMPLEMENTED(); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8822 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8823 | } |
| 8824 | catch(std::bad_alloc&) |
| 8825 | { |
| 8826 | return gl::error(GL_OUT_OF_MEMORY); |
| 8827 | } |
| 8828 | } |
| 8829 | |
| 8830 | void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs) |
| 8831 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8832 | try |
| 8833 | { |
| 8834 | gl::Context *context = gl::getNonLostContext(); |
| 8835 | |
| 8836 | if (context) |
| 8837 | { |
| 8838 | if (context->getClientVersion() < 3) |
| 8839 | { |
| 8840 | return gl::error(GL_INVALID_OPERATION); |
| 8841 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8842 | |
shannon.woods%transgaming.com@gtempaccount.com | 7948c5f | 2013-04-13 03:38:58 +0000 | [diff] [blame] | 8843 | glDrawBuffersEXT(n, bufs); |
| 8844 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8845 | } |
| 8846 | catch(std::bad_alloc&) |
| 8847 | { |
| 8848 | return gl::error(GL_OUT_OF_MEMORY); |
| 8849 | } |
| 8850 | } |
| 8851 | |
| 8852 | void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8853 | { |
| 8854 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8855 | location, count, transpose, value); |
| 8856 | |
| 8857 | try |
| 8858 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8859 | if (count < 0) |
| 8860 | { |
| 8861 | return gl::error(GL_INVALID_VALUE); |
| 8862 | } |
| 8863 | |
| 8864 | if (location == -1) |
| 8865 | { |
| 8866 | return; |
| 8867 | } |
| 8868 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8869 | gl::Context *context = gl::getNonLostContext(); |
| 8870 | |
| 8871 | if (context) |
| 8872 | { |
| 8873 | if (context->getClientVersion() < 3) |
| 8874 | { |
| 8875 | return gl::error(GL_INVALID_OPERATION); |
| 8876 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8877 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8878 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8879 | if (!programBinary) |
| 8880 | { |
| 8881 | return gl::error(GL_INVALID_OPERATION); |
| 8882 | } |
| 8883 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8884 | if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8885 | { |
| 8886 | return gl::error(GL_INVALID_OPERATION); |
| 8887 | } |
| 8888 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8889 | } |
| 8890 | catch(std::bad_alloc&) |
| 8891 | { |
| 8892 | return gl::error(GL_OUT_OF_MEMORY); |
| 8893 | } |
| 8894 | } |
| 8895 | |
| 8896 | void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8897 | { |
| 8898 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8899 | location, count, transpose, value); |
| 8900 | |
| 8901 | try |
| 8902 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8903 | if (count < 0) |
| 8904 | { |
| 8905 | return gl::error(GL_INVALID_VALUE); |
| 8906 | } |
| 8907 | |
| 8908 | if (location == -1) |
| 8909 | { |
| 8910 | return; |
| 8911 | } |
| 8912 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8913 | gl::Context *context = gl::getNonLostContext(); |
| 8914 | |
| 8915 | if (context) |
| 8916 | { |
| 8917 | if (context->getClientVersion() < 3) |
| 8918 | { |
| 8919 | return gl::error(GL_INVALID_OPERATION); |
| 8920 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8921 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8922 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8923 | if (!programBinary) |
| 8924 | { |
| 8925 | return gl::error(GL_INVALID_OPERATION); |
| 8926 | } |
| 8927 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8928 | if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8929 | { |
| 8930 | return gl::error(GL_INVALID_OPERATION); |
| 8931 | } |
| 8932 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8933 | } |
| 8934 | catch(std::bad_alloc&) |
| 8935 | { |
| 8936 | return gl::error(GL_OUT_OF_MEMORY); |
| 8937 | } |
| 8938 | } |
| 8939 | |
| 8940 | void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8941 | { |
| 8942 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8943 | location, count, transpose, value); |
| 8944 | |
| 8945 | try |
| 8946 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8947 | if (count < 0) |
| 8948 | { |
| 8949 | return gl::error(GL_INVALID_VALUE); |
| 8950 | } |
| 8951 | |
| 8952 | if (location == -1) |
| 8953 | { |
| 8954 | return; |
| 8955 | } |
| 8956 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8957 | gl::Context *context = gl::getNonLostContext(); |
| 8958 | |
| 8959 | if (context) |
| 8960 | { |
| 8961 | if (context->getClientVersion() < 3) |
| 8962 | { |
| 8963 | return gl::error(GL_INVALID_OPERATION); |
| 8964 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8965 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8966 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8967 | if (!programBinary) |
| 8968 | { |
| 8969 | return gl::error(GL_INVALID_OPERATION); |
| 8970 | } |
| 8971 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8972 | if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8973 | { |
| 8974 | return gl::error(GL_INVALID_OPERATION); |
| 8975 | } |
| 8976 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8977 | } |
| 8978 | catch(std::bad_alloc&) |
| 8979 | { |
| 8980 | return gl::error(GL_OUT_OF_MEMORY); |
| 8981 | } |
| 8982 | } |
| 8983 | |
| 8984 | void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8985 | { |
| 8986 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8987 | location, count, transpose, value); |
| 8988 | |
| 8989 | try |
| 8990 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8991 | if (count < 0) |
| 8992 | { |
| 8993 | return gl::error(GL_INVALID_VALUE); |
| 8994 | } |
| 8995 | |
| 8996 | if (location == -1) |
| 8997 | { |
| 8998 | return; |
| 8999 | } |
| 9000 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9001 | gl::Context *context = gl::getNonLostContext(); |
| 9002 | |
| 9003 | if (context) |
| 9004 | { |
| 9005 | if (context->getClientVersion() < 3) |
| 9006 | { |
| 9007 | return gl::error(GL_INVALID_OPERATION); |
| 9008 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9009 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9010 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9011 | if (!programBinary) |
| 9012 | { |
| 9013 | return gl::error(GL_INVALID_OPERATION); |
| 9014 | } |
| 9015 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9016 | if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9017 | { |
| 9018 | return gl::error(GL_INVALID_OPERATION); |
| 9019 | } |
| 9020 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9021 | } |
| 9022 | catch(std::bad_alloc&) |
| 9023 | { |
| 9024 | return gl::error(GL_OUT_OF_MEMORY); |
| 9025 | } |
| 9026 | } |
| 9027 | |
| 9028 | void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 9029 | { |
| 9030 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 9031 | location, count, transpose, value); |
| 9032 | |
| 9033 | try |
| 9034 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9035 | if (count < 0) |
| 9036 | { |
| 9037 | return gl::error(GL_INVALID_VALUE); |
| 9038 | } |
| 9039 | |
| 9040 | if (location == -1) |
| 9041 | { |
| 9042 | return; |
| 9043 | } |
| 9044 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9045 | gl::Context *context = gl::getNonLostContext(); |
| 9046 | |
| 9047 | if (context) |
| 9048 | { |
| 9049 | if (context->getClientVersion() < 3) |
| 9050 | { |
| 9051 | return gl::error(GL_INVALID_OPERATION); |
| 9052 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9053 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9054 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9055 | if (!programBinary) |
| 9056 | { |
| 9057 | return gl::error(GL_INVALID_OPERATION); |
| 9058 | } |
| 9059 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9060 | if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9061 | { |
| 9062 | return gl::error(GL_INVALID_OPERATION); |
| 9063 | } |
| 9064 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9065 | } |
| 9066 | catch(std::bad_alloc&) |
| 9067 | { |
| 9068 | return gl::error(GL_OUT_OF_MEMORY); |
| 9069 | } |
| 9070 | } |
| 9071 | |
| 9072 | void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 9073 | { |
| 9074 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 9075 | location, count, transpose, value); |
| 9076 | |
| 9077 | try |
| 9078 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9079 | if (count < 0) |
| 9080 | { |
| 9081 | return gl::error(GL_INVALID_VALUE); |
| 9082 | } |
| 9083 | |
| 9084 | if (location == -1) |
| 9085 | { |
| 9086 | return; |
| 9087 | } |
| 9088 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9089 | gl::Context *context = gl::getNonLostContext(); |
| 9090 | |
| 9091 | if (context) |
| 9092 | { |
| 9093 | if (context->getClientVersion() < 3) |
| 9094 | { |
| 9095 | return gl::error(GL_INVALID_OPERATION); |
| 9096 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9097 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9098 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9099 | if (!programBinary) |
| 9100 | { |
| 9101 | return gl::error(GL_INVALID_OPERATION); |
| 9102 | } |
| 9103 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9104 | if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9105 | { |
| 9106 | return gl::error(GL_INVALID_OPERATION); |
| 9107 | } |
| 9108 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9109 | } |
| 9110 | catch(std::bad_alloc&) |
| 9111 | { |
| 9112 | return gl::error(GL_OUT_OF_MEMORY); |
| 9113 | } |
| 9114 | } |
| 9115 | |
| 9116 | void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) |
| 9117 | { |
| 9118 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, " |
| 9119 | "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 9120 | srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 9121 | |
| 9122 | try |
| 9123 | { |
| 9124 | gl::Context *context = gl::getNonLostContext(); |
| 9125 | |
| 9126 | if (context) |
| 9127 | { |
| 9128 | if (context->getClientVersion() < 3) |
| 9129 | { |
| 9130 | return gl::error(GL_INVALID_OPERATION); |
| 9131 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9132 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 9133 | if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 9134 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 9135 | false)) |
| 9136 | { |
| 9137 | return; |
| 9138 | } |
| 9139 | |
| 9140 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 9141 | mask, filter); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9142 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9143 | } |
| 9144 | catch(std::bad_alloc&) |
| 9145 | { |
| 9146 | return gl::error(GL_OUT_OF_MEMORY); |
| 9147 | } |
| 9148 | } |
| 9149 | |
| 9150 | void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| 9151 | { |
| 9152 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 9153 | target, samples, internalformat, width, height); |
| 9154 | |
| 9155 | try |
| 9156 | { |
| 9157 | gl::Context *context = gl::getNonLostContext(); |
| 9158 | |
| 9159 | if (context) |
| 9160 | { |
| 9161 | if (context->getClientVersion() < 3) |
| 9162 | { |
| 9163 | return gl::error(GL_INVALID_OPERATION); |
| 9164 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9165 | |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 9166 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 9167 | width, height, false)) |
| 9168 | { |
| 9169 | return; |
| 9170 | } |
| 9171 | |
| 9172 | context->setRenderbufferStorage(width, height, internalformat, samples); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9173 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9174 | } |
| 9175 | catch(std::bad_alloc&) |
| 9176 | { |
| 9177 | return gl::error(GL_OUT_OF_MEMORY); |
| 9178 | } |
| 9179 | } |
| 9180 | |
| 9181 | void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) |
| 9182 | { |
| 9183 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)", |
| 9184 | target, attachment, texture, level, layer); |
| 9185 | |
| 9186 | try |
| 9187 | { |
| 9188 | gl::Context *context = gl::getNonLostContext(); |
| 9189 | |
| 9190 | if (context) |
| 9191 | { |
| 9192 | if (context->getClientVersion() < 3) |
| 9193 | { |
| 9194 | return gl::error(GL_INVALID_OPERATION); |
| 9195 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9196 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9197 | // glFramebufferTextureLayer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9198 | UNIMPLEMENTED(); |
| 9199 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9200 | } |
| 9201 | catch(std::bad_alloc&) |
| 9202 | { |
| 9203 | return gl::error(GL_OUT_OF_MEMORY); |
| 9204 | } |
| 9205 | } |
| 9206 | |
| 9207 | GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 9208 | { |
| 9209 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 9210 | target, offset, length, access); |
| 9211 | |
| 9212 | try |
| 9213 | { |
| 9214 | gl::Context *context = gl::getNonLostContext(); |
| 9215 | |
| 9216 | if (context) |
| 9217 | { |
| 9218 | if (context->getClientVersion() < 3) |
| 9219 | { |
| 9220 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 9221 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9222 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9223 | // glMapBufferRange |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9224 | UNIMPLEMENTED(); |
| 9225 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9226 | } |
| 9227 | catch(std::bad_alloc&) |
| 9228 | { |
| 9229 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL)); |
| 9230 | } |
| 9231 | |
| 9232 | return NULL; |
| 9233 | } |
| 9234 | |
| 9235 | void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) |
| 9236 | { |
| 9237 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 9238 | |
| 9239 | try |
| 9240 | { |
| 9241 | gl::Context *context = gl::getNonLostContext(); |
| 9242 | |
| 9243 | if (context) |
| 9244 | { |
| 9245 | if (context->getClientVersion() < 3) |
| 9246 | { |
| 9247 | return gl::error(GL_INVALID_OPERATION); |
| 9248 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9249 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9250 | // glFlushMappedBufferRange |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9251 | UNIMPLEMENTED(); |
| 9252 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9253 | } |
| 9254 | catch(std::bad_alloc&) |
| 9255 | { |
| 9256 | return gl::error(GL_OUT_OF_MEMORY); |
| 9257 | } |
| 9258 | } |
| 9259 | |
| 9260 | void __stdcall glBindVertexArray(GLuint array) |
| 9261 | { |
| 9262 | EVENT("(GLuint array = %u)", array); |
| 9263 | |
| 9264 | try |
| 9265 | { |
| 9266 | gl::Context *context = gl::getNonLostContext(); |
| 9267 | |
| 9268 | if (context) |
| 9269 | { |
| 9270 | if (context->getClientVersion() < 3) |
| 9271 | { |
| 9272 | return gl::error(GL_INVALID_OPERATION); |
| 9273 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9274 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9275 | gl::VertexArray *vao = context->getVertexArray(array); |
| 9276 | |
| 9277 | if (!vao) |
| 9278 | { |
| 9279 | // The default VAO should always exist |
| 9280 | ASSERT(array != 0); |
| 9281 | return gl::error(GL_INVALID_OPERATION); |
| 9282 | } |
| 9283 | |
| 9284 | context->bindVertexArray(array); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9285 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9286 | } |
| 9287 | catch(std::bad_alloc&) |
| 9288 | { |
| 9289 | return gl::error(GL_OUT_OF_MEMORY); |
| 9290 | } |
| 9291 | } |
| 9292 | |
| 9293 | void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) |
| 9294 | { |
| 9295 | EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays); |
| 9296 | |
| 9297 | try |
| 9298 | { |
| 9299 | gl::Context *context = gl::getNonLostContext(); |
| 9300 | |
| 9301 | if (context) |
| 9302 | { |
| 9303 | if (context->getClientVersion() < 3) |
| 9304 | { |
| 9305 | return gl::error(GL_INVALID_OPERATION); |
| 9306 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9307 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9308 | if (n < 0) |
| 9309 | { |
| 9310 | return gl::error(GL_INVALID_VALUE); |
| 9311 | } |
| 9312 | |
| 9313 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 9314 | { |
| 9315 | if (arrays[arrayIndex] != 0) |
| 9316 | { |
| 9317 | context->deleteVertexArray(arrays[arrayIndex]); |
| 9318 | } |
| 9319 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9320 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9321 | } |
| 9322 | catch(std::bad_alloc&) |
| 9323 | { |
| 9324 | return gl::error(GL_OUT_OF_MEMORY); |
| 9325 | } |
| 9326 | } |
| 9327 | |
| 9328 | void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) |
| 9329 | { |
| 9330 | EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays); |
| 9331 | |
| 9332 | try |
| 9333 | { |
| 9334 | gl::Context *context = gl::getNonLostContext(); |
| 9335 | |
| 9336 | if (context) |
| 9337 | { |
| 9338 | if (context->getClientVersion() < 3) |
| 9339 | { |
| 9340 | return gl::error(GL_INVALID_OPERATION); |
| 9341 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9342 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9343 | if (n < 0) |
| 9344 | { |
| 9345 | return gl::error(GL_INVALID_VALUE); |
| 9346 | } |
| 9347 | |
| 9348 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 9349 | { |
| 9350 | arrays[arrayIndex] = context->createVertexArray(); |
| 9351 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9352 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9353 | } |
| 9354 | catch(std::bad_alloc&) |
| 9355 | { |
| 9356 | return gl::error(GL_OUT_OF_MEMORY); |
| 9357 | } |
| 9358 | } |
| 9359 | |
| 9360 | GLboolean __stdcall glIsVertexArray(GLuint array) |
| 9361 | { |
| 9362 | EVENT("(GLuint array = %u)", array); |
| 9363 | |
| 9364 | try |
| 9365 | { |
| 9366 | gl::Context *context = gl::getNonLostContext(); |
| 9367 | |
| 9368 | if (context) |
| 9369 | { |
| 9370 | if (context->getClientVersion() < 3) |
| 9371 | { |
| 9372 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 9373 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9374 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9375 | if (array == 0) |
| 9376 | { |
| 9377 | return GL_FALSE; |
| 9378 | } |
| 9379 | |
| 9380 | gl::VertexArray *vao = context->getVertexArray(array); |
| 9381 | |
| 9382 | return (vao != NULL ? GL_TRUE : GL_FALSE); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9383 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9384 | } |
| 9385 | catch(std::bad_alloc&) |
| 9386 | { |
| 9387 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 9388 | } |
| 9389 | |
| 9390 | return GL_FALSE; |
| 9391 | } |
| 9392 | |
| 9393 | void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data) |
| 9394 | { |
| 9395 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)", |
| 9396 | target, index, data); |
| 9397 | |
| 9398 | try |
| 9399 | { |
| 9400 | gl::Context *context = gl::getNonLostContext(); |
| 9401 | |
| 9402 | if (context) |
| 9403 | { |
| 9404 | if (context->getClientVersion() < 3) |
| 9405 | { |
| 9406 | return gl::error(GL_INVALID_OPERATION); |
| 9407 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9408 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9409 | // glGetIntegeri_v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9410 | UNIMPLEMENTED(); |
| 9411 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9412 | } |
| 9413 | catch(std::bad_alloc&) |
| 9414 | { |
| 9415 | return gl::error(GL_OUT_OF_MEMORY); |
| 9416 | } |
| 9417 | } |
| 9418 | |
| 9419 | void __stdcall glBeginTransformFeedback(GLenum primitiveMode) |
| 9420 | { |
| 9421 | EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode); |
| 9422 | |
| 9423 | try |
| 9424 | { |
| 9425 | gl::Context *context = gl::getNonLostContext(); |
| 9426 | |
| 9427 | if (context) |
| 9428 | { |
| 9429 | if (context->getClientVersion() < 3) |
| 9430 | { |
| 9431 | return gl::error(GL_INVALID_OPERATION); |
| 9432 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9433 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9434 | // glBeginTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9435 | UNIMPLEMENTED(); |
| 9436 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9437 | } |
| 9438 | catch(std::bad_alloc&) |
| 9439 | { |
| 9440 | return gl::error(GL_OUT_OF_MEMORY); |
| 9441 | } |
| 9442 | } |
| 9443 | |
| 9444 | void __stdcall glEndTransformFeedback(void) |
| 9445 | { |
| 9446 | EVENT("(void)"); |
| 9447 | |
| 9448 | try |
| 9449 | { |
| 9450 | gl::Context *context = gl::getNonLostContext(); |
| 9451 | |
| 9452 | if (context) |
| 9453 | { |
| 9454 | if (context->getClientVersion() < 3) |
| 9455 | { |
| 9456 | return gl::error(GL_INVALID_OPERATION); |
| 9457 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9458 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9459 | // glEndTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9460 | UNIMPLEMENTED(); |
| 9461 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9462 | } |
| 9463 | catch(std::bad_alloc&) |
| 9464 | { |
| 9465 | return gl::error(GL_OUT_OF_MEMORY); |
| 9466 | } |
| 9467 | } |
| 9468 | |
| 9469 | void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
| 9470 | { |
| 9471 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)", |
| 9472 | target, index, buffer, offset, size); |
| 9473 | |
| 9474 | try |
| 9475 | { |
| 9476 | gl::Context *context = gl::getNonLostContext(); |
| 9477 | |
| 9478 | if (context) |
| 9479 | { |
| 9480 | if (context->getClientVersion() < 3) |
| 9481 | { |
| 9482 | return gl::error(GL_INVALID_OPERATION); |
| 9483 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9484 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9485 | switch (target) |
| 9486 | { |
| 9487 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9488 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9489 | { |
| 9490 | return gl::error(GL_INVALID_VALUE); |
| 9491 | } |
| 9492 | break; |
| 9493 | |
| 9494 | case GL_UNIFORM_BUFFER: |
| 9495 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 9496 | { |
| 9497 | return gl::error(GL_INVALID_VALUE); |
| 9498 | } |
| 9499 | break; |
| 9500 | |
| 9501 | default: |
| 9502 | return gl::error(GL_INVALID_ENUM); |
| 9503 | } |
| 9504 | |
shannonwoods@chromium.org | e6e0079 | 2013-05-30 00:06:07 +0000 | [diff] [blame] | 9505 | if (buffer != 0 && size <= 0) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9506 | { |
| 9507 | return gl::error(GL_INVALID_VALUE); |
| 9508 | } |
| 9509 | |
| 9510 | switch (target) |
| 9511 | { |
| 9512 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | a26aeaf | 2013-05-30 00:06:13 +0000 | [diff] [blame] | 9513 | |
| 9514 | // size and offset must be a multiple of 4 |
| 9515 | if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) |
| 9516 | { |
| 9517 | return gl::error(GL_INVALID_VALUE); |
| 9518 | } |
| 9519 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9520 | context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 9521 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9522 | break; |
| 9523 | |
| 9524 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 97c3d50 | 2013-05-30 00:04:34 +0000 | [diff] [blame] | 9525 | |
| 9526 | // it is an error to bind an offset not a multiple of the alignment |
| 9527 | if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0) |
| 9528 | { |
| 9529 | return gl::error(GL_INVALID_VALUE); |
| 9530 | } |
| 9531 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9532 | context->bindIndexedUniformBuffer(buffer, index, offset, size); |
| 9533 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9534 | break; |
| 9535 | |
| 9536 | default: |
| 9537 | UNREACHABLE(); |
| 9538 | } |
| 9539 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9540 | } |
| 9541 | catch(std::bad_alloc&) |
| 9542 | { |
| 9543 | return gl::error(GL_OUT_OF_MEMORY); |
| 9544 | } |
| 9545 | } |
| 9546 | |
| 9547 | void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 9548 | { |
| 9549 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)", |
| 9550 | target, index, buffer); |
| 9551 | |
| 9552 | try |
| 9553 | { |
| 9554 | gl::Context *context = gl::getNonLostContext(); |
| 9555 | |
| 9556 | if (context) |
| 9557 | { |
| 9558 | if (context->getClientVersion() < 3) |
| 9559 | { |
| 9560 | return gl::error(GL_INVALID_OPERATION); |
| 9561 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9562 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9563 | switch (target) |
| 9564 | { |
| 9565 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9566 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9567 | { |
| 9568 | return gl::error(GL_INVALID_VALUE); |
| 9569 | } |
| 9570 | break; |
| 9571 | |
| 9572 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9573 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9574 | { |
| 9575 | return gl::error(GL_INVALID_VALUE); |
| 9576 | } |
| 9577 | break; |
| 9578 | |
| 9579 | default: |
| 9580 | return gl::error(GL_INVALID_ENUM); |
| 9581 | } |
| 9582 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9583 | switch (target) |
| 9584 | { |
| 9585 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9586 | context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9587 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9588 | break; |
| 9589 | |
| 9590 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9591 | context->bindIndexedUniformBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9592 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9593 | break; |
| 9594 | |
| 9595 | default: |
| 9596 | UNREACHABLE(); |
| 9597 | } |
| 9598 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9599 | } |
| 9600 | catch(std::bad_alloc&) |
| 9601 | { |
| 9602 | return gl::error(GL_OUT_OF_MEMORY); |
| 9603 | } |
| 9604 | } |
| 9605 | |
| 9606 | void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
| 9607 | { |
| 9608 | EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)", |
| 9609 | program, count, varyings, bufferMode); |
| 9610 | |
| 9611 | try |
| 9612 | { |
| 9613 | gl::Context *context = gl::getNonLostContext(); |
| 9614 | |
| 9615 | if (context) |
| 9616 | { |
| 9617 | if (context->getClientVersion() < 3) |
| 9618 | { |
| 9619 | return gl::error(GL_INVALID_OPERATION); |
| 9620 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9621 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9622 | // glTransformFeedbackVaryings |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9623 | UNIMPLEMENTED(); |
| 9624 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9625 | } |
| 9626 | catch(std::bad_alloc&) |
| 9627 | { |
| 9628 | return gl::error(GL_OUT_OF_MEMORY); |
| 9629 | } |
| 9630 | } |
| 9631 | |
| 9632 | void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
| 9633 | { |
| 9634 | EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, " |
| 9635 | "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
| 9636 | program, index, bufSize, length, size, type, name); |
| 9637 | |
| 9638 | try |
| 9639 | { |
| 9640 | gl::Context *context = gl::getNonLostContext(); |
| 9641 | |
| 9642 | if (context) |
| 9643 | { |
| 9644 | if (context->getClientVersion() < 3) |
| 9645 | { |
| 9646 | return gl::error(GL_INVALID_OPERATION); |
| 9647 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9648 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9649 | // glGetTransformFeedbackVarying |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9650 | UNIMPLEMENTED(); |
| 9651 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9652 | } |
| 9653 | catch(std::bad_alloc&) |
| 9654 | { |
| 9655 | return gl::error(GL_OUT_OF_MEMORY); |
| 9656 | } |
| 9657 | } |
| 9658 | |
| 9659 | void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) |
| 9660 | { |
| 9661 | EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)", |
| 9662 | index, size, type, stride, pointer); |
| 9663 | |
| 9664 | try |
| 9665 | { |
| 9666 | gl::Context *context = gl::getNonLostContext(); |
| 9667 | |
| 9668 | if (context) |
| 9669 | { |
| 9670 | if (context->getClientVersion() < 3) |
| 9671 | { |
| 9672 | return gl::error(GL_INVALID_OPERATION); |
| 9673 | } |
| 9674 | } |
| 9675 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9676 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9677 | { |
| 9678 | return gl::error(GL_INVALID_VALUE); |
| 9679 | } |
| 9680 | |
| 9681 | if (size < 1 || size > 4) |
| 9682 | { |
| 9683 | return gl::error(GL_INVALID_VALUE); |
| 9684 | } |
| 9685 | |
| 9686 | switch (type) |
| 9687 | { |
| 9688 | case GL_BYTE: |
| 9689 | case GL_UNSIGNED_BYTE: |
| 9690 | case GL_SHORT: |
| 9691 | case GL_UNSIGNED_SHORT: |
| 9692 | case GL_INT: |
| 9693 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9694 | case GL_INT_2_10_10_10_REV: |
| 9695 | 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] | 9696 | break; |
| 9697 | default: |
| 9698 | return gl::error(GL_INVALID_ENUM); |
| 9699 | } |
| 9700 | |
| 9701 | if (stride < 0) |
| 9702 | { |
| 9703 | return gl::error(GL_INVALID_VALUE); |
| 9704 | } |
| 9705 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9706 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 9707 | { |
| 9708 | return gl::error(GL_INVALID_OPERATION); |
| 9709 | } |
| 9710 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9711 | if (context) |
| 9712 | { |
Jamie Madill | d8db866 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9713 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 9714 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 9715 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 9716 | // and the pointer argument is not NULL. |
| 9717 | if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && pointer != NULL) |
| 9718 | { |
| 9719 | return gl::error(GL_INVALID_OPERATION); |
| 9720 | } |
| 9721 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9722 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true, |
| 9723 | stride, pointer); |
| 9724 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9725 | } |
| 9726 | catch(std::bad_alloc&) |
| 9727 | { |
| 9728 | return gl::error(GL_OUT_OF_MEMORY); |
| 9729 | } |
| 9730 | } |
| 9731 | |
| 9732 | void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) |
| 9733 | { |
| 9734 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 9735 | index, pname, params); |
| 9736 | |
| 9737 | try |
| 9738 | { |
| 9739 | gl::Context *context = gl::getNonLostContext(); |
| 9740 | |
| 9741 | if (context) |
| 9742 | { |
| 9743 | if (context->getClientVersion() < 3) |
| 9744 | { |
| 9745 | return gl::error(GL_INVALID_OPERATION); |
| 9746 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9747 | |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 9748 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9749 | { |
| 9750 | return gl::error(GL_INVALID_VALUE); |
| 9751 | } |
| 9752 | |
| 9753 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
| 9754 | |
| 9755 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
| 9756 | { |
| 9757 | return; |
| 9758 | } |
| 9759 | |
| 9760 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 9761 | { |
| 9762 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 9763 | for (int i = 0; i < 4; ++i) |
| 9764 | { |
| 9765 | params[i] = currentValueData.IntValues[i]; |
| 9766 | } |
| 9767 | } |
| 9768 | else |
| 9769 | { |
| 9770 | *params = attribState.querySingleParameter<GLint>(pname); |
| 9771 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9772 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9773 | } |
| 9774 | catch(std::bad_alloc&) |
| 9775 | { |
| 9776 | return gl::error(GL_OUT_OF_MEMORY); |
| 9777 | } |
| 9778 | } |
| 9779 | |
| 9780 | void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) |
| 9781 | { |
| 9782 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)", |
| 9783 | index, pname, params); |
| 9784 | |
| 9785 | try |
| 9786 | { |
| 9787 | gl::Context *context = gl::getNonLostContext(); |
| 9788 | |
| 9789 | if (context) |
| 9790 | { |
| 9791 | if (context->getClientVersion() < 3) |
| 9792 | { |
| 9793 | return gl::error(GL_INVALID_OPERATION); |
| 9794 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9795 | |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 9796 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9797 | { |
| 9798 | return gl::error(GL_INVALID_VALUE); |
| 9799 | } |
| 9800 | |
| 9801 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
| 9802 | |
| 9803 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
| 9804 | { |
| 9805 | return; |
| 9806 | } |
| 9807 | |
| 9808 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 9809 | { |
| 9810 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 9811 | for (int i = 0; i < 4; ++i) |
| 9812 | { |
| 9813 | params[i] = currentValueData.UnsignedIntValues[i]; |
| 9814 | } |
| 9815 | } |
| 9816 | else |
| 9817 | { |
| 9818 | *params = attribState.querySingleParameter<GLuint>(pname); |
| 9819 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9820 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9821 | } |
| 9822 | catch(std::bad_alloc&) |
| 9823 | { |
| 9824 | return gl::error(GL_OUT_OF_MEMORY); |
| 9825 | } |
| 9826 | } |
| 9827 | |
| 9828 | void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 9829 | { |
| 9830 | EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)", |
| 9831 | index, x, y, z, w); |
| 9832 | |
| 9833 | try |
| 9834 | { |
| 9835 | gl::Context *context = gl::getNonLostContext(); |
| 9836 | |
| 9837 | if (context) |
| 9838 | { |
| 9839 | if (context->getClientVersion() < 3) |
| 9840 | { |
| 9841 | return gl::error(GL_INVALID_OPERATION); |
| 9842 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9843 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9844 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9845 | { |
| 9846 | return gl::error(GL_INVALID_VALUE); |
| 9847 | } |
| 9848 | |
| 9849 | GLint vals[4] = { x, y, z, w }; |
| 9850 | context->setVertexAttribi(index, vals); |
| 9851 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9852 | } |
| 9853 | catch(std::bad_alloc&) |
| 9854 | { |
| 9855 | return gl::error(GL_OUT_OF_MEMORY); |
| 9856 | } |
| 9857 | } |
| 9858 | |
| 9859 | void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 9860 | { |
| 9861 | EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)", |
| 9862 | index, x, y, z, w); |
| 9863 | |
| 9864 | try |
| 9865 | { |
| 9866 | gl::Context *context = gl::getNonLostContext(); |
| 9867 | |
| 9868 | if (context) |
| 9869 | { |
| 9870 | if (context->getClientVersion() < 3) |
| 9871 | { |
| 9872 | return gl::error(GL_INVALID_OPERATION); |
| 9873 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9874 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9875 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9876 | { |
| 9877 | return gl::error(GL_INVALID_VALUE); |
| 9878 | } |
| 9879 | |
| 9880 | GLuint vals[4] = { x, y, z, w }; |
| 9881 | context->setVertexAttribu(index, vals); |
| 9882 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9883 | } |
| 9884 | catch(std::bad_alloc&) |
| 9885 | { |
| 9886 | return gl::error(GL_OUT_OF_MEMORY); |
| 9887 | } |
| 9888 | } |
| 9889 | |
| 9890 | void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) |
| 9891 | { |
| 9892 | EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v); |
| 9893 | |
| 9894 | try |
| 9895 | { |
| 9896 | gl::Context *context = gl::getNonLostContext(); |
| 9897 | |
| 9898 | if (context) |
| 9899 | { |
| 9900 | if (context->getClientVersion() < 3) |
| 9901 | { |
| 9902 | return gl::error(GL_INVALID_OPERATION); |
| 9903 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9904 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9905 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9906 | { |
| 9907 | return gl::error(GL_INVALID_VALUE); |
| 9908 | } |
| 9909 | |
| 9910 | context->setVertexAttribi(index, v); |
| 9911 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9912 | } |
| 9913 | catch(std::bad_alloc&) |
| 9914 | { |
| 9915 | return gl::error(GL_OUT_OF_MEMORY); |
| 9916 | } |
| 9917 | } |
| 9918 | |
| 9919 | void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v) |
| 9920 | { |
| 9921 | EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v); |
| 9922 | |
| 9923 | try |
| 9924 | { |
| 9925 | gl::Context *context = gl::getNonLostContext(); |
| 9926 | |
| 9927 | if (context) |
| 9928 | { |
| 9929 | if (context->getClientVersion() < 3) |
| 9930 | { |
| 9931 | return gl::error(GL_INVALID_OPERATION); |
| 9932 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9933 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9934 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9935 | { |
| 9936 | return gl::error(GL_INVALID_VALUE); |
| 9937 | } |
| 9938 | |
| 9939 | context->setVertexAttribu(index, v); |
| 9940 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9941 | } |
| 9942 | catch(std::bad_alloc&) |
| 9943 | { |
| 9944 | return gl::error(GL_OUT_OF_MEMORY); |
| 9945 | } |
| 9946 | } |
| 9947 | |
| 9948 | void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) |
| 9949 | { |
| 9950 | EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)", |
| 9951 | program, location, params); |
| 9952 | |
| 9953 | try |
| 9954 | { |
| 9955 | gl::Context *context = gl::getNonLostContext(); |
| 9956 | |
| 9957 | if (context) |
| 9958 | { |
| 9959 | if (context->getClientVersion() < 3) |
| 9960 | { |
| 9961 | return gl::error(GL_INVALID_OPERATION); |
| 9962 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9963 | |
shannon.woods%transgaming.com@gtempaccount.com | e229012 | 2013-04-13 03:41:07 +0000 | [diff] [blame] | 9964 | if (program == 0) |
| 9965 | { |
| 9966 | return gl::error(GL_INVALID_VALUE); |
| 9967 | } |
| 9968 | |
| 9969 | gl::Program *programObject = context->getProgram(program); |
| 9970 | |
| 9971 | if (!programObject || !programObject->isLinked()) |
| 9972 | { |
| 9973 | return gl::error(GL_INVALID_OPERATION); |
| 9974 | } |
| 9975 | |
| 9976 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9977 | if (!programBinary) |
| 9978 | { |
| 9979 | return gl::error(GL_INVALID_OPERATION); |
| 9980 | } |
| 9981 | |
| 9982 | if (!programBinary->getUniformuiv(location, NULL, params)) |
| 9983 | { |
| 9984 | return gl::error(GL_INVALID_OPERATION); |
| 9985 | } |
| 9986 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9987 | } |
| 9988 | catch(std::bad_alloc&) |
| 9989 | { |
| 9990 | return gl::error(GL_OUT_OF_MEMORY); |
| 9991 | } |
| 9992 | } |
| 9993 | |
| 9994 | GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) |
| 9995 | { |
| 9996 | EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)", |
| 9997 | program, name); |
| 9998 | |
| 9999 | try |
| 10000 | { |
| 10001 | gl::Context *context = gl::getNonLostContext(); |
| 10002 | |
| 10003 | if (context) |
| 10004 | { |
| 10005 | if (context->getClientVersion() < 3) |
| 10006 | { |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame] | 10007 | return gl::error(GL_INVALID_OPERATION, -1); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10008 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10009 | |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame] | 10010 | if (program == 0) |
| 10011 | { |
| 10012 | return gl::error(GL_INVALID_VALUE, -1); |
| 10013 | } |
| 10014 | |
| 10015 | gl::Program *programObject = context->getProgram(program); |
| 10016 | |
| 10017 | if (!programObject || !programObject->isLinked()) |
| 10018 | { |
| 10019 | return gl::error(GL_INVALID_OPERATION, -1); |
| 10020 | } |
| 10021 | |
| 10022 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10023 | if (!programBinary) |
| 10024 | { |
| 10025 | return gl::error(GL_INVALID_OPERATION, -1); |
| 10026 | } |
| 10027 | |
| 10028 | return programBinary->getFragDataLocation(name); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10029 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10030 | } |
| 10031 | catch(std::bad_alloc&) |
| 10032 | { |
| 10033 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10034 | } |
| 10035 | |
| 10036 | return 0; |
| 10037 | } |
| 10038 | |
| 10039 | void __stdcall glUniform1ui(GLint location, GLuint v0) |
| 10040 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10041 | glUniform1uiv(location, 1, &v0); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10042 | } |
| 10043 | |
| 10044 | void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1) |
| 10045 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10046 | const GLuint xy[] = { v0, v1 }; |
| 10047 | glUniform2uiv(location, 1, xy); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10048 | } |
| 10049 | |
| 10050 | void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 10051 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10052 | const GLuint xyz[] = { v0, v1, v2 }; |
| 10053 | glUniform3uiv(location, 1, xyz); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10054 | } |
| 10055 | |
| 10056 | void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 10057 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10058 | const GLuint xyzw[] = { v0, v1, v2, v3 }; |
| 10059 | glUniform4uiv(location, 1, xyzw); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10060 | } |
| 10061 | |
| 10062 | void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) |
| 10063 | { |
| 10064 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 10065 | location, count, value); |
| 10066 | |
| 10067 | try |
| 10068 | { |
| 10069 | gl::Context *context = gl::getNonLostContext(); |
| 10070 | |
| 10071 | if (context) |
| 10072 | { |
| 10073 | if (context->getClientVersion() < 3) |
| 10074 | { |
| 10075 | return gl::error(GL_INVALID_OPERATION); |
| 10076 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10077 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10078 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10079 | if (!programBinary) |
| 10080 | { |
| 10081 | return gl::error(GL_INVALID_OPERATION); |
| 10082 | } |
| 10083 | |
| 10084 | if (!programBinary->setUniform1uiv(location, count, value)) |
| 10085 | { |
| 10086 | return gl::error(GL_INVALID_OPERATION); |
| 10087 | } |
| 10088 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10089 | } |
| 10090 | catch(std::bad_alloc&) |
| 10091 | { |
| 10092 | return gl::error(GL_OUT_OF_MEMORY); |
| 10093 | } |
| 10094 | } |
| 10095 | |
| 10096 | void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) |
| 10097 | { |
| 10098 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 10099 | location, count, value); |
| 10100 | |
| 10101 | try |
| 10102 | { |
| 10103 | gl::Context *context = gl::getNonLostContext(); |
| 10104 | |
| 10105 | if (context) |
| 10106 | { |
| 10107 | if (context->getClientVersion() < 3) |
| 10108 | { |
| 10109 | return gl::error(GL_INVALID_OPERATION); |
| 10110 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10111 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10112 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10113 | if (!programBinary) |
| 10114 | { |
| 10115 | return gl::error(GL_INVALID_OPERATION); |
| 10116 | } |
| 10117 | |
| 10118 | if (!programBinary->setUniform2uiv(location, count, value)) |
| 10119 | { |
| 10120 | return gl::error(GL_INVALID_OPERATION); |
| 10121 | } |
| 10122 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10123 | } |
| 10124 | catch(std::bad_alloc&) |
| 10125 | { |
| 10126 | return gl::error(GL_OUT_OF_MEMORY); |
| 10127 | } |
| 10128 | } |
| 10129 | |
| 10130 | void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) |
| 10131 | { |
| 10132 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)", |
| 10133 | location, count, value); |
| 10134 | |
| 10135 | try |
| 10136 | { |
| 10137 | gl::Context *context = gl::getNonLostContext(); |
| 10138 | |
| 10139 | if (context) |
| 10140 | { |
| 10141 | if (context->getClientVersion() < 3) |
| 10142 | { |
| 10143 | return gl::error(GL_INVALID_OPERATION); |
| 10144 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10145 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10146 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10147 | if (!programBinary) |
| 10148 | { |
| 10149 | return gl::error(GL_INVALID_OPERATION); |
| 10150 | } |
| 10151 | |
| 10152 | if (!programBinary->setUniform3uiv(location, count, value)) |
| 10153 | { |
| 10154 | return gl::error(GL_INVALID_OPERATION); |
| 10155 | } |
| 10156 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10157 | } |
| 10158 | catch(std::bad_alloc&) |
| 10159 | { |
| 10160 | return gl::error(GL_OUT_OF_MEMORY); |
| 10161 | } |
| 10162 | } |
| 10163 | |
| 10164 | void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) |
| 10165 | { |
| 10166 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 10167 | location, count, value); |
| 10168 | |
| 10169 | try |
| 10170 | { |
| 10171 | gl::Context *context = gl::getNonLostContext(); |
| 10172 | |
| 10173 | if (context) |
| 10174 | { |
| 10175 | if (context->getClientVersion() < 3) |
| 10176 | { |
| 10177 | return gl::error(GL_INVALID_OPERATION); |
| 10178 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10179 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10180 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10181 | if (!programBinary) |
| 10182 | { |
| 10183 | return gl::error(GL_INVALID_OPERATION); |
| 10184 | } |
| 10185 | |
| 10186 | if (!programBinary->setUniform4uiv(location, count, value)) |
| 10187 | { |
| 10188 | return gl::error(GL_INVALID_OPERATION); |
| 10189 | } |
| 10190 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10191 | } |
| 10192 | catch(std::bad_alloc&) |
| 10193 | { |
| 10194 | return gl::error(GL_OUT_OF_MEMORY); |
| 10195 | } |
| 10196 | } |
| 10197 | |
| 10198 | void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) |
| 10199 | { |
| 10200 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)", |
| 10201 | buffer, drawbuffer, value); |
| 10202 | |
| 10203 | try |
| 10204 | { |
| 10205 | gl::Context *context = gl::getNonLostContext(); |
| 10206 | |
| 10207 | if (context) |
| 10208 | { |
| 10209 | if (context->getClientVersion() < 3) |
| 10210 | { |
| 10211 | return gl::error(GL_INVALID_OPERATION); |
| 10212 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10213 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10214 | // glClearBufferiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10215 | UNIMPLEMENTED(); |
| 10216 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10217 | } |
| 10218 | catch(std::bad_alloc&) |
| 10219 | { |
| 10220 | return gl::error(GL_OUT_OF_MEMORY); |
| 10221 | } |
| 10222 | } |
| 10223 | |
| 10224 | void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) |
| 10225 | { |
| 10226 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)", |
| 10227 | buffer, drawbuffer, value); |
| 10228 | |
| 10229 | try |
| 10230 | { |
| 10231 | gl::Context *context = gl::getNonLostContext(); |
| 10232 | |
| 10233 | if (context) |
| 10234 | { |
| 10235 | if (context->getClientVersion() < 3) |
| 10236 | { |
| 10237 | return gl::error(GL_INVALID_OPERATION); |
| 10238 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10239 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10240 | // glClearBufferuiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10241 | UNIMPLEMENTED(); |
| 10242 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10243 | } |
| 10244 | catch(std::bad_alloc&) |
| 10245 | { |
| 10246 | return gl::error(GL_OUT_OF_MEMORY); |
| 10247 | } |
| 10248 | } |
| 10249 | |
| 10250 | void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) |
| 10251 | { |
| 10252 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)", |
| 10253 | buffer, drawbuffer, value); |
| 10254 | |
| 10255 | try |
| 10256 | { |
| 10257 | gl::Context *context = gl::getNonLostContext(); |
| 10258 | |
| 10259 | if (context) |
| 10260 | { |
| 10261 | if (context->getClientVersion() < 3) |
| 10262 | { |
| 10263 | return gl::error(GL_INVALID_OPERATION); |
| 10264 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10265 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10266 | // glClearBufferfv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10267 | UNIMPLEMENTED(); |
| 10268 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10269 | } |
| 10270 | catch(std::bad_alloc&) |
| 10271 | { |
| 10272 | return gl::error(GL_OUT_OF_MEMORY); |
| 10273 | } |
| 10274 | } |
| 10275 | |
| 10276 | void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 10277 | { |
| 10278 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)", |
| 10279 | buffer, drawbuffer, depth, stencil); |
| 10280 | |
| 10281 | try |
| 10282 | { |
| 10283 | gl::Context *context = gl::getNonLostContext(); |
| 10284 | |
| 10285 | if (context) |
| 10286 | { |
| 10287 | if (context->getClientVersion() < 3) |
| 10288 | { |
| 10289 | return gl::error(GL_INVALID_OPERATION); |
| 10290 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10291 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10292 | // glClearBufferfi |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10293 | UNIMPLEMENTED(); |
| 10294 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10295 | } |
| 10296 | catch(std::bad_alloc&) |
| 10297 | { |
| 10298 | return gl::error(GL_OUT_OF_MEMORY); |
| 10299 | } |
| 10300 | } |
| 10301 | |
| 10302 | const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) |
| 10303 | { |
| 10304 | EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index); |
| 10305 | |
| 10306 | try |
| 10307 | { |
| 10308 | gl::Context *context = gl::getNonLostContext(); |
| 10309 | |
| 10310 | if (context) |
| 10311 | { |
| 10312 | if (context->getClientVersion() < 3) |
| 10313 | { |
| 10314 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL)); |
| 10315 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10316 | |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 10317 | if (name != GL_EXTENSIONS) |
| 10318 | { |
| 10319 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL)); |
| 10320 | } |
| 10321 | |
| 10322 | if (index >= context->getNumExtensions()) |
| 10323 | { |
| 10324 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL)); |
| 10325 | } |
| 10326 | |
| 10327 | return reinterpret_cast<const GLubyte*>(context->getExtensionString(index)); |
| 10328 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10329 | } |
| 10330 | catch(std::bad_alloc&) |
| 10331 | { |
| 10332 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL)); |
| 10333 | } |
| 10334 | |
| 10335 | return NULL; |
| 10336 | } |
| 10337 | |
| 10338 | void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 10339 | { |
| 10340 | EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)", |
| 10341 | readTarget, writeTarget, readOffset, writeOffset, size); |
| 10342 | |
| 10343 | try |
| 10344 | { |
| 10345 | gl::Context *context = gl::getNonLostContext(); |
| 10346 | |
| 10347 | if (context) |
| 10348 | { |
| 10349 | if (context->getClientVersion() < 3) |
| 10350 | { |
| 10351 | return gl::error(GL_INVALID_OPERATION); |
| 10352 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10353 | |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 10354 | gl::Buffer *readBuffer = NULL; |
| 10355 | switch (readTarget) |
| 10356 | { |
| 10357 | case GL_ARRAY_BUFFER: |
| 10358 | readBuffer = context->getArrayBuffer(); |
| 10359 | break; |
| 10360 | case GL_COPY_READ_BUFFER: |
| 10361 | readBuffer = context->getCopyReadBuffer(); |
| 10362 | break; |
| 10363 | case GL_COPY_WRITE_BUFFER: |
| 10364 | readBuffer = context->getCopyWriteBuffer(); |
| 10365 | break; |
| 10366 | case GL_ELEMENT_ARRAY_BUFFER: |
| 10367 | readBuffer = context->getElementArrayBuffer(); |
| 10368 | break; |
| 10369 | case GL_PIXEL_PACK_BUFFER: |
| 10370 | readBuffer = context->getPixelPackBuffer(); |
| 10371 | break; |
| 10372 | case GL_PIXEL_UNPACK_BUFFER: |
| 10373 | readBuffer = context->getPixelUnpackBuffer(); |
| 10374 | break; |
| 10375 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 10376 | readBuffer = context->getGenericTransformFeedbackBuffer(); |
| 10377 | break; |
| 10378 | case GL_UNIFORM_BUFFER: |
| 10379 | readBuffer = context->getGenericUniformBuffer(); |
| 10380 | break; |
| 10381 | default: |
| 10382 | return gl::error(GL_INVALID_ENUM); |
| 10383 | } |
| 10384 | |
| 10385 | gl::Buffer *writeBuffer = NULL; |
| 10386 | switch (writeTarget) |
| 10387 | { |
| 10388 | case GL_ARRAY_BUFFER: |
| 10389 | writeBuffer = context->getArrayBuffer(); |
| 10390 | break; |
| 10391 | case GL_COPY_READ_BUFFER: |
| 10392 | writeBuffer = context->getCopyReadBuffer(); |
| 10393 | break; |
| 10394 | case GL_COPY_WRITE_BUFFER: |
| 10395 | writeBuffer = context->getCopyWriteBuffer(); |
| 10396 | break; |
| 10397 | case GL_ELEMENT_ARRAY_BUFFER: |
| 10398 | writeBuffer = context->getElementArrayBuffer(); |
| 10399 | break; |
| 10400 | case GL_PIXEL_PACK_BUFFER: |
| 10401 | writeBuffer = context->getPixelPackBuffer(); |
| 10402 | break; |
| 10403 | case GL_PIXEL_UNPACK_BUFFER: |
| 10404 | writeBuffer = context->getPixelUnpackBuffer(); |
| 10405 | break; |
| 10406 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 10407 | writeBuffer = context->getGenericTransformFeedbackBuffer(); |
| 10408 | break; |
| 10409 | case GL_UNIFORM_BUFFER: |
| 10410 | writeBuffer = context->getGenericUniformBuffer(); |
| 10411 | break; |
| 10412 | default: |
| 10413 | return gl::error(GL_INVALID_ENUM); |
| 10414 | } |
| 10415 | |
| 10416 | if (!readBuffer || !writeBuffer) |
| 10417 | { |
| 10418 | return gl::error(GL_INVALID_OPERATION); |
| 10419 | } |
| 10420 | |
| 10421 | if (readOffset < 0 || writeOffset < 0 || size < 0 || |
| 10422 | static_cast<unsigned int>(readOffset + size) > readBuffer->size() || |
| 10423 | static_cast<unsigned int>(writeOffset + size) > writeBuffer->size()) |
| 10424 | { |
| 10425 | return gl::error(GL_INVALID_VALUE); |
| 10426 | } |
| 10427 | |
| 10428 | if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size) |
| 10429 | { |
| 10430 | return gl::error(GL_INVALID_VALUE); |
| 10431 | } |
| 10432 | |
| 10433 | // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION) |
| 10434 | |
shannon.woods%transgaming.com@gtempaccount.com | c53376a | 2013-04-13 03:41:23 +0000 | [diff] [blame] | 10435 | // if size is zero, the copy is a successful no-op |
| 10436 | if (size > 0) |
| 10437 | { |
| 10438 | writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); |
| 10439 | } |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 10440 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10441 | } |
| 10442 | catch(std::bad_alloc&) |
| 10443 | { |
| 10444 | return gl::error(GL_OUT_OF_MEMORY); |
| 10445 | } |
| 10446 | } |
| 10447 | |
| 10448 | void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) |
| 10449 | { |
| 10450 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)", |
| 10451 | program, uniformCount, uniformNames, uniformIndices); |
| 10452 | |
| 10453 | try |
| 10454 | { |
| 10455 | gl::Context *context = gl::getNonLostContext(); |
| 10456 | |
| 10457 | if (context) |
| 10458 | { |
| 10459 | if (context->getClientVersion() < 3) |
| 10460 | { |
| 10461 | return gl::error(GL_INVALID_OPERATION); |
| 10462 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10463 | |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 10464 | if (uniformCount < 0) |
| 10465 | { |
| 10466 | return gl::error(GL_INVALID_VALUE); |
| 10467 | } |
| 10468 | |
| 10469 | gl::Program *programObject = context->getProgram(program); |
| 10470 | |
| 10471 | if (!programObject) |
| 10472 | { |
| 10473 | if (context->getShader(program)) |
| 10474 | { |
| 10475 | return gl::error(GL_INVALID_OPERATION); |
| 10476 | } |
| 10477 | else |
| 10478 | { |
| 10479 | return gl::error(GL_INVALID_VALUE); |
| 10480 | } |
| 10481 | } |
| 10482 | |
| 10483 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10484 | if (!programObject->isLinked() || !programBinary) |
| 10485 | { |
| 10486 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10487 | { |
| 10488 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 10489 | } |
| 10490 | } |
| 10491 | else |
| 10492 | { |
| 10493 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10494 | { |
| 10495 | uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]); |
| 10496 | } |
| 10497 | } |
| 10498 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10499 | } |
| 10500 | catch(std::bad_alloc&) |
| 10501 | { |
| 10502 | return gl::error(GL_OUT_OF_MEMORY); |
| 10503 | } |
| 10504 | } |
| 10505 | |
| 10506 | void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) |
| 10507 | { |
| 10508 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10509 | program, uniformCount, uniformIndices, pname, params); |
| 10510 | |
| 10511 | try |
| 10512 | { |
| 10513 | gl::Context *context = gl::getNonLostContext(); |
| 10514 | |
| 10515 | if (context) |
| 10516 | { |
| 10517 | if (context->getClientVersion() < 3) |
| 10518 | { |
| 10519 | return gl::error(GL_INVALID_OPERATION); |
| 10520 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10521 | |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 10522 | if (uniformCount < 0) |
| 10523 | { |
| 10524 | return gl::error(GL_INVALID_VALUE); |
| 10525 | } |
| 10526 | |
| 10527 | gl::Program *programObject = context->getProgram(program); |
| 10528 | |
| 10529 | if (!programObject) |
| 10530 | { |
| 10531 | if (context->getShader(program)) |
| 10532 | { |
| 10533 | return gl::error(GL_INVALID_OPERATION); |
| 10534 | } |
| 10535 | else |
| 10536 | { |
| 10537 | return gl::error(GL_INVALID_VALUE); |
| 10538 | } |
| 10539 | } |
| 10540 | |
| 10541 | switch (pname) |
| 10542 | { |
| 10543 | case GL_UNIFORM_TYPE: |
| 10544 | case GL_UNIFORM_SIZE: |
| 10545 | case GL_UNIFORM_NAME_LENGTH: |
| 10546 | case GL_UNIFORM_BLOCK_INDEX: |
| 10547 | case GL_UNIFORM_OFFSET: |
| 10548 | case GL_UNIFORM_ARRAY_STRIDE: |
| 10549 | case GL_UNIFORM_MATRIX_STRIDE: |
| 10550 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 10551 | break; |
| 10552 | default: |
| 10553 | return gl::error(GL_INVALID_ENUM); |
| 10554 | } |
| 10555 | |
| 10556 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10557 | |
| 10558 | if (!programBinary && uniformCount > 0) |
| 10559 | { |
| 10560 | return gl::error(GL_INVALID_VALUE); |
| 10561 | } |
| 10562 | |
| 10563 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10564 | { |
| 10565 | const GLuint index = uniformIndices[uniformId]; |
| 10566 | |
| 10567 | if (index >= (GLuint)programBinary->getActiveUniformCount()) |
| 10568 | { |
| 10569 | return gl::error(GL_INVALID_VALUE); |
| 10570 | } |
| 10571 | } |
| 10572 | |
| 10573 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10574 | { |
| 10575 | const GLuint index = uniformIndices[uniformId]; |
| 10576 | params[uniformId] = programBinary->getActiveUniformi(index, pname); |
| 10577 | } |
| 10578 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10579 | } |
| 10580 | catch(std::bad_alloc&) |
| 10581 | { |
| 10582 | return gl::error(GL_OUT_OF_MEMORY); |
| 10583 | } |
| 10584 | } |
| 10585 | |
| 10586 | GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) |
| 10587 | { |
| 10588 | EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName); |
| 10589 | |
| 10590 | try |
| 10591 | { |
| 10592 | gl::Context *context = gl::getNonLostContext(); |
| 10593 | |
| 10594 | if (context) |
| 10595 | { |
| 10596 | if (context->getClientVersion() < 3) |
| 10597 | { |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10598 | 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] | 10599 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10600 | |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10601 | gl::Program *programObject = context->getProgram(program); |
| 10602 | |
| 10603 | if (!programObject) |
| 10604 | { |
| 10605 | if (context->getShader(program)) |
| 10606 | { |
| 10607 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
| 10608 | } |
| 10609 | else |
| 10610 | { |
| 10611 | return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX); |
| 10612 | } |
| 10613 | } |
| 10614 | |
| 10615 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10616 | if (!programBinary) |
| 10617 | { |
| 10618 | return GL_INVALID_INDEX; |
| 10619 | } |
| 10620 | |
| 10621 | return programBinary->getUniformBlockIndex(uniformBlockName); |
| 10622 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10623 | } |
| 10624 | catch(std::bad_alloc&) |
| 10625 | { |
| 10626 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10627 | } |
| 10628 | |
| 10629 | return 0; |
| 10630 | } |
| 10631 | |
| 10632 | void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) |
| 10633 | { |
| 10634 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10635 | program, uniformBlockIndex, pname, params); |
| 10636 | |
| 10637 | try |
| 10638 | { |
| 10639 | gl::Context *context = gl::getNonLostContext(); |
| 10640 | |
| 10641 | if (context) |
| 10642 | { |
| 10643 | if (context->getClientVersion() < 3) |
| 10644 | { |
| 10645 | return gl::error(GL_INVALID_OPERATION); |
| 10646 | } |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10647 | gl::Program *programObject = context->getProgram(program); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10648 | |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10649 | if (!programObject) |
| 10650 | { |
| 10651 | if (context->getShader(program)) |
| 10652 | { |
| 10653 | return gl::error(GL_INVALID_OPERATION); |
| 10654 | } |
| 10655 | else |
| 10656 | { |
| 10657 | return gl::error(GL_INVALID_VALUE); |
| 10658 | } |
| 10659 | } |
| 10660 | |
| 10661 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10662 | |
| 10663 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10664 | { |
| 10665 | return gl::error(GL_INVALID_VALUE); |
| 10666 | } |
| 10667 | |
| 10668 | switch (pname) |
| 10669 | { |
| 10670 | case GL_UNIFORM_BLOCK_BINDING: |
| 10671 | *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); |
| 10672 | break; |
| 10673 | |
| 10674 | case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 10675 | case GL_UNIFORM_BLOCK_NAME_LENGTH: |
| 10676 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 10677 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| 10678 | case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
| 10679 | case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
| 10680 | programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params); |
| 10681 | break; |
| 10682 | |
| 10683 | default: |
| 10684 | return gl::error(GL_INVALID_ENUM); |
| 10685 | } |
| 10686 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10687 | } |
| 10688 | catch(std::bad_alloc&) |
| 10689 | { |
| 10690 | return gl::error(GL_OUT_OF_MEMORY); |
| 10691 | } |
| 10692 | } |
| 10693 | |
| 10694 | void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) |
| 10695 | { |
| 10696 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)", |
| 10697 | program, uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10698 | |
| 10699 | try |
| 10700 | { |
| 10701 | gl::Context *context = gl::getNonLostContext(); |
| 10702 | |
| 10703 | if (context) |
| 10704 | { |
| 10705 | if (context->getClientVersion() < 3) |
| 10706 | { |
| 10707 | return gl::error(GL_INVALID_OPERATION); |
| 10708 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10709 | |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 10710 | gl::Program *programObject = context->getProgram(program); |
| 10711 | |
| 10712 | if (!programObject) |
| 10713 | { |
| 10714 | if (context->getShader(program)) |
| 10715 | { |
| 10716 | return gl::error(GL_INVALID_OPERATION); |
| 10717 | } |
| 10718 | else |
| 10719 | { |
| 10720 | return gl::error(GL_INVALID_VALUE); |
| 10721 | } |
| 10722 | } |
| 10723 | |
| 10724 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10725 | |
| 10726 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10727 | { |
| 10728 | return gl::error(GL_INVALID_VALUE); |
| 10729 | } |
| 10730 | |
| 10731 | programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10732 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10733 | } |
| 10734 | catch(std::bad_alloc&) |
| 10735 | { |
| 10736 | return gl::error(GL_OUT_OF_MEMORY); |
| 10737 | } |
| 10738 | } |
| 10739 | |
| 10740 | void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) |
| 10741 | { |
| 10742 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)", |
| 10743 | program, uniformBlockIndex, uniformBlockBinding); |
| 10744 | |
| 10745 | try |
| 10746 | { |
| 10747 | gl::Context *context = gl::getNonLostContext(); |
| 10748 | |
| 10749 | if (context) |
| 10750 | { |
| 10751 | if (context->getClientVersion() < 3) |
| 10752 | { |
| 10753 | return gl::error(GL_INVALID_OPERATION); |
| 10754 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10755 | |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 10756 | if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings()) |
| 10757 | { |
| 10758 | return gl::error(GL_INVALID_VALUE); |
| 10759 | } |
| 10760 | |
| 10761 | gl::Program *programObject = context->getProgram(program); |
| 10762 | |
| 10763 | if (!programObject) |
| 10764 | { |
| 10765 | if (context->getShader(program)) |
| 10766 | { |
| 10767 | return gl::error(GL_INVALID_OPERATION); |
| 10768 | } |
| 10769 | else |
| 10770 | { |
| 10771 | return gl::error(GL_INVALID_VALUE); |
| 10772 | } |
| 10773 | } |
| 10774 | |
| 10775 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10776 | |
| 10777 | // if never linked, there won't be any uniform blocks |
| 10778 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10779 | { |
| 10780 | return gl::error(GL_INVALID_VALUE); |
| 10781 | } |
| 10782 | |
| 10783 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
| 10784 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10785 | } |
| 10786 | catch(std::bad_alloc&) |
| 10787 | { |
| 10788 | return gl::error(GL_OUT_OF_MEMORY); |
| 10789 | } |
| 10790 | } |
| 10791 | |
| 10792 | void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 10793 | { |
| 10794 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)", |
| 10795 | mode, first, count, instanceCount); |
| 10796 | |
| 10797 | try |
| 10798 | { |
| 10799 | gl::Context *context = gl::getNonLostContext(); |
| 10800 | |
| 10801 | if (context) |
| 10802 | { |
| 10803 | if (context->getClientVersion() < 3) |
| 10804 | { |
| 10805 | return gl::error(GL_INVALID_OPERATION); |
| 10806 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10807 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10808 | // glDrawArraysInstanced |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10809 | UNIMPLEMENTED(); |
| 10810 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10811 | } |
| 10812 | catch(std::bad_alloc&) |
| 10813 | { |
| 10814 | return gl::error(GL_OUT_OF_MEMORY); |
| 10815 | } |
| 10816 | } |
| 10817 | |
| 10818 | void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) |
| 10819 | { |
| 10820 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)", |
| 10821 | mode, count, type, indices, instanceCount); |
| 10822 | |
| 10823 | try |
| 10824 | { |
| 10825 | gl::Context *context = gl::getNonLostContext(); |
| 10826 | |
| 10827 | if (context) |
| 10828 | { |
| 10829 | if (context->getClientVersion() < 3) |
| 10830 | { |
| 10831 | return gl::error(GL_INVALID_OPERATION); |
| 10832 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10833 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10834 | // glDrawElementsInstanced |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10835 | UNIMPLEMENTED(); |
| 10836 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10837 | } |
| 10838 | catch(std::bad_alloc&) |
| 10839 | { |
| 10840 | return gl::error(GL_OUT_OF_MEMORY); |
| 10841 | } |
| 10842 | } |
| 10843 | |
| 10844 | GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags) |
| 10845 | { |
| 10846 | EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags); |
| 10847 | |
| 10848 | try |
| 10849 | { |
| 10850 | gl::Context *context = gl::getNonLostContext(); |
| 10851 | |
| 10852 | if (context) |
| 10853 | { |
| 10854 | if (context->getClientVersion() < 3) |
| 10855 | { |
| 10856 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(NULL)); |
| 10857 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10858 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10859 | // glFenceSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10860 | UNIMPLEMENTED(); |
| 10861 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10862 | } |
| 10863 | catch(std::bad_alloc&) |
| 10864 | { |
| 10865 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL)); |
| 10866 | } |
| 10867 | |
| 10868 | return NULL; |
| 10869 | } |
| 10870 | |
| 10871 | GLboolean __stdcall glIsSync(GLsync sync) |
| 10872 | { |
| 10873 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10874 | |
| 10875 | try |
| 10876 | { |
| 10877 | gl::Context *context = gl::getNonLostContext(); |
| 10878 | |
| 10879 | if (context) |
| 10880 | { |
| 10881 | if (context->getClientVersion() < 3) |
| 10882 | { |
| 10883 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10884 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10885 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10886 | // glIsSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10887 | UNIMPLEMENTED(); |
| 10888 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10889 | } |
| 10890 | catch(std::bad_alloc&) |
| 10891 | { |
| 10892 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10893 | } |
| 10894 | |
| 10895 | return GL_FALSE; |
| 10896 | } |
| 10897 | |
| 10898 | void __stdcall glDeleteSync(GLsync sync) |
| 10899 | { |
| 10900 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10901 | |
| 10902 | try |
| 10903 | { |
| 10904 | gl::Context *context = gl::getNonLostContext(); |
| 10905 | |
| 10906 | if (context) |
| 10907 | { |
| 10908 | if (context->getClientVersion() < 3) |
| 10909 | { |
| 10910 | return gl::error(GL_INVALID_OPERATION); |
| 10911 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10912 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10913 | // glDeleteSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10914 | UNIMPLEMENTED(); |
| 10915 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10916 | } |
| 10917 | catch(std::bad_alloc&) |
| 10918 | { |
| 10919 | return gl::error(GL_OUT_OF_MEMORY); |
| 10920 | } |
| 10921 | } |
| 10922 | |
| 10923 | GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10924 | { |
| 10925 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10926 | sync, flags, timeout); |
| 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 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10939 | // glClientWaitSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10940 | UNIMPLEMENTED(); |
| 10941 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10942 | } |
| 10943 | catch(std::bad_alloc&) |
| 10944 | { |
| 10945 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10946 | } |
| 10947 | |
| 10948 | return GL_FALSE; |
| 10949 | } |
| 10950 | |
| 10951 | void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10952 | { |
| 10953 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10954 | sync, flags, timeout); |
| 10955 | |
| 10956 | try |
| 10957 | { |
| 10958 | gl::Context *context = gl::getNonLostContext(); |
| 10959 | |
| 10960 | if (context) |
| 10961 | { |
| 10962 | if (context->getClientVersion() < 3) |
| 10963 | { |
| 10964 | return gl::error(GL_INVALID_OPERATION); |
| 10965 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10966 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10967 | // glWaitSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10968 | UNIMPLEMENTED(); |
| 10969 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10970 | } |
| 10971 | catch(std::bad_alloc&) |
| 10972 | { |
| 10973 | return gl::error(GL_OUT_OF_MEMORY); |
| 10974 | } |
| 10975 | } |
| 10976 | |
| 10977 | void __stdcall glGetInteger64v(GLenum pname, GLint64* params) |
| 10978 | { |
| 10979 | EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10980 | pname, params); |
| 10981 | |
| 10982 | try |
| 10983 | { |
| 10984 | gl::Context *context = gl::getNonLostContext(); |
| 10985 | |
| 10986 | if (context) |
| 10987 | { |
| 10988 | if (context->getClientVersion() < 3) |
| 10989 | { |
| 10990 | return gl::error(GL_INVALID_OPERATION); |
| 10991 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10992 | |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 10993 | if (!(context->getInteger64v(pname, params))) |
| 10994 | { |
| 10995 | GLenum nativeType; |
| 10996 | unsigned int numParams = 0; |
| 10997 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
| 10998 | return gl::error(GL_INVALID_ENUM); |
| 10999 | |
| 11000 | if (numParams == 0) |
| 11001 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 11002 | |
| 11003 | if (nativeType == GL_BOOL) |
| 11004 | { |
| 11005 | GLboolean *boolParams = NULL; |
| 11006 | boolParams = new GLboolean[numParams]; |
| 11007 | |
| 11008 | context->getBooleanv(pname, boolParams); |
| 11009 | |
| 11010 | for (unsigned int i = 0; i < numParams; ++i) |
| 11011 | { |
| 11012 | if (boolParams[i] == GL_FALSE) |
| 11013 | params[i] = 0; |
| 11014 | else |
| 11015 | params[i] = 1; |
| 11016 | } |
| 11017 | |
| 11018 | delete [] boolParams; |
| 11019 | } |
| 11020 | else if (nativeType == GL_INT) |
| 11021 | { |
| 11022 | GLint *intParams = NULL; |
| 11023 | intParams = new GLint[numParams]; |
| 11024 | |
| 11025 | context->getIntegerv(pname, intParams); |
| 11026 | |
| 11027 | for (unsigned int i = 0; i < numParams; ++i) |
| 11028 | { |
| 11029 | params[i] = static_cast<GLint64>(intParams[i]); |
| 11030 | } |
| 11031 | |
| 11032 | delete [] intParams; |
| 11033 | } |
| 11034 | else if (nativeType == GL_FLOAT) |
| 11035 | { |
| 11036 | GLfloat *floatParams = NULL; |
| 11037 | floatParams = new GLfloat[numParams]; |
| 11038 | |
| 11039 | context->getFloatv(pname, floatParams); |
| 11040 | |
| 11041 | for (unsigned int i = 0; i < numParams; ++i) |
| 11042 | { |
| 11043 | // RGBA color values and DepthRangeF values are converted to integer using Equation 2.4 from Table 4.5 |
| 11044 | if (pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE || pname == GL_BLEND_COLOR) |
| 11045 | { |
| 11046 | params[i] = static_cast<GLint64>((static_cast<GLfloat>(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f); |
| 11047 | } |
| 11048 | else |
| 11049 | { |
| 11050 | params[i] = gl::iround<GLint64>(floatParams[i]); |
| 11051 | } |
| 11052 | } |
| 11053 | |
| 11054 | delete [] floatParams; |
| 11055 | } |
| 11056 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11057 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11058 | } |
| 11059 | catch(std::bad_alloc&) |
| 11060 | { |
| 11061 | return gl::error(GL_OUT_OF_MEMORY); |
| 11062 | } |
| 11063 | } |
| 11064 | |
| 11065 | void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) |
| 11066 | { |
| 11067 | EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)", |
| 11068 | sync, pname, bufSize, length, values); |
| 11069 | |
| 11070 | try |
| 11071 | { |
| 11072 | gl::Context *context = gl::getNonLostContext(); |
| 11073 | |
| 11074 | if (context) |
| 11075 | { |
| 11076 | if (context->getClientVersion() < 3) |
| 11077 | { |
| 11078 | return gl::error(GL_INVALID_OPERATION); |
| 11079 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11080 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11081 | // glGetSynciv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11082 | UNIMPLEMENTED(); |
| 11083 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11084 | } |
| 11085 | catch(std::bad_alloc&) |
| 11086 | { |
| 11087 | return gl::error(GL_OUT_OF_MEMORY); |
| 11088 | } |
| 11089 | } |
| 11090 | |
| 11091 | void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) |
| 11092 | { |
| 11093 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)", |
| 11094 | target, index, data); |
| 11095 | |
| 11096 | try |
| 11097 | { |
| 11098 | gl::Context *context = gl::getNonLostContext(); |
| 11099 | |
| 11100 | if (context) |
| 11101 | { |
| 11102 | if (context->getClientVersion() < 3) |
| 11103 | { |
| 11104 | return gl::error(GL_INVALID_OPERATION); |
| 11105 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11106 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11107 | // glGetInteger64i_v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11108 | UNIMPLEMENTED(); |
| 11109 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11110 | } |
| 11111 | catch(std::bad_alloc&) |
| 11112 | { |
| 11113 | return gl::error(GL_OUT_OF_MEMORY); |
| 11114 | } |
| 11115 | } |
| 11116 | |
| 11117 | void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) |
| 11118 | { |
| 11119 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 11120 | target, pname, params); |
| 11121 | |
| 11122 | try |
| 11123 | { |
| 11124 | gl::Context *context = gl::getNonLostContext(); |
| 11125 | |
| 11126 | if (context) |
| 11127 | { |
| 11128 | if (context->getClientVersion() < 3) |
| 11129 | { |
| 11130 | return gl::error(GL_INVALID_OPERATION); |
| 11131 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11132 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11133 | // glGetBufferParameteri64v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11134 | UNIMPLEMENTED(); |
| 11135 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11136 | } |
| 11137 | catch(std::bad_alloc&) |
| 11138 | { |
| 11139 | return gl::error(GL_OUT_OF_MEMORY); |
| 11140 | } |
| 11141 | } |
| 11142 | |
| 11143 | void __stdcall glGenSamplers(GLsizei count, GLuint* samplers) |
| 11144 | { |
| 11145 | EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers); |
| 11146 | |
| 11147 | try |
| 11148 | { |
| 11149 | gl::Context *context = gl::getNonLostContext(); |
| 11150 | |
| 11151 | if (context) |
| 11152 | { |
| 11153 | if (context->getClientVersion() < 3) |
| 11154 | { |
| 11155 | return gl::error(GL_INVALID_OPERATION); |
| 11156 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11157 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame^] | 11158 | if (count < 0) |
| 11159 | { |
| 11160 | return gl::error(GL_INVALID_VALUE); |
| 11161 | } |
| 11162 | |
| 11163 | for (int i = 0; i < count; i++) |
| 11164 | { |
| 11165 | samplers[i] = context->createSampler(); |
| 11166 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11167 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11168 | } |
| 11169 | catch(std::bad_alloc&) |
| 11170 | { |
| 11171 | return gl::error(GL_OUT_OF_MEMORY); |
| 11172 | } |
| 11173 | } |
| 11174 | |
| 11175 | void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers) |
| 11176 | { |
| 11177 | EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers); |
| 11178 | |
| 11179 | try |
| 11180 | { |
| 11181 | gl::Context *context = gl::getNonLostContext(); |
| 11182 | |
| 11183 | if (context) |
| 11184 | { |
| 11185 | if (context->getClientVersion() < 3) |
| 11186 | { |
| 11187 | return gl::error(GL_INVALID_OPERATION); |
| 11188 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11189 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame^] | 11190 | if (count < 0) |
| 11191 | { |
| 11192 | return gl::error(GL_INVALID_VALUE); |
| 11193 | } |
| 11194 | |
| 11195 | for (int i = 0; i < count; i++) |
| 11196 | { |
| 11197 | context->deleteSampler(samplers[i]); |
| 11198 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11199 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11200 | } |
| 11201 | catch(std::bad_alloc&) |
| 11202 | { |
| 11203 | return gl::error(GL_OUT_OF_MEMORY); |
| 11204 | } |
| 11205 | } |
| 11206 | |
| 11207 | GLboolean __stdcall glIsSampler(GLuint sampler) |
| 11208 | { |
| 11209 | EVENT("(GLuint sampler = %u)", sampler); |
| 11210 | |
| 11211 | try |
| 11212 | { |
| 11213 | gl::Context *context = gl::getNonLostContext(); |
| 11214 | |
| 11215 | if (context) |
| 11216 | { |
| 11217 | if (context->getClientVersion() < 3) |
| 11218 | { |
| 11219 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 11220 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11221 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame^] | 11222 | return context->isSampler(sampler); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11223 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11224 | } |
| 11225 | catch(std::bad_alloc&) |
| 11226 | { |
| 11227 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 11228 | } |
| 11229 | |
| 11230 | return GL_FALSE; |
| 11231 | } |
| 11232 | |
| 11233 | void __stdcall glBindSampler(GLuint unit, GLuint sampler) |
| 11234 | { |
| 11235 | EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler); |
| 11236 | |
| 11237 | try |
| 11238 | { |
| 11239 | gl::Context *context = gl::getNonLostContext(); |
| 11240 | |
| 11241 | if (context) |
| 11242 | { |
| 11243 | if (context->getClientVersion() < 3) |
| 11244 | { |
| 11245 | return gl::error(GL_INVALID_OPERATION); |
| 11246 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11247 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame^] | 11248 | if (sampler != 0 && !context->isSampler(sampler)) |
| 11249 | { |
| 11250 | return gl::error(GL_INVALID_OPERATION); |
| 11251 | } |
| 11252 | |
| 11253 | if (unit >= context->getMaximumCombinedTextureImageUnits()) |
| 11254 | { |
| 11255 | return gl::error(GL_INVALID_VALUE); |
| 11256 | } |
| 11257 | |
| 11258 | context->bindSampler(unit, sampler); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11259 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11260 | } |
| 11261 | catch(std::bad_alloc&) |
| 11262 | { |
| 11263 | return gl::error(GL_OUT_OF_MEMORY); |
| 11264 | } |
| 11265 | } |
| 11266 | |
| 11267 | void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 11268 | { |
| 11269 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param); |
| 11270 | |
| 11271 | try |
| 11272 | { |
| 11273 | gl::Context *context = gl::getNonLostContext(); |
| 11274 | |
| 11275 | if (context) |
| 11276 | { |
| 11277 | if (context->getClientVersion() < 3) |
| 11278 | { |
| 11279 | return gl::error(GL_INVALID_OPERATION); |
| 11280 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11281 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame^] | 11282 | if (!validateSamplerObjectParameter(pname)) |
| 11283 | { |
| 11284 | return; |
| 11285 | } |
| 11286 | |
| 11287 | if (!validateTexParamParameters(context, pname, param)) |
| 11288 | { |
| 11289 | return; |
| 11290 | } |
| 11291 | |
| 11292 | if (!context->isSampler(sampler)) |
| 11293 | { |
| 11294 | return gl::error(GL_INVALID_OPERATION); |
| 11295 | } |
| 11296 | |
| 11297 | context->samplerParameteri(sampler, pname, param); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11298 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11299 | } |
| 11300 | catch(std::bad_alloc&) |
| 11301 | { |
| 11302 | return gl::error(GL_OUT_OF_MEMORY); |
| 11303 | } |
| 11304 | } |
| 11305 | |
| 11306 | void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) |
| 11307 | { |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame^] | 11308 | glSamplerParameteri(sampler, pname, *param); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11309 | } |
| 11310 | |
| 11311 | void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 11312 | { |
| 11313 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param); |
| 11314 | |
| 11315 | try |
| 11316 | { |
| 11317 | gl::Context *context = gl::getNonLostContext(); |
| 11318 | |
| 11319 | if (context) |
| 11320 | { |
| 11321 | if (context->getClientVersion() < 3) |
| 11322 | { |
| 11323 | return gl::error(GL_INVALID_OPERATION); |
| 11324 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11325 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame^] | 11326 | if (!validateSamplerObjectParameter(pname)) |
| 11327 | { |
| 11328 | return; |
| 11329 | } |
| 11330 | |
| 11331 | if (!validateTexParamParameters(context, pname, static_cast<GLint>(param))) |
| 11332 | { |
| 11333 | return; |
| 11334 | } |
| 11335 | |
| 11336 | if (!context->isSampler(sampler)) |
| 11337 | { |
| 11338 | return gl::error(GL_INVALID_OPERATION); |
| 11339 | } |
| 11340 | |
| 11341 | context->samplerParameterf(sampler, pname, param); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11342 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11343 | } |
| 11344 | catch(std::bad_alloc&) |
| 11345 | { |
| 11346 | return gl::error(GL_OUT_OF_MEMORY); |
| 11347 | } |
| 11348 | } |
| 11349 | |
| 11350 | void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) |
| 11351 | { |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame^] | 11352 | glSamplerParameterf(sampler, pname, *param); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11353 | } |
| 11354 | |
| 11355 | void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) |
| 11356 | { |
| 11357 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); |
| 11358 | |
| 11359 | try |
| 11360 | { |
| 11361 | gl::Context *context = gl::getNonLostContext(); |
| 11362 | |
| 11363 | if (context) |
| 11364 | { |
| 11365 | if (context->getClientVersion() < 3) |
| 11366 | { |
| 11367 | return gl::error(GL_INVALID_OPERATION); |
| 11368 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11369 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame^] | 11370 | if (!validateSamplerObjectParameter(pname)) |
| 11371 | { |
| 11372 | return; |
| 11373 | } |
| 11374 | |
| 11375 | if (!context->isSampler(sampler)) |
| 11376 | { |
| 11377 | return gl::error(GL_INVALID_OPERATION); |
| 11378 | } |
| 11379 | |
| 11380 | *params = context->getSamplerParameteri(sampler, pname); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11381 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11382 | } |
| 11383 | catch(std::bad_alloc&) |
| 11384 | { |
| 11385 | return gl::error(GL_OUT_OF_MEMORY); |
| 11386 | } |
| 11387 | } |
| 11388 | |
| 11389 | void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) |
| 11390 | { |
| 11391 | EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params); |
| 11392 | |
| 11393 | try |
| 11394 | { |
| 11395 | gl::Context *context = gl::getNonLostContext(); |
| 11396 | |
| 11397 | if (context) |
| 11398 | { |
| 11399 | if (context->getClientVersion() < 3) |
| 11400 | { |
| 11401 | return gl::error(GL_INVALID_OPERATION); |
| 11402 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11403 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame^] | 11404 | if (!validateSamplerObjectParameter(pname)) |
| 11405 | { |
| 11406 | return; |
| 11407 | } |
| 11408 | |
| 11409 | if (!context->isSampler(sampler)) |
| 11410 | { |
| 11411 | return gl::error(GL_INVALID_OPERATION); |
| 11412 | } |
| 11413 | |
| 11414 | *params = context->getSamplerParameterf(sampler, pname); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11415 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11416 | } |
| 11417 | catch(std::bad_alloc&) |
| 11418 | { |
| 11419 | return gl::error(GL_OUT_OF_MEMORY); |
| 11420 | } |
| 11421 | } |
| 11422 | |
| 11423 | void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor) |
| 11424 | { |
| 11425 | EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor); |
| 11426 | |
| 11427 | try |
| 11428 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 11429 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 11430 | { |
| 11431 | return gl::error(GL_INVALID_VALUE); |
| 11432 | } |
| 11433 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11434 | gl::Context *context = gl::getNonLostContext(); |
| 11435 | |
| 11436 | if (context) |
| 11437 | { |
| 11438 | if (context->getClientVersion() < 3) |
| 11439 | { |
| 11440 | return gl::error(GL_INVALID_OPERATION); |
| 11441 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11442 | |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 11443 | context->setVertexAttribDivisor(index, divisor); |
| 11444 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11445 | } |
| 11446 | catch(std::bad_alloc&) |
| 11447 | { |
| 11448 | return gl::error(GL_OUT_OF_MEMORY); |
| 11449 | } |
| 11450 | } |
| 11451 | |
| 11452 | void __stdcall glBindTransformFeedback(GLenum target, GLuint id) |
| 11453 | { |
| 11454 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 11455 | |
| 11456 | try |
| 11457 | { |
| 11458 | gl::Context *context = gl::getNonLostContext(); |
| 11459 | |
| 11460 | if (context) |
| 11461 | { |
| 11462 | if (context->getClientVersion() < 3) |
| 11463 | { |
| 11464 | return gl::error(GL_INVALID_OPERATION); |
| 11465 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11466 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11467 | // glBindTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11468 | UNIMPLEMENTED(); |
| 11469 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11470 | } |
| 11471 | catch(std::bad_alloc&) |
| 11472 | { |
| 11473 | return gl::error(GL_OUT_OF_MEMORY); |
| 11474 | } |
| 11475 | } |
| 11476 | |
| 11477 | void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) |
| 11478 | { |
| 11479 | EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids); |
| 11480 | |
| 11481 | try |
| 11482 | { |
| 11483 | gl::Context *context = gl::getNonLostContext(); |
| 11484 | |
| 11485 | if (context) |
| 11486 | { |
| 11487 | if (context->getClientVersion() < 3) |
| 11488 | { |
| 11489 | return gl::error(GL_INVALID_OPERATION); |
| 11490 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11491 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11492 | // glDeleteTransformFeedbacks |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11493 | UNIMPLEMENTED(); |
| 11494 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11495 | } |
| 11496 | catch(std::bad_alloc&) |
| 11497 | { |
| 11498 | return gl::error(GL_OUT_OF_MEMORY); |
| 11499 | } |
| 11500 | } |
| 11501 | |
| 11502 | void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids) |
| 11503 | { |
| 11504 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 11505 | |
| 11506 | try |
| 11507 | { |
| 11508 | gl::Context *context = gl::getNonLostContext(); |
| 11509 | |
| 11510 | if (context) |
| 11511 | { |
| 11512 | if (context->getClientVersion() < 3) |
| 11513 | { |
| 11514 | return gl::error(GL_INVALID_OPERATION); |
| 11515 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11516 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11517 | // glGenTransformFeedbacks |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11518 | UNIMPLEMENTED(); |
| 11519 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11520 | } |
| 11521 | catch(std::bad_alloc&) |
| 11522 | { |
| 11523 | return gl::error(GL_OUT_OF_MEMORY); |
| 11524 | } |
| 11525 | } |
| 11526 | |
| 11527 | GLboolean __stdcall glIsTransformFeedback(GLuint id) |
| 11528 | { |
| 11529 | EVENT("(GLuint id = %u)", id); |
| 11530 | |
| 11531 | try |
| 11532 | { |
| 11533 | gl::Context *context = gl::getNonLostContext(); |
| 11534 | |
| 11535 | if (context) |
| 11536 | { |
| 11537 | if (context->getClientVersion() < 3) |
| 11538 | { |
| 11539 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 11540 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11541 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11542 | // glIsTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11543 | UNIMPLEMENTED(); |
| 11544 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11545 | } |
| 11546 | catch(std::bad_alloc&) |
| 11547 | { |
| 11548 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 11549 | } |
| 11550 | |
| 11551 | return GL_FALSE; |
| 11552 | } |
| 11553 | |
| 11554 | void __stdcall glPauseTransformFeedback(void) |
| 11555 | { |
| 11556 | EVENT("(void)"); |
| 11557 | |
| 11558 | try |
| 11559 | { |
| 11560 | gl::Context *context = gl::getNonLostContext(); |
| 11561 | |
| 11562 | if (context) |
| 11563 | { |
| 11564 | if (context->getClientVersion() < 3) |
| 11565 | { |
| 11566 | return gl::error(GL_INVALID_OPERATION); |
| 11567 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11568 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11569 | // glPauseTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11570 | UNIMPLEMENTED(); |
| 11571 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11572 | } |
| 11573 | catch(std::bad_alloc&) |
| 11574 | { |
| 11575 | return gl::error(GL_OUT_OF_MEMORY); |
| 11576 | } |
| 11577 | } |
| 11578 | |
| 11579 | void __stdcall glResumeTransformFeedback(void) |
| 11580 | { |
| 11581 | EVENT("(void)"); |
| 11582 | |
| 11583 | try |
| 11584 | { |
| 11585 | gl::Context *context = gl::getNonLostContext(); |
| 11586 | |
| 11587 | if (context) |
| 11588 | { |
| 11589 | if (context->getClientVersion() < 3) |
| 11590 | { |
| 11591 | return gl::error(GL_INVALID_OPERATION); |
| 11592 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11593 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11594 | // glResumeTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11595 | UNIMPLEMENTED(); |
| 11596 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11597 | } |
| 11598 | catch(std::bad_alloc&) |
| 11599 | { |
| 11600 | return gl::error(GL_OUT_OF_MEMORY); |
| 11601 | } |
| 11602 | } |
| 11603 | |
| 11604 | void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) |
| 11605 | { |
| 11606 | EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)", |
| 11607 | program, bufSize, length, binaryFormat, binary); |
| 11608 | |
| 11609 | try |
| 11610 | { |
| 11611 | gl::Context *context = gl::getNonLostContext(); |
| 11612 | |
| 11613 | if (context) |
| 11614 | { |
| 11615 | if (context->getClientVersion() < 3) |
| 11616 | { |
| 11617 | return gl::error(GL_INVALID_OPERATION); |
| 11618 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11619 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11620 | // glGetProgramBinary |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11621 | UNIMPLEMENTED(); |
| 11622 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11623 | } |
| 11624 | catch(std::bad_alloc&) |
| 11625 | { |
| 11626 | return gl::error(GL_OUT_OF_MEMORY); |
| 11627 | } |
| 11628 | } |
| 11629 | |
| 11630 | void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) |
| 11631 | { |
| 11632 | EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
| 11633 | program, binaryFormat, binary, length); |
| 11634 | |
| 11635 | try |
| 11636 | { |
| 11637 | gl::Context *context = gl::getNonLostContext(); |
| 11638 | |
| 11639 | if (context) |
| 11640 | { |
| 11641 | if (context->getClientVersion() < 3) |
| 11642 | { |
| 11643 | return gl::error(GL_INVALID_OPERATION); |
| 11644 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11645 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11646 | // glProgramBinary |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11647 | UNIMPLEMENTED(); |
| 11648 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11649 | } |
| 11650 | catch(std::bad_alloc&) |
| 11651 | { |
| 11652 | return gl::error(GL_OUT_OF_MEMORY); |
| 11653 | } |
| 11654 | } |
| 11655 | |
| 11656 | void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value) |
| 11657 | { |
| 11658 | EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)", |
| 11659 | program, pname, value); |
| 11660 | |
| 11661 | try |
| 11662 | { |
| 11663 | gl::Context *context = gl::getNonLostContext(); |
| 11664 | |
| 11665 | if (context) |
| 11666 | { |
| 11667 | if (context->getClientVersion() < 3) |
| 11668 | { |
| 11669 | return gl::error(GL_INVALID_OPERATION); |
| 11670 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11671 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11672 | // glProgramParameteri |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11673 | UNIMPLEMENTED(); |
| 11674 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11675 | } |
| 11676 | catch(std::bad_alloc&) |
| 11677 | { |
| 11678 | return gl::error(GL_OUT_OF_MEMORY); |
| 11679 | } |
| 11680 | } |
| 11681 | |
| 11682 | void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) |
| 11683 | { |
| 11684 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)", |
| 11685 | target, numAttachments, attachments); |
| 11686 | |
| 11687 | try |
| 11688 | { |
| 11689 | gl::Context *context = gl::getNonLostContext(); |
| 11690 | |
| 11691 | if (context) |
| 11692 | { |
| 11693 | if (context->getClientVersion() < 3) |
| 11694 | { |
| 11695 | return gl::error(GL_INVALID_OPERATION); |
| 11696 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11697 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11698 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11699 | { |
| 11700 | return; |
| 11701 | } |
| 11702 | |
| 11703 | int maxDimension = context->getMaximumRenderbufferDimension(); |
| 11704 | context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension); |
| 11705 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11706 | } |
| 11707 | catch(std::bad_alloc&) |
| 11708 | { |
| 11709 | return gl::error(GL_OUT_OF_MEMORY); |
| 11710 | } |
| 11711 | } |
| 11712 | |
| 11713 | void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) |
| 11714 | { |
| 11715 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, " |
| 11716 | "GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 11717 | target, numAttachments, attachments, x, y, width, height); |
| 11718 | |
| 11719 | try |
| 11720 | { |
| 11721 | gl::Context *context = gl::getNonLostContext(); |
| 11722 | |
| 11723 | if (context) |
| 11724 | { |
| 11725 | if (context->getClientVersion() < 3) |
| 11726 | { |
| 11727 | return gl::error(GL_INVALID_OPERATION); |
| 11728 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11729 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11730 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11731 | { |
| 11732 | return; |
| 11733 | } |
| 11734 | |
| 11735 | context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height); |
| 11736 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11737 | } |
| 11738 | catch(std::bad_alloc&) |
| 11739 | { |
| 11740 | return gl::error(GL_OUT_OF_MEMORY); |
| 11741 | } |
| 11742 | } |
| 11743 | |
| 11744 | void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 11745 | { |
| 11746 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 11747 | target, levels, internalformat, width, height); |
| 11748 | |
| 11749 | try |
| 11750 | { |
| 11751 | gl::Context *context = gl::getNonLostContext(); |
| 11752 | |
| 11753 | if (context) |
| 11754 | { |
| 11755 | if (context->getClientVersion() < 3) |
| 11756 | { |
| 11757 | return gl::error(GL_INVALID_OPERATION); |
| 11758 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11759 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11760 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 11761 | { |
| 11762 | return; |
| 11763 | } |
| 11764 | |
| 11765 | switch (target) |
| 11766 | { |
| 11767 | case GL_TEXTURE_2D: |
| 11768 | { |
| 11769 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 11770 | texture2d->storage(levels, internalformat, width, height); |
| 11771 | } |
| 11772 | break; |
| 11773 | |
| 11774 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 11775 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 11776 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 11777 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 11778 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 11779 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 11780 | { |
| 11781 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 11782 | textureCube->storage(levels, internalformat, width); |
| 11783 | } |
| 11784 | break; |
| 11785 | |
| 11786 | default: |
| 11787 | return gl::error(GL_INVALID_ENUM); |
| 11788 | } |
| 11789 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11790 | } |
| 11791 | catch(std::bad_alloc&) |
| 11792 | { |
| 11793 | return gl::error(GL_OUT_OF_MEMORY); |
| 11794 | } |
| 11795 | } |
| 11796 | |
| 11797 | void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
| 11798 | { |
| 11799 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 11800 | "GLsizei height = %d, GLsizei depth = %d)", |
| 11801 | target, levels, internalformat, width, height, depth); |
| 11802 | |
| 11803 | try |
| 11804 | { |
| 11805 | gl::Context *context = gl::getNonLostContext(); |
| 11806 | |
| 11807 | if (context) |
| 11808 | { |
| 11809 | if (context->getClientVersion() < 3) |
| 11810 | { |
| 11811 | return gl::error(GL_INVALID_OPERATION); |
| 11812 | } |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11813 | |
| 11814 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) |
| 11815 | { |
| 11816 | return; |
| 11817 | } |
| 11818 | |
| 11819 | switch (target) |
| 11820 | { |
| 11821 | case GL_TEXTURE_3D: |
| 11822 | { |
| 11823 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 11824 | texture3d->storage(levels, internalformat, width, height, depth); |
| 11825 | } |
| 11826 | break; |
| 11827 | |
| 11828 | case GL_TEXTURE_2D_ARRAY: |
| 11829 | { |
| 11830 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 11831 | texture2darray->storage(levels, internalformat, width, height, depth); |
| 11832 | } |
| 11833 | break; |
| 11834 | |
| 11835 | default: |
| 11836 | return gl::error(GL_INVALID_ENUM); |
| 11837 | } |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 11838 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11839 | } |
| 11840 | catch(std::bad_alloc&) |
| 11841 | { |
| 11842 | return gl::error(GL_OUT_OF_MEMORY); |
| 11843 | } |
| 11844 | } |
| 11845 | |
| 11846 | void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) |
| 11847 | { |
| 11848 | EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, " |
| 11849 | "GLint* params = 0x%0.8p)", |
| 11850 | target, internalformat, pname, bufSize, params); |
| 11851 | |
| 11852 | try |
| 11853 | { |
| 11854 | gl::Context *context = gl::getNonLostContext(); |
| 11855 | |
| 11856 | if (context) |
| 11857 | { |
| 11858 | if (context->getClientVersion() < 3) |
| 11859 | { |
| 11860 | return gl::error(GL_INVALID_OPERATION); |
| 11861 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11862 | |
Shannon Woods | 809d250 | 2013-07-08 10:32:18 -0400 | [diff] [blame] | 11863 | if (!gl::IsColorRenderingSupported(internalformat, context) && |
| 11864 | !gl::IsDepthRenderingSupported(internalformat, context) && |
| 11865 | !gl::IsStencilRenderingSupported(internalformat, context)) |
| 11866 | { |
| 11867 | return gl::error(GL_INVALID_ENUM); |
| 11868 | } |
| 11869 | |
| 11870 | if (target != GL_RENDERBUFFER) |
| 11871 | { |
| 11872 | return gl::error(GL_INVALID_ENUM); |
| 11873 | } |
| 11874 | |
| 11875 | if (bufSize < 0) |
| 11876 | { |
| 11877 | return gl::error(GL_INVALID_VALUE); |
| 11878 | } |
| 11879 | |
| 11880 | switch (pname) |
| 11881 | { |
| 11882 | case GL_NUM_SAMPLE_COUNTS: |
| 11883 | if (bufSize != 0) |
| 11884 | *params = context->getNumSampleCounts(internalformat); |
| 11885 | break; |
| 11886 | case GL_SAMPLES: |
| 11887 | context->getSampleCounts(internalformat, bufSize, params); |
| 11888 | break; |
| 11889 | default: |
| 11890 | return gl::error(GL_INVALID_ENUM); |
| 11891 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11892 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11893 | } |
| 11894 | catch(std::bad_alloc&) |
| 11895 | { |
| 11896 | return gl::error(GL_OUT_OF_MEMORY); |
| 11897 | } |
| 11898 | } |
| 11899 | |
| 11900 | // Extension functions |
| 11901 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11902 | void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 11903 | GLbitfield mask, GLenum filter) |
| 11904 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11905 | 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] | 11906 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, " |
| 11907 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 11908 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 11909 | |
| 11910 | try |
| 11911 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11912 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11913 | |
| 11914 | if (context) |
| 11915 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11916 | if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 11917 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 11918 | true)) |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11919 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11920 | return; |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11921 | } |
| 11922 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11923 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 11924 | mask, filter); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11925 | } |
| 11926 | } |
| 11927 | catch(std::bad_alloc&) |
| 11928 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11929 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11930 | } |
| 11931 | } |
| 11932 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 11933 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, |
| 11934 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11935 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11936 | 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] | 11937 | "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] | 11938 | "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] | 11939 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 11940 | |
| 11941 | try |
| 11942 | { |
| 11943 | UNIMPLEMENTED(); // FIXME |
| 11944 | } |
| 11945 | catch(std::bad_alloc&) |
| 11946 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11947 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11948 | } |
| 11949 | } |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11950 | |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11951 | void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, |
| 11952 | GLenum *binaryFormat, void *binary) |
| 11953 | { |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11954 | 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] | 11955 | program, bufSize, length, binaryFormat, binary); |
| 11956 | |
| 11957 | try |
| 11958 | { |
| 11959 | gl::Context *context = gl::getNonLostContext(); |
| 11960 | |
| 11961 | if (context) |
| 11962 | { |
| 11963 | gl::Program *programObject = context->getProgram(program); |
| 11964 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 11965 | if (!programObject || !programObject->isLinked()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11966 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11967 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11968 | } |
| 11969 | |
| 11970 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 11971 | |
| 11972 | if (!programBinary) |
| 11973 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11974 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11975 | } |
| 11976 | |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11977 | if (!programBinary->save(binary, bufSize, length)) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11978 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11979 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11980 | } |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11981 | |
| 11982 | *binaryFormat = GL_PROGRAM_BINARY_ANGLE; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11983 | } |
| 11984 | } |
| 11985 | catch(std::bad_alloc&) |
| 11986 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11987 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11988 | } |
| 11989 | } |
| 11990 | |
| 11991 | void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat, |
| 11992 | const void *binary, GLint length) |
| 11993 | { |
| 11994 | EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)", |
| 11995 | program, binaryFormat, binary, length); |
| 11996 | |
| 11997 | try |
| 11998 | { |
| 11999 | gl::Context *context = gl::getNonLostContext(); |
| 12000 | |
| 12001 | if (context) |
| 12002 | { |
| 12003 | if (binaryFormat != GL_PROGRAM_BINARY_ANGLE) |
| 12004 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12005 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12006 | } |
| 12007 | |
| 12008 | gl::Program *programObject = context->getProgram(program); |
| 12009 | |
| 12010 | if (!programObject) |
| 12011 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12012 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12013 | } |
| 12014 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 12015 | context->setProgramBinary(program, binary, length); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12016 | } |
| 12017 | } |
| 12018 | catch(std::bad_alloc&) |
| 12019 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12020 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12021 | } |
| 12022 | } |
| 12023 | |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12024 | void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) |
| 12025 | { |
| 12026 | EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs); |
| 12027 | |
| 12028 | try |
| 12029 | { |
| 12030 | gl::Context *context = gl::getNonLostContext(); |
| 12031 | |
| 12032 | if (context) |
| 12033 | { |
| 12034 | if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets()) |
| 12035 | { |
| 12036 | return gl::error(GL_INVALID_VALUE); |
| 12037 | } |
| 12038 | |
| 12039 | if (context->getDrawFramebufferHandle() == 0) |
| 12040 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12041 | if (n != 1) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12042 | { |
| 12043 | return gl::error(GL_INVALID_OPERATION); |
| 12044 | } |
| 12045 | |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12046 | 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] | 12047 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12048 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12049 | } |
| 12050 | } |
| 12051 | else |
| 12052 | { |
| 12053 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 12054 | { |
| 12055 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 12056 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment) |
| 12057 | { |
| 12058 | return gl::error(GL_INVALID_OPERATION); |
| 12059 | } |
| 12060 | } |
| 12061 | } |
| 12062 | |
| 12063 | gl::Framebuffer *framebuffer = context->getDrawFramebuffer(); |
| 12064 | |
| 12065 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 12066 | { |
| 12067 | framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]); |
| 12068 | } |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12069 | |
| 12070 | for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++) |
| 12071 | { |
| 12072 | framebuffer->setDrawBufferState(colorAttachment, GL_NONE); |
| 12073 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12074 | } |
| 12075 | } |
| 12076 | catch (std::bad_alloc&) |
| 12077 | { |
| 12078 | return gl::error(GL_OUT_OF_MEMORY); |
| 12079 | } |
| 12080 | } |
| 12081 | |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12082 | __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) |
| 12083 | { |
| 12084 | struct Extension |
| 12085 | { |
| 12086 | const char *name; |
| 12087 | __eglMustCastToProperFunctionPointerType address; |
| 12088 | }; |
| 12089 | |
| 12090 | static const Extension glExtensions[] = |
| 12091 | { |
| 12092 | {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 12093 | {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, |
daniel@transgaming.com | 1fe96c9 | 2011-01-14 15:08:44 +0000 | [diff] [blame] | 12094 | {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 12095 | {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, |
| 12096 | {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, |
| 12097 | {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, |
| 12098 | {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, |
| 12099 | {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, |
| 12100 | {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, |
| 12101 | {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 12102 | {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE}, |
daniel@transgaming.com | 0bd1f2f | 2011-11-11 04:19:03 +0000 | [diff] [blame] | 12103 | {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT}, |
daniel@transgaming.com | 709ed11 | 2011-11-12 03:18:10 +0000 | [diff] [blame] | 12104 | {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT}, |
| 12105 | {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT}, |
| 12106 | {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT}, |
| 12107 | {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT}, |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 12108 | {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT}, |
| 12109 | {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT}, |
| 12110 | {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT}, |
| 12111 | {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT}, |
| 12112 | {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT}, |
| 12113 | {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT}, |
| 12114 | {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT}, |
shannon.woods%transgaming.com@gtempaccount.com | 77d9472 | 2013-04-13 03:34:22 +0000 | [diff] [blame] | 12115 | {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT}, |
daniel@transgaming.com | dce02fd | 2012-01-27 15:39:51 +0000 | [diff] [blame] | 12116 | {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE}, |
| 12117 | {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, |
| 12118 | {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12119 | {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, |
| 12120 | {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, }; |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12121 | |
shannon.woods@transgaming.com | d438fd4 | 2013-02-28 23:17:45 +0000 | [diff] [blame] | 12122 | for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12123 | { |
| 12124 | if (strcmp(procname, glExtensions[ext].name) == 0) |
| 12125 | { |
| 12126 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address; |
| 12127 | } |
| 12128 | } |
| 12129 | |
| 12130 | return NULL; |
| 12131 | } |
| 12132 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 12133 | // Non-public functions used by EGL |
| 12134 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 12135 | bool __stdcall glBindTexImage(egl::Surface *surface) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12136 | { |
| 12137 | EVENT("(egl::Surface* surface = 0x%0.8p)", |
| 12138 | surface); |
| 12139 | |
| 12140 | try |
| 12141 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 12142 | gl::Context *context = gl::getNonLostContext(); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12143 | |
| 12144 | if (context) |
| 12145 | { |
| 12146 | gl::Texture2D *textureObject = context->getTexture2D(); |
| 12147 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 12148 | if (textureObject->isImmutable()) |
| 12149 | { |
| 12150 | return false; |
| 12151 | } |
| 12152 | |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12153 | if (textureObject) |
| 12154 | { |
| 12155 | textureObject->bindTexImage(surface); |
| 12156 | } |
| 12157 | } |
| 12158 | } |
| 12159 | catch(std::bad_alloc&) |
| 12160 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12161 | return gl::error(GL_OUT_OF_MEMORY, false); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12162 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 12163 | |
| 12164 | return true; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12165 | } |
| 12166 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 12167 | } |