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 | |
| 2090 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2091 | extern "C" |
| 2092 | { |
| 2093 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2094 | // OpenGL ES 2.0 functions |
| 2095 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2096 | void __stdcall glActiveTexture(GLenum texture) |
| 2097 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2098 | EVENT("(GLenum texture = 0x%X)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2099 | |
| 2100 | try |
| 2101 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2102 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2103 | |
| 2104 | if (context) |
| 2105 | { |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 2106 | if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1) |
| 2107 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2108 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 2109 | } |
| 2110 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2111 | context->setActiveSampler(texture - GL_TEXTURE0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2112 | } |
| 2113 | } |
| 2114 | catch(std::bad_alloc&) |
| 2115 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2116 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2117 | } |
| 2118 | } |
| 2119 | |
| 2120 | void __stdcall glAttachShader(GLuint program, GLuint shader) |
| 2121 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2122 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2123 | |
| 2124 | try |
| 2125 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2126 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2127 | |
| 2128 | if (context) |
| 2129 | { |
| 2130 | gl::Program *programObject = context->getProgram(program); |
| 2131 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2132 | |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2133 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2134 | { |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2135 | if (context->getShader(program)) |
| 2136 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2137 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2138 | } |
| 2139 | else |
| 2140 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2141 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2142 | } |
| 2143 | } |
| 2144 | |
| 2145 | if (!shaderObject) |
| 2146 | { |
| 2147 | if (context->getProgram(shader)) |
| 2148 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2149 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2150 | } |
| 2151 | else |
| 2152 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2153 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2154 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2155 | } |
| 2156 | |
| 2157 | if (!programObject->attachShader(shaderObject)) |
| 2158 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2159 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2160 | } |
| 2161 | } |
| 2162 | } |
| 2163 | catch(std::bad_alloc&) |
| 2164 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2165 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2166 | } |
| 2167 | } |
| 2168 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2169 | void __stdcall glBeginQueryEXT(GLenum target, GLuint id) |
| 2170 | { |
| 2171 | EVENT("(GLenum target = 0x%X, GLuint %d)", target, id); |
| 2172 | |
| 2173 | try |
| 2174 | { |
| 2175 | switch (target) |
| 2176 | { |
| 2177 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 2178 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 2179 | break; |
| 2180 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2181 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2182 | } |
| 2183 | |
| 2184 | if (id == 0) |
| 2185 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2186 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2187 | } |
| 2188 | |
| 2189 | gl::Context *context = gl::getNonLostContext(); |
| 2190 | |
| 2191 | if (context) |
| 2192 | { |
| 2193 | context->beginQuery(target, id); |
| 2194 | } |
| 2195 | } |
| 2196 | catch(std::bad_alloc&) |
| 2197 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2198 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2199 | } |
| 2200 | } |
| 2201 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2202 | void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2203 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2204 | 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] | 2205 | |
| 2206 | try |
| 2207 | { |
| 2208 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 2209 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2210 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2211 | } |
| 2212 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2213 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2214 | |
| 2215 | if (context) |
| 2216 | { |
| 2217 | gl::Program *programObject = context->getProgram(program); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2218 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2219 | if (!programObject) |
| 2220 | { |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2221 | if (context->getShader(program)) |
| 2222 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2223 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2224 | } |
| 2225 | else |
| 2226 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2227 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2228 | } |
| 2229 | } |
| 2230 | |
| 2231 | if (strncmp(name, "gl_", 3) == 0) |
| 2232 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2233 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2234 | } |
| 2235 | |
| 2236 | programObject->bindAttributeLocation(index, name); |
| 2237 | } |
| 2238 | } |
| 2239 | catch(std::bad_alloc&) |
| 2240 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2241 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2242 | } |
| 2243 | } |
| 2244 | |
| 2245 | void __stdcall glBindBuffer(GLenum target, GLuint buffer) |
| 2246 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2247 | EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2248 | |
| 2249 | try |
| 2250 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2251 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2252 | |
| 2253 | if (context) |
| 2254 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2255 | // Check ES3 specific targets |
| 2256 | switch (target) |
| 2257 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2258 | case GL_COPY_READ_BUFFER: |
| 2259 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2260 | case GL_PIXEL_PACK_BUFFER: |
| 2261 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2262 | case GL_UNIFORM_BUFFER: |
| 2263 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2264 | if (context->getClientVersion() < 3) |
| 2265 | { |
| 2266 | return gl::error(GL_INVALID_ENUM); |
| 2267 | } |
| 2268 | } |
| 2269 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2270 | switch (target) |
| 2271 | { |
| 2272 | case GL_ARRAY_BUFFER: |
| 2273 | context->bindArrayBuffer(buffer); |
| 2274 | return; |
| 2275 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2276 | context->bindElementArrayBuffer(buffer); |
| 2277 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2278 | case GL_COPY_READ_BUFFER: |
| 2279 | context->bindCopyReadBuffer(buffer); |
| 2280 | return; |
| 2281 | case GL_COPY_WRITE_BUFFER: |
| 2282 | context->bindCopyWriteBuffer(buffer); |
| 2283 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2284 | case GL_PIXEL_PACK_BUFFER: |
| 2285 | context->bindPixelPackBuffer(buffer); |
| 2286 | return; |
| 2287 | case GL_PIXEL_UNPACK_BUFFER: |
| 2288 | context->bindPixelUnpackBuffer(buffer); |
| 2289 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2290 | case GL_UNIFORM_BUFFER: |
| 2291 | context->bindGenericUniformBuffer(buffer); |
| 2292 | return; |
| 2293 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 7a1ebad | 2013-05-30 00:05:20 +0000 | [diff] [blame] | 2294 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2295 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2296 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2297 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2298 | } |
| 2299 | } |
| 2300 | } |
| 2301 | catch(std::bad_alloc&) |
| 2302 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2303 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2304 | } |
| 2305 | } |
| 2306 | |
| 2307 | void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer) |
| 2308 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2309 | EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2310 | |
| 2311 | try |
| 2312 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2313 | 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] | 2314 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2315 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2316 | } |
| 2317 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2318 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2319 | |
| 2320 | if (context) |
| 2321 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2322 | if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 2323 | { |
| 2324 | context->bindReadFramebuffer(framebuffer); |
| 2325 | } |
| 2326 | |
| 2327 | if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 2328 | { |
| 2329 | context->bindDrawFramebuffer(framebuffer); |
| 2330 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2331 | } |
| 2332 | } |
| 2333 | catch(std::bad_alloc&) |
| 2334 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2335 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2336 | } |
| 2337 | } |
| 2338 | |
| 2339 | void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 2340 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2341 | EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2342 | |
| 2343 | try |
| 2344 | { |
| 2345 | if (target != GL_RENDERBUFFER) |
| 2346 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2347 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2348 | } |
| 2349 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2350 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2351 | |
| 2352 | if (context) |
| 2353 | { |
| 2354 | context->bindRenderbuffer(renderbuffer); |
| 2355 | } |
| 2356 | } |
| 2357 | catch(std::bad_alloc&) |
| 2358 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2359 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2360 | } |
| 2361 | } |
| 2362 | |
| 2363 | void __stdcall glBindTexture(GLenum target, GLuint texture) |
| 2364 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2365 | EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2366 | |
| 2367 | try |
| 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 | gl::Texture *textureObject = context->getTexture(texture); |
| 2374 | |
| 2375 | if (textureObject && textureObject->getTarget() != target && texture != 0) |
| 2376 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2377 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2378 | } |
| 2379 | |
| 2380 | switch (target) |
| 2381 | { |
| 2382 | case GL_TEXTURE_2D: |
| 2383 | context->bindTexture2D(texture); |
| 2384 | return; |
| 2385 | case GL_TEXTURE_CUBE_MAP: |
| 2386 | context->bindTextureCubeMap(texture); |
| 2387 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 2388 | case GL_TEXTURE_3D: |
| 2389 | if (context->getClientVersion() < 3) |
| 2390 | { |
| 2391 | return gl::error(GL_INVALID_ENUM); |
| 2392 | } |
| 2393 | context->bindTexture3D(texture); |
| 2394 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 2395 | case GL_TEXTURE_2D_ARRAY: |
| 2396 | if (context->getClientVersion() < 3) |
| 2397 | { |
| 2398 | return gl::error(GL_INVALID_ENUM); |
| 2399 | } |
| 2400 | context->bindTexture2DArray(texture); |
| 2401 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2402 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2403 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2404 | } |
| 2405 | } |
| 2406 | } |
| 2407 | catch(std::bad_alloc&) |
| 2408 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2409 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2410 | } |
| 2411 | } |
| 2412 | |
| 2413 | void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2414 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2415 | 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] | 2416 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2417 | |
| 2418 | try |
| 2419 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2420 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2421 | |
| 2422 | if (context) |
| 2423 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2424 | 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] | 2425 | } |
| 2426 | } |
| 2427 | catch(std::bad_alloc&) |
| 2428 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2429 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2430 | } |
| 2431 | } |
| 2432 | |
| 2433 | void __stdcall glBlendEquation(GLenum mode) |
| 2434 | { |
| 2435 | glBlendEquationSeparate(mode, mode); |
| 2436 | } |
| 2437 | |
| 2438 | void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 2439 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2440 | EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2441 | |
| 2442 | try |
| 2443 | { |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2444 | gl::Context *context = gl::getNonLostContext(); |
| 2445 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2446 | switch (modeRGB) |
| 2447 | { |
| 2448 | case GL_FUNC_ADD: |
| 2449 | case GL_FUNC_SUBTRACT: |
| 2450 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2451 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2452 | |
| 2453 | case GL_MIN: |
| 2454 | case GL_MAX: |
| 2455 | if (context && context->getClientVersion() < 3) |
| 2456 | { |
| 2457 | return gl::error(GL_INVALID_ENUM); |
| 2458 | } |
| 2459 | break; |
| 2460 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2461 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2462 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2463 | } |
| 2464 | |
| 2465 | switch (modeAlpha) |
| 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 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2484 | if (context) |
| 2485 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2486 | context->setBlendEquation(modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2487 | } |
| 2488 | } |
| 2489 | catch(std::bad_alloc&) |
| 2490 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2491 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2492 | } |
| 2493 | } |
| 2494 | |
| 2495 | void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor) |
| 2496 | { |
| 2497 | glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor); |
| 2498 | } |
| 2499 | |
| 2500 | void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 2501 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2502 | 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] | 2503 | srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2504 | |
| 2505 | try |
| 2506 | { |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2507 | gl::Context *context = gl::getNonLostContext(); |
| 2508 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2509 | switch (srcRGB) |
| 2510 | { |
| 2511 | case GL_ZERO: |
| 2512 | case GL_ONE: |
| 2513 | case GL_SRC_COLOR: |
| 2514 | case GL_ONE_MINUS_SRC_COLOR: |
| 2515 | case GL_DST_COLOR: |
| 2516 | case GL_ONE_MINUS_DST_COLOR: |
| 2517 | case GL_SRC_ALPHA: |
| 2518 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2519 | case GL_DST_ALPHA: |
| 2520 | case GL_ONE_MINUS_DST_ALPHA: |
| 2521 | case GL_CONSTANT_COLOR: |
| 2522 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2523 | case GL_CONSTANT_ALPHA: |
| 2524 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2525 | case GL_SRC_ALPHA_SATURATE: |
| 2526 | break; |
| 2527 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2528 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2529 | } |
| 2530 | |
| 2531 | switch (dstRGB) |
| 2532 | { |
| 2533 | case GL_ZERO: |
| 2534 | case GL_ONE: |
| 2535 | case GL_SRC_COLOR: |
| 2536 | case GL_ONE_MINUS_SRC_COLOR: |
| 2537 | case GL_DST_COLOR: |
| 2538 | case GL_ONE_MINUS_DST_COLOR: |
| 2539 | case GL_SRC_ALPHA: |
| 2540 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2541 | case GL_DST_ALPHA: |
| 2542 | case GL_ONE_MINUS_DST_ALPHA: |
| 2543 | case GL_CONSTANT_COLOR: |
| 2544 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2545 | case GL_CONSTANT_ALPHA: |
| 2546 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2547 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2548 | |
| 2549 | case GL_SRC_ALPHA_SATURATE: |
| 2550 | if (!context || context->getClientVersion() < 3) |
| 2551 | { |
| 2552 | return gl::error(GL_INVALID_ENUM); |
| 2553 | } |
| 2554 | break; |
| 2555 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2556 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2557 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2558 | } |
| 2559 | |
| 2560 | switch (srcAlpha) |
| 2561 | { |
| 2562 | case GL_ZERO: |
| 2563 | case GL_ONE: |
| 2564 | case GL_SRC_COLOR: |
| 2565 | case GL_ONE_MINUS_SRC_COLOR: |
| 2566 | case GL_DST_COLOR: |
| 2567 | case GL_ONE_MINUS_DST_COLOR: |
| 2568 | case GL_SRC_ALPHA: |
| 2569 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2570 | case GL_DST_ALPHA: |
| 2571 | case GL_ONE_MINUS_DST_ALPHA: |
| 2572 | case GL_CONSTANT_COLOR: |
| 2573 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2574 | case GL_CONSTANT_ALPHA: |
| 2575 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2576 | case GL_SRC_ALPHA_SATURATE: |
| 2577 | break; |
| 2578 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2579 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2580 | } |
| 2581 | |
| 2582 | switch (dstAlpha) |
| 2583 | { |
| 2584 | case GL_ZERO: |
| 2585 | case GL_ONE: |
| 2586 | case GL_SRC_COLOR: |
| 2587 | case GL_ONE_MINUS_SRC_COLOR: |
| 2588 | case GL_DST_COLOR: |
| 2589 | case GL_ONE_MINUS_DST_COLOR: |
| 2590 | case GL_SRC_ALPHA: |
| 2591 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2592 | case GL_DST_ALPHA: |
| 2593 | case GL_ONE_MINUS_DST_ALPHA: |
| 2594 | case GL_CONSTANT_COLOR: |
| 2595 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2596 | case GL_CONSTANT_ALPHA: |
| 2597 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2598 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2599 | |
| 2600 | case GL_SRC_ALPHA_SATURATE: |
| 2601 | if (!context || context->getClientVersion() < 3) |
| 2602 | { |
| 2603 | return gl::error(GL_INVALID_ENUM); |
| 2604 | } |
| 2605 | break; |
| 2606 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2607 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2608 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2609 | } |
| 2610 | |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2611 | bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR || |
| 2612 | dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR); |
| 2613 | |
| 2614 | bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA || |
| 2615 | dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA); |
| 2616 | |
| 2617 | if (constantColorUsed && constantAlphaUsed) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2618 | { |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2619 | 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] | 2620 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2621 | } |
| 2622 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2623 | if (context) |
| 2624 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2625 | context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2626 | } |
| 2627 | } |
| 2628 | catch(std::bad_alloc&) |
| 2629 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2630 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2631 | } |
| 2632 | } |
| 2633 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2634 | 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] | 2635 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2636 | 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] | 2637 | target, size, data, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2638 | |
| 2639 | try |
| 2640 | { |
| 2641 | if (size < 0) |
| 2642 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2643 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2644 | } |
| 2645 | |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2646 | gl::Context *context = gl::getNonLostContext(); |
| 2647 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2648 | switch (usage) |
| 2649 | { |
| 2650 | case GL_STREAM_DRAW: |
| 2651 | case GL_STATIC_DRAW: |
| 2652 | case GL_DYNAMIC_DRAW: |
| 2653 | break; |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2654 | |
| 2655 | case GL_STREAM_READ: |
| 2656 | case GL_STREAM_COPY: |
| 2657 | case GL_STATIC_READ: |
| 2658 | case GL_STATIC_COPY: |
| 2659 | case GL_DYNAMIC_READ: |
| 2660 | case GL_DYNAMIC_COPY: |
| 2661 | if (context && context->getClientVersion() < 3) |
| 2662 | { |
| 2663 | return gl::error(GL_INVALID_ENUM); |
| 2664 | } |
| 2665 | break; |
| 2666 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2667 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2668 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2669 | } |
| 2670 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2671 | if (context) |
| 2672 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2673 | // Check ES3 specific targets |
| 2674 | switch (target) |
| 2675 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2676 | case GL_COPY_READ_BUFFER: |
| 2677 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2678 | case GL_PIXEL_PACK_BUFFER: |
| 2679 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2680 | case GL_UNIFORM_BUFFER: |
| 2681 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2682 | if (context->getClientVersion() < 3) |
| 2683 | { |
| 2684 | return gl::error(GL_INVALID_ENUM); |
| 2685 | } |
| 2686 | } |
| 2687 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2688 | gl::Buffer *buffer; |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2689 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2690 | switch (target) |
| 2691 | { |
| 2692 | case GL_ARRAY_BUFFER: |
| 2693 | buffer = context->getArrayBuffer(); |
| 2694 | break; |
| 2695 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2696 | buffer = context->getElementArrayBuffer(); |
| 2697 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2698 | case GL_COPY_READ_BUFFER: |
| 2699 | buffer = context->getCopyReadBuffer(); |
| 2700 | break; |
| 2701 | case GL_COPY_WRITE_BUFFER: |
| 2702 | buffer = context->getCopyWriteBuffer(); |
| 2703 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2704 | case GL_PIXEL_PACK_BUFFER: |
| 2705 | buffer = context->getPixelPackBuffer(); |
| 2706 | break; |
| 2707 | case GL_PIXEL_UNPACK_BUFFER: |
| 2708 | buffer = context->getPixelUnpackBuffer(); |
| 2709 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2710 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2711 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2712 | break; |
| 2713 | case GL_UNIFORM_BUFFER: |
| 2714 | buffer = context->getGenericUniformBuffer(); |
| 2715 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2716 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2717 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2718 | } |
| 2719 | |
| 2720 | if (!buffer) |
| 2721 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2722 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2723 | } |
| 2724 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2725 | buffer->bufferData(data, size, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2726 | } |
| 2727 | } |
| 2728 | catch(std::bad_alloc&) |
| 2729 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2730 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2731 | } |
| 2732 | } |
| 2733 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2734 | 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] | 2735 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2736 | 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] | 2737 | target, offset, size, data); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2738 | |
| 2739 | try |
| 2740 | { |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2741 | if (size < 0 || offset < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2742 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2743 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2744 | } |
| 2745 | |
daniel@transgaming.com | d4620a3 | 2010-03-21 04:31:28 +0000 | [diff] [blame] | 2746 | if (data == NULL) |
| 2747 | { |
| 2748 | return; |
| 2749 | } |
| 2750 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2751 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2752 | |
| 2753 | if (context) |
| 2754 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2755 | // Check ES3 specific targets |
| 2756 | switch (target) |
| 2757 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2758 | case GL_COPY_READ_BUFFER: |
| 2759 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2760 | case GL_PIXEL_PACK_BUFFER: |
| 2761 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2762 | case GL_UNIFORM_BUFFER: |
| 2763 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2764 | if (context->getClientVersion() < 3) |
| 2765 | { |
| 2766 | return gl::error(GL_INVALID_ENUM); |
| 2767 | } |
| 2768 | } |
| 2769 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2770 | gl::Buffer *buffer; |
| 2771 | |
| 2772 | switch (target) |
| 2773 | { |
| 2774 | case GL_ARRAY_BUFFER: |
| 2775 | buffer = context->getArrayBuffer(); |
| 2776 | break; |
| 2777 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2778 | buffer = context->getElementArrayBuffer(); |
| 2779 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2780 | case GL_COPY_READ_BUFFER: |
| 2781 | buffer = context->getCopyReadBuffer(); |
| 2782 | break; |
| 2783 | case GL_COPY_WRITE_BUFFER: |
| 2784 | buffer = context->getCopyWriteBuffer(); |
| 2785 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2786 | case GL_PIXEL_PACK_BUFFER: |
| 2787 | buffer = context->getPixelPackBuffer(); |
| 2788 | break; |
| 2789 | case GL_PIXEL_UNPACK_BUFFER: |
| 2790 | buffer = context->getPixelUnpackBuffer(); |
| 2791 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2792 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2793 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2794 | break; |
| 2795 | case GL_UNIFORM_BUFFER: |
| 2796 | buffer = context->getGenericUniformBuffer(); |
| 2797 | break; |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2798 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2799 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2800 | } |
| 2801 | |
| 2802 | if (!buffer) |
| 2803 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2804 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2805 | } |
| 2806 | |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2807 | if ((size_t)size + offset > buffer->size()) |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2808 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2809 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2810 | } |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2811 | |
| 2812 | buffer->bufferSubData(data, size, offset); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2813 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2814 | } |
| 2815 | catch(std::bad_alloc&) |
| 2816 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2817 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2818 | } |
| 2819 | } |
| 2820 | |
| 2821 | GLenum __stdcall glCheckFramebufferStatus(GLenum target) |
| 2822 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2823 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2824 | |
| 2825 | try |
| 2826 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2827 | 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] | 2828 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2829 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2830 | } |
| 2831 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2832 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2833 | |
| 2834 | if (context) |
| 2835 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2836 | gl::Framebuffer *framebuffer = NULL; |
| 2837 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 2838 | { |
| 2839 | framebuffer = context->getReadFramebuffer(); |
| 2840 | } |
| 2841 | else |
| 2842 | { |
| 2843 | framebuffer = context->getDrawFramebuffer(); |
| 2844 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2845 | |
| 2846 | return framebuffer->completeness(); |
| 2847 | } |
| 2848 | } |
| 2849 | catch(std::bad_alloc&) |
| 2850 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2851 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2852 | } |
| 2853 | |
| 2854 | return 0; |
| 2855 | } |
| 2856 | |
| 2857 | void __stdcall glClear(GLbitfield mask) |
| 2858 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2859 | EVENT("(GLbitfield mask = 0x%X)", mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2860 | |
| 2861 | try |
| 2862 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2863 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2864 | |
| 2865 | if (context) |
| 2866 | { |
| 2867 | context->clear(mask); |
| 2868 | } |
| 2869 | } |
| 2870 | catch(std::bad_alloc&) |
| 2871 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2872 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2873 | } |
| 2874 | } |
| 2875 | |
| 2876 | void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2877 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2878 | 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] | 2879 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2880 | |
| 2881 | try |
| 2882 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2883 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2884 | |
| 2885 | if (context) |
| 2886 | { |
| 2887 | context->setClearColor(red, green, blue, alpha); |
| 2888 | } |
| 2889 | } |
| 2890 | catch(std::bad_alloc&) |
| 2891 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2892 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2893 | } |
| 2894 | } |
| 2895 | |
| 2896 | void __stdcall glClearDepthf(GLclampf depth) |
| 2897 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2898 | EVENT("(GLclampf depth = %f)", depth); |
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->setClearDepth(depth); |
| 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 glClearStencil(GLint s) |
| 2916 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2917 | EVENT("(GLint s = %d)", s); |
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->setClearStencil(s); |
| 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 glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 2935 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2936 | 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] | 2937 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2938 | |
| 2939 | try |
| 2940 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2941 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2942 | |
| 2943 | if (context) |
| 2944 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 2945 | 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] | 2946 | } |
| 2947 | } |
| 2948 | catch(std::bad_alloc&) |
| 2949 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2950 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2951 | } |
| 2952 | } |
| 2953 | |
| 2954 | void __stdcall glCompileShader(GLuint shader) |
| 2955 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2956 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2957 | |
| 2958 | try |
| 2959 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2960 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2961 | |
| 2962 | if (context) |
| 2963 | { |
| 2964 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2965 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2966 | if (!shaderObject) |
| 2967 | { |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2968 | if (context->getProgram(shader)) |
| 2969 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2970 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2971 | } |
| 2972 | else |
| 2973 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2974 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2975 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2976 | } |
| 2977 | |
| 2978 | shaderObject->compile(); |
| 2979 | } |
| 2980 | } |
| 2981 | catch(std::bad_alloc&) |
| 2982 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2983 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2984 | } |
| 2985 | } |
| 2986 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2987 | void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, |
| 2988 | GLint border, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2989 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2990 | 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] | 2991 | "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] | 2992 | target, level, internalformat, width, height, border, imageSize, data); |
| 2993 | |
| 2994 | try |
| 2995 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2996 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2997 | |
| 2998 | if (context) |
| 2999 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3000 | if (context->getClientVersion() < 3 && |
| 3001 | !validateES2TexImageParameters(context, target, level, internalformat, true, false, |
| 3002 | 0, 0, width, height, 0, GL_NONE, GL_NONE, data)) |
| 3003 | { |
| 3004 | return; |
| 3005 | } |
| 3006 | |
| 3007 | if (context->getClientVersion() >= 3 && |
| 3008 | !validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 3009 | 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 3010 | { |
| 3011 | return; |
| 3012 | } |
| 3013 | |
| 3014 | 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] | 3015 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3016 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3017 | } |
| 3018 | |
| 3019 | switch (target) |
| 3020 | { |
| 3021 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3022 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3023 | gl::Texture2D *texture = context->getTexture2D(); |
| 3024 | texture->setCompressedImage(level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3025 | } |
| 3026 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3027 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3028 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3029 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3030 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3031 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3032 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3033 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3034 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3035 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3036 | texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3037 | } |
| 3038 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3039 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3040 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3041 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3042 | } |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3043 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3044 | } |
| 3045 | catch(std::bad_alloc&) |
| 3046 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3047 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3048 | } |
| 3049 | } |
| 3050 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3051 | void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 3052 | GLenum format, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3053 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3054 | 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] | 3055 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3056 | "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3057 | target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 3058 | |
| 3059 | try |
| 3060 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3061 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3062 | |
| 3063 | if (context) |
| 3064 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3065 | if (context->getClientVersion() < 3 && |
| 3066 | !validateES2TexImageParameters(context, target, level, GL_NONE, true, true, |
| 3067 | xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data)) |
| 3068 | { |
| 3069 | return; |
| 3070 | } |
| 3071 | |
| 3072 | if (context->getClientVersion() >= 3 && |
| 3073 | !validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 3074 | xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 3075 | { |
| 3076 | return; |
| 3077 | } |
| 3078 | |
| 3079 | 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] | 3080 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3081 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3082 | } |
| 3083 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3084 | switch (target) |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3085 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3086 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3087 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3088 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 3089 | texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3090 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3091 | break; |
| 3092 | |
| 3093 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3094 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3095 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3096 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3097 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3098 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3099 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3100 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 3101 | texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3102 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3103 | break; |
| 3104 | |
| 3105 | default: |
| 3106 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3107 | } |
| 3108 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3109 | } |
| 3110 | catch(std::bad_alloc&) |
| 3111 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3112 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3113 | } |
| 3114 | } |
| 3115 | |
| 3116 | void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) |
| 3117 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3118 | 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] | 3119 | "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] | 3120 | target, level, internalformat, x, y, width, height, border); |
| 3121 | |
| 3122 | try |
| 3123 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3124 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3125 | |
| 3126 | if (context) |
| 3127 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3128 | if (context->getClientVersion() < 3 && |
| 3129 | !validateES2CopyTexImageParameters(context, target, level, internalformat, false, |
| 3130 | 0, 0, x, y, width, height, border)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 3131 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3132 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 3133 | } |
| 3134 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3135 | if (context->getClientVersion() >= 3 && |
| 3136 | !validateES3CopyTexImageParameters(context, target, level, internalformat, false, |
| 3137 | 0, 0, 0, x, y, width, height, border)) |
| 3138 | { |
| 3139 | return; |
| 3140 | } |
| 3141 | |
| 3142 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 3143 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3144 | switch (target) |
| 3145 | { |
| 3146 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3147 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3148 | gl::Texture2D *texture = context->getTexture2D(); |
| 3149 | texture->copyImage(level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3150 | } |
| 3151 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3152 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3153 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3154 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3155 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3156 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3157 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3158 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3159 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3160 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3161 | texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3162 | } |
| 3163 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3164 | |
| 3165 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3166 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3167 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3168 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3169 | } |
| 3170 | catch(std::bad_alloc&) |
| 3171 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3172 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3173 | } |
| 3174 | } |
| 3175 | |
| 3176 | void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 3177 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3178 | 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] | 3179 | "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] | 3180 | target, level, xoffset, yoffset, x, y, width, height); |
| 3181 | |
| 3182 | try |
| 3183 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3184 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3185 | |
| 3186 | if (context) |
| 3187 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3188 | if (context->getClientVersion() < 3 && |
| 3189 | !validateES2CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 3190 | xoffset, yoffset, x, y, width, height, 0)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3191 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3192 | return; |
| 3193 | } |
| 3194 | |
| 3195 | if (context->getClientVersion() >= 3 && |
| 3196 | !validateES3CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 3197 | xoffset, yoffset, 0, x, y, width, height, 0)) |
| 3198 | { |
| 3199 | return; |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3200 | } |
| 3201 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3202 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3203 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3204 | switch (target) |
daniel@transgaming.com | bbc5779 | 2010-07-28 19:21:05 +0000 | [diff] [blame] | 3205 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3206 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 3207 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3208 | gl::Texture2D *texture = context->getTexture2D(); |
| 3209 | 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] | 3210 | } |
| 3211 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3212 | |
| 3213 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3214 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3215 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3216 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3217 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3218 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 3219 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3220 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3221 | 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] | 3222 | } |
| 3223 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3224 | |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3225 | default: |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3226 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3227 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3228 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3229 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3230 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3231 | catch(std::bad_alloc&) |
| 3232 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3233 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3234 | } |
| 3235 | } |
| 3236 | |
| 3237 | GLuint __stdcall glCreateProgram(void) |
| 3238 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3239 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3240 | |
| 3241 | try |
| 3242 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3243 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3244 | |
| 3245 | if (context) |
| 3246 | { |
| 3247 | return context->createProgram(); |
| 3248 | } |
| 3249 | } |
| 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, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3253 | } |
| 3254 | |
| 3255 | return 0; |
| 3256 | } |
| 3257 | |
| 3258 | GLuint __stdcall glCreateShader(GLenum type) |
| 3259 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3260 | EVENT("(GLenum type = 0x%X)", type); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3261 | |
| 3262 | try |
| 3263 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3264 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3265 | |
| 3266 | if (context) |
| 3267 | { |
| 3268 | switch (type) |
| 3269 | { |
| 3270 | case GL_FRAGMENT_SHADER: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 3271 | case GL_VERTEX_SHADER: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3272 | return context->createShader(type); |
| 3273 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3274 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3275 | } |
| 3276 | } |
| 3277 | } |
| 3278 | catch(std::bad_alloc&) |
| 3279 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3280 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3281 | } |
| 3282 | |
| 3283 | return 0; |
| 3284 | } |
| 3285 | |
| 3286 | void __stdcall glCullFace(GLenum mode) |
| 3287 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3288 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3289 | |
| 3290 | try |
| 3291 | { |
| 3292 | switch (mode) |
| 3293 | { |
| 3294 | case GL_FRONT: |
| 3295 | case GL_BACK: |
| 3296 | case GL_FRONT_AND_BACK: |
| 3297 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3298 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3299 | |
| 3300 | if (context) |
| 3301 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3302 | context->setCullMode(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3303 | } |
| 3304 | } |
| 3305 | break; |
| 3306 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3307 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3308 | } |
| 3309 | } |
| 3310 | catch(std::bad_alloc&) |
| 3311 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3312 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3313 | } |
| 3314 | } |
| 3315 | |
| 3316 | void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers) |
| 3317 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3318 | 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] | 3319 | |
| 3320 | try |
| 3321 | { |
| 3322 | if (n < 0) |
| 3323 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3324 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3325 | } |
| 3326 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3327 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3328 | |
| 3329 | if (context) |
| 3330 | { |
| 3331 | for (int i = 0; i < n; i++) |
| 3332 | { |
| 3333 | context->deleteBuffer(buffers[i]); |
| 3334 | } |
| 3335 | } |
| 3336 | } |
| 3337 | catch(std::bad_alloc&) |
| 3338 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3339 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3340 | } |
| 3341 | } |
| 3342 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3343 | void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences) |
| 3344 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3345 | 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] | 3346 | |
| 3347 | try |
| 3348 | { |
| 3349 | if (n < 0) |
| 3350 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3351 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3352 | } |
| 3353 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3354 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3355 | |
| 3356 | if (context) |
| 3357 | { |
| 3358 | for (int i = 0; i < n; i++) |
| 3359 | { |
| 3360 | context->deleteFence(fences[i]); |
| 3361 | } |
| 3362 | } |
| 3363 | } |
| 3364 | catch(std::bad_alloc&) |
| 3365 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3366 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3367 | } |
| 3368 | } |
| 3369 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3370 | void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) |
| 3371 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3372 | 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] | 3373 | |
| 3374 | try |
| 3375 | { |
| 3376 | if (n < 0) |
| 3377 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3378 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3379 | } |
| 3380 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3381 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3382 | |
| 3383 | if (context) |
| 3384 | { |
| 3385 | for (int i = 0; i < n; i++) |
| 3386 | { |
| 3387 | if (framebuffers[i] != 0) |
| 3388 | { |
| 3389 | context->deleteFramebuffer(framebuffers[i]); |
| 3390 | } |
| 3391 | } |
| 3392 | } |
| 3393 | } |
| 3394 | catch(std::bad_alloc&) |
| 3395 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3396 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3397 | } |
| 3398 | } |
| 3399 | |
| 3400 | void __stdcall glDeleteProgram(GLuint program) |
| 3401 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3402 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3403 | |
| 3404 | try |
| 3405 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3406 | if (program == 0) |
| 3407 | { |
| 3408 | return; |
| 3409 | } |
| 3410 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3411 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3412 | |
| 3413 | if (context) |
| 3414 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3415 | if (!context->getProgram(program)) |
| 3416 | { |
| 3417 | if(context->getShader(program)) |
| 3418 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3419 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3420 | } |
| 3421 | else |
| 3422 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3423 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3424 | } |
| 3425 | } |
| 3426 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3427 | context->deleteProgram(program); |
| 3428 | } |
| 3429 | } |
| 3430 | catch(std::bad_alloc&) |
| 3431 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3432 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3433 | } |
| 3434 | } |
| 3435 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3436 | void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids) |
| 3437 | { |
| 3438 | EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids); |
| 3439 | |
| 3440 | try |
| 3441 | { |
| 3442 | if (n < 0) |
| 3443 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3444 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3445 | } |
| 3446 | |
| 3447 | gl::Context *context = gl::getNonLostContext(); |
| 3448 | |
| 3449 | if (context) |
| 3450 | { |
| 3451 | for (int i = 0; i < n; i++) |
| 3452 | { |
| 3453 | context->deleteQuery(ids[i]); |
| 3454 | } |
| 3455 | } |
| 3456 | } |
| 3457 | catch(std::bad_alloc&) |
| 3458 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3459 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3460 | } |
| 3461 | } |
| 3462 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3463 | void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) |
| 3464 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3465 | 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] | 3466 | |
| 3467 | try |
| 3468 | { |
| 3469 | if (n < 0) |
| 3470 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3471 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3472 | } |
| 3473 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3474 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3475 | |
| 3476 | if (context) |
| 3477 | { |
daniel@transgaming.com | e2b2212 | 2010-03-11 19:22:14 +0000 | [diff] [blame] | 3478 | for (int i = 0; i < n; i++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3479 | { |
| 3480 | context->deleteRenderbuffer(renderbuffers[i]); |
| 3481 | } |
| 3482 | } |
| 3483 | } |
| 3484 | catch(std::bad_alloc&) |
| 3485 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3486 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3487 | } |
| 3488 | } |
| 3489 | |
| 3490 | void __stdcall glDeleteShader(GLuint shader) |
| 3491 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3492 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3493 | |
| 3494 | try |
| 3495 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3496 | if (shader == 0) |
| 3497 | { |
| 3498 | return; |
| 3499 | } |
| 3500 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3501 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3502 | |
| 3503 | if (context) |
| 3504 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3505 | if (!context->getShader(shader)) |
| 3506 | { |
| 3507 | if(context->getProgram(shader)) |
| 3508 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3509 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3510 | } |
| 3511 | else |
| 3512 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3513 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3514 | } |
| 3515 | } |
| 3516 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3517 | context->deleteShader(shader); |
| 3518 | } |
| 3519 | } |
| 3520 | catch(std::bad_alloc&) |
| 3521 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3522 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3523 | } |
| 3524 | } |
| 3525 | |
| 3526 | void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures) |
| 3527 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3528 | 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] | 3529 | |
| 3530 | try |
| 3531 | { |
| 3532 | if (n < 0) |
| 3533 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3534 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3535 | } |
| 3536 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3537 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3538 | |
| 3539 | if (context) |
| 3540 | { |
| 3541 | for (int i = 0; i < n; i++) |
| 3542 | { |
| 3543 | if (textures[i] != 0) |
| 3544 | { |
| 3545 | context->deleteTexture(textures[i]); |
| 3546 | } |
| 3547 | } |
| 3548 | } |
| 3549 | } |
| 3550 | catch(std::bad_alloc&) |
| 3551 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3552 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3553 | } |
| 3554 | } |
| 3555 | |
| 3556 | void __stdcall glDepthFunc(GLenum func) |
| 3557 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3558 | EVENT("(GLenum func = 0x%X)", func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3559 | |
| 3560 | try |
| 3561 | { |
| 3562 | switch (func) |
| 3563 | { |
| 3564 | case GL_NEVER: |
| 3565 | case GL_ALWAYS: |
| 3566 | case GL_LESS: |
| 3567 | case GL_LEQUAL: |
| 3568 | case GL_EQUAL: |
| 3569 | case GL_GREATER: |
| 3570 | case GL_GEQUAL: |
| 3571 | case GL_NOTEQUAL: |
| 3572 | break; |
| 3573 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3574 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3575 | } |
| 3576 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3577 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3578 | |
| 3579 | if (context) |
| 3580 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3581 | context->setDepthFunc(func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3582 | } |
| 3583 | } |
| 3584 | catch(std::bad_alloc&) |
| 3585 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3586 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3587 | } |
| 3588 | } |
| 3589 | |
| 3590 | void __stdcall glDepthMask(GLboolean flag) |
| 3591 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 3592 | EVENT("(GLboolean flag = %u)", flag); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3593 | |
| 3594 | try |
| 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->setDepthMask(flag != GL_FALSE); |
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 glDepthRangef(GLclampf zNear, GLclampf zFar) |
| 3610 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3611 | EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar); |
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->setDepthRange(zNear, zFar); |
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 glDetachShader(GLuint program, GLuint shader) |
| 3629 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3630 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
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 | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3638 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3639 | gl::Program *programObject = context->getProgram(program); |
| 3640 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3641 | |
| 3642 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3643 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3644 | gl::Shader *shaderByProgramHandle; |
| 3645 | shaderByProgramHandle = context->getShader(program); |
| 3646 | if (!shaderByProgramHandle) |
| 3647 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3648 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3649 | } |
| 3650 | else |
| 3651 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3652 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3653 | } |
| 3654 | } |
| 3655 | |
| 3656 | if (!shaderObject) |
| 3657 | { |
| 3658 | gl::Program *programByShaderHandle = context->getProgram(shader); |
| 3659 | if (!programByShaderHandle) |
| 3660 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3661 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3662 | } |
| 3663 | else |
| 3664 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3665 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3666 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3667 | } |
| 3668 | |
| 3669 | if (!programObject->detachShader(shaderObject)) |
| 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 | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3672 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3673 | } |
| 3674 | } |
| 3675 | catch(std::bad_alloc&) |
| 3676 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3677 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3678 | } |
| 3679 | } |
| 3680 | |
| 3681 | void __stdcall glDisable(GLenum cap) |
| 3682 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3683 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3684 | |
| 3685 | try |
| 3686 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3687 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3688 | |
| 3689 | if (context) |
| 3690 | { |
| 3691 | switch (cap) |
| 3692 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3693 | case GL_CULL_FACE: context->setCullFace(false); break; |
| 3694 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break; |
| 3695 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break; |
| 3696 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break; |
| 3697 | case GL_SCISSOR_TEST: context->setScissorTest(false); break; |
| 3698 | case GL_STENCIL_TEST: context->setStencilTest(false); break; |
| 3699 | case GL_DEPTH_TEST: context->setDepthTest(false); break; |
| 3700 | case GL_BLEND: context->setBlend(false); break; |
| 3701 | case GL_DITHER: context->setDither(false); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 3702 | |
| 3703 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 3704 | case GL_RASTERIZER_DISCARD: |
| 3705 | if (context->getClientVersion() < 3) |
| 3706 | { |
| 3707 | return gl::error(GL_INVALID_ENUM); |
| 3708 | } |
| 3709 | UNIMPLEMENTED(); |
| 3710 | break; |
| 3711 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3712 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3713 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3714 | } |
| 3715 | } |
| 3716 | } |
| 3717 | catch(std::bad_alloc&) |
| 3718 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3719 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3720 | } |
| 3721 | } |
| 3722 | |
| 3723 | void __stdcall glDisableVertexAttribArray(GLuint index) |
| 3724 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3725 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3726 | |
| 3727 | try |
| 3728 | { |
| 3729 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3730 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3731 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3732 | } |
| 3733 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3734 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3735 | |
| 3736 | if (context) |
| 3737 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3738 | context->setEnableVertexAttribArray(index, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3739 | } |
| 3740 | } |
| 3741 | catch(std::bad_alloc&) |
| 3742 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3743 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3744 | } |
| 3745 | } |
| 3746 | |
| 3747 | void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count) |
| 3748 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3749 | 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] | 3750 | |
| 3751 | try |
| 3752 | { |
| 3753 | if (count < 0 || first < 0) |
| 3754 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3755 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3756 | } |
| 3757 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3758 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3759 | |
| 3760 | if (context) |
| 3761 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3762 | context->drawArrays(mode, first, count, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3763 | } |
| 3764 | } |
| 3765 | catch(std::bad_alloc&) |
| 3766 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3767 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3768 | } |
| 3769 | } |
| 3770 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3771 | void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
| 3772 | { |
| 3773 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount); |
| 3774 | |
| 3775 | try |
| 3776 | { |
| 3777 | if (count < 0 || first < 0 || primcount < 0) |
| 3778 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3779 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3780 | } |
| 3781 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3782 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3783 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3784 | gl::Context *context = gl::getNonLostContext(); |
| 3785 | |
| 3786 | if (context) |
| 3787 | { |
| 3788 | context->drawArrays(mode, first, count, primcount); |
| 3789 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3790 | } |
| 3791 | } |
| 3792 | catch(std::bad_alloc&) |
| 3793 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3794 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3795 | } |
| 3796 | } |
| 3797 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3798 | 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] | 3799 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3800 | 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] | 3801 | mode, count, type, indices); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3802 | |
| 3803 | try |
| 3804 | { |
| 3805 | if (count < 0) |
| 3806 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3807 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3808 | } |
| 3809 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3810 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3811 | |
| 3812 | if (context) |
| 3813 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3814 | switch (type) |
| 3815 | { |
| 3816 | case GL_UNSIGNED_BYTE: |
| 3817 | case GL_UNSIGNED_SHORT: |
| 3818 | break; |
| 3819 | case GL_UNSIGNED_INT: |
| 3820 | if (!context->supports32bitIndices()) |
| 3821 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3822 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3823 | } |
| 3824 | break; |
| 3825 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3826 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3827 | } |
| 3828 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3829 | context->drawElements(mode, count, type, indices, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3830 | } |
| 3831 | } |
| 3832 | catch(std::bad_alloc&) |
| 3833 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3834 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3835 | } |
| 3836 | } |
| 3837 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3838 | void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount) |
| 3839 | { |
| 3840 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)", |
| 3841 | mode, count, type, indices, primcount); |
| 3842 | |
| 3843 | try |
| 3844 | { |
| 3845 | if (count < 0 || primcount < 0) |
| 3846 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3847 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3848 | } |
| 3849 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3850 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3851 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3852 | gl::Context *context = gl::getNonLostContext(); |
| 3853 | |
| 3854 | if (context) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3855 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3856 | switch (type) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3857 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3858 | case GL_UNSIGNED_BYTE: |
| 3859 | case GL_UNSIGNED_SHORT: |
| 3860 | break; |
| 3861 | case GL_UNSIGNED_INT: |
| 3862 | if (!context->supports32bitIndices()) |
| 3863 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3864 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3865 | } |
| 3866 | break; |
| 3867 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3868 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3869 | } |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3870 | |
| 3871 | context->drawElements(mode, count, type, indices, primcount); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3872 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3873 | } |
| 3874 | } |
| 3875 | catch(std::bad_alloc&) |
| 3876 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3877 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3878 | } |
| 3879 | } |
| 3880 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3881 | void __stdcall glEnable(GLenum cap) |
| 3882 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3883 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3884 | |
| 3885 | try |
| 3886 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3887 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3888 | |
| 3889 | if (context) |
| 3890 | { |
| 3891 | switch (cap) |
| 3892 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3893 | case GL_CULL_FACE: context->setCullFace(true); break; |
| 3894 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break; |
| 3895 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break; |
| 3896 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break; |
| 3897 | case GL_SCISSOR_TEST: context->setScissorTest(true); break; |
| 3898 | case GL_STENCIL_TEST: context->setStencilTest(true); break; |
| 3899 | case GL_DEPTH_TEST: context->setDepthTest(true); break; |
| 3900 | case GL_BLEND: context->setBlend(true); break; |
| 3901 | case GL_DITHER: context->setDither(true); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3902 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3903 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3904 | } |
| 3905 | } |
| 3906 | } |
| 3907 | catch(std::bad_alloc&) |
| 3908 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3909 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3910 | } |
| 3911 | } |
| 3912 | |
| 3913 | void __stdcall glEnableVertexAttribArray(GLuint index) |
| 3914 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3915 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3916 | |
| 3917 | try |
| 3918 | { |
| 3919 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3920 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3921 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3922 | } |
| 3923 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3924 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3925 | |
| 3926 | if (context) |
| 3927 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3928 | context->setEnableVertexAttribArray(index, true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3929 | } |
| 3930 | } |
| 3931 | catch(std::bad_alloc&) |
| 3932 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3933 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3934 | } |
| 3935 | } |
| 3936 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3937 | void __stdcall glEndQueryEXT(GLenum target) |
| 3938 | { |
| 3939 | EVENT("GLenum target = 0x%X)", target); |
| 3940 | |
| 3941 | try |
| 3942 | { |
| 3943 | switch (target) |
| 3944 | { |
| 3945 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 3946 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 3947 | break; |
| 3948 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3949 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3950 | } |
| 3951 | |
| 3952 | gl::Context *context = gl::getNonLostContext(); |
| 3953 | |
| 3954 | if (context) |
| 3955 | { |
| 3956 | context->endQuery(target); |
| 3957 | } |
| 3958 | } |
| 3959 | catch(std::bad_alloc&) |
| 3960 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3961 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3962 | } |
| 3963 | } |
| 3964 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3965 | void __stdcall glFinishFenceNV(GLuint fence) |
| 3966 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3967 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3968 | |
| 3969 | try |
| 3970 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3971 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3972 | |
| 3973 | if (context) |
| 3974 | { |
| 3975 | gl::Fence* fenceObject = context->getFence(fence); |
| 3976 | |
| 3977 | if (fenceObject == NULL) |
| 3978 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3979 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3980 | } |
| 3981 | |
| 3982 | fenceObject->finishFence(); |
| 3983 | } |
| 3984 | } |
| 3985 | catch(std::bad_alloc&) |
| 3986 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3987 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3988 | } |
| 3989 | } |
| 3990 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3991 | void __stdcall glFinish(void) |
| 3992 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3993 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3994 | |
| 3995 | try |
| 3996 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3997 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3998 | |
| 3999 | if (context) |
| 4000 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 4001 | context->sync(true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 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); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4007 | } |
| 4008 | } |
| 4009 | |
| 4010 | void __stdcall glFlush(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(false); |
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 glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) |
| 4030 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4031 | 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] | 4032 | "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4033 | |
| 4034 | try |
| 4035 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4036 | 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] | 4037 | || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4038 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4039 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4040 | } |
| 4041 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4042 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4043 | |
| 4044 | if (context) |
| 4045 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4046 | gl::Framebuffer *framebuffer = NULL; |
| 4047 | GLuint framebufferHandle = 0; |
| 4048 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4049 | { |
| 4050 | framebuffer = context->getReadFramebuffer(); |
| 4051 | framebufferHandle = context->getReadFramebufferHandle(); |
| 4052 | } |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 4053 | else |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4054 | { |
| 4055 | framebuffer = context->getDrawFramebuffer(); |
| 4056 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 4057 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4058 | |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 4059 | if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4060 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4061 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4062 | } |
| 4063 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4064 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4065 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4066 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4067 | |
| 4068 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4069 | { |
| 4070 | return gl::error(GL_INVALID_VALUE); |
| 4071 | } |
| 4072 | |
| 4073 | framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer); |
| 4074 | } |
| 4075 | else |
| 4076 | { |
| 4077 | switch (attachment) |
| 4078 | { |
| 4079 | case GL_DEPTH_ATTACHMENT: |
| 4080 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer); |
| 4081 | break; |
| 4082 | case GL_STENCIL_ATTACHMENT: |
| 4083 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer); |
| 4084 | break; |
| 4085 | default: |
| 4086 | return gl::error(GL_INVALID_ENUM); |
| 4087 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4088 | } |
| 4089 | } |
| 4090 | } |
| 4091 | catch(std::bad_alloc&) |
| 4092 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4093 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4094 | } |
| 4095 | } |
| 4096 | |
| 4097 | void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) |
| 4098 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4099 | 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] | 4100 | "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4101 | |
| 4102 | try |
| 4103 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4104 | 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] | 4105 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4106 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4107 | } |
| 4108 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4109 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4110 | |
| 4111 | if (context) |
| 4112 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4113 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 4114 | { |
| 4115 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4116 | |
| 4117 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4118 | { |
| 4119 | return gl::error(GL_INVALID_VALUE); |
| 4120 | } |
| 4121 | } |
| 4122 | else |
| 4123 | { |
| 4124 | switch (attachment) |
| 4125 | { |
| 4126 | case GL_DEPTH_ATTACHMENT: |
| 4127 | case GL_STENCIL_ATTACHMENT: |
| 4128 | break; |
| 4129 | default: |
| 4130 | return gl::error(GL_INVALID_ENUM); |
| 4131 | } |
| 4132 | } |
| 4133 | |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4134 | if (texture == 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4135 | { |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4136 | textarget = GL_NONE; |
| 4137 | } |
| 4138 | else |
| 4139 | { |
| 4140 | gl::Texture *tex = context->getTexture(texture); |
| 4141 | |
| 4142 | if (tex == NULL) |
| 4143 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4144 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4145 | } |
| 4146 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4147 | switch (textarget) |
| 4148 | { |
| 4149 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4150 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4151 | if (tex->getTarget() != GL_TEXTURE_2D) |
| 4152 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4153 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4154 | } |
| 4155 | gl::Texture2D *tex2d = static_cast<gl::Texture2D *>(tex); |
daniel@transgaming.com | 92f4992 | 2012-05-09 15:49:19 +0000 | [diff] [blame] | 4156 | if (tex2d->isCompressed(0)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4157 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4158 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4159 | } |
| 4160 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4161 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4162 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4163 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4164 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4165 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4166 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4167 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4168 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4169 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4170 | if (tex->getTarget() != GL_TEXTURE_CUBE_MAP) |
| 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::TextureCubeMap *texcube = static_cast<gl::TextureCubeMap *>(tex); |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 4175 | if (texcube->isCompressed(textarget, level)) |
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 | 93a8147 | 2010-04-20 18:52:58 +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 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4183 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4184 | } |
| 4185 | |
| 4186 | if (level != 0) |
| 4187 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4188 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4189 | } |
| 4190 | } |
| 4191 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4192 | gl::Framebuffer *framebuffer = NULL; |
| 4193 | GLuint framebufferHandle = 0; |
| 4194 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4195 | { |
| 4196 | framebuffer = context->getReadFramebuffer(); |
| 4197 | framebufferHandle = context->getReadFramebufferHandle(); |
| 4198 | } |
| 4199 | else |
| 4200 | { |
| 4201 | framebuffer = context->getDrawFramebuffer(); |
| 4202 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 4203 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4204 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4205 | if (framebufferHandle == 0 || !framebuffer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4206 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4207 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4208 | } |
| 4209 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4210 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4211 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4212 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4213 | |
| 4214 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4215 | { |
| 4216 | return gl::error(GL_INVALID_VALUE); |
| 4217 | } |
| 4218 | |
| 4219 | framebuffer->setColorbuffer(colorAttachment, textarget, texture); |
| 4220 | } |
| 4221 | else |
| 4222 | { |
| 4223 | switch (attachment) |
| 4224 | { |
| 4225 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break; |
| 4226 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break; |
| 4227 | } |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4228 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4229 | } |
| 4230 | } |
| 4231 | catch(std::bad_alloc&) |
| 4232 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4233 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4234 | } |
| 4235 | } |
| 4236 | |
| 4237 | void __stdcall glFrontFace(GLenum mode) |
| 4238 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4239 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4240 | |
| 4241 | try |
| 4242 | { |
| 4243 | switch (mode) |
| 4244 | { |
| 4245 | case GL_CW: |
| 4246 | case GL_CCW: |
| 4247 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4248 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4249 | |
| 4250 | if (context) |
| 4251 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4252 | context->setFrontFace(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4253 | } |
| 4254 | } |
| 4255 | break; |
| 4256 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4257 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4258 | } |
| 4259 | } |
| 4260 | catch(std::bad_alloc&) |
| 4261 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4262 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4263 | } |
| 4264 | } |
| 4265 | |
| 4266 | void __stdcall glGenBuffers(GLsizei n, GLuint* buffers) |
| 4267 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4268 | EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4269 | |
| 4270 | try |
| 4271 | { |
| 4272 | if (n < 0) |
| 4273 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4274 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4275 | } |
| 4276 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4277 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4278 | |
| 4279 | if (context) |
| 4280 | { |
| 4281 | for (int i = 0; i < n; i++) |
| 4282 | { |
| 4283 | buffers[i] = context->createBuffer(); |
| 4284 | } |
| 4285 | } |
| 4286 | } |
| 4287 | catch(std::bad_alloc&) |
| 4288 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4289 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4290 | } |
| 4291 | } |
| 4292 | |
| 4293 | void __stdcall glGenerateMipmap(GLenum target) |
| 4294 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4295 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4296 | |
| 4297 | try |
| 4298 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4299 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4300 | |
| 4301 | if (context) |
| 4302 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4303 | gl::Texture *texture = NULL; |
| 4304 | GLint internalFormat = GL_NONE; |
| 4305 | bool isCompressed = false; |
| 4306 | bool isDepth = false; |
| 4307 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4308 | switch (target) |
| 4309 | { |
| 4310 | case GL_TEXTURE_2D: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4311 | { |
| 4312 | gl::Texture2D *tex2d = context->getTexture2D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4313 | if (tex2d) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4314 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4315 | internalFormat = tex2d->getInternalFormat(0); |
| 4316 | isCompressed = tex2d->isCompressed(0); |
| 4317 | isDepth = tex2d->isDepth(0); |
| 4318 | texture = tex2d; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4319 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4320 | break; |
| 4321 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4322 | |
| 4323 | case GL_TEXTURE_CUBE_MAP: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4324 | { |
| 4325 | gl::TextureCubeMap *texcube = context->getTextureCubeMap(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4326 | if (texcube) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4327 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4328 | internalFormat = texcube->getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 4329 | isCompressed = texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 4330 | isDepth = false; |
| 4331 | texture = texcube; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4332 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4333 | break; |
| 4334 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4335 | |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4336 | case GL_TEXTURE_3D: |
| 4337 | { |
| 4338 | if (context->getClientVersion() < 3) |
| 4339 | { |
| 4340 | return gl::error(GL_INVALID_ENUM); |
| 4341 | } |
| 4342 | |
| 4343 | gl::Texture3D *tex3D = context->getTexture3D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4344 | if (tex3D) |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4345 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4346 | internalFormat = tex3D->getInternalFormat(0); |
| 4347 | isCompressed = tex3D->isCompressed(0); |
| 4348 | isDepth = tex3D->isDepth(0); |
| 4349 | texture = tex3D; |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4350 | } |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4351 | break; |
| 4352 | } |
| 4353 | |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4354 | case GL_TEXTURE_2D_ARRAY: |
| 4355 | { |
| 4356 | if (context->getClientVersion() < 3) |
| 4357 | { |
| 4358 | return gl::error(GL_INVALID_ENUM); |
| 4359 | } |
| 4360 | |
| 4361 | gl::Texture2DArray *tex2darr = context->getTexture2DArray(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4362 | if (tex2darr) |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4363 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4364 | internalFormat = tex2darr->getInternalFormat(0); |
| 4365 | isCompressed = tex2darr->isCompressed(0); |
| 4366 | isDepth = tex2darr->isDepth(0); |
| 4367 | texture = tex2darr; |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4368 | } |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4369 | break; |
| 4370 | } |
| 4371 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4372 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4373 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4374 | } |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4375 | |
| 4376 | if (!texture) |
| 4377 | { |
| 4378 | return gl::error(GL_INVALID_OPERATION); |
| 4379 | } |
| 4380 | |
| 4381 | // Internally, all texture formats are sized so checking if the format |
| 4382 | // is color renderable and filterable will not fail. |
| 4383 | if (isDepth || isCompressed || |
| 4384 | !gl::IsColorRenderingSupported(internalFormat, context) || |
| 4385 | !gl::IsTextureFilteringSupported(internalFormat, context)) |
| 4386 | { |
| 4387 | return gl::error(GL_INVALID_OPERATION); |
| 4388 | } |
| 4389 | |
| 4390 | texture->generateMipmaps(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4391 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4392 | } |
| 4393 | catch(std::bad_alloc&) |
| 4394 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4395 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4396 | } |
| 4397 | } |
| 4398 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4399 | void __stdcall glGenFencesNV(GLsizei n, GLuint* fences) |
| 4400 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4401 | EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4402 | |
| 4403 | try |
| 4404 | { |
| 4405 | if (n < 0) |
| 4406 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4407 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4408 | } |
| 4409 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4410 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4411 | |
| 4412 | if (context) |
| 4413 | { |
| 4414 | for (int i = 0; i < n; i++) |
| 4415 | { |
| 4416 | fences[i] = context->createFence(); |
| 4417 | } |
| 4418 | } |
| 4419 | } |
| 4420 | catch(std::bad_alloc&) |
| 4421 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4422 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4423 | } |
| 4424 | } |
| 4425 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4426 | void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers) |
| 4427 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4428 | EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4429 | |
| 4430 | try |
| 4431 | { |
| 4432 | if (n < 0) |
| 4433 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4434 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4435 | } |
| 4436 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4437 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4438 | |
| 4439 | if (context) |
| 4440 | { |
| 4441 | for (int i = 0; i < n; i++) |
| 4442 | { |
| 4443 | framebuffers[i] = context->createFramebuffer(); |
| 4444 | } |
| 4445 | } |
| 4446 | } |
| 4447 | catch(std::bad_alloc&) |
| 4448 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4449 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4450 | } |
| 4451 | } |
| 4452 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4453 | void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids) |
| 4454 | { |
| 4455 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 4456 | |
| 4457 | try |
| 4458 | { |
| 4459 | if (n < 0) |
| 4460 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4461 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4462 | } |
| 4463 | |
| 4464 | gl::Context *context = gl::getNonLostContext(); |
| 4465 | |
| 4466 | if (context) |
| 4467 | { |
| 4468 | for (int i = 0; i < n; i++) |
| 4469 | { |
| 4470 | ids[i] = context->createQuery(); |
| 4471 | } |
| 4472 | } |
| 4473 | } |
| 4474 | catch(std::bad_alloc&) |
| 4475 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4476 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4477 | } |
| 4478 | } |
| 4479 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4480 | void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) |
| 4481 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4482 | EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4483 | |
| 4484 | try |
| 4485 | { |
| 4486 | if (n < 0) |
| 4487 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4488 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4489 | } |
| 4490 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4491 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4492 | |
| 4493 | if (context) |
| 4494 | { |
| 4495 | for (int i = 0; i < n; i++) |
| 4496 | { |
| 4497 | renderbuffers[i] = context->createRenderbuffer(); |
| 4498 | } |
| 4499 | } |
| 4500 | } |
| 4501 | catch(std::bad_alloc&) |
| 4502 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4503 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4504 | } |
| 4505 | } |
| 4506 | |
| 4507 | void __stdcall glGenTextures(GLsizei n, GLuint* textures) |
| 4508 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4509 | EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4510 | |
| 4511 | try |
| 4512 | { |
| 4513 | if (n < 0) |
| 4514 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4515 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4516 | } |
| 4517 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4518 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4519 | |
| 4520 | if (context) |
| 4521 | { |
| 4522 | for (int i = 0; i < n; i++) |
| 4523 | { |
| 4524 | textures[i] = context->createTexture(); |
| 4525 | } |
| 4526 | } |
| 4527 | } |
| 4528 | catch(std::bad_alloc&) |
| 4529 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4530 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4531 | } |
| 4532 | } |
| 4533 | |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4534 | 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] | 4535 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4536 | 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] | 4537 | "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] | 4538 | program, index, bufsize, length, size, type, name); |
| 4539 | |
| 4540 | try |
| 4541 | { |
| 4542 | if (bufsize < 0) |
| 4543 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4544 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4545 | } |
| 4546 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4547 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4548 | |
| 4549 | if (context) |
| 4550 | { |
| 4551 | gl::Program *programObject = context->getProgram(program); |
| 4552 | |
| 4553 | if (!programObject) |
| 4554 | { |
| 4555 | if (context->getShader(program)) |
| 4556 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4557 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4558 | } |
| 4559 | else |
| 4560 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4561 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4562 | } |
| 4563 | } |
| 4564 | |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4565 | if (index >= (GLuint)programObject->getActiveAttributeCount()) |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4566 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4567 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4568 | } |
| 4569 | |
| 4570 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 4571 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4572 | } |
| 4573 | catch(std::bad_alloc&) |
| 4574 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4575 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4576 | } |
| 4577 | } |
| 4578 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4579 | 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] | 4580 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4581 | EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4582 | "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] | 4583 | program, index, bufsize, length, size, type, name); |
| 4584 | |
| 4585 | try |
| 4586 | { |
| 4587 | if (bufsize < 0) |
| 4588 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4589 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4590 | } |
| 4591 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4592 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4593 | |
| 4594 | if (context) |
| 4595 | { |
| 4596 | gl::Program *programObject = context->getProgram(program); |
| 4597 | |
| 4598 | if (!programObject) |
| 4599 | { |
| 4600 | if (context->getShader(program)) |
| 4601 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4602 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4603 | } |
| 4604 | else |
| 4605 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4606 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4607 | } |
| 4608 | } |
| 4609 | |
| 4610 | if (index >= (GLuint)programObject->getActiveUniformCount()) |
| 4611 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4612 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4613 | } |
| 4614 | |
| 4615 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 4616 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4617 | } |
| 4618 | catch(std::bad_alloc&) |
| 4619 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4620 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4621 | } |
| 4622 | } |
| 4623 | |
| 4624 | void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) |
| 4625 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4626 | 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] | 4627 | program, maxcount, count, shaders); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4628 | |
| 4629 | try |
| 4630 | { |
| 4631 | if (maxcount < 0) |
| 4632 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4633 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4634 | } |
| 4635 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4636 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4637 | |
| 4638 | if (context) |
| 4639 | { |
| 4640 | gl::Program *programObject = context->getProgram(program); |
| 4641 | |
| 4642 | if (!programObject) |
| 4643 | { |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4644 | if (context->getShader(program)) |
| 4645 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4646 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4647 | } |
| 4648 | else |
| 4649 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4650 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4651 | } |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4652 | } |
| 4653 | |
| 4654 | return programObject->getAttachedShaders(maxcount, count, shaders); |
| 4655 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4656 | } |
| 4657 | catch(std::bad_alloc&) |
| 4658 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4659 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4660 | } |
| 4661 | } |
| 4662 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4663 | int __stdcall glGetAttribLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4664 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4665 | EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4666 | |
| 4667 | try |
| 4668 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4669 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4670 | |
| 4671 | if (context) |
| 4672 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4673 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4674 | gl::Program *programObject = context->getProgram(program); |
| 4675 | |
| 4676 | if (!programObject) |
| 4677 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4678 | if (context->getShader(program)) |
| 4679 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4680 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4681 | } |
| 4682 | else |
| 4683 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4684 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4685 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4686 | } |
| 4687 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4688 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 4689 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4690 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4691 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4692 | } |
| 4693 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4694 | return programBinary->getAttributeLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4695 | } |
| 4696 | } |
| 4697 | catch(std::bad_alloc&) |
| 4698 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4699 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4700 | } |
| 4701 | |
| 4702 | return -1; |
| 4703 | } |
| 4704 | |
| 4705 | void __stdcall glGetBooleanv(GLenum pname, GLboolean* params) |
| 4706 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4707 | 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] | 4708 | |
| 4709 | try |
| 4710 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4711 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4712 | |
| 4713 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4714 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4715 | if (!(context->getBooleanv(pname, params))) |
| 4716 | { |
| 4717 | GLenum nativeType; |
| 4718 | unsigned int numParams = 0; |
| 4719 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4720 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4721 | |
| 4722 | if (numParams == 0) |
| 4723 | return; // it is known that the pname is valid, but there are no parameters to return |
| 4724 | |
| 4725 | if (nativeType == GL_FLOAT) |
| 4726 | { |
| 4727 | GLfloat *floatParams = NULL; |
| 4728 | floatParams = new GLfloat[numParams]; |
| 4729 | |
| 4730 | context->getFloatv(pname, floatParams); |
| 4731 | |
| 4732 | for (unsigned int i = 0; i < numParams; ++i) |
| 4733 | { |
| 4734 | if (floatParams[i] == 0.0f) |
| 4735 | params[i] = GL_FALSE; |
| 4736 | else |
| 4737 | params[i] = GL_TRUE; |
| 4738 | } |
| 4739 | |
| 4740 | delete [] floatParams; |
| 4741 | } |
| 4742 | else if (nativeType == GL_INT) |
| 4743 | { |
| 4744 | GLint *intParams = NULL; |
| 4745 | intParams = new GLint[numParams]; |
| 4746 | |
| 4747 | context->getIntegerv(pname, intParams); |
| 4748 | |
| 4749 | for (unsigned int i = 0; i < numParams; ++i) |
| 4750 | { |
| 4751 | if (intParams[i] == 0) |
| 4752 | params[i] = GL_FALSE; |
| 4753 | else |
| 4754 | params[i] = GL_TRUE; |
| 4755 | } |
| 4756 | |
| 4757 | delete [] intParams; |
| 4758 | } |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 4759 | else if (nativeType == GL_INT_64_ANGLEX) |
| 4760 | { |
| 4761 | GLint64 *int64Params = NULL; |
| 4762 | int64Params = new GLint64[numParams]; |
| 4763 | |
| 4764 | context->getInteger64v(pname, int64Params); |
| 4765 | |
| 4766 | for (unsigned int i = 0; i < numParams; ++i) |
| 4767 | { |
| 4768 | if (int64Params[i] == 0) |
| 4769 | params[i] = GL_FALSE; |
| 4770 | else |
| 4771 | params[i] = GL_TRUE; |
| 4772 | } |
| 4773 | |
| 4774 | delete [] int64Params; |
| 4775 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4776 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4777 | } |
| 4778 | } |
| 4779 | catch(std::bad_alloc&) |
| 4780 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4781 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4782 | } |
| 4783 | } |
| 4784 | |
| 4785 | void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 4786 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4787 | 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] | 4788 | |
| 4789 | try |
| 4790 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4791 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4792 | |
| 4793 | if (context) |
| 4794 | { |
| 4795 | gl::Buffer *buffer; |
| 4796 | |
| 4797 | switch (target) |
| 4798 | { |
| 4799 | case GL_ARRAY_BUFFER: |
| 4800 | buffer = context->getArrayBuffer(); |
| 4801 | break; |
| 4802 | case GL_ELEMENT_ARRAY_BUFFER: |
| 4803 | buffer = context->getElementArrayBuffer(); |
| 4804 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4805 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4806 | } |
| 4807 | |
| 4808 | if (!buffer) |
| 4809 | { |
| 4810 | // 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] | 4811 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4812 | } |
| 4813 | |
| 4814 | switch (pname) |
| 4815 | { |
| 4816 | case GL_BUFFER_USAGE: |
| 4817 | *params = buffer->usage(); |
| 4818 | break; |
| 4819 | case GL_BUFFER_SIZE: |
| 4820 | *params = buffer->size(); |
| 4821 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4822 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4823 | } |
| 4824 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4825 | } |
| 4826 | catch(std::bad_alloc&) |
| 4827 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4828 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4829 | } |
| 4830 | } |
| 4831 | |
| 4832 | GLenum __stdcall glGetError(void) |
| 4833 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4834 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4835 | |
| 4836 | gl::Context *context = gl::getContext(); |
| 4837 | |
| 4838 | if (context) |
| 4839 | { |
daniel@transgaming.com | 82b2891 | 2011-12-12 21:01:35 +0000 | [diff] [blame] | 4840 | return context->getError(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4841 | } |
| 4842 | |
| 4843 | return GL_NO_ERROR; |
| 4844 | } |
| 4845 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4846 | void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 4847 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4848 | 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] | 4849 | |
| 4850 | try |
| 4851 | { |
| 4852 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4853 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4854 | |
| 4855 | if (context) |
| 4856 | { |
| 4857 | gl::Fence *fenceObject = context->getFence(fence); |
| 4858 | |
| 4859 | if (fenceObject == NULL) |
| 4860 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4861 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4862 | } |
| 4863 | |
| 4864 | fenceObject->getFenceiv(pname, params); |
| 4865 | } |
| 4866 | } |
| 4867 | catch(std::bad_alloc&) |
| 4868 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4869 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4870 | } |
| 4871 | } |
| 4872 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4873 | void __stdcall glGetFloatv(GLenum pname, GLfloat* params) |
| 4874 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4875 | 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] | 4876 | |
| 4877 | try |
| 4878 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4879 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4880 | |
| 4881 | if (context) |
| 4882 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4883 | if (!(context->getFloatv(pname, params))) |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4884 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4885 | GLenum nativeType; |
| 4886 | unsigned int numParams = 0; |
| 4887 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4888 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4889 | |
| 4890 | if (numParams == 0) |
| 4891 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 4892 | |
| 4893 | if (nativeType == GL_BOOL) |
| 4894 | { |
| 4895 | GLboolean *boolParams = NULL; |
| 4896 | boolParams = new GLboolean[numParams]; |
| 4897 | |
| 4898 | context->getBooleanv(pname, boolParams); |
| 4899 | |
| 4900 | for (unsigned int i = 0; i < numParams; ++i) |
| 4901 | { |
| 4902 | if (boolParams[i] == GL_FALSE) |
| 4903 | params[i] = 0.0f; |
| 4904 | else |
| 4905 | params[i] = 1.0f; |
| 4906 | } |
| 4907 | |
| 4908 | delete [] boolParams; |
| 4909 | } |
| 4910 | else if (nativeType == GL_INT) |
| 4911 | { |
| 4912 | GLint *intParams = NULL; |
| 4913 | intParams = new GLint[numParams]; |
| 4914 | |
| 4915 | context->getIntegerv(pname, intParams); |
| 4916 | |
| 4917 | for (unsigned int i = 0; i < numParams; ++i) |
| 4918 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 4919 | params[i] = static_cast<GLfloat>(intParams[i]); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4920 | } |
| 4921 | |
| 4922 | delete [] intParams; |
| 4923 | } |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 4924 | else if (nativeType == GL_INT_64_ANGLEX) |
| 4925 | { |
| 4926 | GLint64 *int64Params = NULL; |
| 4927 | int64Params = new GLint64[numParams]; |
| 4928 | |
| 4929 | context->getInteger64v(pname, int64Params); |
| 4930 | |
| 4931 | for (unsigned int i = 0; i < numParams; ++i) |
| 4932 | { |
| 4933 | params[i] = static_cast<GLfloat>(int64Params[i]); |
| 4934 | } |
| 4935 | |
| 4936 | delete [] int64Params; |
| 4937 | } |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4938 | } |
| 4939 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4940 | } |
| 4941 | catch(std::bad_alloc&) |
| 4942 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4943 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4944 | } |
| 4945 | } |
| 4946 | |
| 4947 | void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) |
| 4948 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4949 | 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] | 4950 | target, attachment, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4951 | |
| 4952 | try |
| 4953 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4954 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4955 | |
| 4956 | if (context) |
| 4957 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4958 | 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] | 4959 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4960 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4961 | } |
| 4962 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4963 | gl::Framebuffer *framebuffer = NULL; |
| 4964 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4965 | { |
| 4966 | if(context->getReadFramebufferHandle() == 0) |
| 4967 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4968 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4969 | } |
| 4970 | |
| 4971 | framebuffer = context->getReadFramebuffer(); |
| 4972 | } |
| 4973 | else |
| 4974 | { |
| 4975 | if (context->getDrawFramebufferHandle() == 0) |
| 4976 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4977 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4978 | } |
| 4979 | |
| 4980 | framebuffer = context->getDrawFramebuffer(); |
| 4981 | } |
| 4982 | |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4983 | GLenum attachmentType; |
| 4984 | GLuint attachmentHandle; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4985 | |
| 4986 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4987 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4988 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4989 | |
| 4990 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4991 | { |
| 4992 | return gl::error(GL_INVALID_ENUM); |
| 4993 | } |
| 4994 | |
| 4995 | attachmentType = framebuffer->getColorbufferType(colorAttachment); |
| 4996 | attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment); |
| 4997 | } |
| 4998 | else |
| 4999 | { |
| 5000 | switch (attachment) |
| 5001 | { |
| 5002 | case GL_DEPTH_ATTACHMENT: |
| 5003 | attachmentType = framebuffer->getDepthbufferType(); |
| 5004 | attachmentHandle = framebuffer->getDepthbufferHandle(); |
| 5005 | break; |
| 5006 | case GL_STENCIL_ATTACHMENT: |
| 5007 | attachmentType = framebuffer->getStencilbufferType(); |
| 5008 | attachmentHandle = framebuffer->getStencilbufferHandle(); |
| 5009 | break; |
| 5010 | default: return gl::error(GL_INVALID_ENUM); |
| 5011 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5012 | } |
| 5013 | |
| 5014 | GLenum attachmentObjectType; // Type category |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 5015 | if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5016 | { |
| 5017 | attachmentObjectType = attachmentType; |
| 5018 | } |
apatrick@chromium.org | 551022e | 2012-01-23 19:56:54 +0000 | [diff] [blame] | 5019 | else if (gl::IsInternalTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5020 | { |
| 5021 | attachmentObjectType = GL_TEXTURE; |
| 5022 | } |
apatrick@chromium.org | a1d8059 | 2012-01-25 21:52:10 +0000 | [diff] [blame] | 5023 | else |
| 5024 | { |
| 5025 | UNREACHABLE(); |
| 5026 | return; |
| 5027 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5028 | |
| 5029 | switch (pname) |
| 5030 | { |
| 5031 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 5032 | *params = attachmentObjectType; |
| 5033 | break; |
| 5034 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 5035 | if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE) |
| 5036 | { |
| 5037 | *params = attachmentHandle; |
| 5038 | } |
| 5039 | else |
| 5040 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5041 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5042 | } |
| 5043 | break; |
| 5044 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 5045 | if (attachmentObjectType == GL_TEXTURE) |
| 5046 | { |
| 5047 | *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0 |
| 5048 | } |
| 5049 | else |
| 5050 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5051 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5052 | } |
| 5053 | break; |
| 5054 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 5055 | if (attachmentObjectType == GL_TEXTURE) |
| 5056 | { |
daniel@transgaming.com | 19ffc24 | 2010-05-04 03:35:21 +0000 | [diff] [blame] | 5057 | if (gl::IsCubemapTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5058 | { |
| 5059 | *params = attachmentType; |
| 5060 | } |
| 5061 | else |
| 5062 | { |
| 5063 | *params = 0; |
| 5064 | } |
| 5065 | } |
| 5066 | else |
| 5067 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5068 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5069 | } |
| 5070 | break; |
| 5071 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5072 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5073 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5074 | } |
| 5075 | } |
| 5076 | catch(std::bad_alloc&) |
| 5077 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5078 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5079 | } |
| 5080 | } |
| 5081 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 5082 | GLenum __stdcall glGetGraphicsResetStatusEXT(void) |
| 5083 | { |
| 5084 | EVENT("()"); |
| 5085 | |
| 5086 | try |
| 5087 | { |
| 5088 | gl::Context *context = gl::getContext(); |
| 5089 | |
| 5090 | if (context) |
| 5091 | { |
| 5092 | return context->getResetStatus(); |
| 5093 | } |
| 5094 | |
| 5095 | return GL_NO_ERROR; |
| 5096 | } |
| 5097 | catch(std::bad_alloc&) |
| 5098 | { |
| 5099 | return GL_OUT_OF_MEMORY; |
| 5100 | } |
| 5101 | } |
| 5102 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5103 | void __stdcall glGetIntegerv(GLenum pname, GLint* params) |
| 5104 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5105 | 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] | 5106 | |
| 5107 | try |
| 5108 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5109 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5110 | |
| 5111 | if (context) |
| 5112 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5113 | if (!(context->getIntegerv(pname, params))) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5114 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5115 | GLenum nativeType; |
| 5116 | unsigned int numParams = 0; |
| 5117 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5118 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5119 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5120 | if (numParams == 0) |
| 5121 | return; // it is known that pname is valid, but there are no parameters to return |
| 5122 | |
| 5123 | if (nativeType == GL_BOOL) |
| 5124 | { |
| 5125 | GLboolean *boolParams = NULL; |
| 5126 | boolParams = new GLboolean[numParams]; |
| 5127 | |
| 5128 | context->getBooleanv(pname, boolParams); |
| 5129 | |
| 5130 | for (unsigned int i = 0; i < numParams; ++i) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5131 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5132 | if (boolParams[i] == GL_FALSE) |
| 5133 | params[i] = 0; |
| 5134 | else |
| 5135 | params[i] = 1; |
| 5136 | } |
| 5137 | |
| 5138 | delete [] boolParams; |
| 5139 | } |
| 5140 | else if (nativeType == GL_FLOAT) |
| 5141 | { |
| 5142 | GLfloat *floatParams = NULL; |
| 5143 | floatParams = new GLfloat[numParams]; |
| 5144 | |
| 5145 | context->getFloatv(pname, floatParams); |
| 5146 | |
| 5147 | for (unsigned int i = 0; i < numParams; ++i) |
| 5148 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5149 | // 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] | 5150 | 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] | 5151 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5152 | 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] | 5153 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5154 | else |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5155 | { |
Jamie Madill | af49691 | 2013-07-19 16:36:54 -0400 | [diff] [blame] | 5156 | params[i] = gl::iround<GLint>(floatParams[i]); |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5157 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5158 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5159 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5160 | delete [] floatParams; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5161 | } |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5162 | else if (nativeType == GL_INT_64_ANGLEX) |
| 5163 | { |
| 5164 | GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min()); |
| 5165 | GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max()); |
| 5166 | GLint64 *int64Params = NULL; |
| 5167 | int64Params = new GLint64[numParams]; |
| 5168 | |
| 5169 | context->getInteger64v(pname, int64Params); |
| 5170 | |
| 5171 | for (unsigned int i = 0; i < numParams; ++i) |
| 5172 | { |
| 5173 | GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue); |
| 5174 | params[i] = static_cast<GLint>(clampedValue); |
| 5175 | } |
| 5176 | |
| 5177 | delete [] int64Params; |
| 5178 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5179 | } |
| 5180 | } |
| 5181 | } |
| 5182 | catch(std::bad_alloc&) |
| 5183 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5184 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5185 | } |
| 5186 | } |
| 5187 | |
| 5188 | void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params) |
| 5189 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5190 | 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] | 5191 | |
| 5192 | try |
| 5193 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5194 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5195 | |
| 5196 | if (context) |
| 5197 | { |
| 5198 | gl::Program *programObject = context->getProgram(program); |
| 5199 | |
| 5200 | if (!programObject) |
| 5201 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5202 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5203 | } |
| 5204 | |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 5205 | if (context->getClientVersion() < 3) |
| 5206 | { |
| 5207 | switch (pname) |
| 5208 | { |
| 5209 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 5210 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 5211 | return gl::error(GL_INVALID_ENUM); |
| 5212 | } |
| 5213 | } |
| 5214 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5215 | switch (pname) |
| 5216 | { |
| 5217 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5218 | *params = programObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5219 | return; |
| 5220 | case GL_LINK_STATUS: |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5221 | *params = programObject->isLinked(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5222 | return; |
| 5223 | case GL_VALIDATE_STATUS: |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 5224 | *params = programObject->isValidated(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5225 | return; |
| 5226 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5227 | *params = programObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5228 | return; |
| 5229 | case GL_ATTACHED_SHADERS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5230 | *params = programObject->getAttachedShadersCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5231 | return; |
| 5232 | case GL_ACTIVE_ATTRIBUTES: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 5233 | *params = programObject->getActiveAttributeCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5234 | return; |
| 5235 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 5236 | *params = programObject->getActiveAttributeMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5237 | return; |
| 5238 | case GL_ACTIVE_UNIFORMS: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 5239 | *params = programObject->getActiveUniformCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5240 | return; |
| 5241 | case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 5242 | *params = programObject->getActiveUniformMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5243 | return; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 5244 | case GL_PROGRAM_BINARY_LENGTH_OES: |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 5245 | *params = programObject->getProgramBinaryLength(); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 5246 | return; |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 5247 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 5248 | *params = programObject->getActiveUniformBlockCount(); |
| 5249 | return; |
| 5250 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 5251 | *params = programObject->getActiveUniformBlockMaxLength(); |
| 5252 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5253 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5254 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5255 | } |
| 5256 | } |
| 5257 | } |
| 5258 | catch(std::bad_alloc&) |
| 5259 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5260 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5261 | } |
| 5262 | } |
| 5263 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5264 | void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5265 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5266 | 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] | 5267 | program, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5268 | |
| 5269 | try |
| 5270 | { |
| 5271 | if (bufsize < 0) |
| 5272 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5273 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5274 | } |
| 5275 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5276 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5277 | |
| 5278 | if (context) |
| 5279 | { |
| 5280 | gl::Program *programObject = context->getProgram(program); |
| 5281 | |
| 5282 | if (!programObject) |
| 5283 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5284 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5285 | } |
| 5286 | |
| 5287 | programObject->getInfoLog(bufsize, length, infolog); |
| 5288 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5289 | } |
| 5290 | catch(std::bad_alloc&) |
| 5291 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5292 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5293 | } |
| 5294 | } |
| 5295 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5296 | void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params) |
| 5297 | { |
| 5298 | EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params); |
| 5299 | |
| 5300 | try |
| 5301 | { |
| 5302 | switch (pname) |
| 5303 | { |
| 5304 | case GL_CURRENT_QUERY_EXT: |
| 5305 | break; |
| 5306 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5307 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5308 | } |
| 5309 | |
| 5310 | gl::Context *context = gl::getNonLostContext(); |
| 5311 | |
| 5312 | if (context) |
| 5313 | { |
| 5314 | params[0] = context->getActiveQuery(target); |
| 5315 | } |
| 5316 | } |
| 5317 | catch(std::bad_alloc&) |
| 5318 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5319 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5320 | } |
| 5321 | } |
| 5322 | |
| 5323 | void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) |
| 5324 | { |
| 5325 | EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params); |
| 5326 | |
| 5327 | try |
| 5328 | { |
| 5329 | switch (pname) |
| 5330 | { |
| 5331 | case GL_QUERY_RESULT_EXT: |
| 5332 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5333 | break; |
| 5334 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5335 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5336 | } |
| 5337 | gl::Context *context = gl::getNonLostContext(); |
| 5338 | |
| 5339 | if (context) |
| 5340 | { |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5341 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 5342 | |
| 5343 | if (!queryObject) |
| 5344 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5345 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5346 | } |
| 5347 | |
| 5348 | if (context->getActiveQuery(queryObject->getType()) == id) |
| 5349 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5350 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5351 | } |
| 5352 | |
| 5353 | switch(pname) |
| 5354 | { |
| 5355 | case GL_QUERY_RESULT_EXT: |
| 5356 | params[0] = queryObject->getResult(); |
| 5357 | break; |
| 5358 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5359 | params[0] = queryObject->isResultAvailable(); |
| 5360 | break; |
| 5361 | default: |
| 5362 | ASSERT(false); |
| 5363 | } |
| 5364 | } |
| 5365 | } |
| 5366 | catch(std::bad_alloc&) |
| 5367 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5368 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5369 | } |
| 5370 | } |
| 5371 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5372 | void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5373 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5374 | 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] | 5375 | |
| 5376 | try |
| 5377 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5378 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5379 | |
| 5380 | if (context) |
| 5381 | { |
| 5382 | if (target != GL_RENDERBUFFER) |
| 5383 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5384 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5385 | } |
| 5386 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5387 | if (context->getRenderbufferHandle() == 0) |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5388 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5389 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5390 | } |
| 5391 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5392 | gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle()); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5393 | |
| 5394 | switch (pname) |
| 5395 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5396 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break; |
| 5397 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break; |
| 5398 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break; |
| 5399 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break; |
| 5400 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break; |
| 5401 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break; |
| 5402 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break; |
| 5403 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break; |
| 5404 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break; |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5405 | case GL_RENDERBUFFER_SAMPLES_ANGLE: |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5406 | if (context->getMaxSupportedSamples() != 0) |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5407 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5408 | *params = renderbuffer->getSamples(); |
| 5409 | } |
| 5410 | else |
| 5411 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5412 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5413 | } |
| 5414 | break; |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5415 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5416 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5417 | } |
| 5418 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5419 | } |
| 5420 | catch(std::bad_alloc&) |
| 5421 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5422 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5423 | } |
| 5424 | } |
| 5425 | |
| 5426 | void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params) |
| 5427 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5428 | 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] | 5429 | |
| 5430 | try |
| 5431 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5432 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5433 | |
| 5434 | if (context) |
| 5435 | { |
| 5436 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 5437 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5438 | if (!shaderObject) |
| 5439 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5440 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5441 | } |
| 5442 | |
| 5443 | switch (pname) |
| 5444 | { |
| 5445 | case GL_SHADER_TYPE: |
| 5446 | *params = shaderObject->getType(); |
| 5447 | return; |
| 5448 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5449 | *params = shaderObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5450 | return; |
| 5451 | case GL_COMPILE_STATUS: |
| 5452 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; |
| 5453 | return; |
| 5454 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5455 | *params = shaderObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5456 | return; |
| 5457 | case GL_SHADER_SOURCE_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5458 | *params = shaderObject->getSourceLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5459 | return; |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5460 | case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: |
| 5461 | *params = shaderObject->getTranslatedSourceLength(); |
| 5462 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5463 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5464 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5465 | } |
| 5466 | } |
| 5467 | } |
| 5468 | catch(std::bad_alloc&) |
| 5469 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5470 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5471 | } |
| 5472 | } |
| 5473 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5474 | void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5475 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5476 | 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] | 5477 | shader, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5478 | |
| 5479 | try |
| 5480 | { |
| 5481 | if (bufsize < 0) |
| 5482 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5483 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5484 | } |
| 5485 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5486 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5487 | |
| 5488 | if (context) |
| 5489 | { |
| 5490 | gl::Shader *shaderObject = context->getShader(shader); |
| 5491 | |
| 5492 | if (!shaderObject) |
| 5493 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5494 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5495 | } |
| 5496 | |
| 5497 | shaderObject->getInfoLog(bufsize, length, infolog); |
| 5498 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5499 | } |
| 5500 | catch(std::bad_alloc&) |
| 5501 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5502 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5503 | } |
| 5504 | } |
| 5505 | |
| 5506 | void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) |
| 5507 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5508 | 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] | 5509 | shadertype, precisiontype, range, precision); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5510 | |
| 5511 | try |
| 5512 | { |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5513 | switch (shadertype) |
| 5514 | { |
| 5515 | case GL_VERTEX_SHADER: |
| 5516 | case GL_FRAGMENT_SHADER: |
| 5517 | break; |
| 5518 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5519 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5520 | } |
| 5521 | |
| 5522 | switch (precisiontype) |
| 5523 | { |
| 5524 | case GL_LOW_FLOAT: |
| 5525 | case GL_MEDIUM_FLOAT: |
| 5526 | case GL_HIGH_FLOAT: |
| 5527 | // Assume IEEE 754 precision |
| 5528 | range[0] = 127; |
| 5529 | range[1] = 127; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5530 | *precision = 23; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5531 | break; |
| 5532 | case GL_LOW_INT: |
| 5533 | case GL_MEDIUM_INT: |
| 5534 | case GL_HIGH_INT: |
| 5535 | // Some (most) hardware only supports single-precision floating-point numbers, |
| 5536 | // which can accurately represent integers up to +/-16777216 |
| 5537 | range[0] = 24; |
| 5538 | range[1] = 24; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5539 | *precision = 0; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5540 | break; |
| 5541 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5542 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5543 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5544 | } |
| 5545 | catch(std::bad_alloc&) |
| 5546 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5547 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5548 | } |
| 5549 | } |
| 5550 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5551 | void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5552 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5553 | 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] | 5554 | shader, bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5555 | |
| 5556 | try |
| 5557 | { |
| 5558 | if (bufsize < 0) |
| 5559 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5560 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5561 | } |
| 5562 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5563 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5564 | |
| 5565 | if (context) |
| 5566 | { |
| 5567 | gl::Shader *shaderObject = context->getShader(shader); |
| 5568 | |
| 5569 | if (!shaderObject) |
| 5570 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5571 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5572 | } |
| 5573 | |
| 5574 | shaderObject->getSource(bufsize, length, source); |
| 5575 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5576 | } |
| 5577 | catch(std::bad_alloc&) |
| 5578 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5579 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5580 | } |
| 5581 | } |
| 5582 | |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5583 | void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
| 5584 | { |
| 5585 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)", |
| 5586 | shader, bufsize, length, source); |
| 5587 | |
| 5588 | try |
| 5589 | { |
| 5590 | if (bufsize < 0) |
| 5591 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5592 | return gl::error(GL_INVALID_VALUE); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5593 | } |
| 5594 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5595 | gl::Context *context = gl::getNonLostContext(); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5596 | |
| 5597 | if (context) |
| 5598 | { |
| 5599 | gl::Shader *shaderObject = context->getShader(shader); |
| 5600 | |
| 5601 | if (!shaderObject) |
| 5602 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5603 | return gl::error(GL_INVALID_OPERATION); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5604 | } |
| 5605 | |
| 5606 | shaderObject->getTranslatedSource(bufsize, length, source); |
| 5607 | } |
| 5608 | } |
| 5609 | catch(std::bad_alloc&) |
| 5610 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5611 | return gl::error(GL_OUT_OF_MEMORY); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5612 | } |
| 5613 | } |
| 5614 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5615 | const GLubyte* __stdcall glGetString(GLenum name) |
| 5616 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5617 | EVENT("(GLenum name = 0x%X)", name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5618 | |
| 5619 | try |
| 5620 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5621 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3e4c600 | 2010-05-05 18:50:13 +0000 | [diff] [blame] | 5622 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5623 | switch (name) |
| 5624 | { |
| 5625 | case GL_VENDOR: |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 5626 | return (GLubyte*)"Google Inc."; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5627 | case GL_RENDERER: |
daniel@transgaming.com | c23ff64 | 2011-08-16 20:28:45 +0000 | [diff] [blame] | 5628 | return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5629 | case GL_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5630 | if (context->getClientVersion() == 2) |
| 5631 | { |
| 5632 | return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")"; |
| 5633 | } |
| 5634 | else |
| 5635 | { |
| 5636 | return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")"; |
| 5637 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5638 | case GL_SHADING_LANGUAGE_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5639 | if (context->getClientVersion() == 2) |
| 5640 | { |
| 5641 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")"; |
| 5642 | } |
| 5643 | else |
| 5644 | { |
| 5645 | return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")"; |
| 5646 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5647 | case GL_EXTENSIONS: |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 5648 | return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : ""); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5649 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5650 | return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5651 | } |
| 5652 | } |
| 5653 | catch(std::bad_alloc&) |
| 5654 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5655 | return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5656 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5657 | } |
| 5658 | |
| 5659 | void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) |
| 5660 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5661 | 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] | 5662 | |
| 5663 | try |
| 5664 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5665 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5666 | |
| 5667 | if (context) |
| 5668 | { |
| 5669 | gl::Texture *texture; |
| 5670 | |
| 5671 | switch (target) |
| 5672 | { |
| 5673 | case GL_TEXTURE_2D: |
| 5674 | texture = context->getTexture2D(); |
| 5675 | break; |
| 5676 | case GL_TEXTURE_CUBE_MAP: |
| 5677 | texture = context->getTextureCubeMap(); |
| 5678 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5679 | case GL_TEXTURE_3D: |
| 5680 | if (context->getClientVersion() < 3) |
| 5681 | { |
| 5682 | return gl::error(GL_INVALID_ENUM); |
| 5683 | } |
| 5684 | texture = context->getTexture3D(); |
| 5685 | break; |
shannonwoods@chromium.org | 0c611d1 | 2013-05-30 00:15:05 +0000 | [diff] [blame] | 5686 | case GL_TEXTURE_2D_ARRAY: |
| 5687 | if (context->getClientVersion() < 3) |
| 5688 | { |
| 5689 | return gl::error(GL_INVALID_ENUM); |
| 5690 | } |
| 5691 | texture = context->getTexture2DArray(); |
| 5692 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5693 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5694 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5695 | } |
| 5696 | |
| 5697 | switch (pname) |
| 5698 | { |
| 5699 | case GL_TEXTURE_MAG_FILTER: |
| 5700 | *params = (GLfloat)texture->getMagFilter(); |
| 5701 | break; |
| 5702 | case GL_TEXTURE_MIN_FILTER: |
| 5703 | *params = (GLfloat)texture->getMinFilter(); |
| 5704 | break; |
| 5705 | case GL_TEXTURE_WRAP_S: |
| 5706 | *params = (GLfloat)texture->getWrapS(); |
| 5707 | break; |
| 5708 | case GL_TEXTURE_WRAP_T: |
| 5709 | *params = (GLfloat)texture->getWrapT(); |
| 5710 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5711 | case GL_TEXTURE_WRAP_R: |
| 5712 | if (context->getClientVersion() < 3) |
| 5713 | { |
| 5714 | return gl::error(GL_INVALID_ENUM); |
| 5715 | } |
| 5716 | *params = (GLfloat)texture->getWrapR(); |
| 5717 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5718 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5719 | // 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] | 5720 | *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE); |
| 5721 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5722 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5723 | if (context->getClientVersion() < 3) |
| 5724 | { |
| 5725 | return gl::error(GL_INVALID_ENUM); |
| 5726 | } |
| 5727 | *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0); |
| 5728 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5729 | case GL_TEXTURE_USAGE_ANGLE: |
| 5730 | *params = (GLfloat)texture->getUsage(); |
| 5731 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5732 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5733 | if (!context->supportsTextureFilterAnisotropy()) |
| 5734 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5735 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5736 | } |
| 5737 | *params = (GLfloat)texture->getMaxAnisotropy(); |
| 5738 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5739 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5740 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5741 | } |
| 5742 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5743 | } |
| 5744 | catch(std::bad_alloc&) |
| 5745 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5746 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5747 | } |
| 5748 | } |
| 5749 | |
| 5750 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5751 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5752 | 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] | 5753 | |
| 5754 | try |
| 5755 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5756 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5757 | |
| 5758 | if (context) |
| 5759 | { |
| 5760 | gl::Texture *texture; |
| 5761 | |
| 5762 | switch (target) |
| 5763 | { |
| 5764 | case GL_TEXTURE_2D: |
| 5765 | texture = context->getTexture2D(); |
| 5766 | break; |
| 5767 | case GL_TEXTURE_CUBE_MAP: |
| 5768 | texture = context->getTextureCubeMap(); |
| 5769 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5770 | case GL_TEXTURE_3D: |
| 5771 | if (context->getClientVersion() < 3) |
| 5772 | { |
| 5773 | return gl::error(GL_INVALID_ENUM); |
| 5774 | } |
| 5775 | texture = context->getTexture3D(); |
| 5776 | break; |
shannonwoods@chromium.org | 0c611d1 | 2013-05-30 00:15:05 +0000 | [diff] [blame] | 5777 | case GL_TEXTURE_2D_ARRAY: |
| 5778 | if (context->getClientVersion() < 3) |
| 5779 | { |
| 5780 | return gl::error(GL_INVALID_ENUM); |
| 5781 | } |
| 5782 | texture = context->getTexture2DArray(); |
| 5783 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5784 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5785 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5786 | } |
| 5787 | |
| 5788 | switch (pname) |
| 5789 | { |
| 5790 | case GL_TEXTURE_MAG_FILTER: |
| 5791 | *params = texture->getMagFilter(); |
| 5792 | break; |
| 5793 | case GL_TEXTURE_MIN_FILTER: |
| 5794 | *params = texture->getMinFilter(); |
| 5795 | break; |
| 5796 | case GL_TEXTURE_WRAP_S: |
| 5797 | *params = texture->getWrapS(); |
| 5798 | break; |
| 5799 | case GL_TEXTURE_WRAP_T: |
| 5800 | *params = texture->getWrapT(); |
| 5801 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5802 | case GL_TEXTURE_WRAP_R: |
| 5803 | if (context->getClientVersion() < 3) |
| 5804 | { |
| 5805 | return gl::error(GL_INVALID_ENUM); |
| 5806 | } |
| 5807 | *params = texture->getWrapR(); |
| 5808 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5809 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5810 | // 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] | 5811 | *params = texture->isImmutable() ? GL_TRUE : GL_FALSE; |
| 5812 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5813 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5814 | if (context->getClientVersion() < 3) |
| 5815 | { |
| 5816 | return gl::error(GL_INVALID_ENUM); |
| 5817 | } |
| 5818 | *params = texture->isImmutable() ? texture->levelCount() : 0; |
| 5819 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5820 | case GL_TEXTURE_USAGE_ANGLE: |
| 5821 | *params = texture->getUsage(); |
| 5822 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5823 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5824 | if (!context->supportsTextureFilterAnisotropy()) |
| 5825 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5826 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5827 | } |
| 5828 | *params = (GLint)texture->getMaxAnisotropy(); |
| 5829 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 5830 | |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5831 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5832 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5833 | } |
| 5834 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5835 | } |
| 5836 | catch(std::bad_alloc&) |
| 5837 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5838 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5839 | } |
| 5840 | } |
| 5841 | |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5842 | void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
| 5843 | { |
| 5844 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)", |
| 5845 | program, location, bufSize, params); |
| 5846 | |
| 5847 | try |
| 5848 | { |
| 5849 | if (bufSize < 0) |
| 5850 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5851 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5852 | } |
| 5853 | |
| 5854 | gl::Context *context = gl::getNonLostContext(); |
| 5855 | |
| 5856 | if (context) |
| 5857 | { |
| 5858 | if (program == 0) |
| 5859 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5860 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5861 | } |
| 5862 | |
| 5863 | gl::Program *programObject = context->getProgram(program); |
| 5864 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5865 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5866 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5867 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5868 | } |
| 5869 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5870 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5871 | if (!programBinary) |
| 5872 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5873 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5874 | } |
| 5875 | |
| 5876 | if (!programBinary->getUniformfv(location, &bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5877 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5878 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5879 | } |
| 5880 | } |
| 5881 | } |
| 5882 | catch(std::bad_alloc&) |
| 5883 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5884 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5885 | } |
| 5886 | } |
| 5887 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5888 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 5889 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5890 | 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] | 5891 | |
| 5892 | try |
| 5893 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5894 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5895 | |
| 5896 | if (context) |
| 5897 | { |
| 5898 | if (program == 0) |
| 5899 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5900 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5901 | } |
| 5902 | |
| 5903 | gl::Program *programObject = context->getProgram(program); |
| 5904 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5905 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5906 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5907 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5908 | } |
| 5909 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5910 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5911 | if (!programBinary) |
| 5912 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5913 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5914 | } |
| 5915 | |
| 5916 | if (!programBinary->getUniformfv(location, NULL, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5917 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5918 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5919 | } |
| 5920 | } |
| 5921 | } |
| 5922 | catch(std::bad_alloc&) |
| 5923 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5924 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5925 | } |
| 5926 | } |
| 5927 | |
| 5928 | void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) |
| 5929 | { |
| 5930 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)", |
| 5931 | program, location, bufSize, params); |
| 5932 | |
| 5933 | try |
| 5934 | { |
| 5935 | if (bufSize < 0) |
| 5936 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5937 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5938 | } |
| 5939 | |
| 5940 | gl::Context *context = gl::getNonLostContext(); |
| 5941 | |
| 5942 | if (context) |
| 5943 | { |
| 5944 | if (program == 0) |
| 5945 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5946 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5947 | } |
| 5948 | |
| 5949 | gl::Program *programObject = context->getProgram(program); |
| 5950 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5951 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5952 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5953 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5954 | } |
| 5955 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5956 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5957 | if (!programBinary) |
| 5958 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5959 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5960 | } |
| 5961 | |
| 5962 | if (!programBinary->getUniformiv(location, &bufSize, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5963 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5964 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5965 | } |
| 5966 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5967 | } |
| 5968 | catch(std::bad_alloc&) |
| 5969 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5970 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5971 | } |
| 5972 | } |
| 5973 | |
| 5974 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 5975 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5976 | 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] | 5977 | |
| 5978 | try |
| 5979 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5980 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5981 | |
| 5982 | if (context) |
| 5983 | { |
| 5984 | if (program == 0) |
| 5985 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5986 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5987 | } |
| 5988 | |
| 5989 | gl::Program *programObject = context->getProgram(program); |
| 5990 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5991 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5992 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5993 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5994 | } |
| 5995 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5996 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5997 | if (!programBinary) |
| 5998 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5999 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6000 | } |
| 6001 | |
| 6002 | if (!programBinary->getUniformiv(location, NULL, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6003 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6004 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6005 | } |
| 6006 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6007 | } |
| 6008 | catch(std::bad_alloc&) |
| 6009 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6010 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6011 | } |
| 6012 | } |
| 6013 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6014 | int __stdcall glGetUniformLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6015 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6016 | 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] | 6017 | |
| 6018 | try |
| 6019 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6020 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6021 | |
| 6022 | if (strstr(name, "gl_") == name) |
| 6023 | { |
| 6024 | return -1; |
| 6025 | } |
| 6026 | |
| 6027 | if (context) |
| 6028 | { |
| 6029 | gl::Program *programObject = context->getProgram(program); |
| 6030 | |
| 6031 | if (!programObject) |
| 6032 | { |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 6033 | if (context->getShader(program)) |
| 6034 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6035 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 6036 | } |
| 6037 | else |
| 6038 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6039 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 6040 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6041 | } |
| 6042 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6043 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 6044 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6045 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6046 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6047 | } |
| 6048 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6049 | return programBinary->getUniformLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6050 | } |
| 6051 | } |
| 6052 | catch(std::bad_alloc&) |
| 6053 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6054 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6055 | } |
| 6056 | |
| 6057 | return -1; |
| 6058 | } |
| 6059 | |
| 6060 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 6061 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6062 | 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] | 6063 | |
| 6064 | try |
| 6065 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6066 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6067 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6068 | if (context) |
| 6069 | { |
| 6070 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6071 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6072 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6073 | } |
| 6074 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 6075 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6076 | |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6077 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6078 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6079 | return; |
| 6080 | } |
| 6081 | |
| 6082 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 6083 | { |
| 6084 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 6085 | for (int i = 0; i < 4; ++i) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6086 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6087 | params[i] = currentValueData.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6088 | } |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6089 | } |
| 6090 | else |
| 6091 | { |
| 6092 | *params = attribState.querySingleParameter<GLfloat>(pname); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6093 | } |
| 6094 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6095 | } |
| 6096 | catch(std::bad_alloc&) |
| 6097 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6098 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6099 | } |
| 6100 | } |
| 6101 | |
| 6102 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 6103 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6104 | 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] | 6105 | |
| 6106 | try |
| 6107 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6108 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6109 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6110 | if (context) |
| 6111 | { |
| 6112 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6113 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6114 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6115 | } |
| 6116 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 6117 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6118 | |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6119 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6120 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6121 | return; |
| 6122 | } |
| 6123 | |
| 6124 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 6125 | { |
| 6126 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 6127 | for (int i = 0; i < 4; ++i) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6128 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6129 | float currentValue = currentValueData.FloatValues[i]; |
Jamie Madill | af49691 | 2013-07-19 16:36:54 -0400 | [diff] [blame] | 6130 | params[i] = gl::iround<GLint>(currentValue); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6131 | } |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6132 | } |
| 6133 | else |
| 6134 | { |
| 6135 | *params = attribState.querySingleParameter<GLint>(pname); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6136 | } |
| 6137 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6138 | } |
| 6139 | catch(std::bad_alloc&) |
| 6140 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6141 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6142 | } |
| 6143 | } |
| 6144 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6145 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6146 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6147 | 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] | 6148 | |
| 6149 | try |
| 6150 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6151 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6152 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6153 | if (context) |
| 6154 | { |
| 6155 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6156 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6157 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6158 | } |
| 6159 | |
| 6160 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) |
| 6161 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6162 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6163 | } |
| 6164 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6165 | *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index)); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6166 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6167 | } |
| 6168 | catch(std::bad_alloc&) |
| 6169 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6170 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6171 | } |
| 6172 | } |
| 6173 | |
| 6174 | void __stdcall glHint(GLenum target, GLenum mode) |
| 6175 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6176 | EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6177 | |
| 6178 | try |
| 6179 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6180 | switch (mode) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6181 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6182 | case GL_FASTEST: |
| 6183 | case GL_NICEST: |
| 6184 | case GL_DONT_CARE: |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6185 | break; |
| 6186 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6187 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6188 | } |
| 6189 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6190 | gl::Context *context = gl::getNonLostContext(); |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6191 | switch (target) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6192 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6193 | case GL_GENERATE_MIPMAP_HINT: |
| 6194 | if (context) context->setGenerateMipmapHint(mode); |
| 6195 | break; |
| 6196 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 6197 | if (context) context->setFragmentShaderDerivativeHint(mode); |
| 6198 | break; |
| 6199 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6200 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6201 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6202 | } |
| 6203 | catch(std::bad_alloc&) |
| 6204 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6205 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6206 | } |
| 6207 | } |
| 6208 | |
| 6209 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 6210 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6211 | EVENT("(GLuint buffer = %d)", buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6212 | |
| 6213 | try |
| 6214 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6215 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6216 | |
| 6217 | if (context && buffer) |
| 6218 | { |
| 6219 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 6220 | |
| 6221 | if (bufferObject) |
| 6222 | { |
| 6223 | return GL_TRUE; |
| 6224 | } |
| 6225 | } |
| 6226 | } |
| 6227 | catch(std::bad_alloc&) |
| 6228 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6229 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6230 | } |
| 6231 | |
| 6232 | return GL_FALSE; |
| 6233 | } |
| 6234 | |
| 6235 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 6236 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6237 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6238 | |
| 6239 | try |
| 6240 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6241 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6242 | |
| 6243 | if (context) |
| 6244 | { |
| 6245 | switch (cap) |
| 6246 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6247 | case GL_CULL_FACE: return context->isCullFaceEnabled(); |
| 6248 | case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled(); |
| 6249 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled(); |
| 6250 | case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled(); |
| 6251 | case GL_SCISSOR_TEST: return context->isScissorTestEnabled(); |
| 6252 | case GL_STENCIL_TEST: return context->isStencilTestEnabled(); |
| 6253 | case GL_DEPTH_TEST: return context->isDepthTestEnabled(); |
| 6254 | case GL_BLEND: return context->isBlendEnabled(); |
| 6255 | case GL_DITHER: return context->isDitherEnabled(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6256 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6257 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6258 | } |
| 6259 | } |
| 6260 | } |
| 6261 | catch(std::bad_alloc&) |
| 6262 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6263 | return gl::error(GL_OUT_OF_MEMORY, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6264 | } |
| 6265 | |
| 6266 | return false; |
| 6267 | } |
| 6268 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6269 | GLboolean __stdcall glIsFenceNV(GLuint fence) |
| 6270 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6271 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6272 | |
| 6273 | try |
| 6274 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6275 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6276 | |
| 6277 | if (context) |
| 6278 | { |
| 6279 | gl::Fence *fenceObject = context->getFence(fence); |
| 6280 | |
| 6281 | if (fenceObject == NULL) |
| 6282 | { |
| 6283 | return GL_FALSE; |
| 6284 | } |
| 6285 | |
| 6286 | return fenceObject->isFence(); |
| 6287 | } |
| 6288 | } |
| 6289 | catch(std::bad_alloc&) |
| 6290 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6291 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6292 | } |
| 6293 | |
| 6294 | return GL_FALSE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6295 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6296 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6297 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 6298 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6299 | EVENT("(GLuint framebuffer = %d)", framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6300 | |
| 6301 | try |
| 6302 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6303 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6304 | |
| 6305 | if (context && framebuffer) |
| 6306 | { |
| 6307 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 6308 | |
| 6309 | if (framebufferObject) |
| 6310 | { |
| 6311 | return GL_TRUE; |
| 6312 | } |
| 6313 | } |
| 6314 | } |
| 6315 | catch(std::bad_alloc&) |
| 6316 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6317 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6318 | } |
| 6319 | |
| 6320 | return GL_FALSE; |
| 6321 | } |
| 6322 | |
| 6323 | GLboolean __stdcall glIsProgram(GLuint program) |
| 6324 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6325 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6326 | |
| 6327 | try |
| 6328 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6329 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6330 | |
| 6331 | if (context && program) |
| 6332 | { |
| 6333 | gl::Program *programObject = context->getProgram(program); |
| 6334 | |
| 6335 | if (programObject) |
| 6336 | { |
| 6337 | return GL_TRUE; |
| 6338 | } |
| 6339 | } |
| 6340 | } |
| 6341 | catch(std::bad_alloc&) |
| 6342 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6343 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6344 | } |
| 6345 | |
| 6346 | return GL_FALSE; |
| 6347 | } |
| 6348 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 6349 | GLboolean __stdcall glIsQueryEXT(GLuint id) |
| 6350 | { |
| 6351 | EVENT("(GLuint id = %d)", id); |
| 6352 | |
| 6353 | try |
| 6354 | { |
| 6355 | if (id == 0) |
| 6356 | { |
| 6357 | return GL_FALSE; |
| 6358 | } |
| 6359 | |
| 6360 | gl::Context *context = gl::getNonLostContext(); |
| 6361 | |
| 6362 | if (context) |
| 6363 | { |
| 6364 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 6365 | |
| 6366 | if (queryObject) |
| 6367 | { |
| 6368 | return GL_TRUE; |
| 6369 | } |
| 6370 | } |
| 6371 | } |
| 6372 | catch(std::bad_alloc&) |
| 6373 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6374 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 6375 | } |
| 6376 | |
| 6377 | return GL_FALSE; |
| 6378 | } |
| 6379 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6380 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 6381 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6382 | EVENT("(GLuint renderbuffer = %d)", renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6383 | |
| 6384 | try |
| 6385 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6386 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6387 | |
| 6388 | if (context && renderbuffer) |
| 6389 | { |
| 6390 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 6391 | |
| 6392 | if (renderbufferObject) |
| 6393 | { |
| 6394 | return GL_TRUE; |
| 6395 | } |
| 6396 | } |
| 6397 | } |
| 6398 | catch(std::bad_alloc&) |
| 6399 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6400 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6401 | } |
| 6402 | |
| 6403 | return GL_FALSE; |
| 6404 | } |
| 6405 | |
| 6406 | GLboolean __stdcall glIsShader(GLuint shader) |
| 6407 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6408 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6409 | |
| 6410 | try |
| 6411 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6412 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6413 | |
| 6414 | if (context && shader) |
| 6415 | { |
| 6416 | gl::Shader *shaderObject = context->getShader(shader); |
| 6417 | |
| 6418 | if (shaderObject) |
| 6419 | { |
| 6420 | return GL_TRUE; |
| 6421 | } |
| 6422 | } |
| 6423 | } |
| 6424 | catch(std::bad_alloc&) |
| 6425 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6426 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6427 | } |
| 6428 | |
| 6429 | return GL_FALSE; |
| 6430 | } |
| 6431 | |
| 6432 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 6433 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6434 | EVENT("(GLuint texture = %d)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6435 | |
| 6436 | try |
| 6437 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6438 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6439 | |
| 6440 | if (context && texture) |
| 6441 | { |
| 6442 | gl::Texture *textureObject = context->getTexture(texture); |
| 6443 | |
| 6444 | if (textureObject) |
| 6445 | { |
| 6446 | return GL_TRUE; |
| 6447 | } |
| 6448 | } |
| 6449 | } |
| 6450 | catch(std::bad_alloc&) |
| 6451 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6452 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6453 | } |
| 6454 | |
| 6455 | return GL_FALSE; |
| 6456 | } |
| 6457 | |
| 6458 | void __stdcall glLineWidth(GLfloat width) |
| 6459 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6460 | EVENT("(GLfloat width = %f)", width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6461 | |
| 6462 | try |
| 6463 | { |
| 6464 | if (width <= 0.0f) |
| 6465 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6466 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6467 | } |
| 6468 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6469 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 6470 | |
| 6471 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6472 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6473 | context->setLineWidth(width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6474 | } |
| 6475 | } |
| 6476 | catch(std::bad_alloc&) |
| 6477 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6478 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6479 | } |
| 6480 | } |
| 6481 | |
| 6482 | void __stdcall glLinkProgram(GLuint program) |
| 6483 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6484 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6485 | |
| 6486 | try |
| 6487 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6488 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6489 | |
| 6490 | if (context) |
| 6491 | { |
| 6492 | gl::Program *programObject = context->getProgram(program); |
| 6493 | |
| 6494 | if (!programObject) |
| 6495 | { |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6496 | if (context->getShader(program)) |
| 6497 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6498 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6499 | } |
| 6500 | else |
| 6501 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6502 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6503 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6504 | } |
| 6505 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 6506 | context->linkProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6507 | } |
| 6508 | } |
| 6509 | catch(std::bad_alloc&) |
| 6510 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6511 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6512 | } |
| 6513 | } |
| 6514 | |
| 6515 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 6516 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6517 | EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6518 | |
| 6519 | try |
| 6520 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6521 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6522 | |
| 6523 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6524 | { |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6525 | switch (pname) |
| 6526 | { |
| 6527 | case GL_UNPACK_ALIGNMENT: |
| 6528 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6529 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6530 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6531 | } |
| 6532 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6533 | context->setUnpackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6534 | break; |
| 6535 | |
| 6536 | case GL_PACK_ALIGNMENT: |
| 6537 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6538 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6539 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6540 | } |
| 6541 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6542 | context->setPackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6543 | break; |
| 6544 | |
bsalomon@google.com | 56d46ab | 2011-11-23 14:53:10 +0000 | [diff] [blame] | 6545 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 6546 | context->setPackReverseRowOrder(param != 0); |
| 6547 | break; |
| 6548 | |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6549 | case GL_UNPACK_IMAGE_HEIGHT: |
| 6550 | case GL_UNPACK_SKIP_IMAGES: |
| 6551 | case GL_UNPACK_ROW_LENGTH: |
| 6552 | case GL_UNPACK_SKIP_ROWS: |
| 6553 | case GL_UNPACK_SKIP_PIXELS: |
| 6554 | case GL_PACK_ROW_LENGTH: |
| 6555 | case GL_PACK_SKIP_ROWS: |
| 6556 | case GL_PACK_SKIP_PIXELS: |
| 6557 | if (context->getClientVersion() < 3) |
| 6558 | { |
| 6559 | return gl::error(GL_INVALID_ENUM); |
| 6560 | } |
| 6561 | UNIMPLEMENTED(); |
| 6562 | break; |
| 6563 | |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6564 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6565 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6566 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6567 | } |
| 6568 | } |
| 6569 | catch(std::bad_alloc&) |
| 6570 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6571 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6572 | } |
| 6573 | } |
| 6574 | |
| 6575 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 6576 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6577 | EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6578 | |
| 6579 | try |
| 6580 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6581 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aede630 | 2010-04-29 03:35:48 +0000 | [diff] [blame] | 6582 | |
| 6583 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6584 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6585 | context->setPolygonOffsetParams(factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6586 | } |
| 6587 | } |
| 6588 | catch(std::bad_alloc&) |
| 6589 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6590 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6591 | } |
| 6592 | } |
| 6593 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6594 | void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6595 | GLenum format, GLenum type, GLsizei bufSize, |
| 6596 | GLvoid *data) |
| 6597 | { |
| 6598 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
| 6599 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)", |
| 6600 | x, y, width, height, format, type, bufSize, data); |
| 6601 | |
| 6602 | try |
| 6603 | { |
| 6604 | if (width < 0 || height < 0 || bufSize < 0) |
| 6605 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6606 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6607 | } |
| 6608 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6609 | gl::Context *context = gl::getNonLostContext(); |
| 6610 | |
| 6611 | if (context) |
| 6612 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6613 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6614 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6615 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6616 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6617 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6618 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6619 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6620 | return; |
| 6621 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6622 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6623 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6624 | |
| 6625 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6626 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6627 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6628 | } |
| 6629 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6630 | context->readPixels(x, y, width, height, format, type, &bufSize, data); |
| 6631 | } |
| 6632 | } |
| 6633 | catch(std::bad_alloc&) |
| 6634 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6635 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6636 | } |
| 6637 | } |
| 6638 | |
| 6639 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6640 | GLenum format, GLenum type, GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6641 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6642 | 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] | 6643 | "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] | 6644 | x, y, width, height, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6645 | |
| 6646 | try |
| 6647 | { |
| 6648 | if (width < 0 || height < 0) |
| 6649 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6650 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6651 | } |
| 6652 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6653 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6654 | |
| 6655 | if (context) |
| 6656 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6657 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6658 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6659 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6660 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6661 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6662 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6663 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6664 | return; |
| 6665 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6666 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6667 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6668 | |
| 6669 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6670 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6671 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6672 | } |
| 6673 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6674 | context->readPixels(x, y, width, height, format, type, NULL, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6675 | } |
| 6676 | } |
| 6677 | catch(std::bad_alloc&) |
| 6678 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6679 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6680 | } |
| 6681 | } |
| 6682 | |
| 6683 | void __stdcall glReleaseShaderCompiler(void) |
| 6684 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6685 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6686 | |
| 6687 | try |
| 6688 | { |
| 6689 | gl::Shader::releaseCompiler(); |
| 6690 | } |
| 6691 | catch(std::bad_alloc&) |
| 6692 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6693 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6694 | } |
| 6695 | } |
| 6696 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6697 | 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] | 6698 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6699 | 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] | 6700 | target, samples, internalformat, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6701 | |
| 6702 | try |
| 6703 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6704 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6705 | |
| 6706 | if (context) |
| 6707 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6708 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 6709 | width, height, true)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6710 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6711 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6712 | } |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 6713 | |
| 6714 | context->setRenderbufferStorage(width, height, internalformat, samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6715 | } |
| 6716 | } |
| 6717 | catch(std::bad_alloc&) |
| 6718 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6719 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6720 | } |
| 6721 | } |
| 6722 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6723 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 6724 | { |
| 6725 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height); |
| 6726 | } |
| 6727 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6728 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 6729 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6730 | EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6731 | |
| 6732 | try |
| 6733 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6734 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6735 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6736 | if (context) |
| 6737 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 6738 | context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6739 | } |
| 6740 | } |
| 6741 | catch(std::bad_alloc&) |
| 6742 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6743 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6744 | } |
| 6745 | } |
| 6746 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6747 | void __stdcall glSetFenceNV(GLuint fence, GLenum condition) |
| 6748 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6749 | EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6750 | |
| 6751 | try |
| 6752 | { |
| 6753 | if (condition != GL_ALL_COMPLETED_NV) |
| 6754 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6755 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6756 | } |
| 6757 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6758 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6759 | |
| 6760 | if (context) |
| 6761 | { |
| 6762 | gl::Fence *fenceObject = context->getFence(fence); |
| 6763 | |
| 6764 | if (fenceObject == NULL) |
| 6765 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6766 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6767 | } |
| 6768 | |
| 6769 | fenceObject->setFence(condition); |
| 6770 | } |
| 6771 | } |
| 6772 | catch(std::bad_alloc&) |
| 6773 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6774 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6775 | } |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6776 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6777 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6778 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 6779 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6780 | 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] | 6781 | |
| 6782 | try |
| 6783 | { |
| 6784 | if (width < 0 || height < 0) |
| 6785 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6786 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6787 | } |
| 6788 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6789 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6790 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6791 | if (context) |
| 6792 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6793 | context->setScissorParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6794 | } |
| 6795 | } |
| 6796 | catch(std::bad_alloc&) |
| 6797 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6798 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6799 | } |
| 6800 | } |
| 6801 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6802 | 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] | 6803 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6804 | 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] | 6805 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 6806 | n, shaders, binaryformat, binary, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6807 | |
| 6808 | try |
| 6809 | { |
daniel@transgaming.com | d1f667f | 2010-04-29 03:38:52 +0000 | [diff] [blame] | 6810 | // No binary shader formats are supported. |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6811 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6812 | } |
| 6813 | catch(std::bad_alloc&) |
| 6814 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6815 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6816 | } |
| 6817 | } |
| 6818 | |
shannon.woods%transgaming.com@gtempaccount.com | 5f33933 | 2013-04-13 03:29:02 +0000 | [diff] [blame] | 6819 | 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] | 6820 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6821 | 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] | 6822 | shader, count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6823 | |
| 6824 | try |
| 6825 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6826 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6827 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6828 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6829 | } |
| 6830 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6831 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6832 | |
| 6833 | if (context) |
| 6834 | { |
| 6835 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6836 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6837 | if (!shaderObject) |
| 6838 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6839 | if (context->getProgram(shader)) |
| 6840 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6841 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6842 | } |
| 6843 | else |
| 6844 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6845 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6846 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6847 | } |
| 6848 | |
| 6849 | shaderObject->setSource(count, string, length); |
| 6850 | } |
| 6851 | } |
| 6852 | catch(std::bad_alloc&) |
| 6853 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6854 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6855 | } |
| 6856 | } |
| 6857 | |
| 6858 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 6859 | { |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6860 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6861 | } |
| 6862 | |
| 6863 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 6864 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6865 | 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] | 6866 | |
| 6867 | try |
| 6868 | { |
| 6869 | switch (face) |
| 6870 | { |
| 6871 | case GL_FRONT: |
| 6872 | case GL_BACK: |
| 6873 | case GL_FRONT_AND_BACK: |
| 6874 | break; |
| 6875 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6876 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6877 | } |
| 6878 | |
| 6879 | switch (func) |
| 6880 | { |
| 6881 | case GL_NEVER: |
| 6882 | case GL_ALWAYS: |
| 6883 | case GL_LESS: |
| 6884 | case GL_LEQUAL: |
| 6885 | case GL_EQUAL: |
| 6886 | case GL_GEQUAL: |
| 6887 | case GL_GREATER: |
| 6888 | case GL_NOTEQUAL: |
| 6889 | break; |
| 6890 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6891 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6892 | } |
| 6893 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6894 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6895 | |
| 6896 | if (context) |
| 6897 | { |
| 6898 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6899 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6900 | context->setStencilParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6901 | } |
| 6902 | |
| 6903 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6904 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6905 | context->setStencilBackParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6906 | } |
| 6907 | } |
| 6908 | } |
| 6909 | catch(std::bad_alloc&) |
| 6910 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6911 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6912 | } |
| 6913 | } |
| 6914 | |
| 6915 | void __stdcall glStencilMask(GLuint mask) |
| 6916 | { |
| 6917 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 6918 | } |
| 6919 | |
| 6920 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 6921 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6922 | EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6923 | |
| 6924 | try |
| 6925 | { |
| 6926 | switch (face) |
| 6927 | { |
| 6928 | case GL_FRONT: |
| 6929 | case GL_BACK: |
| 6930 | case GL_FRONT_AND_BACK: |
| 6931 | break; |
| 6932 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6933 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6934 | } |
| 6935 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6936 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6937 | |
| 6938 | if (context) |
| 6939 | { |
| 6940 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6941 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6942 | context->setStencilWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6943 | } |
| 6944 | |
| 6945 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6946 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6947 | context->setStencilBackWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6948 | } |
| 6949 | } |
| 6950 | } |
| 6951 | catch(std::bad_alloc&) |
| 6952 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6953 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6954 | } |
| 6955 | } |
| 6956 | |
| 6957 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 6958 | { |
| 6959 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 6960 | } |
| 6961 | |
| 6962 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 6963 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6964 | 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] | 6965 | face, fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6966 | |
| 6967 | try |
| 6968 | { |
| 6969 | switch (face) |
| 6970 | { |
| 6971 | case GL_FRONT: |
| 6972 | case GL_BACK: |
| 6973 | case GL_FRONT_AND_BACK: |
| 6974 | break; |
| 6975 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6976 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6977 | } |
| 6978 | |
| 6979 | switch (fail) |
| 6980 | { |
| 6981 | case GL_ZERO: |
| 6982 | case GL_KEEP: |
| 6983 | case GL_REPLACE: |
| 6984 | case GL_INCR: |
| 6985 | case GL_DECR: |
| 6986 | case GL_INVERT: |
| 6987 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6988 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6989 | break; |
| 6990 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6991 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6992 | } |
| 6993 | |
| 6994 | switch (zfail) |
| 6995 | { |
| 6996 | case GL_ZERO: |
| 6997 | case GL_KEEP: |
| 6998 | case GL_REPLACE: |
| 6999 | case GL_INCR: |
| 7000 | case GL_DECR: |
| 7001 | case GL_INVERT: |
| 7002 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 7003 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7004 | break; |
| 7005 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7006 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7007 | } |
| 7008 | |
| 7009 | switch (zpass) |
| 7010 | { |
| 7011 | case GL_ZERO: |
| 7012 | case GL_KEEP: |
| 7013 | case GL_REPLACE: |
| 7014 | case GL_INCR: |
| 7015 | case GL_DECR: |
| 7016 | case GL_INVERT: |
| 7017 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 7018 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7019 | break; |
| 7020 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7021 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7022 | } |
| 7023 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7024 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7025 | |
| 7026 | if (context) |
| 7027 | { |
| 7028 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 7029 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7030 | context->setStencilOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7031 | } |
| 7032 | |
| 7033 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 7034 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7035 | context->setStencilBackOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7036 | } |
| 7037 | } |
| 7038 | } |
| 7039 | catch(std::bad_alloc&) |
| 7040 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7041 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7042 | } |
| 7043 | } |
| 7044 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 7045 | GLboolean __stdcall glTestFenceNV(GLuint fence) |
| 7046 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7047 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7048 | |
| 7049 | try |
| 7050 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7051 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7052 | |
| 7053 | if (context) |
| 7054 | { |
| 7055 | gl::Fence *fenceObject = context->getFence(fence); |
| 7056 | |
| 7057 | if (fenceObject == NULL) |
| 7058 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7059 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7060 | } |
| 7061 | |
| 7062 | return fenceObject->testFence(); |
| 7063 | } |
| 7064 | } |
| 7065 | catch(std::bad_alloc&) |
| 7066 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7067 | gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7068 | } |
| 7069 | |
| 7070 | return GL_TRUE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 7071 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7072 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7073 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, |
| 7074 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7075 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7076 | 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] | 7077 | "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] | 7078 | target, level, internalformat, width, height, border, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7079 | |
| 7080 | try |
| 7081 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7082 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7083 | |
| 7084 | if (context) |
| 7085 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7086 | if (context->getClientVersion() < 3 && |
| 7087 | !validateES2TexImageParameters(context, target, level, internalformat, false, false, |
| 7088 | 0, 0, width, height, border, format, type, pixels)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 7089 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7090 | return; |
| 7091 | } |
| 7092 | |
| 7093 | if (context->getClientVersion() >= 3 && |
| 7094 | !validateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 7095 | 0, 0, 0, width, height, 1, border, format, type)) |
| 7096 | { |
| 7097 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 7098 | } |
| 7099 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7100 | switch (target) |
| 7101 | { |
| 7102 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7103 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7104 | gl::Texture2D *texture = context->getTexture2D(); |
| 7105 | texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7106 | } |
| 7107 | break; |
| 7108 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7109 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7110 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 7111 | texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7112 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7113 | break; |
| 7114 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7115 | { |
| 7116 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7117 | texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7118 | } |
| 7119 | break; |
| 7120 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7121 | { |
| 7122 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7123 | texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7124 | } |
| 7125 | break; |
| 7126 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7127 | { |
| 7128 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7129 | texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7130 | } |
| 7131 | break; |
| 7132 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7133 | { |
| 7134 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7135 | texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7136 | } |
| 7137 | break; |
| 7138 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 7139 | { |
| 7140 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7141 | texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7142 | } |
| 7143 | break; |
| 7144 | default: UNREACHABLE(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7145 | } |
| 7146 | } |
| 7147 | } |
| 7148 | catch(std::bad_alloc&) |
| 7149 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7150 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7151 | } |
| 7152 | } |
| 7153 | |
| 7154 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 7155 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7156 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param); |
| 7157 | |
| 7158 | try |
| 7159 | { |
| 7160 | gl::Context *context = gl::getNonLostContext(); |
| 7161 | |
| 7162 | if (context) |
| 7163 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame^] | 7164 | if (!validateTexParamParameters(context, pname, static_cast<GLint>(param))) |
| 7165 | { |
| 7166 | return; |
| 7167 | } |
| 7168 | |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7169 | gl::Texture *texture; |
| 7170 | |
| 7171 | switch (target) |
| 7172 | { |
| 7173 | case GL_TEXTURE_2D: |
| 7174 | texture = context->getTexture2D(); |
| 7175 | break; |
| 7176 | case GL_TEXTURE_CUBE_MAP: |
| 7177 | texture = context->getTextureCubeMap(); |
| 7178 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 7179 | case GL_TEXTURE_3D: |
| 7180 | if (context->getClientVersion() < 3) |
| 7181 | { |
| 7182 | return gl::error(GL_INVALID_ENUM); |
| 7183 | } |
| 7184 | texture = context->getTexture3D(); |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 7185 | case GL_TEXTURE_2D_ARRAY: |
| 7186 | if (context->getClientVersion() < 3) |
| 7187 | { |
| 7188 | return gl::error(GL_INVALID_ENUM); |
| 7189 | } |
| 7190 | texture = context->getTexture2DArray(); |
| 7191 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7192 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7193 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7194 | } |
| 7195 | |
| 7196 | switch (pname) |
| 7197 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame^] | 7198 | case GL_TEXTURE_WRAP_S: texture->setWrapS(gl::uiround<GLenum>(param)); break; |
| 7199 | case GL_TEXTURE_WRAP_T: texture->setWrapT(gl::uiround<GLenum>(param)); break; |
| 7200 | case GL_TEXTURE_WRAP_R: texture->setWrapR(gl::uiround<GLenum>(param)); break; |
| 7201 | case GL_TEXTURE_MIN_FILTER: texture->setMinFilter(gl::uiround<GLenum>(param)); break; |
| 7202 | case GL_TEXTURE_MAG_FILTER: texture->setMagFilter(gl::uiround<GLenum>(param)); break; |
| 7203 | case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break; |
| 7204 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy(static_cast<GLfloat>(param), context->getTextureMaxAnisotropy()); break; |
| 7205 | case GL_TEXTURE_COMPARE_MODE: texture->setCompareMode(gl::uiround<GLenum>(param)); break; |
| 7206 | 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] | 7207 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame^] | 7208 | case GL_TEXTURE_SWIZZLE_R: |
| 7209 | case GL_TEXTURE_SWIZZLE_G: |
| 7210 | case GL_TEXTURE_SWIZZLE_B: |
| 7211 | case GL_TEXTURE_SWIZZLE_A: |
| 7212 | case GL_TEXTURE_BASE_LEVEL: |
| 7213 | case GL_TEXTURE_MAX_LEVEL: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7214 | case GL_TEXTURE_MIN_LOD: |
| 7215 | case GL_TEXTURE_MAX_LOD: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7216 | UNIMPLEMENTED(); |
| 7217 | break; |
| 7218 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame^] | 7219 | default: UNREACHABLE(); break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7220 | } |
| 7221 | } |
| 7222 | } |
| 7223 | catch(std::bad_alloc&) |
| 7224 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7225 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7226 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7227 | } |
| 7228 | |
| 7229 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 7230 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7231 | glTexParameterf(target, pname, (GLfloat)*params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7232 | } |
| 7233 | |
| 7234 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 7235 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7236 | 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] | 7237 | |
| 7238 | try |
| 7239 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7240 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7241 | |
| 7242 | if (context) |
| 7243 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame^] | 7244 | if (!validateTexParamParameters(context, pname, param)) |
| 7245 | { |
| 7246 | return; |
| 7247 | } |
| 7248 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7249 | gl::Texture *texture; |
| 7250 | |
| 7251 | switch (target) |
| 7252 | { |
| 7253 | case GL_TEXTURE_2D: |
| 7254 | texture = context->getTexture2D(); |
| 7255 | break; |
| 7256 | case GL_TEXTURE_CUBE_MAP: |
| 7257 | texture = context->getTextureCubeMap(); |
| 7258 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 7259 | case GL_TEXTURE_3D: |
| 7260 | if (context->getClientVersion() < 3) |
| 7261 | { |
| 7262 | return gl::error(GL_INVALID_ENUM); |
| 7263 | } |
| 7264 | texture = context->getTexture3D(); |
| 7265 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 7266 | case GL_TEXTURE_2D_ARRAY: |
| 7267 | if (context->getClientVersion() < 3) |
| 7268 | { |
| 7269 | return gl::error(GL_INVALID_ENUM); |
| 7270 | } |
| 7271 | texture = context->getTexture2DArray(); |
| 7272 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7273 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7274 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7275 | } |
| 7276 | |
| 7277 | switch (pname) |
| 7278 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame^] | 7279 | case GL_TEXTURE_WRAP_S: texture->setWrapS((GLenum)param); break; |
| 7280 | case GL_TEXTURE_WRAP_T: texture->setWrapT((GLenum)param); break; |
| 7281 | case GL_TEXTURE_WRAP_R: texture->setWrapR((GLenum)param); break; |
| 7282 | case GL_TEXTURE_MIN_FILTER: texture->setMinFilter((GLenum)param); break; |
| 7283 | case GL_TEXTURE_MAG_FILTER: texture->setMagFilter((GLenum)param); break; |
| 7284 | case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break; |
| 7285 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()); break; |
| 7286 | case GL_TEXTURE_COMPARE_MODE: texture->setCompareMode((GLenum)param); break; |
| 7287 | case GL_TEXTURE_COMPARE_FUNC: texture->setCompareFunc((GLenum)param); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7288 | |
| 7289 | case GL_TEXTURE_SWIZZLE_R: |
| 7290 | case GL_TEXTURE_SWIZZLE_G: |
| 7291 | case GL_TEXTURE_SWIZZLE_B: |
| 7292 | case GL_TEXTURE_SWIZZLE_A: |
| 7293 | case GL_TEXTURE_BASE_LEVEL: |
| 7294 | case GL_TEXTURE_MAX_LEVEL: |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame^] | 7295 | case GL_TEXTURE_MIN_LOD: |
| 7296 | case GL_TEXTURE_MAX_LOD: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7297 | UNIMPLEMENTED(); |
| 7298 | break; |
| 7299 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame^] | 7300 | default: UNREACHABLE(); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7301 | } |
| 7302 | } |
| 7303 | } |
| 7304 | catch(std::bad_alloc&) |
| 7305 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7306 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7307 | } |
| 7308 | } |
| 7309 | |
| 7310 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 7311 | { |
| 7312 | glTexParameteri(target, pname, *params); |
| 7313 | } |
| 7314 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7315 | void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 7316 | { |
| 7317 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 7318 | target, levels, internalformat, width, height); |
| 7319 | |
| 7320 | try |
| 7321 | { |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7322 | gl::Context *context = gl::getNonLostContext(); |
| 7323 | |
| 7324 | if (context) |
| 7325 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7326 | if (context->getClientVersion() < 3 && |
| 7327 | !validateES2TexStorageParameters(context, target, levels, internalformat, width, height)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7328 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7329 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7330 | } |
| 7331 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7332 | if (context->getClientVersion() >= 3 && |
| 7333 | !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7334 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7335 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7336 | } |
| 7337 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7338 | switch (target) |
| 7339 | { |
| 7340 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7341 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7342 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 7343 | texture2d->storage(levels, internalformat, width, height); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7344 | } |
| 7345 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7346 | |
| 7347 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7348 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7349 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7350 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7351 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7352 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7353 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7354 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 7355 | textureCube->storage(levels, internalformat, width); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7356 | } |
| 7357 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7358 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7359 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7360 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7361 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7362 | } |
| 7363 | } |
| 7364 | catch(std::bad_alloc&) |
| 7365 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7366 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7367 | } |
| 7368 | } |
| 7369 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7370 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 7371 | GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7372 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7373 | 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] | 7374 | "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] | 7375 | "const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7376 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 7377 | |
| 7378 | try |
| 7379 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7380 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7381 | |
| 7382 | if (context) |
| 7383 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7384 | if (context->getClientVersion() < 3 && |
| 7385 | !validateES2TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7386 | 0, 0, width, height, 0, format, type, pixels)) |
daniel@transgaming.com | 1d2d3c4 | 2012-05-31 01:14:15 +0000 | [diff] [blame] | 7387 | { |
| 7388 | return; |
| 7389 | } |
| 7390 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7391 | if (context->getClientVersion() >= 3 && |
| 7392 | !validateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7393 | 0, 0, 0, width, height, 1, 0, format, type)) |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7394 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7395 | return; |
| 7396 | } |
| 7397 | |
| 7398 | switch (target) |
| 7399 | { |
| 7400 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7401 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7402 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7403 | 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] | 7404 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7405 | break; |
| 7406 | |
| 7407 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7408 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7409 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7410 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7411 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7412 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7413 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7414 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7415 | 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] | 7416 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7417 | break; |
| 7418 | |
| 7419 | default: |
| 7420 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7421 | } |
| 7422 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7423 | } |
| 7424 | catch(std::bad_alloc&) |
| 7425 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7426 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7427 | } |
| 7428 | } |
| 7429 | |
| 7430 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 7431 | { |
| 7432 | glUniform1fv(location, 1, &x); |
| 7433 | } |
| 7434 | |
| 7435 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 7436 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7437 | 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] | 7438 | |
| 7439 | try |
| 7440 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7441 | if (count < 0) |
| 7442 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7443 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7444 | } |
| 7445 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7446 | if (location == -1) |
| 7447 | { |
| 7448 | return; |
| 7449 | } |
| 7450 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7451 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7452 | |
| 7453 | if (context) |
| 7454 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7455 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7456 | if (!programBinary) |
| 7457 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7458 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7459 | } |
| 7460 | |
| 7461 | if (!programBinary->setUniform1fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7462 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7463 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7464 | } |
| 7465 | } |
| 7466 | } |
| 7467 | catch(std::bad_alloc&) |
| 7468 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7469 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7470 | } |
| 7471 | } |
| 7472 | |
| 7473 | void __stdcall glUniform1i(GLint location, GLint x) |
| 7474 | { |
| 7475 | glUniform1iv(location, 1, &x); |
| 7476 | } |
| 7477 | |
| 7478 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 7479 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7480 | 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] | 7481 | |
| 7482 | try |
| 7483 | { |
| 7484 | if (count < 0) |
| 7485 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7486 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7487 | } |
| 7488 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7489 | if (location == -1) |
| 7490 | { |
| 7491 | return; |
| 7492 | } |
| 7493 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7494 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7495 | |
| 7496 | if (context) |
| 7497 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7498 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7499 | if (!programBinary) |
| 7500 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7501 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7502 | } |
| 7503 | |
| 7504 | if (!programBinary->setUniform1iv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7505 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7506 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7507 | } |
| 7508 | } |
| 7509 | } |
| 7510 | catch(std::bad_alloc&) |
| 7511 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7512 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7513 | } |
| 7514 | } |
| 7515 | |
| 7516 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 7517 | { |
| 7518 | GLfloat xy[2] = {x, y}; |
| 7519 | |
| 7520 | glUniform2fv(location, 1, (GLfloat*)&xy); |
| 7521 | } |
| 7522 | |
| 7523 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 7524 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7525 | 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] | 7526 | |
| 7527 | try |
| 7528 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7529 | if (count < 0) |
| 7530 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7531 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7532 | } |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7533 | |
| 7534 | if (location == -1) |
| 7535 | { |
| 7536 | return; |
| 7537 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7538 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7539 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7540 | |
| 7541 | if (context) |
| 7542 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7543 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7544 | if (!programBinary) |
| 7545 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7546 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7547 | } |
| 7548 | |
| 7549 | if (!programBinary->setUniform2fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7550 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7551 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7552 | } |
| 7553 | } |
| 7554 | } |
| 7555 | catch(std::bad_alloc&) |
| 7556 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7557 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7558 | } |
| 7559 | } |
| 7560 | |
| 7561 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 7562 | { |
| 7563 | GLint xy[4] = {x, y}; |
| 7564 | |
| 7565 | glUniform2iv(location, 1, (GLint*)&xy); |
| 7566 | } |
| 7567 | |
| 7568 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 7569 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7570 | 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] | 7571 | |
| 7572 | try |
| 7573 | { |
| 7574 | if (count < 0) |
| 7575 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7576 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7577 | } |
| 7578 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7579 | if (location == -1) |
| 7580 | { |
| 7581 | return; |
| 7582 | } |
| 7583 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7584 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7585 | |
| 7586 | if (context) |
| 7587 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7588 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7589 | if (!programBinary) |
| 7590 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7591 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7592 | } |
| 7593 | |
| 7594 | if (!programBinary->setUniform2iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7595 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7596 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7597 | } |
| 7598 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7599 | } |
| 7600 | catch(std::bad_alloc&) |
| 7601 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7602 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7603 | } |
| 7604 | } |
| 7605 | |
| 7606 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 7607 | { |
| 7608 | GLfloat xyz[3] = {x, y, z}; |
| 7609 | |
| 7610 | glUniform3fv(location, 1, (GLfloat*)&xyz); |
| 7611 | } |
| 7612 | |
| 7613 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 7614 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7615 | 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] | 7616 | |
| 7617 | try |
| 7618 | { |
| 7619 | if (count < 0) |
| 7620 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7621 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7622 | } |
| 7623 | |
| 7624 | if (location == -1) |
| 7625 | { |
| 7626 | return; |
| 7627 | } |
| 7628 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7629 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7630 | |
| 7631 | if (context) |
| 7632 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7633 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7634 | if (!programBinary) |
| 7635 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7636 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7637 | } |
| 7638 | |
| 7639 | if (!programBinary->setUniform3fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7640 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7641 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7642 | } |
| 7643 | } |
| 7644 | } |
| 7645 | catch(std::bad_alloc&) |
| 7646 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7647 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7648 | } |
| 7649 | } |
| 7650 | |
| 7651 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 7652 | { |
| 7653 | GLint xyz[3] = {x, y, z}; |
| 7654 | |
| 7655 | glUniform3iv(location, 1, (GLint*)&xyz); |
| 7656 | } |
| 7657 | |
| 7658 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 7659 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7660 | 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] | 7661 | |
| 7662 | try |
| 7663 | { |
| 7664 | if (count < 0) |
| 7665 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7666 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7667 | } |
| 7668 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7669 | if (location == -1) |
| 7670 | { |
| 7671 | return; |
| 7672 | } |
| 7673 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7674 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7675 | |
| 7676 | if (context) |
| 7677 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7678 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7679 | if (!programBinary) |
| 7680 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7681 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7682 | } |
| 7683 | |
| 7684 | if (!programBinary->setUniform3iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7685 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7686 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7687 | } |
| 7688 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7689 | } |
| 7690 | catch(std::bad_alloc&) |
| 7691 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7692 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7693 | } |
| 7694 | } |
| 7695 | |
| 7696 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7697 | { |
| 7698 | GLfloat xyzw[4] = {x, y, z, w}; |
| 7699 | |
| 7700 | glUniform4fv(location, 1, (GLfloat*)&xyzw); |
| 7701 | } |
| 7702 | |
| 7703 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 7704 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7705 | 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] | 7706 | |
| 7707 | try |
| 7708 | { |
| 7709 | if (count < 0) |
| 7710 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7711 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7712 | } |
| 7713 | |
| 7714 | if (location == -1) |
| 7715 | { |
| 7716 | return; |
| 7717 | } |
| 7718 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7719 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7720 | |
| 7721 | if (context) |
| 7722 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7723 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7724 | if (!programBinary) |
| 7725 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7726 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7727 | } |
| 7728 | |
| 7729 | if (!programBinary->setUniform4fv(location, count, v)) |
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_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7732 | } |
| 7733 | } |
| 7734 | } |
| 7735 | catch(std::bad_alloc&) |
| 7736 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7737 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7738 | } |
| 7739 | } |
| 7740 | |
| 7741 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 7742 | { |
| 7743 | GLint xyzw[4] = {x, y, z, w}; |
| 7744 | |
| 7745 | glUniform4iv(location, 1, (GLint*)&xyzw); |
| 7746 | } |
| 7747 | |
| 7748 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 7749 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7750 | 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] | 7751 | |
| 7752 | try |
| 7753 | { |
| 7754 | if (count < 0) |
| 7755 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7756 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7757 | } |
| 7758 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7759 | if (location == -1) |
| 7760 | { |
| 7761 | return; |
| 7762 | } |
| 7763 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7764 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7765 | |
| 7766 | if (context) |
| 7767 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7768 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7769 | if (!programBinary) |
| 7770 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7771 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7772 | } |
| 7773 | |
| 7774 | if (!programBinary->setUniform4iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7775 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7776 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7777 | } |
| 7778 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7779 | } |
| 7780 | catch(std::bad_alloc&) |
| 7781 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7782 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7783 | } |
| 7784 | } |
| 7785 | |
| 7786 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7787 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7788 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 7789 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7790 | |
| 7791 | try |
| 7792 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7793 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7794 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7795 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7796 | } |
| 7797 | |
| 7798 | if (location == -1) |
| 7799 | { |
| 7800 | return; |
| 7801 | } |
| 7802 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7803 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7804 | |
| 7805 | if (context) |
| 7806 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7807 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7808 | { |
| 7809 | return gl::error(GL_INVALID_VALUE); |
| 7810 | } |
| 7811 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7812 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7813 | if (!programBinary) |
| 7814 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7815 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7816 | } |
| 7817 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7818 | if (!programBinary->setUniformMatrix2fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7819 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7820 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7821 | } |
| 7822 | } |
| 7823 | } |
| 7824 | catch(std::bad_alloc&) |
| 7825 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7826 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7827 | } |
| 7828 | } |
| 7829 | |
| 7830 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7831 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7832 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 7833 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7834 | |
| 7835 | try |
| 7836 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7837 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7838 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7839 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7840 | } |
| 7841 | |
| 7842 | if (location == -1) |
| 7843 | { |
| 7844 | return; |
| 7845 | } |
| 7846 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7847 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7848 | |
| 7849 | if (context) |
| 7850 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7851 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7852 | { |
| 7853 | return gl::error(GL_INVALID_VALUE); |
| 7854 | } |
| 7855 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7856 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7857 | if (!programBinary) |
| 7858 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7859 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7860 | } |
| 7861 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7862 | if (!programBinary->setUniformMatrix3fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7863 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7864 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7865 | } |
| 7866 | } |
| 7867 | } |
| 7868 | catch(std::bad_alloc&) |
| 7869 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7870 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7871 | } |
| 7872 | } |
| 7873 | |
| 7874 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7875 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7876 | 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] | 7877 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7878 | |
| 7879 | try |
| 7880 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7881 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7882 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7883 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7884 | } |
| 7885 | |
| 7886 | if (location == -1) |
| 7887 | { |
| 7888 | return; |
| 7889 | } |
| 7890 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7891 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7892 | |
| 7893 | if (context) |
| 7894 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7895 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7896 | { |
| 7897 | return gl::error(GL_INVALID_VALUE); |
| 7898 | } |
| 7899 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7900 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7901 | if (!programBinary) |
| 7902 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7903 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7904 | } |
| 7905 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7906 | if (!programBinary->setUniformMatrix4fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 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 | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7909 | } |
| 7910 | } |
| 7911 | } |
| 7912 | catch(std::bad_alloc&) |
| 7913 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7914 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7915 | } |
| 7916 | } |
| 7917 | |
| 7918 | void __stdcall glUseProgram(GLuint program) |
| 7919 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7920 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7921 | |
| 7922 | try |
| 7923 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7924 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7925 | |
| 7926 | if (context) |
| 7927 | { |
| 7928 | gl::Program *programObject = context->getProgram(program); |
| 7929 | |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7930 | if (!programObject && program != 0) |
| 7931 | { |
| 7932 | if (context->getShader(program)) |
| 7933 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7934 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7935 | } |
| 7936 | else |
| 7937 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7938 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7939 | } |
| 7940 | } |
| 7941 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 7942 | if (program != 0 && !programObject->isLinked()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7943 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7944 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7945 | } |
| 7946 | |
| 7947 | context->useProgram(program); |
| 7948 | } |
| 7949 | } |
| 7950 | catch(std::bad_alloc&) |
| 7951 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7952 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7953 | } |
| 7954 | } |
| 7955 | |
| 7956 | void __stdcall glValidateProgram(GLuint program) |
| 7957 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7958 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7959 | |
| 7960 | try |
| 7961 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7962 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7963 | |
| 7964 | if (context) |
| 7965 | { |
| 7966 | gl::Program *programObject = context->getProgram(program); |
| 7967 | |
| 7968 | if (!programObject) |
| 7969 | { |
| 7970 | if (context->getShader(program)) |
| 7971 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7972 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7973 | } |
| 7974 | else |
| 7975 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7976 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7977 | } |
| 7978 | } |
| 7979 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 7980 | programObject->validate(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7981 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7982 | } |
| 7983 | catch(std::bad_alloc&) |
| 7984 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7985 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7986 | } |
| 7987 | } |
| 7988 | |
| 7989 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 7990 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7991 | EVENT("(GLuint index = %d, GLfloat x = %f)", index, x); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7992 | |
| 7993 | try |
| 7994 | { |
| 7995 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7996 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7997 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7998 | } |
| 7999 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8000 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8001 | |
| 8002 | if (context) |
| 8003 | { |
| 8004 | GLfloat vals[4] = { x, 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8005 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8006 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8007 | } |
| 8008 | catch(std::bad_alloc&) |
| 8009 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8010 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8011 | } |
| 8012 | } |
| 8013 | |
| 8014 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 8015 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8016 | 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] | 8017 | |
| 8018 | try |
| 8019 | { |
| 8020 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8021 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8022 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8023 | } |
| 8024 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8025 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8026 | |
| 8027 | if (context) |
| 8028 | { |
| 8029 | GLfloat vals[4] = { values[0], 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8030 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8031 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8032 | } |
| 8033 | catch(std::bad_alloc&) |
| 8034 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8035 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8036 | } |
| 8037 | } |
| 8038 | |
| 8039 | void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 8040 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8041 | 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] | 8042 | |
| 8043 | try |
| 8044 | { |
| 8045 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8046 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8047 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8048 | } |
| 8049 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8050 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8051 | |
| 8052 | if (context) |
| 8053 | { |
| 8054 | GLfloat vals[4] = { x, y, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8055 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8056 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8057 | } |
| 8058 | catch(std::bad_alloc&) |
| 8059 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8060 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8061 | } |
| 8062 | } |
| 8063 | |
| 8064 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 8065 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8066 | 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] | 8067 | |
| 8068 | try |
| 8069 | { |
| 8070 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8071 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8072 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8073 | } |
| 8074 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8075 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8076 | |
| 8077 | if (context) |
| 8078 | { |
| 8079 | 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] | 8080 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8081 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8082 | } |
| 8083 | catch(std::bad_alloc&) |
| 8084 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8085 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8086 | } |
| 8087 | } |
| 8088 | |
| 8089 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 8090 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8091 | 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] | 8092 | |
| 8093 | try |
| 8094 | { |
| 8095 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8096 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8097 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8098 | } |
| 8099 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8100 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8101 | |
| 8102 | if (context) |
| 8103 | { |
| 8104 | GLfloat vals[4] = { x, y, z, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8105 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8106 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8107 | } |
| 8108 | catch(std::bad_alloc&) |
| 8109 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8110 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8111 | } |
| 8112 | } |
| 8113 | |
| 8114 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 8115 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8116 | 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] | 8117 | |
| 8118 | try |
| 8119 | { |
| 8120 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8121 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8122 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8123 | } |
| 8124 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8125 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8126 | |
| 8127 | if (context) |
| 8128 | { |
| 8129 | 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] | 8130 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8131 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8132 | } |
| 8133 | catch(std::bad_alloc&) |
| 8134 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8135 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8136 | } |
| 8137 | } |
| 8138 | |
| 8139 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 8140 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8141 | 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] | 8142 | |
| 8143 | try |
| 8144 | { |
| 8145 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8146 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8147 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8148 | } |
| 8149 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8150 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8151 | |
| 8152 | if (context) |
| 8153 | { |
| 8154 | GLfloat vals[4] = { x, y, z, w }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8155 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8156 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8157 | } |
| 8158 | catch(std::bad_alloc&) |
| 8159 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8160 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8161 | } |
| 8162 | } |
| 8163 | |
| 8164 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 8165 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8166 | 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] | 8167 | |
| 8168 | try |
| 8169 | { |
| 8170 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8171 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8172 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8173 | } |
| 8174 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8175 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8176 | |
| 8177 | if (context) |
| 8178 | { |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8179 | context->setVertexAttribf(index, values); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8180 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8181 | } |
| 8182 | catch(std::bad_alloc&) |
| 8183 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8184 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8185 | } |
| 8186 | } |
| 8187 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8188 | void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
| 8189 | { |
| 8190 | EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor); |
| 8191 | |
| 8192 | try |
| 8193 | { |
| 8194 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 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 | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8197 | } |
| 8198 | |
| 8199 | gl::Context *context = gl::getNonLostContext(); |
| 8200 | |
| 8201 | if (context) |
| 8202 | { |
| 8203 | context->setVertexAttribDivisor(index, divisor); |
| 8204 | } |
| 8205 | } |
| 8206 | catch(std::bad_alloc&) |
| 8207 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8208 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8209 | } |
| 8210 | } |
| 8211 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 8212 | 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] | 8213 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8214 | 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] | 8215 | "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] | 8216 | index, size, type, normalized, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8217 | |
| 8218 | try |
| 8219 | { |
| 8220 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8221 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8222 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8223 | } |
| 8224 | |
| 8225 | if (size < 1 || size > 4) |
| 8226 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8227 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8228 | } |
| 8229 | |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 8230 | gl::Context *context = gl::getNonLostContext(); |
| 8231 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8232 | switch (type) |
| 8233 | { |
| 8234 | case GL_BYTE: |
| 8235 | case GL_UNSIGNED_BYTE: |
| 8236 | case GL_SHORT: |
| 8237 | case GL_UNSIGNED_SHORT: |
| 8238 | case GL_FIXED: |
| 8239 | case GL_FLOAT: |
| 8240 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 8241 | case GL_HALF_FLOAT: |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8242 | case GL_INT: |
| 8243 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 8244 | case GL_INT_2_10_10_10_REV: |
| 8245 | 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] | 8246 | if (context && context->getClientVersion() < 3) |
| 8247 | { |
| 8248 | return gl::error(GL_INVALID_ENUM); |
| 8249 | } |
| 8250 | else |
| 8251 | { |
| 8252 | break; |
| 8253 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8254 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8255 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8256 | } |
| 8257 | |
| 8258 | if (stride < 0) |
| 8259 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8260 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8261 | } |
| 8262 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 8263 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 8264 | { |
| 8265 | return gl::error(GL_INVALID_OPERATION); |
| 8266 | } |
| 8267 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8268 | if (context) |
| 8269 | { |
Jamie Madill | d8db866 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 8270 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 8271 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 8272 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 8273 | // and the pointer argument is not NULL. |
| 8274 | if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && ptr != NULL) |
| 8275 | { |
| 8276 | return gl::error(GL_INVALID_OPERATION); |
| 8277 | } |
| 8278 | |
shannon.woods%transgaming.com@gtempaccount.com | 8de4e6a | 2013-04-13 03:37:44 +0000 | [diff] [blame] | 8279 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, |
| 8280 | normalized == GL_TRUE, false, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8281 | } |
| 8282 | } |
| 8283 | catch(std::bad_alloc&) |
| 8284 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8285 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8286 | } |
| 8287 | } |
| 8288 | |
| 8289 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 8290 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8291 | 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] | 8292 | |
| 8293 | try |
| 8294 | { |
| 8295 | if (width < 0 || height < 0) |
| 8296 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8297 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8298 | } |
| 8299 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8300 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8301 | |
| 8302 | if (context) |
| 8303 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 8304 | context->setViewportParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8305 | } |
| 8306 | } |
| 8307 | catch(std::bad_alloc&) |
| 8308 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8309 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8310 | } |
| 8311 | } |
| 8312 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8313 | // OpenGL ES 3.0 functions |
| 8314 | |
| 8315 | void __stdcall glReadBuffer(GLenum mode) |
| 8316 | { |
| 8317 | EVENT("(GLenum mode = 0x%X)", mode); |
| 8318 | |
| 8319 | try |
| 8320 | { |
| 8321 | gl::Context *context = gl::getNonLostContext(); |
| 8322 | |
| 8323 | if (context) |
| 8324 | { |
| 8325 | if (context->getClientVersion() < 3) |
| 8326 | { |
| 8327 | return gl::error(GL_INVALID_OPERATION); |
| 8328 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8329 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8330 | // glReadBuffer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8331 | UNIMPLEMENTED(); |
| 8332 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8333 | } |
| 8334 | catch(std::bad_alloc&) |
| 8335 | { |
| 8336 | return gl::error(GL_OUT_OF_MEMORY); |
| 8337 | } |
| 8338 | } |
| 8339 | |
| 8340 | void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) |
| 8341 | { |
| 8342 | EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, " |
| 8343 | "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices); |
| 8344 | |
| 8345 | try |
| 8346 | { |
| 8347 | gl::Context *context = gl::getNonLostContext(); |
| 8348 | |
| 8349 | if (context) |
| 8350 | { |
| 8351 | if (context->getClientVersion() < 3) |
| 8352 | { |
| 8353 | return gl::error(GL_INVALID_OPERATION); |
| 8354 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8355 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8356 | // glDrawRangeElements |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8357 | UNIMPLEMENTED(); |
| 8358 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8359 | } |
| 8360 | catch(std::bad_alloc&) |
| 8361 | { |
| 8362 | return gl::error(GL_OUT_OF_MEMORY); |
| 8363 | } |
| 8364 | } |
| 8365 | |
| 8366 | void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
| 8367 | { |
| 8368 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8369 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " |
| 8370 | "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8371 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 8372 | |
| 8373 | try |
| 8374 | { |
| 8375 | gl::Context *context = gl::getNonLostContext(); |
| 8376 | |
| 8377 | if (context) |
| 8378 | { |
| 8379 | if (context->getClientVersion() < 3) |
| 8380 | { |
| 8381 | return gl::error(GL_INVALID_OPERATION); |
| 8382 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8383 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8384 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8385 | if (!validateES3TexImageParameters(context, target, level, internalformat, false, false, |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8386 | 0, 0, 0, width, height, depth, border, format, type)) |
| 8387 | { |
| 8388 | return; |
| 8389 | } |
| 8390 | |
| 8391 | switch(target) |
| 8392 | { |
| 8393 | case GL_TEXTURE_3D: |
| 8394 | { |
| 8395 | gl::Texture3D *texture = context->getTexture3D(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8396 | 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] | 8397 | } |
| 8398 | break; |
| 8399 | |
| 8400 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8401 | { |
| 8402 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8403 | 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] | 8404 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8405 | break; |
| 8406 | |
| 8407 | default: |
| 8408 | return gl::error(GL_INVALID_ENUM); |
| 8409 | } |
| 8410 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8411 | } |
| 8412 | catch(std::bad_alloc&) |
| 8413 | { |
| 8414 | return gl::error(GL_OUT_OF_MEMORY); |
| 8415 | } |
| 8416 | } |
| 8417 | |
| 8418 | 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) |
| 8419 | { |
| 8420 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8421 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8422 | "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8423 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); |
| 8424 | |
| 8425 | try |
| 8426 | { |
| 8427 | gl::Context *context = gl::getNonLostContext(); |
| 8428 | |
| 8429 | if (context) |
| 8430 | { |
| 8431 | if (context->getClientVersion() < 3) |
| 8432 | { |
| 8433 | return gl::error(GL_INVALID_OPERATION); |
| 8434 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8435 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8436 | if (!pixels) |
| 8437 | { |
| 8438 | return gl::error(GL_INVALID_VALUE); |
| 8439 | } |
| 8440 | |
| 8441 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8442 | 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] | 8443 | xoffset, yoffset, zoffset, width, height, depth, 0, |
| 8444 | format, type)) |
| 8445 | { |
| 8446 | return; |
| 8447 | } |
| 8448 | |
| 8449 | switch(target) |
| 8450 | { |
| 8451 | case GL_TEXTURE_3D: |
| 8452 | { |
| 8453 | gl::Texture3D *texture = context->getTexture3D(); |
| 8454 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8455 | } |
| 8456 | break; |
| 8457 | |
| 8458 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8459 | { |
| 8460 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8461 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8462 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8463 | break; |
| 8464 | |
| 8465 | default: |
| 8466 | return gl::error(GL_INVALID_ENUM); |
| 8467 | } |
| 8468 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8469 | } |
| 8470 | catch(std::bad_alloc&) |
| 8471 | { |
| 8472 | return gl::error(GL_OUT_OF_MEMORY); |
| 8473 | } |
| 8474 | } |
| 8475 | |
| 8476 | void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 8477 | { |
| 8478 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8479 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 8480 | target, level, xoffset, yoffset, zoffset, x, y, width, height); |
| 8481 | |
| 8482 | try |
| 8483 | { |
| 8484 | gl::Context *context = gl::getNonLostContext(); |
| 8485 | |
| 8486 | if (context) |
| 8487 | { |
| 8488 | if (context->getClientVersion() < 3) |
| 8489 | { |
| 8490 | return gl::error(GL_INVALID_OPERATION); |
| 8491 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8492 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8493 | if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset, |
| 8494 | x, y, width, height, 0)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8495 | { |
| 8496 | return; |
| 8497 | } |
| 8498 | |
| 8499 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 8500 | gl::Texture *texture = NULL; |
| 8501 | switch (target) |
| 8502 | { |
| 8503 | case GL_TEXTURE_3D: |
| 8504 | texture = context->getTexture3D(); |
| 8505 | break; |
| 8506 | |
| 8507 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8508 | texture = context->getTexture2DArray(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8509 | break; |
| 8510 | |
| 8511 | default: |
| 8512 | return gl::error(GL_INVALID_ENUM); |
| 8513 | } |
| 8514 | |
| 8515 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer); |
| 8516 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8517 | } |
| 8518 | catch(std::bad_alloc&) |
| 8519 | { |
| 8520 | return gl::error(GL_OUT_OF_MEMORY); |
| 8521 | } |
| 8522 | } |
| 8523 | |
| 8524 | void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) |
| 8525 | { |
| 8526 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8527 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, " |
| 8528 | "const GLvoid* data = 0x%0.8p)", |
| 8529 | target, level, internalformat, width, height, depth, border, imageSize, data); |
| 8530 | |
| 8531 | try |
| 8532 | { |
| 8533 | gl::Context *context = gl::getNonLostContext(); |
| 8534 | |
| 8535 | if (context) |
| 8536 | { |
| 8537 | if (context->getClientVersion() < 3) |
| 8538 | { |
| 8539 | return gl::error(GL_INVALID_OPERATION); |
| 8540 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8541 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8542 | 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] | 8543 | { |
| 8544 | return gl::error(GL_INVALID_VALUE); |
| 8545 | } |
| 8546 | |
| 8547 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8548 | if (!validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 8549 | 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] | 8550 | { |
| 8551 | return; |
| 8552 | } |
| 8553 | |
| 8554 | switch(target) |
| 8555 | { |
| 8556 | case GL_TEXTURE_3D: |
| 8557 | { |
| 8558 | gl::Texture3D *texture = context->getTexture3D(); |
| 8559 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8560 | } |
| 8561 | break; |
| 8562 | |
| 8563 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8564 | { |
| 8565 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8566 | texture->setCompressedImage(level, internalformat, width, height, depth, 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 glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) |
| 8582 | { |
| 8583 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8584 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8585 | "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 8586 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); |
| 8587 | |
| 8588 | try |
| 8589 | { |
| 8590 | gl::Context *context = gl::getNonLostContext(); |
| 8591 | |
| 8592 | if (context) |
| 8593 | { |
| 8594 | if (context->getClientVersion() < 3) |
| 8595 | { |
| 8596 | return gl::error(GL_INVALID_OPERATION); |
| 8597 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8598 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8599 | 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] | 8600 | { |
| 8601 | return gl::error(GL_INVALID_VALUE); |
| 8602 | } |
| 8603 | |
| 8604 | if (!data) |
| 8605 | { |
| 8606 | return gl::error(GL_INVALID_VALUE); |
| 8607 | } |
| 8608 | |
| 8609 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8610 | if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 8611 | 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] | 8612 | { |
| 8613 | return; |
| 8614 | } |
| 8615 | |
| 8616 | switch(target) |
| 8617 | { |
| 8618 | case GL_TEXTURE_3D: |
| 8619 | { |
| 8620 | gl::Texture3D *texture = context->getTexture3D(); |
| 8621 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8622 | format, imageSize, data); |
| 8623 | } |
| 8624 | break; |
| 8625 | |
| 8626 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8627 | { |
| 8628 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8629 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8630 | format, imageSize, data); |
| 8631 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8632 | break; |
| 8633 | |
| 8634 | default: |
| 8635 | return gl::error(GL_INVALID_ENUM); |
| 8636 | } |
| 8637 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8638 | } |
| 8639 | catch(std::bad_alloc&) |
| 8640 | { |
| 8641 | return gl::error(GL_OUT_OF_MEMORY); |
| 8642 | } |
| 8643 | } |
| 8644 | |
| 8645 | void __stdcall glGenQueries(GLsizei n, GLuint* ids) |
| 8646 | { |
| 8647 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8648 | |
| 8649 | try |
| 8650 | { |
| 8651 | gl::Context *context = gl::getNonLostContext(); |
| 8652 | |
| 8653 | if (context) |
| 8654 | { |
| 8655 | if (context->getClientVersion() < 3) |
| 8656 | { |
| 8657 | return gl::error(GL_INVALID_OPERATION); |
| 8658 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8659 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8660 | // glGenQueries |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8661 | UNIMPLEMENTED(); |
| 8662 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8663 | } |
| 8664 | catch(std::bad_alloc&) |
| 8665 | { |
| 8666 | return gl::error(GL_OUT_OF_MEMORY); |
| 8667 | } |
| 8668 | } |
| 8669 | |
| 8670 | void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids) |
| 8671 | { |
| 8672 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8673 | |
| 8674 | try |
| 8675 | { |
| 8676 | gl::Context *context = gl::getNonLostContext(); |
| 8677 | |
| 8678 | if (context) |
| 8679 | { |
| 8680 | if (context->getClientVersion() < 3) |
| 8681 | { |
| 8682 | return gl::error(GL_INVALID_OPERATION); |
| 8683 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8684 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8685 | // glDeleteQueries |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8686 | UNIMPLEMENTED(); |
| 8687 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8688 | } |
| 8689 | catch(std::bad_alloc&) |
| 8690 | { |
| 8691 | return gl::error(GL_OUT_OF_MEMORY); |
| 8692 | } |
| 8693 | } |
| 8694 | |
| 8695 | GLboolean __stdcall glIsQuery(GLuint id) |
| 8696 | { |
| 8697 | EVENT("(GLuint id = %u)", id); |
| 8698 | |
| 8699 | try |
| 8700 | { |
| 8701 | gl::Context *context = gl::getNonLostContext(); |
| 8702 | |
| 8703 | if (context) |
| 8704 | { |
| 8705 | if (context->getClientVersion() < 3) |
| 8706 | { |
| 8707 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8708 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8709 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8710 | // glIsQuery |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8711 | UNIMPLEMENTED(); |
| 8712 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8713 | } |
| 8714 | catch(std::bad_alloc&) |
| 8715 | { |
| 8716 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8717 | } |
| 8718 | |
| 8719 | return GL_FALSE; |
| 8720 | } |
| 8721 | |
| 8722 | void __stdcall glBeginQuery(GLenum target, GLuint id) |
| 8723 | { |
| 8724 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 8725 | |
| 8726 | try |
| 8727 | { |
| 8728 | gl::Context *context = gl::getNonLostContext(); |
| 8729 | |
| 8730 | if (context) |
| 8731 | { |
| 8732 | if (context->getClientVersion() < 3) |
| 8733 | { |
| 8734 | return gl::error(GL_INVALID_OPERATION); |
| 8735 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8736 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8737 | // glBeginQuery |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8738 | UNIMPLEMENTED(); |
| 8739 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8740 | } |
| 8741 | catch(std::bad_alloc&) |
| 8742 | { |
| 8743 | return gl::error(GL_OUT_OF_MEMORY); |
| 8744 | } |
| 8745 | } |
| 8746 | |
| 8747 | void __stdcall glEndQuery(GLenum target) |
| 8748 | { |
| 8749 | EVENT("(GLenum target = 0x%X)", target); |
| 8750 | |
| 8751 | try |
| 8752 | { |
| 8753 | gl::Context *context = gl::getNonLostContext(); |
| 8754 | |
| 8755 | if (context) |
| 8756 | { |
| 8757 | if (context->getClientVersion() < 3) |
| 8758 | { |
| 8759 | return gl::error(GL_INVALID_OPERATION); |
| 8760 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8761 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8762 | // glEndQuery |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8763 | UNIMPLEMENTED(); |
| 8764 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8765 | } |
| 8766 | catch(std::bad_alloc&) |
| 8767 | { |
| 8768 | return gl::error(GL_OUT_OF_MEMORY); |
| 8769 | } |
| 8770 | } |
| 8771 | |
| 8772 | void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params) |
| 8773 | { |
| 8774 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
| 8775 | |
| 8776 | try |
| 8777 | { |
| 8778 | gl::Context *context = gl::getNonLostContext(); |
| 8779 | |
| 8780 | if (context) |
| 8781 | { |
| 8782 | if (context->getClientVersion() < 3) |
| 8783 | { |
| 8784 | return gl::error(GL_INVALID_OPERATION); |
| 8785 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8786 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8787 | // glGetQueryiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8788 | UNIMPLEMENTED(); |
| 8789 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8790 | } |
| 8791 | catch(std::bad_alloc&) |
| 8792 | { |
| 8793 | return gl::error(GL_OUT_OF_MEMORY); |
| 8794 | } |
| 8795 | } |
| 8796 | |
| 8797 | void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) |
| 8798 | { |
| 8799 | EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params); |
| 8800 | |
| 8801 | try |
| 8802 | { |
| 8803 | gl::Context *context = gl::getNonLostContext(); |
| 8804 | |
| 8805 | if (context) |
| 8806 | { |
| 8807 | if (context->getClientVersion() < 3) |
| 8808 | { |
| 8809 | return gl::error(GL_INVALID_OPERATION); |
| 8810 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8811 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8812 | // glGetQueryObjectuiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8813 | UNIMPLEMENTED(); |
| 8814 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8815 | } |
| 8816 | catch(std::bad_alloc&) |
| 8817 | { |
| 8818 | return gl::error(GL_OUT_OF_MEMORY); |
| 8819 | } |
| 8820 | } |
| 8821 | |
| 8822 | GLboolean __stdcall glUnmapBuffer(GLenum target) |
| 8823 | { |
| 8824 | EVENT("(GLenum target = 0x%X)", target); |
| 8825 | |
| 8826 | try |
| 8827 | { |
| 8828 | gl::Context *context = gl::getNonLostContext(); |
| 8829 | |
| 8830 | if (context) |
| 8831 | { |
| 8832 | if (context->getClientVersion() < 3) |
| 8833 | { |
| 8834 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8835 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8836 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8837 | // glUnmapBuffer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8838 | UNIMPLEMENTED(); |
| 8839 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8840 | } |
| 8841 | catch(std::bad_alloc&) |
| 8842 | { |
| 8843 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8844 | } |
| 8845 | |
| 8846 | return GL_FALSE; |
| 8847 | } |
| 8848 | |
| 8849 | void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) |
| 8850 | { |
| 8851 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 8852 | |
| 8853 | try |
| 8854 | { |
| 8855 | gl::Context *context = gl::getNonLostContext(); |
| 8856 | |
| 8857 | if (context) |
| 8858 | { |
| 8859 | if (context->getClientVersion() < 3) |
| 8860 | { |
| 8861 | return gl::error(GL_INVALID_OPERATION); |
| 8862 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8863 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8864 | // glGetBufferPointerv |
shannonwoods@chromium.org | 2d2190a | 2013-05-30 00:17:35 +0000 | [diff] [blame] | 8865 | UNIMPLEMENTED(); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8866 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8867 | } |
| 8868 | catch(std::bad_alloc&) |
| 8869 | { |
| 8870 | return gl::error(GL_OUT_OF_MEMORY); |
| 8871 | } |
| 8872 | } |
| 8873 | |
| 8874 | void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs) |
| 8875 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8876 | try |
| 8877 | { |
| 8878 | gl::Context *context = gl::getNonLostContext(); |
| 8879 | |
| 8880 | if (context) |
| 8881 | { |
| 8882 | if (context->getClientVersion() < 3) |
| 8883 | { |
| 8884 | return gl::error(GL_INVALID_OPERATION); |
| 8885 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8886 | |
shannon.woods%transgaming.com@gtempaccount.com | 7948c5f | 2013-04-13 03:38:58 +0000 | [diff] [blame] | 8887 | glDrawBuffersEXT(n, bufs); |
| 8888 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8889 | } |
| 8890 | catch(std::bad_alloc&) |
| 8891 | { |
| 8892 | return gl::error(GL_OUT_OF_MEMORY); |
| 8893 | } |
| 8894 | } |
| 8895 | |
| 8896 | void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8897 | { |
| 8898 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8899 | location, count, transpose, value); |
| 8900 | |
| 8901 | try |
| 8902 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8903 | if (count < 0) |
| 8904 | { |
| 8905 | return gl::error(GL_INVALID_VALUE); |
| 8906 | } |
| 8907 | |
| 8908 | if (location == -1) |
| 8909 | { |
| 8910 | return; |
| 8911 | } |
| 8912 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8913 | gl::Context *context = gl::getNonLostContext(); |
| 8914 | |
| 8915 | if (context) |
| 8916 | { |
| 8917 | if (context->getClientVersion() < 3) |
| 8918 | { |
| 8919 | return gl::error(GL_INVALID_OPERATION); |
| 8920 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8921 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8922 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8923 | if (!programBinary) |
| 8924 | { |
| 8925 | return gl::error(GL_INVALID_OPERATION); |
| 8926 | } |
| 8927 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8928 | if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8929 | { |
| 8930 | return gl::error(GL_INVALID_OPERATION); |
| 8931 | } |
| 8932 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8933 | } |
| 8934 | catch(std::bad_alloc&) |
| 8935 | { |
| 8936 | return gl::error(GL_OUT_OF_MEMORY); |
| 8937 | } |
| 8938 | } |
| 8939 | |
| 8940 | void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8941 | { |
| 8942 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8943 | location, count, transpose, value); |
| 8944 | |
| 8945 | try |
| 8946 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8947 | if (count < 0) |
| 8948 | { |
| 8949 | return gl::error(GL_INVALID_VALUE); |
| 8950 | } |
| 8951 | |
| 8952 | if (location == -1) |
| 8953 | { |
| 8954 | return; |
| 8955 | } |
| 8956 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8957 | gl::Context *context = gl::getNonLostContext(); |
| 8958 | |
| 8959 | if (context) |
| 8960 | { |
| 8961 | if (context->getClientVersion() < 3) |
| 8962 | { |
| 8963 | return gl::error(GL_INVALID_OPERATION); |
| 8964 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8965 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8966 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8967 | if (!programBinary) |
| 8968 | { |
| 8969 | return gl::error(GL_INVALID_OPERATION); |
| 8970 | } |
| 8971 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8972 | if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8973 | { |
| 8974 | return gl::error(GL_INVALID_OPERATION); |
| 8975 | } |
| 8976 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8977 | } |
| 8978 | catch(std::bad_alloc&) |
| 8979 | { |
| 8980 | return gl::error(GL_OUT_OF_MEMORY); |
| 8981 | } |
| 8982 | } |
| 8983 | |
| 8984 | void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8985 | { |
| 8986 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8987 | location, count, transpose, value); |
| 8988 | |
| 8989 | try |
| 8990 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8991 | if (count < 0) |
| 8992 | { |
| 8993 | return gl::error(GL_INVALID_VALUE); |
| 8994 | } |
| 8995 | |
| 8996 | if (location == -1) |
| 8997 | { |
| 8998 | return; |
| 8999 | } |
| 9000 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9001 | gl::Context *context = gl::getNonLostContext(); |
| 9002 | |
| 9003 | if (context) |
| 9004 | { |
| 9005 | if (context->getClientVersion() < 3) |
| 9006 | { |
| 9007 | return gl::error(GL_INVALID_OPERATION); |
| 9008 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9009 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9010 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9011 | if (!programBinary) |
| 9012 | { |
| 9013 | return gl::error(GL_INVALID_OPERATION); |
| 9014 | } |
| 9015 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9016 | if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9017 | { |
| 9018 | return gl::error(GL_INVALID_OPERATION); |
| 9019 | } |
| 9020 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9021 | } |
| 9022 | catch(std::bad_alloc&) |
| 9023 | { |
| 9024 | return gl::error(GL_OUT_OF_MEMORY); |
| 9025 | } |
| 9026 | } |
| 9027 | |
| 9028 | void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 9029 | { |
| 9030 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 9031 | location, count, transpose, value); |
| 9032 | |
| 9033 | try |
| 9034 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9035 | if (count < 0) |
| 9036 | { |
| 9037 | return gl::error(GL_INVALID_VALUE); |
| 9038 | } |
| 9039 | |
| 9040 | if (location == -1) |
| 9041 | { |
| 9042 | return; |
| 9043 | } |
| 9044 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9045 | gl::Context *context = gl::getNonLostContext(); |
| 9046 | |
| 9047 | if (context) |
| 9048 | { |
| 9049 | if (context->getClientVersion() < 3) |
| 9050 | { |
| 9051 | return gl::error(GL_INVALID_OPERATION); |
| 9052 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9053 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9054 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9055 | if (!programBinary) |
| 9056 | { |
| 9057 | return gl::error(GL_INVALID_OPERATION); |
| 9058 | } |
| 9059 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9060 | if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9061 | { |
| 9062 | return gl::error(GL_INVALID_OPERATION); |
| 9063 | } |
| 9064 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9065 | } |
| 9066 | catch(std::bad_alloc&) |
| 9067 | { |
| 9068 | return gl::error(GL_OUT_OF_MEMORY); |
| 9069 | } |
| 9070 | } |
| 9071 | |
| 9072 | void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 9073 | { |
| 9074 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 9075 | location, count, transpose, value); |
| 9076 | |
| 9077 | try |
| 9078 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9079 | if (count < 0) |
| 9080 | { |
| 9081 | return gl::error(GL_INVALID_VALUE); |
| 9082 | } |
| 9083 | |
| 9084 | if (location == -1) |
| 9085 | { |
| 9086 | return; |
| 9087 | } |
| 9088 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9089 | gl::Context *context = gl::getNonLostContext(); |
| 9090 | |
| 9091 | if (context) |
| 9092 | { |
| 9093 | if (context->getClientVersion() < 3) |
| 9094 | { |
| 9095 | return gl::error(GL_INVALID_OPERATION); |
| 9096 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9097 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9098 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9099 | if (!programBinary) |
| 9100 | { |
| 9101 | return gl::error(GL_INVALID_OPERATION); |
| 9102 | } |
| 9103 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9104 | if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9105 | { |
| 9106 | return gl::error(GL_INVALID_OPERATION); |
| 9107 | } |
| 9108 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9109 | } |
| 9110 | catch(std::bad_alloc&) |
| 9111 | { |
| 9112 | return gl::error(GL_OUT_OF_MEMORY); |
| 9113 | } |
| 9114 | } |
| 9115 | |
| 9116 | void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 9117 | { |
| 9118 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 9119 | location, count, transpose, value); |
| 9120 | |
| 9121 | try |
| 9122 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9123 | if (count < 0) |
| 9124 | { |
| 9125 | return gl::error(GL_INVALID_VALUE); |
| 9126 | } |
| 9127 | |
| 9128 | if (location == -1) |
| 9129 | { |
| 9130 | return; |
| 9131 | } |
| 9132 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9133 | gl::Context *context = gl::getNonLostContext(); |
| 9134 | |
| 9135 | if (context) |
| 9136 | { |
| 9137 | if (context->getClientVersion() < 3) |
| 9138 | { |
| 9139 | return gl::error(GL_INVALID_OPERATION); |
| 9140 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9141 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9142 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9143 | if (!programBinary) |
| 9144 | { |
| 9145 | return gl::error(GL_INVALID_OPERATION); |
| 9146 | } |
| 9147 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9148 | if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9149 | { |
| 9150 | return gl::error(GL_INVALID_OPERATION); |
| 9151 | } |
| 9152 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9153 | } |
| 9154 | catch(std::bad_alloc&) |
| 9155 | { |
| 9156 | return gl::error(GL_OUT_OF_MEMORY); |
| 9157 | } |
| 9158 | } |
| 9159 | |
| 9160 | void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) |
| 9161 | { |
| 9162 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, " |
| 9163 | "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 9164 | srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 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 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 9177 | if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 9178 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 9179 | false)) |
| 9180 | { |
| 9181 | return; |
| 9182 | } |
| 9183 | |
| 9184 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 9185 | mask, filter); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9186 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9187 | } |
| 9188 | catch(std::bad_alloc&) |
| 9189 | { |
| 9190 | return gl::error(GL_OUT_OF_MEMORY); |
| 9191 | } |
| 9192 | } |
| 9193 | |
| 9194 | void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| 9195 | { |
| 9196 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 9197 | target, samples, internalformat, width, height); |
| 9198 | |
| 9199 | try |
| 9200 | { |
| 9201 | gl::Context *context = gl::getNonLostContext(); |
| 9202 | |
| 9203 | if (context) |
| 9204 | { |
| 9205 | if (context->getClientVersion() < 3) |
| 9206 | { |
| 9207 | return gl::error(GL_INVALID_OPERATION); |
| 9208 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9209 | |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 9210 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 9211 | width, height, false)) |
| 9212 | { |
| 9213 | return; |
| 9214 | } |
| 9215 | |
| 9216 | context->setRenderbufferStorage(width, height, internalformat, samples); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9217 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9218 | } |
| 9219 | catch(std::bad_alloc&) |
| 9220 | { |
| 9221 | return gl::error(GL_OUT_OF_MEMORY); |
| 9222 | } |
| 9223 | } |
| 9224 | |
| 9225 | void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) |
| 9226 | { |
| 9227 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)", |
| 9228 | target, attachment, texture, level, layer); |
| 9229 | |
| 9230 | try |
| 9231 | { |
| 9232 | gl::Context *context = gl::getNonLostContext(); |
| 9233 | |
| 9234 | if (context) |
| 9235 | { |
| 9236 | if (context->getClientVersion() < 3) |
| 9237 | { |
| 9238 | return gl::error(GL_INVALID_OPERATION); |
| 9239 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9240 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9241 | // glFramebufferTextureLayer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9242 | UNIMPLEMENTED(); |
| 9243 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9244 | } |
| 9245 | catch(std::bad_alloc&) |
| 9246 | { |
| 9247 | return gl::error(GL_OUT_OF_MEMORY); |
| 9248 | } |
| 9249 | } |
| 9250 | |
| 9251 | GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 9252 | { |
| 9253 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 9254 | target, offset, length, access); |
| 9255 | |
| 9256 | try |
| 9257 | { |
| 9258 | gl::Context *context = gl::getNonLostContext(); |
| 9259 | |
| 9260 | if (context) |
| 9261 | { |
| 9262 | if (context->getClientVersion() < 3) |
| 9263 | { |
| 9264 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 9265 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9266 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9267 | // glMapBufferRange |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9268 | UNIMPLEMENTED(); |
| 9269 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9270 | } |
| 9271 | catch(std::bad_alloc&) |
| 9272 | { |
| 9273 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL)); |
| 9274 | } |
| 9275 | |
| 9276 | return NULL; |
| 9277 | } |
| 9278 | |
| 9279 | void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) |
| 9280 | { |
| 9281 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 9282 | |
| 9283 | try |
| 9284 | { |
| 9285 | gl::Context *context = gl::getNonLostContext(); |
| 9286 | |
| 9287 | if (context) |
| 9288 | { |
| 9289 | if (context->getClientVersion() < 3) |
| 9290 | { |
| 9291 | return gl::error(GL_INVALID_OPERATION); |
| 9292 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9293 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9294 | // glFlushMappedBufferRange |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9295 | UNIMPLEMENTED(); |
| 9296 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9297 | } |
| 9298 | catch(std::bad_alloc&) |
| 9299 | { |
| 9300 | return gl::error(GL_OUT_OF_MEMORY); |
| 9301 | } |
| 9302 | } |
| 9303 | |
| 9304 | void __stdcall glBindVertexArray(GLuint array) |
| 9305 | { |
| 9306 | EVENT("(GLuint array = %u)", array); |
| 9307 | |
| 9308 | try |
| 9309 | { |
| 9310 | gl::Context *context = gl::getNonLostContext(); |
| 9311 | |
| 9312 | if (context) |
| 9313 | { |
| 9314 | if (context->getClientVersion() < 3) |
| 9315 | { |
| 9316 | return gl::error(GL_INVALID_OPERATION); |
| 9317 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9318 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9319 | gl::VertexArray *vao = context->getVertexArray(array); |
| 9320 | |
| 9321 | if (!vao) |
| 9322 | { |
| 9323 | // The default VAO should always exist |
| 9324 | ASSERT(array != 0); |
| 9325 | return gl::error(GL_INVALID_OPERATION); |
| 9326 | } |
| 9327 | |
| 9328 | context->bindVertexArray(array); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9329 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9330 | } |
| 9331 | catch(std::bad_alloc&) |
| 9332 | { |
| 9333 | return gl::error(GL_OUT_OF_MEMORY); |
| 9334 | } |
| 9335 | } |
| 9336 | |
| 9337 | void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) |
| 9338 | { |
| 9339 | EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays); |
| 9340 | |
| 9341 | try |
| 9342 | { |
| 9343 | gl::Context *context = gl::getNonLostContext(); |
| 9344 | |
| 9345 | if (context) |
| 9346 | { |
| 9347 | if (context->getClientVersion() < 3) |
| 9348 | { |
| 9349 | return gl::error(GL_INVALID_OPERATION); |
| 9350 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9351 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9352 | if (n < 0) |
| 9353 | { |
| 9354 | return gl::error(GL_INVALID_VALUE); |
| 9355 | } |
| 9356 | |
| 9357 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 9358 | { |
| 9359 | if (arrays[arrayIndex] != 0) |
| 9360 | { |
| 9361 | context->deleteVertexArray(arrays[arrayIndex]); |
| 9362 | } |
| 9363 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9364 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9365 | } |
| 9366 | catch(std::bad_alloc&) |
| 9367 | { |
| 9368 | return gl::error(GL_OUT_OF_MEMORY); |
| 9369 | } |
| 9370 | } |
| 9371 | |
| 9372 | void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) |
| 9373 | { |
| 9374 | EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays); |
| 9375 | |
| 9376 | try |
| 9377 | { |
| 9378 | gl::Context *context = gl::getNonLostContext(); |
| 9379 | |
| 9380 | if (context) |
| 9381 | { |
| 9382 | if (context->getClientVersion() < 3) |
| 9383 | { |
| 9384 | return gl::error(GL_INVALID_OPERATION); |
| 9385 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9386 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9387 | if (n < 0) |
| 9388 | { |
| 9389 | return gl::error(GL_INVALID_VALUE); |
| 9390 | } |
| 9391 | |
| 9392 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 9393 | { |
| 9394 | arrays[arrayIndex] = context->createVertexArray(); |
| 9395 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9396 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9397 | } |
| 9398 | catch(std::bad_alloc&) |
| 9399 | { |
| 9400 | return gl::error(GL_OUT_OF_MEMORY); |
| 9401 | } |
| 9402 | } |
| 9403 | |
| 9404 | GLboolean __stdcall glIsVertexArray(GLuint array) |
| 9405 | { |
| 9406 | EVENT("(GLuint array = %u)", array); |
| 9407 | |
| 9408 | try |
| 9409 | { |
| 9410 | gl::Context *context = gl::getNonLostContext(); |
| 9411 | |
| 9412 | if (context) |
| 9413 | { |
| 9414 | if (context->getClientVersion() < 3) |
| 9415 | { |
| 9416 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 9417 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9418 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9419 | if (array == 0) |
| 9420 | { |
| 9421 | return GL_FALSE; |
| 9422 | } |
| 9423 | |
| 9424 | gl::VertexArray *vao = context->getVertexArray(array); |
| 9425 | |
| 9426 | return (vao != NULL ? GL_TRUE : GL_FALSE); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9427 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9428 | } |
| 9429 | catch(std::bad_alloc&) |
| 9430 | { |
| 9431 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 9432 | } |
| 9433 | |
| 9434 | return GL_FALSE; |
| 9435 | } |
| 9436 | |
| 9437 | void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data) |
| 9438 | { |
| 9439 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)", |
| 9440 | target, index, data); |
| 9441 | |
| 9442 | try |
| 9443 | { |
| 9444 | gl::Context *context = gl::getNonLostContext(); |
| 9445 | |
| 9446 | if (context) |
| 9447 | { |
| 9448 | if (context->getClientVersion() < 3) |
| 9449 | { |
| 9450 | return gl::error(GL_INVALID_OPERATION); |
| 9451 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9452 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9453 | // glGetIntegeri_v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9454 | UNIMPLEMENTED(); |
| 9455 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9456 | } |
| 9457 | catch(std::bad_alloc&) |
| 9458 | { |
| 9459 | return gl::error(GL_OUT_OF_MEMORY); |
| 9460 | } |
| 9461 | } |
| 9462 | |
| 9463 | void __stdcall glBeginTransformFeedback(GLenum primitiveMode) |
| 9464 | { |
| 9465 | EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode); |
| 9466 | |
| 9467 | try |
| 9468 | { |
| 9469 | gl::Context *context = gl::getNonLostContext(); |
| 9470 | |
| 9471 | if (context) |
| 9472 | { |
| 9473 | if (context->getClientVersion() < 3) |
| 9474 | { |
| 9475 | return gl::error(GL_INVALID_OPERATION); |
| 9476 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9477 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9478 | // glBeginTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9479 | UNIMPLEMENTED(); |
| 9480 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9481 | } |
| 9482 | catch(std::bad_alloc&) |
| 9483 | { |
| 9484 | return gl::error(GL_OUT_OF_MEMORY); |
| 9485 | } |
| 9486 | } |
| 9487 | |
| 9488 | void __stdcall glEndTransformFeedback(void) |
| 9489 | { |
| 9490 | EVENT("(void)"); |
| 9491 | |
| 9492 | try |
| 9493 | { |
| 9494 | gl::Context *context = gl::getNonLostContext(); |
| 9495 | |
| 9496 | if (context) |
| 9497 | { |
| 9498 | if (context->getClientVersion() < 3) |
| 9499 | { |
| 9500 | return gl::error(GL_INVALID_OPERATION); |
| 9501 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9502 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9503 | // glEndTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9504 | UNIMPLEMENTED(); |
| 9505 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9506 | } |
| 9507 | catch(std::bad_alloc&) |
| 9508 | { |
| 9509 | return gl::error(GL_OUT_OF_MEMORY); |
| 9510 | } |
| 9511 | } |
| 9512 | |
| 9513 | void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
| 9514 | { |
| 9515 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)", |
| 9516 | target, index, buffer, offset, size); |
| 9517 | |
| 9518 | try |
| 9519 | { |
| 9520 | gl::Context *context = gl::getNonLostContext(); |
| 9521 | |
| 9522 | if (context) |
| 9523 | { |
| 9524 | if (context->getClientVersion() < 3) |
| 9525 | { |
| 9526 | return gl::error(GL_INVALID_OPERATION); |
| 9527 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9528 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9529 | switch (target) |
| 9530 | { |
| 9531 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9532 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9533 | { |
| 9534 | return gl::error(GL_INVALID_VALUE); |
| 9535 | } |
| 9536 | break; |
| 9537 | |
| 9538 | case GL_UNIFORM_BUFFER: |
| 9539 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 9540 | { |
| 9541 | return gl::error(GL_INVALID_VALUE); |
| 9542 | } |
| 9543 | break; |
| 9544 | |
| 9545 | default: |
| 9546 | return gl::error(GL_INVALID_ENUM); |
| 9547 | } |
| 9548 | |
shannonwoods@chromium.org | e6e0079 | 2013-05-30 00:06:07 +0000 | [diff] [blame] | 9549 | if (buffer != 0 && size <= 0) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9550 | { |
| 9551 | return gl::error(GL_INVALID_VALUE); |
| 9552 | } |
| 9553 | |
| 9554 | switch (target) |
| 9555 | { |
| 9556 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | a26aeaf | 2013-05-30 00:06:13 +0000 | [diff] [blame] | 9557 | |
| 9558 | // size and offset must be a multiple of 4 |
| 9559 | if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) |
| 9560 | { |
| 9561 | return gl::error(GL_INVALID_VALUE); |
| 9562 | } |
| 9563 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9564 | context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 9565 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9566 | break; |
| 9567 | |
| 9568 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 97c3d50 | 2013-05-30 00:04:34 +0000 | [diff] [blame] | 9569 | |
| 9570 | // it is an error to bind an offset not a multiple of the alignment |
| 9571 | if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0) |
| 9572 | { |
| 9573 | return gl::error(GL_INVALID_VALUE); |
| 9574 | } |
| 9575 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9576 | context->bindIndexedUniformBuffer(buffer, index, offset, size); |
| 9577 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9578 | break; |
| 9579 | |
| 9580 | default: |
| 9581 | UNREACHABLE(); |
| 9582 | } |
| 9583 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9584 | } |
| 9585 | catch(std::bad_alloc&) |
| 9586 | { |
| 9587 | return gl::error(GL_OUT_OF_MEMORY); |
| 9588 | } |
| 9589 | } |
| 9590 | |
| 9591 | void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 9592 | { |
| 9593 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)", |
| 9594 | target, index, buffer); |
| 9595 | |
| 9596 | try |
| 9597 | { |
| 9598 | gl::Context *context = gl::getNonLostContext(); |
| 9599 | |
| 9600 | if (context) |
| 9601 | { |
| 9602 | if (context->getClientVersion() < 3) |
| 9603 | { |
| 9604 | return gl::error(GL_INVALID_OPERATION); |
| 9605 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9606 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9607 | switch (target) |
| 9608 | { |
| 9609 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9610 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9611 | { |
| 9612 | return gl::error(GL_INVALID_VALUE); |
| 9613 | } |
| 9614 | break; |
| 9615 | |
| 9616 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9617 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9618 | { |
| 9619 | return gl::error(GL_INVALID_VALUE); |
| 9620 | } |
| 9621 | break; |
| 9622 | |
| 9623 | default: |
| 9624 | return gl::error(GL_INVALID_ENUM); |
| 9625 | } |
| 9626 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9627 | switch (target) |
| 9628 | { |
| 9629 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9630 | context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9631 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9632 | break; |
| 9633 | |
| 9634 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9635 | context->bindIndexedUniformBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9636 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9637 | break; |
| 9638 | |
| 9639 | default: |
| 9640 | UNREACHABLE(); |
| 9641 | } |
| 9642 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9643 | } |
| 9644 | catch(std::bad_alloc&) |
| 9645 | { |
| 9646 | return gl::error(GL_OUT_OF_MEMORY); |
| 9647 | } |
| 9648 | } |
| 9649 | |
| 9650 | void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
| 9651 | { |
| 9652 | EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)", |
| 9653 | program, count, varyings, bufferMode); |
| 9654 | |
| 9655 | try |
| 9656 | { |
| 9657 | gl::Context *context = gl::getNonLostContext(); |
| 9658 | |
| 9659 | if (context) |
| 9660 | { |
| 9661 | if (context->getClientVersion() < 3) |
| 9662 | { |
| 9663 | return gl::error(GL_INVALID_OPERATION); |
| 9664 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9665 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9666 | // glTransformFeedbackVaryings |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9667 | UNIMPLEMENTED(); |
| 9668 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9669 | } |
| 9670 | catch(std::bad_alloc&) |
| 9671 | { |
| 9672 | return gl::error(GL_OUT_OF_MEMORY); |
| 9673 | } |
| 9674 | } |
| 9675 | |
| 9676 | void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
| 9677 | { |
| 9678 | EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, " |
| 9679 | "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
| 9680 | program, index, bufSize, length, size, type, name); |
| 9681 | |
| 9682 | try |
| 9683 | { |
| 9684 | gl::Context *context = gl::getNonLostContext(); |
| 9685 | |
| 9686 | if (context) |
| 9687 | { |
| 9688 | if (context->getClientVersion() < 3) |
| 9689 | { |
| 9690 | return gl::error(GL_INVALID_OPERATION); |
| 9691 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9692 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9693 | // glGetTransformFeedbackVarying |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9694 | UNIMPLEMENTED(); |
| 9695 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9696 | } |
| 9697 | catch(std::bad_alloc&) |
| 9698 | { |
| 9699 | return gl::error(GL_OUT_OF_MEMORY); |
| 9700 | } |
| 9701 | } |
| 9702 | |
| 9703 | void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) |
| 9704 | { |
| 9705 | EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)", |
| 9706 | index, size, type, stride, pointer); |
| 9707 | |
| 9708 | try |
| 9709 | { |
| 9710 | gl::Context *context = gl::getNonLostContext(); |
| 9711 | |
| 9712 | if (context) |
| 9713 | { |
| 9714 | if (context->getClientVersion() < 3) |
| 9715 | { |
| 9716 | return gl::error(GL_INVALID_OPERATION); |
| 9717 | } |
| 9718 | } |
| 9719 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9720 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9721 | { |
| 9722 | return gl::error(GL_INVALID_VALUE); |
| 9723 | } |
| 9724 | |
| 9725 | if (size < 1 || size > 4) |
| 9726 | { |
| 9727 | return gl::error(GL_INVALID_VALUE); |
| 9728 | } |
| 9729 | |
| 9730 | switch (type) |
| 9731 | { |
| 9732 | case GL_BYTE: |
| 9733 | case GL_UNSIGNED_BYTE: |
| 9734 | case GL_SHORT: |
| 9735 | case GL_UNSIGNED_SHORT: |
| 9736 | case GL_INT: |
| 9737 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9738 | case GL_INT_2_10_10_10_REV: |
| 9739 | 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] | 9740 | break; |
| 9741 | default: |
| 9742 | return gl::error(GL_INVALID_ENUM); |
| 9743 | } |
| 9744 | |
| 9745 | if (stride < 0) |
| 9746 | { |
| 9747 | return gl::error(GL_INVALID_VALUE); |
| 9748 | } |
| 9749 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9750 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 9751 | { |
| 9752 | return gl::error(GL_INVALID_OPERATION); |
| 9753 | } |
| 9754 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9755 | if (context) |
| 9756 | { |
Jamie Madill | d8db866 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9757 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 9758 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 9759 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 9760 | // and the pointer argument is not NULL. |
| 9761 | if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && pointer != NULL) |
| 9762 | { |
| 9763 | return gl::error(GL_INVALID_OPERATION); |
| 9764 | } |
| 9765 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9766 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true, |
| 9767 | stride, pointer); |
| 9768 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9769 | } |
| 9770 | catch(std::bad_alloc&) |
| 9771 | { |
| 9772 | return gl::error(GL_OUT_OF_MEMORY); |
| 9773 | } |
| 9774 | } |
| 9775 | |
| 9776 | void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) |
| 9777 | { |
| 9778 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 9779 | index, pname, params); |
| 9780 | |
| 9781 | try |
| 9782 | { |
| 9783 | gl::Context *context = gl::getNonLostContext(); |
| 9784 | |
| 9785 | if (context) |
| 9786 | { |
| 9787 | if (context->getClientVersion() < 3) |
| 9788 | { |
| 9789 | return gl::error(GL_INVALID_OPERATION); |
| 9790 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9791 | |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 9792 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9793 | { |
| 9794 | return gl::error(GL_INVALID_VALUE); |
| 9795 | } |
| 9796 | |
| 9797 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
| 9798 | |
| 9799 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
| 9800 | { |
| 9801 | return; |
| 9802 | } |
| 9803 | |
| 9804 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 9805 | { |
| 9806 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 9807 | for (int i = 0; i < 4; ++i) |
| 9808 | { |
| 9809 | params[i] = currentValueData.IntValues[i]; |
| 9810 | } |
| 9811 | } |
| 9812 | else |
| 9813 | { |
| 9814 | *params = attribState.querySingleParameter<GLint>(pname); |
| 9815 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9816 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9817 | } |
| 9818 | catch(std::bad_alloc&) |
| 9819 | { |
| 9820 | return gl::error(GL_OUT_OF_MEMORY); |
| 9821 | } |
| 9822 | } |
| 9823 | |
| 9824 | void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) |
| 9825 | { |
| 9826 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)", |
| 9827 | index, pname, params); |
| 9828 | |
| 9829 | try |
| 9830 | { |
| 9831 | gl::Context *context = gl::getNonLostContext(); |
| 9832 | |
| 9833 | if (context) |
| 9834 | { |
| 9835 | if (context->getClientVersion() < 3) |
| 9836 | { |
| 9837 | return gl::error(GL_INVALID_OPERATION); |
| 9838 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9839 | |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 9840 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9841 | { |
| 9842 | return gl::error(GL_INVALID_VALUE); |
| 9843 | } |
| 9844 | |
| 9845 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
| 9846 | |
| 9847 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
| 9848 | { |
| 9849 | return; |
| 9850 | } |
| 9851 | |
| 9852 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 9853 | { |
| 9854 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 9855 | for (int i = 0; i < 4; ++i) |
| 9856 | { |
| 9857 | params[i] = currentValueData.UnsignedIntValues[i]; |
| 9858 | } |
| 9859 | } |
| 9860 | else |
| 9861 | { |
| 9862 | *params = attribState.querySingleParameter<GLuint>(pname); |
| 9863 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9864 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9865 | } |
| 9866 | catch(std::bad_alloc&) |
| 9867 | { |
| 9868 | return gl::error(GL_OUT_OF_MEMORY); |
| 9869 | } |
| 9870 | } |
| 9871 | |
| 9872 | void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 9873 | { |
| 9874 | EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)", |
| 9875 | index, x, y, z, w); |
| 9876 | |
| 9877 | try |
| 9878 | { |
| 9879 | gl::Context *context = gl::getNonLostContext(); |
| 9880 | |
| 9881 | if (context) |
| 9882 | { |
| 9883 | if (context->getClientVersion() < 3) |
| 9884 | { |
| 9885 | return gl::error(GL_INVALID_OPERATION); |
| 9886 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9887 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9888 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9889 | { |
| 9890 | return gl::error(GL_INVALID_VALUE); |
| 9891 | } |
| 9892 | |
| 9893 | GLint vals[4] = { x, y, z, w }; |
| 9894 | context->setVertexAttribi(index, vals); |
| 9895 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9896 | } |
| 9897 | catch(std::bad_alloc&) |
| 9898 | { |
| 9899 | return gl::error(GL_OUT_OF_MEMORY); |
| 9900 | } |
| 9901 | } |
| 9902 | |
| 9903 | void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 9904 | { |
| 9905 | EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)", |
| 9906 | index, x, y, z, w); |
| 9907 | |
| 9908 | try |
| 9909 | { |
| 9910 | gl::Context *context = gl::getNonLostContext(); |
| 9911 | |
| 9912 | if (context) |
| 9913 | { |
| 9914 | if (context->getClientVersion() < 3) |
| 9915 | { |
| 9916 | return gl::error(GL_INVALID_OPERATION); |
| 9917 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9918 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9919 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9920 | { |
| 9921 | return gl::error(GL_INVALID_VALUE); |
| 9922 | } |
| 9923 | |
| 9924 | GLuint vals[4] = { x, y, z, w }; |
| 9925 | context->setVertexAttribu(index, vals); |
| 9926 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9927 | } |
| 9928 | catch(std::bad_alloc&) |
| 9929 | { |
| 9930 | return gl::error(GL_OUT_OF_MEMORY); |
| 9931 | } |
| 9932 | } |
| 9933 | |
| 9934 | void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) |
| 9935 | { |
| 9936 | EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v); |
| 9937 | |
| 9938 | try |
| 9939 | { |
| 9940 | gl::Context *context = gl::getNonLostContext(); |
| 9941 | |
| 9942 | if (context) |
| 9943 | { |
| 9944 | if (context->getClientVersion() < 3) |
| 9945 | { |
| 9946 | return gl::error(GL_INVALID_OPERATION); |
| 9947 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9948 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9949 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9950 | { |
| 9951 | return gl::error(GL_INVALID_VALUE); |
| 9952 | } |
| 9953 | |
| 9954 | context->setVertexAttribi(index, v); |
| 9955 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9956 | } |
| 9957 | catch(std::bad_alloc&) |
| 9958 | { |
| 9959 | return gl::error(GL_OUT_OF_MEMORY); |
| 9960 | } |
| 9961 | } |
| 9962 | |
| 9963 | void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v) |
| 9964 | { |
| 9965 | EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v); |
| 9966 | |
| 9967 | try |
| 9968 | { |
| 9969 | gl::Context *context = gl::getNonLostContext(); |
| 9970 | |
| 9971 | if (context) |
| 9972 | { |
| 9973 | if (context->getClientVersion() < 3) |
| 9974 | { |
| 9975 | return gl::error(GL_INVALID_OPERATION); |
| 9976 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9977 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9978 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9979 | { |
| 9980 | return gl::error(GL_INVALID_VALUE); |
| 9981 | } |
| 9982 | |
| 9983 | context->setVertexAttribu(index, v); |
| 9984 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9985 | } |
| 9986 | catch(std::bad_alloc&) |
| 9987 | { |
| 9988 | return gl::error(GL_OUT_OF_MEMORY); |
| 9989 | } |
| 9990 | } |
| 9991 | |
| 9992 | void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) |
| 9993 | { |
| 9994 | EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)", |
| 9995 | program, location, params); |
| 9996 | |
| 9997 | try |
| 9998 | { |
| 9999 | gl::Context *context = gl::getNonLostContext(); |
| 10000 | |
| 10001 | if (context) |
| 10002 | { |
| 10003 | if (context->getClientVersion() < 3) |
| 10004 | { |
| 10005 | return gl::error(GL_INVALID_OPERATION); |
| 10006 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10007 | |
shannon.woods%transgaming.com@gtempaccount.com | e229012 | 2013-04-13 03:41:07 +0000 | [diff] [blame] | 10008 | if (program == 0) |
| 10009 | { |
| 10010 | return gl::error(GL_INVALID_VALUE); |
| 10011 | } |
| 10012 | |
| 10013 | gl::Program *programObject = context->getProgram(program); |
| 10014 | |
| 10015 | if (!programObject || !programObject->isLinked()) |
| 10016 | { |
| 10017 | return gl::error(GL_INVALID_OPERATION); |
| 10018 | } |
| 10019 | |
| 10020 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10021 | if (!programBinary) |
| 10022 | { |
| 10023 | return gl::error(GL_INVALID_OPERATION); |
| 10024 | } |
| 10025 | |
| 10026 | if (!programBinary->getUniformuiv(location, NULL, params)) |
| 10027 | { |
| 10028 | return gl::error(GL_INVALID_OPERATION); |
| 10029 | } |
| 10030 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10031 | } |
| 10032 | catch(std::bad_alloc&) |
| 10033 | { |
| 10034 | return gl::error(GL_OUT_OF_MEMORY); |
| 10035 | } |
| 10036 | } |
| 10037 | |
| 10038 | GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) |
| 10039 | { |
| 10040 | EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)", |
| 10041 | program, name); |
| 10042 | |
| 10043 | try |
| 10044 | { |
| 10045 | gl::Context *context = gl::getNonLostContext(); |
| 10046 | |
| 10047 | if (context) |
| 10048 | { |
| 10049 | if (context->getClientVersion() < 3) |
| 10050 | { |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame] | 10051 | return gl::error(GL_INVALID_OPERATION, -1); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10052 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10053 | |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame] | 10054 | if (program == 0) |
| 10055 | { |
| 10056 | return gl::error(GL_INVALID_VALUE, -1); |
| 10057 | } |
| 10058 | |
| 10059 | gl::Program *programObject = context->getProgram(program); |
| 10060 | |
| 10061 | if (!programObject || !programObject->isLinked()) |
| 10062 | { |
| 10063 | return gl::error(GL_INVALID_OPERATION, -1); |
| 10064 | } |
| 10065 | |
| 10066 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10067 | if (!programBinary) |
| 10068 | { |
| 10069 | return gl::error(GL_INVALID_OPERATION, -1); |
| 10070 | } |
| 10071 | |
| 10072 | return programBinary->getFragDataLocation(name); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10073 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10074 | } |
| 10075 | catch(std::bad_alloc&) |
| 10076 | { |
| 10077 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10078 | } |
| 10079 | |
| 10080 | return 0; |
| 10081 | } |
| 10082 | |
| 10083 | void __stdcall glUniform1ui(GLint location, GLuint v0) |
| 10084 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10085 | glUniform1uiv(location, 1, &v0); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10086 | } |
| 10087 | |
| 10088 | void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1) |
| 10089 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10090 | const GLuint xy[] = { v0, v1 }; |
| 10091 | glUniform2uiv(location, 1, xy); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10092 | } |
| 10093 | |
| 10094 | void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 10095 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10096 | const GLuint xyz[] = { v0, v1, v2 }; |
| 10097 | glUniform3uiv(location, 1, xyz); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10098 | } |
| 10099 | |
| 10100 | void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 10101 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10102 | const GLuint xyzw[] = { v0, v1, v2, v3 }; |
| 10103 | glUniform4uiv(location, 1, xyzw); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10104 | } |
| 10105 | |
| 10106 | void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) |
| 10107 | { |
| 10108 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 10109 | location, count, value); |
| 10110 | |
| 10111 | try |
| 10112 | { |
| 10113 | gl::Context *context = gl::getNonLostContext(); |
| 10114 | |
| 10115 | if (context) |
| 10116 | { |
| 10117 | if (context->getClientVersion() < 3) |
| 10118 | { |
| 10119 | return gl::error(GL_INVALID_OPERATION); |
| 10120 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10121 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10122 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10123 | if (!programBinary) |
| 10124 | { |
| 10125 | return gl::error(GL_INVALID_OPERATION); |
| 10126 | } |
| 10127 | |
| 10128 | if (!programBinary->setUniform1uiv(location, count, value)) |
| 10129 | { |
| 10130 | return gl::error(GL_INVALID_OPERATION); |
| 10131 | } |
| 10132 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10133 | } |
| 10134 | catch(std::bad_alloc&) |
| 10135 | { |
| 10136 | return gl::error(GL_OUT_OF_MEMORY); |
| 10137 | } |
| 10138 | } |
| 10139 | |
| 10140 | void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) |
| 10141 | { |
| 10142 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 10143 | location, count, value); |
| 10144 | |
| 10145 | try |
| 10146 | { |
| 10147 | gl::Context *context = gl::getNonLostContext(); |
| 10148 | |
| 10149 | if (context) |
| 10150 | { |
| 10151 | if (context->getClientVersion() < 3) |
| 10152 | { |
| 10153 | return gl::error(GL_INVALID_OPERATION); |
| 10154 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10155 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10156 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10157 | if (!programBinary) |
| 10158 | { |
| 10159 | return gl::error(GL_INVALID_OPERATION); |
| 10160 | } |
| 10161 | |
| 10162 | if (!programBinary->setUniform2uiv(location, count, value)) |
| 10163 | { |
| 10164 | return gl::error(GL_INVALID_OPERATION); |
| 10165 | } |
| 10166 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10167 | } |
| 10168 | catch(std::bad_alloc&) |
| 10169 | { |
| 10170 | return gl::error(GL_OUT_OF_MEMORY); |
| 10171 | } |
| 10172 | } |
| 10173 | |
| 10174 | void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) |
| 10175 | { |
| 10176 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)", |
| 10177 | location, count, value); |
| 10178 | |
| 10179 | try |
| 10180 | { |
| 10181 | gl::Context *context = gl::getNonLostContext(); |
| 10182 | |
| 10183 | if (context) |
| 10184 | { |
| 10185 | if (context->getClientVersion() < 3) |
| 10186 | { |
| 10187 | return gl::error(GL_INVALID_OPERATION); |
| 10188 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10189 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10190 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10191 | if (!programBinary) |
| 10192 | { |
| 10193 | return gl::error(GL_INVALID_OPERATION); |
| 10194 | } |
| 10195 | |
| 10196 | if (!programBinary->setUniform3uiv(location, count, value)) |
| 10197 | { |
| 10198 | return gl::error(GL_INVALID_OPERATION); |
| 10199 | } |
| 10200 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10201 | } |
| 10202 | catch(std::bad_alloc&) |
| 10203 | { |
| 10204 | return gl::error(GL_OUT_OF_MEMORY); |
| 10205 | } |
| 10206 | } |
| 10207 | |
| 10208 | void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) |
| 10209 | { |
| 10210 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 10211 | location, count, value); |
| 10212 | |
| 10213 | try |
| 10214 | { |
| 10215 | gl::Context *context = gl::getNonLostContext(); |
| 10216 | |
| 10217 | if (context) |
| 10218 | { |
| 10219 | if (context->getClientVersion() < 3) |
| 10220 | { |
| 10221 | return gl::error(GL_INVALID_OPERATION); |
| 10222 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10223 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10224 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10225 | if (!programBinary) |
| 10226 | { |
| 10227 | return gl::error(GL_INVALID_OPERATION); |
| 10228 | } |
| 10229 | |
| 10230 | if (!programBinary->setUniform4uiv(location, count, value)) |
| 10231 | { |
| 10232 | return gl::error(GL_INVALID_OPERATION); |
| 10233 | } |
| 10234 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10235 | } |
| 10236 | catch(std::bad_alloc&) |
| 10237 | { |
| 10238 | return gl::error(GL_OUT_OF_MEMORY); |
| 10239 | } |
| 10240 | } |
| 10241 | |
| 10242 | void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) |
| 10243 | { |
| 10244 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)", |
| 10245 | buffer, drawbuffer, value); |
| 10246 | |
| 10247 | try |
| 10248 | { |
| 10249 | gl::Context *context = gl::getNonLostContext(); |
| 10250 | |
| 10251 | if (context) |
| 10252 | { |
| 10253 | if (context->getClientVersion() < 3) |
| 10254 | { |
| 10255 | return gl::error(GL_INVALID_OPERATION); |
| 10256 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10257 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10258 | // glClearBufferiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10259 | UNIMPLEMENTED(); |
| 10260 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10261 | } |
| 10262 | catch(std::bad_alloc&) |
| 10263 | { |
| 10264 | return gl::error(GL_OUT_OF_MEMORY); |
| 10265 | } |
| 10266 | } |
| 10267 | |
| 10268 | void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) |
| 10269 | { |
| 10270 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)", |
| 10271 | buffer, drawbuffer, value); |
| 10272 | |
| 10273 | try |
| 10274 | { |
| 10275 | gl::Context *context = gl::getNonLostContext(); |
| 10276 | |
| 10277 | if (context) |
| 10278 | { |
| 10279 | if (context->getClientVersion() < 3) |
| 10280 | { |
| 10281 | return gl::error(GL_INVALID_OPERATION); |
| 10282 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10283 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10284 | // glClearBufferuiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10285 | UNIMPLEMENTED(); |
| 10286 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10287 | } |
| 10288 | catch(std::bad_alloc&) |
| 10289 | { |
| 10290 | return gl::error(GL_OUT_OF_MEMORY); |
| 10291 | } |
| 10292 | } |
| 10293 | |
| 10294 | void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) |
| 10295 | { |
| 10296 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)", |
| 10297 | buffer, drawbuffer, value); |
| 10298 | |
| 10299 | try |
| 10300 | { |
| 10301 | gl::Context *context = gl::getNonLostContext(); |
| 10302 | |
| 10303 | if (context) |
| 10304 | { |
| 10305 | if (context->getClientVersion() < 3) |
| 10306 | { |
| 10307 | return gl::error(GL_INVALID_OPERATION); |
| 10308 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10309 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10310 | // glClearBufferfv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10311 | UNIMPLEMENTED(); |
| 10312 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10313 | } |
| 10314 | catch(std::bad_alloc&) |
| 10315 | { |
| 10316 | return gl::error(GL_OUT_OF_MEMORY); |
| 10317 | } |
| 10318 | } |
| 10319 | |
| 10320 | void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 10321 | { |
| 10322 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)", |
| 10323 | buffer, drawbuffer, depth, stencil); |
| 10324 | |
| 10325 | try |
| 10326 | { |
| 10327 | gl::Context *context = gl::getNonLostContext(); |
| 10328 | |
| 10329 | if (context) |
| 10330 | { |
| 10331 | if (context->getClientVersion() < 3) |
| 10332 | { |
| 10333 | return gl::error(GL_INVALID_OPERATION); |
| 10334 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10335 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10336 | // glClearBufferfi |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10337 | UNIMPLEMENTED(); |
| 10338 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10339 | } |
| 10340 | catch(std::bad_alloc&) |
| 10341 | { |
| 10342 | return gl::error(GL_OUT_OF_MEMORY); |
| 10343 | } |
| 10344 | } |
| 10345 | |
| 10346 | const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) |
| 10347 | { |
| 10348 | EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index); |
| 10349 | |
| 10350 | try |
| 10351 | { |
| 10352 | gl::Context *context = gl::getNonLostContext(); |
| 10353 | |
| 10354 | if (context) |
| 10355 | { |
| 10356 | if (context->getClientVersion() < 3) |
| 10357 | { |
| 10358 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL)); |
| 10359 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10360 | |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 10361 | if (name != GL_EXTENSIONS) |
| 10362 | { |
| 10363 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL)); |
| 10364 | } |
| 10365 | |
| 10366 | if (index >= context->getNumExtensions()) |
| 10367 | { |
| 10368 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL)); |
| 10369 | } |
| 10370 | |
| 10371 | return reinterpret_cast<const GLubyte*>(context->getExtensionString(index)); |
| 10372 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10373 | } |
| 10374 | catch(std::bad_alloc&) |
| 10375 | { |
| 10376 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL)); |
| 10377 | } |
| 10378 | |
| 10379 | return NULL; |
| 10380 | } |
| 10381 | |
| 10382 | void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 10383 | { |
| 10384 | EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)", |
| 10385 | readTarget, writeTarget, readOffset, writeOffset, size); |
| 10386 | |
| 10387 | try |
| 10388 | { |
| 10389 | gl::Context *context = gl::getNonLostContext(); |
| 10390 | |
| 10391 | if (context) |
| 10392 | { |
| 10393 | if (context->getClientVersion() < 3) |
| 10394 | { |
| 10395 | return gl::error(GL_INVALID_OPERATION); |
| 10396 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10397 | |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 10398 | gl::Buffer *readBuffer = NULL; |
| 10399 | switch (readTarget) |
| 10400 | { |
| 10401 | case GL_ARRAY_BUFFER: |
| 10402 | readBuffer = context->getArrayBuffer(); |
| 10403 | break; |
| 10404 | case GL_COPY_READ_BUFFER: |
| 10405 | readBuffer = context->getCopyReadBuffer(); |
| 10406 | break; |
| 10407 | case GL_COPY_WRITE_BUFFER: |
| 10408 | readBuffer = context->getCopyWriteBuffer(); |
| 10409 | break; |
| 10410 | case GL_ELEMENT_ARRAY_BUFFER: |
| 10411 | readBuffer = context->getElementArrayBuffer(); |
| 10412 | break; |
| 10413 | case GL_PIXEL_PACK_BUFFER: |
| 10414 | readBuffer = context->getPixelPackBuffer(); |
| 10415 | break; |
| 10416 | case GL_PIXEL_UNPACK_BUFFER: |
| 10417 | readBuffer = context->getPixelUnpackBuffer(); |
| 10418 | break; |
| 10419 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 10420 | readBuffer = context->getGenericTransformFeedbackBuffer(); |
| 10421 | break; |
| 10422 | case GL_UNIFORM_BUFFER: |
| 10423 | readBuffer = context->getGenericUniformBuffer(); |
| 10424 | break; |
| 10425 | default: |
| 10426 | return gl::error(GL_INVALID_ENUM); |
| 10427 | } |
| 10428 | |
| 10429 | gl::Buffer *writeBuffer = NULL; |
| 10430 | switch (writeTarget) |
| 10431 | { |
| 10432 | case GL_ARRAY_BUFFER: |
| 10433 | writeBuffer = context->getArrayBuffer(); |
| 10434 | break; |
| 10435 | case GL_COPY_READ_BUFFER: |
| 10436 | writeBuffer = context->getCopyReadBuffer(); |
| 10437 | break; |
| 10438 | case GL_COPY_WRITE_BUFFER: |
| 10439 | writeBuffer = context->getCopyWriteBuffer(); |
| 10440 | break; |
| 10441 | case GL_ELEMENT_ARRAY_BUFFER: |
| 10442 | writeBuffer = context->getElementArrayBuffer(); |
| 10443 | break; |
| 10444 | case GL_PIXEL_PACK_BUFFER: |
| 10445 | writeBuffer = context->getPixelPackBuffer(); |
| 10446 | break; |
| 10447 | case GL_PIXEL_UNPACK_BUFFER: |
| 10448 | writeBuffer = context->getPixelUnpackBuffer(); |
| 10449 | break; |
| 10450 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 10451 | writeBuffer = context->getGenericTransformFeedbackBuffer(); |
| 10452 | break; |
| 10453 | case GL_UNIFORM_BUFFER: |
| 10454 | writeBuffer = context->getGenericUniformBuffer(); |
| 10455 | break; |
| 10456 | default: |
| 10457 | return gl::error(GL_INVALID_ENUM); |
| 10458 | } |
| 10459 | |
| 10460 | if (!readBuffer || !writeBuffer) |
| 10461 | { |
| 10462 | return gl::error(GL_INVALID_OPERATION); |
| 10463 | } |
| 10464 | |
| 10465 | if (readOffset < 0 || writeOffset < 0 || size < 0 || |
| 10466 | static_cast<unsigned int>(readOffset + size) > readBuffer->size() || |
| 10467 | static_cast<unsigned int>(writeOffset + size) > writeBuffer->size()) |
| 10468 | { |
| 10469 | return gl::error(GL_INVALID_VALUE); |
| 10470 | } |
| 10471 | |
| 10472 | if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size) |
| 10473 | { |
| 10474 | return gl::error(GL_INVALID_VALUE); |
| 10475 | } |
| 10476 | |
| 10477 | // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION) |
| 10478 | |
shannon.woods%transgaming.com@gtempaccount.com | c53376a | 2013-04-13 03:41:23 +0000 | [diff] [blame] | 10479 | // if size is zero, the copy is a successful no-op |
| 10480 | if (size > 0) |
| 10481 | { |
| 10482 | writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); |
| 10483 | } |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 10484 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10485 | } |
| 10486 | catch(std::bad_alloc&) |
| 10487 | { |
| 10488 | return gl::error(GL_OUT_OF_MEMORY); |
| 10489 | } |
| 10490 | } |
| 10491 | |
| 10492 | void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) |
| 10493 | { |
| 10494 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)", |
| 10495 | program, uniformCount, uniformNames, uniformIndices); |
| 10496 | |
| 10497 | try |
| 10498 | { |
| 10499 | gl::Context *context = gl::getNonLostContext(); |
| 10500 | |
| 10501 | if (context) |
| 10502 | { |
| 10503 | if (context->getClientVersion() < 3) |
| 10504 | { |
| 10505 | return gl::error(GL_INVALID_OPERATION); |
| 10506 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10507 | |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 10508 | if (uniformCount < 0) |
| 10509 | { |
| 10510 | return gl::error(GL_INVALID_VALUE); |
| 10511 | } |
| 10512 | |
| 10513 | gl::Program *programObject = context->getProgram(program); |
| 10514 | |
| 10515 | if (!programObject) |
| 10516 | { |
| 10517 | if (context->getShader(program)) |
| 10518 | { |
| 10519 | return gl::error(GL_INVALID_OPERATION); |
| 10520 | } |
| 10521 | else |
| 10522 | { |
| 10523 | return gl::error(GL_INVALID_VALUE); |
| 10524 | } |
| 10525 | } |
| 10526 | |
| 10527 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10528 | if (!programObject->isLinked() || !programBinary) |
| 10529 | { |
| 10530 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10531 | { |
| 10532 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 10533 | } |
| 10534 | } |
| 10535 | else |
| 10536 | { |
| 10537 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10538 | { |
| 10539 | uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]); |
| 10540 | } |
| 10541 | } |
| 10542 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10543 | } |
| 10544 | catch(std::bad_alloc&) |
| 10545 | { |
| 10546 | return gl::error(GL_OUT_OF_MEMORY); |
| 10547 | } |
| 10548 | } |
| 10549 | |
| 10550 | void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) |
| 10551 | { |
| 10552 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10553 | program, uniformCount, uniformIndices, pname, params); |
| 10554 | |
| 10555 | try |
| 10556 | { |
| 10557 | gl::Context *context = gl::getNonLostContext(); |
| 10558 | |
| 10559 | if (context) |
| 10560 | { |
| 10561 | if (context->getClientVersion() < 3) |
| 10562 | { |
| 10563 | return gl::error(GL_INVALID_OPERATION); |
| 10564 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10565 | |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 10566 | if (uniformCount < 0) |
| 10567 | { |
| 10568 | return gl::error(GL_INVALID_VALUE); |
| 10569 | } |
| 10570 | |
| 10571 | gl::Program *programObject = context->getProgram(program); |
| 10572 | |
| 10573 | if (!programObject) |
| 10574 | { |
| 10575 | if (context->getShader(program)) |
| 10576 | { |
| 10577 | return gl::error(GL_INVALID_OPERATION); |
| 10578 | } |
| 10579 | else |
| 10580 | { |
| 10581 | return gl::error(GL_INVALID_VALUE); |
| 10582 | } |
| 10583 | } |
| 10584 | |
| 10585 | switch (pname) |
| 10586 | { |
| 10587 | case GL_UNIFORM_TYPE: |
| 10588 | case GL_UNIFORM_SIZE: |
| 10589 | case GL_UNIFORM_NAME_LENGTH: |
| 10590 | case GL_UNIFORM_BLOCK_INDEX: |
| 10591 | case GL_UNIFORM_OFFSET: |
| 10592 | case GL_UNIFORM_ARRAY_STRIDE: |
| 10593 | case GL_UNIFORM_MATRIX_STRIDE: |
| 10594 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 10595 | break; |
| 10596 | default: |
| 10597 | return gl::error(GL_INVALID_ENUM); |
| 10598 | } |
| 10599 | |
| 10600 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10601 | |
| 10602 | if (!programBinary && uniformCount > 0) |
| 10603 | { |
| 10604 | return gl::error(GL_INVALID_VALUE); |
| 10605 | } |
| 10606 | |
| 10607 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10608 | { |
| 10609 | const GLuint index = uniformIndices[uniformId]; |
| 10610 | |
| 10611 | if (index >= (GLuint)programBinary->getActiveUniformCount()) |
| 10612 | { |
| 10613 | return gl::error(GL_INVALID_VALUE); |
| 10614 | } |
| 10615 | } |
| 10616 | |
| 10617 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10618 | { |
| 10619 | const GLuint index = uniformIndices[uniformId]; |
| 10620 | params[uniformId] = programBinary->getActiveUniformi(index, pname); |
| 10621 | } |
| 10622 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10623 | } |
| 10624 | catch(std::bad_alloc&) |
| 10625 | { |
| 10626 | return gl::error(GL_OUT_OF_MEMORY); |
| 10627 | } |
| 10628 | } |
| 10629 | |
| 10630 | GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) |
| 10631 | { |
| 10632 | EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName); |
| 10633 | |
| 10634 | try |
| 10635 | { |
| 10636 | gl::Context *context = gl::getNonLostContext(); |
| 10637 | |
| 10638 | if (context) |
| 10639 | { |
| 10640 | if (context->getClientVersion() < 3) |
| 10641 | { |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10642 | 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] | 10643 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10644 | |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10645 | gl::Program *programObject = context->getProgram(program); |
| 10646 | |
| 10647 | if (!programObject) |
| 10648 | { |
| 10649 | if (context->getShader(program)) |
| 10650 | { |
| 10651 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
| 10652 | } |
| 10653 | else |
| 10654 | { |
| 10655 | return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX); |
| 10656 | } |
| 10657 | } |
| 10658 | |
| 10659 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10660 | if (!programBinary) |
| 10661 | { |
| 10662 | return GL_INVALID_INDEX; |
| 10663 | } |
| 10664 | |
| 10665 | return programBinary->getUniformBlockIndex(uniformBlockName); |
| 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, 0); |
| 10671 | } |
| 10672 | |
| 10673 | return 0; |
| 10674 | } |
| 10675 | |
| 10676 | void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) |
| 10677 | { |
| 10678 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10679 | program, uniformBlockIndex, pname, params); |
| 10680 | |
| 10681 | try |
| 10682 | { |
| 10683 | gl::Context *context = gl::getNonLostContext(); |
| 10684 | |
| 10685 | if (context) |
| 10686 | { |
| 10687 | if (context->getClientVersion() < 3) |
| 10688 | { |
| 10689 | return gl::error(GL_INVALID_OPERATION); |
| 10690 | } |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10691 | gl::Program *programObject = context->getProgram(program); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10692 | |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10693 | if (!programObject) |
| 10694 | { |
| 10695 | if (context->getShader(program)) |
| 10696 | { |
| 10697 | return gl::error(GL_INVALID_OPERATION); |
| 10698 | } |
| 10699 | else |
| 10700 | { |
| 10701 | return gl::error(GL_INVALID_VALUE); |
| 10702 | } |
| 10703 | } |
| 10704 | |
| 10705 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10706 | |
| 10707 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10708 | { |
| 10709 | return gl::error(GL_INVALID_VALUE); |
| 10710 | } |
| 10711 | |
| 10712 | switch (pname) |
| 10713 | { |
| 10714 | case GL_UNIFORM_BLOCK_BINDING: |
| 10715 | *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); |
| 10716 | break; |
| 10717 | |
| 10718 | case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 10719 | case GL_UNIFORM_BLOCK_NAME_LENGTH: |
| 10720 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 10721 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| 10722 | case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
| 10723 | case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
| 10724 | programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params); |
| 10725 | break; |
| 10726 | |
| 10727 | default: |
| 10728 | return gl::error(GL_INVALID_ENUM); |
| 10729 | } |
| 10730 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10731 | } |
| 10732 | catch(std::bad_alloc&) |
| 10733 | { |
| 10734 | return gl::error(GL_OUT_OF_MEMORY); |
| 10735 | } |
| 10736 | } |
| 10737 | |
| 10738 | void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) |
| 10739 | { |
| 10740 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)", |
| 10741 | program, uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10742 | |
| 10743 | try |
| 10744 | { |
| 10745 | gl::Context *context = gl::getNonLostContext(); |
| 10746 | |
| 10747 | if (context) |
| 10748 | { |
| 10749 | if (context->getClientVersion() < 3) |
| 10750 | { |
| 10751 | return gl::error(GL_INVALID_OPERATION); |
| 10752 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10753 | |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 10754 | gl::Program *programObject = context->getProgram(program); |
| 10755 | |
| 10756 | if (!programObject) |
| 10757 | { |
| 10758 | if (context->getShader(program)) |
| 10759 | { |
| 10760 | return gl::error(GL_INVALID_OPERATION); |
| 10761 | } |
| 10762 | else |
| 10763 | { |
| 10764 | return gl::error(GL_INVALID_VALUE); |
| 10765 | } |
| 10766 | } |
| 10767 | |
| 10768 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10769 | |
| 10770 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10771 | { |
| 10772 | return gl::error(GL_INVALID_VALUE); |
| 10773 | } |
| 10774 | |
| 10775 | programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10776 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10777 | } |
| 10778 | catch(std::bad_alloc&) |
| 10779 | { |
| 10780 | return gl::error(GL_OUT_OF_MEMORY); |
| 10781 | } |
| 10782 | } |
| 10783 | |
| 10784 | void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) |
| 10785 | { |
| 10786 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)", |
| 10787 | program, uniformBlockIndex, uniformBlockBinding); |
| 10788 | |
| 10789 | try |
| 10790 | { |
| 10791 | gl::Context *context = gl::getNonLostContext(); |
| 10792 | |
| 10793 | if (context) |
| 10794 | { |
| 10795 | if (context->getClientVersion() < 3) |
| 10796 | { |
| 10797 | return gl::error(GL_INVALID_OPERATION); |
| 10798 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10799 | |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 10800 | if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings()) |
| 10801 | { |
| 10802 | return gl::error(GL_INVALID_VALUE); |
| 10803 | } |
| 10804 | |
| 10805 | gl::Program *programObject = context->getProgram(program); |
| 10806 | |
| 10807 | if (!programObject) |
| 10808 | { |
| 10809 | if (context->getShader(program)) |
| 10810 | { |
| 10811 | return gl::error(GL_INVALID_OPERATION); |
| 10812 | } |
| 10813 | else |
| 10814 | { |
| 10815 | return gl::error(GL_INVALID_VALUE); |
| 10816 | } |
| 10817 | } |
| 10818 | |
| 10819 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10820 | |
| 10821 | // if never linked, there won't be any uniform blocks |
| 10822 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10823 | { |
| 10824 | return gl::error(GL_INVALID_VALUE); |
| 10825 | } |
| 10826 | |
| 10827 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
| 10828 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10829 | } |
| 10830 | catch(std::bad_alloc&) |
| 10831 | { |
| 10832 | return gl::error(GL_OUT_OF_MEMORY); |
| 10833 | } |
| 10834 | } |
| 10835 | |
| 10836 | void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 10837 | { |
| 10838 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)", |
| 10839 | mode, first, count, instanceCount); |
| 10840 | |
| 10841 | try |
| 10842 | { |
| 10843 | gl::Context *context = gl::getNonLostContext(); |
| 10844 | |
| 10845 | if (context) |
| 10846 | { |
| 10847 | if (context->getClientVersion() < 3) |
| 10848 | { |
| 10849 | return gl::error(GL_INVALID_OPERATION); |
| 10850 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10851 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10852 | // glDrawArraysInstanced |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10853 | UNIMPLEMENTED(); |
| 10854 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10855 | } |
| 10856 | catch(std::bad_alloc&) |
| 10857 | { |
| 10858 | return gl::error(GL_OUT_OF_MEMORY); |
| 10859 | } |
| 10860 | } |
| 10861 | |
| 10862 | void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) |
| 10863 | { |
| 10864 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)", |
| 10865 | mode, count, type, indices, instanceCount); |
| 10866 | |
| 10867 | try |
| 10868 | { |
| 10869 | gl::Context *context = gl::getNonLostContext(); |
| 10870 | |
| 10871 | if (context) |
| 10872 | { |
| 10873 | if (context->getClientVersion() < 3) |
| 10874 | { |
| 10875 | return gl::error(GL_INVALID_OPERATION); |
| 10876 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10877 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10878 | // glDrawElementsInstanced |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10879 | UNIMPLEMENTED(); |
| 10880 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10881 | } |
| 10882 | catch(std::bad_alloc&) |
| 10883 | { |
| 10884 | return gl::error(GL_OUT_OF_MEMORY); |
| 10885 | } |
| 10886 | } |
| 10887 | |
| 10888 | GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags) |
| 10889 | { |
| 10890 | EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags); |
| 10891 | |
| 10892 | try |
| 10893 | { |
| 10894 | gl::Context *context = gl::getNonLostContext(); |
| 10895 | |
| 10896 | if (context) |
| 10897 | { |
| 10898 | if (context->getClientVersion() < 3) |
| 10899 | { |
| 10900 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(NULL)); |
| 10901 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10902 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10903 | // glFenceSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10904 | UNIMPLEMENTED(); |
| 10905 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10906 | } |
| 10907 | catch(std::bad_alloc&) |
| 10908 | { |
| 10909 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL)); |
| 10910 | } |
| 10911 | |
| 10912 | return NULL; |
| 10913 | } |
| 10914 | |
| 10915 | GLboolean __stdcall glIsSync(GLsync sync) |
| 10916 | { |
| 10917 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10918 | |
| 10919 | try |
| 10920 | { |
| 10921 | gl::Context *context = gl::getNonLostContext(); |
| 10922 | |
| 10923 | if (context) |
| 10924 | { |
| 10925 | if (context->getClientVersion() < 3) |
| 10926 | { |
| 10927 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10928 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10929 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10930 | // glIsSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10931 | UNIMPLEMENTED(); |
| 10932 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10933 | } |
| 10934 | catch(std::bad_alloc&) |
| 10935 | { |
| 10936 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10937 | } |
| 10938 | |
| 10939 | return GL_FALSE; |
| 10940 | } |
| 10941 | |
| 10942 | void __stdcall glDeleteSync(GLsync sync) |
| 10943 | { |
| 10944 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10945 | |
| 10946 | try |
| 10947 | { |
| 10948 | gl::Context *context = gl::getNonLostContext(); |
| 10949 | |
| 10950 | if (context) |
| 10951 | { |
| 10952 | if (context->getClientVersion() < 3) |
| 10953 | { |
| 10954 | return gl::error(GL_INVALID_OPERATION); |
| 10955 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10956 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10957 | // glDeleteSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10958 | UNIMPLEMENTED(); |
| 10959 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10960 | } |
| 10961 | catch(std::bad_alloc&) |
| 10962 | { |
| 10963 | return gl::error(GL_OUT_OF_MEMORY); |
| 10964 | } |
| 10965 | } |
| 10966 | |
| 10967 | GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10968 | { |
| 10969 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10970 | sync, flags, timeout); |
| 10971 | |
| 10972 | try |
| 10973 | { |
| 10974 | gl::Context *context = gl::getNonLostContext(); |
| 10975 | |
| 10976 | if (context) |
| 10977 | { |
| 10978 | if (context->getClientVersion() < 3) |
| 10979 | { |
| 10980 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10981 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10982 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10983 | // glClientWaitSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10984 | UNIMPLEMENTED(); |
| 10985 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10986 | } |
| 10987 | catch(std::bad_alloc&) |
| 10988 | { |
| 10989 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10990 | } |
| 10991 | |
| 10992 | return GL_FALSE; |
| 10993 | } |
| 10994 | |
| 10995 | void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10996 | { |
| 10997 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10998 | sync, flags, timeout); |
| 10999 | |
| 11000 | try |
| 11001 | { |
| 11002 | gl::Context *context = gl::getNonLostContext(); |
| 11003 | |
| 11004 | if (context) |
| 11005 | { |
| 11006 | if (context->getClientVersion() < 3) |
| 11007 | { |
| 11008 | return gl::error(GL_INVALID_OPERATION); |
| 11009 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11010 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11011 | // glWaitSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11012 | UNIMPLEMENTED(); |
| 11013 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11014 | } |
| 11015 | catch(std::bad_alloc&) |
| 11016 | { |
| 11017 | return gl::error(GL_OUT_OF_MEMORY); |
| 11018 | } |
| 11019 | } |
| 11020 | |
| 11021 | void __stdcall glGetInteger64v(GLenum pname, GLint64* params) |
| 11022 | { |
| 11023 | EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 11024 | pname, params); |
| 11025 | |
| 11026 | try |
| 11027 | { |
| 11028 | gl::Context *context = gl::getNonLostContext(); |
| 11029 | |
| 11030 | if (context) |
| 11031 | { |
| 11032 | if (context->getClientVersion() < 3) |
| 11033 | { |
| 11034 | return gl::error(GL_INVALID_OPERATION); |
| 11035 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11036 | |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 11037 | if (!(context->getInteger64v(pname, params))) |
| 11038 | { |
| 11039 | GLenum nativeType; |
| 11040 | unsigned int numParams = 0; |
| 11041 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
| 11042 | return gl::error(GL_INVALID_ENUM); |
| 11043 | |
| 11044 | if (numParams == 0) |
| 11045 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 11046 | |
| 11047 | if (nativeType == GL_BOOL) |
| 11048 | { |
| 11049 | GLboolean *boolParams = NULL; |
| 11050 | boolParams = new GLboolean[numParams]; |
| 11051 | |
| 11052 | context->getBooleanv(pname, boolParams); |
| 11053 | |
| 11054 | for (unsigned int i = 0; i < numParams; ++i) |
| 11055 | { |
| 11056 | if (boolParams[i] == GL_FALSE) |
| 11057 | params[i] = 0; |
| 11058 | else |
| 11059 | params[i] = 1; |
| 11060 | } |
| 11061 | |
| 11062 | delete [] boolParams; |
| 11063 | } |
| 11064 | else if (nativeType == GL_INT) |
| 11065 | { |
| 11066 | GLint *intParams = NULL; |
| 11067 | intParams = new GLint[numParams]; |
| 11068 | |
| 11069 | context->getIntegerv(pname, intParams); |
| 11070 | |
| 11071 | for (unsigned int i = 0; i < numParams; ++i) |
| 11072 | { |
| 11073 | params[i] = static_cast<GLint64>(intParams[i]); |
| 11074 | } |
| 11075 | |
| 11076 | delete [] intParams; |
| 11077 | } |
| 11078 | else if (nativeType == GL_FLOAT) |
| 11079 | { |
| 11080 | GLfloat *floatParams = NULL; |
| 11081 | floatParams = new GLfloat[numParams]; |
| 11082 | |
| 11083 | context->getFloatv(pname, floatParams); |
| 11084 | |
| 11085 | for (unsigned int i = 0; i < numParams; ++i) |
| 11086 | { |
| 11087 | // RGBA color values and DepthRangeF values are converted to integer using Equation 2.4 from Table 4.5 |
| 11088 | if (pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE || pname == GL_BLEND_COLOR) |
| 11089 | { |
| 11090 | params[i] = static_cast<GLint64>((static_cast<GLfloat>(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f); |
| 11091 | } |
| 11092 | else |
| 11093 | { |
| 11094 | params[i] = gl::iround<GLint64>(floatParams[i]); |
| 11095 | } |
| 11096 | } |
| 11097 | |
| 11098 | delete [] floatParams; |
| 11099 | } |
| 11100 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11101 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11102 | } |
| 11103 | catch(std::bad_alloc&) |
| 11104 | { |
| 11105 | return gl::error(GL_OUT_OF_MEMORY); |
| 11106 | } |
| 11107 | } |
| 11108 | |
| 11109 | void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) |
| 11110 | { |
| 11111 | EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)", |
| 11112 | sync, pname, bufSize, length, values); |
| 11113 | |
| 11114 | try |
| 11115 | { |
| 11116 | gl::Context *context = gl::getNonLostContext(); |
| 11117 | |
| 11118 | if (context) |
| 11119 | { |
| 11120 | if (context->getClientVersion() < 3) |
| 11121 | { |
| 11122 | return gl::error(GL_INVALID_OPERATION); |
| 11123 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11124 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11125 | // glGetSynciv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11126 | UNIMPLEMENTED(); |
| 11127 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11128 | } |
| 11129 | catch(std::bad_alloc&) |
| 11130 | { |
| 11131 | return gl::error(GL_OUT_OF_MEMORY); |
| 11132 | } |
| 11133 | } |
| 11134 | |
| 11135 | void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) |
| 11136 | { |
| 11137 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)", |
| 11138 | target, index, data); |
| 11139 | |
| 11140 | try |
| 11141 | { |
| 11142 | gl::Context *context = gl::getNonLostContext(); |
| 11143 | |
| 11144 | if (context) |
| 11145 | { |
| 11146 | if (context->getClientVersion() < 3) |
| 11147 | { |
| 11148 | return gl::error(GL_INVALID_OPERATION); |
| 11149 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11150 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11151 | // glGetInteger64i_v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11152 | UNIMPLEMENTED(); |
| 11153 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11154 | } |
| 11155 | catch(std::bad_alloc&) |
| 11156 | { |
| 11157 | return gl::error(GL_OUT_OF_MEMORY); |
| 11158 | } |
| 11159 | } |
| 11160 | |
| 11161 | void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) |
| 11162 | { |
| 11163 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 11164 | target, pname, params); |
| 11165 | |
| 11166 | try |
| 11167 | { |
| 11168 | gl::Context *context = gl::getNonLostContext(); |
| 11169 | |
| 11170 | if (context) |
| 11171 | { |
| 11172 | if (context->getClientVersion() < 3) |
| 11173 | { |
| 11174 | return gl::error(GL_INVALID_OPERATION); |
| 11175 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11176 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11177 | // glGetBufferParameteri64v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11178 | UNIMPLEMENTED(); |
| 11179 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11180 | } |
| 11181 | catch(std::bad_alloc&) |
| 11182 | { |
| 11183 | return gl::error(GL_OUT_OF_MEMORY); |
| 11184 | } |
| 11185 | } |
| 11186 | |
| 11187 | void __stdcall glGenSamplers(GLsizei count, GLuint* samplers) |
| 11188 | { |
| 11189 | EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers); |
| 11190 | |
| 11191 | try |
| 11192 | { |
| 11193 | gl::Context *context = gl::getNonLostContext(); |
| 11194 | |
| 11195 | if (context) |
| 11196 | { |
| 11197 | if (context->getClientVersion() < 3) |
| 11198 | { |
| 11199 | return gl::error(GL_INVALID_OPERATION); |
| 11200 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11201 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11202 | // glGenSamplers |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11203 | UNIMPLEMENTED(); |
| 11204 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11205 | } |
| 11206 | catch(std::bad_alloc&) |
| 11207 | { |
| 11208 | return gl::error(GL_OUT_OF_MEMORY); |
| 11209 | } |
| 11210 | } |
| 11211 | |
| 11212 | void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers) |
| 11213 | { |
| 11214 | EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers); |
| 11215 | |
| 11216 | try |
| 11217 | { |
| 11218 | gl::Context *context = gl::getNonLostContext(); |
| 11219 | |
| 11220 | if (context) |
| 11221 | { |
| 11222 | if (context->getClientVersion() < 3) |
| 11223 | { |
| 11224 | return gl::error(GL_INVALID_OPERATION); |
| 11225 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11226 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11227 | // glDeleteSamplers |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11228 | UNIMPLEMENTED(); |
| 11229 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11230 | } |
| 11231 | catch(std::bad_alloc&) |
| 11232 | { |
| 11233 | return gl::error(GL_OUT_OF_MEMORY); |
| 11234 | } |
| 11235 | } |
| 11236 | |
| 11237 | GLboolean __stdcall glIsSampler(GLuint sampler) |
| 11238 | { |
| 11239 | EVENT("(GLuint sampler = %u)", sampler); |
| 11240 | |
| 11241 | try |
| 11242 | { |
| 11243 | gl::Context *context = gl::getNonLostContext(); |
| 11244 | |
| 11245 | if (context) |
| 11246 | { |
| 11247 | if (context->getClientVersion() < 3) |
| 11248 | { |
| 11249 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 11250 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11251 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11252 | // glIsSampler |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11253 | UNIMPLEMENTED(); |
| 11254 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11255 | } |
| 11256 | catch(std::bad_alloc&) |
| 11257 | { |
| 11258 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 11259 | } |
| 11260 | |
| 11261 | return GL_FALSE; |
| 11262 | } |
| 11263 | |
| 11264 | void __stdcall glBindSampler(GLuint unit, GLuint sampler) |
| 11265 | { |
| 11266 | EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler); |
| 11267 | |
| 11268 | try |
| 11269 | { |
| 11270 | gl::Context *context = gl::getNonLostContext(); |
| 11271 | |
| 11272 | if (context) |
| 11273 | { |
| 11274 | if (context->getClientVersion() < 3) |
| 11275 | { |
| 11276 | return gl::error(GL_INVALID_OPERATION); |
| 11277 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11278 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11279 | // glBindSampler |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11280 | UNIMPLEMENTED(); |
| 11281 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11282 | } |
| 11283 | catch(std::bad_alloc&) |
| 11284 | { |
| 11285 | return gl::error(GL_OUT_OF_MEMORY); |
| 11286 | } |
| 11287 | } |
| 11288 | |
| 11289 | void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 11290 | { |
| 11291 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param); |
| 11292 | |
| 11293 | try |
| 11294 | { |
| 11295 | gl::Context *context = gl::getNonLostContext(); |
| 11296 | |
| 11297 | if (context) |
| 11298 | { |
| 11299 | if (context->getClientVersion() < 3) |
| 11300 | { |
| 11301 | return gl::error(GL_INVALID_OPERATION); |
| 11302 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11303 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11304 | // glSamplerParameteri |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11305 | UNIMPLEMENTED(); |
| 11306 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11307 | } |
| 11308 | catch(std::bad_alloc&) |
| 11309 | { |
| 11310 | return gl::error(GL_OUT_OF_MEMORY); |
| 11311 | } |
| 11312 | } |
| 11313 | |
| 11314 | void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) |
| 11315 | { |
| 11316 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLint* param = 0x%0.8p)", |
| 11317 | sampler, pname, param); |
| 11318 | |
| 11319 | try |
| 11320 | { |
| 11321 | gl::Context *context = gl::getNonLostContext(); |
| 11322 | |
| 11323 | if (context) |
| 11324 | { |
| 11325 | if (context->getClientVersion() < 3) |
| 11326 | { |
| 11327 | return gl::error(GL_INVALID_OPERATION); |
| 11328 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11329 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11330 | // glSamplerParameteriv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11331 | UNIMPLEMENTED(); |
| 11332 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11333 | } |
| 11334 | catch(std::bad_alloc&) |
| 11335 | { |
| 11336 | return gl::error(GL_OUT_OF_MEMORY); |
| 11337 | } |
| 11338 | } |
| 11339 | |
| 11340 | void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 11341 | { |
| 11342 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param); |
| 11343 | |
| 11344 | try |
| 11345 | { |
| 11346 | gl::Context *context = gl::getNonLostContext(); |
| 11347 | |
| 11348 | if (context) |
| 11349 | { |
| 11350 | if (context->getClientVersion() < 3) |
| 11351 | { |
| 11352 | return gl::error(GL_INVALID_OPERATION); |
| 11353 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11354 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11355 | // glSamplerParameterf |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11356 | UNIMPLEMENTED(); |
| 11357 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11358 | } |
| 11359 | catch(std::bad_alloc&) |
| 11360 | { |
| 11361 | return gl::error(GL_OUT_OF_MEMORY); |
| 11362 | } |
| 11363 | } |
| 11364 | |
| 11365 | void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) |
| 11366 | { |
| 11367 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLfloat* param = 0x%0.8p)", sampler, pname, param); |
| 11368 | |
| 11369 | try |
| 11370 | { |
| 11371 | gl::Context *context = gl::getNonLostContext(); |
| 11372 | |
| 11373 | if (context) |
| 11374 | { |
| 11375 | if (context->getClientVersion() < 3) |
| 11376 | { |
| 11377 | return gl::error(GL_INVALID_OPERATION); |
| 11378 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11379 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11380 | // glSamplerParameterfv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11381 | UNIMPLEMENTED(); |
| 11382 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11383 | } |
| 11384 | catch(std::bad_alloc&) |
| 11385 | { |
| 11386 | return gl::error(GL_OUT_OF_MEMORY); |
| 11387 | } |
| 11388 | } |
| 11389 | |
| 11390 | void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) |
| 11391 | { |
| 11392 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); |
| 11393 | |
| 11394 | try |
| 11395 | { |
| 11396 | gl::Context *context = gl::getNonLostContext(); |
| 11397 | |
| 11398 | if (context) |
| 11399 | { |
| 11400 | if (context->getClientVersion() < 3) |
| 11401 | { |
| 11402 | return gl::error(GL_INVALID_OPERATION); |
| 11403 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11404 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11405 | // glGetSamplerParameteriv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11406 | UNIMPLEMENTED(); |
| 11407 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11408 | } |
| 11409 | catch(std::bad_alloc&) |
| 11410 | { |
| 11411 | return gl::error(GL_OUT_OF_MEMORY); |
| 11412 | } |
| 11413 | } |
| 11414 | |
| 11415 | void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) |
| 11416 | { |
| 11417 | EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params); |
| 11418 | |
| 11419 | try |
| 11420 | { |
| 11421 | gl::Context *context = gl::getNonLostContext(); |
| 11422 | |
| 11423 | if (context) |
| 11424 | { |
| 11425 | if (context->getClientVersion() < 3) |
| 11426 | { |
| 11427 | return gl::error(GL_INVALID_OPERATION); |
| 11428 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11429 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11430 | // glGetSamplerParameterfv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11431 | UNIMPLEMENTED(); |
| 11432 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11433 | } |
| 11434 | catch(std::bad_alloc&) |
| 11435 | { |
| 11436 | return gl::error(GL_OUT_OF_MEMORY); |
| 11437 | } |
| 11438 | } |
| 11439 | |
| 11440 | void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor) |
| 11441 | { |
| 11442 | EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor); |
| 11443 | |
| 11444 | try |
| 11445 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 11446 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 11447 | { |
| 11448 | return gl::error(GL_INVALID_VALUE); |
| 11449 | } |
| 11450 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11451 | gl::Context *context = gl::getNonLostContext(); |
| 11452 | |
| 11453 | if (context) |
| 11454 | { |
| 11455 | if (context->getClientVersion() < 3) |
| 11456 | { |
| 11457 | return gl::error(GL_INVALID_OPERATION); |
| 11458 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11459 | |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 11460 | context->setVertexAttribDivisor(index, divisor); |
| 11461 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11462 | } |
| 11463 | catch(std::bad_alloc&) |
| 11464 | { |
| 11465 | return gl::error(GL_OUT_OF_MEMORY); |
| 11466 | } |
| 11467 | } |
| 11468 | |
| 11469 | void __stdcall glBindTransformFeedback(GLenum target, GLuint id) |
| 11470 | { |
| 11471 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 11472 | |
| 11473 | try |
| 11474 | { |
| 11475 | gl::Context *context = gl::getNonLostContext(); |
| 11476 | |
| 11477 | if (context) |
| 11478 | { |
| 11479 | if (context->getClientVersion() < 3) |
| 11480 | { |
| 11481 | return gl::error(GL_INVALID_OPERATION); |
| 11482 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11483 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11484 | // glBindTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11485 | UNIMPLEMENTED(); |
| 11486 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11487 | } |
| 11488 | catch(std::bad_alloc&) |
| 11489 | { |
| 11490 | return gl::error(GL_OUT_OF_MEMORY); |
| 11491 | } |
| 11492 | } |
| 11493 | |
| 11494 | void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) |
| 11495 | { |
| 11496 | EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids); |
| 11497 | |
| 11498 | try |
| 11499 | { |
| 11500 | gl::Context *context = gl::getNonLostContext(); |
| 11501 | |
| 11502 | if (context) |
| 11503 | { |
| 11504 | if (context->getClientVersion() < 3) |
| 11505 | { |
| 11506 | return gl::error(GL_INVALID_OPERATION); |
| 11507 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11508 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11509 | // glDeleteTransformFeedbacks |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11510 | UNIMPLEMENTED(); |
| 11511 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11512 | } |
| 11513 | catch(std::bad_alloc&) |
| 11514 | { |
| 11515 | return gl::error(GL_OUT_OF_MEMORY); |
| 11516 | } |
| 11517 | } |
| 11518 | |
| 11519 | void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids) |
| 11520 | { |
| 11521 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 11522 | |
| 11523 | try |
| 11524 | { |
| 11525 | gl::Context *context = gl::getNonLostContext(); |
| 11526 | |
| 11527 | if (context) |
| 11528 | { |
| 11529 | if (context->getClientVersion() < 3) |
| 11530 | { |
| 11531 | return gl::error(GL_INVALID_OPERATION); |
| 11532 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11533 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11534 | // glGenTransformFeedbacks |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11535 | UNIMPLEMENTED(); |
| 11536 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11537 | } |
| 11538 | catch(std::bad_alloc&) |
| 11539 | { |
| 11540 | return gl::error(GL_OUT_OF_MEMORY); |
| 11541 | } |
| 11542 | } |
| 11543 | |
| 11544 | GLboolean __stdcall glIsTransformFeedback(GLuint id) |
| 11545 | { |
| 11546 | EVENT("(GLuint id = %u)", id); |
| 11547 | |
| 11548 | try |
| 11549 | { |
| 11550 | gl::Context *context = gl::getNonLostContext(); |
| 11551 | |
| 11552 | if (context) |
| 11553 | { |
| 11554 | if (context->getClientVersion() < 3) |
| 11555 | { |
| 11556 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 11557 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11558 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11559 | // glIsTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11560 | UNIMPLEMENTED(); |
| 11561 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11562 | } |
| 11563 | catch(std::bad_alloc&) |
| 11564 | { |
| 11565 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 11566 | } |
| 11567 | |
| 11568 | return GL_FALSE; |
| 11569 | } |
| 11570 | |
| 11571 | void __stdcall glPauseTransformFeedback(void) |
| 11572 | { |
| 11573 | EVENT("(void)"); |
| 11574 | |
| 11575 | try |
| 11576 | { |
| 11577 | gl::Context *context = gl::getNonLostContext(); |
| 11578 | |
| 11579 | if (context) |
| 11580 | { |
| 11581 | if (context->getClientVersion() < 3) |
| 11582 | { |
| 11583 | return gl::error(GL_INVALID_OPERATION); |
| 11584 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11585 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11586 | // glPauseTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11587 | UNIMPLEMENTED(); |
| 11588 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11589 | } |
| 11590 | catch(std::bad_alloc&) |
| 11591 | { |
| 11592 | return gl::error(GL_OUT_OF_MEMORY); |
| 11593 | } |
| 11594 | } |
| 11595 | |
| 11596 | void __stdcall glResumeTransformFeedback(void) |
| 11597 | { |
| 11598 | EVENT("(void)"); |
| 11599 | |
| 11600 | try |
| 11601 | { |
| 11602 | gl::Context *context = gl::getNonLostContext(); |
| 11603 | |
| 11604 | if (context) |
| 11605 | { |
| 11606 | if (context->getClientVersion() < 3) |
| 11607 | { |
| 11608 | return gl::error(GL_INVALID_OPERATION); |
| 11609 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11610 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11611 | // glResumeTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11612 | UNIMPLEMENTED(); |
| 11613 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11614 | } |
| 11615 | catch(std::bad_alloc&) |
| 11616 | { |
| 11617 | return gl::error(GL_OUT_OF_MEMORY); |
| 11618 | } |
| 11619 | } |
| 11620 | |
| 11621 | void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) |
| 11622 | { |
| 11623 | EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)", |
| 11624 | program, bufSize, length, binaryFormat, binary); |
| 11625 | |
| 11626 | try |
| 11627 | { |
| 11628 | gl::Context *context = gl::getNonLostContext(); |
| 11629 | |
| 11630 | if (context) |
| 11631 | { |
| 11632 | if (context->getClientVersion() < 3) |
| 11633 | { |
| 11634 | return gl::error(GL_INVALID_OPERATION); |
| 11635 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11636 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11637 | // glGetProgramBinary |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11638 | UNIMPLEMENTED(); |
| 11639 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11640 | } |
| 11641 | catch(std::bad_alloc&) |
| 11642 | { |
| 11643 | return gl::error(GL_OUT_OF_MEMORY); |
| 11644 | } |
| 11645 | } |
| 11646 | |
| 11647 | void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) |
| 11648 | { |
| 11649 | EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
| 11650 | program, binaryFormat, binary, length); |
| 11651 | |
| 11652 | try |
| 11653 | { |
| 11654 | gl::Context *context = gl::getNonLostContext(); |
| 11655 | |
| 11656 | if (context) |
| 11657 | { |
| 11658 | if (context->getClientVersion() < 3) |
| 11659 | { |
| 11660 | return gl::error(GL_INVALID_OPERATION); |
| 11661 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11662 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11663 | // glProgramBinary |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11664 | UNIMPLEMENTED(); |
| 11665 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11666 | } |
| 11667 | catch(std::bad_alloc&) |
| 11668 | { |
| 11669 | return gl::error(GL_OUT_OF_MEMORY); |
| 11670 | } |
| 11671 | } |
| 11672 | |
| 11673 | void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value) |
| 11674 | { |
| 11675 | EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)", |
| 11676 | program, pname, value); |
| 11677 | |
| 11678 | try |
| 11679 | { |
| 11680 | gl::Context *context = gl::getNonLostContext(); |
| 11681 | |
| 11682 | if (context) |
| 11683 | { |
| 11684 | if (context->getClientVersion() < 3) |
| 11685 | { |
| 11686 | return gl::error(GL_INVALID_OPERATION); |
| 11687 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11688 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11689 | // glProgramParameteri |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11690 | UNIMPLEMENTED(); |
| 11691 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11692 | } |
| 11693 | catch(std::bad_alloc&) |
| 11694 | { |
| 11695 | return gl::error(GL_OUT_OF_MEMORY); |
| 11696 | } |
| 11697 | } |
| 11698 | |
| 11699 | void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) |
| 11700 | { |
| 11701 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)", |
| 11702 | target, numAttachments, attachments); |
| 11703 | |
| 11704 | try |
| 11705 | { |
| 11706 | gl::Context *context = gl::getNonLostContext(); |
| 11707 | |
| 11708 | if (context) |
| 11709 | { |
| 11710 | if (context->getClientVersion() < 3) |
| 11711 | { |
| 11712 | return gl::error(GL_INVALID_OPERATION); |
| 11713 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11714 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11715 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11716 | { |
| 11717 | return; |
| 11718 | } |
| 11719 | |
| 11720 | int maxDimension = context->getMaximumRenderbufferDimension(); |
| 11721 | context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension); |
| 11722 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11723 | } |
| 11724 | catch(std::bad_alloc&) |
| 11725 | { |
| 11726 | return gl::error(GL_OUT_OF_MEMORY); |
| 11727 | } |
| 11728 | } |
| 11729 | |
| 11730 | void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) |
| 11731 | { |
| 11732 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, " |
| 11733 | "GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 11734 | target, numAttachments, attachments, x, y, width, height); |
| 11735 | |
| 11736 | try |
| 11737 | { |
| 11738 | gl::Context *context = gl::getNonLostContext(); |
| 11739 | |
| 11740 | if (context) |
| 11741 | { |
| 11742 | if (context->getClientVersion() < 3) |
| 11743 | { |
| 11744 | return gl::error(GL_INVALID_OPERATION); |
| 11745 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11746 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11747 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11748 | { |
| 11749 | return; |
| 11750 | } |
| 11751 | |
| 11752 | context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height); |
| 11753 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11754 | } |
| 11755 | catch(std::bad_alloc&) |
| 11756 | { |
| 11757 | return gl::error(GL_OUT_OF_MEMORY); |
| 11758 | } |
| 11759 | } |
| 11760 | |
| 11761 | void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 11762 | { |
| 11763 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 11764 | target, levels, internalformat, width, height); |
| 11765 | |
| 11766 | try |
| 11767 | { |
| 11768 | gl::Context *context = gl::getNonLostContext(); |
| 11769 | |
| 11770 | if (context) |
| 11771 | { |
| 11772 | if (context->getClientVersion() < 3) |
| 11773 | { |
| 11774 | return gl::error(GL_INVALID_OPERATION); |
| 11775 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11776 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11777 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 11778 | { |
| 11779 | return; |
| 11780 | } |
| 11781 | |
| 11782 | switch (target) |
| 11783 | { |
| 11784 | case GL_TEXTURE_2D: |
| 11785 | { |
| 11786 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 11787 | texture2d->storage(levels, internalformat, width, height); |
| 11788 | } |
| 11789 | break; |
| 11790 | |
| 11791 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 11792 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 11793 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 11794 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 11795 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 11796 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 11797 | { |
| 11798 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 11799 | textureCube->storage(levels, internalformat, width); |
| 11800 | } |
| 11801 | break; |
| 11802 | |
| 11803 | default: |
| 11804 | return gl::error(GL_INVALID_ENUM); |
| 11805 | } |
| 11806 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11807 | } |
| 11808 | catch(std::bad_alloc&) |
| 11809 | { |
| 11810 | return gl::error(GL_OUT_OF_MEMORY); |
| 11811 | } |
| 11812 | } |
| 11813 | |
| 11814 | void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
| 11815 | { |
| 11816 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 11817 | "GLsizei height = %d, GLsizei depth = %d)", |
| 11818 | target, levels, internalformat, width, height, depth); |
| 11819 | |
| 11820 | try |
| 11821 | { |
| 11822 | gl::Context *context = gl::getNonLostContext(); |
| 11823 | |
| 11824 | if (context) |
| 11825 | { |
| 11826 | if (context->getClientVersion() < 3) |
| 11827 | { |
| 11828 | return gl::error(GL_INVALID_OPERATION); |
| 11829 | } |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11830 | |
| 11831 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) |
| 11832 | { |
| 11833 | return; |
| 11834 | } |
| 11835 | |
| 11836 | switch (target) |
| 11837 | { |
| 11838 | case GL_TEXTURE_3D: |
| 11839 | { |
| 11840 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 11841 | texture3d->storage(levels, internalformat, width, height, depth); |
| 11842 | } |
| 11843 | break; |
| 11844 | |
| 11845 | case GL_TEXTURE_2D_ARRAY: |
| 11846 | { |
| 11847 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 11848 | texture2darray->storage(levels, internalformat, width, height, depth); |
| 11849 | } |
| 11850 | break; |
| 11851 | |
| 11852 | default: |
| 11853 | return gl::error(GL_INVALID_ENUM); |
| 11854 | } |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 11855 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11856 | } |
| 11857 | catch(std::bad_alloc&) |
| 11858 | { |
| 11859 | return gl::error(GL_OUT_OF_MEMORY); |
| 11860 | } |
| 11861 | } |
| 11862 | |
| 11863 | void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) |
| 11864 | { |
| 11865 | EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, " |
| 11866 | "GLint* params = 0x%0.8p)", |
| 11867 | target, internalformat, pname, bufSize, params); |
| 11868 | |
| 11869 | try |
| 11870 | { |
| 11871 | gl::Context *context = gl::getNonLostContext(); |
| 11872 | |
| 11873 | if (context) |
| 11874 | { |
| 11875 | if (context->getClientVersion() < 3) |
| 11876 | { |
| 11877 | return gl::error(GL_INVALID_OPERATION); |
| 11878 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11879 | |
Shannon Woods | 809d250 | 2013-07-08 10:32:18 -0400 | [diff] [blame] | 11880 | if (!gl::IsColorRenderingSupported(internalformat, context) && |
| 11881 | !gl::IsDepthRenderingSupported(internalformat, context) && |
| 11882 | !gl::IsStencilRenderingSupported(internalformat, context)) |
| 11883 | { |
| 11884 | return gl::error(GL_INVALID_ENUM); |
| 11885 | } |
| 11886 | |
| 11887 | if (target != GL_RENDERBUFFER) |
| 11888 | { |
| 11889 | return gl::error(GL_INVALID_ENUM); |
| 11890 | } |
| 11891 | |
| 11892 | if (bufSize < 0) |
| 11893 | { |
| 11894 | return gl::error(GL_INVALID_VALUE); |
| 11895 | } |
| 11896 | |
| 11897 | switch (pname) |
| 11898 | { |
| 11899 | case GL_NUM_SAMPLE_COUNTS: |
| 11900 | if (bufSize != 0) |
| 11901 | *params = context->getNumSampleCounts(internalformat); |
| 11902 | break; |
| 11903 | case GL_SAMPLES: |
| 11904 | context->getSampleCounts(internalformat, bufSize, params); |
| 11905 | break; |
| 11906 | default: |
| 11907 | return gl::error(GL_INVALID_ENUM); |
| 11908 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11909 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11910 | } |
| 11911 | catch(std::bad_alloc&) |
| 11912 | { |
| 11913 | return gl::error(GL_OUT_OF_MEMORY); |
| 11914 | } |
| 11915 | } |
| 11916 | |
| 11917 | // Extension functions |
| 11918 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11919 | void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 11920 | GLbitfield mask, GLenum filter) |
| 11921 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11922 | 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] | 11923 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, " |
| 11924 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 11925 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 11926 | |
| 11927 | try |
| 11928 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11929 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11930 | |
| 11931 | if (context) |
| 11932 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11933 | if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 11934 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 11935 | true)) |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11936 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11937 | return; |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11938 | } |
| 11939 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11940 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 11941 | mask, filter); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11942 | } |
| 11943 | } |
| 11944 | catch(std::bad_alloc&) |
| 11945 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11946 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11947 | } |
| 11948 | } |
| 11949 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 11950 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, |
| 11951 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11952 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11953 | 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] | 11954 | "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] | 11955 | "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] | 11956 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 11957 | |
| 11958 | try |
| 11959 | { |
| 11960 | UNIMPLEMENTED(); // FIXME |
| 11961 | } |
| 11962 | catch(std::bad_alloc&) |
| 11963 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11964 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11965 | } |
| 11966 | } |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11967 | |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11968 | void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, |
| 11969 | GLenum *binaryFormat, void *binary) |
| 11970 | { |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11971 | 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] | 11972 | program, bufSize, length, binaryFormat, binary); |
| 11973 | |
| 11974 | try |
| 11975 | { |
| 11976 | gl::Context *context = gl::getNonLostContext(); |
| 11977 | |
| 11978 | if (context) |
| 11979 | { |
| 11980 | gl::Program *programObject = context->getProgram(program); |
| 11981 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 11982 | if (!programObject || !programObject->isLinked()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11983 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11984 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11985 | } |
| 11986 | |
| 11987 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 11988 | |
| 11989 | if (!programBinary) |
| 11990 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11991 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11992 | } |
| 11993 | |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11994 | if (!programBinary->save(binary, bufSize, length)) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11995 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11996 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11997 | } |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11998 | |
| 11999 | *binaryFormat = GL_PROGRAM_BINARY_ANGLE; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12000 | } |
| 12001 | } |
| 12002 | catch(std::bad_alloc&) |
| 12003 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12004 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12005 | } |
| 12006 | } |
| 12007 | |
| 12008 | void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat, |
| 12009 | const void *binary, GLint length) |
| 12010 | { |
| 12011 | EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)", |
| 12012 | program, binaryFormat, binary, length); |
| 12013 | |
| 12014 | try |
| 12015 | { |
| 12016 | gl::Context *context = gl::getNonLostContext(); |
| 12017 | |
| 12018 | if (context) |
| 12019 | { |
| 12020 | if (binaryFormat != GL_PROGRAM_BINARY_ANGLE) |
| 12021 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12022 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12023 | } |
| 12024 | |
| 12025 | gl::Program *programObject = context->getProgram(program); |
| 12026 | |
| 12027 | if (!programObject) |
| 12028 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12029 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12030 | } |
| 12031 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 12032 | context->setProgramBinary(program, binary, length); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12033 | } |
| 12034 | } |
| 12035 | catch(std::bad_alloc&) |
| 12036 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12037 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12038 | } |
| 12039 | } |
| 12040 | |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12041 | void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) |
| 12042 | { |
| 12043 | EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs); |
| 12044 | |
| 12045 | try |
| 12046 | { |
| 12047 | gl::Context *context = gl::getNonLostContext(); |
| 12048 | |
| 12049 | if (context) |
| 12050 | { |
| 12051 | if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets()) |
| 12052 | { |
| 12053 | return gl::error(GL_INVALID_VALUE); |
| 12054 | } |
| 12055 | |
| 12056 | if (context->getDrawFramebufferHandle() == 0) |
| 12057 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12058 | if (n != 1) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12059 | { |
| 12060 | return gl::error(GL_INVALID_OPERATION); |
| 12061 | } |
| 12062 | |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12063 | 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] | 12064 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12065 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12066 | } |
| 12067 | } |
| 12068 | else |
| 12069 | { |
| 12070 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 12071 | { |
| 12072 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 12073 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment) |
| 12074 | { |
| 12075 | return gl::error(GL_INVALID_OPERATION); |
| 12076 | } |
| 12077 | } |
| 12078 | } |
| 12079 | |
| 12080 | gl::Framebuffer *framebuffer = context->getDrawFramebuffer(); |
| 12081 | |
| 12082 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 12083 | { |
| 12084 | framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]); |
| 12085 | } |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12086 | |
| 12087 | for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++) |
| 12088 | { |
| 12089 | framebuffer->setDrawBufferState(colorAttachment, GL_NONE); |
| 12090 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12091 | } |
| 12092 | } |
| 12093 | catch (std::bad_alloc&) |
| 12094 | { |
| 12095 | return gl::error(GL_OUT_OF_MEMORY); |
| 12096 | } |
| 12097 | } |
| 12098 | |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12099 | __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) |
| 12100 | { |
| 12101 | struct Extension |
| 12102 | { |
| 12103 | const char *name; |
| 12104 | __eglMustCastToProperFunctionPointerType address; |
| 12105 | }; |
| 12106 | |
| 12107 | static const Extension glExtensions[] = |
| 12108 | { |
| 12109 | {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 12110 | {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, |
daniel@transgaming.com | 1fe96c9 | 2011-01-14 15:08:44 +0000 | [diff] [blame] | 12111 | {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 12112 | {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, |
| 12113 | {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, |
| 12114 | {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, |
| 12115 | {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, |
| 12116 | {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, |
| 12117 | {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, |
| 12118 | {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 12119 | {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE}, |
daniel@transgaming.com | 0bd1f2f | 2011-11-11 04:19:03 +0000 | [diff] [blame] | 12120 | {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT}, |
daniel@transgaming.com | 709ed11 | 2011-11-12 03:18:10 +0000 | [diff] [blame] | 12121 | {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT}, |
| 12122 | {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT}, |
| 12123 | {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT}, |
| 12124 | {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT}, |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 12125 | {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT}, |
| 12126 | {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT}, |
| 12127 | {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT}, |
| 12128 | {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT}, |
| 12129 | {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT}, |
| 12130 | {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT}, |
| 12131 | {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT}, |
shannon.woods%transgaming.com@gtempaccount.com | 77d9472 | 2013-04-13 03:34:22 +0000 | [diff] [blame] | 12132 | {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT}, |
daniel@transgaming.com | dce02fd | 2012-01-27 15:39:51 +0000 | [diff] [blame] | 12133 | {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE}, |
| 12134 | {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, |
| 12135 | {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12136 | {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, |
| 12137 | {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, }; |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12138 | |
shannon.woods@transgaming.com | d438fd4 | 2013-02-28 23:17:45 +0000 | [diff] [blame] | 12139 | for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12140 | { |
| 12141 | if (strcmp(procname, glExtensions[ext].name) == 0) |
| 12142 | { |
| 12143 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address; |
| 12144 | } |
| 12145 | } |
| 12146 | |
| 12147 | return NULL; |
| 12148 | } |
| 12149 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 12150 | // Non-public functions used by EGL |
| 12151 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 12152 | bool __stdcall glBindTexImage(egl::Surface *surface) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12153 | { |
| 12154 | EVENT("(egl::Surface* surface = 0x%0.8p)", |
| 12155 | surface); |
| 12156 | |
| 12157 | try |
| 12158 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 12159 | gl::Context *context = gl::getNonLostContext(); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12160 | |
| 12161 | if (context) |
| 12162 | { |
| 12163 | gl::Texture2D *textureObject = context->getTexture2D(); |
| 12164 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 12165 | if (textureObject->isImmutable()) |
| 12166 | { |
| 12167 | return false; |
| 12168 | } |
| 12169 | |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12170 | if (textureObject) |
| 12171 | { |
| 12172 | textureObject->bindTexImage(surface); |
| 12173 | } |
| 12174 | } |
| 12175 | } |
| 12176 | catch(std::bad_alloc&) |
| 12177 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12178 | return gl::error(GL_OUT_OF_MEMORY, false); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12179 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 12180 | |
| 12181 | return true; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12182 | } |
| 12183 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 12184 | } |