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 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2110 | extern "C" |
| 2111 | { |
| 2112 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2113 | // OpenGL ES 2.0 functions |
| 2114 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2115 | void __stdcall glActiveTexture(GLenum texture) |
| 2116 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2117 | EVENT("(GLenum texture = 0x%X)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2118 | |
| 2119 | try |
| 2120 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2121 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2122 | |
| 2123 | if (context) |
| 2124 | { |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 2125 | if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1) |
| 2126 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2127 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 2128 | } |
| 2129 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2130 | context->setActiveSampler(texture - GL_TEXTURE0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2131 | } |
| 2132 | } |
| 2133 | catch(std::bad_alloc&) |
| 2134 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2135 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2136 | } |
| 2137 | } |
| 2138 | |
| 2139 | void __stdcall glAttachShader(GLuint program, GLuint shader) |
| 2140 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2141 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2142 | |
| 2143 | try |
| 2144 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2145 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2146 | |
| 2147 | if (context) |
| 2148 | { |
| 2149 | gl::Program *programObject = context->getProgram(program); |
| 2150 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2151 | |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2152 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2153 | { |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2154 | if (context->getShader(program)) |
| 2155 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2156 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2157 | } |
| 2158 | else |
| 2159 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2160 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2161 | } |
| 2162 | } |
| 2163 | |
| 2164 | if (!shaderObject) |
| 2165 | { |
| 2166 | if (context->getProgram(shader)) |
| 2167 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2168 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2169 | } |
| 2170 | else |
| 2171 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2172 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2173 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2174 | } |
| 2175 | |
| 2176 | if (!programObject->attachShader(shaderObject)) |
| 2177 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2178 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2179 | } |
| 2180 | } |
| 2181 | } |
| 2182 | catch(std::bad_alloc&) |
| 2183 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2184 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2185 | } |
| 2186 | } |
| 2187 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2188 | void __stdcall glBeginQueryEXT(GLenum target, GLuint id) |
| 2189 | { |
| 2190 | EVENT("(GLenum target = 0x%X, GLuint %d)", target, id); |
| 2191 | |
| 2192 | try |
| 2193 | { |
| 2194 | switch (target) |
| 2195 | { |
| 2196 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 2197 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 2198 | break; |
| 2199 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2200 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2201 | } |
| 2202 | |
| 2203 | if (id == 0) |
| 2204 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2205 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2206 | } |
| 2207 | |
| 2208 | gl::Context *context = gl::getNonLostContext(); |
| 2209 | |
| 2210 | if (context) |
| 2211 | { |
| 2212 | context->beginQuery(target, id); |
| 2213 | } |
| 2214 | } |
| 2215 | catch(std::bad_alloc&) |
| 2216 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2217 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2218 | } |
| 2219 | } |
| 2220 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2221 | void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2222 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2223 | 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] | 2224 | |
| 2225 | try |
| 2226 | { |
| 2227 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 2228 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2229 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2230 | } |
| 2231 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2232 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2233 | |
| 2234 | if (context) |
| 2235 | { |
| 2236 | gl::Program *programObject = context->getProgram(program); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2237 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2238 | if (!programObject) |
| 2239 | { |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2240 | if (context->getShader(program)) |
| 2241 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2242 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2243 | } |
| 2244 | else |
| 2245 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2246 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2247 | } |
| 2248 | } |
| 2249 | |
| 2250 | if (strncmp(name, "gl_", 3) == 0) |
| 2251 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2252 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2253 | } |
| 2254 | |
| 2255 | programObject->bindAttributeLocation(index, name); |
| 2256 | } |
| 2257 | } |
| 2258 | catch(std::bad_alloc&) |
| 2259 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2260 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2261 | } |
| 2262 | } |
| 2263 | |
| 2264 | void __stdcall glBindBuffer(GLenum target, GLuint buffer) |
| 2265 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2266 | EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2267 | |
| 2268 | try |
| 2269 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2270 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2271 | |
| 2272 | if (context) |
| 2273 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2274 | // Check ES3 specific targets |
| 2275 | switch (target) |
| 2276 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2277 | case GL_COPY_READ_BUFFER: |
| 2278 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2279 | case GL_PIXEL_PACK_BUFFER: |
| 2280 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2281 | case GL_UNIFORM_BUFFER: |
| 2282 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2283 | if (context->getClientVersion() < 3) |
| 2284 | { |
| 2285 | return gl::error(GL_INVALID_ENUM); |
| 2286 | } |
| 2287 | } |
| 2288 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2289 | switch (target) |
| 2290 | { |
| 2291 | case GL_ARRAY_BUFFER: |
| 2292 | context->bindArrayBuffer(buffer); |
| 2293 | return; |
| 2294 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2295 | context->bindElementArrayBuffer(buffer); |
| 2296 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2297 | case GL_COPY_READ_BUFFER: |
| 2298 | context->bindCopyReadBuffer(buffer); |
| 2299 | return; |
| 2300 | case GL_COPY_WRITE_BUFFER: |
| 2301 | context->bindCopyWriteBuffer(buffer); |
| 2302 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2303 | case GL_PIXEL_PACK_BUFFER: |
| 2304 | context->bindPixelPackBuffer(buffer); |
| 2305 | return; |
| 2306 | case GL_PIXEL_UNPACK_BUFFER: |
| 2307 | context->bindPixelUnpackBuffer(buffer); |
| 2308 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2309 | case GL_UNIFORM_BUFFER: |
| 2310 | context->bindGenericUniformBuffer(buffer); |
| 2311 | return; |
| 2312 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 7a1ebad | 2013-05-30 00:05:20 +0000 | [diff] [blame] | 2313 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2314 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2315 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2316 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2317 | } |
| 2318 | } |
| 2319 | } |
| 2320 | catch(std::bad_alloc&) |
| 2321 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2322 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2323 | } |
| 2324 | } |
| 2325 | |
| 2326 | void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer) |
| 2327 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2328 | EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2329 | |
| 2330 | try |
| 2331 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2332 | 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] | 2333 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2334 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2335 | } |
| 2336 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2337 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2338 | |
| 2339 | if (context) |
| 2340 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2341 | if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 2342 | { |
| 2343 | context->bindReadFramebuffer(framebuffer); |
| 2344 | } |
| 2345 | |
| 2346 | if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 2347 | { |
| 2348 | context->bindDrawFramebuffer(framebuffer); |
| 2349 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2350 | } |
| 2351 | } |
| 2352 | catch(std::bad_alloc&) |
| 2353 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2354 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2355 | } |
| 2356 | } |
| 2357 | |
| 2358 | void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 2359 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2360 | EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2361 | |
| 2362 | try |
| 2363 | { |
| 2364 | if (target != GL_RENDERBUFFER) |
| 2365 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2366 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2367 | } |
| 2368 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2369 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2370 | |
| 2371 | if (context) |
| 2372 | { |
| 2373 | context->bindRenderbuffer(renderbuffer); |
| 2374 | } |
| 2375 | } |
| 2376 | catch(std::bad_alloc&) |
| 2377 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2378 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2379 | } |
| 2380 | } |
| 2381 | |
| 2382 | void __stdcall glBindTexture(GLenum target, GLuint texture) |
| 2383 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2384 | EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2385 | |
| 2386 | try |
| 2387 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2388 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2389 | |
| 2390 | if (context) |
| 2391 | { |
| 2392 | gl::Texture *textureObject = context->getTexture(texture); |
| 2393 | |
| 2394 | if (textureObject && textureObject->getTarget() != target && texture != 0) |
| 2395 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2396 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2397 | } |
| 2398 | |
| 2399 | switch (target) |
| 2400 | { |
| 2401 | case GL_TEXTURE_2D: |
| 2402 | context->bindTexture2D(texture); |
| 2403 | return; |
| 2404 | case GL_TEXTURE_CUBE_MAP: |
| 2405 | context->bindTextureCubeMap(texture); |
| 2406 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 2407 | case GL_TEXTURE_3D: |
| 2408 | if (context->getClientVersion() < 3) |
| 2409 | { |
| 2410 | return gl::error(GL_INVALID_ENUM); |
| 2411 | } |
| 2412 | context->bindTexture3D(texture); |
| 2413 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 2414 | case GL_TEXTURE_2D_ARRAY: |
| 2415 | if (context->getClientVersion() < 3) |
| 2416 | { |
| 2417 | return gl::error(GL_INVALID_ENUM); |
| 2418 | } |
| 2419 | context->bindTexture2DArray(texture); |
| 2420 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2421 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2422 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2423 | } |
| 2424 | } |
| 2425 | } |
| 2426 | catch(std::bad_alloc&) |
| 2427 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2428 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2429 | } |
| 2430 | } |
| 2431 | |
| 2432 | void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2433 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2434 | 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] | 2435 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2436 | |
| 2437 | try |
| 2438 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2439 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2440 | |
| 2441 | if (context) |
| 2442 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2443 | 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] | 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 glBlendEquation(GLenum mode) |
| 2453 | { |
| 2454 | glBlendEquationSeparate(mode, mode); |
| 2455 | } |
| 2456 | |
| 2457 | void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 2458 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2459 | EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2460 | |
| 2461 | try |
| 2462 | { |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2463 | gl::Context *context = gl::getNonLostContext(); |
| 2464 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2465 | switch (modeRGB) |
| 2466 | { |
| 2467 | case GL_FUNC_ADD: |
| 2468 | case GL_FUNC_SUBTRACT: |
| 2469 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2470 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2471 | |
| 2472 | case GL_MIN: |
| 2473 | case GL_MAX: |
| 2474 | if (context && context->getClientVersion() < 3) |
| 2475 | { |
| 2476 | return gl::error(GL_INVALID_ENUM); |
| 2477 | } |
| 2478 | break; |
| 2479 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2480 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2481 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2482 | } |
| 2483 | |
| 2484 | switch (modeAlpha) |
| 2485 | { |
| 2486 | case GL_FUNC_ADD: |
| 2487 | case GL_FUNC_SUBTRACT: |
| 2488 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2489 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2490 | |
| 2491 | case GL_MIN: |
| 2492 | case GL_MAX: |
| 2493 | if (context && context->getClientVersion() < 3) |
| 2494 | { |
| 2495 | return gl::error(GL_INVALID_ENUM); |
| 2496 | } |
| 2497 | break; |
| 2498 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2499 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2500 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2501 | } |
| 2502 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2503 | if (context) |
| 2504 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2505 | context->setBlendEquation(modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2506 | } |
| 2507 | } |
| 2508 | catch(std::bad_alloc&) |
| 2509 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2510 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2511 | } |
| 2512 | } |
| 2513 | |
| 2514 | void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor) |
| 2515 | { |
| 2516 | glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor); |
| 2517 | } |
| 2518 | |
| 2519 | void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 2520 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2521 | 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] | 2522 | srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2523 | |
| 2524 | try |
| 2525 | { |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2526 | gl::Context *context = gl::getNonLostContext(); |
| 2527 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2528 | switch (srcRGB) |
| 2529 | { |
| 2530 | case GL_ZERO: |
| 2531 | case GL_ONE: |
| 2532 | case GL_SRC_COLOR: |
| 2533 | case GL_ONE_MINUS_SRC_COLOR: |
| 2534 | case GL_DST_COLOR: |
| 2535 | case GL_ONE_MINUS_DST_COLOR: |
| 2536 | case GL_SRC_ALPHA: |
| 2537 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2538 | case GL_DST_ALPHA: |
| 2539 | case GL_ONE_MINUS_DST_ALPHA: |
| 2540 | case GL_CONSTANT_COLOR: |
| 2541 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2542 | case GL_CONSTANT_ALPHA: |
| 2543 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2544 | case GL_SRC_ALPHA_SATURATE: |
| 2545 | break; |
| 2546 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2547 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2548 | } |
| 2549 | |
| 2550 | switch (dstRGB) |
| 2551 | { |
| 2552 | case GL_ZERO: |
| 2553 | case GL_ONE: |
| 2554 | case GL_SRC_COLOR: |
| 2555 | case GL_ONE_MINUS_SRC_COLOR: |
| 2556 | case GL_DST_COLOR: |
| 2557 | case GL_ONE_MINUS_DST_COLOR: |
| 2558 | case GL_SRC_ALPHA: |
| 2559 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2560 | case GL_DST_ALPHA: |
| 2561 | case GL_ONE_MINUS_DST_ALPHA: |
| 2562 | case GL_CONSTANT_COLOR: |
| 2563 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2564 | case GL_CONSTANT_ALPHA: |
| 2565 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2566 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2567 | |
| 2568 | case GL_SRC_ALPHA_SATURATE: |
| 2569 | if (!context || context->getClientVersion() < 3) |
| 2570 | { |
| 2571 | return gl::error(GL_INVALID_ENUM); |
| 2572 | } |
| 2573 | break; |
| 2574 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2575 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2576 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2577 | } |
| 2578 | |
| 2579 | switch (srcAlpha) |
| 2580 | { |
| 2581 | case GL_ZERO: |
| 2582 | case GL_ONE: |
| 2583 | case GL_SRC_COLOR: |
| 2584 | case GL_ONE_MINUS_SRC_COLOR: |
| 2585 | case GL_DST_COLOR: |
| 2586 | case GL_ONE_MINUS_DST_COLOR: |
| 2587 | case GL_SRC_ALPHA: |
| 2588 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2589 | case GL_DST_ALPHA: |
| 2590 | case GL_ONE_MINUS_DST_ALPHA: |
| 2591 | case GL_CONSTANT_COLOR: |
| 2592 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2593 | case GL_CONSTANT_ALPHA: |
| 2594 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2595 | case GL_SRC_ALPHA_SATURATE: |
| 2596 | break; |
| 2597 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2598 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2599 | } |
| 2600 | |
| 2601 | switch (dstAlpha) |
| 2602 | { |
| 2603 | case GL_ZERO: |
| 2604 | case GL_ONE: |
| 2605 | case GL_SRC_COLOR: |
| 2606 | case GL_ONE_MINUS_SRC_COLOR: |
| 2607 | case GL_DST_COLOR: |
| 2608 | case GL_ONE_MINUS_DST_COLOR: |
| 2609 | case GL_SRC_ALPHA: |
| 2610 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2611 | case GL_DST_ALPHA: |
| 2612 | case GL_ONE_MINUS_DST_ALPHA: |
| 2613 | case GL_CONSTANT_COLOR: |
| 2614 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2615 | case GL_CONSTANT_ALPHA: |
| 2616 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2617 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2618 | |
| 2619 | case GL_SRC_ALPHA_SATURATE: |
| 2620 | if (!context || context->getClientVersion() < 3) |
| 2621 | { |
| 2622 | return gl::error(GL_INVALID_ENUM); |
| 2623 | } |
| 2624 | break; |
| 2625 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2626 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2627 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2628 | } |
| 2629 | |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2630 | bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR || |
| 2631 | dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR); |
| 2632 | |
| 2633 | bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA || |
| 2634 | dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA); |
| 2635 | |
| 2636 | if (constantColorUsed && constantAlphaUsed) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2637 | { |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2638 | 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] | 2639 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2640 | } |
| 2641 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2642 | if (context) |
| 2643 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2644 | context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2645 | } |
| 2646 | } |
| 2647 | catch(std::bad_alloc&) |
| 2648 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2649 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2650 | } |
| 2651 | } |
| 2652 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2653 | 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] | 2654 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2655 | 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] | 2656 | target, size, data, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2657 | |
| 2658 | try |
| 2659 | { |
| 2660 | if (size < 0) |
| 2661 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2662 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2663 | } |
| 2664 | |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2665 | gl::Context *context = gl::getNonLostContext(); |
| 2666 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2667 | switch (usage) |
| 2668 | { |
| 2669 | case GL_STREAM_DRAW: |
| 2670 | case GL_STATIC_DRAW: |
| 2671 | case GL_DYNAMIC_DRAW: |
| 2672 | break; |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2673 | |
| 2674 | case GL_STREAM_READ: |
| 2675 | case GL_STREAM_COPY: |
| 2676 | case GL_STATIC_READ: |
| 2677 | case GL_STATIC_COPY: |
| 2678 | case GL_DYNAMIC_READ: |
| 2679 | case GL_DYNAMIC_COPY: |
| 2680 | if (context && context->getClientVersion() < 3) |
| 2681 | { |
| 2682 | return gl::error(GL_INVALID_ENUM); |
| 2683 | } |
| 2684 | break; |
| 2685 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2686 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2687 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2688 | } |
| 2689 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2690 | if (context) |
| 2691 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2692 | // Check ES3 specific targets |
| 2693 | switch (target) |
| 2694 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2695 | case GL_COPY_READ_BUFFER: |
| 2696 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2697 | case GL_PIXEL_PACK_BUFFER: |
| 2698 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2699 | case GL_UNIFORM_BUFFER: |
| 2700 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2701 | if (context->getClientVersion() < 3) |
| 2702 | { |
| 2703 | return gl::error(GL_INVALID_ENUM); |
| 2704 | } |
| 2705 | } |
| 2706 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2707 | gl::Buffer *buffer; |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2708 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2709 | switch (target) |
| 2710 | { |
| 2711 | case GL_ARRAY_BUFFER: |
| 2712 | buffer = context->getArrayBuffer(); |
| 2713 | break; |
| 2714 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2715 | buffer = context->getElementArrayBuffer(); |
| 2716 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2717 | case GL_COPY_READ_BUFFER: |
| 2718 | buffer = context->getCopyReadBuffer(); |
| 2719 | break; |
| 2720 | case GL_COPY_WRITE_BUFFER: |
| 2721 | buffer = context->getCopyWriteBuffer(); |
| 2722 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2723 | case GL_PIXEL_PACK_BUFFER: |
| 2724 | buffer = context->getPixelPackBuffer(); |
| 2725 | break; |
| 2726 | case GL_PIXEL_UNPACK_BUFFER: |
| 2727 | buffer = context->getPixelUnpackBuffer(); |
| 2728 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2729 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2730 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2731 | break; |
| 2732 | case GL_UNIFORM_BUFFER: |
| 2733 | buffer = context->getGenericUniformBuffer(); |
| 2734 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2735 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2736 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2737 | } |
| 2738 | |
| 2739 | if (!buffer) |
| 2740 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2741 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2742 | } |
| 2743 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2744 | buffer->bufferData(data, size, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2745 | } |
| 2746 | } |
| 2747 | catch(std::bad_alloc&) |
| 2748 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2749 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2750 | } |
| 2751 | } |
| 2752 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2753 | 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] | 2754 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2755 | 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] | 2756 | target, offset, size, data); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2757 | |
| 2758 | try |
| 2759 | { |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2760 | if (size < 0 || offset < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2761 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2762 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2763 | } |
| 2764 | |
daniel@transgaming.com | d4620a3 | 2010-03-21 04:31:28 +0000 | [diff] [blame] | 2765 | if (data == NULL) |
| 2766 | { |
| 2767 | return; |
| 2768 | } |
| 2769 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2770 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2771 | |
| 2772 | if (context) |
| 2773 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2774 | // Check ES3 specific targets |
| 2775 | switch (target) |
| 2776 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2777 | case GL_COPY_READ_BUFFER: |
| 2778 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2779 | case GL_PIXEL_PACK_BUFFER: |
| 2780 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2781 | case GL_UNIFORM_BUFFER: |
| 2782 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2783 | if (context->getClientVersion() < 3) |
| 2784 | { |
| 2785 | return gl::error(GL_INVALID_ENUM); |
| 2786 | } |
| 2787 | } |
| 2788 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2789 | gl::Buffer *buffer; |
| 2790 | |
| 2791 | switch (target) |
| 2792 | { |
| 2793 | case GL_ARRAY_BUFFER: |
| 2794 | buffer = context->getArrayBuffer(); |
| 2795 | break; |
| 2796 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2797 | buffer = context->getElementArrayBuffer(); |
| 2798 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2799 | case GL_COPY_READ_BUFFER: |
| 2800 | buffer = context->getCopyReadBuffer(); |
| 2801 | break; |
| 2802 | case GL_COPY_WRITE_BUFFER: |
| 2803 | buffer = context->getCopyWriteBuffer(); |
| 2804 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2805 | case GL_PIXEL_PACK_BUFFER: |
| 2806 | buffer = context->getPixelPackBuffer(); |
| 2807 | break; |
| 2808 | case GL_PIXEL_UNPACK_BUFFER: |
| 2809 | buffer = context->getPixelUnpackBuffer(); |
| 2810 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2811 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2812 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2813 | break; |
| 2814 | case GL_UNIFORM_BUFFER: |
| 2815 | buffer = context->getGenericUniformBuffer(); |
| 2816 | break; |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2817 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2818 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2819 | } |
| 2820 | |
| 2821 | if (!buffer) |
| 2822 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2823 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2824 | } |
| 2825 | |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2826 | if ((size_t)size + offset > buffer->size()) |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2827 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2828 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2829 | } |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2830 | |
| 2831 | buffer->bufferSubData(data, size, offset); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2832 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2833 | } |
| 2834 | catch(std::bad_alloc&) |
| 2835 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2836 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2837 | } |
| 2838 | } |
| 2839 | |
| 2840 | GLenum __stdcall glCheckFramebufferStatus(GLenum target) |
| 2841 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2842 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2843 | |
| 2844 | try |
| 2845 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2846 | 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] | 2847 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2848 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2849 | } |
| 2850 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2851 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2852 | |
| 2853 | if (context) |
| 2854 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2855 | gl::Framebuffer *framebuffer = NULL; |
| 2856 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 2857 | { |
| 2858 | framebuffer = context->getReadFramebuffer(); |
| 2859 | } |
| 2860 | else |
| 2861 | { |
| 2862 | framebuffer = context->getDrawFramebuffer(); |
| 2863 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2864 | |
| 2865 | return framebuffer->completeness(); |
| 2866 | } |
| 2867 | } |
| 2868 | catch(std::bad_alloc&) |
| 2869 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2870 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2871 | } |
| 2872 | |
| 2873 | return 0; |
| 2874 | } |
| 2875 | |
| 2876 | void __stdcall glClear(GLbitfield mask) |
| 2877 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2878 | EVENT("(GLbitfield mask = 0x%X)", mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2879 | |
| 2880 | try |
| 2881 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2882 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2883 | |
| 2884 | if (context) |
| 2885 | { |
| 2886 | context->clear(mask); |
| 2887 | } |
| 2888 | } |
| 2889 | catch(std::bad_alloc&) |
| 2890 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2891 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2892 | } |
| 2893 | } |
| 2894 | |
| 2895 | void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2896 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2897 | 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] | 2898 | red, green, blue, alpha); |
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->setClearColor(red, green, blue, alpha); |
| 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 glClearDepthf(GLclampf depth) |
| 2916 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2917 | EVENT("(GLclampf depth = %f)", depth); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2918 | |
| 2919 | try |
| 2920 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2921 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2922 | |
| 2923 | if (context) |
| 2924 | { |
| 2925 | context->setClearDepth(depth); |
| 2926 | } |
| 2927 | } |
| 2928 | catch(std::bad_alloc&) |
| 2929 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2930 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2931 | } |
| 2932 | } |
| 2933 | |
| 2934 | void __stdcall glClearStencil(GLint s) |
| 2935 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2936 | EVENT("(GLint s = %d)", s); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2937 | |
| 2938 | try |
| 2939 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2940 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2941 | |
| 2942 | if (context) |
| 2943 | { |
| 2944 | context->setClearStencil(s); |
| 2945 | } |
| 2946 | } |
| 2947 | catch(std::bad_alloc&) |
| 2948 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2949 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2950 | } |
| 2951 | } |
| 2952 | |
| 2953 | void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 2954 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2955 | 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] | 2956 | red, green, blue, alpha); |
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 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 2964 | 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] | 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 glCompileShader(GLuint shader) |
| 2974 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2975 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2976 | |
| 2977 | try |
| 2978 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2979 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2980 | |
| 2981 | if (context) |
| 2982 | { |
| 2983 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2984 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2985 | if (!shaderObject) |
| 2986 | { |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2987 | if (context->getProgram(shader)) |
| 2988 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2989 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2990 | } |
| 2991 | else |
| 2992 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2993 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2994 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2995 | } |
| 2996 | |
| 2997 | shaderObject->compile(); |
| 2998 | } |
| 2999 | } |
| 3000 | catch(std::bad_alloc&) |
| 3001 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3002 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3003 | } |
| 3004 | } |
| 3005 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3006 | void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, |
| 3007 | GLint border, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3008 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3009 | 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] | 3010 | "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] | 3011 | target, level, internalformat, width, height, border, imageSize, data); |
| 3012 | |
| 3013 | try |
| 3014 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3015 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3016 | |
| 3017 | if (context) |
| 3018 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3019 | if (context->getClientVersion() < 3 && |
| 3020 | !validateES2TexImageParameters(context, target, level, internalformat, true, false, |
| 3021 | 0, 0, width, height, 0, GL_NONE, GL_NONE, data)) |
| 3022 | { |
| 3023 | return; |
| 3024 | } |
| 3025 | |
| 3026 | if (context->getClientVersion() >= 3 && |
| 3027 | !validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 3028 | 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 3029 | { |
| 3030 | return; |
| 3031 | } |
| 3032 | |
| 3033 | 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] | 3034 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3035 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3036 | } |
| 3037 | |
| 3038 | switch (target) |
| 3039 | { |
| 3040 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3041 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3042 | gl::Texture2D *texture = context->getTexture2D(); |
| 3043 | texture->setCompressedImage(level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3044 | } |
| 3045 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3046 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3047 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3048 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3049 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3050 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3051 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3052 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3053 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3054 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3055 | texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3056 | } |
| 3057 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3058 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3059 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3060 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3061 | } |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3062 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3063 | } |
| 3064 | catch(std::bad_alloc&) |
| 3065 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3066 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3067 | } |
| 3068 | } |
| 3069 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3070 | void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 3071 | GLenum format, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3072 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3073 | 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] | 3074 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3075 | "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3076 | target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 3077 | |
| 3078 | try |
| 3079 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3080 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3081 | |
| 3082 | if (context) |
| 3083 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3084 | if (context->getClientVersion() < 3 && |
| 3085 | !validateES2TexImageParameters(context, target, level, GL_NONE, true, true, |
| 3086 | xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data)) |
| 3087 | { |
| 3088 | return; |
| 3089 | } |
| 3090 | |
| 3091 | if (context->getClientVersion() >= 3 && |
| 3092 | !validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 3093 | xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 3094 | { |
| 3095 | return; |
| 3096 | } |
| 3097 | |
| 3098 | 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] | 3099 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3100 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3101 | } |
| 3102 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3103 | switch (target) |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3104 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3105 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3106 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3107 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 3108 | texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3109 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3110 | break; |
| 3111 | |
| 3112 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3113 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3114 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3115 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3116 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3117 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3118 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3119 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 3120 | texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3121 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3122 | break; |
| 3123 | |
| 3124 | default: |
| 3125 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3126 | } |
| 3127 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3128 | } |
| 3129 | catch(std::bad_alloc&) |
| 3130 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3131 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3132 | } |
| 3133 | } |
| 3134 | |
| 3135 | void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) |
| 3136 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3137 | 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] | 3138 | "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] | 3139 | target, level, internalformat, x, y, width, height, border); |
| 3140 | |
| 3141 | try |
| 3142 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3143 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3144 | |
| 3145 | if (context) |
| 3146 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3147 | if (context->getClientVersion() < 3 && |
| 3148 | !validateES2CopyTexImageParameters(context, target, level, internalformat, false, |
| 3149 | 0, 0, x, y, width, height, border)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 3150 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3151 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 3152 | } |
| 3153 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3154 | if (context->getClientVersion() >= 3 && |
| 3155 | !validateES3CopyTexImageParameters(context, target, level, internalformat, false, |
| 3156 | 0, 0, 0, x, y, width, height, border)) |
| 3157 | { |
| 3158 | return; |
| 3159 | } |
| 3160 | |
| 3161 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 3162 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3163 | switch (target) |
| 3164 | { |
| 3165 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3166 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3167 | gl::Texture2D *texture = context->getTexture2D(); |
| 3168 | texture->copyImage(level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3169 | } |
| 3170 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3171 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3172 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3173 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3174 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3175 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3176 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3177 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3178 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3179 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3180 | texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3181 | } |
| 3182 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3183 | |
| 3184 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3185 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3186 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3187 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3188 | } |
| 3189 | catch(std::bad_alloc&) |
| 3190 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3191 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3192 | } |
| 3193 | } |
| 3194 | |
| 3195 | void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 3196 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3197 | 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] | 3198 | "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] | 3199 | target, level, xoffset, yoffset, x, y, width, height); |
| 3200 | |
| 3201 | try |
| 3202 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3203 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3204 | |
| 3205 | if (context) |
| 3206 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3207 | if (context->getClientVersion() < 3 && |
| 3208 | !validateES2CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 3209 | xoffset, yoffset, x, y, width, height, 0)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3210 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3211 | return; |
| 3212 | } |
| 3213 | |
| 3214 | if (context->getClientVersion() >= 3 && |
| 3215 | !validateES3CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 3216 | xoffset, yoffset, 0, x, y, width, height, 0)) |
| 3217 | { |
| 3218 | return; |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3219 | } |
| 3220 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3221 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3222 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3223 | switch (target) |
daniel@transgaming.com | bbc5779 | 2010-07-28 19:21:05 +0000 | [diff] [blame] | 3224 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3225 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 3226 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3227 | gl::Texture2D *texture = context->getTexture2D(); |
| 3228 | 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] | 3229 | } |
| 3230 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3231 | |
| 3232 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3233 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3234 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3235 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3236 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3237 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 3238 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3239 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3240 | 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] | 3241 | } |
| 3242 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3243 | |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3244 | default: |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3245 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3246 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3247 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3248 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3249 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3250 | catch(std::bad_alloc&) |
| 3251 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3252 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3253 | } |
| 3254 | } |
| 3255 | |
| 3256 | GLuint __stdcall glCreateProgram(void) |
| 3257 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3258 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3259 | |
| 3260 | try |
| 3261 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3262 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3263 | |
| 3264 | if (context) |
| 3265 | { |
| 3266 | return context->createProgram(); |
| 3267 | } |
| 3268 | } |
| 3269 | catch(std::bad_alloc&) |
| 3270 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3271 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3272 | } |
| 3273 | |
| 3274 | return 0; |
| 3275 | } |
| 3276 | |
| 3277 | GLuint __stdcall glCreateShader(GLenum type) |
| 3278 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3279 | EVENT("(GLenum type = 0x%X)", type); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3280 | |
| 3281 | try |
| 3282 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3283 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3284 | |
| 3285 | if (context) |
| 3286 | { |
| 3287 | switch (type) |
| 3288 | { |
| 3289 | case GL_FRAGMENT_SHADER: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 3290 | case GL_VERTEX_SHADER: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3291 | return context->createShader(type); |
| 3292 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3293 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3294 | } |
| 3295 | } |
| 3296 | } |
| 3297 | catch(std::bad_alloc&) |
| 3298 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3299 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3300 | } |
| 3301 | |
| 3302 | return 0; |
| 3303 | } |
| 3304 | |
| 3305 | void __stdcall glCullFace(GLenum mode) |
| 3306 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3307 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3308 | |
| 3309 | try |
| 3310 | { |
| 3311 | switch (mode) |
| 3312 | { |
| 3313 | case GL_FRONT: |
| 3314 | case GL_BACK: |
| 3315 | case GL_FRONT_AND_BACK: |
| 3316 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3317 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3318 | |
| 3319 | if (context) |
| 3320 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3321 | context->setCullMode(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3322 | } |
| 3323 | } |
| 3324 | break; |
| 3325 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3326 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3327 | } |
| 3328 | } |
| 3329 | catch(std::bad_alloc&) |
| 3330 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3331 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3332 | } |
| 3333 | } |
| 3334 | |
| 3335 | void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers) |
| 3336 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3337 | 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] | 3338 | |
| 3339 | try |
| 3340 | { |
| 3341 | if (n < 0) |
| 3342 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3343 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3344 | } |
| 3345 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3346 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3347 | |
| 3348 | if (context) |
| 3349 | { |
| 3350 | for (int i = 0; i < n; i++) |
| 3351 | { |
| 3352 | context->deleteBuffer(buffers[i]); |
| 3353 | } |
| 3354 | } |
| 3355 | } |
| 3356 | catch(std::bad_alloc&) |
| 3357 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3358 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3359 | } |
| 3360 | } |
| 3361 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3362 | void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences) |
| 3363 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3364 | 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] | 3365 | |
| 3366 | try |
| 3367 | { |
| 3368 | if (n < 0) |
| 3369 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3370 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3371 | } |
| 3372 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3373 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3374 | |
| 3375 | if (context) |
| 3376 | { |
| 3377 | for (int i = 0; i < n; i++) |
| 3378 | { |
| 3379 | context->deleteFence(fences[i]); |
| 3380 | } |
| 3381 | } |
| 3382 | } |
| 3383 | catch(std::bad_alloc&) |
| 3384 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3385 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3386 | } |
| 3387 | } |
| 3388 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3389 | void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) |
| 3390 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3391 | 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] | 3392 | |
| 3393 | try |
| 3394 | { |
| 3395 | if (n < 0) |
| 3396 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3397 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3398 | } |
| 3399 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3400 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3401 | |
| 3402 | if (context) |
| 3403 | { |
| 3404 | for (int i = 0; i < n; i++) |
| 3405 | { |
| 3406 | if (framebuffers[i] != 0) |
| 3407 | { |
| 3408 | context->deleteFramebuffer(framebuffers[i]); |
| 3409 | } |
| 3410 | } |
| 3411 | } |
| 3412 | } |
| 3413 | catch(std::bad_alloc&) |
| 3414 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3415 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3416 | } |
| 3417 | } |
| 3418 | |
| 3419 | void __stdcall glDeleteProgram(GLuint program) |
| 3420 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3421 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3422 | |
| 3423 | try |
| 3424 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3425 | if (program == 0) |
| 3426 | { |
| 3427 | return; |
| 3428 | } |
| 3429 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3430 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3431 | |
| 3432 | if (context) |
| 3433 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3434 | if (!context->getProgram(program)) |
| 3435 | { |
| 3436 | if(context->getShader(program)) |
| 3437 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3438 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3439 | } |
| 3440 | else |
| 3441 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3442 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3443 | } |
| 3444 | } |
| 3445 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3446 | context->deleteProgram(program); |
| 3447 | } |
| 3448 | } |
| 3449 | catch(std::bad_alloc&) |
| 3450 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3451 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3452 | } |
| 3453 | } |
| 3454 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3455 | void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids) |
| 3456 | { |
| 3457 | EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids); |
| 3458 | |
| 3459 | try |
| 3460 | { |
| 3461 | if (n < 0) |
| 3462 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3463 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3464 | } |
| 3465 | |
| 3466 | gl::Context *context = gl::getNonLostContext(); |
| 3467 | |
| 3468 | if (context) |
| 3469 | { |
| 3470 | for (int i = 0; i < n; i++) |
| 3471 | { |
| 3472 | context->deleteQuery(ids[i]); |
| 3473 | } |
| 3474 | } |
| 3475 | } |
| 3476 | catch(std::bad_alloc&) |
| 3477 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3478 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3479 | } |
| 3480 | } |
| 3481 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3482 | void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) |
| 3483 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3484 | 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] | 3485 | |
| 3486 | try |
| 3487 | { |
| 3488 | if (n < 0) |
| 3489 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3490 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3491 | } |
| 3492 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3493 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3494 | |
| 3495 | if (context) |
| 3496 | { |
daniel@transgaming.com | e2b2212 | 2010-03-11 19:22:14 +0000 | [diff] [blame] | 3497 | for (int i = 0; i < n; i++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3498 | { |
| 3499 | context->deleteRenderbuffer(renderbuffers[i]); |
| 3500 | } |
| 3501 | } |
| 3502 | } |
| 3503 | catch(std::bad_alloc&) |
| 3504 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3505 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3506 | } |
| 3507 | } |
| 3508 | |
| 3509 | void __stdcall glDeleteShader(GLuint shader) |
| 3510 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3511 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3512 | |
| 3513 | try |
| 3514 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3515 | if (shader == 0) |
| 3516 | { |
| 3517 | return; |
| 3518 | } |
| 3519 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3520 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3521 | |
| 3522 | if (context) |
| 3523 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3524 | if (!context->getShader(shader)) |
| 3525 | { |
| 3526 | if(context->getProgram(shader)) |
| 3527 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3528 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3529 | } |
| 3530 | else |
| 3531 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3532 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3533 | } |
| 3534 | } |
| 3535 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3536 | context->deleteShader(shader); |
| 3537 | } |
| 3538 | } |
| 3539 | catch(std::bad_alloc&) |
| 3540 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3541 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3542 | } |
| 3543 | } |
| 3544 | |
| 3545 | void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures) |
| 3546 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3547 | 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] | 3548 | |
| 3549 | try |
| 3550 | { |
| 3551 | if (n < 0) |
| 3552 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3553 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3554 | } |
| 3555 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3556 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3557 | |
| 3558 | if (context) |
| 3559 | { |
| 3560 | for (int i = 0; i < n; i++) |
| 3561 | { |
| 3562 | if (textures[i] != 0) |
| 3563 | { |
| 3564 | context->deleteTexture(textures[i]); |
| 3565 | } |
| 3566 | } |
| 3567 | } |
| 3568 | } |
| 3569 | catch(std::bad_alloc&) |
| 3570 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3571 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3572 | } |
| 3573 | } |
| 3574 | |
| 3575 | void __stdcall glDepthFunc(GLenum func) |
| 3576 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3577 | EVENT("(GLenum func = 0x%X)", func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3578 | |
| 3579 | try |
| 3580 | { |
| 3581 | switch (func) |
| 3582 | { |
| 3583 | case GL_NEVER: |
| 3584 | case GL_ALWAYS: |
| 3585 | case GL_LESS: |
| 3586 | case GL_LEQUAL: |
| 3587 | case GL_EQUAL: |
| 3588 | case GL_GREATER: |
| 3589 | case GL_GEQUAL: |
| 3590 | case GL_NOTEQUAL: |
| 3591 | break; |
| 3592 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3593 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3594 | } |
| 3595 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3596 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3597 | |
| 3598 | if (context) |
| 3599 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3600 | context->setDepthFunc(func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3601 | } |
| 3602 | } |
| 3603 | catch(std::bad_alloc&) |
| 3604 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3605 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3606 | } |
| 3607 | } |
| 3608 | |
| 3609 | void __stdcall glDepthMask(GLboolean flag) |
| 3610 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 3611 | EVENT("(GLboolean flag = %u)", flag); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3612 | |
| 3613 | try |
| 3614 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3615 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3616 | |
| 3617 | if (context) |
| 3618 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3619 | context->setDepthMask(flag != GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3620 | } |
| 3621 | } |
| 3622 | catch(std::bad_alloc&) |
| 3623 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3624 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3625 | } |
| 3626 | } |
| 3627 | |
| 3628 | void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar) |
| 3629 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3630 | EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3631 | |
| 3632 | try |
| 3633 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3634 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3635 | |
| 3636 | if (context) |
| 3637 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3638 | context->setDepthRange(zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3639 | } |
| 3640 | } |
| 3641 | catch(std::bad_alloc&) |
| 3642 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3643 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3644 | } |
| 3645 | } |
| 3646 | |
| 3647 | void __stdcall glDetachShader(GLuint program, GLuint shader) |
| 3648 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3649 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3650 | |
| 3651 | try |
| 3652 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3653 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3654 | |
| 3655 | if (context) |
| 3656 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3657 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3658 | gl::Program *programObject = context->getProgram(program); |
| 3659 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3660 | |
| 3661 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3662 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3663 | gl::Shader *shaderByProgramHandle; |
| 3664 | shaderByProgramHandle = context->getShader(program); |
| 3665 | if (!shaderByProgramHandle) |
| 3666 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3667 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3668 | } |
| 3669 | else |
| 3670 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3671 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3672 | } |
| 3673 | } |
| 3674 | |
| 3675 | if (!shaderObject) |
| 3676 | { |
| 3677 | gl::Program *programByShaderHandle = context->getProgram(shader); |
| 3678 | if (!programByShaderHandle) |
| 3679 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3680 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3681 | } |
| 3682 | else |
| 3683 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3684 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3685 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3686 | } |
| 3687 | |
| 3688 | if (!programObject->detachShader(shaderObject)) |
| 3689 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3690 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3691 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3692 | } |
| 3693 | } |
| 3694 | catch(std::bad_alloc&) |
| 3695 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3696 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3697 | } |
| 3698 | } |
| 3699 | |
| 3700 | void __stdcall glDisable(GLenum cap) |
| 3701 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3702 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3703 | |
| 3704 | try |
| 3705 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3706 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3707 | |
| 3708 | if (context) |
| 3709 | { |
| 3710 | switch (cap) |
| 3711 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3712 | case GL_CULL_FACE: context->setCullFace(false); break; |
| 3713 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break; |
| 3714 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break; |
| 3715 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break; |
| 3716 | case GL_SCISSOR_TEST: context->setScissorTest(false); break; |
| 3717 | case GL_STENCIL_TEST: context->setStencilTest(false); break; |
| 3718 | case GL_DEPTH_TEST: context->setDepthTest(false); break; |
| 3719 | case GL_BLEND: context->setBlend(false); break; |
| 3720 | case GL_DITHER: context->setDither(false); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 3721 | |
| 3722 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 3723 | case GL_RASTERIZER_DISCARD: |
| 3724 | if (context->getClientVersion() < 3) |
| 3725 | { |
| 3726 | return gl::error(GL_INVALID_ENUM); |
| 3727 | } |
| 3728 | UNIMPLEMENTED(); |
| 3729 | break; |
| 3730 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3731 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3732 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3733 | } |
| 3734 | } |
| 3735 | } |
| 3736 | catch(std::bad_alloc&) |
| 3737 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3738 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3739 | } |
| 3740 | } |
| 3741 | |
| 3742 | void __stdcall glDisableVertexAttribArray(GLuint index) |
| 3743 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3744 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3745 | |
| 3746 | try |
| 3747 | { |
| 3748 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3749 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3750 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3751 | } |
| 3752 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3753 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3754 | |
| 3755 | if (context) |
| 3756 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3757 | context->setEnableVertexAttribArray(index, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3758 | } |
| 3759 | } |
| 3760 | catch(std::bad_alloc&) |
| 3761 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3762 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3763 | } |
| 3764 | } |
| 3765 | |
| 3766 | void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count) |
| 3767 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3768 | 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] | 3769 | |
| 3770 | try |
| 3771 | { |
| 3772 | if (count < 0 || first < 0) |
| 3773 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3774 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3775 | } |
| 3776 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3777 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3778 | |
| 3779 | if (context) |
| 3780 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3781 | context->drawArrays(mode, first, count, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3782 | } |
| 3783 | } |
| 3784 | catch(std::bad_alloc&) |
| 3785 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3786 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3787 | } |
| 3788 | } |
| 3789 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3790 | void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
| 3791 | { |
| 3792 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount); |
| 3793 | |
| 3794 | try |
| 3795 | { |
| 3796 | if (count < 0 || first < 0 || primcount < 0) |
| 3797 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3798 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3799 | } |
| 3800 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3801 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3802 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3803 | gl::Context *context = gl::getNonLostContext(); |
| 3804 | |
| 3805 | if (context) |
| 3806 | { |
| 3807 | context->drawArrays(mode, first, count, primcount); |
| 3808 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3809 | } |
| 3810 | } |
| 3811 | catch(std::bad_alloc&) |
| 3812 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3813 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3814 | } |
| 3815 | } |
| 3816 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3817 | 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] | 3818 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3819 | 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] | 3820 | mode, count, type, indices); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3821 | |
| 3822 | try |
| 3823 | { |
| 3824 | if (count < 0) |
| 3825 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3826 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3827 | } |
| 3828 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3829 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3830 | |
| 3831 | if (context) |
| 3832 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3833 | switch (type) |
| 3834 | { |
| 3835 | case GL_UNSIGNED_BYTE: |
| 3836 | case GL_UNSIGNED_SHORT: |
| 3837 | break; |
| 3838 | case GL_UNSIGNED_INT: |
| 3839 | if (!context->supports32bitIndices()) |
| 3840 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3841 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3842 | } |
| 3843 | break; |
| 3844 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3845 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3846 | } |
| 3847 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3848 | context->drawElements(mode, count, type, indices, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3849 | } |
| 3850 | } |
| 3851 | catch(std::bad_alloc&) |
| 3852 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3853 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3854 | } |
| 3855 | } |
| 3856 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3857 | void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount) |
| 3858 | { |
| 3859 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)", |
| 3860 | mode, count, type, indices, primcount); |
| 3861 | |
| 3862 | try |
| 3863 | { |
| 3864 | if (count < 0 || primcount < 0) |
| 3865 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3866 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3867 | } |
| 3868 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3869 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3870 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3871 | gl::Context *context = gl::getNonLostContext(); |
| 3872 | |
| 3873 | if (context) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3874 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3875 | switch (type) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3876 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3877 | case GL_UNSIGNED_BYTE: |
| 3878 | case GL_UNSIGNED_SHORT: |
| 3879 | break; |
| 3880 | case GL_UNSIGNED_INT: |
| 3881 | if (!context->supports32bitIndices()) |
| 3882 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3883 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3884 | } |
| 3885 | break; |
| 3886 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3887 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3888 | } |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3889 | |
| 3890 | context->drawElements(mode, count, type, indices, primcount); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3891 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3892 | } |
| 3893 | } |
| 3894 | catch(std::bad_alloc&) |
| 3895 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3896 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3897 | } |
| 3898 | } |
| 3899 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3900 | void __stdcall glEnable(GLenum cap) |
| 3901 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3902 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3903 | |
| 3904 | try |
| 3905 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3906 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3907 | |
| 3908 | if (context) |
| 3909 | { |
| 3910 | switch (cap) |
| 3911 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3912 | case GL_CULL_FACE: context->setCullFace(true); break; |
| 3913 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break; |
| 3914 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break; |
| 3915 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break; |
| 3916 | case GL_SCISSOR_TEST: context->setScissorTest(true); break; |
| 3917 | case GL_STENCIL_TEST: context->setStencilTest(true); break; |
| 3918 | case GL_DEPTH_TEST: context->setDepthTest(true); break; |
| 3919 | case GL_BLEND: context->setBlend(true); break; |
| 3920 | case GL_DITHER: context->setDither(true); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3921 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3922 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3923 | } |
| 3924 | } |
| 3925 | } |
| 3926 | catch(std::bad_alloc&) |
| 3927 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3928 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3929 | } |
| 3930 | } |
| 3931 | |
| 3932 | void __stdcall glEnableVertexAttribArray(GLuint index) |
| 3933 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3934 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3935 | |
| 3936 | try |
| 3937 | { |
| 3938 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3939 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3940 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3941 | } |
| 3942 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3943 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3944 | |
| 3945 | if (context) |
| 3946 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3947 | context->setEnableVertexAttribArray(index, true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3948 | } |
| 3949 | } |
| 3950 | catch(std::bad_alloc&) |
| 3951 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3952 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3953 | } |
| 3954 | } |
| 3955 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3956 | void __stdcall glEndQueryEXT(GLenum target) |
| 3957 | { |
| 3958 | EVENT("GLenum target = 0x%X)", target); |
| 3959 | |
| 3960 | try |
| 3961 | { |
| 3962 | switch (target) |
| 3963 | { |
| 3964 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 3965 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 3966 | break; |
| 3967 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3968 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3969 | } |
| 3970 | |
| 3971 | gl::Context *context = gl::getNonLostContext(); |
| 3972 | |
| 3973 | if (context) |
| 3974 | { |
| 3975 | context->endQuery(target); |
| 3976 | } |
| 3977 | } |
| 3978 | catch(std::bad_alloc&) |
| 3979 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3980 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3981 | } |
| 3982 | } |
| 3983 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3984 | void __stdcall glFinishFenceNV(GLuint fence) |
| 3985 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3986 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3987 | |
| 3988 | try |
| 3989 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3990 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3991 | |
| 3992 | if (context) |
| 3993 | { |
| 3994 | gl::Fence* fenceObject = context->getFence(fence); |
| 3995 | |
| 3996 | if (fenceObject == NULL) |
| 3997 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3998 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3999 | } |
| 4000 | |
| 4001 | fenceObject->finishFence(); |
| 4002 | } |
| 4003 | } |
| 4004 | catch(std::bad_alloc&) |
| 4005 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4006 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4007 | } |
| 4008 | } |
| 4009 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4010 | void __stdcall glFinish(void) |
| 4011 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4012 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4013 | |
| 4014 | try |
| 4015 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4016 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4017 | |
| 4018 | if (context) |
| 4019 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 4020 | context->sync(true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4021 | } |
| 4022 | } |
| 4023 | catch(std::bad_alloc&) |
| 4024 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4025 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4026 | } |
| 4027 | } |
| 4028 | |
| 4029 | void __stdcall glFlush(void) |
| 4030 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4031 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4032 | |
| 4033 | try |
| 4034 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4035 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4036 | |
| 4037 | if (context) |
| 4038 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 4039 | context->sync(false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4040 | } |
| 4041 | } |
| 4042 | catch(std::bad_alloc&) |
| 4043 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4044 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4045 | } |
| 4046 | } |
| 4047 | |
| 4048 | void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) |
| 4049 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4050 | 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] | 4051 | "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4052 | |
| 4053 | try |
| 4054 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4055 | 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] | 4056 | || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4057 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4058 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4059 | } |
| 4060 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4061 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4062 | |
| 4063 | if (context) |
| 4064 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4065 | gl::Framebuffer *framebuffer = NULL; |
| 4066 | GLuint framebufferHandle = 0; |
| 4067 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4068 | { |
| 4069 | framebuffer = context->getReadFramebuffer(); |
| 4070 | framebufferHandle = context->getReadFramebufferHandle(); |
| 4071 | } |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 4072 | else |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4073 | { |
| 4074 | framebuffer = context->getDrawFramebuffer(); |
| 4075 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 4076 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4077 | |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 4078 | if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4079 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4080 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4081 | } |
| 4082 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4083 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4084 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4085 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4086 | |
| 4087 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4088 | { |
| 4089 | return gl::error(GL_INVALID_VALUE); |
| 4090 | } |
| 4091 | |
| 4092 | framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer); |
| 4093 | } |
| 4094 | else |
| 4095 | { |
| 4096 | switch (attachment) |
| 4097 | { |
| 4098 | case GL_DEPTH_ATTACHMENT: |
| 4099 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer); |
| 4100 | break; |
| 4101 | case GL_STENCIL_ATTACHMENT: |
| 4102 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer); |
| 4103 | break; |
| 4104 | default: |
| 4105 | return gl::error(GL_INVALID_ENUM); |
| 4106 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4107 | } |
| 4108 | } |
| 4109 | } |
| 4110 | catch(std::bad_alloc&) |
| 4111 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4112 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4113 | } |
| 4114 | } |
| 4115 | |
| 4116 | void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) |
| 4117 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4118 | 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] | 4119 | "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4120 | |
| 4121 | try |
| 4122 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4123 | 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] | 4124 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4125 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4126 | } |
| 4127 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4128 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4129 | |
| 4130 | if (context) |
| 4131 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4132 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 4133 | { |
| 4134 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4135 | |
| 4136 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4137 | { |
| 4138 | return gl::error(GL_INVALID_VALUE); |
| 4139 | } |
| 4140 | } |
| 4141 | else |
| 4142 | { |
| 4143 | switch (attachment) |
| 4144 | { |
| 4145 | case GL_DEPTH_ATTACHMENT: |
| 4146 | case GL_STENCIL_ATTACHMENT: |
| 4147 | break; |
| 4148 | default: |
| 4149 | return gl::error(GL_INVALID_ENUM); |
| 4150 | } |
| 4151 | } |
| 4152 | |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4153 | if (texture == 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4154 | { |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4155 | textarget = GL_NONE; |
| 4156 | } |
| 4157 | else |
| 4158 | { |
| 4159 | gl::Texture *tex = context->getTexture(texture); |
| 4160 | |
| 4161 | if (tex == NULL) |
| 4162 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4163 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4164 | } |
| 4165 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4166 | switch (textarget) |
| 4167 | { |
| 4168 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4169 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4170 | if (tex->getTarget() != GL_TEXTURE_2D) |
| 4171 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4172 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4173 | } |
| 4174 | gl::Texture2D *tex2d = static_cast<gl::Texture2D *>(tex); |
daniel@transgaming.com | 92f4992 | 2012-05-09 15:49:19 +0000 | [diff] [blame] | 4175 | if (tex2d->isCompressed(0)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4176 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4177 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4178 | } |
| 4179 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4180 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4181 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4182 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4183 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4184 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4185 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4186 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4187 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4188 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4189 | if (tex->getTarget() != GL_TEXTURE_CUBE_MAP) |
| 4190 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4191 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4192 | } |
| 4193 | gl::TextureCubeMap *texcube = static_cast<gl::TextureCubeMap *>(tex); |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 4194 | if (texcube->isCompressed(textarget, level)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4195 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4196 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4197 | } |
| 4198 | break; |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4199 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4200 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4201 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4202 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4203 | } |
| 4204 | |
| 4205 | if (level != 0) |
| 4206 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4207 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4208 | } |
| 4209 | } |
| 4210 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4211 | gl::Framebuffer *framebuffer = NULL; |
| 4212 | GLuint framebufferHandle = 0; |
| 4213 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4214 | { |
| 4215 | framebuffer = context->getReadFramebuffer(); |
| 4216 | framebufferHandle = context->getReadFramebufferHandle(); |
| 4217 | } |
| 4218 | else |
| 4219 | { |
| 4220 | framebuffer = context->getDrawFramebuffer(); |
| 4221 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 4222 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4223 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4224 | if (framebufferHandle == 0 || !framebuffer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4225 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4226 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4227 | } |
| 4228 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4229 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4230 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4231 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4232 | |
| 4233 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4234 | { |
| 4235 | return gl::error(GL_INVALID_VALUE); |
| 4236 | } |
| 4237 | |
| 4238 | framebuffer->setColorbuffer(colorAttachment, textarget, texture); |
| 4239 | } |
| 4240 | else |
| 4241 | { |
| 4242 | switch (attachment) |
| 4243 | { |
| 4244 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break; |
| 4245 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break; |
| 4246 | } |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4247 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4248 | } |
| 4249 | } |
| 4250 | catch(std::bad_alloc&) |
| 4251 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4252 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4253 | } |
| 4254 | } |
| 4255 | |
| 4256 | void __stdcall glFrontFace(GLenum mode) |
| 4257 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4258 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4259 | |
| 4260 | try |
| 4261 | { |
| 4262 | switch (mode) |
| 4263 | { |
| 4264 | case GL_CW: |
| 4265 | case GL_CCW: |
| 4266 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4267 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4268 | |
| 4269 | if (context) |
| 4270 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4271 | context->setFrontFace(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4272 | } |
| 4273 | } |
| 4274 | break; |
| 4275 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4276 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4277 | } |
| 4278 | } |
| 4279 | catch(std::bad_alloc&) |
| 4280 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4281 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4282 | } |
| 4283 | } |
| 4284 | |
| 4285 | void __stdcall glGenBuffers(GLsizei n, GLuint* buffers) |
| 4286 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4287 | EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4288 | |
| 4289 | try |
| 4290 | { |
| 4291 | if (n < 0) |
| 4292 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4293 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4294 | } |
| 4295 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4296 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4297 | |
| 4298 | if (context) |
| 4299 | { |
| 4300 | for (int i = 0; i < n; i++) |
| 4301 | { |
| 4302 | buffers[i] = context->createBuffer(); |
| 4303 | } |
| 4304 | } |
| 4305 | } |
| 4306 | catch(std::bad_alloc&) |
| 4307 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4308 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4309 | } |
| 4310 | } |
| 4311 | |
| 4312 | void __stdcall glGenerateMipmap(GLenum target) |
| 4313 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4314 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4315 | |
| 4316 | try |
| 4317 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4318 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4319 | |
| 4320 | if (context) |
| 4321 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4322 | gl::Texture *texture = NULL; |
| 4323 | GLint internalFormat = GL_NONE; |
| 4324 | bool isCompressed = false; |
| 4325 | bool isDepth = false; |
| 4326 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4327 | switch (target) |
| 4328 | { |
| 4329 | case GL_TEXTURE_2D: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4330 | { |
| 4331 | gl::Texture2D *tex2d = context->getTexture2D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4332 | if (tex2d) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4333 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4334 | internalFormat = tex2d->getInternalFormat(0); |
| 4335 | isCompressed = tex2d->isCompressed(0); |
| 4336 | isDepth = tex2d->isDepth(0); |
| 4337 | texture = tex2d; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4338 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4339 | break; |
| 4340 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4341 | |
| 4342 | case GL_TEXTURE_CUBE_MAP: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4343 | { |
| 4344 | gl::TextureCubeMap *texcube = context->getTextureCubeMap(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4345 | if (texcube) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4346 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4347 | internalFormat = texcube->getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 4348 | isCompressed = texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 4349 | isDepth = false; |
| 4350 | texture = texcube; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4351 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4352 | break; |
| 4353 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4354 | |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4355 | case GL_TEXTURE_3D: |
| 4356 | { |
| 4357 | if (context->getClientVersion() < 3) |
| 4358 | { |
| 4359 | return gl::error(GL_INVALID_ENUM); |
| 4360 | } |
| 4361 | |
| 4362 | gl::Texture3D *tex3D = context->getTexture3D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4363 | if (tex3D) |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4364 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4365 | internalFormat = tex3D->getInternalFormat(0); |
| 4366 | isCompressed = tex3D->isCompressed(0); |
| 4367 | isDepth = tex3D->isDepth(0); |
| 4368 | texture = tex3D; |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4369 | } |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4370 | break; |
| 4371 | } |
| 4372 | |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4373 | case GL_TEXTURE_2D_ARRAY: |
| 4374 | { |
| 4375 | if (context->getClientVersion() < 3) |
| 4376 | { |
| 4377 | return gl::error(GL_INVALID_ENUM); |
| 4378 | } |
| 4379 | |
| 4380 | gl::Texture2DArray *tex2darr = context->getTexture2DArray(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4381 | if (tex2darr) |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4382 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4383 | internalFormat = tex2darr->getInternalFormat(0); |
| 4384 | isCompressed = tex2darr->isCompressed(0); |
| 4385 | isDepth = tex2darr->isDepth(0); |
| 4386 | texture = tex2darr; |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4387 | } |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4388 | break; |
| 4389 | } |
| 4390 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4391 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4392 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4393 | } |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4394 | |
| 4395 | if (!texture) |
| 4396 | { |
| 4397 | return gl::error(GL_INVALID_OPERATION); |
| 4398 | } |
| 4399 | |
| 4400 | // Internally, all texture formats are sized so checking if the format |
| 4401 | // is color renderable and filterable will not fail. |
| 4402 | if (isDepth || isCompressed || |
| 4403 | !gl::IsColorRenderingSupported(internalFormat, context) || |
| 4404 | !gl::IsTextureFilteringSupported(internalFormat, context)) |
| 4405 | { |
| 4406 | return gl::error(GL_INVALID_OPERATION); |
| 4407 | } |
| 4408 | |
| 4409 | texture->generateMipmaps(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4410 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4411 | } |
| 4412 | catch(std::bad_alloc&) |
| 4413 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4414 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4415 | } |
| 4416 | } |
| 4417 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4418 | void __stdcall glGenFencesNV(GLsizei n, GLuint* fences) |
| 4419 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4420 | EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4421 | |
| 4422 | try |
| 4423 | { |
| 4424 | if (n < 0) |
| 4425 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4426 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4427 | } |
| 4428 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4429 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4430 | |
| 4431 | if (context) |
| 4432 | { |
| 4433 | for (int i = 0; i < n; i++) |
| 4434 | { |
| 4435 | fences[i] = context->createFence(); |
| 4436 | } |
| 4437 | } |
| 4438 | } |
| 4439 | catch(std::bad_alloc&) |
| 4440 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4441 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4442 | } |
| 4443 | } |
| 4444 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4445 | void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers) |
| 4446 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4447 | EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4448 | |
| 4449 | try |
| 4450 | { |
| 4451 | if (n < 0) |
| 4452 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4453 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4454 | } |
| 4455 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4456 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4457 | |
| 4458 | if (context) |
| 4459 | { |
| 4460 | for (int i = 0; i < n; i++) |
| 4461 | { |
| 4462 | framebuffers[i] = context->createFramebuffer(); |
| 4463 | } |
| 4464 | } |
| 4465 | } |
| 4466 | catch(std::bad_alloc&) |
| 4467 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4468 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4469 | } |
| 4470 | } |
| 4471 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4472 | void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids) |
| 4473 | { |
| 4474 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 4475 | |
| 4476 | try |
| 4477 | { |
| 4478 | if (n < 0) |
| 4479 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4480 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4481 | } |
| 4482 | |
| 4483 | gl::Context *context = gl::getNonLostContext(); |
| 4484 | |
| 4485 | if (context) |
| 4486 | { |
| 4487 | for (int i = 0; i < n; i++) |
| 4488 | { |
| 4489 | ids[i] = context->createQuery(); |
| 4490 | } |
| 4491 | } |
| 4492 | } |
| 4493 | catch(std::bad_alloc&) |
| 4494 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4495 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4496 | } |
| 4497 | } |
| 4498 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4499 | void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) |
| 4500 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4501 | EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4502 | |
| 4503 | try |
| 4504 | { |
| 4505 | if (n < 0) |
| 4506 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4507 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4508 | } |
| 4509 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4510 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4511 | |
| 4512 | if (context) |
| 4513 | { |
| 4514 | for (int i = 0; i < n; i++) |
| 4515 | { |
| 4516 | renderbuffers[i] = context->createRenderbuffer(); |
| 4517 | } |
| 4518 | } |
| 4519 | } |
| 4520 | catch(std::bad_alloc&) |
| 4521 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4522 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4523 | } |
| 4524 | } |
| 4525 | |
| 4526 | void __stdcall glGenTextures(GLsizei n, GLuint* textures) |
| 4527 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4528 | EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4529 | |
| 4530 | try |
| 4531 | { |
| 4532 | if (n < 0) |
| 4533 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4534 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4535 | } |
| 4536 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4537 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4538 | |
| 4539 | if (context) |
| 4540 | { |
| 4541 | for (int i = 0; i < n; i++) |
| 4542 | { |
| 4543 | textures[i] = context->createTexture(); |
| 4544 | } |
| 4545 | } |
| 4546 | } |
| 4547 | catch(std::bad_alloc&) |
| 4548 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4549 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4550 | } |
| 4551 | } |
| 4552 | |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4553 | 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] | 4554 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4555 | 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] | 4556 | "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] | 4557 | program, index, bufsize, length, size, type, name); |
| 4558 | |
| 4559 | try |
| 4560 | { |
| 4561 | if (bufsize < 0) |
| 4562 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4563 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4564 | } |
| 4565 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4566 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4567 | |
| 4568 | if (context) |
| 4569 | { |
| 4570 | gl::Program *programObject = context->getProgram(program); |
| 4571 | |
| 4572 | if (!programObject) |
| 4573 | { |
| 4574 | if (context->getShader(program)) |
| 4575 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4576 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4577 | } |
| 4578 | else |
| 4579 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4580 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4581 | } |
| 4582 | } |
| 4583 | |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4584 | if (index >= (GLuint)programObject->getActiveAttributeCount()) |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4585 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4586 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4587 | } |
| 4588 | |
| 4589 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 4590 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4591 | } |
| 4592 | catch(std::bad_alloc&) |
| 4593 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4594 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4595 | } |
| 4596 | } |
| 4597 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4598 | 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] | 4599 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4600 | EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4601 | "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] | 4602 | program, index, bufsize, length, size, type, name); |
| 4603 | |
| 4604 | try |
| 4605 | { |
| 4606 | if (bufsize < 0) |
| 4607 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4608 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4609 | } |
| 4610 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4611 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4612 | |
| 4613 | if (context) |
| 4614 | { |
| 4615 | gl::Program *programObject = context->getProgram(program); |
| 4616 | |
| 4617 | if (!programObject) |
| 4618 | { |
| 4619 | if (context->getShader(program)) |
| 4620 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4621 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4622 | } |
| 4623 | else |
| 4624 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4625 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4626 | } |
| 4627 | } |
| 4628 | |
| 4629 | if (index >= (GLuint)programObject->getActiveUniformCount()) |
| 4630 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4631 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4632 | } |
| 4633 | |
| 4634 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 4635 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4636 | } |
| 4637 | catch(std::bad_alloc&) |
| 4638 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4639 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4640 | } |
| 4641 | } |
| 4642 | |
| 4643 | void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) |
| 4644 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4645 | 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] | 4646 | program, maxcount, count, shaders); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4647 | |
| 4648 | try |
| 4649 | { |
| 4650 | if (maxcount < 0) |
| 4651 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4652 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4653 | } |
| 4654 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4655 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4656 | |
| 4657 | if (context) |
| 4658 | { |
| 4659 | gl::Program *programObject = context->getProgram(program); |
| 4660 | |
| 4661 | if (!programObject) |
| 4662 | { |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4663 | if (context->getShader(program)) |
| 4664 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4665 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4666 | } |
| 4667 | else |
| 4668 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4669 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4670 | } |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4671 | } |
| 4672 | |
| 4673 | return programObject->getAttachedShaders(maxcount, count, shaders); |
| 4674 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4675 | } |
| 4676 | catch(std::bad_alloc&) |
| 4677 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4678 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4679 | } |
| 4680 | } |
| 4681 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4682 | int __stdcall glGetAttribLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4683 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4684 | EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4685 | |
| 4686 | try |
| 4687 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4688 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4689 | |
| 4690 | if (context) |
| 4691 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4692 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4693 | gl::Program *programObject = context->getProgram(program); |
| 4694 | |
| 4695 | if (!programObject) |
| 4696 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4697 | if (context->getShader(program)) |
| 4698 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4699 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4700 | } |
| 4701 | else |
| 4702 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4703 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4704 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4705 | } |
| 4706 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4707 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 4708 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4709 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4710 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4711 | } |
| 4712 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4713 | return programBinary->getAttributeLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4714 | } |
| 4715 | } |
| 4716 | catch(std::bad_alloc&) |
| 4717 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4718 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4719 | } |
| 4720 | |
| 4721 | return -1; |
| 4722 | } |
| 4723 | |
| 4724 | void __stdcall glGetBooleanv(GLenum pname, GLboolean* params) |
| 4725 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4726 | 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] | 4727 | |
| 4728 | try |
| 4729 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4730 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4731 | |
| 4732 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4733 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4734 | if (!(context->getBooleanv(pname, params))) |
| 4735 | { |
| 4736 | GLenum nativeType; |
| 4737 | unsigned int numParams = 0; |
| 4738 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4739 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4740 | |
| 4741 | if (numParams == 0) |
| 4742 | return; // it is known that the pname is valid, but there are no parameters to return |
| 4743 | |
| 4744 | if (nativeType == GL_FLOAT) |
| 4745 | { |
| 4746 | GLfloat *floatParams = NULL; |
| 4747 | floatParams = new GLfloat[numParams]; |
| 4748 | |
| 4749 | context->getFloatv(pname, floatParams); |
| 4750 | |
| 4751 | for (unsigned int i = 0; i < numParams; ++i) |
| 4752 | { |
| 4753 | if (floatParams[i] == 0.0f) |
| 4754 | params[i] = GL_FALSE; |
| 4755 | else |
| 4756 | params[i] = GL_TRUE; |
| 4757 | } |
| 4758 | |
| 4759 | delete [] floatParams; |
| 4760 | } |
| 4761 | else if (nativeType == GL_INT) |
| 4762 | { |
| 4763 | GLint *intParams = NULL; |
| 4764 | intParams = new GLint[numParams]; |
| 4765 | |
| 4766 | context->getIntegerv(pname, intParams); |
| 4767 | |
| 4768 | for (unsigned int i = 0; i < numParams; ++i) |
| 4769 | { |
| 4770 | if (intParams[i] == 0) |
| 4771 | params[i] = GL_FALSE; |
| 4772 | else |
| 4773 | params[i] = GL_TRUE; |
| 4774 | } |
| 4775 | |
| 4776 | delete [] intParams; |
| 4777 | } |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 4778 | else if (nativeType == GL_INT_64_ANGLEX) |
| 4779 | { |
| 4780 | GLint64 *int64Params = NULL; |
| 4781 | int64Params = new GLint64[numParams]; |
| 4782 | |
| 4783 | context->getInteger64v(pname, int64Params); |
| 4784 | |
| 4785 | for (unsigned int i = 0; i < numParams; ++i) |
| 4786 | { |
| 4787 | if (int64Params[i] == 0) |
| 4788 | params[i] = GL_FALSE; |
| 4789 | else |
| 4790 | params[i] = GL_TRUE; |
| 4791 | } |
| 4792 | |
| 4793 | delete [] int64Params; |
| 4794 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4795 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4796 | } |
| 4797 | } |
| 4798 | catch(std::bad_alloc&) |
| 4799 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4800 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4801 | } |
| 4802 | } |
| 4803 | |
| 4804 | void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 4805 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4806 | 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] | 4807 | |
| 4808 | try |
| 4809 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4810 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4811 | |
| 4812 | if (context) |
| 4813 | { |
| 4814 | gl::Buffer *buffer; |
| 4815 | |
| 4816 | switch (target) |
| 4817 | { |
| 4818 | case GL_ARRAY_BUFFER: |
| 4819 | buffer = context->getArrayBuffer(); |
| 4820 | break; |
| 4821 | case GL_ELEMENT_ARRAY_BUFFER: |
| 4822 | buffer = context->getElementArrayBuffer(); |
| 4823 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4824 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4825 | } |
| 4826 | |
| 4827 | if (!buffer) |
| 4828 | { |
| 4829 | // 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] | 4830 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4831 | } |
| 4832 | |
| 4833 | switch (pname) |
| 4834 | { |
| 4835 | case GL_BUFFER_USAGE: |
| 4836 | *params = buffer->usage(); |
| 4837 | break; |
| 4838 | case GL_BUFFER_SIZE: |
| 4839 | *params = buffer->size(); |
| 4840 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4841 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4842 | } |
| 4843 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4844 | } |
| 4845 | catch(std::bad_alloc&) |
| 4846 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4847 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4848 | } |
| 4849 | } |
| 4850 | |
| 4851 | GLenum __stdcall glGetError(void) |
| 4852 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4853 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4854 | |
| 4855 | gl::Context *context = gl::getContext(); |
| 4856 | |
| 4857 | if (context) |
| 4858 | { |
daniel@transgaming.com | 82b2891 | 2011-12-12 21:01:35 +0000 | [diff] [blame] | 4859 | return context->getError(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4860 | } |
| 4861 | |
| 4862 | return GL_NO_ERROR; |
| 4863 | } |
| 4864 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4865 | void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 4866 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4867 | 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] | 4868 | |
| 4869 | try |
| 4870 | { |
| 4871 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4872 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4873 | |
| 4874 | if (context) |
| 4875 | { |
| 4876 | gl::Fence *fenceObject = context->getFence(fence); |
| 4877 | |
| 4878 | if (fenceObject == NULL) |
| 4879 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4880 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4881 | } |
| 4882 | |
| 4883 | fenceObject->getFenceiv(pname, params); |
| 4884 | } |
| 4885 | } |
| 4886 | catch(std::bad_alloc&) |
| 4887 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4888 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4889 | } |
| 4890 | } |
| 4891 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4892 | void __stdcall glGetFloatv(GLenum pname, GLfloat* params) |
| 4893 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4894 | 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] | 4895 | |
| 4896 | try |
| 4897 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4898 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4899 | |
| 4900 | if (context) |
| 4901 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4902 | if (!(context->getFloatv(pname, params))) |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4903 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4904 | GLenum nativeType; |
| 4905 | unsigned int numParams = 0; |
| 4906 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4907 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4908 | |
| 4909 | if (numParams == 0) |
| 4910 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 4911 | |
| 4912 | if (nativeType == GL_BOOL) |
| 4913 | { |
| 4914 | GLboolean *boolParams = NULL; |
| 4915 | boolParams = new GLboolean[numParams]; |
| 4916 | |
| 4917 | context->getBooleanv(pname, boolParams); |
| 4918 | |
| 4919 | for (unsigned int i = 0; i < numParams; ++i) |
| 4920 | { |
| 4921 | if (boolParams[i] == GL_FALSE) |
| 4922 | params[i] = 0.0f; |
| 4923 | else |
| 4924 | params[i] = 1.0f; |
| 4925 | } |
| 4926 | |
| 4927 | delete [] boolParams; |
| 4928 | } |
| 4929 | else if (nativeType == GL_INT) |
| 4930 | { |
| 4931 | GLint *intParams = NULL; |
| 4932 | intParams = new GLint[numParams]; |
| 4933 | |
| 4934 | context->getIntegerv(pname, intParams); |
| 4935 | |
| 4936 | for (unsigned int i = 0; i < numParams; ++i) |
| 4937 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 4938 | params[i] = static_cast<GLfloat>(intParams[i]); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4939 | } |
| 4940 | |
| 4941 | delete [] intParams; |
| 4942 | } |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 4943 | else if (nativeType == GL_INT_64_ANGLEX) |
| 4944 | { |
| 4945 | GLint64 *int64Params = NULL; |
| 4946 | int64Params = new GLint64[numParams]; |
| 4947 | |
| 4948 | context->getInteger64v(pname, int64Params); |
| 4949 | |
| 4950 | for (unsigned int i = 0; i < numParams; ++i) |
| 4951 | { |
| 4952 | params[i] = static_cast<GLfloat>(int64Params[i]); |
| 4953 | } |
| 4954 | |
| 4955 | delete [] int64Params; |
| 4956 | } |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4957 | } |
| 4958 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4959 | } |
| 4960 | catch(std::bad_alloc&) |
| 4961 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4962 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4963 | } |
| 4964 | } |
| 4965 | |
| 4966 | void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) |
| 4967 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4968 | 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] | 4969 | target, attachment, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4970 | |
| 4971 | try |
| 4972 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4973 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4974 | |
| 4975 | if (context) |
| 4976 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4977 | 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] | 4978 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4979 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4980 | } |
| 4981 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4982 | gl::Framebuffer *framebuffer = NULL; |
| 4983 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4984 | { |
| 4985 | if(context->getReadFramebufferHandle() == 0) |
| 4986 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4987 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4988 | } |
| 4989 | |
| 4990 | framebuffer = context->getReadFramebuffer(); |
| 4991 | } |
| 4992 | else |
| 4993 | { |
| 4994 | if (context->getDrawFramebufferHandle() == 0) |
| 4995 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4996 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4997 | } |
| 4998 | |
| 4999 | framebuffer = context->getDrawFramebuffer(); |
| 5000 | } |
| 5001 | |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5002 | GLenum attachmentType; |
| 5003 | GLuint attachmentHandle; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 5004 | |
| 5005 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5006 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 5007 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 5008 | |
| 5009 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 5010 | { |
| 5011 | return gl::error(GL_INVALID_ENUM); |
| 5012 | } |
| 5013 | |
| 5014 | attachmentType = framebuffer->getColorbufferType(colorAttachment); |
| 5015 | attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment); |
| 5016 | } |
| 5017 | else |
| 5018 | { |
| 5019 | switch (attachment) |
| 5020 | { |
| 5021 | case GL_DEPTH_ATTACHMENT: |
| 5022 | attachmentType = framebuffer->getDepthbufferType(); |
| 5023 | attachmentHandle = framebuffer->getDepthbufferHandle(); |
| 5024 | break; |
| 5025 | case GL_STENCIL_ATTACHMENT: |
| 5026 | attachmentType = framebuffer->getStencilbufferType(); |
| 5027 | attachmentHandle = framebuffer->getStencilbufferHandle(); |
| 5028 | break; |
| 5029 | default: return gl::error(GL_INVALID_ENUM); |
| 5030 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5031 | } |
| 5032 | |
| 5033 | GLenum attachmentObjectType; // Type category |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 5034 | if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5035 | { |
| 5036 | attachmentObjectType = attachmentType; |
| 5037 | } |
apatrick@chromium.org | 551022e | 2012-01-23 19:56:54 +0000 | [diff] [blame] | 5038 | else if (gl::IsInternalTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5039 | { |
| 5040 | attachmentObjectType = GL_TEXTURE; |
| 5041 | } |
apatrick@chromium.org | a1d8059 | 2012-01-25 21:52:10 +0000 | [diff] [blame] | 5042 | else |
| 5043 | { |
| 5044 | UNREACHABLE(); |
| 5045 | return; |
| 5046 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5047 | |
| 5048 | switch (pname) |
| 5049 | { |
| 5050 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 5051 | *params = attachmentObjectType; |
| 5052 | break; |
| 5053 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 5054 | if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE) |
| 5055 | { |
| 5056 | *params = attachmentHandle; |
| 5057 | } |
| 5058 | else |
| 5059 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5060 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5061 | } |
| 5062 | break; |
| 5063 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 5064 | if (attachmentObjectType == GL_TEXTURE) |
| 5065 | { |
| 5066 | *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0 |
| 5067 | } |
| 5068 | else |
| 5069 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5070 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5071 | } |
| 5072 | break; |
| 5073 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 5074 | if (attachmentObjectType == GL_TEXTURE) |
| 5075 | { |
daniel@transgaming.com | 19ffc24 | 2010-05-04 03:35:21 +0000 | [diff] [blame] | 5076 | if (gl::IsCubemapTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5077 | { |
| 5078 | *params = attachmentType; |
| 5079 | } |
| 5080 | else |
| 5081 | { |
| 5082 | *params = 0; |
| 5083 | } |
| 5084 | } |
| 5085 | else |
| 5086 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5087 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5088 | } |
| 5089 | break; |
| 5090 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5091 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5092 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5093 | } |
| 5094 | } |
| 5095 | catch(std::bad_alloc&) |
| 5096 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5097 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5098 | } |
| 5099 | } |
| 5100 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 5101 | GLenum __stdcall glGetGraphicsResetStatusEXT(void) |
| 5102 | { |
| 5103 | EVENT("()"); |
| 5104 | |
| 5105 | try |
| 5106 | { |
| 5107 | gl::Context *context = gl::getContext(); |
| 5108 | |
| 5109 | if (context) |
| 5110 | { |
| 5111 | return context->getResetStatus(); |
| 5112 | } |
| 5113 | |
| 5114 | return GL_NO_ERROR; |
| 5115 | } |
| 5116 | catch(std::bad_alloc&) |
| 5117 | { |
| 5118 | return GL_OUT_OF_MEMORY; |
| 5119 | } |
| 5120 | } |
| 5121 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5122 | void __stdcall glGetIntegerv(GLenum pname, GLint* params) |
| 5123 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5124 | 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] | 5125 | |
| 5126 | try |
| 5127 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5128 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5129 | |
| 5130 | if (context) |
| 5131 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5132 | if (!(context->getIntegerv(pname, params))) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5133 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5134 | GLenum nativeType; |
| 5135 | unsigned int numParams = 0; |
| 5136 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5137 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5138 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5139 | if (numParams == 0) |
| 5140 | return; // it is known that pname is valid, but there are no parameters to return |
| 5141 | |
| 5142 | if (nativeType == GL_BOOL) |
| 5143 | { |
| 5144 | GLboolean *boolParams = NULL; |
| 5145 | boolParams = new GLboolean[numParams]; |
| 5146 | |
| 5147 | context->getBooleanv(pname, boolParams); |
| 5148 | |
| 5149 | for (unsigned int i = 0; i < numParams; ++i) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5150 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5151 | if (boolParams[i] == GL_FALSE) |
| 5152 | params[i] = 0; |
| 5153 | else |
| 5154 | params[i] = 1; |
| 5155 | } |
| 5156 | |
| 5157 | delete [] boolParams; |
| 5158 | } |
| 5159 | else if (nativeType == GL_FLOAT) |
| 5160 | { |
| 5161 | GLfloat *floatParams = NULL; |
| 5162 | floatParams = new GLfloat[numParams]; |
| 5163 | |
| 5164 | context->getFloatv(pname, floatParams); |
| 5165 | |
| 5166 | for (unsigned int i = 0; i < numParams; ++i) |
| 5167 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5168 | // 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] | 5169 | 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] | 5170 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5171 | 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] | 5172 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5173 | else |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5174 | { |
Jamie Madill | af49691 | 2013-07-19 16:36:54 -0400 | [diff] [blame] | 5175 | params[i] = gl::iround<GLint>(floatParams[i]); |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5176 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5177 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5178 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5179 | delete [] floatParams; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5180 | } |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5181 | else if (nativeType == GL_INT_64_ANGLEX) |
| 5182 | { |
| 5183 | GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min()); |
| 5184 | GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max()); |
| 5185 | GLint64 *int64Params = NULL; |
| 5186 | int64Params = new GLint64[numParams]; |
| 5187 | |
| 5188 | context->getInteger64v(pname, int64Params); |
| 5189 | |
| 5190 | for (unsigned int i = 0; i < numParams; ++i) |
| 5191 | { |
| 5192 | GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue); |
| 5193 | params[i] = static_cast<GLint>(clampedValue); |
| 5194 | } |
| 5195 | |
| 5196 | delete [] int64Params; |
| 5197 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5198 | } |
| 5199 | } |
| 5200 | } |
| 5201 | catch(std::bad_alloc&) |
| 5202 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5203 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5204 | } |
| 5205 | } |
| 5206 | |
| 5207 | void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params) |
| 5208 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5209 | 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] | 5210 | |
| 5211 | try |
| 5212 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5213 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5214 | |
| 5215 | if (context) |
| 5216 | { |
| 5217 | gl::Program *programObject = context->getProgram(program); |
| 5218 | |
| 5219 | if (!programObject) |
| 5220 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5221 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5222 | } |
| 5223 | |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 5224 | if (context->getClientVersion() < 3) |
| 5225 | { |
| 5226 | switch (pname) |
| 5227 | { |
| 5228 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 5229 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 5230 | return gl::error(GL_INVALID_ENUM); |
| 5231 | } |
| 5232 | } |
| 5233 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5234 | switch (pname) |
| 5235 | { |
| 5236 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5237 | *params = programObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5238 | return; |
| 5239 | case GL_LINK_STATUS: |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5240 | *params = programObject->isLinked(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5241 | return; |
| 5242 | case GL_VALIDATE_STATUS: |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 5243 | *params = programObject->isValidated(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5244 | return; |
| 5245 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5246 | *params = programObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5247 | return; |
| 5248 | case GL_ATTACHED_SHADERS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5249 | *params = programObject->getAttachedShadersCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5250 | return; |
| 5251 | case GL_ACTIVE_ATTRIBUTES: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 5252 | *params = programObject->getActiveAttributeCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5253 | return; |
| 5254 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 5255 | *params = programObject->getActiveAttributeMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5256 | return; |
| 5257 | case GL_ACTIVE_UNIFORMS: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 5258 | *params = programObject->getActiveUniformCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5259 | return; |
| 5260 | case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 5261 | *params = programObject->getActiveUniformMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5262 | return; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 5263 | case GL_PROGRAM_BINARY_LENGTH_OES: |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 5264 | *params = programObject->getProgramBinaryLength(); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 5265 | return; |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 5266 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 5267 | *params = programObject->getActiveUniformBlockCount(); |
| 5268 | return; |
| 5269 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 5270 | *params = programObject->getActiveUniformBlockMaxLength(); |
| 5271 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5272 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5273 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5274 | } |
| 5275 | } |
| 5276 | } |
| 5277 | catch(std::bad_alloc&) |
| 5278 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5279 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5280 | } |
| 5281 | } |
| 5282 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5283 | void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5284 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5285 | 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] | 5286 | program, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5287 | |
| 5288 | try |
| 5289 | { |
| 5290 | if (bufsize < 0) |
| 5291 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5292 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5293 | } |
| 5294 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5295 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5296 | |
| 5297 | if (context) |
| 5298 | { |
| 5299 | gl::Program *programObject = context->getProgram(program); |
| 5300 | |
| 5301 | if (!programObject) |
| 5302 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5303 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5304 | } |
| 5305 | |
| 5306 | programObject->getInfoLog(bufsize, length, infolog); |
| 5307 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5308 | } |
| 5309 | catch(std::bad_alloc&) |
| 5310 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5311 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5312 | } |
| 5313 | } |
| 5314 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5315 | void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params) |
| 5316 | { |
| 5317 | EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params); |
| 5318 | |
| 5319 | try |
| 5320 | { |
| 5321 | switch (pname) |
| 5322 | { |
| 5323 | case GL_CURRENT_QUERY_EXT: |
| 5324 | break; |
| 5325 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5326 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5327 | } |
| 5328 | |
| 5329 | gl::Context *context = gl::getNonLostContext(); |
| 5330 | |
| 5331 | if (context) |
| 5332 | { |
| 5333 | params[0] = context->getActiveQuery(target); |
| 5334 | } |
| 5335 | } |
| 5336 | catch(std::bad_alloc&) |
| 5337 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5338 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5339 | } |
| 5340 | } |
| 5341 | |
| 5342 | void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) |
| 5343 | { |
| 5344 | EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params); |
| 5345 | |
| 5346 | try |
| 5347 | { |
| 5348 | switch (pname) |
| 5349 | { |
| 5350 | case GL_QUERY_RESULT_EXT: |
| 5351 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5352 | break; |
| 5353 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5354 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5355 | } |
| 5356 | gl::Context *context = gl::getNonLostContext(); |
| 5357 | |
| 5358 | if (context) |
| 5359 | { |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5360 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 5361 | |
| 5362 | if (!queryObject) |
| 5363 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5364 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5365 | } |
| 5366 | |
| 5367 | if (context->getActiveQuery(queryObject->getType()) == id) |
| 5368 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5369 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5370 | } |
| 5371 | |
| 5372 | switch(pname) |
| 5373 | { |
| 5374 | case GL_QUERY_RESULT_EXT: |
| 5375 | params[0] = queryObject->getResult(); |
| 5376 | break; |
| 5377 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5378 | params[0] = queryObject->isResultAvailable(); |
| 5379 | break; |
| 5380 | default: |
| 5381 | ASSERT(false); |
| 5382 | } |
| 5383 | } |
| 5384 | } |
| 5385 | catch(std::bad_alloc&) |
| 5386 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5387 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5388 | } |
| 5389 | } |
| 5390 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5391 | void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5392 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5393 | 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] | 5394 | |
| 5395 | try |
| 5396 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5397 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5398 | |
| 5399 | if (context) |
| 5400 | { |
| 5401 | if (target != GL_RENDERBUFFER) |
| 5402 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5403 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5404 | } |
| 5405 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5406 | if (context->getRenderbufferHandle() == 0) |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5407 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5408 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5409 | } |
| 5410 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5411 | gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle()); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5412 | |
| 5413 | switch (pname) |
| 5414 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5415 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break; |
| 5416 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break; |
| 5417 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break; |
| 5418 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break; |
| 5419 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break; |
| 5420 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break; |
| 5421 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break; |
| 5422 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break; |
| 5423 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break; |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5424 | case GL_RENDERBUFFER_SAMPLES_ANGLE: |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5425 | if (context->getMaxSupportedSamples() != 0) |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5426 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5427 | *params = renderbuffer->getSamples(); |
| 5428 | } |
| 5429 | else |
| 5430 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5431 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5432 | } |
| 5433 | break; |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5434 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5435 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5436 | } |
| 5437 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5438 | } |
| 5439 | catch(std::bad_alloc&) |
| 5440 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5441 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5442 | } |
| 5443 | } |
| 5444 | |
| 5445 | void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params) |
| 5446 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5447 | 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] | 5448 | |
| 5449 | try |
| 5450 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5451 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5452 | |
| 5453 | if (context) |
| 5454 | { |
| 5455 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 5456 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5457 | if (!shaderObject) |
| 5458 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5459 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5460 | } |
| 5461 | |
| 5462 | switch (pname) |
| 5463 | { |
| 5464 | case GL_SHADER_TYPE: |
| 5465 | *params = shaderObject->getType(); |
| 5466 | return; |
| 5467 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5468 | *params = shaderObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5469 | return; |
| 5470 | case GL_COMPILE_STATUS: |
| 5471 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; |
| 5472 | return; |
| 5473 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5474 | *params = shaderObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5475 | return; |
| 5476 | case GL_SHADER_SOURCE_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5477 | *params = shaderObject->getSourceLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5478 | return; |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5479 | case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: |
| 5480 | *params = shaderObject->getTranslatedSourceLength(); |
| 5481 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5482 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5483 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5484 | } |
| 5485 | } |
| 5486 | } |
| 5487 | catch(std::bad_alloc&) |
| 5488 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5489 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5490 | } |
| 5491 | } |
| 5492 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5493 | void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5494 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5495 | 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] | 5496 | shader, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5497 | |
| 5498 | try |
| 5499 | { |
| 5500 | if (bufsize < 0) |
| 5501 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5502 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5503 | } |
| 5504 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5505 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5506 | |
| 5507 | if (context) |
| 5508 | { |
| 5509 | gl::Shader *shaderObject = context->getShader(shader); |
| 5510 | |
| 5511 | if (!shaderObject) |
| 5512 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5513 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5514 | } |
| 5515 | |
| 5516 | shaderObject->getInfoLog(bufsize, length, infolog); |
| 5517 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5518 | } |
| 5519 | catch(std::bad_alloc&) |
| 5520 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5521 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5522 | } |
| 5523 | } |
| 5524 | |
| 5525 | void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) |
| 5526 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5527 | 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] | 5528 | shadertype, precisiontype, range, precision); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5529 | |
| 5530 | try |
| 5531 | { |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5532 | switch (shadertype) |
| 5533 | { |
| 5534 | case GL_VERTEX_SHADER: |
| 5535 | case GL_FRAGMENT_SHADER: |
| 5536 | break; |
| 5537 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5538 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5539 | } |
| 5540 | |
| 5541 | switch (precisiontype) |
| 5542 | { |
| 5543 | case GL_LOW_FLOAT: |
| 5544 | case GL_MEDIUM_FLOAT: |
| 5545 | case GL_HIGH_FLOAT: |
| 5546 | // Assume IEEE 754 precision |
| 5547 | range[0] = 127; |
| 5548 | range[1] = 127; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5549 | *precision = 23; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5550 | break; |
| 5551 | case GL_LOW_INT: |
| 5552 | case GL_MEDIUM_INT: |
| 5553 | case GL_HIGH_INT: |
| 5554 | // Some (most) hardware only supports single-precision floating-point numbers, |
| 5555 | // which can accurately represent integers up to +/-16777216 |
| 5556 | range[0] = 24; |
| 5557 | range[1] = 24; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5558 | *precision = 0; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5559 | break; |
| 5560 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5561 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5562 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5563 | } |
| 5564 | catch(std::bad_alloc&) |
| 5565 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5566 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5567 | } |
| 5568 | } |
| 5569 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5570 | void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5571 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5572 | 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] | 5573 | shader, bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5574 | |
| 5575 | try |
| 5576 | { |
| 5577 | if (bufsize < 0) |
| 5578 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5579 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5580 | } |
| 5581 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5582 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5583 | |
| 5584 | if (context) |
| 5585 | { |
| 5586 | gl::Shader *shaderObject = context->getShader(shader); |
| 5587 | |
| 5588 | if (!shaderObject) |
| 5589 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5590 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5591 | } |
| 5592 | |
| 5593 | shaderObject->getSource(bufsize, length, source); |
| 5594 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5595 | } |
| 5596 | catch(std::bad_alloc&) |
| 5597 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5598 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5599 | } |
| 5600 | } |
| 5601 | |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5602 | void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
| 5603 | { |
| 5604 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)", |
| 5605 | shader, bufsize, length, source); |
| 5606 | |
| 5607 | try |
| 5608 | { |
| 5609 | if (bufsize < 0) |
| 5610 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5611 | return gl::error(GL_INVALID_VALUE); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5612 | } |
| 5613 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5614 | gl::Context *context = gl::getNonLostContext(); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5615 | |
| 5616 | if (context) |
| 5617 | { |
| 5618 | gl::Shader *shaderObject = context->getShader(shader); |
| 5619 | |
| 5620 | if (!shaderObject) |
| 5621 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5622 | return gl::error(GL_INVALID_OPERATION); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5623 | } |
| 5624 | |
| 5625 | shaderObject->getTranslatedSource(bufsize, length, source); |
| 5626 | } |
| 5627 | } |
| 5628 | catch(std::bad_alloc&) |
| 5629 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5630 | return gl::error(GL_OUT_OF_MEMORY); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5631 | } |
| 5632 | } |
| 5633 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5634 | const GLubyte* __stdcall glGetString(GLenum name) |
| 5635 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5636 | EVENT("(GLenum name = 0x%X)", name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5637 | |
| 5638 | try |
| 5639 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5640 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3e4c600 | 2010-05-05 18:50:13 +0000 | [diff] [blame] | 5641 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5642 | switch (name) |
| 5643 | { |
| 5644 | case GL_VENDOR: |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 5645 | return (GLubyte*)"Google Inc."; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5646 | case GL_RENDERER: |
daniel@transgaming.com | c23ff64 | 2011-08-16 20:28:45 +0000 | [diff] [blame] | 5647 | return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5648 | case GL_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5649 | if (context->getClientVersion() == 2) |
| 5650 | { |
| 5651 | return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")"; |
| 5652 | } |
| 5653 | else |
| 5654 | { |
| 5655 | return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")"; |
| 5656 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5657 | case GL_SHADING_LANGUAGE_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5658 | if (context->getClientVersion() == 2) |
| 5659 | { |
| 5660 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")"; |
| 5661 | } |
| 5662 | else |
| 5663 | { |
| 5664 | return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")"; |
| 5665 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5666 | case GL_EXTENSIONS: |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 5667 | return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : ""); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5668 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5669 | return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5670 | } |
| 5671 | } |
| 5672 | catch(std::bad_alloc&) |
| 5673 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5674 | return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5675 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5676 | } |
| 5677 | |
| 5678 | void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) |
| 5679 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5680 | 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] | 5681 | |
| 5682 | try |
| 5683 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5684 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5685 | |
| 5686 | if (context) |
| 5687 | { |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame^] | 5688 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5689 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame^] | 5690 | if (!texture) |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5691 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5692 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5693 | } |
| 5694 | |
| 5695 | switch (pname) |
| 5696 | { |
| 5697 | case GL_TEXTURE_MAG_FILTER: |
| 5698 | *params = (GLfloat)texture->getMagFilter(); |
| 5699 | break; |
| 5700 | case GL_TEXTURE_MIN_FILTER: |
| 5701 | *params = (GLfloat)texture->getMinFilter(); |
| 5702 | break; |
| 5703 | case GL_TEXTURE_WRAP_S: |
| 5704 | *params = (GLfloat)texture->getWrapS(); |
| 5705 | break; |
| 5706 | case GL_TEXTURE_WRAP_T: |
| 5707 | *params = (GLfloat)texture->getWrapT(); |
| 5708 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5709 | case GL_TEXTURE_WRAP_R: |
| 5710 | if (context->getClientVersion() < 3) |
| 5711 | { |
| 5712 | return gl::error(GL_INVALID_ENUM); |
| 5713 | } |
| 5714 | *params = (GLfloat)texture->getWrapR(); |
| 5715 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5716 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5717 | // 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] | 5718 | *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE); |
| 5719 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5720 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5721 | if (context->getClientVersion() < 3) |
| 5722 | { |
| 5723 | return gl::error(GL_INVALID_ENUM); |
| 5724 | } |
| 5725 | *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0); |
| 5726 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5727 | case GL_TEXTURE_USAGE_ANGLE: |
| 5728 | *params = (GLfloat)texture->getUsage(); |
| 5729 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5730 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5731 | if (!context->supportsTextureFilterAnisotropy()) |
| 5732 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5733 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5734 | } |
| 5735 | *params = (GLfloat)texture->getMaxAnisotropy(); |
| 5736 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5737 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5738 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5739 | } |
| 5740 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5741 | } |
| 5742 | catch(std::bad_alloc&) |
| 5743 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5744 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5745 | } |
| 5746 | } |
| 5747 | |
| 5748 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5749 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5750 | 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] | 5751 | |
| 5752 | try |
| 5753 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5754 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5755 | |
| 5756 | if (context) |
| 5757 | { |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame^] | 5758 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5759 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame^] | 5760 | if (!texture) |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5761 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5762 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5763 | } |
| 5764 | |
| 5765 | switch (pname) |
| 5766 | { |
| 5767 | case GL_TEXTURE_MAG_FILTER: |
| 5768 | *params = texture->getMagFilter(); |
| 5769 | break; |
| 5770 | case GL_TEXTURE_MIN_FILTER: |
| 5771 | *params = texture->getMinFilter(); |
| 5772 | break; |
| 5773 | case GL_TEXTURE_WRAP_S: |
| 5774 | *params = texture->getWrapS(); |
| 5775 | break; |
| 5776 | case GL_TEXTURE_WRAP_T: |
| 5777 | *params = texture->getWrapT(); |
| 5778 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5779 | case GL_TEXTURE_WRAP_R: |
| 5780 | if (context->getClientVersion() < 3) |
| 5781 | { |
| 5782 | return gl::error(GL_INVALID_ENUM); |
| 5783 | } |
| 5784 | *params = texture->getWrapR(); |
| 5785 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5786 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5787 | // 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] | 5788 | *params = texture->isImmutable() ? GL_TRUE : GL_FALSE; |
| 5789 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5790 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5791 | if (context->getClientVersion() < 3) |
| 5792 | { |
| 5793 | return gl::error(GL_INVALID_ENUM); |
| 5794 | } |
| 5795 | *params = texture->isImmutable() ? texture->levelCount() : 0; |
| 5796 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5797 | case GL_TEXTURE_USAGE_ANGLE: |
| 5798 | *params = texture->getUsage(); |
| 5799 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5800 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5801 | if (!context->supportsTextureFilterAnisotropy()) |
| 5802 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5803 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5804 | } |
| 5805 | *params = (GLint)texture->getMaxAnisotropy(); |
| 5806 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 5807 | |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5808 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5809 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5810 | } |
| 5811 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5812 | } |
| 5813 | catch(std::bad_alloc&) |
| 5814 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5815 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5816 | } |
| 5817 | } |
| 5818 | |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5819 | void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
| 5820 | { |
| 5821 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)", |
| 5822 | program, location, bufSize, params); |
| 5823 | |
| 5824 | try |
| 5825 | { |
| 5826 | if (bufSize < 0) |
| 5827 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5828 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5829 | } |
| 5830 | |
| 5831 | gl::Context *context = gl::getNonLostContext(); |
| 5832 | |
| 5833 | if (context) |
| 5834 | { |
| 5835 | if (program == 0) |
| 5836 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5837 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5838 | } |
| 5839 | |
| 5840 | gl::Program *programObject = context->getProgram(program); |
| 5841 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5842 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5843 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5844 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5845 | } |
| 5846 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5847 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5848 | if (!programBinary) |
| 5849 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5850 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5851 | } |
| 5852 | |
| 5853 | if (!programBinary->getUniformfv(location, &bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5854 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5855 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5856 | } |
| 5857 | } |
| 5858 | } |
| 5859 | catch(std::bad_alloc&) |
| 5860 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5861 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5862 | } |
| 5863 | } |
| 5864 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5865 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 5866 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5867 | 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] | 5868 | |
| 5869 | try |
| 5870 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5871 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5872 | |
| 5873 | if (context) |
| 5874 | { |
| 5875 | if (program == 0) |
| 5876 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5877 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5878 | } |
| 5879 | |
| 5880 | gl::Program *programObject = context->getProgram(program); |
| 5881 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5882 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5883 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5884 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5885 | } |
| 5886 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5887 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5888 | if (!programBinary) |
| 5889 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5890 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5891 | } |
| 5892 | |
| 5893 | if (!programBinary->getUniformfv(location, NULL, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5894 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5895 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5896 | } |
| 5897 | } |
| 5898 | } |
| 5899 | catch(std::bad_alloc&) |
| 5900 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5901 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5902 | } |
| 5903 | } |
| 5904 | |
| 5905 | void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) |
| 5906 | { |
| 5907 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)", |
| 5908 | program, location, bufSize, params); |
| 5909 | |
| 5910 | try |
| 5911 | { |
| 5912 | if (bufSize < 0) |
| 5913 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5914 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5915 | } |
| 5916 | |
| 5917 | gl::Context *context = gl::getNonLostContext(); |
| 5918 | |
| 5919 | if (context) |
| 5920 | { |
| 5921 | if (program == 0) |
| 5922 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5923 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5924 | } |
| 5925 | |
| 5926 | gl::Program *programObject = context->getProgram(program); |
| 5927 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5928 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5929 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5930 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5931 | } |
| 5932 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5933 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5934 | if (!programBinary) |
| 5935 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5936 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5937 | } |
| 5938 | |
| 5939 | if (!programBinary->getUniformiv(location, &bufSize, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5940 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5941 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5942 | } |
| 5943 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5944 | } |
| 5945 | catch(std::bad_alloc&) |
| 5946 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5947 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5948 | } |
| 5949 | } |
| 5950 | |
| 5951 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 5952 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5953 | 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] | 5954 | |
| 5955 | try |
| 5956 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5957 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5958 | |
| 5959 | if (context) |
| 5960 | { |
| 5961 | if (program == 0) |
| 5962 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5963 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5964 | } |
| 5965 | |
| 5966 | gl::Program *programObject = context->getProgram(program); |
| 5967 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5968 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5969 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5970 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5971 | } |
| 5972 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5973 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5974 | if (!programBinary) |
| 5975 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5976 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5977 | } |
| 5978 | |
| 5979 | if (!programBinary->getUniformiv(location, NULL, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5980 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5981 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5982 | } |
| 5983 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5984 | } |
| 5985 | catch(std::bad_alloc&) |
| 5986 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5987 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5988 | } |
| 5989 | } |
| 5990 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5991 | int __stdcall glGetUniformLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5992 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5993 | 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] | 5994 | |
| 5995 | try |
| 5996 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5997 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5998 | |
| 5999 | if (strstr(name, "gl_") == name) |
| 6000 | { |
| 6001 | return -1; |
| 6002 | } |
| 6003 | |
| 6004 | if (context) |
| 6005 | { |
| 6006 | gl::Program *programObject = context->getProgram(program); |
| 6007 | |
| 6008 | if (!programObject) |
| 6009 | { |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 6010 | if (context->getShader(program)) |
| 6011 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6012 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 6013 | } |
| 6014 | else |
| 6015 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6016 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 6017 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6018 | } |
| 6019 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6020 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 6021 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6022 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6023 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6024 | } |
| 6025 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6026 | return programBinary->getUniformLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6027 | } |
| 6028 | } |
| 6029 | catch(std::bad_alloc&) |
| 6030 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6031 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6032 | } |
| 6033 | |
| 6034 | return -1; |
| 6035 | } |
| 6036 | |
| 6037 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 6038 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6039 | 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] | 6040 | |
| 6041 | try |
| 6042 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6043 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6044 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6045 | if (context) |
| 6046 | { |
| 6047 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6048 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6049 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6050 | } |
| 6051 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 6052 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6053 | |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6054 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6055 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6056 | return; |
| 6057 | } |
| 6058 | |
| 6059 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 6060 | { |
| 6061 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 6062 | for (int i = 0; i < 4; ++i) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6063 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6064 | params[i] = currentValueData.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6065 | } |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6066 | } |
| 6067 | else |
| 6068 | { |
| 6069 | *params = attribState.querySingleParameter<GLfloat>(pname); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6070 | } |
| 6071 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6072 | } |
| 6073 | catch(std::bad_alloc&) |
| 6074 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6075 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6076 | } |
| 6077 | } |
| 6078 | |
| 6079 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 6080 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6081 | 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] | 6082 | |
| 6083 | try |
| 6084 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6085 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6086 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6087 | if (context) |
| 6088 | { |
| 6089 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6090 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6091 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6092 | } |
| 6093 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 6094 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6095 | |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6096 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6097 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6098 | return; |
| 6099 | } |
| 6100 | |
| 6101 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 6102 | { |
| 6103 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 6104 | for (int i = 0; i < 4; ++i) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6105 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6106 | float currentValue = currentValueData.FloatValues[i]; |
Jamie Madill | af49691 | 2013-07-19 16:36:54 -0400 | [diff] [blame] | 6107 | params[i] = gl::iround<GLint>(currentValue); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6108 | } |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6109 | } |
| 6110 | else |
| 6111 | { |
| 6112 | *params = attribState.querySingleParameter<GLint>(pname); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6113 | } |
| 6114 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6115 | } |
| 6116 | catch(std::bad_alloc&) |
| 6117 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6118 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6119 | } |
| 6120 | } |
| 6121 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6122 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6123 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6124 | 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] | 6125 | |
| 6126 | try |
| 6127 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6128 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6129 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6130 | if (context) |
| 6131 | { |
| 6132 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6133 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6134 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6135 | } |
| 6136 | |
| 6137 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) |
| 6138 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6139 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6140 | } |
| 6141 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6142 | *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index)); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6143 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6144 | } |
| 6145 | catch(std::bad_alloc&) |
| 6146 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6147 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6148 | } |
| 6149 | } |
| 6150 | |
| 6151 | void __stdcall glHint(GLenum target, GLenum mode) |
| 6152 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6153 | EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6154 | |
| 6155 | try |
| 6156 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6157 | switch (mode) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6158 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6159 | case GL_FASTEST: |
| 6160 | case GL_NICEST: |
| 6161 | case GL_DONT_CARE: |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6162 | break; |
| 6163 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6164 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6165 | } |
| 6166 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6167 | gl::Context *context = gl::getNonLostContext(); |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6168 | switch (target) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6169 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6170 | case GL_GENERATE_MIPMAP_HINT: |
| 6171 | if (context) context->setGenerateMipmapHint(mode); |
| 6172 | break; |
| 6173 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 6174 | if (context) context->setFragmentShaderDerivativeHint(mode); |
| 6175 | break; |
| 6176 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6177 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6178 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6179 | } |
| 6180 | catch(std::bad_alloc&) |
| 6181 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6182 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6183 | } |
| 6184 | } |
| 6185 | |
| 6186 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 6187 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6188 | EVENT("(GLuint buffer = %d)", buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6189 | |
| 6190 | try |
| 6191 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6192 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6193 | |
| 6194 | if (context && buffer) |
| 6195 | { |
| 6196 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 6197 | |
| 6198 | if (bufferObject) |
| 6199 | { |
| 6200 | return GL_TRUE; |
| 6201 | } |
| 6202 | } |
| 6203 | } |
| 6204 | catch(std::bad_alloc&) |
| 6205 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6206 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6207 | } |
| 6208 | |
| 6209 | return GL_FALSE; |
| 6210 | } |
| 6211 | |
| 6212 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 6213 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6214 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6215 | |
| 6216 | try |
| 6217 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6218 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6219 | |
| 6220 | if (context) |
| 6221 | { |
| 6222 | switch (cap) |
| 6223 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6224 | case GL_CULL_FACE: return context->isCullFaceEnabled(); |
| 6225 | case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled(); |
| 6226 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled(); |
| 6227 | case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled(); |
| 6228 | case GL_SCISSOR_TEST: return context->isScissorTestEnabled(); |
| 6229 | case GL_STENCIL_TEST: return context->isStencilTestEnabled(); |
| 6230 | case GL_DEPTH_TEST: return context->isDepthTestEnabled(); |
| 6231 | case GL_BLEND: return context->isBlendEnabled(); |
| 6232 | case GL_DITHER: return context->isDitherEnabled(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6233 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6234 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6235 | } |
| 6236 | } |
| 6237 | } |
| 6238 | catch(std::bad_alloc&) |
| 6239 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6240 | return gl::error(GL_OUT_OF_MEMORY, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6241 | } |
| 6242 | |
| 6243 | return false; |
| 6244 | } |
| 6245 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6246 | GLboolean __stdcall glIsFenceNV(GLuint fence) |
| 6247 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6248 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6249 | |
| 6250 | try |
| 6251 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6252 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6253 | |
| 6254 | if (context) |
| 6255 | { |
| 6256 | gl::Fence *fenceObject = context->getFence(fence); |
| 6257 | |
| 6258 | if (fenceObject == NULL) |
| 6259 | { |
| 6260 | return GL_FALSE; |
| 6261 | } |
| 6262 | |
| 6263 | return fenceObject->isFence(); |
| 6264 | } |
| 6265 | } |
| 6266 | catch(std::bad_alloc&) |
| 6267 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6268 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6269 | } |
| 6270 | |
| 6271 | return GL_FALSE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6272 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6273 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6274 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 6275 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6276 | EVENT("(GLuint framebuffer = %d)", framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6277 | |
| 6278 | try |
| 6279 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6280 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6281 | |
| 6282 | if (context && framebuffer) |
| 6283 | { |
| 6284 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 6285 | |
| 6286 | if (framebufferObject) |
| 6287 | { |
| 6288 | return GL_TRUE; |
| 6289 | } |
| 6290 | } |
| 6291 | } |
| 6292 | catch(std::bad_alloc&) |
| 6293 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6294 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6295 | } |
| 6296 | |
| 6297 | return GL_FALSE; |
| 6298 | } |
| 6299 | |
| 6300 | GLboolean __stdcall glIsProgram(GLuint program) |
| 6301 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6302 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6303 | |
| 6304 | try |
| 6305 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6306 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6307 | |
| 6308 | if (context && program) |
| 6309 | { |
| 6310 | gl::Program *programObject = context->getProgram(program); |
| 6311 | |
| 6312 | if (programObject) |
| 6313 | { |
| 6314 | return GL_TRUE; |
| 6315 | } |
| 6316 | } |
| 6317 | } |
| 6318 | catch(std::bad_alloc&) |
| 6319 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6320 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6321 | } |
| 6322 | |
| 6323 | return GL_FALSE; |
| 6324 | } |
| 6325 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 6326 | GLboolean __stdcall glIsQueryEXT(GLuint id) |
| 6327 | { |
| 6328 | EVENT("(GLuint id = %d)", id); |
| 6329 | |
| 6330 | try |
| 6331 | { |
| 6332 | if (id == 0) |
| 6333 | { |
| 6334 | return GL_FALSE; |
| 6335 | } |
| 6336 | |
| 6337 | gl::Context *context = gl::getNonLostContext(); |
| 6338 | |
| 6339 | if (context) |
| 6340 | { |
| 6341 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 6342 | |
| 6343 | if (queryObject) |
| 6344 | { |
| 6345 | return GL_TRUE; |
| 6346 | } |
| 6347 | } |
| 6348 | } |
| 6349 | catch(std::bad_alloc&) |
| 6350 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6351 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 6352 | } |
| 6353 | |
| 6354 | return GL_FALSE; |
| 6355 | } |
| 6356 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6357 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 6358 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6359 | EVENT("(GLuint renderbuffer = %d)", renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6360 | |
| 6361 | try |
| 6362 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6363 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6364 | |
| 6365 | if (context && renderbuffer) |
| 6366 | { |
| 6367 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 6368 | |
| 6369 | if (renderbufferObject) |
| 6370 | { |
| 6371 | return GL_TRUE; |
| 6372 | } |
| 6373 | } |
| 6374 | } |
| 6375 | catch(std::bad_alloc&) |
| 6376 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6377 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6378 | } |
| 6379 | |
| 6380 | return GL_FALSE; |
| 6381 | } |
| 6382 | |
| 6383 | GLboolean __stdcall glIsShader(GLuint shader) |
| 6384 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6385 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6386 | |
| 6387 | try |
| 6388 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6389 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6390 | |
| 6391 | if (context && shader) |
| 6392 | { |
| 6393 | gl::Shader *shaderObject = context->getShader(shader); |
| 6394 | |
| 6395 | if (shaderObject) |
| 6396 | { |
| 6397 | return GL_TRUE; |
| 6398 | } |
| 6399 | } |
| 6400 | } |
| 6401 | catch(std::bad_alloc&) |
| 6402 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6403 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6404 | } |
| 6405 | |
| 6406 | return GL_FALSE; |
| 6407 | } |
| 6408 | |
| 6409 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 6410 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6411 | EVENT("(GLuint texture = %d)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6412 | |
| 6413 | try |
| 6414 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6415 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6416 | |
| 6417 | if (context && texture) |
| 6418 | { |
| 6419 | gl::Texture *textureObject = context->getTexture(texture); |
| 6420 | |
| 6421 | if (textureObject) |
| 6422 | { |
| 6423 | return GL_TRUE; |
| 6424 | } |
| 6425 | } |
| 6426 | } |
| 6427 | catch(std::bad_alloc&) |
| 6428 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6429 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6430 | } |
| 6431 | |
| 6432 | return GL_FALSE; |
| 6433 | } |
| 6434 | |
| 6435 | void __stdcall glLineWidth(GLfloat width) |
| 6436 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6437 | EVENT("(GLfloat width = %f)", width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6438 | |
| 6439 | try |
| 6440 | { |
| 6441 | if (width <= 0.0f) |
| 6442 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6443 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6444 | } |
| 6445 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6446 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 6447 | |
| 6448 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6449 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6450 | context->setLineWidth(width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6451 | } |
| 6452 | } |
| 6453 | catch(std::bad_alloc&) |
| 6454 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6455 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6456 | } |
| 6457 | } |
| 6458 | |
| 6459 | void __stdcall glLinkProgram(GLuint program) |
| 6460 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6461 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6462 | |
| 6463 | try |
| 6464 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6465 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6466 | |
| 6467 | if (context) |
| 6468 | { |
| 6469 | gl::Program *programObject = context->getProgram(program); |
| 6470 | |
| 6471 | if (!programObject) |
| 6472 | { |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6473 | if (context->getShader(program)) |
| 6474 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6475 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6476 | } |
| 6477 | else |
| 6478 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6479 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6480 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6481 | } |
| 6482 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 6483 | context->linkProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6484 | } |
| 6485 | } |
| 6486 | catch(std::bad_alloc&) |
| 6487 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6488 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6489 | } |
| 6490 | } |
| 6491 | |
| 6492 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 6493 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6494 | EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6495 | |
| 6496 | try |
| 6497 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6498 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6499 | |
| 6500 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6501 | { |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6502 | switch (pname) |
| 6503 | { |
| 6504 | case GL_UNPACK_ALIGNMENT: |
| 6505 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6506 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6507 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6508 | } |
| 6509 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6510 | context->setUnpackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6511 | break; |
| 6512 | |
| 6513 | case GL_PACK_ALIGNMENT: |
| 6514 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6515 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6516 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6517 | } |
| 6518 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6519 | context->setPackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6520 | break; |
| 6521 | |
bsalomon@google.com | 56d46ab | 2011-11-23 14:53:10 +0000 | [diff] [blame] | 6522 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 6523 | context->setPackReverseRowOrder(param != 0); |
| 6524 | break; |
| 6525 | |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6526 | case GL_UNPACK_IMAGE_HEIGHT: |
| 6527 | case GL_UNPACK_SKIP_IMAGES: |
| 6528 | case GL_UNPACK_ROW_LENGTH: |
| 6529 | case GL_UNPACK_SKIP_ROWS: |
| 6530 | case GL_UNPACK_SKIP_PIXELS: |
| 6531 | case GL_PACK_ROW_LENGTH: |
| 6532 | case GL_PACK_SKIP_ROWS: |
| 6533 | case GL_PACK_SKIP_PIXELS: |
| 6534 | if (context->getClientVersion() < 3) |
| 6535 | { |
| 6536 | return gl::error(GL_INVALID_ENUM); |
| 6537 | } |
| 6538 | UNIMPLEMENTED(); |
| 6539 | break; |
| 6540 | |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6541 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6542 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6543 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6544 | } |
| 6545 | } |
| 6546 | catch(std::bad_alloc&) |
| 6547 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6548 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6549 | } |
| 6550 | } |
| 6551 | |
| 6552 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 6553 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6554 | EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6555 | |
| 6556 | try |
| 6557 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6558 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aede630 | 2010-04-29 03:35:48 +0000 | [diff] [blame] | 6559 | |
| 6560 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6561 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6562 | context->setPolygonOffsetParams(factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6563 | } |
| 6564 | } |
| 6565 | catch(std::bad_alloc&) |
| 6566 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6567 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6568 | } |
| 6569 | } |
| 6570 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6571 | void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6572 | GLenum format, GLenum type, GLsizei bufSize, |
| 6573 | GLvoid *data) |
| 6574 | { |
| 6575 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
| 6576 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)", |
| 6577 | x, y, width, height, format, type, bufSize, data); |
| 6578 | |
| 6579 | try |
| 6580 | { |
| 6581 | if (width < 0 || height < 0 || bufSize < 0) |
| 6582 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6583 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6584 | } |
| 6585 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6586 | gl::Context *context = gl::getNonLostContext(); |
| 6587 | |
| 6588 | if (context) |
| 6589 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6590 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6591 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6592 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6593 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6594 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6595 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6596 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6597 | return; |
| 6598 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6599 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6600 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6601 | |
| 6602 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6603 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6604 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6605 | } |
| 6606 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6607 | context->readPixels(x, y, width, height, format, type, &bufSize, data); |
| 6608 | } |
| 6609 | } |
| 6610 | catch(std::bad_alloc&) |
| 6611 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6612 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6613 | } |
| 6614 | } |
| 6615 | |
| 6616 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6617 | GLenum format, GLenum type, GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6618 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6619 | 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] | 6620 | "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] | 6621 | x, y, width, height, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6622 | |
| 6623 | try |
| 6624 | { |
| 6625 | if (width < 0 || height < 0) |
| 6626 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6627 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6628 | } |
| 6629 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6630 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6631 | |
| 6632 | if (context) |
| 6633 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6634 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6635 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6636 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6637 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6638 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6639 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6640 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6641 | return; |
| 6642 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6643 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6644 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6645 | |
| 6646 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6647 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6648 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6649 | } |
| 6650 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6651 | context->readPixels(x, y, width, height, format, type, NULL, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6652 | } |
| 6653 | } |
| 6654 | catch(std::bad_alloc&) |
| 6655 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6656 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6657 | } |
| 6658 | } |
| 6659 | |
| 6660 | void __stdcall glReleaseShaderCompiler(void) |
| 6661 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6662 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6663 | |
| 6664 | try |
| 6665 | { |
| 6666 | gl::Shader::releaseCompiler(); |
| 6667 | } |
| 6668 | catch(std::bad_alloc&) |
| 6669 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6670 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6671 | } |
| 6672 | } |
| 6673 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6674 | 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] | 6675 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6676 | 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] | 6677 | target, samples, internalformat, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6678 | |
| 6679 | try |
| 6680 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6681 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6682 | |
| 6683 | if (context) |
| 6684 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6685 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 6686 | width, height, true)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6687 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6688 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6689 | } |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 6690 | |
| 6691 | context->setRenderbufferStorage(width, height, internalformat, samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6692 | } |
| 6693 | } |
| 6694 | catch(std::bad_alloc&) |
| 6695 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6696 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6697 | } |
| 6698 | } |
| 6699 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6700 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 6701 | { |
| 6702 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height); |
| 6703 | } |
| 6704 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6705 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 6706 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6707 | EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6708 | |
| 6709 | try |
| 6710 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6711 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6712 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6713 | if (context) |
| 6714 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 6715 | context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6716 | } |
| 6717 | } |
| 6718 | catch(std::bad_alloc&) |
| 6719 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6720 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6721 | } |
| 6722 | } |
| 6723 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6724 | void __stdcall glSetFenceNV(GLuint fence, GLenum condition) |
| 6725 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6726 | EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6727 | |
| 6728 | try |
| 6729 | { |
| 6730 | if (condition != GL_ALL_COMPLETED_NV) |
| 6731 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6732 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6733 | } |
| 6734 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6735 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6736 | |
| 6737 | if (context) |
| 6738 | { |
| 6739 | gl::Fence *fenceObject = context->getFence(fence); |
| 6740 | |
| 6741 | if (fenceObject == NULL) |
| 6742 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6743 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6744 | } |
| 6745 | |
| 6746 | fenceObject->setFence(condition); |
| 6747 | } |
| 6748 | } |
| 6749 | catch(std::bad_alloc&) |
| 6750 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6751 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6752 | } |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6753 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6754 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6755 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 6756 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6757 | 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] | 6758 | |
| 6759 | try |
| 6760 | { |
| 6761 | if (width < 0 || height < 0) |
| 6762 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6763 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6764 | } |
| 6765 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6766 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6767 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6768 | if (context) |
| 6769 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6770 | context->setScissorParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6771 | } |
| 6772 | } |
| 6773 | catch(std::bad_alloc&) |
| 6774 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6775 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6776 | } |
| 6777 | } |
| 6778 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6779 | 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] | 6780 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6781 | 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] | 6782 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 6783 | n, shaders, binaryformat, binary, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6784 | |
| 6785 | try |
| 6786 | { |
daniel@transgaming.com | d1f667f | 2010-04-29 03:38:52 +0000 | [diff] [blame] | 6787 | // No binary shader formats are supported. |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6788 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6789 | } |
| 6790 | catch(std::bad_alloc&) |
| 6791 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6792 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6793 | } |
| 6794 | } |
| 6795 | |
shannon.woods%transgaming.com@gtempaccount.com | 5f33933 | 2013-04-13 03:29:02 +0000 | [diff] [blame] | 6796 | 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] | 6797 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6798 | 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] | 6799 | shader, count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6800 | |
| 6801 | try |
| 6802 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6803 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6804 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6805 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6806 | } |
| 6807 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6808 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6809 | |
| 6810 | if (context) |
| 6811 | { |
| 6812 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6813 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6814 | if (!shaderObject) |
| 6815 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6816 | if (context->getProgram(shader)) |
| 6817 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6818 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6819 | } |
| 6820 | else |
| 6821 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6822 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6823 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6824 | } |
| 6825 | |
| 6826 | shaderObject->setSource(count, string, length); |
| 6827 | } |
| 6828 | } |
| 6829 | catch(std::bad_alloc&) |
| 6830 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6831 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6832 | } |
| 6833 | } |
| 6834 | |
| 6835 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 6836 | { |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6837 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6838 | } |
| 6839 | |
| 6840 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 6841 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6842 | 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] | 6843 | |
| 6844 | try |
| 6845 | { |
| 6846 | switch (face) |
| 6847 | { |
| 6848 | case GL_FRONT: |
| 6849 | case GL_BACK: |
| 6850 | case GL_FRONT_AND_BACK: |
| 6851 | break; |
| 6852 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6853 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6854 | } |
| 6855 | |
| 6856 | switch (func) |
| 6857 | { |
| 6858 | case GL_NEVER: |
| 6859 | case GL_ALWAYS: |
| 6860 | case GL_LESS: |
| 6861 | case GL_LEQUAL: |
| 6862 | case GL_EQUAL: |
| 6863 | case GL_GEQUAL: |
| 6864 | case GL_GREATER: |
| 6865 | case GL_NOTEQUAL: |
| 6866 | break; |
| 6867 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6868 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6869 | } |
| 6870 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6871 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6872 | |
| 6873 | if (context) |
| 6874 | { |
| 6875 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6876 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6877 | context->setStencilParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6878 | } |
| 6879 | |
| 6880 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6881 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6882 | context->setStencilBackParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6883 | } |
| 6884 | } |
| 6885 | } |
| 6886 | catch(std::bad_alloc&) |
| 6887 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6888 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6889 | } |
| 6890 | } |
| 6891 | |
| 6892 | void __stdcall glStencilMask(GLuint mask) |
| 6893 | { |
| 6894 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 6895 | } |
| 6896 | |
| 6897 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 6898 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6899 | EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6900 | |
| 6901 | try |
| 6902 | { |
| 6903 | switch (face) |
| 6904 | { |
| 6905 | case GL_FRONT: |
| 6906 | case GL_BACK: |
| 6907 | case GL_FRONT_AND_BACK: |
| 6908 | break; |
| 6909 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6910 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6911 | } |
| 6912 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6913 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6914 | |
| 6915 | if (context) |
| 6916 | { |
| 6917 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6918 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6919 | context->setStencilWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6920 | } |
| 6921 | |
| 6922 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6923 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6924 | context->setStencilBackWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6925 | } |
| 6926 | } |
| 6927 | } |
| 6928 | catch(std::bad_alloc&) |
| 6929 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6930 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6931 | } |
| 6932 | } |
| 6933 | |
| 6934 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 6935 | { |
| 6936 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 6937 | } |
| 6938 | |
| 6939 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 6940 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6941 | 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] | 6942 | face, fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6943 | |
| 6944 | try |
| 6945 | { |
| 6946 | switch (face) |
| 6947 | { |
| 6948 | case GL_FRONT: |
| 6949 | case GL_BACK: |
| 6950 | case GL_FRONT_AND_BACK: |
| 6951 | break; |
| 6952 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6953 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6954 | } |
| 6955 | |
| 6956 | switch (fail) |
| 6957 | { |
| 6958 | case GL_ZERO: |
| 6959 | case GL_KEEP: |
| 6960 | case GL_REPLACE: |
| 6961 | case GL_INCR: |
| 6962 | case GL_DECR: |
| 6963 | case GL_INVERT: |
| 6964 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6965 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6966 | break; |
| 6967 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6968 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6969 | } |
| 6970 | |
| 6971 | switch (zfail) |
| 6972 | { |
| 6973 | case GL_ZERO: |
| 6974 | case GL_KEEP: |
| 6975 | case GL_REPLACE: |
| 6976 | case GL_INCR: |
| 6977 | case GL_DECR: |
| 6978 | case GL_INVERT: |
| 6979 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6980 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6981 | break; |
| 6982 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6983 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6984 | } |
| 6985 | |
| 6986 | switch (zpass) |
| 6987 | { |
| 6988 | case GL_ZERO: |
| 6989 | case GL_KEEP: |
| 6990 | case GL_REPLACE: |
| 6991 | case GL_INCR: |
| 6992 | case GL_DECR: |
| 6993 | case GL_INVERT: |
| 6994 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6995 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6996 | break; |
| 6997 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6998 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6999 | } |
| 7000 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7001 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7002 | |
| 7003 | if (context) |
| 7004 | { |
| 7005 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 7006 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7007 | context->setStencilOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7008 | } |
| 7009 | |
| 7010 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 7011 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7012 | context->setStencilBackOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7013 | } |
| 7014 | } |
| 7015 | } |
| 7016 | catch(std::bad_alloc&) |
| 7017 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7018 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7019 | } |
| 7020 | } |
| 7021 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 7022 | GLboolean __stdcall glTestFenceNV(GLuint fence) |
| 7023 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7024 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7025 | |
| 7026 | try |
| 7027 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7028 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7029 | |
| 7030 | if (context) |
| 7031 | { |
| 7032 | gl::Fence *fenceObject = context->getFence(fence); |
| 7033 | |
| 7034 | if (fenceObject == NULL) |
| 7035 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7036 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7037 | } |
| 7038 | |
| 7039 | return fenceObject->testFence(); |
| 7040 | } |
| 7041 | } |
| 7042 | catch(std::bad_alloc&) |
| 7043 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7044 | gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7045 | } |
| 7046 | |
| 7047 | return GL_TRUE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 7048 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7049 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7050 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, |
| 7051 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7052 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7053 | 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] | 7054 | "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] | 7055 | target, level, internalformat, width, height, border, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7056 | |
| 7057 | try |
| 7058 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7059 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7060 | |
| 7061 | if (context) |
| 7062 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7063 | if (context->getClientVersion() < 3 && |
| 7064 | !validateES2TexImageParameters(context, target, level, internalformat, false, false, |
| 7065 | 0, 0, width, height, border, format, type, pixels)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 7066 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7067 | return; |
| 7068 | } |
| 7069 | |
| 7070 | if (context->getClientVersion() >= 3 && |
| 7071 | !validateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 7072 | 0, 0, 0, width, height, 1, border, format, type)) |
| 7073 | { |
| 7074 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 7075 | } |
| 7076 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7077 | switch (target) |
| 7078 | { |
| 7079 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7080 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7081 | gl::Texture2D *texture = context->getTexture2D(); |
| 7082 | texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7083 | } |
| 7084 | break; |
| 7085 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7086 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7087 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 7088 | texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7089 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7090 | break; |
| 7091 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7092 | { |
| 7093 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7094 | texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7095 | } |
| 7096 | break; |
| 7097 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7098 | { |
| 7099 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7100 | texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7101 | } |
| 7102 | break; |
| 7103 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7104 | { |
| 7105 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7106 | texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7107 | } |
| 7108 | break; |
| 7109 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7110 | { |
| 7111 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7112 | texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7113 | } |
| 7114 | break; |
| 7115 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 7116 | { |
| 7117 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7118 | texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7119 | } |
| 7120 | break; |
| 7121 | default: UNREACHABLE(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7122 | } |
| 7123 | } |
| 7124 | } |
| 7125 | catch(std::bad_alloc&) |
| 7126 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7127 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7128 | } |
| 7129 | } |
| 7130 | |
| 7131 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 7132 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7133 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param); |
| 7134 | |
| 7135 | try |
| 7136 | { |
| 7137 | gl::Context *context = gl::getNonLostContext(); |
| 7138 | |
| 7139 | if (context) |
| 7140 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7141 | if (!validateTexParamParameters(context, pname, static_cast<GLint>(param))) |
| 7142 | { |
| 7143 | return; |
| 7144 | } |
| 7145 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame^] | 7146 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7147 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame^] | 7148 | if (!texture) |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7149 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7150 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7151 | } |
| 7152 | |
| 7153 | switch (pname) |
| 7154 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7155 | case GL_TEXTURE_WRAP_S: texture->setWrapS(gl::uiround<GLenum>(param)); break; |
| 7156 | case GL_TEXTURE_WRAP_T: texture->setWrapT(gl::uiround<GLenum>(param)); break; |
| 7157 | case GL_TEXTURE_WRAP_R: texture->setWrapR(gl::uiround<GLenum>(param)); break; |
| 7158 | case GL_TEXTURE_MIN_FILTER: texture->setMinFilter(gl::uiround<GLenum>(param)); break; |
| 7159 | case GL_TEXTURE_MAG_FILTER: texture->setMagFilter(gl::uiround<GLenum>(param)); break; |
| 7160 | case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break; |
| 7161 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy(static_cast<GLfloat>(param), context->getTextureMaxAnisotropy()); break; |
| 7162 | case GL_TEXTURE_COMPARE_MODE: texture->setCompareMode(gl::uiround<GLenum>(param)); break; |
| 7163 | 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] | 7164 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7165 | case GL_TEXTURE_SWIZZLE_R: |
| 7166 | case GL_TEXTURE_SWIZZLE_G: |
| 7167 | case GL_TEXTURE_SWIZZLE_B: |
| 7168 | case GL_TEXTURE_SWIZZLE_A: |
| 7169 | case GL_TEXTURE_BASE_LEVEL: |
| 7170 | case GL_TEXTURE_MAX_LEVEL: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7171 | case GL_TEXTURE_MIN_LOD: |
| 7172 | case GL_TEXTURE_MAX_LOD: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7173 | UNIMPLEMENTED(); |
| 7174 | break; |
| 7175 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7176 | default: UNREACHABLE(); break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7177 | } |
| 7178 | } |
| 7179 | } |
| 7180 | catch(std::bad_alloc&) |
| 7181 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7182 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7183 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7184 | } |
| 7185 | |
| 7186 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 7187 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7188 | glTexParameterf(target, pname, (GLfloat)*params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7189 | } |
| 7190 | |
| 7191 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 7192 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7193 | 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] | 7194 | |
| 7195 | try |
| 7196 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7197 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7198 | |
| 7199 | if (context) |
| 7200 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7201 | if (!validateTexParamParameters(context, pname, param)) |
| 7202 | { |
| 7203 | return; |
| 7204 | } |
| 7205 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame^] | 7206 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7207 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame^] | 7208 | if (!texture) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7209 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7210 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7211 | } |
| 7212 | |
| 7213 | switch (pname) |
| 7214 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7215 | case GL_TEXTURE_WRAP_S: texture->setWrapS((GLenum)param); break; |
| 7216 | case GL_TEXTURE_WRAP_T: texture->setWrapT((GLenum)param); break; |
| 7217 | case GL_TEXTURE_WRAP_R: texture->setWrapR((GLenum)param); break; |
| 7218 | case GL_TEXTURE_MIN_FILTER: texture->setMinFilter((GLenum)param); break; |
| 7219 | case GL_TEXTURE_MAG_FILTER: texture->setMagFilter((GLenum)param); break; |
| 7220 | case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break; |
| 7221 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()); break; |
| 7222 | case GL_TEXTURE_COMPARE_MODE: texture->setCompareMode((GLenum)param); break; |
| 7223 | case GL_TEXTURE_COMPARE_FUNC: texture->setCompareFunc((GLenum)param); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7224 | |
| 7225 | case GL_TEXTURE_SWIZZLE_R: |
| 7226 | case GL_TEXTURE_SWIZZLE_G: |
| 7227 | case GL_TEXTURE_SWIZZLE_B: |
| 7228 | case GL_TEXTURE_SWIZZLE_A: |
| 7229 | case GL_TEXTURE_BASE_LEVEL: |
| 7230 | case GL_TEXTURE_MAX_LEVEL: |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7231 | case GL_TEXTURE_MIN_LOD: |
| 7232 | case GL_TEXTURE_MAX_LOD: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7233 | UNIMPLEMENTED(); |
| 7234 | break; |
| 7235 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7236 | default: UNREACHABLE(); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7237 | } |
| 7238 | } |
| 7239 | } |
| 7240 | catch(std::bad_alloc&) |
| 7241 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7242 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7243 | } |
| 7244 | } |
| 7245 | |
| 7246 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 7247 | { |
| 7248 | glTexParameteri(target, pname, *params); |
| 7249 | } |
| 7250 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7251 | void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 7252 | { |
| 7253 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 7254 | target, levels, internalformat, width, height); |
| 7255 | |
| 7256 | try |
| 7257 | { |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7258 | gl::Context *context = gl::getNonLostContext(); |
| 7259 | |
| 7260 | if (context) |
| 7261 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7262 | if (context->getClientVersion() < 3 && |
| 7263 | !validateES2TexStorageParameters(context, target, levels, internalformat, width, height)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7264 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7265 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7266 | } |
| 7267 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7268 | if (context->getClientVersion() >= 3 && |
| 7269 | !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7270 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7271 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7272 | } |
| 7273 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7274 | switch (target) |
| 7275 | { |
| 7276 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7277 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7278 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 7279 | texture2d->storage(levels, internalformat, width, height); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7280 | } |
| 7281 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7282 | |
| 7283 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7284 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7285 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7286 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7287 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7288 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7289 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7290 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 7291 | textureCube->storage(levels, internalformat, width); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7292 | } |
| 7293 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7294 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7295 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7296 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7297 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7298 | } |
| 7299 | } |
| 7300 | catch(std::bad_alloc&) |
| 7301 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7302 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7303 | } |
| 7304 | } |
| 7305 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7306 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 7307 | GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7308 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7309 | 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] | 7310 | "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] | 7311 | "const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7312 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 7313 | |
| 7314 | try |
| 7315 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7316 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7317 | |
| 7318 | if (context) |
| 7319 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7320 | if (context->getClientVersion() < 3 && |
| 7321 | !validateES2TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7322 | 0, 0, width, height, 0, format, type, pixels)) |
daniel@transgaming.com | 1d2d3c4 | 2012-05-31 01:14:15 +0000 | [diff] [blame] | 7323 | { |
| 7324 | return; |
| 7325 | } |
| 7326 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7327 | if (context->getClientVersion() >= 3 && |
| 7328 | !validateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7329 | 0, 0, 0, width, height, 1, 0, format, type)) |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7330 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7331 | return; |
| 7332 | } |
| 7333 | |
| 7334 | switch (target) |
| 7335 | { |
| 7336 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7337 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7338 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7339 | 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] | 7340 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7341 | break; |
| 7342 | |
| 7343 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7344 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7345 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7346 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7347 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7348 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7349 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7350 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7351 | 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] | 7352 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7353 | break; |
| 7354 | |
| 7355 | default: |
| 7356 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7357 | } |
| 7358 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7359 | } |
| 7360 | catch(std::bad_alloc&) |
| 7361 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7362 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7363 | } |
| 7364 | } |
| 7365 | |
| 7366 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 7367 | { |
| 7368 | glUniform1fv(location, 1, &x); |
| 7369 | } |
| 7370 | |
| 7371 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 7372 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7373 | 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] | 7374 | |
| 7375 | try |
| 7376 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7377 | if (count < 0) |
| 7378 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7379 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7380 | } |
| 7381 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7382 | if (location == -1) |
| 7383 | { |
| 7384 | return; |
| 7385 | } |
| 7386 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7387 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7388 | |
| 7389 | if (context) |
| 7390 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7391 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7392 | if (!programBinary) |
| 7393 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7394 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7395 | } |
| 7396 | |
| 7397 | if (!programBinary->setUniform1fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7398 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7399 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7400 | } |
| 7401 | } |
| 7402 | } |
| 7403 | catch(std::bad_alloc&) |
| 7404 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7405 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7406 | } |
| 7407 | } |
| 7408 | |
| 7409 | void __stdcall glUniform1i(GLint location, GLint x) |
| 7410 | { |
| 7411 | glUniform1iv(location, 1, &x); |
| 7412 | } |
| 7413 | |
| 7414 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 7415 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7416 | 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] | 7417 | |
| 7418 | try |
| 7419 | { |
| 7420 | if (count < 0) |
| 7421 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7422 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7423 | } |
| 7424 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7425 | if (location == -1) |
| 7426 | { |
| 7427 | return; |
| 7428 | } |
| 7429 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7430 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7431 | |
| 7432 | if (context) |
| 7433 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7434 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7435 | if (!programBinary) |
| 7436 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7437 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7438 | } |
| 7439 | |
| 7440 | if (!programBinary->setUniform1iv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7441 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7442 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7443 | } |
| 7444 | } |
| 7445 | } |
| 7446 | catch(std::bad_alloc&) |
| 7447 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7448 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7449 | } |
| 7450 | } |
| 7451 | |
| 7452 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 7453 | { |
| 7454 | GLfloat xy[2] = {x, y}; |
| 7455 | |
| 7456 | glUniform2fv(location, 1, (GLfloat*)&xy); |
| 7457 | } |
| 7458 | |
| 7459 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 7460 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7461 | 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] | 7462 | |
| 7463 | try |
| 7464 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7465 | if (count < 0) |
| 7466 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7467 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7468 | } |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7469 | |
| 7470 | if (location == -1) |
| 7471 | { |
| 7472 | return; |
| 7473 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7474 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7475 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7476 | |
| 7477 | if (context) |
| 7478 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7479 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7480 | if (!programBinary) |
| 7481 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7482 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7483 | } |
| 7484 | |
| 7485 | if (!programBinary->setUniform2fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7486 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7487 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7488 | } |
| 7489 | } |
| 7490 | } |
| 7491 | catch(std::bad_alloc&) |
| 7492 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7493 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7494 | } |
| 7495 | } |
| 7496 | |
| 7497 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 7498 | { |
| 7499 | GLint xy[4] = {x, y}; |
| 7500 | |
| 7501 | glUniform2iv(location, 1, (GLint*)&xy); |
| 7502 | } |
| 7503 | |
| 7504 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 7505 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7506 | 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] | 7507 | |
| 7508 | try |
| 7509 | { |
| 7510 | if (count < 0) |
| 7511 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7512 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7513 | } |
| 7514 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7515 | if (location == -1) |
| 7516 | { |
| 7517 | return; |
| 7518 | } |
| 7519 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7520 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7521 | |
| 7522 | if (context) |
| 7523 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7524 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7525 | if (!programBinary) |
| 7526 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7527 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7528 | } |
| 7529 | |
| 7530 | if (!programBinary->setUniform2iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7531 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7532 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7533 | } |
| 7534 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7535 | } |
| 7536 | catch(std::bad_alloc&) |
| 7537 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7538 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7539 | } |
| 7540 | } |
| 7541 | |
| 7542 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 7543 | { |
| 7544 | GLfloat xyz[3] = {x, y, z}; |
| 7545 | |
| 7546 | glUniform3fv(location, 1, (GLfloat*)&xyz); |
| 7547 | } |
| 7548 | |
| 7549 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 7550 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7551 | 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] | 7552 | |
| 7553 | try |
| 7554 | { |
| 7555 | if (count < 0) |
| 7556 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7557 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7558 | } |
| 7559 | |
| 7560 | if (location == -1) |
| 7561 | { |
| 7562 | return; |
| 7563 | } |
| 7564 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7565 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7566 | |
| 7567 | if (context) |
| 7568 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7569 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7570 | if (!programBinary) |
| 7571 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7572 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7573 | } |
| 7574 | |
| 7575 | if (!programBinary->setUniform3fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7576 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7577 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7578 | } |
| 7579 | } |
| 7580 | } |
| 7581 | catch(std::bad_alloc&) |
| 7582 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7583 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7584 | } |
| 7585 | } |
| 7586 | |
| 7587 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 7588 | { |
| 7589 | GLint xyz[3] = {x, y, z}; |
| 7590 | |
| 7591 | glUniform3iv(location, 1, (GLint*)&xyz); |
| 7592 | } |
| 7593 | |
| 7594 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 7595 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7596 | 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] | 7597 | |
| 7598 | try |
| 7599 | { |
| 7600 | if (count < 0) |
| 7601 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7602 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7603 | } |
| 7604 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7605 | if (location == -1) |
| 7606 | { |
| 7607 | return; |
| 7608 | } |
| 7609 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7610 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7611 | |
| 7612 | if (context) |
| 7613 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7614 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7615 | if (!programBinary) |
| 7616 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7617 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7618 | } |
| 7619 | |
| 7620 | if (!programBinary->setUniform3iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7621 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7622 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7623 | } |
| 7624 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7625 | } |
| 7626 | catch(std::bad_alloc&) |
| 7627 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7628 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7629 | } |
| 7630 | } |
| 7631 | |
| 7632 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7633 | { |
| 7634 | GLfloat xyzw[4] = {x, y, z, w}; |
| 7635 | |
| 7636 | glUniform4fv(location, 1, (GLfloat*)&xyzw); |
| 7637 | } |
| 7638 | |
| 7639 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 7640 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7641 | 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] | 7642 | |
| 7643 | try |
| 7644 | { |
| 7645 | if (count < 0) |
| 7646 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7647 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7648 | } |
| 7649 | |
| 7650 | if (location == -1) |
| 7651 | { |
| 7652 | return; |
| 7653 | } |
| 7654 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7655 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7656 | |
| 7657 | if (context) |
| 7658 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7659 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7660 | if (!programBinary) |
| 7661 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7662 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7663 | } |
| 7664 | |
| 7665 | if (!programBinary->setUniform4fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7666 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7667 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7668 | } |
| 7669 | } |
| 7670 | } |
| 7671 | catch(std::bad_alloc&) |
| 7672 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7673 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7674 | } |
| 7675 | } |
| 7676 | |
| 7677 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 7678 | { |
| 7679 | GLint xyzw[4] = {x, y, z, w}; |
| 7680 | |
| 7681 | glUniform4iv(location, 1, (GLint*)&xyzw); |
| 7682 | } |
| 7683 | |
| 7684 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 7685 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7686 | 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] | 7687 | |
| 7688 | try |
| 7689 | { |
| 7690 | if (count < 0) |
| 7691 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7692 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7693 | } |
| 7694 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7695 | if (location == -1) |
| 7696 | { |
| 7697 | return; |
| 7698 | } |
| 7699 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7700 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7701 | |
| 7702 | if (context) |
| 7703 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7704 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7705 | if (!programBinary) |
| 7706 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7707 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7708 | } |
| 7709 | |
| 7710 | if (!programBinary->setUniform4iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7711 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7712 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7713 | } |
| 7714 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7715 | } |
| 7716 | catch(std::bad_alloc&) |
| 7717 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7718 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7719 | } |
| 7720 | } |
| 7721 | |
| 7722 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7723 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7724 | 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] | 7725 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7726 | |
| 7727 | try |
| 7728 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7729 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7730 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7731 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7732 | } |
| 7733 | |
| 7734 | if (location == -1) |
| 7735 | { |
| 7736 | return; |
| 7737 | } |
| 7738 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7739 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7740 | |
| 7741 | if (context) |
| 7742 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7743 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7744 | { |
| 7745 | return gl::error(GL_INVALID_VALUE); |
| 7746 | } |
| 7747 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7748 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7749 | if (!programBinary) |
| 7750 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7751 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7752 | } |
| 7753 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7754 | if (!programBinary->setUniformMatrix2fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7755 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7756 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7757 | } |
| 7758 | } |
| 7759 | } |
| 7760 | catch(std::bad_alloc&) |
| 7761 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7762 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7763 | } |
| 7764 | } |
| 7765 | |
| 7766 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7767 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7768 | 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] | 7769 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7770 | |
| 7771 | try |
| 7772 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7773 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7774 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7775 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7776 | } |
| 7777 | |
| 7778 | if (location == -1) |
| 7779 | { |
| 7780 | return; |
| 7781 | } |
| 7782 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7783 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7784 | |
| 7785 | if (context) |
| 7786 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7787 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7788 | { |
| 7789 | return gl::error(GL_INVALID_VALUE); |
| 7790 | } |
| 7791 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7792 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7793 | if (!programBinary) |
| 7794 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7795 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7796 | } |
| 7797 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7798 | if (!programBinary->setUniformMatrix3fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7799 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7800 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7801 | } |
| 7802 | } |
| 7803 | } |
| 7804 | catch(std::bad_alloc&) |
| 7805 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7806 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7807 | } |
| 7808 | } |
| 7809 | |
| 7810 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7811 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7812 | 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] | 7813 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7814 | |
| 7815 | try |
| 7816 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7817 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7818 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7819 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7820 | } |
| 7821 | |
| 7822 | if (location == -1) |
| 7823 | { |
| 7824 | return; |
| 7825 | } |
| 7826 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7827 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7828 | |
| 7829 | if (context) |
| 7830 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7831 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7832 | { |
| 7833 | return gl::error(GL_INVALID_VALUE); |
| 7834 | } |
| 7835 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7836 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7837 | if (!programBinary) |
| 7838 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7839 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7840 | } |
| 7841 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7842 | if (!programBinary->setUniformMatrix4fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7843 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7844 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7845 | } |
| 7846 | } |
| 7847 | } |
| 7848 | catch(std::bad_alloc&) |
| 7849 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7850 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7851 | } |
| 7852 | } |
| 7853 | |
| 7854 | void __stdcall glUseProgram(GLuint program) |
| 7855 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7856 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7857 | |
| 7858 | try |
| 7859 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7860 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7861 | |
| 7862 | if (context) |
| 7863 | { |
| 7864 | gl::Program *programObject = context->getProgram(program); |
| 7865 | |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7866 | if (!programObject && program != 0) |
| 7867 | { |
| 7868 | if (context->getShader(program)) |
| 7869 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7870 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7871 | } |
| 7872 | else |
| 7873 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7874 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7875 | } |
| 7876 | } |
| 7877 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 7878 | if (program != 0 && !programObject->isLinked()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7879 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7880 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7881 | } |
| 7882 | |
| 7883 | context->useProgram(program); |
| 7884 | } |
| 7885 | } |
| 7886 | catch(std::bad_alloc&) |
| 7887 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7888 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7889 | } |
| 7890 | } |
| 7891 | |
| 7892 | void __stdcall glValidateProgram(GLuint program) |
| 7893 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7894 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7895 | |
| 7896 | try |
| 7897 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7898 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7899 | |
| 7900 | if (context) |
| 7901 | { |
| 7902 | gl::Program *programObject = context->getProgram(program); |
| 7903 | |
| 7904 | if (!programObject) |
| 7905 | { |
| 7906 | if (context->getShader(program)) |
| 7907 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7908 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7909 | } |
| 7910 | else |
| 7911 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7912 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7913 | } |
| 7914 | } |
| 7915 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 7916 | programObject->validate(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7917 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7918 | } |
| 7919 | catch(std::bad_alloc&) |
| 7920 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7921 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7922 | } |
| 7923 | } |
| 7924 | |
| 7925 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 7926 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7927 | EVENT("(GLuint index = %d, GLfloat x = %f)", index, x); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7928 | |
| 7929 | try |
| 7930 | { |
| 7931 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7932 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7933 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7934 | } |
| 7935 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7936 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7937 | |
| 7938 | if (context) |
| 7939 | { |
| 7940 | GLfloat vals[4] = { x, 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7941 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7942 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7943 | } |
| 7944 | catch(std::bad_alloc&) |
| 7945 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7946 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7947 | } |
| 7948 | } |
| 7949 | |
| 7950 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 7951 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7952 | 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] | 7953 | |
| 7954 | try |
| 7955 | { |
| 7956 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7957 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7958 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7959 | } |
| 7960 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7961 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7962 | |
| 7963 | if (context) |
| 7964 | { |
| 7965 | GLfloat vals[4] = { values[0], 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7966 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7967 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7968 | } |
| 7969 | catch(std::bad_alloc&) |
| 7970 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7971 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7972 | } |
| 7973 | } |
| 7974 | |
| 7975 | void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 7976 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7977 | 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] | 7978 | |
| 7979 | try |
| 7980 | { |
| 7981 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7982 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7983 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7984 | } |
| 7985 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7986 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7987 | |
| 7988 | if (context) |
| 7989 | { |
| 7990 | GLfloat vals[4] = { x, y, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7991 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7992 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7993 | } |
| 7994 | catch(std::bad_alloc&) |
| 7995 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7996 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7997 | } |
| 7998 | } |
| 7999 | |
| 8000 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 8001 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8002 | 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] | 8003 | |
| 8004 | try |
| 8005 | { |
| 8006 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8007 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8008 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8009 | } |
| 8010 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8011 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8012 | |
| 8013 | if (context) |
| 8014 | { |
| 8015 | 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] | 8016 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8017 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8018 | } |
| 8019 | catch(std::bad_alloc&) |
| 8020 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8021 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8022 | } |
| 8023 | } |
| 8024 | |
| 8025 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 8026 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8027 | 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] | 8028 | |
| 8029 | try |
| 8030 | { |
| 8031 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8032 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8033 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8034 | } |
| 8035 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8036 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8037 | |
| 8038 | if (context) |
| 8039 | { |
| 8040 | GLfloat vals[4] = { x, y, z, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8041 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8042 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8043 | } |
| 8044 | catch(std::bad_alloc&) |
| 8045 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8046 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8047 | } |
| 8048 | } |
| 8049 | |
| 8050 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 8051 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8052 | 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] | 8053 | |
| 8054 | try |
| 8055 | { |
| 8056 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8057 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8058 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8059 | } |
| 8060 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8061 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8062 | |
| 8063 | if (context) |
| 8064 | { |
| 8065 | 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] | 8066 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8067 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8068 | } |
| 8069 | catch(std::bad_alloc&) |
| 8070 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8071 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8072 | } |
| 8073 | } |
| 8074 | |
| 8075 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 8076 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8077 | 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] | 8078 | |
| 8079 | try |
| 8080 | { |
| 8081 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8082 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8083 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8084 | } |
| 8085 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8086 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8087 | |
| 8088 | if (context) |
| 8089 | { |
| 8090 | GLfloat vals[4] = { x, y, z, w }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8091 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8092 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8093 | } |
| 8094 | catch(std::bad_alloc&) |
| 8095 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8096 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8097 | } |
| 8098 | } |
| 8099 | |
| 8100 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 8101 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8102 | 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] | 8103 | |
| 8104 | try |
| 8105 | { |
| 8106 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8107 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8108 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8109 | } |
| 8110 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8111 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8112 | |
| 8113 | if (context) |
| 8114 | { |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8115 | context->setVertexAttribf(index, values); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8116 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8117 | } |
| 8118 | catch(std::bad_alloc&) |
| 8119 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8120 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8121 | } |
| 8122 | } |
| 8123 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8124 | void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
| 8125 | { |
| 8126 | EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor); |
| 8127 | |
| 8128 | try |
| 8129 | { |
| 8130 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8131 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8132 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8133 | } |
| 8134 | |
| 8135 | gl::Context *context = gl::getNonLostContext(); |
| 8136 | |
| 8137 | if (context) |
| 8138 | { |
| 8139 | context->setVertexAttribDivisor(index, divisor); |
| 8140 | } |
| 8141 | } |
| 8142 | catch(std::bad_alloc&) |
| 8143 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8144 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8145 | } |
| 8146 | } |
| 8147 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 8148 | 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] | 8149 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8150 | 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] | 8151 | "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] | 8152 | index, size, type, normalized, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8153 | |
| 8154 | try |
| 8155 | { |
| 8156 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8157 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8158 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8159 | } |
| 8160 | |
| 8161 | if (size < 1 || size > 4) |
| 8162 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8163 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8164 | } |
| 8165 | |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 8166 | gl::Context *context = gl::getNonLostContext(); |
| 8167 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8168 | switch (type) |
| 8169 | { |
| 8170 | case GL_BYTE: |
| 8171 | case GL_UNSIGNED_BYTE: |
| 8172 | case GL_SHORT: |
| 8173 | case GL_UNSIGNED_SHORT: |
| 8174 | case GL_FIXED: |
| 8175 | case GL_FLOAT: |
| 8176 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 8177 | case GL_HALF_FLOAT: |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8178 | case GL_INT: |
| 8179 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 8180 | case GL_INT_2_10_10_10_REV: |
| 8181 | 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] | 8182 | if (context && context->getClientVersion() < 3) |
| 8183 | { |
| 8184 | return gl::error(GL_INVALID_ENUM); |
| 8185 | } |
| 8186 | else |
| 8187 | { |
| 8188 | break; |
| 8189 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8190 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8191 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8192 | } |
| 8193 | |
| 8194 | if (stride < 0) |
| 8195 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8196 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8197 | } |
| 8198 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 8199 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 8200 | { |
| 8201 | return gl::error(GL_INVALID_OPERATION); |
| 8202 | } |
| 8203 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8204 | if (context) |
| 8205 | { |
Jamie Madill | d8db866 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 8206 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 8207 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 8208 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 8209 | // and the pointer argument is not NULL. |
| 8210 | if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && ptr != NULL) |
| 8211 | { |
| 8212 | return gl::error(GL_INVALID_OPERATION); |
| 8213 | } |
| 8214 | |
shannon.woods%transgaming.com@gtempaccount.com | 8de4e6a | 2013-04-13 03:37:44 +0000 | [diff] [blame] | 8215 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, |
| 8216 | normalized == GL_TRUE, false, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8217 | } |
| 8218 | } |
| 8219 | catch(std::bad_alloc&) |
| 8220 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8221 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8222 | } |
| 8223 | } |
| 8224 | |
| 8225 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 8226 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8227 | 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] | 8228 | |
| 8229 | try |
| 8230 | { |
| 8231 | if (width < 0 || height < 0) |
| 8232 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8233 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8234 | } |
| 8235 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8236 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8237 | |
| 8238 | if (context) |
| 8239 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 8240 | context->setViewportParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8241 | } |
| 8242 | } |
| 8243 | catch(std::bad_alloc&) |
| 8244 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8245 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8246 | } |
| 8247 | } |
| 8248 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8249 | // OpenGL ES 3.0 functions |
| 8250 | |
| 8251 | void __stdcall glReadBuffer(GLenum mode) |
| 8252 | { |
| 8253 | EVENT("(GLenum mode = 0x%X)", mode); |
| 8254 | |
| 8255 | try |
| 8256 | { |
| 8257 | gl::Context *context = gl::getNonLostContext(); |
| 8258 | |
| 8259 | if (context) |
| 8260 | { |
| 8261 | if (context->getClientVersion() < 3) |
| 8262 | { |
| 8263 | return gl::error(GL_INVALID_OPERATION); |
| 8264 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8265 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8266 | // glReadBuffer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8267 | UNIMPLEMENTED(); |
| 8268 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8269 | } |
| 8270 | catch(std::bad_alloc&) |
| 8271 | { |
| 8272 | return gl::error(GL_OUT_OF_MEMORY); |
| 8273 | } |
| 8274 | } |
| 8275 | |
| 8276 | void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) |
| 8277 | { |
| 8278 | EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, " |
| 8279 | "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices); |
| 8280 | |
| 8281 | try |
| 8282 | { |
| 8283 | gl::Context *context = gl::getNonLostContext(); |
| 8284 | |
| 8285 | if (context) |
| 8286 | { |
| 8287 | if (context->getClientVersion() < 3) |
| 8288 | { |
| 8289 | return gl::error(GL_INVALID_OPERATION); |
| 8290 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8291 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8292 | // glDrawRangeElements |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8293 | UNIMPLEMENTED(); |
| 8294 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8295 | } |
| 8296 | catch(std::bad_alloc&) |
| 8297 | { |
| 8298 | return gl::error(GL_OUT_OF_MEMORY); |
| 8299 | } |
| 8300 | } |
| 8301 | |
| 8302 | void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
| 8303 | { |
| 8304 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8305 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " |
| 8306 | "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8307 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 8308 | |
| 8309 | try |
| 8310 | { |
| 8311 | gl::Context *context = gl::getNonLostContext(); |
| 8312 | |
| 8313 | if (context) |
| 8314 | { |
| 8315 | if (context->getClientVersion() < 3) |
| 8316 | { |
| 8317 | return gl::error(GL_INVALID_OPERATION); |
| 8318 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8319 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8320 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8321 | if (!validateES3TexImageParameters(context, target, level, internalformat, false, false, |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8322 | 0, 0, 0, width, height, depth, border, format, type)) |
| 8323 | { |
| 8324 | return; |
| 8325 | } |
| 8326 | |
| 8327 | switch(target) |
| 8328 | { |
| 8329 | case GL_TEXTURE_3D: |
| 8330 | { |
| 8331 | gl::Texture3D *texture = context->getTexture3D(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8332 | 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] | 8333 | } |
| 8334 | break; |
| 8335 | |
| 8336 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8337 | { |
| 8338 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8339 | 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] | 8340 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8341 | break; |
| 8342 | |
| 8343 | default: |
| 8344 | return gl::error(GL_INVALID_ENUM); |
| 8345 | } |
| 8346 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8347 | } |
| 8348 | catch(std::bad_alloc&) |
| 8349 | { |
| 8350 | return gl::error(GL_OUT_OF_MEMORY); |
| 8351 | } |
| 8352 | } |
| 8353 | |
| 8354 | 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) |
| 8355 | { |
| 8356 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8357 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8358 | "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8359 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); |
| 8360 | |
| 8361 | try |
| 8362 | { |
| 8363 | gl::Context *context = gl::getNonLostContext(); |
| 8364 | |
| 8365 | if (context) |
| 8366 | { |
| 8367 | if (context->getClientVersion() < 3) |
| 8368 | { |
| 8369 | return gl::error(GL_INVALID_OPERATION); |
| 8370 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8371 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8372 | if (!pixels) |
| 8373 | { |
| 8374 | return gl::error(GL_INVALID_VALUE); |
| 8375 | } |
| 8376 | |
| 8377 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8378 | 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] | 8379 | xoffset, yoffset, zoffset, width, height, depth, 0, |
| 8380 | format, type)) |
| 8381 | { |
| 8382 | return; |
| 8383 | } |
| 8384 | |
| 8385 | switch(target) |
| 8386 | { |
| 8387 | case GL_TEXTURE_3D: |
| 8388 | { |
| 8389 | gl::Texture3D *texture = context->getTexture3D(); |
| 8390 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8391 | } |
| 8392 | break; |
| 8393 | |
| 8394 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8395 | { |
| 8396 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8397 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8398 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8399 | break; |
| 8400 | |
| 8401 | default: |
| 8402 | return gl::error(GL_INVALID_ENUM); |
| 8403 | } |
| 8404 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8405 | } |
| 8406 | catch(std::bad_alloc&) |
| 8407 | { |
| 8408 | return gl::error(GL_OUT_OF_MEMORY); |
| 8409 | } |
| 8410 | } |
| 8411 | |
| 8412 | void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 8413 | { |
| 8414 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8415 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 8416 | target, level, xoffset, yoffset, zoffset, x, y, width, height); |
| 8417 | |
| 8418 | try |
| 8419 | { |
| 8420 | gl::Context *context = gl::getNonLostContext(); |
| 8421 | |
| 8422 | if (context) |
| 8423 | { |
| 8424 | if (context->getClientVersion() < 3) |
| 8425 | { |
| 8426 | return gl::error(GL_INVALID_OPERATION); |
| 8427 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8428 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8429 | if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset, |
| 8430 | x, y, width, height, 0)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8431 | { |
| 8432 | return; |
| 8433 | } |
| 8434 | |
| 8435 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 8436 | gl::Texture *texture = NULL; |
| 8437 | switch (target) |
| 8438 | { |
| 8439 | case GL_TEXTURE_3D: |
| 8440 | texture = context->getTexture3D(); |
| 8441 | break; |
| 8442 | |
| 8443 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8444 | texture = context->getTexture2DArray(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8445 | break; |
| 8446 | |
| 8447 | default: |
| 8448 | return gl::error(GL_INVALID_ENUM); |
| 8449 | } |
| 8450 | |
| 8451 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer); |
| 8452 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8453 | } |
| 8454 | catch(std::bad_alloc&) |
| 8455 | { |
| 8456 | return gl::error(GL_OUT_OF_MEMORY); |
| 8457 | } |
| 8458 | } |
| 8459 | |
| 8460 | void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) |
| 8461 | { |
| 8462 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8463 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, " |
| 8464 | "const GLvoid* data = 0x%0.8p)", |
| 8465 | target, level, internalformat, width, height, depth, border, imageSize, data); |
| 8466 | |
| 8467 | try |
| 8468 | { |
| 8469 | gl::Context *context = gl::getNonLostContext(); |
| 8470 | |
| 8471 | if (context) |
| 8472 | { |
| 8473 | if (context->getClientVersion() < 3) |
| 8474 | { |
| 8475 | return gl::error(GL_INVALID_OPERATION); |
| 8476 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8477 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8478 | 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] | 8479 | { |
| 8480 | return gl::error(GL_INVALID_VALUE); |
| 8481 | } |
| 8482 | |
| 8483 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8484 | if (!validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 8485 | 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] | 8486 | { |
| 8487 | return; |
| 8488 | } |
| 8489 | |
| 8490 | switch(target) |
| 8491 | { |
| 8492 | case GL_TEXTURE_3D: |
| 8493 | { |
| 8494 | gl::Texture3D *texture = context->getTexture3D(); |
| 8495 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8496 | } |
| 8497 | break; |
| 8498 | |
| 8499 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8500 | { |
| 8501 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8502 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8503 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8504 | break; |
| 8505 | |
| 8506 | default: |
| 8507 | return gl::error(GL_INVALID_ENUM); |
| 8508 | } |
| 8509 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8510 | } |
| 8511 | catch(std::bad_alloc&) |
| 8512 | { |
| 8513 | return gl::error(GL_OUT_OF_MEMORY); |
| 8514 | } |
| 8515 | } |
| 8516 | |
| 8517 | 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) |
| 8518 | { |
| 8519 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8520 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8521 | "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 8522 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); |
| 8523 | |
| 8524 | try |
| 8525 | { |
| 8526 | gl::Context *context = gl::getNonLostContext(); |
| 8527 | |
| 8528 | if (context) |
| 8529 | { |
| 8530 | if (context->getClientVersion() < 3) |
| 8531 | { |
| 8532 | return gl::error(GL_INVALID_OPERATION); |
| 8533 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8534 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8535 | 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] | 8536 | { |
| 8537 | return gl::error(GL_INVALID_VALUE); |
| 8538 | } |
| 8539 | |
| 8540 | if (!data) |
| 8541 | { |
| 8542 | return gl::error(GL_INVALID_VALUE); |
| 8543 | } |
| 8544 | |
| 8545 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8546 | if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 8547 | 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] | 8548 | { |
| 8549 | return; |
| 8550 | } |
| 8551 | |
| 8552 | switch(target) |
| 8553 | { |
| 8554 | case GL_TEXTURE_3D: |
| 8555 | { |
| 8556 | gl::Texture3D *texture = context->getTexture3D(); |
| 8557 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8558 | format, imageSize, data); |
| 8559 | } |
| 8560 | break; |
| 8561 | |
| 8562 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8563 | { |
| 8564 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8565 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8566 | format, imageSize, data); |
| 8567 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8568 | break; |
| 8569 | |
| 8570 | default: |
| 8571 | return gl::error(GL_INVALID_ENUM); |
| 8572 | } |
| 8573 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8574 | } |
| 8575 | catch(std::bad_alloc&) |
| 8576 | { |
| 8577 | return gl::error(GL_OUT_OF_MEMORY); |
| 8578 | } |
| 8579 | } |
| 8580 | |
| 8581 | void __stdcall glGenQueries(GLsizei n, GLuint* ids) |
| 8582 | { |
| 8583 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8584 | |
| 8585 | try |
| 8586 | { |
| 8587 | gl::Context *context = gl::getNonLostContext(); |
| 8588 | |
| 8589 | if (context) |
| 8590 | { |
| 8591 | if (context->getClientVersion() < 3) |
| 8592 | { |
| 8593 | return gl::error(GL_INVALID_OPERATION); |
| 8594 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8595 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8596 | // glGenQueries |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8597 | UNIMPLEMENTED(); |
| 8598 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8599 | } |
| 8600 | catch(std::bad_alloc&) |
| 8601 | { |
| 8602 | return gl::error(GL_OUT_OF_MEMORY); |
| 8603 | } |
| 8604 | } |
| 8605 | |
| 8606 | void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids) |
| 8607 | { |
| 8608 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8609 | |
| 8610 | try |
| 8611 | { |
| 8612 | gl::Context *context = gl::getNonLostContext(); |
| 8613 | |
| 8614 | if (context) |
| 8615 | { |
| 8616 | if (context->getClientVersion() < 3) |
| 8617 | { |
| 8618 | return gl::error(GL_INVALID_OPERATION); |
| 8619 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8620 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8621 | // glDeleteQueries |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8622 | UNIMPLEMENTED(); |
| 8623 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8624 | } |
| 8625 | catch(std::bad_alloc&) |
| 8626 | { |
| 8627 | return gl::error(GL_OUT_OF_MEMORY); |
| 8628 | } |
| 8629 | } |
| 8630 | |
| 8631 | GLboolean __stdcall glIsQuery(GLuint id) |
| 8632 | { |
| 8633 | EVENT("(GLuint id = %u)", id); |
| 8634 | |
| 8635 | try |
| 8636 | { |
| 8637 | gl::Context *context = gl::getNonLostContext(); |
| 8638 | |
| 8639 | if (context) |
| 8640 | { |
| 8641 | if (context->getClientVersion() < 3) |
| 8642 | { |
| 8643 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8644 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8645 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8646 | // glIsQuery |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8647 | UNIMPLEMENTED(); |
| 8648 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8649 | } |
| 8650 | catch(std::bad_alloc&) |
| 8651 | { |
| 8652 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8653 | } |
| 8654 | |
| 8655 | return GL_FALSE; |
| 8656 | } |
| 8657 | |
| 8658 | void __stdcall glBeginQuery(GLenum target, GLuint id) |
| 8659 | { |
| 8660 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 8661 | |
| 8662 | try |
| 8663 | { |
| 8664 | gl::Context *context = gl::getNonLostContext(); |
| 8665 | |
| 8666 | if (context) |
| 8667 | { |
| 8668 | if (context->getClientVersion() < 3) |
| 8669 | { |
| 8670 | return gl::error(GL_INVALID_OPERATION); |
| 8671 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8672 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8673 | // glBeginQuery |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8674 | UNIMPLEMENTED(); |
| 8675 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8676 | } |
| 8677 | catch(std::bad_alloc&) |
| 8678 | { |
| 8679 | return gl::error(GL_OUT_OF_MEMORY); |
| 8680 | } |
| 8681 | } |
| 8682 | |
| 8683 | void __stdcall glEndQuery(GLenum target) |
| 8684 | { |
| 8685 | EVENT("(GLenum target = 0x%X)", target); |
| 8686 | |
| 8687 | try |
| 8688 | { |
| 8689 | gl::Context *context = gl::getNonLostContext(); |
| 8690 | |
| 8691 | if (context) |
| 8692 | { |
| 8693 | if (context->getClientVersion() < 3) |
| 8694 | { |
| 8695 | return gl::error(GL_INVALID_OPERATION); |
| 8696 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8697 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8698 | // glEndQuery |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8699 | UNIMPLEMENTED(); |
| 8700 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8701 | } |
| 8702 | catch(std::bad_alloc&) |
| 8703 | { |
| 8704 | return gl::error(GL_OUT_OF_MEMORY); |
| 8705 | } |
| 8706 | } |
| 8707 | |
| 8708 | void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params) |
| 8709 | { |
| 8710 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
| 8711 | |
| 8712 | try |
| 8713 | { |
| 8714 | gl::Context *context = gl::getNonLostContext(); |
| 8715 | |
| 8716 | if (context) |
| 8717 | { |
| 8718 | if (context->getClientVersion() < 3) |
| 8719 | { |
| 8720 | return gl::error(GL_INVALID_OPERATION); |
| 8721 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8722 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8723 | // glGetQueryiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8724 | UNIMPLEMENTED(); |
| 8725 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8726 | } |
| 8727 | catch(std::bad_alloc&) |
| 8728 | { |
| 8729 | return gl::error(GL_OUT_OF_MEMORY); |
| 8730 | } |
| 8731 | } |
| 8732 | |
| 8733 | void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) |
| 8734 | { |
| 8735 | EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params); |
| 8736 | |
| 8737 | try |
| 8738 | { |
| 8739 | gl::Context *context = gl::getNonLostContext(); |
| 8740 | |
| 8741 | if (context) |
| 8742 | { |
| 8743 | if (context->getClientVersion() < 3) |
| 8744 | { |
| 8745 | return gl::error(GL_INVALID_OPERATION); |
| 8746 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8747 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8748 | // glGetQueryObjectuiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8749 | UNIMPLEMENTED(); |
| 8750 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8751 | } |
| 8752 | catch(std::bad_alloc&) |
| 8753 | { |
| 8754 | return gl::error(GL_OUT_OF_MEMORY); |
| 8755 | } |
| 8756 | } |
| 8757 | |
| 8758 | GLboolean __stdcall glUnmapBuffer(GLenum target) |
| 8759 | { |
| 8760 | EVENT("(GLenum target = 0x%X)", target); |
| 8761 | |
| 8762 | try |
| 8763 | { |
| 8764 | gl::Context *context = gl::getNonLostContext(); |
| 8765 | |
| 8766 | if (context) |
| 8767 | { |
| 8768 | if (context->getClientVersion() < 3) |
| 8769 | { |
| 8770 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8771 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8772 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8773 | // glUnmapBuffer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8774 | UNIMPLEMENTED(); |
| 8775 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8776 | } |
| 8777 | catch(std::bad_alloc&) |
| 8778 | { |
| 8779 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8780 | } |
| 8781 | |
| 8782 | return GL_FALSE; |
| 8783 | } |
| 8784 | |
| 8785 | void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) |
| 8786 | { |
| 8787 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 8788 | |
| 8789 | try |
| 8790 | { |
| 8791 | gl::Context *context = gl::getNonLostContext(); |
| 8792 | |
| 8793 | if (context) |
| 8794 | { |
| 8795 | if (context->getClientVersion() < 3) |
| 8796 | { |
| 8797 | return gl::error(GL_INVALID_OPERATION); |
| 8798 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8799 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8800 | // glGetBufferPointerv |
shannonwoods@chromium.org | 2d2190a | 2013-05-30 00:17:35 +0000 | [diff] [blame] | 8801 | UNIMPLEMENTED(); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8802 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8803 | } |
| 8804 | catch(std::bad_alloc&) |
| 8805 | { |
| 8806 | return gl::error(GL_OUT_OF_MEMORY); |
| 8807 | } |
| 8808 | } |
| 8809 | |
| 8810 | void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs) |
| 8811 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8812 | try |
| 8813 | { |
| 8814 | gl::Context *context = gl::getNonLostContext(); |
| 8815 | |
| 8816 | if (context) |
| 8817 | { |
| 8818 | if (context->getClientVersion() < 3) |
| 8819 | { |
| 8820 | return gl::error(GL_INVALID_OPERATION); |
| 8821 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8822 | |
shannon.woods%transgaming.com@gtempaccount.com | 7948c5f | 2013-04-13 03:38:58 +0000 | [diff] [blame] | 8823 | glDrawBuffersEXT(n, bufs); |
| 8824 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8825 | } |
| 8826 | catch(std::bad_alloc&) |
| 8827 | { |
| 8828 | return gl::error(GL_OUT_OF_MEMORY); |
| 8829 | } |
| 8830 | } |
| 8831 | |
| 8832 | void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8833 | { |
| 8834 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8835 | location, count, transpose, value); |
| 8836 | |
| 8837 | try |
| 8838 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8839 | if (count < 0) |
| 8840 | { |
| 8841 | return gl::error(GL_INVALID_VALUE); |
| 8842 | } |
| 8843 | |
| 8844 | if (location == -1) |
| 8845 | { |
| 8846 | return; |
| 8847 | } |
| 8848 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8849 | gl::Context *context = gl::getNonLostContext(); |
| 8850 | |
| 8851 | if (context) |
| 8852 | { |
| 8853 | if (context->getClientVersion() < 3) |
| 8854 | { |
| 8855 | return gl::error(GL_INVALID_OPERATION); |
| 8856 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8857 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8858 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8859 | if (!programBinary) |
| 8860 | { |
| 8861 | return gl::error(GL_INVALID_OPERATION); |
| 8862 | } |
| 8863 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8864 | if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8865 | { |
| 8866 | return gl::error(GL_INVALID_OPERATION); |
| 8867 | } |
| 8868 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8869 | } |
| 8870 | catch(std::bad_alloc&) |
| 8871 | { |
| 8872 | return gl::error(GL_OUT_OF_MEMORY); |
| 8873 | } |
| 8874 | } |
| 8875 | |
| 8876 | void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8877 | { |
| 8878 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8879 | location, count, transpose, value); |
| 8880 | |
| 8881 | try |
| 8882 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8883 | if (count < 0) |
| 8884 | { |
| 8885 | return gl::error(GL_INVALID_VALUE); |
| 8886 | } |
| 8887 | |
| 8888 | if (location == -1) |
| 8889 | { |
| 8890 | return; |
| 8891 | } |
| 8892 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8893 | gl::Context *context = gl::getNonLostContext(); |
| 8894 | |
| 8895 | if (context) |
| 8896 | { |
| 8897 | if (context->getClientVersion() < 3) |
| 8898 | { |
| 8899 | return gl::error(GL_INVALID_OPERATION); |
| 8900 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8901 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8902 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8903 | if (!programBinary) |
| 8904 | { |
| 8905 | return gl::error(GL_INVALID_OPERATION); |
| 8906 | } |
| 8907 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8908 | if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8909 | { |
| 8910 | return gl::error(GL_INVALID_OPERATION); |
| 8911 | } |
| 8912 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8913 | } |
| 8914 | catch(std::bad_alloc&) |
| 8915 | { |
| 8916 | return gl::error(GL_OUT_OF_MEMORY); |
| 8917 | } |
| 8918 | } |
| 8919 | |
| 8920 | void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8921 | { |
| 8922 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8923 | location, count, transpose, value); |
| 8924 | |
| 8925 | try |
| 8926 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8927 | if (count < 0) |
| 8928 | { |
| 8929 | return gl::error(GL_INVALID_VALUE); |
| 8930 | } |
| 8931 | |
| 8932 | if (location == -1) |
| 8933 | { |
| 8934 | return; |
| 8935 | } |
| 8936 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8937 | gl::Context *context = gl::getNonLostContext(); |
| 8938 | |
| 8939 | if (context) |
| 8940 | { |
| 8941 | if (context->getClientVersion() < 3) |
| 8942 | { |
| 8943 | return gl::error(GL_INVALID_OPERATION); |
| 8944 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8945 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8946 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8947 | if (!programBinary) |
| 8948 | { |
| 8949 | return gl::error(GL_INVALID_OPERATION); |
| 8950 | } |
| 8951 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8952 | if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8953 | { |
| 8954 | return gl::error(GL_INVALID_OPERATION); |
| 8955 | } |
| 8956 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8957 | } |
| 8958 | catch(std::bad_alloc&) |
| 8959 | { |
| 8960 | return gl::error(GL_OUT_OF_MEMORY); |
| 8961 | } |
| 8962 | } |
| 8963 | |
| 8964 | void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8965 | { |
| 8966 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8967 | location, count, transpose, value); |
| 8968 | |
| 8969 | try |
| 8970 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8971 | if (count < 0) |
| 8972 | { |
| 8973 | return gl::error(GL_INVALID_VALUE); |
| 8974 | } |
| 8975 | |
| 8976 | if (location == -1) |
| 8977 | { |
| 8978 | return; |
| 8979 | } |
| 8980 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8981 | gl::Context *context = gl::getNonLostContext(); |
| 8982 | |
| 8983 | if (context) |
| 8984 | { |
| 8985 | if (context->getClientVersion() < 3) |
| 8986 | { |
| 8987 | return gl::error(GL_INVALID_OPERATION); |
| 8988 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8989 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8990 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8991 | if (!programBinary) |
| 8992 | { |
| 8993 | return gl::error(GL_INVALID_OPERATION); |
| 8994 | } |
| 8995 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8996 | if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8997 | { |
| 8998 | return gl::error(GL_INVALID_OPERATION); |
| 8999 | } |
| 9000 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9001 | } |
| 9002 | catch(std::bad_alloc&) |
| 9003 | { |
| 9004 | return gl::error(GL_OUT_OF_MEMORY); |
| 9005 | } |
| 9006 | } |
| 9007 | |
| 9008 | void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 9009 | { |
| 9010 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 9011 | location, count, transpose, value); |
| 9012 | |
| 9013 | try |
| 9014 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9015 | if (count < 0) |
| 9016 | { |
| 9017 | return gl::error(GL_INVALID_VALUE); |
| 9018 | } |
| 9019 | |
| 9020 | if (location == -1) |
| 9021 | { |
| 9022 | return; |
| 9023 | } |
| 9024 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9025 | gl::Context *context = gl::getNonLostContext(); |
| 9026 | |
| 9027 | if (context) |
| 9028 | { |
| 9029 | if (context->getClientVersion() < 3) |
| 9030 | { |
| 9031 | return gl::error(GL_INVALID_OPERATION); |
| 9032 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9033 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9034 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9035 | if (!programBinary) |
| 9036 | { |
| 9037 | return gl::error(GL_INVALID_OPERATION); |
| 9038 | } |
| 9039 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9040 | if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9041 | { |
| 9042 | return gl::error(GL_INVALID_OPERATION); |
| 9043 | } |
| 9044 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9045 | } |
| 9046 | catch(std::bad_alloc&) |
| 9047 | { |
| 9048 | return gl::error(GL_OUT_OF_MEMORY); |
| 9049 | } |
| 9050 | } |
| 9051 | |
| 9052 | void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 9053 | { |
| 9054 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 9055 | location, count, transpose, value); |
| 9056 | |
| 9057 | try |
| 9058 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9059 | if (count < 0) |
| 9060 | { |
| 9061 | return gl::error(GL_INVALID_VALUE); |
| 9062 | } |
| 9063 | |
| 9064 | if (location == -1) |
| 9065 | { |
| 9066 | return; |
| 9067 | } |
| 9068 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9069 | gl::Context *context = gl::getNonLostContext(); |
| 9070 | |
| 9071 | if (context) |
| 9072 | { |
| 9073 | if (context->getClientVersion() < 3) |
| 9074 | { |
| 9075 | return gl::error(GL_INVALID_OPERATION); |
| 9076 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9077 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9078 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9079 | if (!programBinary) |
| 9080 | { |
| 9081 | return gl::error(GL_INVALID_OPERATION); |
| 9082 | } |
| 9083 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9084 | if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9085 | { |
| 9086 | return gl::error(GL_INVALID_OPERATION); |
| 9087 | } |
| 9088 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9089 | } |
| 9090 | catch(std::bad_alloc&) |
| 9091 | { |
| 9092 | return gl::error(GL_OUT_OF_MEMORY); |
| 9093 | } |
| 9094 | } |
| 9095 | |
| 9096 | void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) |
| 9097 | { |
| 9098 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, " |
| 9099 | "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 9100 | srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 9101 | |
| 9102 | try |
| 9103 | { |
| 9104 | gl::Context *context = gl::getNonLostContext(); |
| 9105 | |
| 9106 | if (context) |
| 9107 | { |
| 9108 | if (context->getClientVersion() < 3) |
| 9109 | { |
| 9110 | return gl::error(GL_INVALID_OPERATION); |
| 9111 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9112 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 9113 | if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 9114 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 9115 | false)) |
| 9116 | { |
| 9117 | return; |
| 9118 | } |
| 9119 | |
| 9120 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 9121 | mask, filter); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9122 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9123 | } |
| 9124 | catch(std::bad_alloc&) |
| 9125 | { |
| 9126 | return gl::error(GL_OUT_OF_MEMORY); |
| 9127 | } |
| 9128 | } |
| 9129 | |
| 9130 | void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| 9131 | { |
| 9132 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 9133 | target, samples, internalformat, width, height); |
| 9134 | |
| 9135 | try |
| 9136 | { |
| 9137 | gl::Context *context = gl::getNonLostContext(); |
| 9138 | |
| 9139 | if (context) |
| 9140 | { |
| 9141 | if (context->getClientVersion() < 3) |
| 9142 | { |
| 9143 | return gl::error(GL_INVALID_OPERATION); |
| 9144 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9145 | |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 9146 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 9147 | width, height, false)) |
| 9148 | { |
| 9149 | return; |
| 9150 | } |
| 9151 | |
| 9152 | context->setRenderbufferStorage(width, height, internalformat, samples); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9153 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9154 | } |
| 9155 | catch(std::bad_alloc&) |
| 9156 | { |
| 9157 | return gl::error(GL_OUT_OF_MEMORY); |
| 9158 | } |
| 9159 | } |
| 9160 | |
| 9161 | void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) |
| 9162 | { |
| 9163 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)", |
| 9164 | target, attachment, texture, level, layer); |
| 9165 | |
| 9166 | try |
| 9167 | { |
| 9168 | gl::Context *context = gl::getNonLostContext(); |
| 9169 | |
| 9170 | if (context) |
| 9171 | { |
| 9172 | if (context->getClientVersion() < 3) |
| 9173 | { |
| 9174 | return gl::error(GL_INVALID_OPERATION); |
| 9175 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9176 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9177 | // glFramebufferTextureLayer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9178 | UNIMPLEMENTED(); |
| 9179 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9180 | } |
| 9181 | catch(std::bad_alloc&) |
| 9182 | { |
| 9183 | return gl::error(GL_OUT_OF_MEMORY); |
| 9184 | } |
| 9185 | } |
| 9186 | |
| 9187 | GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 9188 | { |
| 9189 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 9190 | target, offset, length, access); |
| 9191 | |
| 9192 | try |
| 9193 | { |
| 9194 | gl::Context *context = gl::getNonLostContext(); |
| 9195 | |
| 9196 | if (context) |
| 9197 | { |
| 9198 | if (context->getClientVersion() < 3) |
| 9199 | { |
| 9200 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 9201 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9202 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9203 | // glMapBufferRange |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9204 | UNIMPLEMENTED(); |
| 9205 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9206 | } |
| 9207 | catch(std::bad_alloc&) |
| 9208 | { |
| 9209 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL)); |
| 9210 | } |
| 9211 | |
| 9212 | return NULL; |
| 9213 | } |
| 9214 | |
| 9215 | void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) |
| 9216 | { |
| 9217 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 9218 | |
| 9219 | try |
| 9220 | { |
| 9221 | gl::Context *context = gl::getNonLostContext(); |
| 9222 | |
| 9223 | if (context) |
| 9224 | { |
| 9225 | if (context->getClientVersion() < 3) |
| 9226 | { |
| 9227 | return gl::error(GL_INVALID_OPERATION); |
| 9228 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9229 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9230 | // glFlushMappedBufferRange |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9231 | UNIMPLEMENTED(); |
| 9232 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9233 | } |
| 9234 | catch(std::bad_alloc&) |
| 9235 | { |
| 9236 | return gl::error(GL_OUT_OF_MEMORY); |
| 9237 | } |
| 9238 | } |
| 9239 | |
| 9240 | void __stdcall glBindVertexArray(GLuint array) |
| 9241 | { |
| 9242 | EVENT("(GLuint array = %u)", array); |
| 9243 | |
| 9244 | try |
| 9245 | { |
| 9246 | gl::Context *context = gl::getNonLostContext(); |
| 9247 | |
| 9248 | if (context) |
| 9249 | { |
| 9250 | if (context->getClientVersion() < 3) |
| 9251 | { |
| 9252 | return gl::error(GL_INVALID_OPERATION); |
| 9253 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9254 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9255 | gl::VertexArray *vao = context->getVertexArray(array); |
| 9256 | |
| 9257 | if (!vao) |
| 9258 | { |
| 9259 | // The default VAO should always exist |
| 9260 | ASSERT(array != 0); |
| 9261 | return gl::error(GL_INVALID_OPERATION); |
| 9262 | } |
| 9263 | |
| 9264 | context->bindVertexArray(array); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9265 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9266 | } |
| 9267 | catch(std::bad_alloc&) |
| 9268 | { |
| 9269 | return gl::error(GL_OUT_OF_MEMORY); |
| 9270 | } |
| 9271 | } |
| 9272 | |
| 9273 | void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) |
| 9274 | { |
| 9275 | EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays); |
| 9276 | |
| 9277 | try |
| 9278 | { |
| 9279 | gl::Context *context = gl::getNonLostContext(); |
| 9280 | |
| 9281 | if (context) |
| 9282 | { |
| 9283 | if (context->getClientVersion() < 3) |
| 9284 | { |
| 9285 | return gl::error(GL_INVALID_OPERATION); |
| 9286 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9287 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9288 | if (n < 0) |
| 9289 | { |
| 9290 | return gl::error(GL_INVALID_VALUE); |
| 9291 | } |
| 9292 | |
| 9293 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 9294 | { |
| 9295 | if (arrays[arrayIndex] != 0) |
| 9296 | { |
| 9297 | context->deleteVertexArray(arrays[arrayIndex]); |
| 9298 | } |
| 9299 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9300 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9301 | } |
| 9302 | catch(std::bad_alloc&) |
| 9303 | { |
| 9304 | return gl::error(GL_OUT_OF_MEMORY); |
| 9305 | } |
| 9306 | } |
| 9307 | |
| 9308 | void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) |
| 9309 | { |
| 9310 | EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays); |
| 9311 | |
| 9312 | try |
| 9313 | { |
| 9314 | gl::Context *context = gl::getNonLostContext(); |
| 9315 | |
| 9316 | if (context) |
| 9317 | { |
| 9318 | if (context->getClientVersion() < 3) |
| 9319 | { |
| 9320 | return gl::error(GL_INVALID_OPERATION); |
| 9321 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9322 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9323 | if (n < 0) |
| 9324 | { |
| 9325 | return gl::error(GL_INVALID_VALUE); |
| 9326 | } |
| 9327 | |
| 9328 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 9329 | { |
| 9330 | arrays[arrayIndex] = context->createVertexArray(); |
| 9331 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9332 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9333 | } |
| 9334 | catch(std::bad_alloc&) |
| 9335 | { |
| 9336 | return gl::error(GL_OUT_OF_MEMORY); |
| 9337 | } |
| 9338 | } |
| 9339 | |
| 9340 | GLboolean __stdcall glIsVertexArray(GLuint array) |
| 9341 | { |
| 9342 | EVENT("(GLuint array = %u)", array); |
| 9343 | |
| 9344 | try |
| 9345 | { |
| 9346 | gl::Context *context = gl::getNonLostContext(); |
| 9347 | |
| 9348 | if (context) |
| 9349 | { |
| 9350 | if (context->getClientVersion() < 3) |
| 9351 | { |
| 9352 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 9353 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9354 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9355 | if (array == 0) |
| 9356 | { |
| 9357 | return GL_FALSE; |
| 9358 | } |
| 9359 | |
| 9360 | gl::VertexArray *vao = context->getVertexArray(array); |
| 9361 | |
| 9362 | return (vao != NULL ? GL_TRUE : GL_FALSE); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9363 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9364 | } |
| 9365 | catch(std::bad_alloc&) |
| 9366 | { |
| 9367 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 9368 | } |
| 9369 | |
| 9370 | return GL_FALSE; |
| 9371 | } |
| 9372 | |
| 9373 | void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data) |
| 9374 | { |
| 9375 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)", |
| 9376 | target, index, data); |
| 9377 | |
| 9378 | try |
| 9379 | { |
| 9380 | gl::Context *context = gl::getNonLostContext(); |
| 9381 | |
| 9382 | if (context) |
| 9383 | { |
| 9384 | if (context->getClientVersion() < 3) |
| 9385 | { |
| 9386 | return gl::error(GL_INVALID_OPERATION); |
| 9387 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9388 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9389 | // glGetIntegeri_v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9390 | UNIMPLEMENTED(); |
| 9391 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9392 | } |
| 9393 | catch(std::bad_alloc&) |
| 9394 | { |
| 9395 | return gl::error(GL_OUT_OF_MEMORY); |
| 9396 | } |
| 9397 | } |
| 9398 | |
| 9399 | void __stdcall glBeginTransformFeedback(GLenum primitiveMode) |
| 9400 | { |
| 9401 | EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode); |
| 9402 | |
| 9403 | try |
| 9404 | { |
| 9405 | gl::Context *context = gl::getNonLostContext(); |
| 9406 | |
| 9407 | if (context) |
| 9408 | { |
| 9409 | if (context->getClientVersion() < 3) |
| 9410 | { |
| 9411 | return gl::error(GL_INVALID_OPERATION); |
| 9412 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9413 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9414 | // glBeginTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9415 | UNIMPLEMENTED(); |
| 9416 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9417 | } |
| 9418 | catch(std::bad_alloc&) |
| 9419 | { |
| 9420 | return gl::error(GL_OUT_OF_MEMORY); |
| 9421 | } |
| 9422 | } |
| 9423 | |
| 9424 | void __stdcall glEndTransformFeedback(void) |
| 9425 | { |
| 9426 | EVENT("(void)"); |
| 9427 | |
| 9428 | try |
| 9429 | { |
| 9430 | gl::Context *context = gl::getNonLostContext(); |
| 9431 | |
| 9432 | if (context) |
| 9433 | { |
| 9434 | if (context->getClientVersion() < 3) |
| 9435 | { |
| 9436 | return gl::error(GL_INVALID_OPERATION); |
| 9437 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9438 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9439 | // glEndTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9440 | UNIMPLEMENTED(); |
| 9441 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9442 | } |
| 9443 | catch(std::bad_alloc&) |
| 9444 | { |
| 9445 | return gl::error(GL_OUT_OF_MEMORY); |
| 9446 | } |
| 9447 | } |
| 9448 | |
| 9449 | void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
| 9450 | { |
| 9451 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)", |
| 9452 | target, index, buffer, offset, size); |
| 9453 | |
| 9454 | try |
| 9455 | { |
| 9456 | gl::Context *context = gl::getNonLostContext(); |
| 9457 | |
| 9458 | if (context) |
| 9459 | { |
| 9460 | if (context->getClientVersion() < 3) |
| 9461 | { |
| 9462 | return gl::error(GL_INVALID_OPERATION); |
| 9463 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9464 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9465 | switch (target) |
| 9466 | { |
| 9467 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9468 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9469 | { |
| 9470 | return gl::error(GL_INVALID_VALUE); |
| 9471 | } |
| 9472 | break; |
| 9473 | |
| 9474 | case GL_UNIFORM_BUFFER: |
| 9475 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 9476 | { |
| 9477 | return gl::error(GL_INVALID_VALUE); |
| 9478 | } |
| 9479 | break; |
| 9480 | |
| 9481 | default: |
| 9482 | return gl::error(GL_INVALID_ENUM); |
| 9483 | } |
| 9484 | |
shannonwoods@chromium.org | e6e0079 | 2013-05-30 00:06:07 +0000 | [diff] [blame] | 9485 | if (buffer != 0 && size <= 0) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9486 | { |
| 9487 | return gl::error(GL_INVALID_VALUE); |
| 9488 | } |
| 9489 | |
| 9490 | switch (target) |
| 9491 | { |
| 9492 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | a26aeaf | 2013-05-30 00:06:13 +0000 | [diff] [blame] | 9493 | |
| 9494 | // size and offset must be a multiple of 4 |
| 9495 | if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) |
| 9496 | { |
| 9497 | return gl::error(GL_INVALID_VALUE); |
| 9498 | } |
| 9499 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9500 | context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 9501 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9502 | break; |
| 9503 | |
| 9504 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 97c3d50 | 2013-05-30 00:04:34 +0000 | [diff] [blame] | 9505 | |
| 9506 | // it is an error to bind an offset not a multiple of the alignment |
| 9507 | if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0) |
| 9508 | { |
| 9509 | return gl::error(GL_INVALID_VALUE); |
| 9510 | } |
| 9511 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9512 | context->bindIndexedUniformBuffer(buffer, index, offset, size); |
| 9513 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9514 | break; |
| 9515 | |
| 9516 | default: |
| 9517 | UNREACHABLE(); |
| 9518 | } |
| 9519 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9520 | } |
| 9521 | catch(std::bad_alloc&) |
| 9522 | { |
| 9523 | return gl::error(GL_OUT_OF_MEMORY); |
| 9524 | } |
| 9525 | } |
| 9526 | |
| 9527 | void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 9528 | { |
| 9529 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)", |
| 9530 | target, index, buffer); |
| 9531 | |
| 9532 | try |
| 9533 | { |
| 9534 | gl::Context *context = gl::getNonLostContext(); |
| 9535 | |
| 9536 | if (context) |
| 9537 | { |
| 9538 | if (context->getClientVersion() < 3) |
| 9539 | { |
| 9540 | return gl::error(GL_INVALID_OPERATION); |
| 9541 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9542 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9543 | switch (target) |
| 9544 | { |
| 9545 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9546 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9547 | { |
| 9548 | return gl::error(GL_INVALID_VALUE); |
| 9549 | } |
| 9550 | break; |
| 9551 | |
| 9552 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9553 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9554 | { |
| 9555 | return gl::error(GL_INVALID_VALUE); |
| 9556 | } |
| 9557 | break; |
| 9558 | |
| 9559 | default: |
| 9560 | return gl::error(GL_INVALID_ENUM); |
| 9561 | } |
| 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 | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9566 | context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9567 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9568 | break; |
| 9569 | |
| 9570 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9571 | context->bindIndexedUniformBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9572 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9573 | break; |
| 9574 | |
| 9575 | default: |
| 9576 | UNREACHABLE(); |
| 9577 | } |
| 9578 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9579 | } |
| 9580 | catch(std::bad_alloc&) |
| 9581 | { |
| 9582 | return gl::error(GL_OUT_OF_MEMORY); |
| 9583 | } |
| 9584 | } |
| 9585 | |
| 9586 | void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
| 9587 | { |
| 9588 | EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)", |
| 9589 | program, count, varyings, bufferMode); |
| 9590 | |
| 9591 | try |
| 9592 | { |
| 9593 | gl::Context *context = gl::getNonLostContext(); |
| 9594 | |
| 9595 | if (context) |
| 9596 | { |
| 9597 | if (context->getClientVersion() < 3) |
| 9598 | { |
| 9599 | return gl::error(GL_INVALID_OPERATION); |
| 9600 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9601 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9602 | // glTransformFeedbackVaryings |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9603 | UNIMPLEMENTED(); |
| 9604 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9605 | } |
| 9606 | catch(std::bad_alloc&) |
| 9607 | { |
| 9608 | return gl::error(GL_OUT_OF_MEMORY); |
| 9609 | } |
| 9610 | } |
| 9611 | |
| 9612 | void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
| 9613 | { |
| 9614 | EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, " |
| 9615 | "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
| 9616 | program, index, bufSize, length, size, type, name); |
| 9617 | |
| 9618 | try |
| 9619 | { |
| 9620 | gl::Context *context = gl::getNonLostContext(); |
| 9621 | |
| 9622 | if (context) |
| 9623 | { |
| 9624 | if (context->getClientVersion() < 3) |
| 9625 | { |
| 9626 | return gl::error(GL_INVALID_OPERATION); |
| 9627 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9628 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9629 | // glGetTransformFeedbackVarying |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9630 | UNIMPLEMENTED(); |
| 9631 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9632 | } |
| 9633 | catch(std::bad_alloc&) |
| 9634 | { |
| 9635 | return gl::error(GL_OUT_OF_MEMORY); |
| 9636 | } |
| 9637 | } |
| 9638 | |
| 9639 | void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) |
| 9640 | { |
| 9641 | EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)", |
| 9642 | index, size, type, stride, pointer); |
| 9643 | |
| 9644 | try |
| 9645 | { |
| 9646 | gl::Context *context = gl::getNonLostContext(); |
| 9647 | |
| 9648 | if (context) |
| 9649 | { |
| 9650 | if (context->getClientVersion() < 3) |
| 9651 | { |
| 9652 | return gl::error(GL_INVALID_OPERATION); |
| 9653 | } |
| 9654 | } |
| 9655 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9656 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9657 | { |
| 9658 | return gl::error(GL_INVALID_VALUE); |
| 9659 | } |
| 9660 | |
| 9661 | if (size < 1 || size > 4) |
| 9662 | { |
| 9663 | return gl::error(GL_INVALID_VALUE); |
| 9664 | } |
| 9665 | |
| 9666 | switch (type) |
| 9667 | { |
| 9668 | case GL_BYTE: |
| 9669 | case GL_UNSIGNED_BYTE: |
| 9670 | case GL_SHORT: |
| 9671 | case GL_UNSIGNED_SHORT: |
| 9672 | case GL_INT: |
| 9673 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9674 | case GL_INT_2_10_10_10_REV: |
| 9675 | 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] | 9676 | break; |
| 9677 | default: |
| 9678 | return gl::error(GL_INVALID_ENUM); |
| 9679 | } |
| 9680 | |
| 9681 | if (stride < 0) |
| 9682 | { |
| 9683 | return gl::error(GL_INVALID_VALUE); |
| 9684 | } |
| 9685 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9686 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 9687 | { |
| 9688 | return gl::error(GL_INVALID_OPERATION); |
| 9689 | } |
| 9690 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9691 | if (context) |
| 9692 | { |
Jamie Madill | d8db866 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9693 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 9694 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 9695 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 9696 | // and the pointer argument is not NULL. |
| 9697 | if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && pointer != NULL) |
| 9698 | { |
| 9699 | return gl::error(GL_INVALID_OPERATION); |
| 9700 | } |
| 9701 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9702 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true, |
| 9703 | stride, pointer); |
| 9704 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9705 | } |
| 9706 | catch(std::bad_alloc&) |
| 9707 | { |
| 9708 | return gl::error(GL_OUT_OF_MEMORY); |
| 9709 | } |
| 9710 | } |
| 9711 | |
| 9712 | void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) |
| 9713 | { |
| 9714 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 9715 | index, pname, params); |
| 9716 | |
| 9717 | try |
| 9718 | { |
| 9719 | gl::Context *context = gl::getNonLostContext(); |
| 9720 | |
| 9721 | if (context) |
| 9722 | { |
| 9723 | if (context->getClientVersion() < 3) |
| 9724 | { |
| 9725 | return gl::error(GL_INVALID_OPERATION); |
| 9726 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9727 | |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 9728 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9729 | { |
| 9730 | return gl::error(GL_INVALID_VALUE); |
| 9731 | } |
| 9732 | |
| 9733 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
| 9734 | |
| 9735 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
| 9736 | { |
| 9737 | return; |
| 9738 | } |
| 9739 | |
| 9740 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 9741 | { |
| 9742 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 9743 | for (int i = 0; i < 4; ++i) |
| 9744 | { |
| 9745 | params[i] = currentValueData.IntValues[i]; |
| 9746 | } |
| 9747 | } |
| 9748 | else |
| 9749 | { |
| 9750 | *params = attribState.querySingleParameter<GLint>(pname); |
| 9751 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9752 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9753 | } |
| 9754 | catch(std::bad_alloc&) |
| 9755 | { |
| 9756 | return gl::error(GL_OUT_OF_MEMORY); |
| 9757 | } |
| 9758 | } |
| 9759 | |
| 9760 | void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) |
| 9761 | { |
| 9762 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)", |
| 9763 | index, pname, params); |
| 9764 | |
| 9765 | try |
| 9766 | { |
| 9767 | gl::Context *context = gl::getNonLostContext(); |
| 9768 | |
| 9769 | if (context) |
| 9770 | { |
| 9771 | if (context->getClientVersion() < 3) |
| 9772 | { |
| 9773 | return gl::error(GL_INVALID_OPERATION); |
| 9774 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9775 | |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 9776 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9777 | { |
| 9778 | return gl::error(GL_INVALID_VALUE); |
| 9779 | } |
| 9780 | |
| 9781 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
| 9782 | |
| 9783 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
| 9784 | { |
| 9785 | return; |
| 9786 | } |
| 9787 | |
| 9788 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 9789 | { |
| 9790 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 9791 | for (int i = 0; i < 4; ++i) |
| 9792 | { |
| 9793 | params[i] = currentValueData.UnsignedIntValues[i]; |
| 9794 | } |
| 9795 | } |
| 9796 | else |
| 9797 | { |
| 9798 | *params = attribState.querySingleParameter<GLuint>(pname); |
| 9799 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9800 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9801 | } |
| 9802 | catch(std::bad_alloc&) |
| 9803 | { |
| 9804 | return gl::error(GL_OUT_OF_MEMORY); |
| 9805 | } |
| 9806 | } |
| 9807 | |
| 9808 | void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 9809 | { |
| 9810 | EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)", |
| 9811 | index, x, y, z, w); |
| 9812 | |
| 9813 | try |
| 9814 | { |
| 9815 | gl::Context *context = gl::getNonLostContext(); |
| 9816 | |
| 9817 | if (context) |
| 9818 | { |
| 9819 | if (context->getClientVersion() < 3) |
| 9820 | { |
| 9821 | return gl::error(GL_INVALID_OPERATION); |
| 9822 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9823 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9824 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9825 | { |
| 9826 | return gl::error(GL_INVALID_VALUE); |
| 9827 | } |
| 9828 | |
| 9829 | GLint vals[4] = { x, y, z, w }; |
| 9830 | context->setVertexAttribi(index, vals); |
| 9831 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9832 | } |
| 9833 | catch(std::bad_alloc&) |
| 9834 | { |
| 9835 | return gl::error(GL_OUT_OF_MEMORY); |
| 9836 | } |
| 9837 | } |
| 9838 | |
| 9839 | void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 9840 | { |
| 9841 | EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)", |
| 9842 | index, x, y, z, w); |
| 9843 | |
| 9844 | try |
| 9845 | { |
| 9846 | gl::Context *context = gl::getNonLostContext(); |
| 9847 | |
| 9848 | if (context) |
| 9849 | { |
| 9850 | if (context->getClientVersion() < 3) |
| 9851 | { |
| 9852 | return gl::error(GL_INVALID_OPERATION); |
| 9853 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9854 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9855 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9856 | { |
| 9857 | return gl::error(GL_INVALID_VALUE); |
| 9858 | } |
| 9859 | |
| 9860 | GLuint vals[4] = { x, y, z, w }; |
| 9861 | context->setVertexAttribu(index, vals); |
| 9862 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9863 | } |
| 9864 | catch(std::bad_alloc&) |
| 9865 | { |
| 9866 | return gl::error(GL_OUT_OF_MEMORY); |
| 9867 | } |
| 9868 | } |
| 9869 | |
| 9870 | void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) |
| 9871 | { |
| 9872 | EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v); |
| 9873 | |
| 9874 | try |
| 9875 | { |
| 9876 | gl::Context *context = gl::getNonLostContext(); |
| 9877 | |
| 9878 | if (context) |
| 9879 | { |
| 9880 | if (context->getClientVersion() < 3) |
| 9881 | { |
| 9882 | return gl::error(GL_INVALID_OPERATION); |
| 9883 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9884 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9885 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9886 | { |
| 9887 | return gl::error(GL_INVALID_VALUE); |
| 9888 | } |
| 9889 | |
| 9890 | context->setVertexAttribi(index, v); |
| 9891 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9892 | } |
| 9893 | catch(std::bad_alloc&) |
| 9894 | { |
| 9895 | return gl::error(GL_OUT_OF_MEMORY); |
| 9896 | } |
| 9897 | } |
| 9898 | |
| 9899 | void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v) |
| 9900 | { |
| 9901 | EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v); |
| 9902 | |
| 9903 | try |
| 9904 | { |
| 9905 | gl::Context *context = gl::getNonLostContext(); |
| 9906 | |
| 9907 | if (context) |
| 9908 | { |
| 9909 | if (context->getClientVersion() < 3) |
| 9910 | { |
| 9911 | return gl::error(GL_INVALID_OPERATION); |
| 9912 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9913 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9914 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9915 | { |
| 9916 | return gl::error(GL_INVALID_VALUE); |
| 9917 | } |
| 9918 | |
| 9919 | context->setVertexAttribu(index, v); |
| 9920 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9921 | } |
| 9922 | catch(std::bad_alloc&) |
| 9923 | { |
| 9924 | return gl::error(GL_OUT_OF_MEMORY); |
| 9925 | } |
| 9926 | } |
| 9927 | |
| 9928 | void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) |
| 9929 | { |
| 9930 | EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)", |
| 9931 | program, location, params); |
| 9932 | |
| 9933 | try |
| 9934 | { |
| 9935 | gl::Context *context = gl::getNonLostContext(); |
| 9936 | |
| 9937 | if (context) |
| 9938 | { |
| 9939 | if (context->getClientVersion() < 3) |
| 9940 | { |
| 9941 | return gl::error(GL_INVALID_OPERATION); |
| 9942 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9943 | |
shannon.woods%transgaming.com@gtempaccount.com | e229012 | 2013-04-13 03:41:07 +0000 | [diff] [blame] | 9944 | if (program == 0) |
| 9945 | { |
| 9946 | return gl::error(GL_INVALID_VALUE); |
| 9947 | } |
| 9948 | |
| 9949 | gl::Program *programObject = context->getProgram(program); |
| 9950 | |
| 9951 | if (!programObject || !programObject->isLinked()) |
| 9952 | { |
| 9953 | return gl::error(GL_INVALID_OPERATION); |
| 9954 | } |
| 9955 | |
| 9956 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9957 | if (!programBinary) |
| 9958 | { |
| 9959 | return gl::error(GL_INVALID_OPERATION); |
| 9960 | } |
| 9961 | |
| 9962 | if (!programBinary->getUniformuiv(location, NULL, params)) |
| 9963 | { |
| 9964 | return gl::error(GL_INVALID_OPERATION); |
| 9965 | } |
| 9966 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9967 | } |
| 9968 | catch(std::bad_alloc&) |
| 9969 | { |
| 9970 | return gl::error(GL_OUT_OF_MEMORY); |
| 9971 | } |
| 9972 | } |
| 9973 | |
| 9974 | GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) |
| 9975 | { |
| 9976 | EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)", |
| 9977 | program, name); |
| 9978 | |
| 9979 | try |
| 9980 | { |
| 9981 | gl::Context *context = gl::getNonLostContext(); |
| 9982 | |
| 9983 | if (context) |
| 9984 | { |
| 9985 | if (context->getClientVersion() < 3) |
| 9986 | { |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame] | 9987 | return gl::error(GL_INVALID_OPERATION, -1); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9988 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9989 | |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame] | 9990 | if (program == 0) |
| 9991 | { |
| 9992 | return gl::error(GL_INVALID_VALUE, -1); |
| 9993 | } |
| 9994 | |
| 9995 | gl::Program *programObject = context->getProgram(program); |
| 9996 | |
| 9997 | if (!programObject || !programObject->isLinked()) |
| 9998 | { |
| 9999 | return gl::error(GL_INVALID_OPERATION, -1); |
| 10000 | } |
| 10001 | |
| 10002 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10003 | if (!programBinary) |
| 10004 | { |
| 10005 | return gl::error(GL_INVALID_OPERATION, -1); |
| 10006 | } |
| 10007 | |
| 10008 | return programBinary->getFragDataLocation(name); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10009 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10010 | } |
| 10011 | catch(std::bad_alloc&) |
| 10012 | { |
| 10013 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10014 | } |
| 10015 | |
| 10016 | return 0; |
| 10017 | } |
| 10018 | |
| 10019 | void __stdcall glUniform1ui(GLint location, GLuint v0) |
| 10020 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10021 | glUniform1uiv(location, 1, &v0); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10022 | } |
| 10023 | |
| 10024 | void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1) |
| 10025 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10026 | const GLuint xy[] = { v0, v1 }; |
| 10027 | glUniform2uiv(location, 1, xy); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10028 | } |
| 10029 | |
| 10030 | void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 10031 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10032 | const GLuint xyz[] = { v0, v1, v2 }; |
| 10033 | glUniform3uiv(location, 1, xyz); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10034 | } |
| 10035 | |
| 10036 | void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 10037 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10038 | const GLuint xyzw[] = { v0, v1, v2, v3 }; |
| 10039 | glUniform4uiv(location, 1, xyzw); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10040 | } |
| 10041 | |
| 10042 | void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) |
| 10043 | { |
| 10044 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 10045 | location, count, value); |
| 10046 | |
| 10047 | try |
| 10048 | { |
| 10049 | gl::Context *context = gl::getNonLostContext(); |
| 10050 | |
| 10051 | if (context) |
| 10052 | { |
| 10053 | if (context->getClientVersion() < 3) |
| 10054 | { |
| 10055 | return gl::error(GL_INVALID_OPERATION); |
| 10056 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10057 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10058 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10059 | if (!programBinary) |
| 10060 | { |
| 10061 | return gl::error(GL_INVALID_OPERATION); |
| 10062 | } |
| 10063 | |
| 10064 | if (!programBinary->setUniform1uiv(location, count, value)) |
| 10065 | { |
| 10066 | return gl::error(GL_INVALID_OPERATION); |
| 10067 | } |
| 10068 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10069 | } |
| 10070 | catch(std::bad_alloc&) |
| 10071 | { |
| 10072 | return gl::error(GL_OUT_OF_MEMORY); |
| 10073 | } |
| 10074 | } |
| 10075 | |
| 10076 | void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) |
| 10077 | { |
| 10078 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 10079 | location, count, value); |
| 10080 | |
| 10081 | try |
| 10082 | { |
| 10083 | gl::Context *context = gl::getNonLostContext(); |
| 10084 | |
| 10085 | if (context) |
| 10086 | { |
| 10087 | if (context->getClientVersion() < 3) |
| 10088 | { |
| 10089 | return gl::error(GL_INVALID_OPERATION); |
| 10090 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10091 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10092 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10093 | if (!programBinary) |
| 10094 | { |
| 10095 | return gl::error(GL_INVALID_OPERATION); |
| 10096 | } |
| 10097 | |
| 10098 | if (!programBinary->setUniform2uiv(location, count, value)) |
| 10099 | { |
| 10100 | return gl::error(GL_INVALID_OPERATION); |
| 10101 | } |
| 10102 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10103 | } |
| 10104 | catch(std::bad_alloc&) |
| 10105 | { |
| 10106 | return gl::error(GL_OUT_OF_MEMORY); |
| 10107 | } |
| 10108 | } |
| 10109 | |
| 10110 | void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) |
| 10111 | { |
| 10112 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)", |
| 10113 | location, count, value); |
| 10114 | |
| 10115 | try |
| 10116 | { |
| 10117 | gl::Context *context = gl::getNonLostContext(); |
| 10118 | |
| 10119 | if (context) |
| 10120 | { |
| 10121 | if (context->getClientVersion() < 3) |
| 10122 | { |
| 10123 | return gl::error(GL_INVALID_OPERATION); |
| 10124 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10125 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10126 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10127 | if (!programBinary) |
| 10128 | { |
| 10129 | return gl::error(GL_INVALID_OPERATION); |
| 10130 | } |
| 10131 | |
| 10132 | if (!programBinary->setUniform3uiv(location, count, value)) |
| 10133 | { |
| 10134 | return gl::error(GL_INVALID_OPERATION); |
| 10135 | } |
| 10136 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10137 | } |
| 10138 | catch(std::bad_alloc&) |
| 10139 | { |
| 10140 | return gl::error(GL_OUT_OF_MEMORY); |
| 10141 | } |
| 10142 | } |
| 10143 | |
| 10144 | void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) |
| 10145 | { |
| 10146 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 10147 | location, count, value); |
| 10148 | |
| 10149 | try |
| 10150 | { |
| 10151 | gl::Context *context = gl::getNonLostContext(); |
| 10152 | |
| 10153 | if (context) |
| 10154 | { |
| 10155 | if (context->getClientVersion() < 3) |
| 10156 | { |
| 10157 | return gl::error(GL_INVALID_OPERATION); |
| 10158 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10159 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10160 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10161 | if (!programBinary) |
| 10162 | { |
| 10163 | return gl::error(GL_INVALID_OPERATION); |
| 10164 | } |
| 10165 | |
| 10166 | if (!programBinary->setUniform4uiv(location, count, value)) |
| 10167 | { |
| 10168 | return gl::error(GL_INVALID_OPERATION); |
| 10169 | } |
| 10170 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10171 | } |
| 10172 | catch(std::bad_alloc&) |
| 10173 | { |
| 10174 | return gl::error(GL_OUT_OF_MEMORY); |
| 10175 | } |
| 10176 | } |
| 10177 | |
| 10178 | void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) |
| 10179 | { |
| 10180 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)", |
| 10181 | buffer, drawbuffer, value); |
| 10182 | |
| 10183 | try |
| 10184 | { |
| 10185 | gl::Context *context = gl::getNonLostContext(); |
| 10186 | |
| 10187 | if (context) |
| 10188 | { |
| 10189 | if (context->getClientVersion() < 3) |
| 10190 | { |
| 10191 | return gl::error(GL_INVALID_OPERATION); |
| 10192 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10193 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10194 | // glClearBufferiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10195 | UNIMPLEMENTED(); |
| 10196 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10197 | } |
| 10198 | catch(std::bad_alloc&) |
| 10199 | { |
| 10200 | return gl::error(GL_OUT_OF_MEMORY); |
| 10201 | } |
| 10202 | } |
| 10203 | |
| 10204 | void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) |
| 10205 | { |
| 10206 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)", |
| 10207 | buffer, drawbuffer, value); |
| 10208 | |
| 10209 | try |
| 10210 | { |
| 10211 | gl::Context *context = gl::getNonLostContext(); |
| 10212 | |
| 10213 | if (context) |
| 10214 | { |
| 10215 | if (context->getClientVersion() < 3) |
| 10216 | { |
| 10217 | return gl::error(GL_INVALID_OPERATION); |
| 10218 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10219 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10220 | // glClearBufferuiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10221 | UNIMPLEMENTED(); |
| 10222 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10223 | } |
| 10224 | catch(std::bad_alloc&) |
| 10225 | { |
| 10226 | return gl::error(GL_OUT_OF_MEMORY); |
| 10227 | } |
| 10228 | } |
| 10229 | |
| 10230 | void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) |
| 10231 | { |
| 10232 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)", |
| 10233 | buffer, drawbuffer, value); |
| 10234 | |
| 10235 | try |
| 10236 | { |
| 10237 | gl::Context *context = gl::getNonLostContext(); |
| 10238 | |
| 10239 | if (context) |
| 10240 | { |
| 10241 | if (context->getClientVersion() < 3) |
| 10242 | { |
| 10243 | return gl::error(GL_INVALID_OPERATION); |
| 10244 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10245 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10246 | // glClearBufferfv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10247 | UNIMPLEMENTED(); |
| 10248 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10249 | } |
| 10250 | catch(std::bad_alloc&) |
| 10251 | { |
| 10252 | return gl::error(GL_OUT_OF_MEMORY); |
| 10253 | } |
| 10254 | } |
| 10255 | |
| 10256 | void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 10257 | { |
| 10258 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)", |
| 10259 | buffer, drawbuffer, depth, stencil); |
| 10260 | |
| 10261 | try |
| 10262 | { |
| 10263 | gl::Context *context = gl::getNonLostContext(); |
| 10264 | |
| 10265 | if (context) |
| 10266 | { |
| 10267 | if (context->getClientVersion() < 3) |
| 10268 | { |
| 10269 | return gl::error(GL_INVALID_OPERATION); |
| 10270 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10271 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10272 | // glClearBufferfi |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10273 | UNIMPLEMENTED(); |
| 10274 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10275 | } |
| 10276 | catch(std::bad_alloc&) |
| 10277 | { |
| 10278 | return gl::error(GL_OUT_OF_MEMORY); |
| 10279 | } |
| 10280 | } |
| 10281 | |
| 10282 | const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) |
| 10283 | { |
| 10284 | EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index); |
| 10285 | |
| 10286 | try |
| 10287 | { |
| 10288 | gl::Context *context = gl::getNonLostContext(); |
| 10289 | |
| 10290 | if (context) |
| 10291 | { |
| 10292 | if (context->getClientVersion() < 3) |
| 10293 | { |
| 10294 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL)); |
| 10295 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10296 | |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 10297 | if (name != GL_EXTENSIONS) |
| 10298 | { |
| 10299 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL)); |
| 10300 | } |
| 10301 | |
| 10302 | if (index >= context->getNumExtensions()) |
| 10303 | { |
| 10304 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL)); |
| 10305 | } |
| 10306 | |
| 10307 | return reinterpret_cast<const GLubyte*>(context->getExtensionString(index)); |
| 10308 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10309 | } |
| 10310 | catch(std::bad_alloc&) |
| 10311 | { |
| 10312 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL)); |
| 10313 | } |
| 10314 | |
| 10315 | return NULL; |
| 10316 | } |
| 10317 | |
| 10318 | void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 10319 | { |
| 10320 | EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)", |
| 10321 | readTarget, writeTarget, readOffset, writeOffset, size); |
| 10322 | |
| 10323 | try |
| 10324 | { |
| 10325 | gl::Context *context = gl::getNonLostContext(); |
| 10326 | |
| 10327 | if (context) |
| 10328 | { |
| 10329 | if (context->getClientVersion() < 3) |
| 10330 | { |
| 10331 | return gl::error(GL_INVALID_OPERATION); |
| 10332 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10333 | |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 10334 | gl::Buffer *readBuffer = NULL; |
| 10335 | switch (readTarget) |
| 10336 | { |
| 10337 | case GL_ARRAY_BUFFER: |
| 10338 | readBuffer = context->getArrayBuffer(); |
| 10339 | break; |
| 10340 | case GL_COPY_READ_BUFFER: |
| 10341 | readBuffer = context->getCopyReadBuffer(); |
| 10342 | break; |
| 10343 | case GL_COPY_WRITE_BUFFER: |
| 10344 | readBuffer = context->getCopyWriteBuffer(); |
| 10345 | break; |
| 10346 | case GL_ELEMENT_ARRAY_BUFFER: |
| 10347 | readBuffer = context->getElementArrayBuffer(); |
| 10348 | break; |
| 10349 | case GL_PIXEL_PACK_BUFFER: |
| 10350 | readBuffer = context->getPixelPackBuffer(); |
| 10351 | break; |
| 10352 | case GL_PIXEL_UNPACK_BUFFER: |
| 10353 | readBuffer = context->getPixelUnpackBuffer(); |
| 10354 | break; |
| 10355 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 10356 | readBuffer = context->getGenericTransformFeedbackBuffer(); |
| 10357 | break; |
| 10358 | case GL_UNIFORM_BUFFER: |
| 10359 | readBuffer = context->getGenericUniformBuffer(); |
| 10360 | break; |
| 10361 | default: |
| 10362 | return gl::error(GL_INVALID_ENUM); |
| 10363 | } |
| 10364 | |
| 10365 | gl::Buffer *writeBuffer = NULL; |
| 10366 | switch (writeTarget) |
| 10367 | { |
| 10368 | case GL_ARRAY_BUFFER: |
| 10369 | writeBuffer = context->getArrayBuffer(); |
| 10370 | break; |
| 10371 | case GL_COPY_READ_BUFFER: |
| 10372 | writeBuffer = context->getCopyReadBuffer(); |
| 10373 | break; |
| 10374 | case GL_COPY_WRITE_BUFFER: |
| 10375 | writeBuffer = context->getCopyWriteBuffer(); |
| 10376 | break; |
| 10377 | case GL_ELEMENT_ARRAY_BUFFER: |
| 10378 | writeBuffer = context->getElementArrayBuffer(); |
| 10379 | break; |
| 10380 | case GL_PIXEL_PACK_BUFFER: |
| 10381 | writeBuffer = context->getPixelPackBuffer(); |
| 10382 | break; |
| 10383 | case GL_PIXEL_UNPACK_BUFFER: |
| 10384 | writeBuffer = context->getPixelUnpackBuffer(); |
| 10385 | break; |
| 10386 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 10387 | writeBuffer = context->getGenericTransformFeedbackBuffer(); |
| 10388 | break; |
| 10389 | case GL_UNIFORM_BUFFER: |
| 10390 | writeBuffer = context->getGenericUniformBuffer(); |
| 10391 | break; |
| 10392 | default: |
| 10393 | return gl::error(GL_INVALID_ENUM); |
| 10394 | } |
| 10395 | |
| 10396 | if (!readBuffer || !writeBuffer) |
| 10397 | { |
| 10398 | return gl::error(GL_INVALID_OPERATION); |
| 10399 | } |
| 10400 | |
| 10401 | if (readOffset < 0 || writeOffset < 0 || size < 0 || |
| 10402 | static_cast<unsigned int>(readOffset + size) > readBuffer->size() || |
| 10403 | static_cast<unsigned int>(writeOffset + size) > writeBuffer->size()) |
| 10404 | { |
| 10405 | return gl::error(GL_INVALID_VALUE); |
| 10406 | } |
| 10407 | |
| 10408 | if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size) |
| 10409 | { |
| 10410 | return gl::error(GL_INVALID_VALUE); |
| 10411 | } |
| 10412 | |
| 10413 | // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION) |
| 10414 | |
shannon.woods%transgaming.com@gtempaccount.com | c53376a | 2013-04-13 03:41:23 +0000 | [diff] [blame] | 10415 | // if size is zero, the copy is a successful no-op |
| 10416 | if (size > 0) |
| 10417 | { |
| 10418 | writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); |
| 10419 | } |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 10420 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10421 | } |
| 10422 | catch(std::bad_alloc&) |
| 10423 | { |
| 10424 | return gl::error(GL_OUT_OF_MEMORY); |
| 10425 | } |
| 10426 | } |
| 10427 | |
| 10428 | void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) |
| 10429 | { |
| 10430 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)", |
| 10431 | program, uniformCount, uniformNames, uniformIndices); |
| 10432 | |
| 10433 | try |
| 10434 | { |
| 10435 | gl::Context *context = gl::getNonLostContext(); |
| 10436 | |
| 10437 | if (context) |
| 10438 | { |
| 10439 | if (context->getClientVersion() < 3) |
| 10440 | { |
| 10441 | return gl::error(GL_INVALID_OPERATION); |
| 10442 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10443 | |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 10444 | if (uniformCount < 0) |
| 10445 | { |
| 10446 | return gl::error(GL_INVALID_VALUE); |
| 10447 | } |
| 10448 | |
| 10449 | gl::Program *programObject = context->getProgram(program); |
| 10450 | |
| 10451 | if (!programObject) |
| 10452 | { |
| 10453 | if (context->getShader(program)) |
| 10454 | { |
| 10455 | return gl::error(GL_INVALID_OPERATION); |
| 10456 | } |
| 10457 | else |
| 10458 | { |
| 10459 | return gl::error(GL_INVALID_VALUE); |
| 10460 | } |
| 10461 | } |
| 10462 | |
| 10463 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10464 | if (!programObject->isLinked() || !programBinary) |
| 10465 | { |
| 10466 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10467 | { |
| 10468 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 10469 | } |
| 10470 | } |
| 10471 | else |
| 10472 | { |
| 10473 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10474 | { |
| 10475 | uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]); |
| 10476 | } |
| 10477 | } |
| 10478 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10479 | } |
| 10480 | catch(std::bad_alloc&) |
| 10481 | { |
| 10482 | return gl::error(GL_OUT_OF_MEMORY); |
| 10483 | } |
| 10484 | } |
| 10485 | |
| 10486 | void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) |
| 10487 | { |
| 10488 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10489 | program, uniformCount, uniformIndices, pname, params); |
| 10490 | |
| 10491 | try |
| 10492 | { |
| 10493 | gl::Context *context = gl::getNonLostContext(); |
| 10494 | |
| 10495 | if (context) |
| 10496 | { |
| 10497 | if (context->getClientVersion() < 3) |
| 10498 | { |
| 10499 | return gl::error(GL_INVALID_OPERATION); |
| 10500 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10501 | |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 10502 | if (uniformCount < 0) |
| 10503 | { |
| 10504 | return gl::error(GL_INVALID_VALUE); |
| 10505 | } |
| 10506 | |
| 10507 | gl::Program *programObject = context->getProgram(program); |
| 10508 | |
| 10509 | if (!programObject) |
| 10510 | { |
| 10511 | if (context->getShader(program)) |
| 10512 | { |
| 10513 | return gl::error(GL_INVALID_OPERATION); |
| 10514 | } |
| 10515 | else |
| 10516 | { |
| 10517 | return gl::error(GL_INVALID_VALUE); |
| 10518 | } |
| 10519 | } |
| 10520 | |
| 10521 | switch (pname) |
| 10522 | { |
| 10523 | case GL_UNIFORM_TYPE: |
| 10524 | case GL_UNIFORM_SIZE: |
| 10525 | case GL_UNIFORM_NAME_LENGTH: |
| 10526 | case GL_UNIFORM_BLOCK_INDEX: |
| 10527 | case GL_UNIFORM_OFFSET: |
| 10528 | case GL_UNIFORM_ARRAY_STRIDE: |
| 10529 | case GL_UNIFORM_MATRIX_STRIDE: |
| 10530 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 10531 | break; |
| 10532 | default: |
| 10533 | return gl::error(GL_INVALID_ENUM); |
| 10534 | } |
| 10535 | |
| 10536 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10537 | |
| 10538 | if (!programBinary && uniformCount > 0) |
| 10539 | { |
| 10540 | return gl::error(GL_INVALID_VALUE); |
| 10541 | } |
| 10542 | |
| 10543 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10544 | { |
| 10545 | const GLuint index = uniformIndices[uniformId]; |
| 10546 | |
| 10547 | if (index >= (GLuint)programBinary->getActiveUniformCount()) |
| 10548 | { |
| 10549 | return gl::error(GL_INVALID_VALUE); |
| 10550 | } |
| 10551 | } |
| 10552 | |
| 10553 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10554 | { |
| 10555 | const GLuint index = uniformIndices[uniformId]; |
| 10556 | params[uniformId] = programBinary->getActiveUniformi(index, pname); |
| 10557 | } |
| 10558 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10559 | } |
| 10560 | catch(std::bad_alloc&) |
| 10561 | { |
| 10562 | return gl::error(GL_OUT_OF_MEMORY); |
| 10563 | } |
| 10564 | } |
| 10565 | |
| 10566 | GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) |
| 10567 | { |
| 10568 | EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName); |
| 10569 | |
| 10570 | try |
| 10571 | { |
| 10572 | gl::Context *context = gl::getNonLostContext(); |
| 10573 | |
| 10574 | if (context) |
| 10575 | { |
| 10576 | if (context->getClientVersion() < 3) |
| 10577 | { |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10578 | 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] | 10579 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10580 | |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10581 | gl::Program *programObject = context->getProgram(program); |
| 10582 | |
| 10583 | if (!programObject) |
| 10584 | { |
| 10585 | if (context->getShader(program)) |
| 10586 | { |
| 10587 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
| 10588 | } |
| 10589 | else |
| 10590 | { |
| 10591 | return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX); |
| 10592 | } |
| 10593 | } |
| 10594 | |
| 10595 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10596 | if (!programBinary) |
| 10597 | { |
| 10598 | return GL_INVALID_INDEX; |
| 10599 | } |
| 10600 | |
| 10601 | return programBinary->getUniformBlockIndex(uniformBlockName); |
| 10602 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10603 | } |
| 10604 | catch(std::bad_alloc&) |
| 10605 | { |
| 10606 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10607 | } |
| 10608 | |
| 10609 | return 0; |
| 10610 | } |
| 10611 | |
| 10612 | void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) |
| 10613 | { |
| 10614 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10615 | program, uniformBlockIndex, pname, params); |
| 10616 | |
| 10617 | try |
| 10618 | { |
| 10619 | gl::Context *context = gl::getNonLostContext(); |
| 10620 | |
| 10621 | if (context) |
| 10622 | { |
| 10623 | if (context->getClientVersion() < 3) |
| 10624 | { |
| 10625 | return gl::error(GL_INVALID_OPERATION); |
| 10626 | } |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10627 | gl::Program *programObject = context->getProgram(program); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10628 | |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10629 | if (!programObject) |
| 10630 | { |
| 10631 | if (context->getShader(program)) |
| 10632 | { |
| 10633 | return gl::error(GL_INVALID_OPERATION); |
| 10634 | } |
| 10635 | else |
| 10636 | { |
| 10637 | return gl::error(GL_INVALID_VALUE); |
| 10638 | } |
| 10639 | } |
| 10640 | |
| 10641 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10642 | |
| 10643 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10644 | { |
| 10645 | return gl::error(GL_INVALID_VALUE); |
| 10646 | } |
| 10647 | |
| 10648 | switch (pname) |
| 10649 | { |
| 10650 | case GL_UNIFORM_BLOCK_BINDING: |
| 10651 | *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); |
| 10652 | break; |
| 10653 | |
| 10654 | case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 10655 | case GL_UNIFORM_BLOCK_NAME_LENGTH: |
| 10656 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 10657 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| 10658 | case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
| 10659 | case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
| 10660 | programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params); |
| 10661 | break; |
| 10662 | |
| 10663 | default: |
| 10664 | return gl::error(GL_INVALID_ENUM); |
| 10665 | } |
| 10666 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10667 | } |
| 10668 | catch(std::bad_alloc&) |
| 10669 | { |
| 10670 | return gl::error(GL_OUT_OF_MEMORY); |
| 10671 | } |
| 10672 | } |
| 10673 | |
| 10674 | void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) |
| 10675 | { |
| 10676 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)", |
| 10677 | program, uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10678 | |
| 10679 | try |
| 10680 | { |
| 10681 | gl::Context *context = gl::getNonLostContext(); |
| 10682 | |
| 10683 | if (context) |
| 10684 | { |
| 10685 | if (context->getClientVersion() < 3) |
| 10686 | { |
| 10687 | return gl::error(GL_INVALID_OPERATION); |
| 10688 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10689 | |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 10690 | gl::Program *programObject = context->getProgram(program); |
| 10691 | |
| 10692 | if (!programObject) |
| 10693 | { |
| 10694 | if (context->getShader(program)) |
| 10695 | { |
| 10696 | return gl::error(GL_INVALID_OPERATION); |
| 10697 | } |
| 10698 | else |
| 10699 | { |
| 10700 | return gl::error(GL_INVALID_VALUE); |
| 10701 | } |
| 10702 | } |
| 10703 | |
| 10704 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10705 | |
| 10706 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10707 | { |
| 10708 | return gl::error(GL_INVALID_VALUE); |
| 10709 | } |
| 10710 | |
| 10711 | programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10712 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10713 | } |
| 10714 | catch(std::bad_alloc&) |
| 10715 | { |
| 10716 | return gl::error(GL_OUT_OF_MEMORY); |
| 10717 | } |
| 10718 | } |
| 10719 | |
| 10720 | void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) |
| 10721 | { |
| 10722 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)", |
| 10723 | program, uniformBlockIndex, uniformBlockBinding); |
| 10724 | |
| 10725 | try |
| 10726 | { |
| 10727 | gl::Context *context = gl::getNonLostContext(); |
| 10728 | |
| 10729 | if (context) |
| 10730 | { |
| 10731 | if (context->getClientVersion() < 3) |
| 10732 | { |
| 10733 | return gl::error(GL_INVALID_OPERATION); |
| 10734 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10735 | |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 10736 | if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings()) |
| 10737 | { |
| 10738 | return gl::error(GL_INVALID_VALUE); |
| 10739 | } |
| 10740 | |
| 10741 | gl::Program *programObject = context->getProgram(program); |
| 10742 | |
| 10743 | if (!programObject) |
| 10744 | { |
| 10745 | if (context->getShader(program)) |
| 10746 | { |
| 10747 | return gl::error(GL_INVALID_OPERATION); |
| 10748 | } |
| 10749 | else |
| 10750 | { |
| 10751 | return gl::error(GL_INVALID_VALUE); |
| 10752 | } |
| 10753 | } |
| 10754 | |
| 10755 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10756 | |
| 10757 | // if never linked, there won't be any uniform blocks |
| 10758 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10759 | { |
| 10760 | return gl::error(GL_INVALID_VALUE); |
| 10761 | } |
| 10762 | |
| 10763 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
| 10764 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10765 | } |
| 10766 | catch(std::bad_alloc&) |
| 10767 | { |
| 10768 | return gl::error(GL_OUT_OF_MEMORY); |
| 10769 | } |
| 10770 | } |
| 10771 | |
| 10772 | void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 10773 | { |
| 10774 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)", |
| 10775 | mode, first, count, instanceCount); |
| 10776 | |
| 10777 | try |
| 10778 | { |
| 10779 | gl::Context *context = gl::getNonLostContext(); |
| 10780 | |
| 10781 | if (context) |
| 10782 | { |
| 10783 | if (context->getClientVersion() < 3) |
| 10784 | { |
| 10785 | return gl::error(GL_INVALID_OPERATION); |
| 10786 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10787 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10788 | // glDrawArraysInstanced |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10789 | UNIMPLEMENTED(); |
| 10790 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10791 | } |
| 10792 | catch(std::bad_alloc&) |
| 10793 | { |
| 10794 | return gl::error(GL_OUT_OF_MEMORY); |
| 10795 | } |
| 10796 | } |
| 10797 | |
| 10798 | void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) |
| 10799 | { |
| 10800 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)", |
| 10801 | mode, count, type, indices, instanceCount); |
| 10802 | |
| 10803 | try |
| 10804 | { |
| 10805 | gl::Context *context = gl::getNonLostContext(); |
| 10806 | |
| 10807 | if (context) |
| 10808 | { |
| 10809 | if (context->getClientVersion() < 3) |
| 10810 | { |
| 10811 | return gl::error(GL_INVALID_OPERATION); |
| 10812 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10813 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10814 | // glDrawElementsInstanced |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10815 | UNIMPLEMENTED(); |
| 10816 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10817 | } |
| 10818 | catch(std::bad_alloc&) |
| 10819 | { |
| 10820 | return gl::error(GL_OUT_OF_MEMORY); |
| 10821 | } |
| 10822 | } |
| 10823 | |
| 10824 | GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags) |
| 10825 | { |
| 10826 | EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags); |
| 10827 | |
| 10828 | try |
| 10829 | { |
| 10830 | gl::Context *context = gl::getNonLostContext(); |
| 10831 | |
| 10832 | if (context) |
| 10833 | { |
| 10834 | if (context->getClientVersion() < 3) |
| 10835 | { |
| 10836 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(NULL)); |
| 10837 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10838 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10839 | // glFenceSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10840 | UNIMPLEMENTED(); |
| 10841 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10842 | } |
| 10843 | catch(std::bad_alloc&) |
| 10844 | { |
| 10845 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL)); |
| 10846 | } |
| 10847 | |
| 10848 | return NULL; |
| 10849 | } |
| 10850 | |
| 10851 | GLboolean __stdcall glIsSync(GLsync sync) |
| 10852 | { |
| 10853 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10854 | |
| 10855 | try |
| 10856 | { |
| 10857 | gl::Context *context = gl::getNonLostContext(); |
| 10858 | |
| 10859 | if (context) |
| 10860 | { |
| 10861 | if (context->getClientVersion() < 3) |
| 10862 | { |
| 10863 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10864 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10865 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10866 | // glIsSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10867 | UNIMPLEMENTED(); |
| 10868 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10869 | } |
| 10870 | catch(std::bad_alloc&) |
| 10871 | { |
| 10872 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10873 | } |
| 10874 | |
| 10875 | return GL_FALSE; |
| 10876 | } |
| 10877 | |
| 10878 | void __stdcall glDeleteSync(GLsync sync) |
| 10879 | { |
| 10880 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10881 | |
| 10882 | try |
| 10883 | { |
| 10884 | gl::Context *context = gl::getNonLostContext(); |
| 10885 | |
| 10886 | if (context) |
| 10887 | { |
| 10888 | if (context->getClientVersion() < 3) |
| 10889 | { |
| 10890 | return gl::error(GL_INVALID_OPERATION); |
| 10891 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10892 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10893 | // glDeleteSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10894 | UNIMPLEMENTED(); |
| 10895 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10896 | } |
| 10897 | catch(std::bad_alloc&) |
| 10898 | { |
| 10899 | return gl::error(GL_OUT_OF_MEMORY); |
| 10900 | } |
| 10901 | } |
| 10902 | |
| 10903 | GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10904 | { |
| 10905 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10906 | sync, flags, timeout); |
| 10907 | |
| 10908 | try |
| 10909 | { |
| 10910 | gl::Context *context = gl::getNonLostContext(); |
| 10911 | |
| 10912 | if (context) |
| 10913 | { |
| 10914 | if (context->getClientVersion() < 3) |
| 10915 | { |
| 10916 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10917 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10918 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10919 | // glClientWaitSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10920 | UNIMPLEMENTED(); |
| 10921 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10922 | } |
| 10923 | catch(std::bad_alloc&) |
| 10924 | { |
| 10925 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10926 | } |
| 10927 | |
| 10928 | return GL_FALSE; |
| 10929 | } |
| 10930 | |
| 10931 | void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10932 | { |
| 10933 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10934 | sync, flags, timeout); |
| 10935 | |
| 10936 | try |
| 10937 | { |
| 10938 | gl::Context *context = gl::getNonLostContext(); |
| 10939 | |
| 10940 | if (context) |
| 10941 | { |
| 10942 | if (context->getClientVersion() < 3) |
| 10943 | { |
| 10944 | return gl::error(GL_INVALID_OPERATION); |
| 10945 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10946 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10947 | // glWaitSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10948 | UNIMPLEMENTED(); |
| 10949 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10950 | } |
| 10951 | catch(std::bad_alloc&) |
| 10952 | { |
| 10953 | return gl::error(GL_OUT_OF_MEMORY); |
| 10954 | } |
| 10955 | } |
| 10956 | |
| 10957 | void __stdcall glGetInteger64v(GLenum pname, GLint64* params) |
| 10958 | { |
| 10959 | EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10960 | pname, params); |
| 10961 | |
| 10962 | try |
| 10963 | { |
| 10964 | gl::Context *context = gl::getNonLostContext(); |
| 10965 | |
| 10966 | if (context) |
| 10967 | { |
| 10968 | if (context->getClientVersion() < 3) |
| 10969 | { |
| 10970 | return gl::error(GL_INVALID_OPERATION); |
| 10971 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10972 | |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 10973 | if (!(context->getInteger64v(pname, params))) |
| 10974 | { |
| 10975 | GLenum nativeType; |
| 10976 | unsigned int numParams = 0; |
| 10977 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
| 10978 | return gl::error(GL_INVALID_ENUM); |
| 10979 | |
| 10980 | if (numParams == 0) |
| 10981 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 10982 | |
| 10983 | if (nativeType == GL_BOOL) |
| 10984 | { |
| 10985 | GLboolean *boolParams = NULL; |
| 10986 | boolParams = new GLboolean[numParams]; |
| 10987 | |
| 10988 | context->getBooleanv(pname, boolParams); |
| 10989 | |
| 10990 | for (unsigned int i = 0; i < numParams; ++i) |
| 10991 | { |
| 10992 | if (boolParams[i] == GL_FALSE) |
| 10993 | params[i] = 0; |
| 10994 | else |
| 10995 | params[i] = 1; |
| 10996 | } |
| 10997 | |
| 10998 | delete [] boolParams; |
| 10999 | } |
| 11000 | else if (nativeType == GL_INT) |
| 11001 | { |
| 11002 | GLint *intParams = NULL; |
| 11003 | intParams = new GLint[numParams]; |
| 11004 | |
| 11005 | context->getIntegerv(pname, intParams); |
| 11006 | |
| 11007 | for (unsigned int i = 0; i < numParams; ++i) |
| 11008 | { |
| 11009 | params[i] = static_cast<GLint64>(intParams[i]); |
| 11010 | } |
| 11011 | |
| 11012 | delete [] intParams; |
| 11013 | } |
| 11014 | else if (nativeType == GL_FLOAT) |
| 11015 | { |
| 11016 | GLfloat *floatParams = NULL; |
| 11017 | floatParams = new GLfloat[numParams]; |
| 11018 | |
| 11019 | context->getFloatv(pname, floatParams); |
| 11020 | |
| 11021 | for (unsigned int i = 0; i < numParams; ++i) |
| 11022 | { |
| 11023 | // RGBA color values and DepthRangeF values are converted to integer using Equation 2.4 from Table 4.5 |
| 11024 | if (pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE || pname == GL_BLEND_COLOR) |
| 11025 | { |
| 11026 | params[i] = static_cast<GLint64>((static_cast<GLfloat>(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f); |
| 11027 | } |
| 11028 | else |
| 11029 | { |
| 11030 | params[i] = gl::iround<GLint64>(floatParams[i]); |
| 11031 | } |
| 11032 | } |
| 11033 | |
| 11034 | delete [] floatParams; |
| 11035 | } |
| 11036 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11037 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11038 | } |
| 11039 | catch(std::bad_alloc&) |
| 11040 | { |
| 11041 | return gl::error(GL_OUT_OF_MEMORY); |
| 11042 | } |
| 11043 | } |
| 11044 | |
| 11045 | void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) |
| 11046 | { |
| 11047 | EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)", |
| 11048 | sync, pname, bufSize, length, values); |
| 11049 | |
| 11050 | try |
| 11051 | { |
| 11052 | gl::Context *context = gl::getNonLostContext(); |
| 11053 | |
| 11054 | if (context) |
| 11055 | { |
| 11056 | if (context->getClientVersion() < 3) |
| 11057 | { |
| 11058 | return gl::error(GL_INVALID_OPERATION); |
| 11059 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11060 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11061 | // glGetSynciv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11062 | UNIMPLEMENTED(); |
| 11063 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11064 | } |
| 11065 | catch(std::bad_alloc&) |
| 11066 | { |
| 11067 | return gl::error(GL_OUT_OF_MEMORY); |
| 11068 | } |
| 11069 | } |
| 11070 | |
| 11071 | void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) |
| 11072 | { |
| 11073 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)", |
| 11074 | target, index, data); |
| 11075 | |
| 11076 | try |
| 11077 | { |
| 11078 | gl::Context *context = gl::getNonLostContext(); |
| 11079 | |
| 11080 | if (context) |
| 11081 | { |
| 11082 | if (context->getClientVersion() < 3) |
| 11083 | { |
| 11084 | return gl::error(GL_INVALID_OPERATION); |
| 11085 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11086 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11087 | // glGetInteger64i_v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11088 | UNIMPLEMENTED(); |
| 11089 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11090 | } |
| 11091 | catch(std::bad_alloc&) |
| 11092 | { |
| 11093 | return gl::error(GL_OUT_OF_MEMORY); |
| 11094 | } |
| 11095 | } |
| 11096 | |
| 11097 | void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) |
| 11098 | { |
| 11099 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 11100 | target, pname, params); |
| 11101 | |
| 11102 | try |
| 11103 | { |
| 11104 | gl::Context *context = gl::getNonLostContext(); |
| 11105 | |
| 11106 | if (context) |
| 11107 | { |
| 11108 | if (context->getClientVersion() < 3) |
| 11109 | { |
| 11110 | return gl::error(GL_INVALID_OPERATION); |
| 11111 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11112 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11113 | // glGetBufferParameteri64v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11114 | UNIMPLEMENTED(); |
| 11115 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11116 | } |
| 11117 | catch(std::bad_alloc&) |
| 11118 | { |
| 11119 | return gl::error(GL_OUT_OF_MEMORY); |
| 11120 | } |
| 11121 | } |
| 11122 | |
| 11123 | void __stdcall glGenSamplers(GLsizei count, GLuint* samplers) |
| 11124 | { |
| 11125 | EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers); |
| 11126 | |
| 11127 | try |
| 11128 | { |
| 11129 | gl::Context *context = gl::getNonLostContext(); |
| 11130 | |
| 11131 | if (context) |
| 11132 | { |
| 11133 | if (context->getClientVersion() < 3) |
| 11134 | { |
| 11135 | return gl::error(GL_INVALID_OPERATION); |
| 11136 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11137 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11138 | // glGenSamplers |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11139 | UNIMPLEMENTED(); |
| 11140 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11141 | } |
| 11142 | catch(std::bad_alloc&) |
| 11143 | { |
| 11144 | return gl::error(GL_OUT_OF_MEMORY); |
| 11145 | } |
| 11146 | } |
| 11147 | |
| 11148 | void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers) |
| 11149 | { |
| 11150 | EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers); |
| 11151 | |
| 11152 | try |
| 11153 | { |
| 11154 | gl::Context *context = gl::getNonLostContext(); |
| 11155 | |
| 11156 | if (context) |
| 11157 | { |
| 11158 | if (context->getClientVersion() < 3) |
| 11159 | { |
| 11160 | return gl::error(GL_INVALID_OPERATION); |
| 11161 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11162 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11163 | // glDeleteSamplers |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11164 | UNIMPLEMENTED(); |
| 11165 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11166 | } |
| 11167 | catch(std::bad_alloc&) |
| 11168 | { |
| 11169 | return gl::error(GL_OUT_OF_MEMORY); |
| 11170 | } |
| 11171 | } |
| 11172 | |
| 11173 | GLboolean __stdcall glIsSampler(GLuint sampler) |
| 11174 | { |
| 11175 | EVENT("(GLuint sampler = %u)", sampler); |
| 11176 | |
| 11177 | try |
| 11178 | { |
| 11179 | gl::Context *context = gl::getNonLostContext(); |
| 11180 | |
| 11181 | if (context) |
| 11182 | { |
| 11183 | if (context->getClientVersion() < 3) |
| 11184 | { |
| 11185 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 11186 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11187 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11188 | // glIsSampler |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11189 | UNIMPLEMENTED(); |
| 11190 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11191 | } |
| 11192 | catch(std::bad_alloc&) |
| 11193 | { |
| 11194 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 11195 | } |
| 11196 | |
| 11197 | return GL_FALSE; |
| 11198 | } |
| 11199 | |
| 11200 | void __stdcall glBindSampler(GLuint unit, GLuint sampler) |
| 11201 | { |
| 11202 | EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler); |
| 11203 | |
| 11204 | try |
| 11205 | { |
| 11206 | gl::Context *context = gl::getNonLostContext(); |
| 11207 | |
| 11208 | if (context) |
| 11209 | { |
| 11210 | if (context->getClientVersion() < 3) |
| 11211 | { |
| 11212 | return gl::error(GL_INVALID_OPERATION); |
| 11213 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11214 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11215 | // glBindSampler |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11216 | UNIMPLEMENTED(); |
| 11217 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11218 | } |
| 11219 | catch(std::bad_alloc&) |
| 11220 | { |
| 11221 | return gl::error(GL_OUT_OF_MEMORY); |
| 11222 | } |
| 11223 | } |
| 11224 | |
| 11225 | void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 11226 | { |
| 11227 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param); |
| 11228 | |
| 11229 | try |
| 11230 | { |
| 11231 | gl::Context *context = gl::getNonLostContext(); |
| 11232 | |
| 11233 | if (context) |
| 11234 | { |
| 11235 | if (context->getClientVersion() < 3) |
| 11236 | { |
| 11237 | return gl::error(GL_INVALID_OPERATION); |
| 11238 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11239 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11240 | // glSamplerParameteri |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11241 | UNIMPLEMENTED(); |
| 11242 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11243 | } |
| 11244 | catch(std::bad_alloc&) |
| 11245 | { |
| 11246 | return gl::error(GL_OUT_OF_MEMORY); |
| 11247 | } |
| 11248 | } |
| 11249 | |
| 11250 | void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) |
| 11251 | { |
| 11252 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLint* param = 0x%0.8p)", |
| 11253 | sampler, pname, param); |
| 11254 | |
| 11255 | try |
| 11256 | { |
| 11257 | gl::Context *context = gl::getNonLostContext(); |
| 11258 | |
| 11259 | if (context) |
| 11260 | { |
| 11261 | if (context->getClientVersion() < 3) |
| 11262 | { |
| 11263 | return gl::error(GL_INVALID_OPERATION); |
| 11264 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11265 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11266 | // glSamplerParameteriv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11267 | UNIMPLEMENTED(); |
| 11268 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11269 | } |
| 11270 | catch(std::bad_alloc&) |
| 11271 | { |
| 11272 | return gl::error(GL_OUT_OF_MEMORY); |
| 11273 | } |
| 11274 | } |
| 11275 | |
| 11276 | void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 11277 | { |
| 11278 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param); |
| 11279 | |
| 11280 | try |
| 11281 | { |
| 11282 | gl::Context *context = gl::getNonLostContext(); |
| 11283 | |
| 11284 | if (context) |
| 11285 | { |
| 11286 | if (context->getClientVersion() < 3) |
| 11287 | { |
| 11288 | return gl::error(GL_INVALID_OPERATION); |
| 11289 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11290 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11291 | // glSamplerParameterf |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11292 | UNIMPLEMENTED(); |
| 11293 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11294 | } |
| 11295 | catch(std::bad_alloc&) |
| 11296 | { |
| 11297 | return gl::error(GL_OUT_OF_MEMORY); |
| 11298 | } |
| 11299 | } |
| 11300 | |
| 11301 | void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) |
| 11302 | { |
| 11303 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLfloat* param = 0x%0.8p)", sampler, pname, param); |
| 11304 | |
| 11305 | try |
| 11306 | { |
| 11307 | gl::Context *context = gl::getNonLostContext(); |
| 11308 | |
| 11309 | if (context) |
| 11310 | { |
| 11311 | if (context->getClientVersion() < 3) |
| 11312 | { |
| 11313 | return gl::error(GL_INVALID_OPERATION); |
| 11314 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11315 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11316 | // glSamplerParameterfv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11317 | UNIMPLEMENTED(); |
| 11318 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11319 | } |
| 11320 | catch(std::bad_alloc&) |
| 11321 | { |
| 11322 | return gl::error(GL_OUT_OF_MEMORY); |
| 11323 | } |
| 11324 | } |
| 11325 | |
| 11326 | void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) |
| 11327 | { |
| 11328 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); |
| 11329 | |
| 11330 | try |
| 11331 | { |
| 11332 | gl::Context *context = gl::getNonLostContext(); |
| 11333 | |
| 11334 | if (context) |
| 11335 | { |
| 11336 | if (context->getClientVersion() < 3) |
| 11337 | { |
| 11338 | return gl::error(GL_INVALID_OPERATION); |
| 11339 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11340 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11341 | // glGetSamplerParameteriv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11342 | UNIMPLEMENTED(); |
| 11343 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11344 | } |
| 11345 | catch(std::bad_alloc&) |
| 11346 | { |
| 11347 | return gl::error(GL_OUT_OF_MEMORY); |
| 11348 | } |
| 11349 | } |
| 11350 | |
| 11351 | void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) |
| 11352 | { |
| 11353 | EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params); |
| 11354 | |
| 11355 | try |
| 11356 | { |
| 11357 | gl::Context *context = gl::getNonLostContext(); |
| 11358 | |
| 11359 | if (context) |
| 11360 | { |
| 11361 | if (context->getClientVersion() < 3) |
| 11362 | { |
| 11363 | return gl::error(GL_INVALID_OPERATION); |
| 11364 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11365 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11366 | // glGetSamplerParameterfv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11367 | UNIMPLEMENTED(); |
| 11368 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11369 | } |
| 11370 | catch(std::bad_alloc&) |
| 11371 | { |
| 11372 | return gl::error(GL_OUT_OF_MEMORY); |
| 11373 | } |
| 11374 | } |
| 11375 | |
| 11376 | void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor) |
| 11377 | { |
| 11378 | EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor); |
| 11379 | |
| 11380 | try |
| 11381 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 11382 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 11383 | { |
| 11384 | return gl::error(GL_INVALID_VALUE); |
| 11385 | } |
| 11386 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11387 | gl::Context *context = gl::getNonLostContext(); |
| 11388 | |
| 11389 | if (context) |
| 11390 | { |
| 11391 | if (context->getClientVersion() < 3) |
| 11392 | { |
| 11393 | return gl::error(GL_INVALID_OPERATION); |
| 11394 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11395 | |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 11396 | context->setVertexAttribDivisor(index, divisor); |
| 11397 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11398 | } |
| 11399 | catch(std::bad_alloc&) |
| 11400 | { |
| 11401 | return gl::error(GL_OUT_OF_MEMORY); |
| 11402 | } |
| 11403 | } |
| 11404 | |
| 11405 | void __stdcall glBindTransformFeedback(GLenum target, GLuint id) |
| 11406 | { |
| 11407 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 11408 | |
| 11409 | try |
| 11410 | { |
| 11411 | gl::Context *context = gl::getNonLostContext(); |
| 11412 | |
| 11413 | if (context) |
| 11414 | { |
| 11415 | if (context->getClientVersion() < 3) |
| 11416 | { |
| 11417 | return gl::error(GL_INVALID_OPERATION); |
| 11418 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11419 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11420 | // glBindTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11421 | UNIMPLEMENTED(); |
| 11422 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11423 | } |
| 11424 | catch(std::bad_alloc&) |
| 11425 | { |
| 11426 | return gl::error(GL_OUT_OF_MEMORY); |
| 11427 | } |
| 11428 | } |
| 11429 | |
| 11430 | void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) |
| 11431 | { |
| 11432 | EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids); |
| 11433 | |
| 11434 | try |
| 11435 | { |
| 11436 | gl::Context *context = gl::getNonLostContext(); |
| 11437 | |
| 11438 | if (context) |
| 11439 | { |
| 11440 | if (context->getClientVersion() < 3) |
| 11441 | { |
| 11442 | return gl::error(GL_INVALID_OPERATION); |
| 11443 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11444 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11445 | // glDeleteTransformFeedbacks |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11446 | UNIMPLEMENTED(); |
| 11447 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11448 | } |
| 11449 | catch(std::bad_alloc&) |
| 11450 | { |
| 11451 | return gl::error(GL_OUT_OF_MEMORY); |
| 11452 | } |
| 11453 | } |
| 11454 | |
| 11455 | void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids) |
| 11456 | { |
| 11457 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 11458 | |
| 11459 | try |
| 11460 | { |
| 11461 | gl::Context *context = gl::getNonLostContext(); |
| 11462 | |
| 11463 | if (context) |
| 11464 | { |
| 11465 | if (context->getClientVersion() < 3) |
| 11466 | { |
| 11467 | return gl::error(GL_INVALID_OPERATION); |
| 11468 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11469 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11470 | // glGenTransformFeedbacks |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11471 | UNIMPLEMENTED(); |
| 11472 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11473 | } |
| 11474 | catch(std::bad_alloc&) |
| 11475 | { |
| 11476 | return gl::error(GL_OUT_OF_MEMORY); |
| 11477 | } |
| 11478 | } |
| 11479 | |
| 11480 | GLboolean __stdcall glIsTransformFeedback(GLuint id) |
| 11481 | { |
| 11482 | EVENT("(GLuint id = %u)", id); |
| 11483 | |
| 11484 | try |
| 11485 | { |
| 11486 | gl::Context *context = gl::getNonLostContext(); |
| 11487 | |
| 11488 | if (context) |
| 11489 | { |
| 11490 | if (context->getClientVersion() < 3) |
| 11491 | { |
| 11492 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 11493 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11494 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11495 | // glIsTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11496 | UNIMPLEMENTED(); |
| 11497 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11498 | } |
| 11499 | catch(std::bad_alloc&) |
| 11500 | { |
| 11501 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 11502 | } |
| 11503 | |
| 11504 | return GL_FALSE; |
| 11505 | } |
| 11506 | |
| 11507 | void __stdcall glPauseTransformFeedback(void) |
| 11508 | { |
| 11509 | EVENT("(void)"); |
| 11510 | |
| 11511 | try |
| 11512 | { |
| 11513 | gl::Context *context = gl::getNonLostContext(); |
| 11514 | |
| 11515 | if (context) |
| 11516 | { |
| 11517 | if (context->getClientVersion() < 3) |
| 11518 | { |
| 11519 | return gl::error(GL_INVALID_OPERATION); |
| 11520 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11521 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11522 | // glPauseTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11523 | UNIMPLEMENTED(); |
| 11524 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11525 | } |
| 11526 | catch(std::bad_alloc&) |
| 11527 | { |
| 11528 | return gl::error(GL_OUT_OF_MEMORY); |
| 11529 | } |
| 11530 | } |
| 11531 | |
| 11532 | void __stdcall glResumeTransformFeedback(void) |
| 11533 | { |
| 11534 | EVENT("(void)"); |
| 11535 | |
| 11536 | try |
| 11537 | { |
| 11538 | gl::Context *context = gl::getNonLostContext(); |
| 11539 | |
| 11540 | if (context) |
| 11541 | { |
| 11542 | if (context->getClientVersion() < 3) |
| 11543 | { |
| 11544 | return gl::error(GL_INVALID_OPERATION); |
| 11545 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11546 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11547 | // glResumeTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11548 | UNIMPLEMENTED(); |
| 11549 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11550 | } |
| 11551 | catch(std::bad_alloc&) |
| 11552 | { |
| 11553 | return gl::error(GL_OUT_OF_MEMORY); |
| 11554 | } |
| 11555 | } |
| 11556 | |
| 11557 | void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) |
| 11558 | { |
| 11559 | EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)", |
| 11560 | program, bufSize, length, binaryFormat, binary); |
| 11561 | |
| 11562 | try |
| 11563 | { |
| 11564 | gl::Context *context = gl::getNonLostContext(); |
| 11565 | |
| 11566 | if (context) |
| 11567 | { |
| 11568 | if (context->getClientVersion() < 3) |
| 11569 | { |
| 11570 | return gl::error(GL_INVALID_OPERATION); |
| 11571 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11572 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11573 | // glGetProgramBinary |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11574 | UNIMPLEMENTED(); |
| 11575 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11576 | } |
| 11577 | catch(std::bad_alloc&) |
| 11578 | { |
| 11579 | return gl::error(GL_OUT_OF_MEMORY); |
| 11580 | } |
| 11581 | } |
| 11582 | |
| 11583 | void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) |
| 11584 | { |
| 11585 | EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
| 11586 | program, binaryFormat, binary, length); |
| 11587 | |
| 11588 | try |
| 11589 | { |
| 11590 | gl::Context *context = gl::getNonLostContext(); |
| 11591 | |
| 11592 | if (context) |
| 11593 | { |
| 11594 | if (context->getClientVersion() < 3) |
| 11595 | { |
| 11596 | return gl::error(GL_INVALID_OPERATION); |
| 11597 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11598 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11599 | // glProgramBinary |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11600 | UNIMPLEMENTED(); |
| 11601 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11602 | } |
| 11603 | catch(std::bad_alloc&) |
| 11604 | { |
| 11605 | return gl::error(GL_OUT_OF_MEMORY); |
| 11606 | } |
| 11607 | } |
| 11608 | |
| 11609 | void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value) |
| 11610 | { |
| 11611 | EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)", |
| 11612 | program, pname, value); |
| 11613 | |
| 11614 | try |
| 11615 | { |
| 11616 | gl::Context *context = gl::getNonLostContext(); |
| 11617 | |
| 11618 | if (context) |
| 11619 | { |
| 11620 | if (context->getClientVersion() < 3) |
| 11621 | { |
| 11622 | return gl::error(GL_INVALID_OPERATION); |
| 11623 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11624 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11625 | // glProgramParameteri |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11626 | UNIMPLEMENTED(); |
| 11627 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11628 | } |
| 11629 | catch(std::bad_alloc&) |
| 11630 | { |
| 11631 | return gl::error(GL_OUT_OF_MEMORY); |
| 11632 | } |
| 11633 | } |
| 11634 | |
| 11635 | void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) |
| 11636 | { |
| 11637 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)", |
| 11638 | target, numAttachments, attachments); |
| 11639 | |
| 11640 | try |
| 11641 | { |
| 11642 | gl::Context *context = gl::getNonLostContext(); |
| 11643 | |
| 11644 | if (context) |
| 11645 | { |
| 11646 | if (context->getClientVersion() < 3) |
| 11647 | { |
| 11648 | return gl::error(GL_INVALID_OPERATION); |
| 11649 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11650 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11651 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11652 | { |
| 11653 | return; |
| 11654 | } |
| 11655 | |
| 11656 | int maxDimension = context->getMaximumRenderbufferDimension(); |
| 11657 | context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension); |
| 11658 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11659 | } |
| 11660 | catch(std::bad_alloc&) |
| 11661 | { |
| 11662 | return gl::error(GL_OUT_OF_MEMORY); |
| 11663 | } |
| 11664 | } |
| 11665 | |
| 11666 | void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) |
| 11667 | { |
| 11668 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, " |
| 11669 | "GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 11670 | target, numAttachments, attachments, x, y, width, height); |
| 11671 | |
| 11672 | try |
| 11673 | { |
| 11674 | gl::Context *context = gl::getNonLostContext(); |
| 11675 | |
| 11676 | if (context) |
| 11677 | { |
| 11678 | if (context->getClientVersion() < 3) |
| 11679 | { |
| 11680 | return gl::error(GL_INVALID_OPERATION); |
| 11681 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11682 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11683 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11684 | { |
| 11685 | return; |
| 11686 | } |
| 11687 | |
| 11688 | context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height); |
| 11689 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11690 | } |
| 11691 | catch(std::bad_alloc&) |
| 11692 | { |
| 11693 | return gl::error(GL_OUT_OF_MEMORY); |
| 11694 | } |
| 11695 | } |
| 11696 | |
| 11697 | void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 11698 | { |
| 11699 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 11700 | target, levels, internalformat, width, height); |
| 11701 | |
| 11702 | try |
| 11703 | { |
| 11704 | gl::Context *context = gl::getNonLostContext(); |
| 11705 | |
| 11706 | if (context) |
| 11707 | { |
| 11708 | if (context->getClientVersion() < 3) |
| 11709 | { |
| 11710 | return gl::error(GL_INVALID_OPERATION); |
| 11711 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11712 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11713 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 11714 | { |
| 11715 | return; |
| 11716 | } |
| 11717 | |
| 11718 | switch (target) |
| 11719 | { |
| 11720 | case GL_TEXTURE_2D: |
| 11721 | { |
| 11722 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 11723 | texture2d->storage(levels, internalformat, width, height); |
| 11724 | } |
| 11725 | break; |
| 11726 | |
| 11727 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 11728 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 11729 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 11730 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 11731 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 11732 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 11733 | { |
| 11734 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 11735 | textureCube->storage(levels, internalformat, width); |
| 11736 | } |
| 11737 | break; |
| 11738 | |
| 11739 | default: |
| 11740 | return gl::error(GL_INVALID_ENUM); |
| 11741 | } |
| 11742 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11743 | } |
| 11744 | catch(std::bad_alloc&) |
| 11745 | { |
| 11746 | return gl::error(GL_OUT_OF_MEMORY); |
| 11747 | } |
| 11748 | } |
| 11749 | |
| 11750 | void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
| 11751 | { |
| 11752 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 11753 | "GLsizei height = %d, GLsizei depth = %d)", |
| 11754 | target, levels, internalformat, width, height, depth); |
| 11755 | |
| 11756 | try |
| 11757 | { |
| 11758 | gl::Context *context = gl::getNonLostContext(); |
| 11759 | |
| 11760 | if (context) |
| 11761 | { |
| 11762 | if (context->getClientVersion() < 3) |
| 11763 | { |
| 11764 | return gl::error(GL_INVALID_OPERATION); |
| 11765 | } |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11766 | |
| 11767 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) |
| 11768 | { |
| 11769 | return; |
| 11770 | } |
| 11771 | |
| 11772 | switch (target) |
| 11773 | { |
| 11774 | case GL_TEXTURE_3D: |
| 11775 | { |
| 11776 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 11777 | texture3d->storage(levels, internalformat, width, height, depth); |
| 11778 | } |
| 11779 | break; |
| 11780 | |
| 11781 | case GL_TEXTURE_2D_ARRAY: |
| 11782 | { |
| 11783 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 11784 | texture2darray->storage(levels, internalformat, width, height, depth); |
| 11785 | } |
| 11786 | break; |
| 11787 | |
| 11788 | default: |
| 11789 | return gl::error(GL_INVALID_ENUM); |
| 11790 | } |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 11791 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11792 | } |
| 11793 | catch(std::bad_alloc&) |
| 11794 | { |
| 11795 | return gl::error(GL_OUT_OF_MEMORY); |
| 11796 | } |
| 11797 | } |
| 11798 | |
| 11799 | void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) |
| 11800 | { |
| 11801 | EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, " |
| 11802 | "GLint* params = 0x%0.8p)", |
| 11803 | target, internalformat, pname, bufSize, params); |
| 11804 | |
| 11805 | try |
| 11806 | { |
| 11807 | gl::Context *context = gl::getNonLostContext(); |
| 11808 | |
| 11809 | if (context) |
| 11810 | { |
| 11811 | if (context->getClientVersion() < 3) |
| 11812 | { |
| 11813 | return gl::error(GL_INVALID_OPERATION); |
| 11814 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11815 | |
Shannon Woods | 809d250 | 2013-07-08 10:32:18 -0400 | [diff] [blame] | 11816 | if (!gl::IsColorRenderingSupported(internalformat, context) && |
| 11817 | !gl::IsDepthRenderingSupported(internalformat, context) && |
| 11818 | !gl::IsStencilRenderingSupported(internalformat, context)) |
| 11819 | { |
| 11820 | return gl::error(GL_INVALID_ENUM); |
| 11821 | } |
| 11822 | |
| 11823 | if (target != GL_RENDERBUFFER) |
| 11824 | { |
| 11825 | return gl::error(GL_INVALID_ENUM); |
| 11826 | } |
| 11827 | |
| 11828 | if (bufSize < 0) |
| 11829 | { |
| 11830 | return gl::error(GL_INVALID_VALUE); |
| 11831 | } |
| 11832 | |
| 11833 | switch (pname) |
| 11834 | { |
| 11835 | case GL_NUM_SAMPLE_COUNTS: |
| 11836 | if (bufSize != 0) |
| 11837 | *params = context->getNumSampleCounts(internalformat); |
| 11838 | break; |
| 11839 | case GL_SAMPLES: |
| 11840 | context->getSampleCounts(internalformat, bufSize, params); |
| 11841 | break; |
| 11842 | default: |
| 11843 | return gl::error(GL_INVALID_ENUM); |
| 11844 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11845 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11846 | } |
| 11847 | catch(std::bad_alloc&) |
| 11848 | { |
| 11849 | return gl::error(GL_OUT_OF_MEMORY); |
| 11850 | } |
| 11851 | } |
| 11852 | |
| 11853 | // Extension functions |
| 11854 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11855 | void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 11856 | GLbitfield mask, GLenum filter) |
| 11857 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11858 | 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] | 11859 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, " |
| 11860 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 11861 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 11862 | |
| 11863 | try |
| 11864 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11865 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11866 | |
| 11867 | if (context) |
| 11868 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11869 | if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 11870 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 11871 | true)) |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11872 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11873 | return; |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11874 | } |
| 11875 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11876 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 11877 | mask, filter); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11878 | } |
| 11879 | } |
| 11880 | catch(std::bad_alloc&) |
| 11881 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11882 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11883 | } |
| 11884 | } |
| 11885 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 11886 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, |
| 11887 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11888 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11889 | 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] | 11890 | "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] | 11891 | "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] | 11892 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 11893 | |
| 11894 | try |
| 11895 | { |
| 11896 | UNIMPLEMENTED(); // FIXME |
| 11897 | } |
| 11898 | catch(std::bad_alloc&) |
| 11899 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11900 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11901 | } |
| 11902 | } |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11903 | |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11904 | void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, |
| 11905 | GLenum *binaryFormat, void *binary) |
| 11906 | { |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11907 | 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] | 11908 | program, bufSize, length, binaryFormat, binary); |
| 11909 | |
| 11910 | try |
| 11911 | { |
| 11912 | gl::Context *context = gl::getNonLostContext(); |
| 11913 | |
| 11914 | if (context) |
| 11915 | { |
| 11916 | gl::Program *programObject = context->getProgram(program); |
| 11917 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 11918 | if (!programObject || !programObject->isLinked()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11919 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11920 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11921 | } |
| 11922 | |
| 11923 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 11924 | |
| 11925 | if (!programBinary) |
| 11926 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11927 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11928 | } |
| 11929 | |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11930 | if (!programBinary->save(binary, bufSize, length)) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11931 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11932 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11933 | } |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11934 | |
| 11935 | *binaryFormat = GL_PROGRAM_BINARY_ANGLE; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11936 | } |
| 11937 | } |
| 11938 | catch(std::bad_alloc&) |
| 11939 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11940 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11941 | } |
| 11942 | } |
| 11943 | |
| 11944 | void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat, |
| 11945 | const void *binary, GLint length) |
| 11946 | { |
| 11947 | EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)", |
| 11948 | program, binaryFormat, binary, length); |
| 11949 | |
| 11950 | try |
| 11951 | { |
| 11952 | gl::Context *context = gl::getNonLostContext(); |
| 11953 | |
| 11954 | if (context) |
| 11955 | { |
| 11956 | if (binaryFormat != GL_PROGRAM_BINARY_ANGLE) |
| 11957 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11958 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11959 | } |
| 11960 | |
| 11961 | gl::Program *programObject = context->getProgram(program); |
| 11962 | |
| 11963 | if (!programObject) |
| 11964 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11965 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11966 | } |
| 11967 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 11968 | context->setProgramBinary(program, binary, length); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11969 | } |
| 11970 | } |
| 11971 | catch(std::bad_alloc&) |
| 11972 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11973 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11974 | } |
| 11975 | } |
| 11976 | |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11977 | void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) |
| 11978 | { |
| 11979 | EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs); |
| 11980 | |
| 11981 | try |
| 11982 | { |
| 11983 | gl::Context *context = gl::getNonLostContext(); |
| 11984 | |
| 11985 | if (context) |
| 11986 | { |
| 11987 | if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets()) |
| 11988 | { |
| 11989 | return gl::error(GL_INVALID_VALUE); |
| 11990 | } |
| 11991 | |
| 11992 | if (context->getDrawFramebufferHandle() == 0) |
| 11993 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11994 | if (n != 1) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11995 | { |
| 11996 | return gl::error(GL_INVALID_OPERATION); |
| 11997 | } |
| 11998 | |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11999 | 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] | 12000 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12001 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12002 | } |
| 12003 | } |
| 12004 | else |
| 12005 | { |
| 12006 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 12007 | { |
| 12008 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 12009 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment) |
| 12010 | { |
| 12011 | return gl::error(GL_INVALID_OPERATION); |
| 12012 | } |
| 12013 | } |
| 12014 | } |
| 12015 | |
| 12016 | gl::Framebuffer *framebuffer = context->getDrawFramebuffer(); |
| 12017 | |
| 12018 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 12019 | { |
| 12020 | framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]); |
| 12021 | } |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12022 | |
| 12023 | for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++) |
| 12024 | { |
| 12025 | framebuffer->setDrawBufferState(colorAttachment, GL_NONE); |
| 12026 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12027 | } |
| 12028 | } |
| 12029 | catch (std::bad_alloc&) |
| 12030 | { |
| 12031 | return gl::error(GL_OUT_OF_MEMORY); |
| 12032 | } |
| 12033 | } |
| 12034 | |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12035 | __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) |
| 12036 | { |
| 12037 | struct Extension |
| 12038 | { |
| 12039 | const char *name; |
| 12040 | __eglMustCastToProperFunctionPointerType address; |
| 12041 | }; |
| 12042 | |
| 12043 | static const Extension glExtensions[] = |
| 12044 | { |
| 12045 | {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 12046 | {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, |
daniel@transgaming.com | 1fe96c9 | 2011-01-14 15:08:44 +0000 | [diff] [blame] | 12047 | {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 12048 | {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, |
| 12049 | {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, |
| 12050 | {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, |
| 12051 | {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, |
| 12052 | {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, |
| 12053 | {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, |
| 12054 | {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 12055 | {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE}, |
daniel@transgaming.com | 0bd1f2f | 2011-11-11 04:19:03 +0000 | [diff] [blame] | 12056 | {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT}, |
daniel@transgaming.com | 709ed11 | 2011-11-12 03:18:10 +0000 | [diff] [blame] | 12057 | {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT}, |
| 12058 | {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT}, |
| 12059 | {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT}, |
| 12060 | {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT}, |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 12061 | {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT}, |
| 12062 | {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT}, |
| 12063 | {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT}, |
| 12064 | {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT}, |
| 12065 | {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT}, |
| 12066 | {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT}, |
| 12067 | {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT}, |
shannon.woods%transgaming.com@gtempaccount.com | 77d9472 | 2013-04-13 03:34:22 +0000 | [diff] [blame] | 12068 | {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT}, |
daniel@transgaming.com | dce02fd | 2012-01-27 15:39:51 +0000 | [diff] [blame] | 12069 | {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE}, |
| 12070 | {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, |
| 12071 | {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12072 | {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, |
| 12073 | {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, }; |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12074 | |
shannon.woods@transgaming.com | d438fd4 | 2013-02-28 23:17:45 +0000 | [diff] [blame] | 12075 | for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12076 | { |
| 12077 | if (strcmp(procname, glExtensions[ext].name) == 0) |
| 12078 | { |
| 12079 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address; |
| 12080 | } |
| 12081 | } |
| 12082 | |
| 12083 | return NULL; |
| 12084 | } |
| 12085 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 12086 | // Non-public functions used by EGL |
| 12087 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 12088 | bool __stdcall glBindTexImage(egl::Surface *surface) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12089 | { |
| 12090 | EVENT("(egl::Surface* surface = 0x%0.8p)", |
| 12091 | surface); |
| 12092 | |
| 12093 | try |
| 12094 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 12095 | gl::Context *context = gl::getNonLostContext(); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12096 | |
| 12097 | if (context) |
| 12098 | { |
| 12099 | gl::Texture2D *textureObject = context->getTexture2D(); |
| 12100 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 12101 | if (textureObject->isImmutable()) |
| 12102 | { |
| 12103 | return false; |
| 12104 | } |
| 12105 | |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12106 | if (textureObject) |
| 12107 | { |
| 12108 | textureObject->bindTexImage(surface); |
| 12109 | } |
| 12110 | } |
| 12111 | } |
| 12112 | catch(std::bad_alloc&) |
| 12113 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12114 | return gl::error(GL_OUT_OF_MEMORY, false); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12115 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 12116 | |
| 12117 | return true; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12118 | } |
| 12119 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 12120 | } |