shannon.woods@transgaming.com | bdf2d80 | 2013-02-28 23:16:20 +0000 | [diff] [blame] | 1 | #include "precompiled.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2 | // |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 3 | // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4 | // Use of this source code is governed by a BSD-style license that can be |
| 5 | // found in the LICENSE file. |
| 6 | // |
| 7 | |
| 8 | // libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions. |
| 9 | |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 10 | #include "common/version.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 11 | |
| 12 | #include "libGLESv2/main.h" |
shannonwoods@chromium.org | a2ecfcc | 2013-05-30 00:11:59 +0000 | [diff] [blame] | 13 | #include "common/utilities.h" |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 14 | #include "libGLESv2/formatutils.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 15 | #include "libGLESv2/Buffer.h" |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 16 | #include "libGLESv2/Fence.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 17 | #include "libGLESv2/Framebuffer.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 18 | #include "libGLESv2/Renderbuffer.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 19 | #include "libGLESv2/Program.h" |
apatrick@chromium.org | ea09f9b | 2012-06-08 00:45:32 +0000 | [diff] [blame] | 20 | #include "libGLESv2/ProgramBinary.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 21 | #include "libGLESv2/Texture.h" |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 22 | #include "libGLESv2/Query.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 23 | #include "libGLESv2/Context.h" |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 24 | #include "libGLESv2/VertexArray.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 25 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 26 | bool validImageSize(const gl::Context *context, GLint level, GLsizei width, GLsizei height, GLsizei depth) |
daniel@transgaming.com | 4f9ef0d | 2011-05-30 23:51:19 +0000 | [diff] [blame] | 27 | { |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 28 | if (level < 0 || width < 0 || height < 0 || depth < 0) |
daniel@transgaming.com | 4f9ef0d | 2011-05-30 23:51:19 +0000 | [diff] [blame] | 29 | { |
| 30 | return false; |
| 31 | } |
| 32 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 33 | if (context->supportsNonPower2Texture()) |
daniel@transgaming.com | 4f9ef0d | 2011-05-30 23:51:19 +0000 | [diff] [blame] | 34 | { |
| 35 | return true; |
| 36 | } |
| 37 | |
| 38 | if (level == 0) |
| 39 | { |
| 40 | return true; |
| 41 | } |
| 42 | |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 43 | if (gl::isPow2(width) && gl::isPow2(height) && gl::isPow2(depth)) |
daniel@transgaming.com | 4f9ef0d | 2011-05-30 23:51:19 +0000 | [diff] [blame] | 44 | { |
| 45 | return true; |
| 46 | } |
| 47 | |
| 48 | return false; |
| 49 | } |
| 50 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 51 | bool validCompressedImageSize(GLsizei width, GLsizei height) |
| 52 | { |
| 53 | if (width != 1 && width != 2 && width % 4 != 0) |
| 54 | { |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | if (height != 1 && height != 2 && height % 4 != 0) |
| 59 | { |
| 60 | return false; |
| 61 | } |
| 62 | |
| 63 | return true; |
| 64 | } |
| 65 | |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 66 | // Verify that format/type are one of the combinations from table 3.4. |
| 67 | bool checkTextureFormatType(GLenum format, GLenum type) |
| 68 | { |
| 69 | // validate <format> by itself (used as secondary key below) |
| 70 | switch (format) |
| 71 | { |
| 72 | case GL_RGBA: |
| 73 | case GL_BGRA_EXT: |
| 74 | case GL_RGB: |
| 75 | case GL_ALPHA: |
| 76 | case GL_LUMINANCE: |
| 77 | case GL_LUMINANCE_ALPHA: |
| 78 | case GL_DEPTH_COMPONENT: |
| 79 | case GL_DEPTH_STENCIL_OES: |
| 80 | break; |
| 81 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 82 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | // invalid <type> -> sets INVALID_ENUM |
| 86 | // invalid <format>+<type> combination -> sets INVALID_OPERATION |
| 87 | switch (type) |
| 88 | { |
| 89 | case GL_UNSIGNED_BYTE: |
| 90 | switch (format) |
| 91 | { |
| 92 | case GL_RGBA: |
| 93 | case GL_BGRA_EXT: |
| 94 | case GL_RGB: |
| 95 | case GL_ALPHA: |
| 96 | case GL_LUMINANCE: |
| 97 | case GL_LUMINANCE_ALPHA: |
| 98 | return true; |
| 99 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 100 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | case GL_FLOAT: |
| 104 | case GL_HALF_FLOAT_OES: |
| 105 | switch (format) |
| 106 | { |
| 107 | case GL_RGBA: |
| 108 | case GL_RGB: |
| 109 | case GL_ALPHA: |
| 110 | case GL_LUMINANCE: |
| 111 | case GL_LUMINANCE_ALPHA: |
| 112 | return true; |
| 113 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 114 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 118 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 119 | switch (format) |
| 120 | { |
| 121 | case GL_RGBA: |
| 122 | return true; |
| 123 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 124 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | case GL_UNSIGNED_SHORT_5_6_5: |
| 128 | switch (format) |
| 129 | { |
| 130 | case GL_RGB: |
| 131 | return true; |
| 132 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 133 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | case GL_UNSIGNED_SHORT: |
| 137 | case GL_UNSIGNED_INT: |
| 138 | switch (format) |
| 139 | { |
| 140 | case GL_DEPTH_COMPONENT: |
| 141 | return true; |
| 142 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 143 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | case GL_UNSIGNED_INT_24_8_OES: |
| 147 | switch (format) |
| 148 | { |
| 149 | case GL_DEPTH_STENCIL_OES: |
| 150 | return true; |
| 151 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 152 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 156 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 8833dd2 | 2012-06-05 19:49:58 +0000 | [diff] [blame] | 157 | } |
| 158 | } |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 159 | |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 160 | bool validateSubImageParams2D(bool compressed, GLsizei width, GLsizei height, |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 161 | GLint xoffset, GLint yoffset, GLint level, GLenum format, GLenum type, |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 162 | gl::Texture2D *texture) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 163 | { |
| 164 | if (!texture) |
| 165 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 166 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 167 | } |
| 168 | |
daniel@transgaming.com | 92f4992 | 2012-05-09 15:49:19 +0000 | [diff] [blame] | 169 | if (compressed != texture->isCompressed(level)) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 170 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 171 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 172 | } |
| 173 | |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 174 | if (format != GL_NONE) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 175 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 176 | GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 177 | if (internalformat != texture->getInternalFormat(level)) |
| 178 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 179 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 180 | } |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | if (compressed) |
| 184 | { |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 185 | if ((width % 4 != 0 && width != texture->getWidth(0)) || |
| 186 | (height % 4 != 0 && height != texture->getHeight(0))) |
| 187 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 188 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 189 | } |
| 190 | } |
| 191 | |
| 192 | if (xoffset + width > texture->getWidth(level) || |
| 193 | yoffset + height > texture->getHeight(level)) |
| 194 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 195 | return gl::error(GL_INVALID_VALUE, false); |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | return true; |
| 199 | } |
| 200 | |
| 201 | bool validateSubImageParamsCube(bool compressed, GLsizei width, GLsizei height, |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 202 | GLint xoffset, GLint yoffset, GLenum target, GLint level, GLenum format, GLenum type, |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 203 | gl::TextureCubeMap *texture) |
| 204 | { |
| 205 | if (!texture) |
| 206 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 207 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 208 | } |
| 209 | |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 210 | if (compressed != texture->isCompressed(target, level)) |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 211 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 212 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 213 | } |
| 214 | |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 215 | if (format != GL_NONE) |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 216 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 217 | GLenum internalformat = gl::GetSizedInternalFormat(format, type, 2); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 218 | if (internalformat != texture->getInternalFormat(target, level)) |
| 219 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 220 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 221 | } |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | if (compressed) |
| 225 | { |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 226 | if ((width % 4 != 0 && width != texture->getWidth(target, 0)) || |
| 227 | (height % 4 != 0 && height != texture->getHeight(target, 0))) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 228 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 229 | return gl::error(GL_INVALID_OPERATION, false); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 230 | } |
| 231 | } |
| 232 | |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 233 | if (xoffset + width > texture->getWidth(target, level) || |
| 234 | yoffset + height > texture->getHeight(target, level)) |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 235 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 236 | return gl::error(GL_INVALID_VALUE, false); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | return true; |
| 240 | } |
| 241 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 242 | bool validateES2TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage, |
| 243 | GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 244 | GLint border, GLenum format, GLenum type, const GLvoid *pixels) |
| 245 | { |
| 246 | if (!validImageSize(context, level, width, height, 1)) |
| 247 | { |
| 248 | return gl::error(GL_INVALID_VALUE, false); |
| 249 | } |
| 250 | |
| 251 | if (isCompressed && !validCompressedImageSize(width, height)) |
| 252 | { |
| 253 | return gl::error(GL_INVALID_OPERATION, false); |
| 254 | } |
| 255 | |
| 256 | if (level < 0 || xoffset < 0 || |
| 257 | std::numeric_limits<GLsizei>::max() - xoffset < width || |
| 258 | std::numeric_limits<GLsizei>::max() - yoffset < height) |
| 259 | { |
| 260 | return gl::error(GL_INVALID_VALUE, false); |
| 261 | } |
| 262 | |
| 263 | if (!isSubImage && !isCompressed && internalformat != GLint(format)) |
| 264 | { |
| 265 | return gl::error(GL_INVALID_OPERATION, false); |
| 266 | } |
| 267 | |
| 268 | gl::Texture *texture = NULL; |
| 269 | bool textureCompressed = false; |
| 270 | GLenum textureInternalFormat = GL_NONE; |
| 271 | GLint textureLevelWidth = 0; |
| 272 | GLint textureLevelHeight = 0; |
| 273 | switch (target) |
| 274 | { |
| 275 | case GL_TEXTURE_2D: |
| 276 | { |
| 277 | if (width > (context->getMaximum2DTextureDimension() >> level) || |
| 278 | height > (context->getMaximum2DTextureDimension() >> level)) |
| 279 | { |
| 280 | return gl::error(GL_INVALID_VALUE, false); |
| 281 | } |
| 282 | |
| 283 | gl::Texture2D *tex2d = context->getTexture2D(); |
| 284 | if (tex2d) |
| 285 | { |
| 286 | textureCompressed = tex2d->isCompressed(level); |
| 287 | textureInternalFormat = tex2d->getInternalFormat(level); |
| 288 | textureLevelWidth = tex2d->getWidth(level); |
| 289 | textureLevelHeight = tex2d->getHeight(level); |
| 290 | texture = tex2d; |
| 291 | } |
| 292 | |
| 293 | if (isSubImage && !validateSubImageParams2D(isCompressed, width, height, xoffset, yoffset, |
| 294 | level, format, type, tex2d)) |
| 295 | { |
| 296 | return false; |
| 297 | } |
| 298 | |
| 299 | texture = tex2d; |
| 300 | } |
| 301 | break; |
| 302 | |
| 303 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 304 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 305 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 306 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 307 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 308 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 309 | { |
| 310 | if (!isSubImage && width != height) |
| 311 | { |
| 312 | return gl::error(GL_INVALID_VALUE, false); |
| 313 | } |
| 314 | |
| 315 | if (width > (context->getMaximumCubeTextureDimension() >> level) || |
| 316 | height > (context->getMaximumCubeTextureDimension() >> level)) |
| 317 | { |
| 318 | return gl::error(GL_INVALID_VALUE, false); |
| 319 | } |
| 320 | |
| 321 | gl::TextureCubeMap *texCube = context->getTextureCubeMap(); |
| 322 | if (texCube) |
| 323 | { |
| 324 | textureCompressed = texCube->isCompressed(target, level); |
| 325 | textureInternalFormat = texCube->getInternalFormat(target, level); |
| 326 | textureLevelWidth = texCube->getWidth(target, level); |
| 327 | textureLevelHeight = texCube->getHeight(target, level); |
| 328 | texture = texCube; |
| 329 | } |
| 330 | |
| 331 | if (isSubImage && !validateSubImageParamsCube(isCompressed, width, height, xoffset, yoffset, |
| 332 | target, level, format, type, texCube)) |
| 333 | { |
| 334 | return false; |
| 335 | } |
| 336 | } |
| 337 | break; |
| 338 | |
| 339 | default: |
| 340 | return gl::error(GL_INVALID_ENUM, false); |
| 341 | } |
| 342 | |
| 343 | if (!texture) |
| 344 | { |
| 345 | return gl::error(GL_INVALID_OPERATION, false); |
| 346 | } |
| 347 | |
| 348 | if (!isSubImage && texture->isImmutable()) |
| 349 | { |
| 350 | return gl::error(GL_INVALID_OPERATION, false); |
| 351 | } |
| 352 | |
| 353 | // Verify zero border |
| 354 | if (border != 0) |
| 355 | { |
| 356 | return gl::error(GL_INVALID_VALUE, false); |
| 357 | } |
| 358 | |
| 359 | // Verify texture is not requesting more mip levels than are available. |
| 360 | if (level > context->getMaximumTextureLevel()) |
| 361 | { |
| 362 | return gl::error(GL_INVALID_VALUE, false); |
| 363 | } |
| 364 | |
| 365 | GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat; |
| 366 | if (isCompressed) |
| 367 | { |
| 368 | switch (actualInternalFormat) |
| 369 | { |
| 370 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 371 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 372 | if (!context->supportsDXT1Textures()) |
| 373 | { |
| 374 | return gl::error(GL_INVALID_ENUM, false); |
| 375 | } |
| 376 | break; |
| 377 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 378 | if (!context->supportsDXT3Textures()) |
| 379 | { |
| 380 | return gl::error(GL_INVALID_ENUM, false); |
| 381 | } |
| 382 | break; |
| 383 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 384 | if (!context->supportsDXT5Textures()) |
| 385 | { |
| 386 | return gl::error(GL_INVALID_ENUM, false); |
| 387 | } |
| 388 | break; |
| 389 | default: |
| 390 | return gl::error(GL_INVALID_ENUM, false); |
| 391 | } |
| 392 | } |
| 393 | else |
| 394 | { |
| 395 | // validate <type> by itself (used as secondary key below) |
| 396 | switch (type) |
| 397 | { |
| 398 | case GL_UNSIGNED_BYTE: |
| 399 | case GL_UNSIGNED_SHORT_5_6_5: |
| 400 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 401 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 402 | case GL_UNSIGNED_SHORT: |
| 403 | case GL_UNSIGNED_INT: |
| 404 | case GL_UNSIGNED_INT_24_8_OES: |
| 405 | case GL_HALF_FLOAT_OES: |
| 406 | case GL_FLOAT: |
| 407 | break; |
| 408 | default: |
| 409 | return gl::error(GL_INVALID_ENUM, false); |
| 410 | } |
| 411 | |
| 412 | // validate <format> + <type> combinations |
| 413 | // - invalid <format> -> sets INVALID_ENUM |
| 414 | // - invalid <format>+<type> combination -> sets INVALID_OPERATION |
| 415 | switch (format) |
| 416 | { |
| 417 | case GL_ALPHA: |
| 418 | case GL_LUMINANCE: |
| 419 | case GL_LUMINANCE_ALPHA: |
| 420 | switch (type) |
| 421 | { |
| 422 | case GL_UNSIGNED_BYTE: |
| 423 | case GL_FLOAT: |
| 424 | case GL_HALF_FLOAT_OES: |
| 425 | break; |
| 426 | default: |
| 427 | return gl::error(GL_INVALID_OPERATION, false); |
| 428 | } |
| 429 | break; |
| 430 | case GL_RGB: |
| 431 | switch (type) |
| 432 | { |
| 433 | case GL_UNSIGNED_BYTE: |
| 434 | case GL_UNSIGNED_SHORT_5_6_5: |
| 435 | case GL_FLOAT: |
| 436 | case GL_HALF_FLOAT_OES: |
| 437 | break; |
| 438 | default: |
| 439 | return gl::error(GL_INVALID_OPERATION, false); |
| 440 | } |
| 441 | break; |
| 442 | case GL_RGBA: |
| 443 | switch (type) |
| 444 | { |
| 445 | case GL_UNSIGNED_BYTE: |
| 446 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 447 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 448 | case GL_FLOAT: |
| 449 | case GL_HALF_FLOAT_OES: |
| 450 | break; |
| 451 | default: |
| 452 | return gl::error(GL_INVALID_OPERATION, false); |
| 453 | } |
| 454 | break; |
| 455 | case GL_BGRA_EXT: |
| 456 | switch (type) |
| 457 | { |
| 458 | case GL_UNSIGNED_BYTE: |
| 459 | break; |
| 460 | default: |
| 461 | return gl::error(GL_INVALID_OPERATION, false); |
| 462 | } |
| 463 | break; |
| 464 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below |
| 465 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 466 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 467 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 468 | break; |
| 469 | case GL_DEPTH_COMPONENT: |
| 470 | switch (type) |
| 471 | { |
| 472 | case GL_UNSIGNED_SHORT: |
| 473 | case GL_UNSIGNED_INT: |
| 474 | break; |
| 475 | default: |
| 476 | return gl::error(GL_INVALID_OPERATION, false); |
| 477 | } |
| 478 | break; |
| 479 | case GL_DEPTH_STENCIL_OES: |
| 480 | switch (type) |
| 481 | { |
| 482 | case GL_UNSIGNED_INT_24_8_OES: |
| 483 | break; |
| 484 | default: |
| 485 | return gl::error(GL_INVALID_OPERATION, false); |
| 486 | } |
| 487 | break; |
| 488 | default: |
| 489 | return gl::error(GL_INVALID_ENUM, false); |
| 490 | } |
| 491 | |
| 492 | switch (format) |
| 493 | { |
| 494 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 495 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 496 | if (context->supportsDXT1Textures()) |
| 497 | { |
| 498 | return gl::error(GL_INVALID_OPERATION, false); |
| 499 | } |
| 500 | else |
| 501 | { |
| 502 | return gl::error(GL_INVALID_ENUM, false); |
| 503 | } |
| 504 | break; |
| 505 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 506 | if (context->supportsDXT3Textures()) |
| 507 | { |
| 508 | return gl::error(GL_INVALID_OPERATION, false); |
| 509 | } |
| 510 | else |
| 511 | { |
| 512 | return gl::error(GL_INVALID_ENUM, false); |
| 513 | } |
| 514 | break; |
| 515 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 516 | if (context->supportsDXT5Textures()) |
| 517 | { |
| 518 | return gl::error(GL_INVALID_OPERATION, false); |
| 519 | } |
| 520 | else |
| 521 | { |
| 522 | return gl::error(GL_INVALID_ENUM, false); |
| 523 | } |
| 524 | break; |
| 525 | case GL_DEPTH_COMPONENT: |
| 526 | case GL_DEPTH_STENCIL_OES: |
| 527 | if (!context->supportsDepthTextures()) |
| 528 | { |
| 529 | return gl::error(GL_INVALID_VALUE, false); |
| 530 | } |
| 531 | if (target != GL_TEXTURE_2D) |
| 532 | { |
| 533 | return gl::error(GL_INVALID_OPERATION, false); |
| 534 | } |
| 535 | // OES_depth_texture supports loading depth data and multiple levels, |
| 536 | // but ANGLE_depth_texture does not |
| 537 | if (pixels != NULL || level != 0) |
| 538 | { |
| 539 | return gl::error(GL_INVALID_OPERATION, false); |
| 540 | } |
| 541 | break; |
| 542 | default: |
| 543 | break; |
| 544 | } |
| 545 | |
| 546 | if (type == GL_FLOAT) |
| 547 | { |
| 548 | if (!context->supportsFloat32Textures()) |
| 549 | { |
| 550 | return gl::error(GL_INVALID_ENUM, false); |
| 551 | } |
| 552 | } |
| 553 | else if (type == GL_HALF_FLOAT_OES) |
| 554 | { |
| 555 | if (!context->supportsFloat16Textures()) |
| 556 | { |
| 557 | return gl::error(GL_INVALID_ENUM, false); |
| 558 | } |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | return true; |
| 563 | } |
| 564 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 565 | bool validateES3TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage, |
| 566 | GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, |
| 567 | GLint border, GLenum format, GLenum type) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 568 | { |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 569 | // Validate image size |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 570 | if (!validImageSize(context, level, width, height, depth)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 571 | { |
| 572 | return gl::error(GL_INVALID_VALUE, false); |
| 573 | } |
| 574 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 575 | if (isCompressed && !validCompressedImageSize(width, height)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 576 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 577 | return gl::error(GL_INVALID_OPERATION, false); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | // Verify zero border |
| 581 | if (border != 0) |
| 582 | { |
| 583 | return gl::error(GL_INVALID_VALUE, false); |
| 584 | } |
| 585 | |
| 586 | // Validate dimensions based on Context limits and validate the texture |
| 587 | if (level > context->getMaximumTextureLevel()) |
| 588 | { |
| 589 | return gl::error(GL_INVALID_VALUE, false); |
| 590 | } |
| 591 | |
| 592 | gl::Texture *texture = NULL; |
| 593 | bool textureCompressed = false; |
| 594 | GLenum textureInternalFormat = GL_NONE; |
| 595 | GLint textureLevelWidth = 0; |
| 596 | GLint textureLevelHeight = 0; |
| 597 | GLint textureLevelDepth = 0; |
| 598 | switch (target) |
| 599 | { |
| 600 | case GL_TEXTURE_2D: |
| 601 | { |
| 602 | if (width > (context->getMaximum2DTextureDimension() >> level) || |
| 603 | height > (context->getMaximum2DTextureDimension() >> level)) |
| 604 | { |
| 605 | return gl::error(GL_INVALID_VALUE, false); |
| 606 | } |
| 607 | |
| 608 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 609 | if (texture2d) |
| 610 | { |
| 611 | textureCompressed = texture2d->isCompressed(level); |
| 612 | textureInternalFormat = texture2d->getInternalFormat(level); |
| 613 | textureLevelWidth = texture2d->getWidth(level); |
| 614 | textureLevelHeight = texture2d->getHeight(level); |
| 615 | textureLevelDepth = 1; |
| 616 | texture = texture2d; |
| 617 | } |
| 618 | } |
| 619 | break; |
| 620 | |
| 621 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 622 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 623 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 624 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 625 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 626 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 627 | { |
shannonwoods@chromium.org | 92852cf | 2013-05-30 00:14:12 +0000 | [diff] [blame] | 628 | if (!isSubImage && width != height) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 629 | { |
| 630 | return gl::error(GL_INVALID_VALUE, false); |
| 631 | } |
| 632 | |
| 633 | if (width > (context->getMaximumCubeTextureDimension() >> level)) |
| 634 | { |
| 635 | return gl::error(GL_INVALID_VALUE, false); |
| 636 | } |
| 637 | |
| 638 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 639 | if (textureCube) |
| 640 | { |
| 641 | textureCompressed = textureCube->isCompressed(target, level); |
| 642 | textureInternalFormat = textureCube->getInternalFormat(target, level); |
| 643 | textureLevelWidth = textureCube->getWidth(target, level); |
| 644 | textureLevelHeight = textureCube->getHeight(target, level); |
| 645 | textureLevelDepth = 1; |
| 646 | texture = textureCube; |
| 647 | } |
| 648 | } |
| 649 | break; |
| 650 | |
| 651 | case GL_TEXTURE_3D: |
| 652 | { |
| 653 | if (width > (context->getMaximum3DTextureDimension() >> level) || |
| 654 | height > (context->getMaximum3DTextureDimension() >> level) || |
| 655 | depth > (context->getMaximum3DTextureDimension() >> level)) |
| 656 | { |
| 657 | return gl::error(GL_INVALID_VALUE, false); |
| 658 | } |
| 659 | |
| 660 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 661 | if (texture3d) |
| 662 | { |
| 663 | textureCompressed = texture3d->isCompressed(level); |
| 664 | textureInternalFormat = texture3d->getInternalFormat(level); |
| 665 | textureLevelWidth = texture3d->getWidth(level); |
| 666 | textureLevelHeight = texture3d->getHeight(level); |
| 667 | textureLevelDepth = texture3d->getDepth(level); |
| 668 | texture = texture3d; |
| 669 | } |
| 670 | } |
| 671 | break; |
| 672 | |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 673 | case GL_TEXTURE_2D_ARRAY: |
| 674 | { |
| 675 | if (width > (context->getMaximum2DTextureDimension() >> level) || |
| 676 | height > (context->getMaximum2DTextureDimension() >> level) || |
| 677 | depth > (context->getMaximum2DArrayTextureLayers() >> level)) |
| 678 | { |
| 679 | return gl::error(GL_INVALID_VALUE, false); |
| 680 | } |
| 681 | |
| 682 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 683 | if (texture2darray) |
| 684 | { |
| 685 | textureCompressed = texture2darray->isCompressed(level); |
| 686 | textureInternalFormat = texture2darray->getInternalFormat(level); |
| 687 | textureLevelWidth = texture2darray->getWidth(level); |
| 688 | textureLevelHeight = texture2darray->getHeight(level); |
| 689 | textureLevelDepth = texture2darray->getDepth(level); |
| 690 | texture = texture2darray; |
| 691 | } |
| 692 | } |
| 693 | break; |
| 694 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 695 | default: |
| 696 | return gl::error(GL_INVALID_ENUM, false); |
| 697 | } |
| 698 | |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 699 | if (!texture) |
| 700 | { |
| 701 | return gl::error(GL_INVALID_OPERATION, false); |
| 702 | } |
| 703 | |
shannonwoods@chromium.org | cf2533c | 2013-05-30 00:14:18 +0000 | [diff] [blame] | 704 | if (texture->isImmutable() && !isSubImage) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 705 | { |
| 706 | return gl::error(GL_INVALID_OPERATION, false); |
| 707 | } |
| 708 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 709 | // Validate texture formats |
| 710 | GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat; |
| 711 | if (isCompressed) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 712 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 713 | if (!gl::IsFormatCompressed(actualInternalFormat, context->getClientVersion())) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 714 | { |
| 715 | return gl::error(GL_INVALID_ENUM, false); |
| 716 | } |
| 717 | |
| 718 | if (target == GL_TEXTURE_3D) |
| 719 | { |
| 720 | return gl::error(GL_INVALID_OPERATION, false); |
| 721 | } |
| 722 | } |
| 723 | else |
| 724 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 725 | if (!gl::IsValidInternalFormat(actualInternalFormat, context) || |
| 726 | !gl::IsValidFormat(format, context->getClientVersion()) || |
| 727 | !gl::IsValidType(type, context->getClientVersion())) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 728 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 729 | return gl::error(GL_INVALID_ENUM, false); |
| 730 | } |
| 731 | |
| 732 | if (!gl::IsValidFormatCombination(actualInternalFormat, format, type, context->getClientVersion())) |
| 733 | { |
| 734 | return gl::error(GL_INVALID_OPERATION, false); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 735 | } |
| 736 | |
| 737 | if ((target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) && |
| 738 | (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL)) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 739 | { |
| 740 | return gl::error(GL_INVALID_OPERATION, false); |
| 741 | } |
| 742 | } |
| 743 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 744 | // Validate sub image parameters |
| 745 | if (isSubImage) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 746 | { |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 747 | if (isCompressed != textureCompressed) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 748 | { |
| 749 | return gl::error(GL_INVALID_OPERATION, false); |
| 750 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 751 | |
| 752 | if (format != GL_NONE) |
| 753 | { |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 754 | GLenum internalformat = gl::GetSizedInternalFormat(format, type, context->getClientVersion()); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 755 | if (internalformat != textureInternalFormat) |
| 756 | { |
| 757 | return gl::error(GL_INVALID_OPERATION, false); |
| 758 | } |
| 759 | } |
| 760 | |
| 761 | if (isCompressed) |
| 762 | { |
| 763 | if ((width % 4 != 0 && width != textureLevelWidth) || |
| 764 | (height % 4 != 0 && height != textureLevelHeight)) |
| 765 | { |
| 766 | return gl::error(GL_INVALID_OPERATION, false); |
| 767 | } |
| 768 | } |
| 769 | |
| 770 | if (width == 0 || height == 0 || depth == 0) |
| 771 | { |
| 772 | return false; |
| 773 | } |
| 774 | |
| 775 | if (xoffset < 0 || yoffset < 0 || zoffset < 0) |
| 776 | { |
| 777 | return gl::error(GL_INVALID_VALUE, false); |
| 778 | } |
| 779 | |
| 780 | if (std::numeric_limits<GLsizei>::max() - xoffset < width || |
| 781 | std::numeric_limits<GLsizei>::max() - yoffset < height || |
| 782 | std::numeric_limits<GLsizei>::max() - zoffset < depth) |
| 783 | { |
| 784 | return gl::error(GL_INVALID_VALUE, false); |
| 785 | } |
| 786 | |
| 787 | if (xoffset + width > textureLevelWidth || |
| 788 | yoffset + height > textureLevelHeight || |
| 789 | zoffset + depth > textureLevelDepth) |
| 790 | { |
| 791 | return gl::error(GL_INVALID_VALUE, false); |
| 792 | } |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 793 | } |
| 794 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 795 | return true; |
| 796 | } |
| 797 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 798 | |
| 799 | bool validateES2CopyTexImageParameters(gl::Context* context, GLenum target, GLint level, GLenum internalformat, bool isSubImage, |
| 800 | GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, |
| 801 | GLint border) |
| 802 | { |
| 803 | if (!gl::IsInternalTextureTarget(target)) |
| 804 | { |
| 805 | return gl::error(GL_INVALID_ENUM, false); |
| 806 | } |
| 807 | |
| 808 | if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0) |
| 809 | { |
| 810 | return gl::error(GL_INVALID_VALUE, false); |
| 811 | } |
| 812 | |
| 813 | if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height) |
| 814 | { |
| 815 | return gl::error(GL_INVALID_VALUE, false); |
| 816 | } |
| 817 | |
| 818 | if (width == 0 || height == 0) |
| 819 | { |
| 820 | return false; |
| 821 | } |
| 822 | |
| 823 | // Verify zero border |
| 824 | if (border != 0) |
| 825 | { |
| 826 | return gl::error(GL_INVALID_VALUE, false); |
| 827 | } |
| 828 | |
| 829 | // Validate dimensions based on Context limits and validate the texture |
| 830 | if (level > context->getMaximumTextureLevel()) |
| 831 | { |
| 832 | return gl::error(GL_INVALID_VALUE, false); |
| 833 | } |
| 834 | |
| 835 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 836 | |
| 837 | if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) |
| 838 | { |
| 839 | return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); |
| 840 | } |
| 841 | |
| 842 | if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0) |
| 843 | { |
| 844 | return gl::error(GL_INVALID_OPERATION, false); |
| 845 | } |
| 846 | |
| 847 | GLenum colorbufferFormat = framebuffer->getReadColorbuffer()->getInternalFormat(); |
| 848 | gl::Texture *texture = NULL; |
| 849 | GLenum textureFormat = GL_RGBA; |
| 850 | |
| 851 | switch (target) |
| 852 | { |
| 853 | case GL_TEXTURE_2D: |
| 854 | { |
| 855 | if (width > (context->getMaximum2DTextureDimension() >> level) || |
| 856 | height > (context->getMaximum2DTextureDimension() >> level)) |
| 857 | { |
| 858 | return gl::error(GL_INVALID_VALUE, false); |
| 859 | } |
| 860 | |
| 861 | gl::Texture2D *tex2d = context->getTexture2D(); |
| 862 | if (tex2d) |
| 863 | { |
| 864 | if (isSubImage && !validateSubImageParams2D(false, width, height, xoffset, yoffset, level, GL_NONE, GL_NONE, tex2d)) |
| 865 | { |
| 866 | return false; // error already registered by validateSubImageParams |
| 867 | } |
| 868 | texture = tex2d; |
| 869 | textureFormat = gl::GetFormat(tex2d->getInternalFormat(level), context->getClientVersion()); |
| 870 | } |
| 871 | } |
| 872 | break; |
| 873 | |
| 874 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 875 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 876 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 877 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 878 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 879 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 880 | { |
| 881 | if (!isSubImage && width != height) |
| 882 | { |
| 883 | return gl::error(GL_INVALID_VALUE, false); |
| 884 | } |
| 885 | |
| 886 | if (width > (context->getMaximumCubeTextureDimension() >> level) || |
| 887 | height > (context->getMaximumCubeTextureDimension() >> level)) |
| 888 | { |
| 889 | return gl::error(GL_INVALID_VALUE, false); |
| 890 | } |
| 891 | |
| 892 | gl::TextureCubeMap *texcube = context->getTextureCubeMap(); |
| 893 | if (texcube) |
| 894 | { |
| 895 | if (isSubImage && !validateSubImageParamsCube(false, width, height, xoffset, yoffset, target, level, GL_NONE, GL_NONE, texcube)) |
| 896 | { |
| 897 | return false; // error already registered by validateSubImageParams |
| 898 | } |
| 899 | texture = texcube; |
| 900 | textureFormat = gl::GetFormat(texcube->getInternalFormat(target, level), context->getClientVersion()); |
| 901 | } |
| 902 | } |
| 903 | break; |
| 904 | |
| 905 | default: |
| 906 | return gl::error(GL_INVALID_ENUM, false); |
| 907 | } |
| 908 | |
| 909 | if (!texture) |
| 910 | { |
| 911 | return gl::error(GL_INVALID_OPERATION, false); |
| 912 | } |
| 913 | |
| 914 | if (texture->isImmutable() && !isSubImage) |
| 915 | { |
| 916 | return gl::error(GL_INVALID_OPERATION, false); |
| 917 | } |
| 918 | |
| 919 | |
| 920 | // [OpenGL ES 2.0.24] table 3.9 |
| 921 | if (isSubImage) |
| 922 | { |
| 923 | switch (textureFormat) |
| 924 | { |
| 925 | case GL_ALPHA: |
| 926 | if (colorbufferFormat != GL_ALPHA8_EXT && |
| 927 | colorbufferFormat != GL_RGBA4 && |
| 928 | colorbufferFormat != GL_RGB5_A1 && |
| 929 | colorbufferFormat != GL_RGBA8_OES) |
| 930 | { |
| 931 | return gl::error(GL_INVALID_OPERATION, false); |
| 932 | } |
| 933 | break; |
| 934 | case GL_LUMINANCE: |
| 935 | case GL_RGB: |
| 936 | if (colorbufferFormat != GL_RGB565 && |
| 937 | colorbufferFormat != GL_RGB8_OES && |
| 938 | colorbufferFormat != GL_RGBA4 && |
| 939 | colorbufferFormat != GL_RGB5_A1 && |
| 940 | colorbufferFormat != GL_RGBA8_OES) |
| 941 | { |
| 942 | return gl::error(GL_INVALID_OPERATION, false); |
| 943 | } |
| 944 | break; |
| 945 | case GL_LUMINANCE_ALPHA: |
| 946 | case GL_RGBA: |
| 947 | if (colorbufferFormat != GL_RGBA4 && |
| 948 | colorbufferFormat != GL_RGB5_A1 && |
| 949 | colorbufferFormat != GL_RGBA8_OES) |
| 950 | { |
| 951 | return gl::error(GL_INVALID_OPERATION, false); |
| 952 | } |
| 953 | break; |
| 954 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 955 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 956 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 957 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 958 | return gl::error(GL_INVALID_OPERATION, false); |
| 959 | case GL_DEPTH_COMPONENT: |
| 960 | case GL_DEPTH_STENCIL_OES: |
| 961 | return gl::error(GL_INVALID_OPERATION, false); |
| 962 | default: |
| 963 | return gl::error(GL_INVALID_OPERATION, false); |
| 964 | } |
| 965 | } |
| 966 | else |
| 967 | { |
| 968 | switch (internalformat) |
| 969 | { |
| 970 | case GL_ALPHA: |
| 971 | if (colorbufferFormat != GL_ALPHA8_EXT && |
| 972 | colorbufferFormat != GL_RGBA4 && |
| 973 | colorbufferFormat != GL_RGB5_A1 && |
| 974 | colorbufferFormat != GL_BGRA8_EXT && |
| 975 | colorbufferFormat != GL_RGBA8_OES) |
| 976 | { |
| 977 | return gl::error(GL_INVALID_OPERATION, false); |
| 978 | } |
| 979 | break; |
| 980 | case GL_LUMINANCE: |
| 981 | case GL_RGB: |
| 982 | if (colorbufferFormat != GL_RGB565 && |
| 983 | colorbufferFormat != GL_RGB8_OES && |
| 984 | colorbufferFormat != GL_RGBA4 && |
| 985 | colorbufferFormat != GL_RGB5_A1 && |
| 986 | colorbufferFormat != GL_BGRA8_EXT && |
| 987 | colorbufferFormat != GL_RGBA8_OES) |
| 988 | { |
| 989 | return gl::error(GL_INVALID_OPERATION, false); |
| 990 | } |
| 991 | break; |
| 992 | case GL_LUMINANCE_ALPHA: |
| 993 | case GL_RGBA: |
| 994 | if (colorbufferFormat != GL_RGBA4 && |
| 995 | colorbufferFormat != GL_RGB5_A1 && |
| 996 | colorbufferFormat != GL_BGRA8_EXT && |
| 997 | colorbufferFormat != GL_RGBA8_OES) |
| 998 | { |
| 999 | return gl::error(GL_INVALID_OPERATION, false); |
| 1000 | } |
| 1001 | break; |
| 1002 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 1003 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 1004 | if (context->supportsDXT1Textures()) |
| 1005 | { |
| 1006 | return gl::error(GL_INVALID_OPERATION, false); |
| 1007 | } |
| 1008 | else |
| 1009 | { |
| 1010 | return gl::error(GL_INVALID_ENUM, false); |
| 1011 | } |
| 1012 | break; |
| 1013 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 1014 | if (context->supportsDXT3Textures()) |
| 1015 | { |
| 1016 | return gl::error(GL_INVALID_OPERATION, false); |
| 1017 | } |
| 1018 | else |
| 1019 | { |
| 1020 | return gl::error(GL_INVALID_ENUM, false); |
| 1021 | } |
| 1022 | break; |
| 1023 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 1024 | if (context->supportsDXT5Textures()) |
| 1025 | { |
| 1026 | return gl::error(GL_INVALID_OPERATION, false); |
| 1027 | } |
| 1028 | else |
| 1029 | { |
| 1030 | return gl::error(GL_INVALID_ENUM, false); |
| 1031 | } |
| 1032 | break; |
| 1033 | case GL_DEPTH_COMPONENT: |
| 1034 | case GL_DEPTH_COMPONENT16: |
| 1035 | case GL_DEPTH_COMPONENT32_OES: |
| 1036 | case GL_DEPTH_STENCIL_OES: |
| 1037 | case GL_DEPTH24_STENCIL8_OES: |
| 1038 | if (context->supportsDepthTextures()) |
| 1039 | { |
| 1040 | return gl::error(GL_INVALID_OPERATION, false); |
| 1041 | } |
| 1042 | else |
| 1043 | { |
| 1044 | return gl::error(GL_INVALID_ENUM, false); |
| 1045 | } |
| 1046 | default: |
| 1047 | return gl::error(GL_INVALID_ENUM, false); |
| 1048 | } |
| 1049 | } |
| 1050 | |
| 1051 | return true; |
| 1052 | } |
| 1053 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 1054 | bool validateES3CopyTexImageParameters(gl::Context *context, GLenum target, GLint level, GLenum internalformat, |
| 1055 | bool isSubImage, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, |
| 1056 | GLsizei width, GLsizei height, GLint border) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1057 | { |
| 1058 | if (level < 0 || xoffset < 0 || yoffset < 0 || zoffset < 0 || width < 0 || height < 0) |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 1059 | { |
| 1060 | return gl::error(GL_INVALID_VALUE, false); |
| 1061 | } |
| 1062 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1063 | if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height) |
| 1064 | { |
| 1065 | return gl::error(GL_INVALID_VALUE, false); |
| 1066 | } |
| 1067 | |
| 1068 | if (width == 0 || height == 0) |
| 1069 | { |
| 1070 | return false; |
| 1071 | } |
| 1072 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 1073 | if (border != 0) |
| 1074 | { |
| 1075 | return gl::error(GL_INVALID_VALUE, false); |
| 1076 | } |
| 1077 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1078 | if (level > context->getMaximumTextureLevel()) |
| 1079 | { |
| 1080 | return gl::error(GL_INVALID_VALUE, false); |
| 1081 | } |
| 1082 | |
| 1083 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 1084 | |
| 1085 | if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) |
| 1086 | { |
| 1087 | return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); |
| 1088 | } |
| 1089 | |
| 1090 | if (context->getReadFramebufferHandle() != 0 && framebuffer->getSamples() != 0) |
| 1091 | { |
| 1092 | return gl::error(GL_INVALID_OPERATION, false); |
| 1093 | } |
| 1094 | |
| 1095 | gl::Renderbuffer *source = framebuffer->getReadColorbuffer(); |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1096 | GLenum colorbufferInternalFormat = source->getInternalFormat(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1097 | gl::Texture *texture = NULL; |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1098 | GLenum textureInternalFormat = GL_NONE; |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1099 | bool textureCompressed = false; |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame] | 1100 | bool textureIsDepth = false; |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1101 | GLint textureLevelWidth = 0; |
| 1102 | GLint textureLevelHeight = 0; |
| 1103 | GLint textureLevelDepth = 0; |
| 1104 | switch (target) |
| 1105 | { |
| 1106 | case GL_TEXTURE_2D: |
| 1107 | { |
| 1108 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 1109 | if (texture2d) |
| 1110 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1111 | textureInternalFormat = texture2d->getInternalFormat(level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1112 | textureCompressed = texture2d->isCompressed(level); |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame] | 1113 | textureIsDepth = texture2d->isDepth(level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1114 | textureLevelWidth = texture2d->getWidth(level); |
| 1115 | textureLevelHeight = texture2d->getHeight(level); |
| 1116 | textureLevelDepth = 1; |
| 1117 | texture = texture2d; |
| 1118 | } |
| 1119 | } |
| 1120 | break; |
| 1121 | |
| 1122 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 1123 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 1124 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 1125 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 1126 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 1127 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 1128 | { |
| 1129 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 1130 | if (textureCube) |
| 1131 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1132 | textureInternalFormat = textureCube->getInternalFormat(target, level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1133 | textureCompressed = textureCube->isCompressed(target, level); |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame] | 1134 | textureIsDepth = false; |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1135 | textureLevelWidth = textureCube->getWidth(target, level); |
| 1136 | textureLevelHeight = textureCube->getHeight(target, level); |
| 1137 | textureLevelDepth = 1; |
| 1138 | texture = textureCube; |
| 1139 | } |
| 1140 | } |
| 1141 | break; |
| 1142 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1143 | case GL_TEXTURE_2D_ARRAY: |
| 1144 | { |
| 1145 | gl::Texture2DArray *texture2dArray = context->getTexture2DArray(); |
| 1146 | if (texture2dArray) |
| 1147 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1148 | textureInternalFormat = texture2dArray->getInternalFormat(level); |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1149 | textureCompressed = texture2dArray->isCompressed(level); |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame] | 1150 | textureIsDepth = texture2dArray->isDepth(level); |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 1151 | textureLevelWidth = texture2dArray->getWidth(level); |
| 1152 | textureLevelHeight = texture2dArray->getHeight(level); |
| 1153 | textureLevelDepth = texture2dArray->getDepth(level); |
| 1154 | texture = texture2dArray; |
| 1155 | } |
| 1156 | } |
| 1157 | break; |
| 1158 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1159 | case GL_TEXTURE_3D: |
| 1160 | { |
| 1161 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 1162 | if (texture3d) |
| 1163 | { |
shannonwoods@chromium.org | ffab47d | 2013-05-30 00:16:22 +0000 | [diff] [blame] | 1164 | textureInternalFormat = texture3d->getInternalFormat(level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1165 | textureCompressed = texture3d->isCompressed(level); |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame] | 1166 | textureIsDepth = texture3d->isDepth(level); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1167 | textureLevelWidth = texture3d->getWidth(level); |
| 1168 | textureLevelHeight = texture3d->getHeight(level); |
| 1169 | textureLevelDepth = texture3d->getDepth(level); |
| 1170 | texture = texture3d; |
| 1171 | } |
| 1172 | } |
| 1173 | break; |
| 1174 | |
| 1175 | default: |
| 1176 | return gl::error(GL_INVALID_ENUM, false); |
| 1177 | } |
| 1178 | |
| 1179 | if (!texture) |
| 1180 | { |
| 1181 | return gl::error(GL_INVALID_OPERATION, false); |
| 1182 | } |
| 1183 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 1184 | if (texture->isImmutable() && !isSubImage) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1185 | { |
| 1186 | return gl::error(GL_INVALID_OPERATION, false); |
| 1187 | } |
| 1188 | |
Geoff Lang | 0e7c2fd | 2013-06-12 16:43:52 -0400 | [diff] [blame] | 1189 | if (textureIsDepth) |
| 1190 | { |
| 1191 | return gl::error(GL_INVALID_OPERATION, false); |
| 1192 | } |
| 1193 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 1194 | if (textureCompressed) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1195 | { |
| 1196 | if ((width % 4 != 0 && width != textureLevelWidth) || |
| 1197 | (height % 4 != 0 && height != textureLevelHeight)) |
| 1198 | { |
| 1199 | return gl::error(GL_INVALID_OPERATION, false); |
| 1200 | } |
| 1201 | } |
| 1202 | |
Geoff Lang | a4d1332 | 2013-06-05 14:57:51 -0400 | [diff] [blame] | 1203 | if (isSubImage) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1204 | { |
Geoff Lang | a4d1332 | 2013-06-05 14:57:51 -0400 | [diff] [blame] | 1205 | if (xoffset + width > textureLevelWidth || |
| 1206 | yoffset + height > textureLevelHeight || |
| 1207 | zoffset >= textureLevelDepth) |
| 1208 | { |
| 1209 | return gl::error(GL_INVALID_VALUE, false); |
| 1210 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1211 | |
Geoff Lang | a4d1332 | 2013-06-05 14:57:51 -0400 | [diff] [blame] | 1212 | if (!gl::IsValidCopyTexImageCombination(textureInternalFormat, colorbufferInternalFormat, |
| 1213 | context->getClientVersion())) |
| 1214 | { |
| 1215 | return gl::error(GL_INVALID_OPERATION, false); |
| 1216 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 1217 | } |
| 1218 | |
shannon.woods%transgaming.com@gtempaccount.com | 6d73c4e | 2013-04-13 03:45:12 +0000 | [diff] [blame] | 1219 | return true; |
| 1220 | } |
| 1221 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 1222 | bool validateES2TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat, |
| 1223 | GLsizei width, GLsizei height) |
| 1224 | { |
| 1225 | if (target != GL_TEXTURE_2D && target != GL_TEXTURE_CUBE_MAP) |
| 1226 | { |
| 1227 | return gl::error(GL_INVALID_ENUM, false); |
| 1228 | } |
| 1229 | |
| 1230 | if (width < 1 || height < 1 || levels < 1) |
| 1231 | { |
| 1232 | return gl::error(GL_INVALID_VALUE, false); |
| 1233 | } |
| 1234 | |
| 1235 | if (target == GL_TEXTURE_CUBE_MAP && width != height) |
| 1236 | { |
| 1237 | return gl::error(GL_INVALID_VALUE, false); |
| 1238 | } |
| 1239 | |
| 1240 | if (levels != 1 && levels != gl::log2(std::max(width, height)) + 1) |
| 1241 | { |
| 1242 | return gl::error(GL_INVALID_OPERATION, false); |
| 1243 | } |
| 1244 | |
| 1245 | GLenum format = gl::GetFormat(internalformat, context->getClientVersion()); |
| 1246 | GLenum type = gl::GetType(internalformat, context->getClientVersion()); |
| 1247 | |
| 1248 | if (format == GL_NONE || type == GL_NONE) |
| 1249 | { |
| 1250 | return gl::error(GL_INVALID_ENUM, false); |
| 1251 | } |
| 1252 | |
| 1253 | switch (target) |
| 1254 | { |
| 1255 | case GL_TEXTURE_2D: |
| 1256 | if (width > context->getMaximum2DTextureDimension() || |
| 1257 | height > context->getMaximum2DTextureDimension()) |
| 1258 | { |
| 1259 | return gl::error(GL_INVALID_VALUE, false); |
| 1260 | } |
| 1261 | break; |
| 1262 | case GL_TEXTURE_CUBE_MAP: |
| 1263 | if (width > context->getMaximumCubeTextureDimension() || |
| 1264 | height > context->getMaximumCubeTextureDimension()) |
| 1265 | { |
| 1266 | return gl::error(GL_INVALID_VALUE, false); |
| 1267 | } |
| 1268 | break; |
| 1269 | default: |
| 1270 | return gl::error(GL_INVALID_ENUM, false); |
| 1271 | } |
| 1272 | |
| 1273 | if (levels != 1 && !context->supportsNonPower2Texture()) |
| 1274 | { |
| 1275 | if (!gl::isPow2(width) || !gl::isPow2(height)) |
| 1276 | { |
| 1277 | return gl::error(GL_INVALID_OPERATION, false); |
| 1278 | } |
| 1279 | } |
| 1280 | |
| 1281 | switch (internalformat) |
| 1282 | { |
| 1283 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
| 1284 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 1285 | if (!context->supportsDXT1Textures()) |
| 1286 | { |
| 1287 | return gl::error(GL_INVALID_ENUM, false); |
| 1288 | } |
| 1289 | break; |
| 1290 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: |
| 1291 | if (!context->supportsDXT3Textures()) |
| 1292 | { |
| 1293 | return gl::error(GL_INVALID_ENUM, false); |
| 1294 | } |
| 1295 | break; |
| 1296 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: |
| 1297 | if (!context->supportsDXT5Textures()) |
| 1298 | { |
| 1299 | return gl::error(GL_INVALID_ENUM, false); |
| 1300 | } |
| 1301 | break; |
| 1302 | case GL_RGBA32F_EXT: |
| 1303 | case GL_RGB32F_EXT: |
| 1304 | case GL_ALPHA32F_EXT: |
| 1305 | case GL_LUMINANCE32F_EXT: |
| 1306 | case GL_LUMINANCE_ALPHA32F_EXT: |
| 1307 | if (!context->supportsFloat32Textures()) |
| 1308 | { |
| 1309 | return gl::error(GL_INVALID_ENUM, false); |
| 1310 | } |
| 1311 | break; |
| 1312 | case GL_RGBA16F_EXT: |
| 1313 | case GL_RGB16F_EXT: |
| 1314 | case GL_ALPHA16F_EXT: |
| 1315 | case GL_LUMINANCE16F_EXT: |
| 1316 | case GL_LUMINANCE_ALPHA16F_EXT: |
| 1317 | if (!context->supportsFloat16Textures()) |
| 1318 | { |
| 1319 | return gl::error(GL_INVALID_ENUM, false); |
| 1320 | } |
| 1321 | break; |
| 1322 | case GL_DEPTH_COMPONENT16: |
| 1323 | case GL_DEPTH_COMPONENT32_OES: |
| 1324 | case GL_DEPTH24_STENCIL8_OES: |
| 1325 | if (!context->supportsDepthTextures()) |
| 1326 | { |
| 1327 | return gl::error(GL_INVALID_ENUM, false); |
| 1328 | } |
| 1329 | if (target != GL_TEXTURE_2D) |
| 1330 | { |
| 1331 | return gl::error(GL_INVALID_OPERATION, false); |
| 1332 | } |
| 1333 | // ANGLE_depth_texture only supports 1-level textures |
| 1334 | if (levels != 1) |
| 1335 | { |
| 1336 | return gl::error(GL_INVALID_OPERATION, false); |
| 1337 | } |
| 1338 | break; |
| 1339 | default: |
| 1340 | break; |
| 1341 | } |
| 1342 | |
| 1343 | gl::Texture *texture = NULL; |
| 1344 | switch(target) |
| 1345 | { |
| 1346 | case GL_TEXTURE_2D: |
| 1347 | texture = context->getTexture2D(); |
| 1348 | break; |
| 1349 | case GL_TEXTURE_CUBE_MAP: |
| 1350 | texture = context->getTextureCubeMap(); |
| 1351 | break; |
| 1352 | default: |
| 1353 | UNREACHABLE(); |
| 1354 | } |
| 1355 | |
| 1356 | if (!texture || texture->id() == 0) |
| 1357 | { |
| 1358 | return gl::error(GL_INVALID_OPERATION, false); |
| 1359 | } |
| 1360 | |
| 1361 | if (texture->isImmutable()) |
| 1362 | { |
| 1363 | return gl::error(GL_INVALID_OPERATION, false); |
| 1364 | } |
| 1365 | |
| 1366 | return true; |
| 1367 | } |
| 1368 | |
| 1369 | bool validateES3TexStorageParameters(gl::Context *context, GLenum target, GLsizei levels, GLenum internalformat, |
| 1370 | GLsizei width, GLsizei height, GLsizei depth) |
| 1371 | { |
| 1372 | if (width < 1 || height < 1 || depth < 1 || levels < 1) |
| 1373 | { |
| 1374 | return gl::error(GL_INVALID_VALUE, false); |
| 1375 | } |
| 1376 | |
| 1377 | if (levels > gl::log2(std::max(std::max(width, height), depth)) + 1) |
| 1378 | { |
| 1379 | return gl::error(GL_INVALID_OPERATION, false); |
| 1380 | } |
| 1381 | |
| 1382 | gl::Texture *texture = NULL; |
| 1383 | switch (target) |
| 1384 | { |
| 1385 | case GL_TEXTURE_2D: |
| 1386 | { |
| 1387 | texture = context->getTexture2D(); |
| 1388 | |
| 1389 | if (width > (context->getMaximum2DTextureDimension()) || |
| 1390 | height > (context->getMaximum2DTextureDimension())) |
| 1391 | { |
| 1392 | return gl::error(GL_INVALID_VALUE, false); |
| 1393 | } |
| 1394 | } |
| 1395 | break; |
| 1396 | |
| 1397 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 1398 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 1399 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 1400 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 1401 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 1402 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 1403 | { |
| 1404 | texture = context->getTextureCubeMap(); |
| 1405 | |
| 1406 | if (width != height) |
| 1407 | { |
| 1408 | return gl::error(GL_INVALID_VALUE, false); |
| 1409 | } |
| 1410 | |
| 1411 | if (width > (context->getMaximumCubeTextureDimension())) |
| 1412 | { |
| 1413 | return gl::error(GL_INVALID_VALUE, false); |
| 1414 | } |
| 1415 | } |
| 1416 | break; |
| 1417 | |
| 1418 | case GL_TEXTURE_3D: |
| 1419 | { |
| 1420 | texture = context->getTexture3D(); |
| 1421 | |
| 1422 | if (width > (context->getMaximum3DTextureDimension()) || |
| 1423 | height > (context->getMaximum3DTextureDimension()) || |
| 1424 | depth > (context->getMaximum3DTextureDimension())) |
| 1425 | { |
| 1426 | return gl::error(GL_INVALID_VALUE, false); |
| 1427 | } |
| 1428 | } |
| 1429 | break; |
| 1430 | |
| 1431 | case GL_TEXTURE_2D_ARRAY: |
| 1432 | { |
| 1433 | texture = context->getTexture2DArray(); |
| 1434 | |
| 1435 | if (width > (context->getMaximum2DTextureDimension()) || |
| 1436 | height > (context->getMaximum2DTextureDimension()) || |
| 1437 | depth > (context->getMaximum2DArrayTextureLayers())) |
| 1438 | { |
| 1439 | return gl::error(GL_INVALID_VALUE, false); |
| 1440 | } |
| 1441 | } |
| 1442 | break; |
| 1443 | |
| 1444 | default: |
| 1445 | return gl::error(GL_INVALID_ENUM, false); |
| 1446 | } |
| 1447 | |
| 1448 | if (!texture || texture->id() == 0) |
| 1449 | { |
| 1450 | return gl::error(GL_INVALID_OPERATION, false); |
| 1451 | } |
| 1452 | |
| 1453 | if (texture->isImmutable()) |
| 1454 | { |
| 1455 | return gl::error(GL_INVALID_OPERATION, false); |
| 1456 | } |
| 1457 | |
| 1458 | if (!gl::IsValidInternalFormat(internalformat, context)) |
| 1459 | { |
| 1460 | return gl::error(GL_INVALID_ENUM, false); |
| 1461 | } |
| 1462 | |
| 1463 | if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion())) |
| 1464 | { |
| 1465 | return gl::error(GL_INVALID_ENUM, false); |
| 1466 | } |
| 1467 | |
| 1468 | return true; |
| 1469 | } |
| 1470 | |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 1471 | bool validateRenderbufferStorageParameters(const gl::Context *context, GLenum target, GLsizei samples, |
| 1472 | GLenum internalformat, GLsizei width, GLsizei height, |
| 1473 | bool angleExtension) |
| 1474 | { |
| 1475 | switch (target) |
| 1476 | { |
| 1477 | case GL_RENDERBUFFER: |
| 1478 | break; |
| 1479 | default: |
| 1480 | return gl::error(GL_INVALID_ENUM, false); |
| 1481 | } |
| 1482 | |
| 1483 | if (width < 0 || height < 0 || samples < 0) |
| 1484 | { |
| 1485 | return gl::error(GL_INVALID_VALUE, false); |
| 1486 | } |
| 1487 | |
| 1488 | if (!gl::IsValidInternalFormat(internalformat, context)) |
| 1489 | { |
| 1490 | return gl::error(GL_INVALID_ENUM, false); |
| 1491 | } |
| 1492 | |
| 1493 | // ANGLE_framebuffer_multisample does not explicitly state that the internal format must be |
| 1494 | // sized but it does state that the format must be in the ES2.0 spec table 4.5 which contains |
| 1495 | // only sized internal formats. The ES3 spec (section 4.4.2) does, however, state that the |
| 1496 | // internal format must be sized and not an integer format if samples is greater than zero. |
| 1497 | if (!gl::IsSizedInternalFormat(internalformat, context->getClientVersion())) |
| 1498 | { |
| 1499 | return gl::error(GL_INVALID_ENUM, false); |
| 1500 | } |
| 1501 | |
| 1502 | if (gl::IsIntegerFormat(internalformat, context->getClientVersion()) && samples > 0) |
| 1503 | { |
| 1504 | return gl::error(GL_INVALID_OPERATION, false); |
| 1505 | } |
| 1506 | |
| 1507 | if (!gl::IsColorRenderingSupported(internalformat, context) && |
| 1508 | !gl::IsDepthRenderingSupported(internalformat, context) && |
| 1509 | !gl::IsStencilRenderingSupported(internalformat, context)) |
| 1510 | { |
| 1511 | return gl::error(GL_INVALID_ENUM, false); |
| 1512 | } |
| 1513 | |
| 1514 | if (std::max(width, height) > context->getMaximumRenderbufferDimension()) |
| 1515 | { |
| 1516 | return gl::error(GL_INVALID_VALUE, false); |
| 1517 | } |
| 1518 | |
| 1519 | // ANGLE_framebuffer_multisample states that the value of samples must be less than or equal |
| 1520 | // to MAX_SAMPLES_ANGLE (Context::getMaxSupportedSamples) while the ES3.0 spec (section 4.4.2) |
| 1521 | // states that samples must be less than or equal to the maximum samples for the specified |
| 1522 | // internal format. |
| 1523 | if (angleExtension) |
| 1524 | { |
| 1525 | if (samples > context->getMaxSupportedSamples()) |
| 1526 | { |
| 1527 | return gl::error(GL_INVALID_VALUE, false); |
| 1528 | } |
| 1529 | } |
| 1530 | else |
| 1531 | { |
| 1532 | if (samples > context->getMaxSupportedFormatSamples(internalformat)) |
| 1533 | { |
| 1534 | return gl::error(GL_INVALID_VALUE, false); |
| 1535 | } |
| 1536 | } |
| 1537 | |
| 1538 | GLuint handle = context->getRenderbufferHandle(); |
| 1539 | if (handle == 0) |
| 1540 | { |
| 1541 | return gl::error(GL_INVALID_OPERATION, false); |
| 1542 | } |
| 1543 | |
| 1544 | return true; |
| 1545 | } |
| 1546 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1547 | // check for combinations of format and type that are valid for ReadPixels |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 1548 | bool validES2ReadFormatType(GLenum format, GLenum type) |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1549 | { |
| 1550 | switch (format) |
| 1551 | { |
| 1552 | case GL_RGBA: |
| 1553 | switch (type) |
| 1554 | { |
| 1555 | case GL_UNSIGNED_BYTE: |
| 1556 | break; |
| 1557 | default: |
| 1558 | return false; |
| 1559 | } |
| 1560 | break; |
| 1561 | case GL_BGRA_EXT: |
| 1562 | switch (type) |
| 1563 | { |
| 1564 | case GL_UNSIGNED_BYTE: |
| 1565 | case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: |
| 1566 | case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: |
| 1567 | break; |
| 1568 | default: |
| 1569 | return false; |
| 1570 | } |
| 1571 | break; |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 1572 | default: |
| 1573 | return false; |
| 1574 | } |
| 1575 | return true; |
| 1576 | } |
| 1577 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 1578 | bool validES3ReadFormatType(GLenum internalFormat, GLenum format, GLenum type) |
| 1579 | { |
| 1580 | switch (format) |
| 1581 | { |
| 1582 | case GL_RGBA: |
| 1583 | switch (type) |
| 1584 | { |
| 1585 | case GL_UNSIGNED_BYTE: |
| 1586 | break; |
| 1587 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 1588 | if (internalFormat != GL_RGB10_A2) |
| 1589 | { |
| 1590 | return false; |
| 1591 | } |
| 1592 | break; |
| 1593 | default: |
| 1594 | return false; |
| 1595 | } |
| 1596 | break; |
| 1597 | case GL_RGBA_INTEGER: |
| 1598 | switch (type) |
| 1599 | { |
| 1600 | case GL_INT: |
Geoff Lang | d384a94 | 2013-06-05 15:00:10 -0400 | [diff] [blame] | 1601 | if (!gl::IsSignedIntegerFormat(internalFormat, 3)) |
| 1602 | { |
| 1603 | return false; |
| 1604 | } |
| 1605 | break; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 1606 | case GL_UNSIGNED_INT: |
Geoff Lang | d384a94 | 2013-06-05 15:00:10 -0400 | [diff] [blame] | 1607 | if (!gl::IsUnsignedIntegerFormat(internalFormat, 3)) |
| 1608 | { |
| 1609 | return false; |
| 1610 | } |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 1611 | break; |
| 1612 | default: |
| 1613 | return false; |
| 1614 | } |
| 1615 | break; |
| 1616 | case GL_BGRA_EXT: |
| 1617 | switch (type) |
| 1618 | { |
| 1619 | case GL_UNSIGNED_BYTE: |
| 1620 | case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: |
| 1621 | case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: |
| 1622 | break; |
| 1623 | default: |
| 1624 | return false; |
| 1625 | } |
| 1626 | break; |
| 1627 | default: |
| 1628 | return false; |
| 1629 | } |
| 1630 | return true; |
| 1631 | } |
| 1632 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 1633 | bool validateInvalidateFramebufferParameters(gl::Context *context, GLenum target, GLsizei numAttachments, |
| 1634 | const GLenum* attachments) |
| 1635 | { |
| 1636 | bool defaultFramebuffer = false; |
| 1637 | |
| 1638 | switch (target) |
| 1639 | { |
| 1640 | case GL_DRAW_FRAMEBUFFER: |
| 1641 | case GL_FRAMEBUFFER: |
| 1642 | defaultFramebuffer = context->getDrawFramebufferHandle() == 0; |
| 1643 | break; |
| 1644 | case GL_READ_FRAMEBUFFER: |
| 1645 | defaultFramebuffer = context->getReadFramebufferHandle() == 0; |
| 1646 | break; |
| 1647 | default: |
| 1648 | return gl::error(GL_INVALID_ENUM, false); |
| 1649 | } |
| 1650 | |
| 1651 | for (int i = 0; i < numAttachments; ++i) |
| 1652 | { |
| 1653 | if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15) |
| 1654 | { |
| 1655 | if (defaultFramebuffer) |
| 1656 | { |
| 1657 | return gl::error(GL_INVALID_ENUM, false); |
| 1658 | } |
| 1659 | |
| 1660 | if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getMaximumRenderTargets()) |
| 1661 | { |
| 1662 | return gl::error(GL_INVALID_OPERATION, false); |
| 1663 | } |
| 1664 | } |
| 1665 | else |
| 1666 | { |
| 1667 | switch (attachments[i]) |
| 1668 | { |
| 1669 | case GL_DEPTH_ATTACHMENT: |
| 1670 | case GL_STENCIL_ATTACHMENT: |
| 1671 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 1672 | if (defaultFramebuffer) |
| 1673 | { |
| 1674 | return gl::error(GL_INVALID_ENUM, false); |
| 1675 | } |
| 1676 | break; |
| 1677 | case GL_COLOR: |
| 1678 | case GL_DEPTH: |
| 1679 | case GL_STENCIL: |
| 1680 | if (!defaultFramebuffer) |
| 1681 | { |
| 1682 | return gl::error(GL_INVALID_ENUM, false); |
| 1683 | } |
| 1684 | break; |
| 1685 | default: |
| 1686 | return gl::error(GL_INVALID_ENUM, false); |
| 1687 | } |
| 1688 | } |
| 1689 | } |
| 1690 | |
| 1691 | return true; |
| 1692 | } |
| 1693 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 1694 | bool validateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, |
| 1695 | GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, |
| 1696 | GLenum filter, bool fromAngleExtension) |
| 1697 | { |
| 1698 | switch (filter) |
| 1699 | { |
| 1700 | case GL_NEAREST: |
| 1701 | break; |
| 1702 | case GL_LINEAR: |
| 1703 | if (fromAngleExtension) |
| 1704 | { |
| 1705 | return gl::error(GL_INVALID_ENUM, false); |
| 1706 | } |
| 1707 | break; |
| 1708 | default: |
| 1709 | return gl::error(GL_INVALID_ENUM, false); |
| 1710 | } |
| 1711 | |
| 1712 | if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0) |
| 1713 | { |
| 1714 | return gl::error(GL_INVALID_VALUE, false); |
| 1715 | } |
| 1716 | |
| 1717 | if (mask == 0) |
| 1718 | { |
| 1719 | // ES3.0 spec, section 4.3.2 specifies that a mask of zero is valid and no |
| 1720 | // buffers are copied. |
| 1721 | return false; |
| 1722 | } |
| 1723 | |
| 1724 | if (fromAngleExtension && (srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0)) |
| 1725 | { |
| 1726 | ERR("Scaling and flipping in BlitFramebufferANGLE not supported by this implementation."); |
| 1727 | return gl::error(GL_INVALID_OPERATION, false); |
| 1728 | } |
| 1729 | |
| 1730 | // ES3.0 spec, section 4.3.2 states that linear filtering is only available for the |
| 1731 | // color buffer, leaving only nearest being unfiltered from above |
| 1732 | if ((mask & ~GL_COLOR_BUFFER_BIT) != 0 && filter != GL_NEAREST) |
| 1733 | { |
| 1734 | return gl::error(GL_INVALID_OPERATION, false); |
| 1735 | } |
| 1736 | |
| 1737 | if (context->getReadFramebufferHandle() == context->getDrawFramebufferHandle()) |
| 1738 | { |
| 1739 | if (fromAngleExtension) |
| 1740 | { |
| 1741 | ERR("Blits with the same source and destination framebuffer are not supported by this " |
| 1742 | "implementation."); |
| 1743 | } |
| 1744 | return gl::error(GL_INVALID_OPERATION, false); |
| 1745 | } |
| 1746 | |
| 1747 | gl::Framebuffer *readFramebuffer = context->getReadFramebuffer(); |
| 1748 | gl::Framebuffer *drawFramebuffer = context->getDrawFramebuffer(); |
| 1749 | if (!readFramebuffer || readFramebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE || |
| 1750 | !drawFramebuffer || drawFramebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE) |
| 1751 | { |
| 1752 | return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION, false); |
| 1753 | } |
| 1754 | |
| 1755 | if (drawFramebuffer->getSamples() != 0) |
| 1756 | { |
| 1757 | return gl::error(GL_INVALID_OPERATION, false); |
| 1758 | } |
| 1759 | |
| 1760 | gl::Rectangle sourceClippedRect, destClippedRect; |
| 1761 | bool partialCopy; |
| 1762 | if (!context->clipBlitFramebufferCoordinates(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 1763 | &sourceClippedRect, &destClippedRect, &partialCopy)) |
| 1764 | { |
| 1765 | return gl::error(GL_INVALID_OPERATION, false); |
| 1766 | } |
| 1767 | |
| 1768 | bool sameBounds = srcX0 == dstX0 && srcY0 == dstY0 && srcX1 == dstX1 && srcY1 == dstY1; |
| 1769 | |
| 1770 | GLuint clientVersion = context->getClientVersion(); |
| 1771 | |
| 1772 | if (mask & GL_COLOR_BUFFER_BIT) |
| 1773 | { |
| 1774 | gl::Renderbuffer *readColorBuffer = readFramebuffer->getReadColorbuffer(); |
| 1775 | gl::Renderbuffer *drawColorBuffer = drawFramebuffer->getFirstColorbuffer(); |
| 1776 | |
| 1777 | if (readColorBuffer && drawColorBuffer) |
| 1778 | { |
| 1779 | GLint readInternalFormat = readColorBuffer->getActualFormat(); |
| 1780 | GLint drawInternalFormat = drawColorBuffer->getActualFormat(); |
| 1781 | |
| 1782 | for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; i++) |
| 1783 | { |
| 1784 | if (drawFramebuffer->isEnabledColorAttachment(i)) |
| 1785 | { |
| 1786 | GLint drawbufferAttachmentFormat = drawFramebuffer->getColorbuffer(i)->getActualFormat(); |
| 1787 | |
| 1788 | if (gl::IsNormalizedFixedPointFormat(readInternalFormat, clientVersion) && |
| 1789 | !gl::IsNormalizedFixedPointFormat(drawbufferAttachmentFormat, clientVersion)) |
| 1790 | { |
| 1791 | return gl::error(GL_INVALID_OPERATION, false); |
| 1792 | } |
| 1793 | |
| 1794 | if (gl::IsUnsignedIntegerFormat(readInternalFormat, clientVersion) && |
| 1795 | !gl::IsUnsignedIntegerFormat(drawbufferAttachmentFormat, clientVersion)) |
| 1796 | { |
| 1797 | return gl::error(GL_INVALID_OPERATION, false); |
| 1798 | } |
| 1799 | |
| 1800 | if (gl::IsSignedIntegerFormat(readInternalFormat, clientVersion) && |
| 1801 | !gl::IsSignedIntegerFormat(drawbufferAttachmentFormat, clientVersion)) |
| 1802 | { |
| 1803 | return gl::error(GL_INVALID_OPERATION, false); |
| 1804 | } |
| 1805 | |
| 1806 | if (readColorBuffer->getSamples() > 0 && (readInternalFormat != drawbufferAttachmentFormat || !sameBounds)) |
| 1807 | { |
| 1808 | return gl::error(GL_INVALID_OPERATION, false); |
| 1809 | } |
| 1810 | } |
| 1811 | } |
| 1812 | |
| 1813 | if (gl::IsIntegerFormat(readInternalFormat, clientVersion) && filter == GL_LINEAR) |
| 1814 | { |
| 1815 | return gl::error(GL_INVALID_OPERATION, false); |
| 1816 | } |
| 1817 | |
| 1818 | if (fromAngleExtension) |
| 1819 | { |
| 1820 | const GLenum readColorbufferType = readFramebuffer->getReadColorbufferType(); |
| 1821 | if (readColorbufferType != GL_TEXTURE_2D && readColorbufferType != GL_RENDERBUFFER) |
| 1822 | { |
| 1823 | return gl::error(GL_INVALID_OPERATION, false); |
| 1824 | } |
| 1825 | |
| 1826 | for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) |
| 1827 | { |
| 1828 | if (drawFramebuffer->isEnabledColorAttachment(colorAttachment)) |
| 1829 | { |
| 1830 | if (drawFramebuffer->getColorbufferType(colorAttachment) != GL_TEXTURE_2D && |
| 1831 | drawFramebuffer->getColorbufferType(colorAttachment) != GL_RENDERBUFFER) |
| 1832 | { |
| 1833 | return gl::error(GL_INVALID_OPERATION, false); |
| 1834 | } |
| 1835 | |
| 1836 | if (drawFramebuffer->getColorbuffer(colorAttachment)->getActualFormat() != readColorBuffer->getActualFormat()) |
| 1837 | { |
| 1838 | return gl::error(GL_INVALID_OPERATION, false); |
| 1839 | } |
| 1840 | } |
| 1841 | } |
| 1842 | |
| 1843 | if (partialCopy && readFramebuffer->getSamples() != 0) |
| 1844 | { |
| 1845 | return gl::error(GL_INVALID_OPERATION, false); |
| 1846 | } |
| 1847 | } |
| 1848 | } |
| 1849 | } |
| 1850 | |
| 1851 | if (mask & GL_DEPTH_BUFFER_BIT) |
| 1852 | { |
| 1853 | gl::Renderbuffer *readDepthBuffer = readFramebuffer->getDepthbuffer(); |
| 1854 | gl::Renderbuffer *drawDepthBuffer = drawFramebuffer->getDepthbuffer(); |
| 1855 | |
| 1856 | if (readDepthBuffer && drawDepthBuffer) |
| 1857 | { |
| 1858 | if (readDepthBuffer->getActualFormat() != drawDepthBuffer->getActualFormat()) |
| 1859 | { |
| 1860 | return gl::error(GL_INVALID_OPERATION, false); |
| 1861 | } |
| 1862 | |
| 1863 | if (readDepthBuffer->getSamples() > 0 && !sameBounds) |
| 1864 | { |
| 1865 | return gl::error(GL_INVALID_OPERATION, false); |
| 1866 | } |
| 1867 | |
| 1868 | if (fromAngleExtension) |
| 1869 | { |
| 1870 | if (partialCopy) |
| 1871 | { |
| 1872 | ERR("Only whole-buffer depth and stencil blits are supported by this implementation."); |
| 1873 | return gl::error(GL_INVALID_OPERATION, false); // only whole-buffer copies are permitted |
| 1874 | } |
| 1875 | |
| 1876 | if (readDepthBuffer->getSamples() != 0 || drawDepthBuffer->getSamples() != 0) |
| 1877 | { |
| 1878 | return gl::error(GL_INVALID_OPERATION, false); |
| 1879 | } |
| 1880 | } |
| 1881 | } |
| 1882 | } |
| 1883 | |
| 1884 | if (mask & GL_STENCIL_BUFFER_BIT) |
| 1885 | { |
| 1886 | gl::Renderbuffer *readStencilBuffer = readFramebuffer->getStencilbuffer(); |
| 1887 | gl::Renderbuffer *drawStencilBuffer = drawFramebuffer->getStencilbuffer(); |
| 1888 | |
| 1889 | if (fromAngleExtension && partialCopy) |
| 1890 | { |
| 1891 | ERR("Only whole-buffer depth and stencil blits are supported by this implementation."); |
| 1892 | return gl::error(GL_INVALID_OPERATION, false); // only whole-buffer copies are permitted |
| 1893 | } |
| 1894 | |
| 1895 | if (readStencilBuffer && drawStencilBuffer) |
| 1896 | { |
| 1897 | if (readStencilBuffer->getActualFormat() != drawStencilBuffer->getActualFormat()) |
| 1898 | { |
| 1899 | return gl::error(GL_INVALID_OPERATION, false); |
| 1900 | } |
| 1901 | |
| 1902 | if (readStencilBuffer->getSamples() > 0 && !sameBounds) |
| 1903 | { |
| 1904 | return gl::error(GL_INVALID_OPERATION, false); |
| 1905 | } |
| 1906 | |
| 1907 | if (fromAngleExtension) |
| 1908 | { |
| 1909 | if (partialCopy) |
| 1910 | { |
| 1911 | ERR("Only whole-buffer depth and stencil blits are supported by this implementation."); |
| 1912 | return gl::error(GL_INVALID_OPERATION, false); // only whole-buffer copies are permitted |
| 1913 | } |
| 1914 | |
| 1915 | if (readStencilBuffer->getSamples() != 0 || drawStencilBuffer->getSamples() != 0) |
| 1916 | { |
| 1917 | return gl::error(GL_INVALID_OPERATION, false); |
| 1918 | } |
| 1919 | } |
| 1920 | } |
| 1921 | } |
| 1922 | |
| 1923 | return true; |
| 1924 | } |
| 1925 | |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 1926 | bool validateGetVertexAttribParameters(GLenum pname, int clientVersion) |
| 1927 | { |
| 1928 | switch (pname) |
| 1929 | { |
| 1930 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
| 1931 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
| 1932 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
| 1933 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
| 1934 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
| 1935 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
| 1936 | case GL_CURRENT_VERTEX_ATTRIB: |
| 1937 | return true; |
| 1938 | |
| 1939 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 1940 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 1941 | // the same constant. |
| 1942 | META_ASSERT(GL_VERTEX_ATTRIB_ARRAY_DIVISOR == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE); |
| 1943 | return true; |
| 1944 | |
Jamie Madill | 30855b3 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 1945 | case GL_VERTEX_ATTRIB_ARRAY_INTEGER: |
| 1946 | return ((clientVersion >= 3) ? true : gl::error(GL_INVALID_ENUM, false)); |
| 1947 | |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 1948 | default: |
| 1949 | return gl::error(GL_INVALID_ENUM, false); |
| 1950 | } |
| 1951 | } |
| 1952 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 1953 | bool validateTexParamParameters(gl::Context *context, GLenum pname, GLint param) |
| 1954 | { |
| 1955 | switch (pname) |
| 1956 | { |
| 1957 | case GL_TEXTURE_WRAP_R: |
| 1958 | case GL_TEXTURE_SWIZZLE_R: |
| 1959 | case GL_TEXTURE_SWIZZLE_G: |
| 1960 | case GL_TEXTURE_SWIZZLE_B: |
| 1961 | case GL_TEXTURE_SWIZZLE_A: |
| 1962 | case GL_TEXTURE_BASE_LEVEL: |
| 1963 | case GL_TEXTURE_MAX_LEVEL: |
| 1964 | case GL_TEXTURE_COMPARE_MODE: |
| 1965 | case GL_TEXTURE_COMPARE_FUNC: |
| 1966 | case GL_TEXTURE_MIN_LOD: |
| 1967 | case GL_TEXTURE_MAX_LOD: |
| 1968 | if (context->getClientVersion() < 3) |
| 1969 | { |
| 1970 | return gl::error(GL_INVALID_ENUM, false); |
| 1971 | } |
| 1972 | break; |
| 1973 | |
| 1974 | default: break; |
| 1975 | } |
| 1976 | |
| 1977 | switch (pname) |
| 1978 | { |
| 1979 | case GL_TEXTURE_WRAP_S: |
| 1980 | case GL_TEXTURE_WRAP_T: |
| 1981 | case GL_TEXTURE_WRAP_R: |
| 1982 | switch (param) |
| 1983 | { |
| 1984 | case GL_REPEAT: |
| 1985 | case GL_CLAMP_TO_EDGE: |
| 1986 | case GL_MIRRORED_REPEAT: |
| 1987 | return true; |
| 1988 | default: |
| 1989 | return gl::error(GL_INVALID_ENUM, false); |
| 1990 | } |
| 1991 | |
| 1992 | case GL_TEXTURE_MIN_FILTER: |
| 1993 | switch (param) |
| 1994 | { |
| 1995 | case GL_NEAREST: |
| 1996 | case GL_LINEAR: |
| 1997 | case GL_NEAREST_MIPMAP_NEAREST: |
| 1998 | case GL_LINEAR_MIPMAP_NEAREST: |
| 1999 | case GL_NEAREST_MIPMAP_LINEAR: |
| 2000 | case GL_LINEAR_MIPMAP_LINEAR: |
| 2001 | return true; |
| 2002 | default: |
| 2003 | return gl::error(GL_INVALID_ENUM, false); |
| 2004 | } |
| 2005 | break; |
| 2006 | |
| 2007 | case GL_TEXTURE_MAG_FILTER: |
| 2008 | switch (param) |
| 2009 | { |
| 2010 | case GL_NEAREST: |
| 2011 | case GL_LINEAR: |
| 2012 | return true; |
| 2013 | default: |
| 2014 | return gl::error(GL_INVALID_ENUM, false); |
| 2015 | } |
| 2016 | break; |
| 2017 | |
| 2018 | case GL_TEXTURE_USAGE_ANGLE: |
| 2019 | switch (param) |
| 2020 | { |
| 2021 | case GL_NONE: |
| 2022 | case GL_FRAMEBUFFER_ATTACHMENT_ANGLE: |
| 2023 | return true; |
| 2024 | default: |
| 2025 | return gl::error(GL_INVALID_ENUM, false); |
| 2026 | } |
| 2027 | break; |
| 2028 | |
| 2029 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 2030 | if (!context->supportsTextureFilterAnisotropy()) |
| 2031 | { |
| 2032 | return gl::error(GL_INVALID_ENUM, false); |
| 2033 | } |
| 2034 | |
| 2035 | // we assume the parameter passed to this validation method is truncated, not rounded |
| 2036 | if (param < 1) |
| 2037 | { |
| 2038 | return gl::error(GL_INVALID_VALUE, false); |
| 2039 | } |
| 2040 | return true; |
| 2041 | |
| 2042 | case GL_TEXTURE_MIN_LOD: |
| 2043 | case GL_TEXTURE_MAX_LOD: |
| 2044 | // any value is permissible |
| 2045 | return true; |
| 2046 | |
| 2047 | case GL_TEXTURE_COMPARE_MODE: |
| 2048 | switch (param) |
| 2049 | { |
| 2050 | case GL_NONE: |
| 2051 | case GL_COMPARE_REF_TO_TEXTURE: |
| 2052 | return true; |
| 2053 | default: |
| 2054 | return gl::error(GL_INVALID_ENUM, false); |
| 2055 | } |
| 2056 | break; |
| 2057 | |
| 2058 | case GL_TEXTURE_COMPARE_FUNC: |
| 2059 | switch (param) |
| 2060 | { |
| 2061 | case GL_LEQUAL: |
| 2062 | case GL_GEQUAL: |
| 2063 | case GL_LESS: |
| 2064 | case GL_GREATER: |
| 2065 | case GL_EQUAL: |
| 2066 | case GL_NOTEQUAL: |
| 2067 | case GL_ALWAYS: |
| 2068 | case GL_NEVER: |
| 2069 | return true; |
| 2070 | default: |
| 2071 | return gl::error(GL_INVALID_ENUM, false); |
| 2072 | } |
| 2073 | break; |
| 2074 | |
| 2075 | case GL_TEXTURE_SWIZZLE_R: |
| 2076 | case GL_TEXTURE_SWIZZLE_G: |
| 2077 | case GL_TEXTURE_SWIZZLE_B: |
| 2078 | case GL_TEXTURE_SWIZZLE_A: |
| 2079 | case GL_TEXTURE_BASE_LEVEL: |
| 2080 | case GL_TEXTURE_MAX_LEVEL: |
| 2081 | UNIMPLEMENTED(); |
| 2082 | return true; |
| 2083 | |
| 2084 | default: |
| 2085 | return gl::error(GL_INVALID_ENUM, false); |
| 2086 | } |
| 2087 | } |
| 2088 | |
| 2089 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 2090 | gl::Texture *getTargetTexture(gl::Context *context, GLenum target) |
| 2091 | { |
| 2092 | if (context->getClientVersion() < 3) |
| 2093 | { |
| 2094 | if (target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) |
| 2095 | { |
| 2096 | return NULL; |
| 2097 | } |
| 2098 | } |
| 2099 | |
| 2100 | switch (target) |
| 2101 | { |
| 2102 | case GL_TEXTURE_2D: return context->getTexture2D(); |
| 2103 | case GL_TEXTURE_CUBE_MAP: return context->getTextureCubeMap(); |
| 2104 | case GL_TEXTURE_3D: return context->getTexture3D(); |
| 2105 | case GL_TEXTURE_2D_ARRAY: return context->getTexture2DArray(); |
| 2106 | default: return NULL; |
| 2107 | } |
| 2108 | } |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2109 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 2110 | bool validateSamplerObjectParameter(GLenum pname) |
| 2111 | { |
| 2112 | switch (pname) |
| 2113 | { |
| 2114 | case GL_TEXTURE_MIN_FILTER: |
| 2115 | case GL_TEXTURE_MAG_FILTER: |
| 2116 | case GL_TEXTURE_WRAP_S: |
| 2117 | case GL_TEXTURE_WRAP_T: |
| 2118 | case GL_TEXTURE_WRAP_R: |
| 2119 | case GL_TEXTURE_MIN_LOD: |
| 2120 | case GL_TEXTURE_MAX_LOD: |
| 2121 | case GL_TEXTURE_COMPARE_MODE: |
| 2122 | case GL_TEXTURE_COMPARE_FUNC: |
| 2123 | return true; |
| 2124 | |
| 2125 | default: |
| 2126 | return gl::error(GL_INVALID_ENUM, false); |
| 2127 | } |
| 2128 | } |
| 2129 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2130 | extern "C" |
| 2131 | { |
| 2132 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2133 | // OpenGL ES 2.0 functions |
| 2134 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2135 | void __stdcall glActiveTexture(GLenum texture) |
| 2136 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2137 | EVENT("(GLenum texture = 0x%X)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2138 | |
| 2139 | try |
| 2140 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2141 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2142 | |
| 2143 | if (context) |
| 2144 | { |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 2145 | if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1) |
| 2146 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2147 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 2148 | } |
| 2149 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2150 | context->setActiveSampler(texture - GL_TEXTURE0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2151 | } |
| 2152 | } |
| 2153 | catch(std::bad_alloc&) |
| 2154 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2155 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2156 | } |
| 2157 | } |
| 2158 | |
| 2159 | void __stdcall glAttachShader(GLuint program, GLuint shader) |
| 2160 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2161 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2162 | |
| 2163 | try |
| 2164 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2165 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2166 | |
| 2167 | if (context) |
| 2168 | { |
| 2169 | gl::Program *programObject = context->getProgram(program); |
| 2170 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2171 | |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2172 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2173 | { |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2174 | if (context->getShader(program)) |
| 2175 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2176 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2177 | } |
| 2178 | else |
| 2179 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2180 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2181 | } |
| 2182 | } |
| 2183 | |
| 2184 | if (!shaderObject) |
| 2185 | { |
| 2186 | if (context->getProgram(shader)) |
| 2187 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2188 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2189 | } |
| 2190 | else |
| 2191 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2192 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 2193 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2194 | } |
| 2195 | |
| 2196 | if (!programObject->attachShader(shaderObject)) |
| 2197 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2198 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2199 | } |
| 2200 | } |
| 2201 | } |
| 2202 | catch(std::bad_alloc&) |
| 2203 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2204 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2205 | } |
| 2206 | } |
| 2207 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2208 | void __stdcall glBeginQueryEXT(GLenum target, GLuint id) |
| 2209 | { |
| 2210 | EVENT("(GLenum target = 0x%X, GLuint %d)", target, id); |
| 2211 | |
| 2212 | try |
| 2213 | { |
| 2214 | switch (target) |
| 2215 | { |
| 2216 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 2217 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 2218 | break; |
| 2219 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2220 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2221 | } |
| 2222 | |
| 2223 | if (id == 0) |
| 2224 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2225 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2226 | } |
| 2227 | |
| 2228 | gl::Context *context = gl::getNonLostContext(); |
| 2229 | |
| 2230 | if (context) |
| 2231 | { |
| 2232 | context->beginQuery(target, id); |
| 2233 | } |
| 2234 | } |
| 2235 | catch(std::bad_alloc&) |
| 2236 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2237 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2238 | } |
| 2239 | } |
| 2240 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2241 | void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2242 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2243 | EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2244 | |
| 2245 | try |
| 2246 | { |
| 2247 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 2248 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2249 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2250 | } |
| 2251 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2252 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2253 | |
| 2254 | if (context) |
| 2255 | { |
| 2256 | gl::Program *programObject = context->getProgram(program); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2257 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2258 | if (!programObject) |
| 2259 | { |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2260 | if (context->getShader(program)) |
| 2261 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2262 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2263 | } |
| 2264 | else |
| 2265 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2266 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2267 | } |
| 2268 | } |
| 2269 | |
| 2270 | if (strncmp(name, "gl_", 3) == 0) |
| 2271 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2272 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2273 | } |
| 2274 | |
| 2275 | programObject->bindAttributeLocation(index, name); |
| 2276 | } |
| 2277 | } |
| 2278 | catch(std::bad_alloc&) |
| 2279 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2280 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2281 | } |
| 2282 | } |
| 2283 | |
| 2284 | void __stdcall glBindBuffer(GLenum target, GLuint buffer) |
| 2285 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2286 | EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2287 | |
| 2288 | try |
| 2289 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2290 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2291 | |
| 2292 | if (context) |
| 2293 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2294 | // Check ES3 specific targets |
| 2295 | switch (target) |
| 2296 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2297 | case GL_COPY_READ_BUFFER: |
| 2298 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2299 | case GL_PIXEL_PACK_BUFFER: |
| 2300 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2301 | case GL_UNIFORM_BUFFER: |
| 2302 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2303 | if (context->getClientVersion() < 3) |
| 2304 | { |
| 2305 | return gl::error(GL_INVALID_ENUM); |
| 2306 | } |
| 2307 | } |
| 2308 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2309 | switch (target) |
| 2310 | { |
| 2311 | case GL_ARRAY_BUFFER: |
| 2312 | context->bindArrayBuffer(buffer); |
| 2313 | return; |
| 2314 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2315 | context->bindElementArrayBuffer(buffer); |
| 2316 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2317 | case GL_COPY_READ_BUFFER: |
| 2318 | context->bindCopyReadBuffer(buffer); |
| 2319 | return; |
| 2320 | case GL_COPY_WRITE_BUFFER: |
| 2321 | context->bindCopyWriteBuffer(buffer); |
| 2322 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2323 | case GL_PIXEL_PACK_BUFFER: |
| 2324 | context->bindPixelPackBuffer(buffer); |
| 2325 | return; |
| 2326 | case GL_PIXEL_UNPACK_BUFFER: |
| 2327 | context->bindPixelUnpackBuffer(buffer); |
| 2328 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2329 | case GL_UNIFORM_BUFFER: |
| 2330 | context->bindGenericUniformBuffer(buffer); |
| 2331 | return; |
| 2332 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 7a1ebad | 2013-05-30 00:05:20 +0000 | [diff] [blame] | 2333 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2334 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2335 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2336 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2337 | } |
| 2338 | } |
| 2339 | } |
| 2340 | catch(std::bad_alloc&) |
| 2341 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2342 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2343 | } |
| 2344 | } |
| 2345 | |
| 2346 | void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer) |
| 2347 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2348 | EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2349 | |
| 2350 | try |
| 2351 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2352 | if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2353 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2354 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2355 | } |
| 2356 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2357 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2358 | |
| 2359 | if (context) |
| 2360 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2361 | if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 2362 | { |
| 2363 | context->bindReadFramebuffer(framebuffer); |
| 2364 | } |
| 2365 | |
| 2366 | if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 2367 | { |
| 2368 | context->bindDrawFramebuffer(framebuffer); |
| 2369 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2370 | } |
| 2371 | } |
| 2372 | catch(std::bad_alloc&) |
| 2373 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2374 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2375 | } |
| 2376 | } |
| 2377 | |
| 2378 | void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 2379 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2380 | EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2381 | |
| 2382 | try |
| 2383 | { |
| 2384 | if (target != GL_RENDERBUFFER) |
| 2385 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2386 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2387 | } |
| 2388 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2389 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2390 | |
| 2391 | if (context) |
| 2392 | { |
| 2393 | context->bindRenderbuffer(renderbuffer); |
| 2394 | } |
| 2395 | } |
| 2396 | catch(std::bad_alloc&) |
| 2397 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2398 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2399 | } |
| 2400 | } |
| 2401 | |
| 2402 | void __stdcall glBindTexture(GLenum target, GLuint texture) |
| 2403 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2404 | EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2405 | |
| 2406 | try |
| 2407 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2408 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2409 | |
| 2410 | if (context) |
| 2411 | { |
| 2412 | gl::Texture *textureObject = context->getTexture(texture); |
| 2413 | |
| 2414 | if (textureObject && textureObject->getTarget() != target && texture != 0) |
| 2415 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2416 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2417 | } |
| 2418 | |
| 2419 | switch (target) |
| 2420 | { |
| 2421 | case GL_TEXTURE_2D: |
| 2422 | context->bindTexture2D(texture); |
| 2423 | return; |
| 2424 | case GL_TEXTURE_CUBE_MAP: |
| 2425 | context->bindTextureCubeMap(texture); |
| 2426 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 2427 | case GL_TEXTURE_3D: |
| 2428 | if (context->getClientVersion() < 3) |
| 2429 | { |
| 2430 | return gl::error(GL_INVALID_ENUM); |
| 2431 | } |
| 2432 | context->bindTexture3D(texture); |
| 2433 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 2434 | case GL_TEXTURE_2D_ARRAY: |
| 2435 | if (context->getClientVersion() < 3) |
| 2436 | { |
| 2437 | return gl::error(GL_INVALID_ENUM); |
| 2438 | } |
| 2439 | context->bindTexture2DArray(texture); |
| 2440 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2441 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2442 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2443 | } |
| 2444 | } |
| 2445 | } |
| 2446 | catch(std::bad_alloc&) |
| 2447 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2448 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2449 | } |
| 2450 | } |
| 2451 | |
| 2452 | void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2453 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2454 | EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 2455 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2456 | |
| 2457 | try |
| 2458 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2459 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2460 | |
| 2461 | if (context) |
| 2462 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2463 | context->setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha)); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2464 | } |
| 2465 | } |
| 2466 | catch(std::bad_alloc&) |
| 2467 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2468 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2469 | } |
| 2470 | } |
| 2471 | |
| 2472 | void __stdcall glBlendEquation(GLenum mode) |
| 2473 | { |
| 2474 | glBlendEquationSeparate(mode, mode); |
| 2475 | } |
| 2476 | |
| 2477 | void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 2478 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2479 | EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2480 | |
| 2481 | try |
| 2482 | { |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2483 | gl::Context *context = gl::getNonLostContext(); |
| 2484 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2485 | switch (modeRGB) |
| 2486 | { |
| 2487 | case GL_FUNC_ADD: |
| 2488 | case GL_FUNC_SUBTRACT: |
| 2489 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2490 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2491 | |
| 2492 | case GL_MIN: |
| 2493 | case GL_MAX: |
| 2494 | if (context && context->getClientVersion() < 3) |
| 2495 | { |
| 2496 | return gl::error(GL_INVALID_ENUM); |
| 2497 | } |
| 2498 | break; |
| 2499 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2500 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2501 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2502 | } |
| 2503 | |
| 2504 | switch (modeAlpha) |
| 2505 | { |
| 2506 | case GL_FUNC_ADD: |
| 2507 | case GL_FUNC_SUBTRACT: |
| 2508 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2509 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2510 | |
| 2511 | case GL_MIN: |
| 2512 | case GL_MAX: |
| 2513 | if (context && context->getClientVersion() < 3) |
| 2514 | { |
| 2515 | return gl::error(GL_INVALID_ENUM); |
| 2516 | } |
| 2517 | break; |
| 2518 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2519 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2520 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2521 | } |
| 2522 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2523 | if (context) |
| 2524 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2525 | context->setBlendEquation(modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2526 | } |
| 2527 | } |
| 2528 | catch(std::bad_alloc&) |
| 2529 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2530 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2531 | } |
| 2532 | } |
| 2533 | |
| 2534 | void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor) |
| 2535 | { |
| 2536 | glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor); |
| 2537 | } |
| 2538 | |
| 2539 | void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 2540 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2541 | EVENT("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 2542 | srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2543 | |
| 2544 | try |
| 2545 | { |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2546 | gl::Context *context = gl::getNonLostContext(); |
| 2547 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2548 | switch (srcRGB) |
| 2549 | { |
| 2550 | case GL_ZERO: |
| 2551 | case GL_ONE: |
| 2552 | case GL_SRC_COLOR: |
| 2553 | case GL_ONE_MINUS_SRC_COLOR: |
| 2554 | case GL_DST_COLOR: |
| 2555 | case GL_ONE_MINUS_DST_COLOR: |
| 2556 | case GL_SRC_ALPHA: |
| 2557 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2558 | case GL_DST_ALPHA: |
| 2559 | case GL_ONE_MINUS_DST_ALPHA: |
| 2560 | case GL_CONSTANT_COLOR: |
| 2561 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2562 | case GL_CONSTANT_ALPHA: |
| 2563 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2564 | case GL_SRC_ALPHA_SATURATE: |
| 2565 | break; |
| 2566 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2567 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2568 | } |
| 2569 | |
| 2570 | switch (dstRGB) |
| 2571 | { |
| 2572 | case GL_ZERO: |
| 2573 | case GL_ONE: |
| 2574 | case GL_SRC_COLOR: |
| 2575 | case GL_ONE_MINUS_SRC_COLOR: |
| 2576 | case GL_DST_COLOR: |
| 2577 | case GL_ONE_MINUS_DST_COLOR: |
| 2578 | case GL_SRC_ALPHA: |
| 2579 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2580 | case GL_DST_ALPHA: |
| 2581 | case GL_ONE_MINUS_DST_ALPHA: |
| 2582 | case GL_CONSTANT_COLOR: |
| 2583 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2584 | case GL_CONSTANT_ALPHA: |
| 2585 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2586 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2587 | |
| 2588 | case GL_SRC_ALPHA_SATURATE: |
| 2589 | if (!context || context->getClientVersion() < 3) |
| 2590 | { |
| 2591 | return gl::error(GL_INVALID_ENUM); |
| 2592 | } |
| 2593 | break; |
| 2594 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2595 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2596 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2597 | } |
| 2598 | |
| 2599 | switch (srcAlpha) |
| 2600 | { |
| 2601 | case GL_ZERO: |
| 2602 | case GL_ONE: |
| 2603 | case GL_SRC_COLOR: |
| 2604 | case GL_ONE_MINUS_SRC_COLOR: |
| 2605 | case GL_DST_COLOR: |
| 2606 | case GL_ONE_MINUS_DST_COLOR: |
| 2607 | case GL_SRC_ALPHA: |
| 2608 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2609 | case GL_DST_ALPHA: |
| 2610 | case GL_ONE_MINUS_DST_ALPHA: |
| 2611 | case GL_CONSTANT_COLOR: |
| 2612 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2613 | case GL_CONSTANT_ALPHA: |
| 2614 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2615 | case GL_SRC_ALPHA_SATURATE: |
| 2616 | break; |
| 2617 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2618 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2619 | } |
| 2620 | |
| 2621 | switch (dstAlpha) |
| 2622 | { |
| 2623 | case GL_ZERO: |
| 2624 | case GL_ONE: |
| 2625 | case GL_SRC_COLOR: |
| 2626 | case GL_ONE_MINUS_SRC_COLOR: |
| 2627 | case GL_DST_COLOR: |
| 2628 | case GL_ONE_MINUS_DST_COLOR: |
| 2629 | case GL_SRC_ALPHA: |
| 2630 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2631 | case GL_DST_ALPHA: |
| 2632 | case GL_ONE_MINUS_DST_ALPHA: |
| 2633 | case GL_CONSTANT_COLOR: |
| 2634 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2635 | case GL_CONSTANT_ALPHA: |
| 2636 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2637 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2638 | |
| 2639 | case GL_SRC_ALPHA_SATURATE: |
| 2640 | if (!context || context->getClientVersion() < 3) |
| 2641 | { |
| 2642 | return gl::error(GL_INVALID_ENUM); |
| 2643 | } |
| 2644 | break; |
| 2645 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2646 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2647 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2648 | } |
| 2649 | |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2650 | bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR || |
| 2651 | dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR); |
| 2652 | |
| 2653 | bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA || |
| 2654 | dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA); |
| 2655 | |
| 2656 | if (constantColorUsed && constantAlphaUsed) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2657 | { |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2658 | ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR invalid under WebGL"); |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2659 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2660 | } |
| 2661 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2662 | if (context) |
| 2663 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2664 | context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2665 | } |
| 2666 | } |
| 2667 | catch(std::bad_alloc&) |
| 2668 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2669 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2670 | } |
| 2671 | } |
| 2672 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2673 | void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2674 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2675 | EVENT("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p, GLenum usage = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 2676 | target, size, data, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2677 | |
| 2678 | try |
| 2679 | { |
| 2680 | if (size < 0) |
| 2681 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2682 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2683 | } |
| 2684 | |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2685 | gl::Context *context = gl::getNonLostContext(); |
| 2686 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2687 | switch (usage) |
| 2688 | { |
| 2689 | case GL_STREAM_DRAW: |
| 2690 | case GL_STATIC_DRAW: |
| 2691 | case GL_DYNAMIC_DRAW: |
| 2692 | break; |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2693 | |
| 2694 | case GL_STREAM_READ: |
| 2695 | case GL_STREAM_COPY: |
| 2696 | case GL_STATIC_READ: |
| 2697 | case GL_STATIC_COPY: |
| 2698 | case GL_DYNAMIC_READ: |
| 2699 | case GL_DYNAMIC_COPY: |
| 2700 | if (context && context->getClientVersion() < 3) |
| 2701 | { |
| 2702 | return gl::error(GL_INVALID_ENUM); |
| 2703 | } |
| 2704 | break; |
| 2705 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2706 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2707 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2708 | } |
| 2709 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2710 | if (context) |
| 2711 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2712 | // Check ES3 specific targets |
| 2713 | switch (target) |
| 2714 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2715 | case GL_COPY_READ_BUFFER: |
| 2716 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2717 | case GL_PIXEL_PACK_BUFFER: |
| 2718 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2719 | case GL_UNIFORM_BUFFER: |
| 2720 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2721 | if (context->getClientVersion() < 3) |
| 2722 | { |
| 2723 | return gl::error(GL_INVALID_ENUM); |
| 2724 | } |
| 2725 | } |
| 2726 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2727 | gl::Buffer *buffer; |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2728 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2729 | switch (target) |
| 2730 | { |
| 2731 | case GL_ARRAY_BUFFER: |
| 2732 | buffer = context->getArrayBuffer(); |
| 2733 | break; |
| 2734 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2735 | buffer = context->getElementArrayBuffer(); |
| 2736 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2737 | case GL_COPY_READ_BUFFER: |
| 2738 | buffer = context->getCopyReadBuffer(); |
| 2739 | break; |
| 2740 | case GL_COPY_WRITE_BUFFER: |
| 2741 | buffer = context->getCopyWriteBuffer(); |
| 2742 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2743 | case GL_PIXEL_PACK_BUFFER: |
| 2744 | buffer = context->getPixelPackBuffer(); |
| 2745 | break; |
| 2746 | case GL_PIXEL_UNPACK_BUFFER: |
| 2747 | buffer = context->getPixelUnpackBuffer(); |
| 2748 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2749 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2750 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2751 | break; |
| 2752 | case GL_UNIFORM_BUFFER: |
| 2753 | buffer = context->getGenericUniformBuffer(); |
| 2754 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2755 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2756 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2757 | } |
| 2758 | |
| 2759 | if (!buffer) |
| 2760 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2761 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2762 | } |
| 2763 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2764 | buffer->bufferData(data, size, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2765 | } |
| 2766 | } |
| 2767 | catch(std::bad_alloc&) |
| 2768 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2769 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2770 | } |
| 2771 | } |
| 2772 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2773 | void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2774 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2775 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 2776 | target, offset, size, data); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2777 | |
| 2778 | try |
| 2779 | { |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2780 | if (size < 0 || offset < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2781 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2782 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2783 | } |
| 2784 | |
daniel@transgaming.com | d4620a3 | 2010-03-21 04:31:28 +0000 | [diff] [blame] | 2785 | if (data == NULL) |
| 2786 | { |
| 2787 | return; |
| 2788 | } |
| 2789 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2790 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2791 | |
| 2792 | if (context) |
| 2793 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2794 | // Check ES3 specific targets |
| 2795 | switch (target) |
| 2796 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2797 | case GL_COPY_READ_BUFFER: |
| 2798 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2799 | case GL_PIXEL_PACK_BUFFER: |
| 2800 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2801 | case GL_UNIFORM_BUFFER: |
| 2802 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2803 | if (context->getClientVersion() < 3) |
| 2804 | { |
| 2805 | return gl::error(GL_INVALID_ENUM); |
| 2806 | } |
| 2807 | } |
| 2808 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2809 | gl::Buffer *buffer; |
| 2810 | |
| 2811 | switch (target) |
| 2812 | { |
| 2813 | case GL_ARRAY_BUFFER: |
| 2814 | buffer = context->getArrayBuffer(); |
| 2815 | break; |
| 2816 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2817 | buffer = context->getElementArrayBuffer(); |
| 2818 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2819 | case GL_COPY_READ_BUFFER: |
| 2820 | buffer = context->getCopyReadBuffer(); |
| 2821 | break; |
| 2822 | case GL_COPY_WRITE_BUFFER: |
| 2823 | buffer = context->getCopyWriteBuffer(); |
| 2824 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2825 | case GL_PIXEL_PACK_BUFFER: |
| 2826 | buffer = context->getPixelPackBuffer(); |
| 2827 | break; |
| 2828 | case GL_PIXEL_UNPACK_BUFFER: |
| 2829 | buffer = context->getPixelUnpackBuffer(); |
| 2830 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2831 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2832 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2833 | break; |
| 2834 | case GL_UNIFORM_BUFFER: |
| 2835 | buffer = context->getGenericUniformBuffer(); |
| 2836 | break; |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2837 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2838 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2839 | } |
| 2840 | |
| 2841 | if (!buffer) |
| 2842 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2843 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2844 | } |
| 2845 | |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2846 | if ((size_t)size + offset > buffer->size()) |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2847 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2848 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2849 | } |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2850 | |
| 2851 | buffer->bufferSubData(data, size, offset); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2852 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2853 | } |
| 2854 | catch(std::bad_alloc&) |
| 2855 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2856 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2857 | } |
| 2858 | } |
| 2859 | |
| 2860 | GLenum __stdcall glCheckFramebufferStatus(GLenum target) |
| 2861 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2862 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2863 | |
| 2864 | try |
| 2865 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2866 | if (target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2867 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2868 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2869 | } |
| 2870 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2871 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2872 | |
| 2873 | if (context) |
| 2874 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2875 | gl::Framebuffer *framebuffer = NULL; |
| 2876 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 2877 | { |
| 2878 | framebuffer = context->getReadFramebuffer(); |
| 2879 | } |
| 2880 | else |
| 2881 | { |
| 2882 | framebuffer = context->getDrawFramebuffer(); |
| 2883 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2884 | |
| 2885 | return framebuffer->completeness(); |
| 2886 | } |
| 2887 | } |
| 2888 | catch(std::bad_alloc&) |
| 2889 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2890 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2891 | } |
| 2892 | |
| 2893 | return 0; |
| 2894 | } |
| 2895 | |
| 2896 | void __stdcall glClear(GLbitfield mask) |
| 2897 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2898 | EVENT("(GLbitfield mask = 0x%X)", mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2899 | |
| 2900 | try |
| 2901 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2902 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2903 | |
| 2904 | if (context) |
| 2905 | { |
| 2906 | context->clear(mask); |
| 2907 | } |
| 2908 | } |
| 2909 | catch(std::bad_alloc&) |
| 2910 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2911 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2912 | } |
| 2913 | } |
| 2914 | |
| 2915 | void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2916 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2917 | EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 2918 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2919 | |
| 2920 | try |
| 2921 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2922 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2923 | |
| 2924 | if (context) |
| 2925 | { |
| 2926 | context->setClearColor(red, green, blue, alpha); |
| 2927 | } |
| 2928 | } |
| 2929 | catch(std::bad_alloc&) |
| 2930 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2931 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2932 | } |
| 2933 | } |
| 2934 | |
| 2935 | void __stdcall glClearDepthf(GLclampf depth) |
| 2936 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2937 | EVENT("(GLclampf depth = %f)", depth); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2938 | |
| 2939 | try |
| 2940 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2941 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2942 | |
| 2943 | if (context) |
| 2944 | { |
| 2945 | context->setClearDepth(depth); |
| 2946 | } |
| 2947 | } |
| 2948 | catch(std::bad_alloc&) |
| 2949 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2950 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2951 | } |
| 2952 | } |
| 2953 | |
| 2954 | void __stdcall glClearStencil(GLint s) |
| 2955 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2956 | EVENT("(GLint s = %d)", s); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2957 | |
| 2958 | try |
| 2959 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2960 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2961 | |
| 2962 | if (context) |
| 2963 | { |
| 2964 | context->setClearStencil(s); |
| 2965 | } |
| 2966 | } |
| 2967 | catch(std::bad_alloc&) |
| 2968 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2969 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2970 | } |
| 2971 | } |
| 2972 | |
| 2973 | void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 2974 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2975 | EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 2976 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2977 | |
| 2978 | try |
| 2979 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2980 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2981 | |
| 2982 | if (context) |
| 2983 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 2984 | context->setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2985 | } |
| 2986 | } |
| 2987 | catch(std::bad_alloc&) |
| 2988 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2989 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2990 | } |
| 2991 | } |
| 2992 | |
| 2993 | void __stdcall glCompileShader(GLuint shader) |
| 2994 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2995 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2996 | |
| 2997 | try |
| 2998 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2999 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3000 | |
| 3001 | if (context) |
| 3002 | { |
| 3003 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 3004 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3005 | if (!shaderObject) |
| 3006 | { |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 3007 | if (context->getProgram(shader)) |
| 3008 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3009 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 3010 | } |
| 3011 | else |
| 3012 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3013 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 3014 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3015 | } |
| 3016 | |
| 3017 | shaderObject->compile(); |
| 3018 | } |
| 3019 | } |
| 3020 | catch(std::bad_alloc&) |
| 3021 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3022 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3023 | } |
| 3024 | } |
| 3025 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3026 | void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, |
| 3027 | GLint border, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3028 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3029 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3030 | "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3031 | target, level, internalformat, width, height, border, imageSize, data); |
| 3032 | |
| 3033 | try |
| 3034 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3035 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3036 | |
| 3037 | if (context) |
| 3038 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3039 | if (context->getClientVersion() < 3 && |
| 3040 | !validateES2TexImageParameters(context, target, level, internalformat, true, false, |
| 3041 | 0, 0, width, height, 0, GL_NONE, GL_NONE, data)) |
| 3042 | { |
| 3043 | return; |
| 3044 | } |
| 3045 | |
| 3046 | if (context->getClientVersion() >= 3 && |
| 3047 | !validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 3048 | 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 3049 | { |
| 3050 | return; |
| 3051 | } |
| 3052 | |
| 3053 | if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3054 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3055 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3056 | } |
| 3057 | |
| 3058 | switch (target) |
| 3059 | { |
| 3060 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3061 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3062 | gl::Texture2D *texture = context->getTexture2D(); |
| 3063 | texture->setCompressedImage(level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3064 | } |
| 3065 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3066 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3067 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3068 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3069 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3070 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3071 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3072 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3073 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3074 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3075 | texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3076 | } |
| 3077 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3078 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3079 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3080 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3081 | } |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3082 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3083 | } |
| 3084 | catch(std::bad_alloc&) |
| 3085 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3086 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3087 | } |
| 3088 | } |
| 3089 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3090 | void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 3091 | GLenum format, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3092 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3093 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 3094 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3095 | "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3096 | target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 3097 | |
| 3098 | try |
| 3099 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3100 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3101 | |
| 3102 | if (context) |
| 3103 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3104 | if (context->getClientVersion() < 3 && |
| 3105 | !validateES2TexImageParameters(context, target, level, GL_NONE, true, true, |
| 3106 | xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data)) |
| 3107 | { |
| 3108 | return; |
| 3109 | } |
| 3110 | |
| 3111 | if (context->getClientVersion() >= 3 && |
| 3112 | !validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 3113 | xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 3114 | { |
| 3115 | return; |
| 3116 | } |
| 3117 | |
| 3118 | if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, context->getClientVersion(), width, height)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3119 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3120 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3121 | } |
| 3122 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3123 | switch (target) |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3124 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3125 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3126 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3127 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 3128 | texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3129 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3130 | break; |
| 3131 | |
| 3132 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3133 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3134 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3135 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3136 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3137 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3138 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3139 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 3140 | texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3141 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3142 | break; |
| 3143 | |
| 3144 | default: |
| 3145 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 3146 | } |
| 3147 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3148 | } |
| 3149 | catch(std::bad_alloc&) |
| 3150 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3151 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3152 | } |
| 3153 | } |
| 3154 | |
| 3155 | void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) |
| 3156 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3157 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 3158 | "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3159 | target, level, internalformat, x, y, width, height, border); |
| 3160 | |
| 3161 | try |
| 3162 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3163 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3164 | |
| 3165 | if (context) |
| 3166 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3167 | if (context->getClientVersion() < 3 && |
| 3168 | !validateES2CopyTexImageParameters(context, target, level, internalformat, false, |
| 3169 | 0, 0, x, y, width, height, border)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 3170 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3171 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 3172 | } |
| 3173 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3174 | if (context->getClientVersion() >= 3 && |
| 3175 | !validateES3CopyTexImageParameters(context, target, level, internalformat, false, |
| 3176 | 0, 0, 0, x, y, width, height, border)) |
| 3177 | { |
| 3178 | return; |
| 3179 | } |
| 3180 | |
| 3181 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 3182 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3183 | switch (target) |
| 3184 | { |
| 3185 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3186 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3187 | gl::Texture2D *texture = context->getTexture2D(); |
| 3188 | texture->copyImage(level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3189 | } |
| 3190 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3191 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3192 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3193 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3194 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3195 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3196 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3197 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3198 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3199 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3200 | texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3201 | } |
| 3202 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3203 | |
| 3204 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3205 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3206 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3207 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3208 | } |
| 3209 | catch(std::bad_alloc&) |
| 3210 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3211 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3212 | } |
| 3213 | } |
| 3214 | |
| 3215 | void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 3216 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3217 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 3218 | "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3219 | target, level, xoffset, yoffset, x, y, width, height); |
| 3220 | |
| 3221 | try |
| 3222 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3223 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3224 | |
| 3225 | if (context) |
| 3226 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3227 | if (context->getClientVersion() < 3 && |
| 3228 | !validateES2CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 3229 | xoffset, yoffset, x, y, width, height, 0)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3230 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3231 | return; |
| 3232 | } |
| 3233 | |
| 3234 | if (context->getClientVersion() >= 3 && |
| 3235 | !validateES3CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 3236 | xoffset, yoffset, 0, x, y, width, height, 0)) |
| 3237 | { |
| 3238 | return; |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3239 | } |
| 3240 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3241 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3242 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3243 | switch (target) |
daniel@transgaming.com | bbc5779 | 2010-07-28 19:21:05 +0000 | [diff] [blame] | 3244 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3245 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 3246 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3247 | gl::Texture2D *texture = context->getTexture2D(); |
| 3248 | texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3249 | } |
| 3250 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3251 | |
| 3252 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3253 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3254 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3255 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3256 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3257 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 3258 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3259 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3260 | texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer); |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 3261 | } |
| 3262 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3263 | |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3264 | default: |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3265 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3266 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3267 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3268 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3269 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3270 | catch(std::bad_alloc&) |
| 3271 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3272 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3273 | } |
| 3274 | } |
| 3275 | |
| 3276 | GLuint __stdcall glCreateProgram(void) |
| 3277 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3278 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3279 | |
| 3280 | try |
| 3281 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3282 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3283 | |
| 3284 | if (context) |
| 3285 | { |
| 3286 | return context->createProgram(); |
| 3287 | } |
| 3288 | } |
| 3289 | catch(std::bad_alloc&) |
| 3290 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3291 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3292 | } |
| 3293 | |
| 3294 | return 0; |
| 3295 | } |
| 3296 | |
| 3297 | GLuint __stdcall glCreateShader(GLenum type) |
| 3298 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3299 | EVENT("(GLenum type = 0x%X)", type); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3300 | |
| 3301 | try |
| 3302 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3303 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3304 | |
| 3305 | if (context) |
| 3306 | { |
| 3307 | switch (type) |
| 3308 | { |
| 3309 | case GL_FRAGMENT_SHADER: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 3310 | case GL_VERTEX_SHADER: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3311 | return context->createShader(type); |
| 3312 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3313 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3314 | } |
| 3315 | } |
| 3316 | } |
| 3317 | catch(std::bad_alloc&) |
| 3318 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3319 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3320 | } |
| 3321 | |
| 3322 | return 0; |
| 3323 | } |
| 3324 | |
| 3325 | void __stdcall glCullFace(GLenum mode) |
| 3326 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3327 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3328 | |
| 3329 | try |
| 3330 | { |
| 3331 | switch (mode) |
| 3332 | { |
| 3333 | case GL_FRONT: |
| 3334 | case GL_BACK: |
| 3335 | case GL_FRONT_AND_BACK: |
| 3336 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3337 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3338 | |
| 3339 | if (context) |
| 3340 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3341 | context->setCullMode(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3342 | } |
| 3343 | } |
| 3344 | break; |
| 3345 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3346 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3347 | } |
| 3348 | } |
| 3349 | catch(std::bad_alloc&) |
| 3350 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3351 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3352 | } |
| 3353 | } |
| 3354 | |
| 3355 | void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers) |
| 3356 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3357 | EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3358 | |
| 3359 | try |
| 3360 | { |
| 3361 | if (n < 0) |
| 3362 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3363 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3364 | } |
| 3365 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3366 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3367 | |
| 3368 | if (context) |
| 3369 | { |
| 3370 | for (int i = 0; i < n; i++) |
| 3371 | { |
| 3372 | context->deleteBuffer(buffers[i]); |
| 3373 | } |
| 3374 | } |
| 3375 | } |
| 3376 | catch(std::bad_alloc&) |
| 3377 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3378 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3379 | } |
| 3380 | } |
| 3381 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3382 | void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences) |
| 3383 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3384 | EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3385 | |
| 3386 | try |
| 3387 | { |
| 3388 | if (n < 0) |
| 3389 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3390 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3391 | } |
| 3392 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3393 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3394 | |
| 3395 | if (context) |
| 3396 | { |
| 3397 | for (int i = 0; i < n; i++) |
| 3398 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 3399 | context->deleteFenceNV(fences[i]); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3400 | } |
| 3401 | } |
| 3402 | } |
| 3403 | catch(std::bad_alloc&) |
| 3404 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3405 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3406 | } |
| 3407 | } |
| 3408 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3409 | void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) |
| 3410 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3411 | EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3412 | |
| 3413 | try |
| 3414 | { |
| 3415 | if (n < 0) |
| 3416 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3417 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3418 | } |
| 3419 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3420 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3421 | |
| 3422 | if (context) |
| 3423 | { |
| 3424 | for (int i = 0; i < n; i++) |
| 3425 | { |
| 3426 | if (framebuffers[i] != 0) |
| 3427 | { |
| 3428 | context->deleteFramebuffer(framebuffers[i]); |
| 3429 | } |
| 3430 | } |
| 3431 | } |
| 3432 | } |
| 3433 | catch(std::bad_alloc&) |
| 3434 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3435 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3436 | } |
| 3437 | } |
| 3438 | |
| 3439 | void __stdcall glDeleteProgram(GLuint program) |
| 3440 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3441 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3442 | |
| 3443 | try |
| 3444 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3445 | if (program == 0) |
| 3446 | { |
| 3447 | return; |
| 3448 | } |
| 3449 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3450 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3451 | |
| 3452 | if (context) |
| 3453 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3454 | if (!context->getProgram(program)) |
| 3455 | { |
| 3456 | if(context->getShader(program)) |
| 3457 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3458 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3459 | } |
| 3460 | else |
| 3461 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3462 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3463 | } |
| 3464 | } |
| 3465 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3466 | context->deleteProgram(program); |
| 3467 | } |
| 3468 | } |
| 3469 | catch(std::bad_alloc&) |
| 3470 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3471 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3472 | } |
| 3473 | } |
| 3474 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3475 | void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids) |
| 3476 | { |
| 3477 | EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids); |
| 3478 | |
| 3479 | try |
| 3480 | { |
| 3481 | if (n < 0) |
| 3482 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3483 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3484 | } |
| 3485 | |
| 3486 | gl::Context *context = gl::getNonLostContext(); |
| 3487 | |
| 3488 | if (context) |
| 3489 | { |
| 3490 | for (int i = 0; i < n; i++) |
| 3491 | { |
| 3492 | context->deleteQuery(ids[i]); |
| 3493 | } |
| 3494 | } |
| 3495 | } |
| 3496 | catch(std::bad_alloc&) |
| 3497 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3498 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3499 | } |
| 3500 | } |
| 3501 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3502 | void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) |
| 3503 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3504 | EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3505 | |
| 3506 | try |
| 3507 | { |
| 3508 | if (n < 0) |
| 3509 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3510 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3511 | } |
| 3512 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3513 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3514 | |
| 3515 | if (context) |
| 3516 | { |
daniel@transgaming.com | e2b2212 | 2010-03-11 19:22:14 +0000 | [diff] [blame] | 3517 | for (int i = 0; i < n; i++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3518 | { |
| 3519 | context->deleteRenderbuffer(renderbuffers[i]); |
| 3520 | } |
| 3521 | } |
| 3522 | } |
| 3523 | catch(std::bad_alloc&) |
| 3524 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3525 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3526 | } |
| 3527 | } |
| 3528 | |
| 3529 | void __stdcall glDeleteShader(GLuint shader) |
| 3530 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3531 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3532 | |
| 3533 | try |
| 3534 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3535 | if (shader == 0) |
| 3536 | { |
| 3537 | return; |
| 3538 | } |
| 3539 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3540 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3541 | |
| 3542 | if (context) |
| 3543 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3544 | if (!context->getShader(shader)) |
| 3545 | { |
| 3546 | if(context->getProgram(shader)) |
| 3547 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3548 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3549 | } |
| 3550 | else |
| 3551 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3552 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3553 | } |
| 3554 | } |
| 3555 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3556 | context->deleteShader(shader); |
| 3557 | } |
| 3558 | } |
| 3559 | catch(std::bad_alloc&) |
| 3560 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3561 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3562 | } |
| 3563 | } |
| 3564 | |
| 3565 | void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures) |
| 3566 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3567 | EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3568 | |
| 3569 | try |
| 3570 | { |
| 3571 | if (n < 0) |
| 3572 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3573 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3574 | } |
| 3575 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3576 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3577 | |
| 3578 | if (context) |
| 3579 | { |
| 3580 | for (int i = 0; i < n; i++) |
| 3581 | { |
| 3582 | if (textures[i] != 0) |
| 3583 | { |
| 3584 | context->deleteTexture(textures[i]); |
| 3585 | } |
| 3586 | } |
| 3587 | } |
| 3588 | } |
| 3589 | catch(std::bad_alloc&) |
| 3590 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3591 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3592 | } |
| 3593 | } |
| 3594 | |
| 3595 | void __stdcall glDepthFunc(GLenum func) |
| 3596 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3597 | EVENT("(GLenum func = 0x%X)", func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3598 | |
| 3599 | try |
| 3600 | { |
| 3601 | switch (func) |
| 3602 | { |
| 3603 | case GL_NEVER: |
| 3604 | case GL_ALWAYS: |
| 3605 | case GL_LESS: |
| 3606 | case GL_LEQUAL: |
| 3607 | case GL_EQUAL: |
| 3608 | case GL_GREATER: |
| 3609 | case GL_GEQUAL: |
| 3610 | case GL_NOTEQUAL: |
| 3611 | break; |
| 3612 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3613 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3614 | } |
| 3615 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3616 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3617 | |
| 3618 | if (context) |
| 3619 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3620 | context->setDepthFunc(func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3621 | } |
| 3622 | } |
| 3623 | catch(std::bad_alloc&) |
| 3624 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3625 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3626 | } |
| 3627 | } |
| 3628 | |
| 3629 | void __stdcall glDepthMask(GLboolean flag) |
| 3630 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 3631 | EVENT("(GLboolean flag = %u)", flag); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3632 | |
| 3633 | try |
| 3634 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3635 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3636 | |
| 3637 | if (context) |
| 3638 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3639 | context->setDepthMask(flag != GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3640 | } |
| 3641 | } |
| 3642 | catch(std::bad_alloc&) |
| 3643 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3644 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3645 | } |
| 3646 | } |
| 3647 | |
| 3648 | void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar) |
| 3649 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3650 | EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3651 | |
| 3652 | try |
| 3653 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3654 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3655 | |
| 3656 | if (context) |
| 3657 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3658 | context->setDepthRange(zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3659 | } |
| 3660 | } |
| 3661 | catch(std::bad_alloc&) |
| 3662 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3663 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3664 | } |
| 3665 | } |
| 3666 | |
| 3667 | void __stdcall glDetachShader(GLuint program, GLuint shader) |
| 3668 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3669 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3670 | |
| 3671 | try |
| 3672 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3673 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3674 | |
| 3675 | if (context) |
| 3676 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3677 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3678 | gl::Program *programObject = context->getProgram(program); |
| 3679 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3680 | |
| 3681 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3682 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3683 | gl::Shader *shaderByProgramHandle; |
| 3684 | shaderByProgramHandle = context->getShader(program); |
| 3685 | if (!shaderByProgramHandle) |
| 3686 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3687 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3688 | } |
| 3689 | else |
| 3690 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3691 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3692 | } |
| 3693 | } |
| 3694 | |
| 3695 | if (!shaderObject) |
| 3696 | { |
| 3697 | gl::Program *programByShaderHandle = context->getProgram(shader); |
| 3698 | if (!programByShaderHandle) |
| 3699 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3700 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3701 | } |
| 3702 | else |
| 3703 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3704 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3705 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3706 | } |
| 3707 | |
| 3708 | if (!programObject->detachShader(shaderObject)) |
| 3709 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3710 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3711 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3712 | } |
| 3713 | } |
| 3714 | catch(std::bad_alloc&) |
| 3715 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3716 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3717 | } |
| 3718 | } |
| 3719 | |
| 3720 | void __stdcall glDisable(GLenum cap) |
| 3721 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3722 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3723 | |
| 3724 | try |
| 3725 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3726 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3727 | |
| 3728 | if (context) |
| 3729 | { |
| 3730 | switch (cap) |
| 3731 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3732 | case GL_CULL_FACE: context->setCullFace(false); break; |
| 3733 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break; |
| 3734 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break; |
| 3735 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break; |
| 3736 | case GL_SCISSOR_TEST: context->setScissorTest(false); break; |
| 3737 | case GL_STENCIL_TEST: context->setStencilTest(false); break; |
| 3738 | case GL_DEPTH_TEST: context->setDepthTest(false); break; |
| 3739 | case GL_BLEND: context->setBlend(false); break; |
| 3740 | case GL_DITHER: context->setDither(false); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 3741 | |
| 3742 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 3743 | case GL_RASTERIZER_DISCARD: |
| 3744 | if (context->getClientVersion() < 3) |
| 3745 | { |
| 3746 | return gl::error(GL_INVALID_ENUM); |
| 3747 | } |
| 3748 | UNIMPLEMENTED(); |
| 3749 | break; |
| 3750 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3751 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3752 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3753 | } |
| 3754 | } |
| 3755 | } |
| 3756 | catch(std::bad_alloc&) |
| 3757 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3758 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3759 | } |
| 3760 | } |
| 3761 | |
| 3762 | void __stdcall glDisableVertexAttribArray(GLuint index) |
| 3763 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3764 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3765 | |
| 3766 | try |
| 3767 | { |
| 3768 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3769 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3770 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3771 | } |
| 3772 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3773 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3774 | |
| 3775 | if (context) |
| 3776 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3777 | context->setEnableVertexAttribArray(index, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3778 | } |
| 3779 | } |
| 3780 | catch(std::bad_alloc&) |
| 3781 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3782 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3783 | } |
| 3784 | } |
| 3785 | |
| 3786 | void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count) |
| 3787 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3788 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3789 | |
| 3790 | try |
| 3791 | { |
| 3792 | if (count < 0 || first < 0) |
| 3793 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3794 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3795 | } |
| 3796 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3797 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3798 | |
| 3799 | if (context) |
| 3800 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3801 | context->drawArrays(mode, first, count, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3802 | } |
| 3803 | } |
| 3804 | catch(std::bad_alloc&) |
| 3805 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3806 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3807 | } |
| 3808 | } |
| 3809 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3810 | void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
| 3811 | { |
| 3812 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount); |
| 3813 | |
| 3814 | try |
| 3815 | { |
| 3816 | if (count < 0 || first < 0 || primcount < 0) |
| 3817 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3818 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3819 | } |
| 3820 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3821 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3822 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3823 | gl::Context *context = gl::getNonLostContext(); |
| 3824 | |
| 3825 | if (context) |
| 3826 | { |
| 3827 | context->drawArrays(mode, first, count, primcount); |
| 3828 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3829 | } |
| 3830 | } |
| 3831 | catch(std::bad_alloc&) |
| 3832 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3833 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3834 | } |
| 3835 | } |
| 3836 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3837 | void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3838 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3839 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 3840 | mode, count, type, indices); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3841 | |
| 3842 | try |
| 3843 | { |
| 3844 | if (count < 0) |
| 3845 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3846 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3847 | } |
| 3848 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3849 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3850 | |
| 3851 | if (context) |
| 3852 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3853 | switch (type) |
| 3854 | { |
| 3855 | case GL_UNSIGNED_BYTE: |
| 3856 | case GL_UNSIGNED_SHORT: |
| 3857 | break; |
| 3858 | case GL_UNSIGNED_INT: |
| 3859 | if (!context->supports32bitIndices()) |
| 3860 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3861 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3862 | } |
| 3863 | break; |
| 3864 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3865 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3866 | } |
| 3867 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3868 | context->drawElements(mode, count, type, indices, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3869 | } |
| 3870 | } |
| 3871 | catch(std::bad_alloc&) |
| 3872 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3873 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3874 | } |
| 3875 | } |
| 3876 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3877 | void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount) |
| 3878 | { |
| 3879 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)", |
| 3880 | mode, count, type, indices, primcount); |
| 3881 | |
| 3882 | try |
| 3883 | { |
| 3884 | if (count < 0 || primcount < 0) |
| 3885 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3886 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3887 | } |
| 3888 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3889 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3890 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3891 | gl::Context *context = gl::getNonLostContext(); |
| 3892 | |
| 3893 | if (context) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3894 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3895 | switch (type) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3896 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3897 | case GL_UNSIGNED_BYTE: |
| 3898 | case GL_UNSIGNED_SHORT: |
| 3899 | break; |
| 3900 | case GL_UNSIGNED_INT: |
| 3901 | if (!context->supports32bitIndices()) |
| 3902 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3903 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3904 | } |
| 3905 | break; |
| 3906 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3907 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3908 | } |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3909 | |
| 3910 | context->drawElements(mode, count, type, indices, primcount); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3911 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3912 | } |
| 3913 | } |
| 3914 | catch(std::bad_alloc&) |
| 3915 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3916 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3917 | } |
| 3918 | } |
| 3919 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3920 | void __stdcall glEnable(GLenum cap) |
| 3921 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3922 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3923 | |
| 3924 | try |
| 3925 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3926 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3927 | |
| 3928 | if (context) |
| 3929 | { |
| 3930 | switch (cap) |
| 3931 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3932 | case GL_CULL_FACE: context->setCullFace(true); break; |
| 3933 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break; |
| 3934 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break; |
| 3935 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break; |
| 3936 | case GL_SCISSOR_TEST: context->setScissorTest(true); break; |
| 3937 | case GL_STENCIL_TEST: context->setStencilTest(true); break; |
| 3938 | case GL_DEPTH_TEST: context->setDepthTest(true); break; |
| 3939 | case GL_BLEND: context->setBlend(true); break; |
| 3940 | case GL_DITHER: context->setDither(true); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3941 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3942 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3943 | } |
| 3944 | } |
| 3945 | } |
| 3946 | catch(std::bad_alloc&) |
| 3947 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3948 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3949 | } |
| 3950 | } |
| 3951 | |
| 3952 | void __stdcall glEnableVertexAttribArray(GLuint index) |
| 3953 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3954 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3955 | |
| 3956 | try |
| 3957 | { |
| 3958 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3959 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3960 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3961 | } |
| 3962 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3963 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3964 | |
| 3965 | if (context) |
| 3966 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3967 | context->setEnableVertexAttribArray(index, true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3968 | } |
| 3969 | } |
| 3970 | catch(std::bad_alloc&) |
| 3971 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3972 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3973 | } |
| 3974 | } |
| 3975 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3976 | void __stdcall glEndQueryEXT(GLenum target) |
| 3977 | { |
| 3978 | EVENT("GLenum target = 0x%X)", target); |
| 3979 | |
| 3980 | try |
| 3981 | { |
| 3982 | switch (target) |
| 3983 | { |
| 3984 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 3985 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 3986 | break; |
| 3987 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3988 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3989 | } |
| 3990 | |
| 3991 | gl::Context *context = gl::getNonLostContext(); |
| 3992 | |
| 3993 | if (context) |
| 3994 | { |
| 3995 | context->endQuery(target); |
| 3996 | } |
| 3997 | } |
| 3998 | catch(std::bad_alloc&) |
| 3999 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4000 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4001 | } |
| 4002 | } |
| 4003 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4004 | void __stdcall glFinishFenceNV(GLuint fence) |
| 4005 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4006 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4007 | |
| 4008 | try |
| 4009 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4010 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4011 | |
| 4012 | if (context) |
| 4013 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 4014 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4015 | |
| 4016 | if (fenceObject == NULL) |
| 4017 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4018 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4019 | } |
| 4020 | |
Jamie Madill | fb9a740 | 2013-07-26 11:55:01 -0400 | [diff] [blame] | 4021 | if (fenceObject->isFence() != GL_TRUE) |
| 4022 | { |
| 4023 | return gl::error(GL_INVALID_OPERATION); |
| 4024 | } |
| 4025 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4026 | fenceObject->finishFence(); |
| 4027 | } |
| 4028 | } |
| 4029 | catch(std::bad_alloc&) |
| 4030 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4031 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4032 | } |
| 4033 | } |
| 4034 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4035 | void __stdcall glFinish(void) |
| 4036 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4037 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4038 | |
| 4039 | try |
| 4040 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4041 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4042 | |
| 4043 | if (context) |
| 4044 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 4045 | context->sync(true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4046 | } |
| 4047 | } |
| 4048 | catch(std::bad_alloc&) |
| 4049 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4050 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4051 | } |
| 4052 | } |
| 4053 | |
| 4054 | void __stdcall glFlush(void) |
| 4055 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4056 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4057 | |
| 4058 | try |
| 4059 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4060 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4061 | |
| 4062 | if (context) |
| 4063 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 4064 | context->sync(false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4065 | } |
| 4066 | } |
| 4067 | catch(std::bad_alloc&) |
| 4068 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4069 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4070 | } |
| 4071 | } |
| 4072 | |
| 4073 | void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) |
| 4074 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4075 | 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] | 4076 | "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4077 | |
| 4078 | try |
| 4079 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4080 | 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] | 4081 | || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4082 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4083 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4084 | } |
| 4085 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4086 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4087 | |
| 4088 | if (context) |
| 4089 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4090 | gl::Framebuffer *framebuffer = NULL; |
| 4091 | GLuint framebufferHandle = 0; |
| 4092 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4093 | { |
| 4094 | framebuffer = context->getReadFramebuffer(); |
| 4095 | framebufferHandle = context->getReadFramebufferHandle(); |
| 4096 | } |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 4097 | else |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4098 | { |
| 4099 | framebuffer = context->getDrawFramebuffer(); |
| 4100 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 4101 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4102 | |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 4103 | if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4104 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4105 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4106 | } |
| 4107 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4108 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4109 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4110 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4111 | |
| 4112 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4113 | { |
| 4114 | return gl::error(GL_INVALID_VALUE); |
| 4115 | } |
| 4116 | |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 4117 | framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4118 | } |
| 4119 | else |
| 4120 | { |
| 4121 | switch (attachment) |
| 4122 | { |
| 4123 | case GL_DEPTH_ATTACHMENT: |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 4124 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4125 | break; |
| 4126 | case GL_STENCIL_ATTACHMENT: |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 4127 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4128 | break; |
| 4129 | default: |
| 4130 | return gl::error(GL_INVALID_ENUM); |
| 4131 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4132 | } |
| 4133 | } |
| 4134 | } |
| 4135 | catch(std::bad_alloc&) |
| 4136 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4137 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4138 | } |
| 4139 | } |
| 4140 | |
| 4141 | void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) |
| 4142 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4143 | 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] | 4144 | "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4145 | |
| 4146 | try |
| 4147 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4148 | 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] | 4149 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4150 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4151 | } |
| 4152 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4153 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4154 | |
| 4155 | if (context) |
| 4156 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4157 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 4158 | { |
| 4159 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4160 | |
| 4161 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4162 | { |
| 4163 | return gl::error(GL_INVALID_VALUE); |
| 4164 | } |
| 4165 | } |
| 4166 | else |
| 4167 | { |
| 4168 | switch (attachment) |
| 4169 | { |
| 4170 | case GL_DEPTH_ATTACHMENT: |
| 4171 | case GL_STENCIL_ATTACHMENT: |
| 4172 | break; |
Geoff Lang | 55ba29c | 2013-07-11 16:57:53 -0400 | [diff] [blame] | 4173 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 4174 | if (context->getClientVersion() < 3) |
| 4175 | { |
| 4176 | return gl::error(GL_INVALID_ENUM); |
| 4177 | } |
| 4178 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4179 | default: |
| 4180 | return gl::error(GL_INVALID_ENUM); |
| 4181 | } |
| 4182 | } |
| 4183 | |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4184 | if (texture == 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4185 | { |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4186 | textarget = GL_NONE; |
| 4187 | } |
| 4188 | else |
| 4189 | { |
| 4190 | gl::Texture *tex = context->getTexture(texture); |
| 4191 | |
| 4192 | if (tex == NULL) |
| 4193 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4194 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4195 | } |
| 4196 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4197 | switch (textarget) |
| 4198 | { |
| 4199 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4200 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4201 | if (tex->getTarget() != GL_TEXTURE_2D) |
| 4202 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4203 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4204 | } |
| 4205 | gl::Texture2D *tex2d = static_cast<gl::Texture2D *>(tex); |
daniel@transgaming.com | 92f4992 | 2012-05-09 15:49:19 +0000 | [diff] [blame] | 4206 | if (tex2d->isCompressed(0)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4207 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4208 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4209 | } |
| 4210 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4211 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4212 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4213 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4214 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4215 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4216 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4217 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4218 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4219 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4220 | if (tex->getTarget() != GL_TEXTURE_CUBE_MAP) |
| 4221 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4222 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4223 | } |
| 4224 | gl::TextureCubeMap *texcube = static_cast<gl::TextureCubeMap *>(tex); |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 4225 | if (texcube->isCompressed(textarget, level)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4226 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4227 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4228 | } |
| 4229 | break; |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4230 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4231 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4232 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4233 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4234 | } |
| 4235 | |
| 4236 | if (level != 0) |
| 4237 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4238 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4239 | } |
| 4240 | } |
| 4241 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4242 | gl::Framebuffer *framebuffer = NULL; |
| 4243 | GLuint framebufferHandle = 0; |
| 4244 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4245 | { |
| 4246 | framebuffer = context->getReadFramebuffer(); |
| 4247 | framebufferHandle = context->getReadFramebufferHandle(); |
| 4248 | } |
| 4249 | else |
| 4250 | { |
| 4251 | framebuffer = context->getDrawFramebuffer(); |
| 4252 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 4253 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4254 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4255 | if (framebufferHandle == 0 || !framebuffer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4256 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4257 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4258 | } |
| 4259 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4260 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4261 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4262 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4263 | |
| 4264 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4265 | { |
| 4266 | return gl::error(GL_INVALID_VALUE); |
| 4267 | } |
| 4268 | |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 4269 | framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4270 | } |
| 4271 | else |
| 4272 | { |
| 4273 | switch (attachment) |
| 4274 | { |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 4275 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, 0); break; |
| 4276 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, 0); break; |
| 4277 | case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, 0); break; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4278 | } |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4279 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4280 | } |
| 4281 | } |
| 4282 | catch(std::bad_alloc&) |
| 4283 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4284 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4285 | } |
| 4286 | } |
| 4287 | |
| 4288 | void __stdcall glFrontFace(GLenum mode) |
| 4289 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4290 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4291 | |
| 4292 | try |
| 4293 | { |
| 4294 | switch (mode) |
| 4295 | { |
| 4296 | case GL_CW: |
| 4297 | case GL_CCW: |
| 4298 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4299 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4300 | |
| 4301 | if (context) |
| 4302 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4303 | context->setFrontFace(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4304 | } |
| 4305 | } |
| 4306 | break; |
| 4307 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4308 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4309 | } |
| 4310 | } |
| 4311 | catch(std::bad_alloc&) |
| 4312 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4313 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4314 | } |
| 4315 | } |
| 4316 | |
| 4317 | void __stdcall glGenBuffers(GLsizei n, GLuint* buffers) |
| 4318 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4319 | EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4320 | |
| 4321 | try |
| 4322 | { |
| 4323 | if (n < 0) |
| 4324 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4325 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4326 | } |
| 4327 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4328 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4329 | |
| 4330 | if (context) |
| 4331 | { |
| 4332 | for (int i = 0; i < n; i++) |
| 4333 | { |
| 4334 | buffers[i] = context->createBuffer(); |
| 4335 | } |
| 4336 | } |
| 4337 | } |
| 4338 | catch(std::bad_alloc&) |
| 4339 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4340 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4341 | } |
| 4342 | } |
| 4343 | |
| 4344 | void __stdcall glGenerateMipmap(GLenum target) |
| 4345 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4346 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4347 | |
| 4348 | try |
| 4349 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4350 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4351 | |
| 4352 | if (context) |
| 4353 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4354 | gl::Texture *texture = NULL; |
| 4355 | GLint internalFormat = GL_NONE; |
| 4356 | bool isCompressed = false; |
| 4357 | bool isDepth = false; |
| 4358 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4359 | switch (target) |
| 4360 | { |
| 4361 | case GL_TEXTURE_2D: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4362 | { |
| 4363 | gl::Texture2D *tex2d = context->getTexture2D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4364 | if (tex2d) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4365 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4366 | internalFormat = tex2d->getInternalFormat(0); |
| 4367 | isCompressed = tex2d->isCompressed(0); |
| 4368 | isDepth = tex2d->isDepth(0); |
| 4369 | texture = tex2d; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4370 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4371 | break; |
| 4372 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4373 | |
| 4374 | case GL_TEXTURE_CUBE_MAP: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4375 | { |
| 4376 | gl::TextureCubeMap *texcube = context->getTextureCubeMap(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4377 | if (texcube) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4378 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4379 | internalFormat = texcube->getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 4380 | isCompressed = texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 4381 | isDepth = false; |
| 4382 | texture = texcube; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4383 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4384 | break; |
| 4385 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4386 | |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4387 | case GL_TEXTURE_3D: |
| 4388 | { |
| 4389 | if (context->getClientVersion() < 3) |
| 4390 | { |
| 4391 | return gl::error(GL_INVALID_ENUM); |
| 4392 | } |
| 4393 | |
| 4394 | gl::Texture3D *tex3D = context->getTexture3D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4395 | if (tex3D) |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4396 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4397 | internalFormat = tex3D->getInternalFormat(0); |
| 4398 | isCompressed = tex3D->isCompressed(0); |
| 4399 | isDepth = tex3D->isDepth(0); |
| 4400 | texture = tex3D; |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4401 | } |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4402 | break; |
| 4403 | } |
| 4404 | |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4405 | case GL_TEXTURE_2D_ARRAY: |
| 4406 | { |
| 4407 | if (context->getClientVersion() < 3) |
| 4408 | { |
| 4409 | return gl::error(GL_INVALID_ENUM); |
| 4410 | } |
| 4411 | |
| 4412 | gl::Texture2DArray *tex2darr = context->getTexture2DArray(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4413 | if (tex2darr) |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4414 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4415 | internalFormat = tex2darr->getInternalFormat(0); |
| 4416 | isCompressed = tex2darr->isCompressed(0); |
| 4417 | isDepth = tex2darr->isDepth(0); |
| 4418 | texture = tex2darr; |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4419 | } |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4420 | break; |
| 4421 | } |
| 4422 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4423 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4424 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4425 | } |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4426 | |
| 4427 | if (!texture) |
| 4428 | { |
| 4429 | return gl::error(GL_INVALID_OPERATION); |
| 4430 | } |
| 4431 | |
| 4432 | // Internally, all texture formats are sized so checking if the format |
| 4433 | // is color renderable and filterable will not fail. |
| 4434 | if (isDepth || isCompressed || |
| 4435 | !gl::IsColorRenderingSupported(internalFormat, context) || |
| 4436 | !gl::IsTextureFilteringSupported(internalFormat, context)) |
| 4437 | { |
| 4438 | return gl::error(GL_INVALID_OPERATION); |
| 4439 | } |
| 4440 | |
| 4441 | texture->generateMipmaps(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4442 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4443 | } |
| 4444 | catch(std::bad_alloc&) |
| 4445 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4446 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4447 | } |
| 4448 | } |
| 4449 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4450 | void __stdcall glGenFencesNV(GLsizei n, GLuint* fences) |
| 4451 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4452 | EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4453 | |
| 4454 | try |
| 4455 | { |
| 4456 | if (n < 0) |
| 4457 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4458 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4459 | } |
| 4460 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4461 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4462 | |
| 4463 | if (context) |
| 4464 | { |
| 4465 | for (int i = 0; i < n; i++) |
| 4466 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 4467 | fences[i] = context->createFenceNV(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4468 | } |
| 4469 | } |
| 4470 | } |
| 4471 | catch(std::bad_alloc&) |
| 4472 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4473 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4474 | } |
| 4475 | } |
| 4476 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4477 | void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers) |
| 4478 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4479 | EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4480 | |
| 4481 | try |
| 4482 | { |
| 4483 | if (n < 0) |
| 4484 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4485 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4486 | } |
| 4487 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4488 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4489 | |
| 4490 | if (context) |
| 4491 | { |
| 4492 | for (int i = 0; i < n; i++) |
| 4493 | { |
| 4494 | framebuffers[i] = context->createFramebuffer(); |
| 4495 | } |
| 4496 | } |
| 4497 | } |
| 4498 | catch(std::bad_alloc&) |
| 4499 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4500 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4501 | } |
| 4502 | } |
| 4503 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4504 | void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids) |
| 4505 | { |
| 4506 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 4507 | |
| 4508 | try |
| 4509 | { |
| 4510 | if (n < 0) |
| 4511 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4512 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4513 | } |
| 4514 | |
| 4515 | gl::Context *context = gl::getNonLostContext(); |
| 4516 | |
| 4517 | if (context) |
| 4518 | { |
| 4519 | for (int i = 0; i < n; i++) |
| 4520 | { |
| 4521 | ids[i] = context->createQuery(); |
| 4522 | } |
| 4523 | } |
| 4524 | } |
| 4525 | catch(std::bad_alloc&) |
| 4526 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4527 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4528 | } |
| 4529 | } |
| 4530 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4531 | void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) |
| 4532 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4533 | EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4534 | |
| 4535 | try |
| 4536 | { |
| 4537 | if (n < 0) |
| 4538 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4539 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4540 | } |
| 4541 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4542 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4543 | |
| 4544 | if (context) |
| 4545 | { |
| 4546 | for (int i = 0; i < n; i++) |
| 4547 | { |
| 4548 | renderbuffers[i] = context->createRenderbuffer(); |
| 4549 | } |
| 4550 | } |
| 4551 | } |
| 4552 | catch(std::bad_alloc&) |
| 4553 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4554 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4555 | } |
| 4556 | } |
| 4557 | |
| 4558 | void __stdcall glGenTextures(GLsizei n, GLuint* textures) |
| 4559 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4560 | EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4561 | |
| 4562 | try |
| 4563 | { |
| 4564 | if (n < 0) |
| 4565 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4566 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4567 | } |
| 4568 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4569 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4570 | |
| 4571 | if (context) |
| 4572 | { |
| 4573 | for (int i = 0; i < n; i++) |
| 4574 | { |
| 4575 | textures[i] = context->createTexture(); |
| 4576 | } |
| 4577 | } |
| 4578 | } |
| 4579 | catch(std::bad_alloc&) |
| 4580 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4581 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4582 | } |
| 4583 | } |
| 4584 | |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4585 | 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] | 4586 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4587 | 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] | 4588 | "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] | 4589 | program, index, bufsize, length, size, type, name); |
| 4590 | |
| 4591 | try |
| 4592 | { |
| 4593 | if (bufsize < 0) |
| 4594 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4595 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4596 | } |
| 4597 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4598 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4599 | |
| 4600 | if (context) |
| 4601 | { |
| 4602 | gl::Program *programObject = context->getProgram(program); |
| 4603 | |
| 4604 | if (!programObject) |
| 4605 | { |
| 4606 | if (context->getShader(program)) |
| 4607 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4608 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4609 | } |
| 4610 | else |
| 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 | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4613 | } |
| 4614 | } |
| 4615 | |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4616 | if (index >= (GLuint)programObject->getActiveAttributeCount()) |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4617 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4618 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4619 | } |
| 4620 | |
| 4621 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 4622 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4623 | } |
| 4624 | catch(std::bad_alloc&) |
| 4625 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4626 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4627 | } |
| 4628 | } |
| 4629 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4630 | 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] | 4631 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4632 | EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4633 | "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] | 4634 | program, index, bufsize, length, size, type, name); |
| 4635 | |
| 4636 | try |
| 4637 | { |
| 4638 | if (bufsize < 0) |
| 4639 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4640 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4641 | } |
| 4642 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4643 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4644 | |
| 4645 | if (context) |
| 4646 | { |
| 4647 | gl::Program *programObject = context->getProgram(program); |
| 4648 | |
| 4649 | if (!programObject) |
| 4650 | { |
| 4651 | if (context->getShader(program)) |
| 4652 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4653 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4654 | } |
| 4655 | else |
| 4656 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4657 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4658 | } |
| 4659 | } |
| 4660 | |
| 4661 | if (index >= (GLuint)programObject->getActiveUniformCount()) |
| 4662 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4663 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4664 | } |
| 4665 | |
| 4666 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 4667 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4668 | } |
| 4669 | catch(std::bad_alloc&) |
| 4670 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4671 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4672 | } |
| 4673 | } |
| 4674 | |
| 4675 | void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) |
| 4676 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4677 | 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] | 4678 | program, maxcount, count, shaders); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4679 | |
| 4680 | try |
| 4681 | { |
| 4682 | if (maxcount < 0) |
| 4683 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4684 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4685 | } |
| 4686 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4687 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4688 | |
| 4689 | if (context) |
| 4690 | { |
| 4691 | gl::Program *programObject = context->getProgram(program); |
| 4692 | |
| 4693 | if (!programObject) |
| 4694 | { |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4695 | if (context->getShader(program)) |
| 4696 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4697 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4698 | } |
| 4699 | else |
| 4700 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4701 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4702 | } |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4703 | } |
| 4704 | |
| 4705 | return programObject->getAttachedShaders(maxcount, count, shaders); |
| 4706 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4707 | } |
| 4708 | catch(std::bad_alloc&) |
| 4709 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4710 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4711 | } |
| 4712 | } |
| 4713 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4714 | int __stdcall glGetAttribLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4715 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4716 | EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4717 | |
| 4718 | try |
| 4719 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4720 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4721 | |
| 4722 | if (context) |
| 4723 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4724 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4725 | gl::Program *programObject = context->getProgram(program); |
| 4726 | |
| 4727 | if (!programObject) |
| 4728 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4729 | if (context->getShader(program)) |
| 4730 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4731 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4732 | } |
| 4733 | else |
| 4734 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4735 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4736 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4737 | } |
| 4738 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4739 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 4740 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4741 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4742 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4743 | } |
| 4744 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4745 | return programBinary->getAttributeLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4746 | } |
| 4747 | } |
| 4748 | catch(std::bad_alloc&) |
| 4749 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4750 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4751 | } |
| 4752 | |
| 4753 | return -1; |
| 4754 | } |
| 4755 | |
| 4756 | void __stdcall glGetBooleanv(GLenum pname, GLboolean* params) |
| 4757 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4758 | 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] | 4759 | |
| 4760 | try |
| 4761 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4762 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4763 | |
| 4764 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4765 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4766 | if (!(context->getBooleanv(pname, params))) |
| 4767 | { |
| 4768 | GLenum nativeType; |
| 4769 | unsigned int numParams = 0; |
| 4770 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4771 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4772 | |
| 4773 | if (numParams == 0) |
| 4774 | return; // it is known that the pname is valid, but there are no parameters to return |
| 4775 | |
| 4776 | if (nativeType == GL_FLOAT) |
| 4777 | { |
| 4778 | GLfloat *floatParams = NULL; |
| 4779 | floatParams = new GLfloat[numParams]; |
| 4780 | |
| 4781 | context->getFloatv(pname, floatParams); |
| 4782 | |
| 4783 | for (unsigned int i = 0; i < numParams; ++i) |
| 4784 | { |
| 4785 | if (floatParams[i] == 0.0f) |
| 4786 | params[i] = GL_FALSE; |
| 4787 | else |
| 4788 | params[i] = GL_TRUE; |
| 4789 | } |
| 4790 | |
| 4791 | delete [] floatParams; |
| 4792 | } |
| 4793 | else if (nativeType == GL_INT) |
| 4794 | { |
| 4795 | GLint *intParams = NULL; |
| 4796 | intParams = new GLint[numParams]; |
| 4797 | |
| 4798 | context->getIntegerv(pname, intParams); |
| 4799 | |
| 4800 | for (unsigned int i = 0; i < numParams; ++i) |
| 4801 | { |
| 4802 | if (intParams[i] == 0) |
| 4803 | params[i] = GL_FALSE; |
| 4804 | else |
| 4805 | params[i] = GL_TRUE; |
| 4806 | } |
| 4807 | |
| 4808 | delete [] intParams; |
| 4809 | } |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 4810 | else if (nativeType == GL_INT_64_ANGLEX) |
| 4811 | { |
| 4812 | GLint64 *int64Params = NULL; |
| 4813 | int64Params = new GLint64[numParams]; |
| 4814 | |
| 4815 | context->getInteger64v(pname, int64Params); |
| 4816 | |
| 4817 | for (unsigned int i = 0; i < numParams; ++i) |
| 4818 | { |
| 4819 | if (int64Params[i] == 0) |
| 4820 | params[i] = GL_FALSE; |
| 4821 | else |
| 4822 | params[i] = GL_TRUE; |
| 4823 | } |
| 4824 | |
| 4825 | delete [] int64Params; |
| 4826 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4827 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4828 | } |
| 4829 | } |
| 4830 | catch(std::bad_alloc&) |
| 4831 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4832 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4833 | } |
| 4834 | } |
| 4835 | |
| 4836 | void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 4837 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4838 | 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] | 4839 | |
| 4840 | try |
| 4841 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4842 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4843 | |
| 4844 | if (context) |
| 4845 | { |
| 4846 | gl::Buffer *buffer; |
| 4847 | |
| 4848 | switch (target) |
| 4849 | { |
| 4850 | case GL_ARRAY_BUFFER: |
| 4851 | buffer = context->getArrayBuffer(); |
| 4852 | break; |
| 4853 | case GL_ELEMENT_ARRAY_BUFFER: |
| 4854 | buffer = context->getElementArrayBuffer(); |
| 4855 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4856 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4857 | } |
| 4858 | |
| 4859 | if (!buffer) |
| 4860 | { |
| 4861 | // 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] | 4862 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4863 | } |
| 4864 | |
| 4865 | switch (pname) |
| 4866 | { |
| 4867 | case GL_BUFFER_USAGE: |
| 4868 | *params = buffer->usage(); |
| 4869 | break; |
| 4870 | case GL_BUFFER_SIZE: |
| 4871 | *params = buffer->size(); |
| 4872 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4873 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4874 | } |
| 4875 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4876 | } |
| 4877 | catch(std::bad_alloc&) |
| 4878 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4879 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4880 | } |
| 4881 | } |
| 4882 | |
| 4883 | GLenum __stdcall glGetError(void) |
| 4884 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4885 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4886 | |
| 4887 | gl::Context *context = gl::getContext(); |
| 4888 | |
| 4889 | if (context) |
| 4890 | { |
daniel@transgaming.com | 82b2891 | 2011-12-12 21:01:35 +0000 | [diff] [blame] | 4891 | return context->getError(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4892 | } |
| 4893 | |
| 4894 | return GL_NO_ERROR; |
| 4895 | } |
| 4896 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4897 | void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 4898 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4899 | 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] | 4900 | |
| 4901 | try |
| 4902 | { |
| 4903 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4904 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4905 | |
| 4906 | if (context) |
| 4907 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 4908 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4909 | |
| 4910 | if (fenceObject == NULL) |
| 4911 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4912 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4913 | } |
| 4914 | |
Jamie Madill | fb9a740 | 2013-07-26 11:55:01 -0400 | [diff] [blame] | 4915 | if (fenceObject->isFence() != GL_TRUE) |
| 4916 | { |
| 4917 | return gl::error(GL_INVALID_OPERATION); |
| 4918 | } |
| 4919 | |
| 4920 | switch (pname) |
| 4921 | { |
| 4922 | case GL_FENCE_STATUS_NV: |
| 4923 | case GL_FENCE_CONDITION_NV: |
| 4924 | break; |
| 4925 | |
| 4926 | default: return gl::error(GL_INVALID_ENUM); |
| 4927 | } |
| 4928 | |
| 4929 | params[0] = fenceObject->getFencei(pname); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4930 | } |
| 4931 | } |
| 4932 | catch(std::bad_alloc&) |
| 4933 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4934 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4935 | } |
| 4936 | } |
| 4937 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4938 | void __stdcall glGetFloatv(GLenum pname, GLfloat* params) |
| 4939 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4940 | 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] | 4941 | |
| 4942 | try |
| 4943 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4944 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4945 | |
| 4946 | if (context) |
| 4947 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4948 | if (!(context->getFloatv(pname, params))) |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4949 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4950 | GLenum nativeType; |
| 4951 | unsigned int numParams = 0; |
| 4952 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4953 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4954 | |
| 4955 | if (numParams == 0) |
| 4956 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 4957 | |
| 4958 | if (nativeType == GL_BOOL) |
| 4959 | { |
| 4960 | GLboolean *boolParams = NULL; |
| 4961 | boolParams = new GLboolean[numParams]; |
| 4962 | |
| 4963 | context->getBooleanv(pname, boolParams); |
| 4964 | |
| 4965 | for (unsigned int i = 0; i < numParams; ++i) |
| 4966 | { |
| 4967 | if (boolParams[i] == GL_FALSE) |
| 4968 | params[i] = 0.0f; |
| 4969 | else |
| 4970 | params[i] = 1.0f; |
| 4971 | } |
| 4972 | |
| 4973 | delete [] boolParams; |
| 4974 | } |
| 4975 | else if (nativeType == GL_INT) |
| 4976 | { |
| 4977 | GLint *intParams = NULL; |
| 4978 | intParams = new GLint[numParams]; |
| 4979 | |
| 4980 | context->getIntegerv(pname, intParams); |
| 4981 | |
| 4982 | for (unsigned int i = 0; i < numParams; ++i) |
| 4983 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 4984 | params[i] = static_cast<GLfloat>(intParams[i]); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4985 | } |
| 4986 | |
| 4987 | delete [] intParams; |
| 4988 | } |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 4989 | else if (nativeType == GL_INT_64_ANGLEX) |
| 4990 | { |
| 4991 | GLint64 *int64Params = NULL; |
| 4992 | int64Params = new GLint64[numParams]; |
| 4993 | |
| 4994 | context->getInteger64v(pname, int64Params); |
| 4995 | |
| 4996 | for (unsigned int i = 0; i < numParams; ++i) |
| 4997 | { |
| 4998 | params[i] = static_cast<GLfloat>(int64Params[i]); |
| 4999 | } |
| 5000 | |
| 5001 | delete [] int64Params; |
| 5002 | } |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 5003 | } |
| 5004 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5005 | } |
| 5006 | catch(std::bad_alloc&) |
| 5007 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5008 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5009 | } |
| 5010 | } |
| 5011 | |
| 5012 | void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) |
| 5013 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5014 | 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] | 5015 | target, attachment, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5016 | |
| 5017 | try |
| 5018 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5019 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5020 | |
| 5021 | if (context) |
| 5022 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 5023 | 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] | 5024 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5025 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5026 | } |
| 5027 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 5028 | gl::Framebuffer *framebuffer = NULL; |
| 5029 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 5030 | { |
| 5031 | if(context->getReadFramebufferHandle() == 0) |
| 5032 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5033 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 5034 | } |
| 5035 | |
| 5036 | framebuffer = context->getReadFramebuffer(); |
| 5037 | } |
| 5038 | else |
| 5039 | { |
| 5040 | if (context->getDrawFramebufferHandle() == 0) |
| 5041 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5042 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 5043 | } |
| 5044 | |
| 5045 | framebuffer = context->getDrawFramebuffer(); |
| 5046 | } |
| 5047 | |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5048 | GLenum attachmentType; |
| 5049 | GLuint attachmentHandle; |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 5050 | GLuint attachmentLevel; |
| 5051 | GLuint attachmentLayer; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 5052 | |
| 5053 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5054 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 5055 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 5056 | |
| 5057 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 5058 | { |
| 5059 | return gl::error(GL_INVALID_ENUM); |
| 5060 | } |
| 5061 | |
| 5062 | attachmentType = framebuffer->getColorbufferType(colorAttachment); |
| 5063 | attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment); |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 5064 | attachmentLevel = framebuffer->getColorbufferMipLevel(colorAttachment); |
| 5065 | attachmentLayer = framebuffer->getColorbufferLayer(colorAttachment); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 5066 | } |
| 5067 | else |
| 5068 | { |
| 5069 | switch (attachment) |
| 5070 | { |
| 5071 | case GL_DEPTH_ATTACHMENT: |
| 5072 | attachmentType = framebuffer->getDepthbufferType(); |
| 5073 | attachmentHandle = framebuffer->getDepthbufferHandle(); |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 5074 | attachmentLevel = framebuffer->getDepthbufferMipLevel(); |
| 5075 | attachmentLayer = framebuffer->getDepthbufferLayer(); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 5076 | break; |
| 5077 | case GL_STENCIL_ATTACHMENT: |
| 5078 | attachmentType = framebuffer->getStencilbufferType(); |
| 5079 | attachmentHandle = framebuffer->getStencilbufferHandle(); |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 5080 | attachmentLevel = framebuffer->getStencilbufferMipLevel(); |
| 5081 | attachmentLayer = framebuffer->getStencilbufferLayer(); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 5082 | break; |
Geoff Lang | 55ba29c | 2013-07-11 16:57:53 -0400 | [diff] [blame] | 5083 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 5084 | if (context->getClientVersion() < 3) |
| 5085 | { |
| 5086 | return gl::error(GL_INVALID_ENUM); |
| 5087 | } |
| 5088 | if (framebuffer->getDepthbufferHandle() != framebuffer->getStencilbufferHandle()) |
| 5089 | { |
| 5090 | return gl::error(GL_INVALID_OPERATION); |
| 5091 | } |
| 5092 | attachmentType = framebuffer->getDepthStencilbufferType(); |
| 5093 | attachmentHandle = framebuffer->getDepthStencilbufferHandle(); |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 5094 | attachmentLevel = framebuffer->getDepthStencilbufferMipLevel(); |
| 5095 | attachmentLayer = framebuffer->getDepthStencilbufferLayer(); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 5096 | default: return gl::error(GL_INVALID_ENUM); |
| 5097 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5098 | } |
| 5099 | |
| 5100 | GLenum attachmentObjectType; // Type category |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 5101 | if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5102 | { |
| 5103 | attachmentObjectType = attachmentType; |
| 5104 | } |
apatrick@chromium.org | 551022e | 2012-01-23 19:56:54 +0000 | [diff] [blame] | 5105 | else if (gl::IsInternalTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5106 | { |
| 5107 | attachmentObjectType = GL_TEXTURE; |
| 5108 | } |
apatrick@chromium.org | a1d8059 | 2012-01-25 21:52:10 +0000 | [diff] [blame] | 5109 | else |
| 5110 | { |
| 5111 | UNREACHABLE(); |
| 5112 | return; |
| 5113 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5114 | |
| 5115 | switch (pname) |
| 5116 | { |
| 5117 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 5118 | *params = attachmentObjectType; |
| 5119 | break; |
| 5120 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 5121 | if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE) |
| 5122 | { |
| 5123 | *params = attachmentHandle; |
| 5124 | } |
| 5125 | else |
| 5126 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5127 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5128 | } |
| 5129 | break; |
| 5130 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 5131 | if (attachmentObjectType == GL_TEXTURE) |
| 5132 | { |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 5133 | *params = attachmentLevel; |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5134 | } |
| 5135 | else |
| 5136 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5137 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5138 | } |
| 5139 | break; |
| 5140 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 5141 | if (attachmentObjectType == GL_TEXTURE) |
| 5142 | { |
daniel@transgaming.com | 19ffc24 | 2010-05-04 03:35:21 +0000 | [diff] [blame] | 5143 | if (gl::IsCubemapTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5144 | { |
| 5145 | *params = attachmentType; |
| 5146 | } |
| 5147 | else |
| 5148 | { |
| 5149 | *params = 0; |
| 5150 | } |
| 5151 | } |
| 5152 | else |
| 5153 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5154 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5155 | } |
| 5156 | break; |
Geoff Lang | 309c92a | 2013-07-25 16:23:19 -0400 | [diff] [blame] | 5157 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: |
| 5158 | if (context->getClientVersion() < 3) |
| 5159 | { |
| 5160 | return gl::error(GL_INVALID_ENUM); |
| 5161 | } |
| 5162 | if (attachmentObjectType == GL_TEXTURE) |
| 5163 | { |
| 5164 | *params = attachmentLayer; |
| 5165 | } |
| 5166 | else |
| 5167 | { |
| 5168 | return gl::error(GL_INVALID_ENUM); |
| 5169 | } |
| 5170 | break; |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5171 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5172 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5173 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5174 | } |
| 5175 | } |
| 5176 | catch(std::bad_alloc&) |
| 5177 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5178 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5179 | } |
| 5180 | } |
| 5181 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 5182 | GLenum __stdcall glGetGraphicsResetStatusEXT(void) |
| 5183 | { |
| 5184 | EVENT("()"); |
| 5185 | |
| 5186 | try |
| 5187 | { |
| 5188 | gl::Context *context = gl::getContext(); |
| 5189 | |
| 5190 | if (context) |
| 5191 | { |
| 5192 | return context->getResetStatus(); |
| 5193 | } |
| 5194 | |
| 5195 | return GL_NO_ERROR; |
| 5196 | } |
| 5197 | catch(std::bad_alloc&) |
| 5198 | { |
| 5199 | return GL_OUT_OF_MEMORY; |
| 5200 | } |
| 5201 | } |
| 5202 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5203 | void __stdcall glGetIntegerv(GLenum pname, GLint* params) |
| 5204 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5205 | 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] | 5206 | |
| 5207 | try |
| 5208 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5209 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5210 | |
| 5211 | if (context) |
| 5212 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5213 | if (!(context->getIntegerv(pname, params))) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5214 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5215 | GLenum nativeType; |
| 5216 | unsigned int numParams = 0; |
| 5217 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5218 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5219 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5220 | if (numParams == 0) |
| 5221 | return; // it is known that pname is valid, but there are no parameters to return |
| 5222 | |
| 5223 | if (nativeType == GL_BOOL) |
| 5224 | { |
| 5225 | GLboolean *boolParams = NULL; |
| 5226 | boolParams = new GLboolean[numParams]; |
| 5227 | |
| 5228 | context->getBooleanv(pname, boolParams); |
| 5229 | |
| 5230 | for (unsigned int i = 0; i < numParams; ++i) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5231 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5232 | if (boolParams[i] == GL_FALSE) |
| 5233 | params[i] = 0; |
| 5234 | else |
| 5235 | params[i] = 1; |
| 5236 | } |
| 5237 | |
| 5238 | delete [] boolParams; |
| 5239 | } |
| 5240 | else if (nativeType == GL_FLOAT) |
| 5241 | { |
| 5242 | GLfloat *floatParams = NULL; |
| 5243 | floatParams = new GLfloat[numParams]; |
| 5244 | |
| 5245 | context->getFloatv(pname, floatParams); |
| 5246 | |
| 5247 | for (unsigned int i = 0; i < numParams; ++i) |
| 5248 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5249 | // 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] | 5250 | 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] | 5251 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5252 | 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] | 5253 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5254 | else |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5255 | { |
Jamie Madill | af49691 | 2013-07-19 16:36:54 -0400 | [diff] [blame] | 5256 | params[i] = gl::iround<GLint>(floatParams[i]); |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5257 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5258 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5259 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5260 | delete [] floatParams; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5261 | } |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5262 | else if (nativeType == GL_INT_64_ANGLEX) |
| 5263 | { |
| 5264 | GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min()); |
| 5265 | GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max()); |
| 5266 | GLint64 *int64Params = NULL; |
| 5267 | int64Params = new GLint64[numParams]; |
| 5268 | |
| 5269 | context->getInteger64v(pname, int64Params); |
| 5270 | |
| 5271 | for (unsigned int i = 0; i < numParams; ++i) |
| 5272 | { |
| 5273 | GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue); |
| 5274 | params[i] = static_cast<GLint>(clampedValue); |
| 5275 | } |
| 5276 | |
| 5277 | delete [] int64Params; |
| 5278 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5279 | } |
| 5280 | } |
| 5281 | } |
| 5282 | catch(std::bad_alloc&) |
| 5283 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5284 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5285 | } |
| 5286 | } |
| 5287 | |
| 5288 | void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params) |
| 5289 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5290 | 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] | 5291 | |
| 5292 | try |
| 5293 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5294 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5295 | |
| 5296 | if (context) |
| 5297 | { |
| 5298 | gl::Program *programObject = context->getProgram(program); |
| 5299 | |
| 5300 | if (!programObject) |
| 5301 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5302 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5303 | } |
| 5304 | |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 5305 | if (context->getClientVersion() < 3) |
| 5306 | { |
| 5307 | switch (pname) |
| 5308 | { |
| 5309 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 5310 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 5311 | return gl::error(GL_INVALID_ENUM); |
| 5312 | } |
| 5313 | } |
| 5314 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5315 | switch (pname) |
| 5316 | { |
| 5317 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5318 | *params = programObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5319 | return; |
| 5320 | case GL_LINK_STATUS: |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5321 | *params = programObject->isLinked(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5322 | return; |
| 5323 | case GL_VALIDATE_STATUS: |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 5324 | *params = programObject->isValidated(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5325 | return; |
| 5326 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5327 | *params = programObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5328 | return; |
| 5329 | case GL_ATTACHED_SHADERS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5330 | *params = programObject->getAttachedShadersCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5331 | return; |
| 5332 | case GL_ACTIVE_ATTRIBUTES: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 5333 | *params = programObject->getActiveAttributeCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5334 | return; |
| 5335 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 5336 | *params = programObject->getActiveAttributeMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5337 | return; |
| 5338 | case GL_ACTIVE_UNIFORMS: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 5339 | *params = programObject->getActiveUniformCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5340 | return; |
| 5341 | case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 5342 | *params = programObject->getActiveUniformMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5343 | return; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 5344 | case GL_PROGRAM_BINARY_LENGTH_OES: |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 5345 | *params = programObject->getProgramBinaryLength(); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 5346 | return; |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 5347 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 5348 | *params = programObject->getActiveUniformBlockCount(); |
| 5349 | return; |
| 5350 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 5351 | *params = programObject->getActiveUniformBlockMaxLength(); |
| 5352 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5353 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5354 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5355 | } |
| 5356 | } |
| 5357 | } |
| 5358 | catch(std::bad_alloc&) |
| 5359 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5360 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5361 | } |
| 5362 | } |
| 5363 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5364 | void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5365 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5366 | 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] | 5367 | program, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5368 | |
| 5369 | try |
| 5370 | { |
| 5371 | if (bufsize < 0) |
| 5372 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5373 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5374 | } |
| 5375 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5376 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5377 | |
| 5378 | if (context) |
| 5379 | { |
| 5380 | gl::Program *programObject = context->getProgram(program); |
| 5381 | |
| 5382 | if (!programObject) |
| 5383 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5384 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5385 | } |
| 5386 | |
| 5387 | programObject->getInfoLog(bufsize, length, infolog); |
| 5388 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5389 | } |
| 5390 | catch(std::bad_alloc&) |
| 5391 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5392 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5393 | } |
| 5394 | } |
| 5395 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5396 | void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params) |
| 5397 | { |
| 5398 | EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params); |
| 5399 | |
| 5400 | try |
| 5401 | { |
| 5402 | switch (pname) |
| 5403 | { |
| 5404 | case GL_CURRENT_QUERY_EXT: |
| 5405 | break; |
| 5406 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5407 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5408 | } |
| 5409 | |
| 5410 | gl::Context *context = gl::getNonLostContext(); |
| 5411 | |
| 5412 | if (context) |
| 5413 | { |
| 5414 | params[0] = context->getActiveQuery(target); |
| 5415 | } |
| 5416 | } |
| 5417 | catch(std::bad_alloc&) |
| 5418 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5419 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5420 | } |
| 5421 | } |
| 5422 | |
| 5423 | void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) |
| 5424 | { |
| 5425 | EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params); |
| 5426 | |
| 5427 | try |
| 5428 | { |
| 5429 | switch (pname) |
| 5430 | { |
| 5431 | case GL_QUERY_RESULT_EXT: |
| 5432 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5433 | break; |
| 5434 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5435 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5436 | } |
| 5437 | gl::Context *context = gl::getNonLostContext(); |
| 5438 | |
| 5439 | if (context) |
| 5440 | { |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5441 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 5442 | |
| 5443 | if (!queryObject) |
| 5444 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5445 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5446 | } |
| 5447 | |
| 5448 | if (context->getActiveQuery(queryObject->getType()) == id) |
| 5449 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5450 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5451 | } |
| 5452 | |
| 5453 | switch(pname) |
| 5454 | { |
| 5455 | case GL_QUERY_RESULT_EXT: |
| 5456 | params[0] = queryObject->getResult(); |
| 5457 | break; |
| 5458 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5459 | params[0] = queryObject->isResultAvailable(); |
| 5460 | break; |
| 5461 | default: |
| 5462 | ASSERT(false); |
| 5463 | } |
| 5464 | } |
| 5465 | } |
| 5466 | catch(std::bad_alloc&) |
| 5467 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5468 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5469 | } |
| 5470 | } |
| 5471 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5472 | void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5473 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5474 | 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] | 5475 | |
| 5476 | try |
| 5477 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5478 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5479 | |
| 5480 | if (context) |
| 5481 | { |
| 5482 | if (target != GL_RENDERBUFFER) |
| 5483 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5484 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5485 | } |
| 5486 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5487 | if (context->getRenderbufferHandle() == 0) |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5488 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5489 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5490 | } |
| 5491 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5492 | gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle()); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5493 | |
| 5494 | switch (pname) |
| 5495 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5496 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break; |
| 5497 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break; |
| 5498 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break; |
| 5499 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break; |
| 5500 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break; |
| 5501 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break; |
| 5502 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break; |
| 5503 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break; |
| 5504 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break; |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5505 | case GL_RENDERBUFFER_SAMPLES_ANGLE: |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5506 | if (context->getMaxSupportedSamples() != 0) |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5507 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5508 | *params = renderbuffer->getSamples(); |
| 5509 | } |
| 5510 | else |
| 5511 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5512 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5513 | } |
| 5514 | break; |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5515 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5516 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5517 | } |
| 5518 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5519 | } |
| 5520 | catch(std::bad_alloc&) |
| 5521 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5522 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5523 | } |
| 5524 | } |
| 5525 | |
| 5526 | void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params) |
| 5527 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5528 | 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] | 5529 | |
| 5530 | try |
| 5531 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5532 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5533 | |
| 5534 | if (context) |
| 5535 | { |
| 5536 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 5537 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5538 | if (!shaderObject) |
| 5539 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5540 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5541 | } |
| 5542 | |
| 5543 | switch (pname) |
| 5544 | { |
| 5545 | case GL_SHADER_TYPE: |
| 5546 | *params = shaderObject->getType(); |
| 5547 | return; |
| 5548 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5549 | *params = shaderObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5550 | return; |
| 5551 | case GL_COMPILE_STATUS: |
| 5552 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; |
| 5553 | return; |
| 5554 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5555 | *params = shaderObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5556 | return; |
| 5557 | case GL_SHADER_SOURCE_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5558 | *params = shaderObject->getSourceLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5559 | return; |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5560 | case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: |
| 5561 | *params = shaderObject->getTranslatedSourceLength(); |
| 5562 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5563 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5564 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5565 | } |
| 5566 | } |
| 5567 | } |
| 5568 | catch(std::bad_alloc&) |
| 5569 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5570 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5571 | } |
| 5572 | } |
| 5573 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5574 | void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5575 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5576 | 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] | 5577 | shader, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5578 | |
| 5579 | try |
| 5580 | { |
| 5581 | if (bufsize < 0) |
| 5582 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5583 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5584 | } |
| 5585 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5586 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5587 | |
| 5588 | if (context) |
| 5589 | { |
| 5590 | gl::Shader *shaderObject = context->getShader(shader); |
| 5591 | |
| 5592 | if (!shaderObject) |
| 5593 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5594 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5595 | } |
| 5596 | |
| 5597 | shaderObject->getInfoLog(bufsize, length, infolog); |
| 5598 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5599 | } |
| 5600 | catch(std::bad_alloc&) |
| 5601 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5602 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5603 | } |
| 5604 | } |
| 5605 | |
| 5606 | void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) |
| 5607 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5608 | 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] | 5609 | shadertype, precisiontype, range, precision); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5610 | |
| 5611 | try |
| 5612 | { |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5613 | switch (shadertype) |
| 5614 | { |
| 5615 | case GL_VERTEX_SHADER: |
| 5616 | case GL_FRAGMENT_SHADER: |
| 5617 | break; |
| 5618 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5619 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5620 | } |
| 5621 | |
| 5622 | switch (precisiontype) |
| 5623 | { |
| 5624 | case GL_LOW_FLOAT: |
| 5625 | case GL_MEDIUM_FLOAT: |
| 5626 | case GL_HIGH_FLOAT: |
| 5627 | // Assume IEEE 754 precision |
| 5628 | range[0] = 127; |
| 5629 | range[1] = 127; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5630 | *precision = 23; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5631 | break; |
| 5632 | case GL_LOW_INT: |
| 5633 | case GL_MEDIUM_INT: |
| 5634 | case GL_HIGH_INT: |
| 5635 | // Some (most) hardware only supports single-precision floating-point numbers, |
| 5636 | // which can accurately represent integers up to +/-16777216 |
| 5637 | range[0] = 24; |
| 5638 | range[1] = 24; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5639 | *precision = 0; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5640 | break; |
| 5641 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5642 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5643 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5644 | } |
| 5645 | catch(std::bad_alloc&) |
| 5646 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5647 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5648 | } |
| 5649 | } |
| 5650 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5651 | void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5652 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5653 | 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] | 5654 | shader, bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5655 | |
| 5656 | try |
| 5657 | { |
| 5658 | if (bufsize < 0) |
| 5659 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5660 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5661 | } |
| 5662 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5663 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5664 | |
| 5665 | if (context) |
| 5666 | { |
| 5667 | gl::Shader *shaderObject = context->getShader(shader); |
| 5668 | |
| 5669 | if (!shaderObject) |
| 5670 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5671 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5672 | } |
| 5673 | |
| 5674 | shaderObject->getSource(bufsize, length, source); |
| 5675 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5676 | } |
| 5677 | catch(std::bad_alloc&) |
| 5678 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5679 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5680 | } |
| 5681 | } |
| 5682 | |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5683 | void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
| 5684 | { |
| 5685 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)", |
| 5686 | shader, bufsize, length, source); |
| 5687 | |
| 5688 | try |
| 5689 | { |
| 5690 | if (bufsize < 0) |
| 5691 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5692 | return gl::error(GL_INVALID_VALUE); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5693 | } |
| 5694 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5695 | gl::Context *context = gl::getNonLostContext(); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5696 | |
| 5697 | if (context) |
| 5698 | { |
| 5699 | gl::Shader *shaderObject = context->getShader(shader); |
| 5700 | |
| 5701 | if (!shaderObject) |
| 5702 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5703 | return gl::error(GL_INVALID_OPERATION); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5704 | } |
| 5705 | |
| 5706 | shaderObject->getTranslatedSource(bufsize, length, source); |
| 5707 | } |
| 5708 | } |
| 5709 | catch(std::bad_alloc&) |
| 5710 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5711 | return gl::error(GL_OUT_OF_MEMORY); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5712 | } |
| 5713 | } |
| 5714 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5715 | const GLubyte* __stdcall glGetString(GLenum name) |
| 5716 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5717 | EVENT("(GLenum name = 0x%X)", name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5718 | |
| 5719 | try |
| 5720 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5721 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3e4c600 | 2010-05-05 18:50:13 +0000 | [diff] [blame] | 5722 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5723 | switch (name) |
| 5724 | { |
| 5725 | case GL_VENDOR: |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 5726 | return (GLubyte*)"Google Inc."; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5727 | case GL_RENDERER: |
daniel@transgaming.com | c23ff64 | 2011-08-16 20:28:45 +0000 | [diff] [blame] | 5728 | return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5729 | case GL_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5730 | if (context->getClientVersion() == 2) |
| 5731 | { |
| 5732 | return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")"; |
| 5733 | } |
| 5734 | else |
| 5735 | { |
| 5736 | return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")"; |
| 5737 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5738 | case GL_SHADING_LANGUAGE_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5739 | if (context->getClientVersion() == 2) |
| 5740 | { |
| 5741 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")"; |
| 5742 | } |
| 5743 | else |
| 5744 | { |
| 5745 | return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")"; |
| 5746 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5747 | case GL_EXTENSIONS: |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 5748 | return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : ""); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5749 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5750 | return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5751 | } |
| 5752 | } |
| 5753 | catch(std::bad_alloc&) |
| 5754 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5755 | return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5756 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5757 | } |
| 5758 | |
| 5759 | void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) |
| 5760 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5761 | 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] | 5762 | |
| 5763 | try |
| 5764 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5765 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5766 | |
| 5767 | if (context) |
| 5768 | { |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 5769 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5770 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 5771 | if (!texture) |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5772 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5773 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5774 | } |
| 5775 | |
| 5776 | switch (pname) |
| 5777 | { |
| 5778 | case GL_TEXTURE_MAG_FILTER: |
| 5779 | *params = (GLfloat)texture->getMagFilter(); |
| 5780 | break; |
| 5781 | case GL_TEXTURE_MIN_FILTER: |
| 5782 | *params = (GLfloat)texture->getMinFilter(); |
| 5783 | break; |
| 5784 | case GL_TEXTURE_WRAP_S: |
| 5785 | *params = (GLfloat)texture->getWrapS(); |
| 5786 | break; |
| 5787 | case GL_TEXTURE_WRAP_T: |
| 5788 | *params = (GLfloat)texture->getWrapT(); |
| 5789 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5790 | case GL_TEXTURE_WRAP_R: |
| 5791 | if (context->getClientVersion() < 3) |
| 5792 | { |
| 5793 | return gl::error(GL_INVALID_ENUM); |
| 5794 | } |
| 5795 | *params = (GLfloat)texture->getWrapR(); |
| 5796 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5797 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5798 | // 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] | 5799 | *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE); |
| 5800 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5801 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5802 | if (context->getClientVersion() < 3) |
| 5803 | { |
| 5804 | return gl::error(GL_INVALID_ENUM); |
| 5805 | } |
| 5806 | *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0); |
| 5807 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5808 | case GL_TEXTURE_USAGE_ANGLE: |
| 5809 | *params = (GLfloat)texture->getUsage(); |
| 5810 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5811 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5812 | if (!context->supportsTextureFilterAnisotropy()) |
| 5813 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5814 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5815 | } |
| 5816 | *params = (GLfloat)texture->getMaxAnisotropy(); |
| 5817 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5818 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5819 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5820 | } |
| 5821 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5822 | } |
| 5823 | catch(std::bad_alloc&) |
| 5824 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5825 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5826 | } |
| 5827 | } |
| 5828 | |
| 5829 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5830 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5831 | 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] | 5832 | |
| 5833 | try |
| 5834 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5835 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5836 | |
| 5837 | if (context) |
| 5838 | { |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 5839 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5840 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 5841 | if (!texture) |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5842 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5843 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5844 | } |
| 5845 | |
| 5846 | switch (pname) |
| 5847 | { |
| 5848 | case GL_TEXTURE_MAG_FILTER: |
| 5849 | *params = texture->getMagFilter(); |
| 5850 | break; |
| 5851 | case GL_TEXTURE_MIN_FILTER: |
| 5852 | *params = texture->getMinFilter(); |
| 5853 | break; |
| 5854 | case GL_TEXTURE_WRAP_S: |
| 5855 | *params = texture->getWrapS(); |
| 5856 | break; |
| 5857 | case GL_TEXTURE_WRAP_T: |
| 5858 | *params = texture->getWrapT(); |
| 5859 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5860 | case GL_TEXTURE_WRAP_R: |
| 5861 | if (context->getClientVersion() < 3) |
| 5862 | { |
| 5863 | return gl::error(GL_INVALID_ENUM); |
| 5864 | } |
| 5865 | *params = texture->getWrapR(); |
| 5866 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5867 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5868 | // 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] | 5869 | *params = texture->isImmutable() ? GL_TRUE : GL_FALSE; |
| 5870 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5871 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5872 | if (context->getClientVersion() < 3) |
| 5873 | { |
| 5874 | return gl::error(GL_INVALID_ENUM); |
| 5875 | } |
| 5876 | *params = texture->isImmutable() ? texture->levelCount() : 0; |
| 5877 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5878 | case GL_TEXTURE_USAGE_ANGLE: |
| 5879 | *params = texture->getUsage(); |
| 5880 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5881 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5882 | if (!context->supportsTextureFilterAnisotropy()) |
| 5883 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5884 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5885 | } |
| 5886 | *params = (GLint)texture->getMaxAnisotropy(); |
| 5887 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 5888 | |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5889 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5890 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5891 | } |
| 5892 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5893 | } |
| 5894 | catch(std::bad_alloc&) |
| 5895 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5896 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5897 | } |
| 5898 | } |
| 5899 | |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5900 | void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
| 5901 | { |
| 5902 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)", |
| 5903 | program, location, bufSize, params); |
| 5904 | |
| 5905 | try |
| 5906 | { |
| 5907 | if (bufSize < 0) |
| 5908 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5909 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5910 | } |
| 5911 | |
| 5912 | gl::Context *context = gl::getNonLostContext(); |
| 5913 | |
| 5914 | if (context) |
| 5915 | { |
| 5916 | if (program == 0) |
| 5917 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5918 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5919 | } |
| 5920 | |
| 5921 | gl::Program *programObject = context->getProgram(program); |
| 5922 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5923 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5924 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5925 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5926 | } |
| 5927 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5928 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5929 | if (!programBinary) |
| 5930 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5931 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5932 | } |
| 5933 | |
| 5934 | if (!programBinary->getUniformfv(location, &bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5935 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5936 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5937 | } |
| 5938 | } |
| 5939 | } |
| 5940 | catch(std::bad_alloc&) |
| 5941 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5942 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5943 | } |
| 5944 | } |
| 5945 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5946 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 5947 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5948 | 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] | 5949 | |
| 5950 | try |
| 5951 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5952 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5953 | |
| 5954 | if (context) |
| 5955 | { |
| 5956 | if (program == 0) |
| 5957 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5958 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5959 | } |
| 5960 | |
| 5961 | gl::Program *programObject = context->getProgram(program); |
| 5962 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5963 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5964 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5965 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5966 | } |
| 5967 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5968 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5969 | if (!programBinary) |
| 5970 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5971 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5972 | } |
| 5973 | |
| 5974 | if (!programBinary->getUniformfv(location, NULL, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5975 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5976 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5977 | } |
| 5978 | } |
| 5979 | } |
| 5980 | catch(std::bad_alloc&) |
| 5981 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5982 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5983 | } |
| 5984 | } |
| 5985 | |
| 5986 | void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) |
| 5987 | { |
| 5988 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)", |
| 5989 | program, location, bufSize, params); |
| 5990 | |
| 5991 | try |
| 5992 | { |
| 5993 | if (bufSize < 0) |
| 5994 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5995 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5996 | } |
| 5997 | |
| 5998 | gl::Context *context = gl::getNonLostContext(); |
| 5999 | |
| 6000 | if (context) |
| 6001 | { |
| 6002 | if (program == 0) |
| 6003 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6004 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 6005 | } |
| 6006 | |
| 6007 | gl::Program *programObject = context->getProgram(program); |
| 6008 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 6009 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 6010 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6011 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 6012 | } |
| 6013 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6014 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 6015 | if (!programBinary) |
| 6016 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6017 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6018 | } |
| 6019 | |
| 6020 | if (!programBinary->getUniformiv(location, &bufSize, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6021 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6022 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6023 | } |
| 6024 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6025 | } |
| 6026 | catch(std::bad_alloc&) |
| 6027 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6028 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6029 | } |
| 6030 | } |
| 6031 | |
| 6032 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 6033 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6034 | 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] | 6035 | |
| 6036 | try |
| 6037 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6038 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6039 | |
| 6040 | if (context) |
| 6041 | { |
| 6042 | if (program == 0) |
| 6043 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6044 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6045 | } |
| 6046 | |
| 6047 | gl::Program *programObject = context->getProgram(program); |
| 6048 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 6049 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6050 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6051 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6052 | } |
| 6053 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6054 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 6055 | if (!programBinary) |
| 6056 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6057 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6058 | } |
| 6059 | |
| 6060 | if (!programBinary->getUniformiv(location, NULL, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6061 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6062 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6063 | } |
| 6064 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6065 | } |
| 6066 | catch(std::bad_alloc&) |
| 6067 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6068 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6069 | } |
| 6070 | } |
| 6071 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6072 | int __stdcall glGetUniformLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6073 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6074 | 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] | 6075 | |
| 6076 | try |
| 6077 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6078 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6079 | |
| 6080 | if (strstr(name, "gl_") == name) |
| 6081 | { |
| 6082 | return -1; |
| 6083 | } |
| 6084 | |
| 6085 | if (context) |
| 6086 | { |
| 6087 | gl::Program *programObject = context->getProgram(program); |
| 6088 | |
| 6089 | if (!programObject) |
| 6090 | { |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 6091 | if (context->getShader(program)) |
| 6092 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6093 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 6094 | } |
| 6095 | else |
| 6096 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6097 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 6098 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6099 | } |
| 6100 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6101 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 6102 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6103 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6104 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6105 | } |
| 6106 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6107 | return programBinary->getUniformLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6108 | } |
| 6109 | } |
| 6110 | catch(std::bad_alloc&) |
| 6111 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6112 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6113 | } |
| 6114 | |
| 6115 | return -1; |
| 6116 | } |
| 6117 | |
| 6118 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 6119 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6120 | 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] | 6121 | |
| 6122 | try |
| 6123 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6124 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6125 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6126 | if (context) |
| 6127 | { |
| 6128 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6129 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6130 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6131 | } |
| 6132 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 6133 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6134 | |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6135 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6136 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6137 | return; |
| 6138 | } |
| 6139 | |
| 6140 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 6141 | { |
| 6142 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 6143 | for (int i = 0; i < 4; ++i) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6144 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6145 | params[i] = currentValueData.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6146 | } |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6147 | } |
| 6148 | else |
| 6149 | { |
| 6150 | *params = attribState.querySingleParameter<GLfloat>(pname); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6151 | } |
| 6152 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6153 | } |
| 6154 | catch(std::bad_alloc&) |
| 6155 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6156 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6157 | } |
| 6158 | } |
| 6159 | |
| 6160 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 6161 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6162 | 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] | 6163 | |
| 6164 | try |
| 6165 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6166 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6167 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6168 | if (context) |
| 6169 | { |
| 6170 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6171 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6172 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6173 | } |
| 6174 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 6175 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6176 | |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6177 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6178 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6179 | return; |
| 6180 | } |
| 6181 | |
| 6182 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 6183 | { |
| 6184 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 6185 | for (int i = 0; i < 4; ++i) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6186 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6187 | float currentValue = currentValueData.FloatValues[i]; |
Jamie Madill | af49691 | 2013-07-19 16:36:54 -0400 | [diff] [blame] | 6188 | params[i] = gl::iround<GLint>(currentValue); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6189 | } |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6190 | } |
| 6191 | else |
| 6192 | { |
| 6193 | *params = attribState.querySingleParameter<GLint>(pname); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6194 | } |
| 6195 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6196 | } |
| 6197 | catch(std::bad_alloc&) |
| 6198 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6199 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6200 | } |
| 6201 | } |
| 6202 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6203 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6204 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6205 | 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] | 6206 | |
| 6207 | try |
| 6208 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6209 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6210 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6211 | if (context) |
| 6212 | { |
| 6213 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6214 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6215 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6216 | } |
| 6217 | |
| 6218 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) |
| 6219 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6220 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6221 | } |
| 6222 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6223 | *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index)); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6224 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6225 | } |
| 6226 | catch(std::bad_alloc&) |
| 6227 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6228 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6229 | } |
| 6230 | } |
| 6231 | |
| 6232 | void __stdcall glHint(GLenum target, GLenum mode) |
| 6233 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6234 | EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6235 | |
| 6236 | try |
| 6237 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6238 | switch (mode) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6239 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6240 | case GL_FASTEST: |
| 6241 | case GL_NICEST: |
| 6242 | case GL_DONT_CARE: |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6243 | break; |
| 6244 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6245 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6246 | } |
| 6247 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6248 | gl::Context *context = gl::getNonLostContext(); |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6249 | switch (target) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6250 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6251 | case GL_GENERATE_MIPMAP_HINT: |
| 6252 | if (context) context->setGenerateMipmapHint(mode); |
| 6253 | break; |
| 6254 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 6255 | if (context) context->setFragmentShaderDerivativeHint(mode); |
| 6256 | break; |
| 6257 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6258 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6259 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 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); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6264 | } |
| 6265 | } |
| 6266 | |
| 6267 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 6268 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6269 | EVENT("(GLuint buffer = %d)", buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6270 | |
| 6271 | try |
| 6272 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6273 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6274 | |
| 6275 | if (context && buffer) |
| 6276 | { |
| 6277 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 6278 | |
| 6279 | if (bufferObject) |
| 6280 | { |
| 6281 | return GL_TRUE; |
| 6282 | } |
| 6283 | } |
| 6284 | } |
| 6285 | catch(std::bad_alloc&) |
| 6286 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6287 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6288 | } |
| 6289 | |
| 6290 | return GL_FALSE; |
| 6291 | } |
| 6292 | |
| 6293 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 6294 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6295 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6296 | |
| 6297 | try |
| 6298 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6299 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6300 | |
| 6301 | if (context) |
| 6302 | { |
| 6303 | switch (cap) |
| 6304 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6305 | case GL_CULL_FACE: return context->isCullFaceEnabled(); |
| 6306 | case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled(); |
| 6307 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled(); |
| 6308 | case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled(); |
| 6309 | case GL_SCISSOR_TEST: return context->isScissorTestEnabled(); |
| 6310 | case GL_STENCIL_TEST: return context->isStencilTestEnabled(); |
| 6311 | case GL_DEPTH_TEST: return context->isDepthTestEnabled(); |
| 6312 | case GL_BLEND: return context->isBlendEnabled(); |
| 6313 | case GL_DITHER: return context->isDitherEnabled(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6314 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6315 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6316 | } |
| 6317 | } |
| 6318 | } |
| 6319 | catch(std::bad_alloc&) |
| 6320 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6321 | return gl::error(GL_OUT_OF_MEMORY, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6322 | } |
| 6323 | |
| 6324 | return false; |
| 6325 | } |
| 6326 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6327 | GLboolean __stdcall glIsFenceNV(GLuint fence) |
| 6328 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6329 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6330 | |
| 6331 | try |
| 6332 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6333 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6334 | |
| 6335 | if (context) |
| 6336 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 6337 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6338 | |
| 6339 | if (fenceObject == NULL) |
| 6340 | { |
| 6341 | return GL_FALSE; |
| 6342 | } |
| 6343 | |
| 6344 | return fenceObject->isFence(); |
| 6345 | } |
| 6346 | } |
| 6347 | catch(std::bad_alloc&) |
| 6348 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6349 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6350 | } |
| 6351 | |
| 6352 | return GL_FALSE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6353 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6354 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6355 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 6356 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6357 | EVENT("(GLuint framebuffer = %d)", framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6358 | |
| 6359 | try |
| 6360 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6361 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6362 | |
| 6363 | if (context && framebuffer) |
| 6364 | { |
| 6365 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 6366 | |
| 6367 | if (framebufferObject) |
| 6368 | { |
| 6369 | return GL_TRUE; |
| 6370 | } |
| 6371 | } |
| 6372 | } |
| 6373 | catch(std::bad_alloc&) |
| 6374 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6375 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6376 | } |
| 6377 | |
| 6378 | return GL_FALSE; |
| 6379 | } |
| 6380 | |
| 6381 | GLboolean __stdcall glIsProgram(GLuint program) |
| 6382 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6383 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6384 | |
| 6385 | try |
| 6386 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6387 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6388 | |
| 6389 | if (context && program) |
| 6390 | { |
| 6391 | gl::Program *programObject = context->getProgram(program); |
| 6392 | |
| 6393 | if (programObject) |
| 6394 | { |
| 6395 | return GL_TRUE; |
| 6396 | } |
| 6397 | } |
| 6398 | } |
| 6399 | catch(std::bad_alloc&) |
| 6400 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6401 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6402 | } |
| 6403 | |
| 6404 | return GL_FALSE; |
| 6405 | } |
| 6406 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 6407 | GLboolean __stdcall glIsQueryEXT(GLuint id) |
| 6408 | { |
| 6409 | EVENT("(GLuint id = %d)", id); |
| 6410 | |
| 6411 | try |
| 6412 | { |
| 6413 | if (id == 0) |
| 6414 | { |
| 6415 | return GL_FALSE; |
| 6416 | } |
| 6417 | |
| 6418 | gl::Context *context = gl::getNonLostContext(); |
| 6419 | |
| 6420 | if (context) |
| 6421 | { |
| 6422 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 6423 | |
| 6424 | if (queryObject) |
| 6425 | { |
| 6426 | return GL_TRUE; |
| 6427 | } |
| 6428 | } |
| 6429 | } |
| 6430 | catch(std::bad_alloc&) |
| 6431 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6432 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 6433 | } |
| 6434 | |
| 6435 | return GL_FALSE; |
| 6436 | } |
| 6437 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6438 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 6439 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6440 | EVENT("(GLuint renderbuffer = %d)", renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6441 | |
| 6442 | try |
| 6443 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6444 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6445 | |
| 6446 | if (context && renderbuffer) |
| 6447 | { |
| 6448 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 6449 | |
| 6450 | if (renderbufferObject) |
| 6451 | { |
| 6452 | return GL_TRUE; |
| 6453 | } |
| 6454 | } |
| 6455 | } |
| 6456 | catch(std::bad_alloc&) |
| 6457 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6458 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6459 | } |
| 6460 | |
| 6461 | return GL_FALSE; |
| 6462 | } |
| 6463 | |
| 6464 | GLboolean __stdcall glIsShader(GLuint shader) |
| 6465 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6466 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6467 | |
| 6468 | try |
| 6469 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6470 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6471 | |
| 6472 | if (context && shader) |
| 6473 | { |
| 6474 | gl::Shader *shaderObject = context->getShader(shader); |
| 6475 | |
| 6476 | if (shaderObject) |
| 6477 | { |
| 6478 | return GL_TRUE; |
| 6479 | } |
| 6480 | } |
| 6481 | } |
| 6482 | catch(std::bad_alloc&) |
| 6483 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6484 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6485 | } |
| 6486 | |
| 6487 | return GL_FALSE; |
| 6488 | } |
| 6489 | |
| 6490 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 6491 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6492 | EVENT("(GLuint texture = %d)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6493 | |
| 6494 | try |
| 6495 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6496 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6497 | |
| 6498 | if (context && texture) |
| 6499 | { |
| 6500 | gl::Texture *textureObject = context->getTexture(texture); |
| 6501 | |
| 6502 | if (textureObject) |
| 6503 | { |
| 6504 | return GL_TRUE; |
| 6505 | } |
| 6506 | } |
| 6507 | } |
| 6508 | catch(std::bad_alloc&) |
| 6509 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6510 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6511 | } |
| 6512 | |
| 6513 | return GL_FALSE; |
| 6514 | } |
| 6515 | |
| 6516 | void __stdcall glLineWidth(GLfloat width) |
| 6517 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6518 | EVENT("(GLfloat width = %f)", width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6519 | |
| 6520 | try |
| 6521 | { |
| 6522 | if (width <= 0.0f) |
| 6523 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6524 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6525 | } |
| 6526 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6527 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 6528 | |
| 6529 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6530 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6531 | context->setLineWidth(width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6532 | } |
| 6533 | } |
| 6534 | catch(std::bad_alloc&) |
| 6535 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6536 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6537 | } |
| 6538 | } |
| 6539 | |
| 6540 | void __stdcall glLinkProgram(GLuint program) |
| 6541 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6542 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6543 | |
| 6544 | try |
| 6545 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6546 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6547 | |
| 6548 | if (context) |
| 6549 | { |
| 6550 | gl::Program *programObject = context->getProgram(program); |
| 6551 | |
| 6552 | if (!programObject) |
| 6553 | { |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6554 | if (context->getShader(program)) |
| 6555 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6556 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6557 | } |
| 6558 | else |
| 6559 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6560 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6561 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6562 | } |
| 6563 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 6564 | context->linkProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6565 | } |
| 6566 | } |
| 6567 | catch(std::bad_alloc&) |
| 6568 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6569 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6570 | } |
| 6571 | } |
| 6572 | |
| 6573 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 6574 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6575 | EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6576 | |
| 6577 | try |
| 6578 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6579 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6580 | |
| 6581 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6582 | { |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6583 | switch (pname) |
| 6584 | { |
| 6585 | case GL_UNPACK_ALIGNMENT: |
| 6586 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6587 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6588 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6589 | } |
| 6590 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6591 | context->setUnpackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6592 | break; |
| 6593 | |
| 6594 | case GL_PACK_ALIGNMENT: |
| 6595 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6596 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6597 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6598 | } |
| 6599 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6600 | context->setPackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6601 | break; |
| 6602 | |
bsalomon@google.com | 56d46ab | 2011-11-23 14:53:10 +0000 | [diff] [blame] | 6603 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 6604 | context->setPackReverseRowOrder(param != 0); |
| 6605 | break; |
| 6606 | |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6607 | case GL_UNPACK_IMAGE_HEIGHT: |
| 6608 | case GL_UNPACK_SKIP_IMAGES: |
| 6609 | case GL_UNPACK_ROW_LENGTH: |
| 6610 | case GL_UNPACK_SKIP_ROWS: |
| 6611 | case GL_UNPACK_SKIP_PIXELS: |
| 6612 | case GL_PACK_ROW_LENGTH: |
| 6613 | case GL_PACK_SKIP_ROWS: |
| 6614 | case GL_PACK_SKIP_PIXELS: |
| 6615 | if (context->getClientVersion() < 3) |
| 6616 | { |
| 6617 | return gl::error(GL_INVALID_ENUM); |
| 6618 | } |
| 6619 | UNIMPLEMENTED(); |
| 6620 | break; |
| 6621 | |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6622 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6623 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6624 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6625 | } |
| 6626 | } |
| 6627 | catch(std::bad_alloc&) |
| 6628 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6629 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6630 | } |
| 6631 | } |
| 6632 | |
| 6633 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 6634 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6635 | EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6636 | |
| 6637 | try |
| 6638 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6639 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aede630 | 2010-04-29 03:35:48 +0000 | [diff] [blame] | 6640 | |
| 6641 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6642 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6643 | context->setPolygonOffsetParams(factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6644 | } |
| 6645 | } |
| 6646 | catch(std::bad_alloc&) |
| 6647 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6648 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6649 | } |
| 6650 | } |
| 6651 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6652 | void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6653 | GLenum format, GLenum type, GLsizei bufSize, |
| 6654 | GLvoid *data) |
| 6655 | { |
| 6656 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
| 6657 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)", |
| 6658 | x, y, width, height, format, type, bufSize, data); |
| 6659 | |
| 6660 | try |
| 6661 | { |
| 6662 | if (width < 0 || height < 0 || bufSize < 0) |
| 6663 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6664 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6665 | } |
| 6666 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6667 | gl::Context *context = gl::getNonLostContext(); |
| 6668 | |
| 6669 | if (context) |
| 6670 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6671 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6672 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6673 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6674 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6675 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6676 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6677 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6678 | return; |
| 6679 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6680 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6681 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6682 | |
| 6683 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6684 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6685 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6686 | } |
| 6687 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6688 | context->readPixels(x, y, width, height, format, type, &bufSize, data); |
| 6689 | } |
| 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 | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6694 | } |
| 6695 | } |
| 6696 | |
| 6697 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6698 | GLenum format, GLenum type, GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6699 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6700 | 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] | 6701 | "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] | 6702 | x, y, width, height, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6703 | |
| 6704 | try |
| 6705 | { |
| 6706 | if (width < 0 || height < 0) |
| 6707 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6708 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6709 | } |
| 6710 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6711 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6712 | |
| 6713 | if (context) |
| 6714 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6715 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6716 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6717 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6718 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6719 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6720 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6721 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6722 | return; |
| 6723 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6724 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6725 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6726 | |
| 6727 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6728 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6729 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6730 | } |
| 6731 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6732 | context->readPixels(x, y, width, height, format, type, NULL, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6733 | } |
| 6734 | } |
| 6735 | catch(std::bad_alloc&) |
| 6736 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6737 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6738 | } |
| 6739 | } |
| 6740 | |
| 6741 | void __stdcall glReleaseShaderCompiler(void) |
| 6742 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6743 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6744 | |
| 6745 | try |
| 6746 | { |
| 6747 | gl::Shader::releaseCompiler(); |
| 6748 | } |
| 6749 | catch(std::bad_alloc&) |
| 6750 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6751 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6752 | } |
| 6753 | } |
| 6754 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6755 | 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] | 6756 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6757 | 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] | 6758 | target, samples, internalformat, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6759 | |
| 6760 | try |
| 6761 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6762 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6763 | |
| 6764 | if (context) |
| 6765 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6766 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 6767 | width, height, true)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6768 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6769 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6770 | } |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 6771 | |
| 6772 | context->setRenderbufferStorage(width, height, internalformat, samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6773 | } |
| 6774 | } |
| 6775 | catch(std::bad_alloc&) |
| 6776 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6777 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6778 | } |
| 6779 | } |
| 6780 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6781 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 6782 | { |
| 6783 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height); |
| 6784 | } |
| 6785 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6786 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 6787 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6788 | EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6789 | |
| 6790 | try |
| 6791 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6792 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6793 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6794 | if (context) |
| 6795 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 6796 | context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6797 | } |
| 6798 | } |
| 6799 | catch(std::bad_alloc&) |
| 6800 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6801 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6802 | } |
| 6803 | } |
| 6804 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6805 | void __stdcall glSetFenceNV(GLuint fence, GLenum condition) |
| 6806 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6807 | EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6808 | |
| 6809 | try |
| 6810 | { |
| 6811 | if (condition != GL_ALL_COMPLETED_NV) |
| 6812 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6813 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6814 | } |
| 6815 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6816 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6817 | |
| 6818 | if (context) |
| 6819 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 6820 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6821 | |
| 6822 | if (fenceObject == NULL) |
| 6823 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6824 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6825 | } |
| 6826 | |
| 6827 | fenceObject->setFence(condition); |
| 6828 | } |
| 6829 | } |
| 6830 | catch(std::bad_alloc&) |
| 6831 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6832 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6833 | } |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6834 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6835 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6836 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 6837 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6838 | 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] | 6839 | |
| 6840 | try |
| 6841 | { |
| 6842 | if (width < 0 || height < 0) |
| 6843 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6844 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6845 | } |
| 6846 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6847 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6848 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6849 | if (context) |
| 6850 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6851 | context->setScissorParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6852 | } |
| 6853 | } |
| 6854 | catch(std::bad_alloc&) |
| 6855 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6856 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6857 | } |
| 6858 | } |
| 6859 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6860 | 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] | 6861 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6862 | 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] | 6863 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 6864 | n, shaders, binaryformat, binary, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6865 | |
| 6866 | try |
| 6867 | { |
daniel@transgaming.com | d1f667f | 2010-04-29 03:38:52 +0000 | [diff] [blame] | 6868 | // No binary shader formats are supported. |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6869 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6870 | } |
| 6871 | catch(std::bad_alloc&) |
| 6872 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6873 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6874 | } |
| 6875 | } |
| 6876 | |
shannon.woods%transgaming.com@gtempaccount.com | 5f33933 | 2013-04-13 03:29:02 +0000 | [diff] [blame] | 6877 | 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] | 6878 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6879 | 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] | 6880 | shader, count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6881 | |
| 6882 | try |
| 6883 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6884 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6885 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6886 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6887 | } |
| 6888 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6889 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6890 | |
| 6891 | if (context) |
| 6892 | { |
| 6893 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6894 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6895 | if (!shaderObject) |
| 6896 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6897 | if (context->getProgram(shader)) |
| 6898 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6899 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6900 | } |
| 6901 | else |
| 6902 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6903 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6904 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6905 | } |
| 6906 | |
| 6907 | shaderObject->setSource(count, string, length); |
| 6908 | } |
| 6909 | } |
| 6910 | catch(std::bad_alloc&) |
| 6911 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6912 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6913 | } |
| 6914 | } |
| 6915 | |
| 6916 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 6917 | { |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6918 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6919 | } |
| 6920 | |
| 6921 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 6922 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6923 | 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] | 6924 | |
| 6925 | try |
| 6926 | { |
| 6927 | switch (face) |
| 6928 | { |
| 6929 | case GL_FRONT: |
| 6930 | case GL_BACK: |
| 6931 | case GL_FRONT_AND_BACK: |
| 6932 | break; |
| 6933 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6934 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6935 | } |
| 6936 | |
| 6937 | switch (func) |
| 6938 | { |
| 6939 | case GL_NEVER: |
| 6940 | case GL_ALWAYS: |
| 6941 | case GL_LESS: |
| 6942 | case GL_LEQUAL: |
| 6943 | case GL_EQUAL: |
| 6944 | case GL_GEQUAL: |
| 6945 | case GL_GREATER: |
| 6946 | case GL_NOTEQUAL: |
| 6947 | break; |
| 6948 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6949 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6950 | } |
| 6951 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6952 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6953 | |
| 6954 | if (context) |
| 6955 | { |
| 6956 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6957 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6958 | context->setStencilParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6959 | } |
| 6960 | |
| 6961 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6962 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6963 | context->setStencilBackParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6964 | } |
| 6965 | } |
| 6966 | } |
| 6967 | catch(std::bad_alloc&) |
| 6968 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6969 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6970 | } |
| 6971 | } |
| 6972 | |
| 6973 | void __stdcall glStencilMask(GLuint mask) |
| 6974 | { |
| 6975 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 6976 | } |
| 6977 | |
| 6978 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 6979 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6980 | EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6981 | |
| 6982 | try |
| 6983 | { |
| 6984 | switch (face) |
| 6985 | { |
| 6986 | case GL_FRONT: |
| 6987 | case GL_BACK: |
| 6988 | case GL_FRONT_AND_BACK: |
| 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 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6994 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6995 | |
| 6996 | if (context) |
| 6997 | { |
| 6998 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6999 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7000 | context->setStencilWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7001 | } |
| 7002 | |
| 7003 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 7004 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7005 | context->setStencilBackWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7006 | } |
| 7007 | } |
| 7008 | } |
| 7009 | catch(std::bad_alloc&) |
| 7010 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7011 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7012 | } |
| 7013 | } |
| 7014 | |
| 7015 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 7016 | { |
| 7017 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 7018 | } |
| 7019 | |
| 7020 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 7021 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7022 | 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] | 7023 | face, fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7024 | |
| 7025 | try |
| 7026 | { |
| 7027 | switch (face) |
| 7028 | { |
| 7029 | case GL_FRONT: |
| 7030 | case GL_BACK: |
| 7031 | case GL_FRONT_AND_BACK: |
| 7032 | break; |
| 7033 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7034 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7035 | } |
| 7036 | |
| 7037 | switch (fail) |
| 7038 | { |
| 7039 | case GL_ZERO: |
| 7040 | case GL_KEEP: |
| 7041 | case GL_REPLACE: |
| 7042 | case GL_INCR: |
| 7043 | case GL_DECR: |
| 7044 | case GL_INVERT: |
| 7045 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 7046 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7047 | break; |
| 7048 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7049 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7050 | } |
| 7051 | |
| 7052 | switch (zfail) |
| 7053 | { |
| 7054 | case GL_ZERO: |
| 7055 | case GL_KEEP: |
| 7056 | case GL_REPLACE: |
| 7057 | case GL_INCR: |
| 7058 | case GL_DECR: |
| 7059 | case GL_INVERT: |
| 7060 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 7061 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7062 | break; |
| 7063 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7064 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7065 | } |
| 7066 | |
| 7067 | switch (zpass) |
| 7068 | { |
| 7069 | case GL_ZERO: |
| 7070 | case GL_KEEP: |
| 7071 | case GL_REPLACE: |
| 7072 | case GL_INCR: |
| 7073 | case GL_DECR: |
| 7074 | case GL_INVERT: |
| 7075 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 7076 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7077 | break; |
| 7078 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7079 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7080 | } |
| 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 | { |
| 7086 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 7087 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7088 | context->setStencilOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7089 | } |
| 7090 | |
| 7091 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 7092 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7093 | context->setStencilBackOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7094 | } |
| 7095 | } |
| 7096 | } |
| 7097 | catch(std::bad_alloc&) |
| 7098 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7099 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7100 | } |
| 7101 | } |
| 7102 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 7103 | GLboolean __stdcall glTestFenceNV(GLuint fence) |
| 7104 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7105 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7106 | |
| 7107 | try |
| 7108 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7109 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7110 | |
| 7111 | if (context) |
| 7112 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 7113 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7114 | |
| 7115 | if (fenceObject == NULL) |
| 7116 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7117 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7118 | } |
| 7119 | |
Jamie Madill | fb9a740 | 2013-07-26 11:55:01 -0400 | [diff] [blame] | 7120 | if (fenceObject->isFence() != GL_TRUE) |
| 7121 | { |
| 7122 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
| 7123 | } |
| 7124 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7125 | return fenceObject->testFence(); |
| 7126 | } |
| 7127 | } |
| 7128 | catch(std::bad_alloc&) |
| 7129 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7130 | gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7131 | } |
| 7132 | |
| 7133 | return GL_TRUE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 7134 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7135 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7136 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, |
| 7137 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7138 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7139 | 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] | 7140 | "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] | 7141 | target, level, internalformat, width, height, border, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7142 | |
| 7143 | try |
| 7144 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7145 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7146 | |
| 7147 | if (context) |
| 7148 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7149 | if (context->getClientVersion() < 3 && |
| 7150 | !validateES2TexImageParameters(context, target, level, internalformat, false, false, |
| 7151 | 0, 0, width, height, border, format, type, pixels)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 7152 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7153 | return; |
| 7154 | } |
| 7155 | |
| 7156 | if (context->getClientVersion() >= 3 && |
| 7157 | !validateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 7158 | 0, 0, 0, width, height, 1, border, format, type)) |
| 7159 | { |
| 7160 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 7161 | } |
| 7162 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7163 | switch (target) |
| 7164 | { |
| 7165 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7166 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7167 | gl::Texture2D *texture = context->getTexture2D(); |
| 7168 | texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7169 | } |
| 7170 | break; |
| 7171 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7172 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7173 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 7174 | texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7175 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7176 | break; |
| 7177 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7178 | { |
| 7179 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7180 | texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7181 | } |
| 7182 | break; |
| 7183 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7184 | { |
| 7185 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7186 | texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7187 | } |
| 7188 | break; |
| 7189 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7190 | { |
| 7191 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7192 | texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7193 | } |
| 7194 | break; |
| 7195 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7196 | { |
| 7197 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7198 | texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7199 | } |
| 7200 | break; |
| 7201 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 7202 | { |
| 7203 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7204 | texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7205 | } |
| 7206 | break; |
| 7207 | default: UNREACHABLE(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7208 | } |
| 7209 | } |
| 7210 | } |
| 7211 | catch(std::bad_alloc&) |
| 7212 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7213 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7214 | } |
| 7215 | } |
| 7216 | |
| 7217 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 7218 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7219 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param); |
| 7220 | |
| 7221 | try |
| 7222 | { |
| 7223 | gl::Context *context = gl::getNonLostContext(); |
| 7224 | |
| 7225 | if (context) |
| 7226 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7227 | if (!validateTexParamParameters(context, pname, static_cast<GLint>(param))) |
| 7228 | { |
| 7229 | return; |
| 7230 | } |
| 7231 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 7232 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7233 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 7234 | if (!texture) |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7235 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7236 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7237 | } |
| 7238 | |
| 7239 | switch (pname) |
| 7240 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7241 | case GL_TEXTURE_WRAP_S: texture->setWrapS(gl::uiround<GLenum>(param)); break; |
| 7242 | case GL_TEXTURE_WRAP_T: texture->setWrapT(gl::uiround<GLenum>(param)); break; |
| 7243 | case GL_TEXTURE_WRAP_R: texture->setWrapR(gl::uiround<GLenum>(param)); break; |
| 7244 | case GL_TEXTURE_MIN_FILTER: texture->setMinFilter(gl::uiround<GLenum>(param)); break; |
| 7245 | case GL_TEXTURE_MAG_FILTER: texture->setMagFilter(gl::uiround<GLenum>(param)); break; |
| 7246 | case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break; |
| 7247 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy(static_cast<GLfloat>(param), context->getTextureMaxAnisotropy()); break; |
| 7248 | case GL_TEXTURE_COMPARE_MODE: texture->setCompareMode(gl::uiround<GLenum>(param)); break; |
| 7249 | 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] | 7250 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7251 | case GL_TEXTURE_SWIZZLE_R: |
| 7252 | case GL_TEXTURE_SWIZZLE_G: |
| 7253 | case GL_TEXTURE_SWIZZLE_B: |
| 7254 | case GL_TEXTURE_SWIZZLE_A: |
| 7255 | case GL_TEXTURE_BASE_LEVEL: |
| 7256 | case GL_TEXTURE_MAX_LEVEL: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7257 | case GL_TEXTURE_MIN_LOD: |
| 7258 | case GL_TEXTURE_MAX_LOD: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7259 | UNIMPLEMENTED(); |
| 7260 | break; |
| 7261 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7262 | default: UNREACHABLE(); break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7263 | } |
| 7264 | } |
| 7265 | } |
| 7266 | catch(std::bad_alloc&) |
| 7267 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7268 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7269 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7270 | } |
| 7271 | |
| 7272 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 7273 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7274 | glTexParameterf(target, pname, (GLfloat)*params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7275 | } |
| 7276 | |
| 7277 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 7278 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7279 | 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] | 7280 | |
| 7281 | try |
| 7282 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7283 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7284 | |
| 7285 | if (context) |
| 7286 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7287 | if (!validateTexParamParameters(context, pname, param)) |
| 7288 | { |
| 7289 | return; |
| 7290 | } |
| 7291 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 7292 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7293 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 7294 | if (!texture) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7295 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7296 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7297 | } |
| 7298 | |
| 7299 | switch (pname) |
| 7300 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7301 | case GL_TEXTURE_WRAP_S: texture->setWrapS((GLenum)param); break; |
| 7302 | case GL_TEXTURE_WRAP_T: texture->setWrapT((GLenum)param); break; |
| 7303 | case GL_TEXTURE_WRAP_R: texture->setWrapR((GLenum)param); break; |
| 7304 | case GL_TEXTURE_MIN_FILTER: texture->setMinFilter((GLenum)param); break; |
| 7305 | case GL_TEXTURE_MAG_FILTER: texture->setMagFilter((GLenum)param); break; |
| 7306 | case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break; |
| 7307 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()); break; |
| 7308 | case GL_TEXTURE_COMPARE_MODE: texture->setCompareMode((GLenum)param); break; |
| 7309 | case GL_TEXTURE_COMPARE_FUNC: texture->setCompareFunc((GLenum)param); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7310 | |
| 7311 | case GL_TEXTURE_SWIZZLE_R: |
| 7312 | case GL_TEXTURE_SWIZZLE_G: |
| 7313 | case GL_TEXTURE_SWIZZLE_B: |
| 7314 | case GL_TEXTURE_SWIZZLE_A: |
| 7315 | case GL_TEXTURE_BASE_LEVEL: |
| 7316 | case GL_TEXTURE_MAX_LEVEL: |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7317 | case GL_TEXTURE_MIN_LOD: |
| 7318 | case GL_TEXTURE_MAX_LOD: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7319 | UNIMPLEMENTED(); |
| 7320 | break; |
| 7321 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7322 | default: UNREACHABLE(); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7323 | } |
| 7324 | } |
| 7325 | } |
| 7326 | catch(std::bad_alloc&) |
| 7327 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7328 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7329 | } |
| 7330 | } |
| 7331 | |
| 7332 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 7333 | { |
| 7334 | glTexParameteri(target, pname, *params); |
| 7335 | } |
| 7336 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7337 | void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 7338 | { |
| 7339 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 7340 | target, levels, internalformat, width, height); |
| 7341 | |
| 7342 | try |
| 7343 | { |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7344 | gl::Context *context = gl::getNonLostContext(); |
| 7345 | |
| 7346 | if (context) |
| 7347 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7348 | if (context->getClientVersion() < 3 && |
| 7349 | !validateES2TexStorageParameters(context, target, levels, internalformat, width, height)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7350 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7351 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7352 | } |
| 7353 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7354 | if (context->getClientVersion() >= 3 && |
| 7355 | !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7356 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7357 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7358 | } |
| 7359 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7360 | switch (target) |
| 7361 | { |
| 7362 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7363 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7364 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 7365 | texture2d->storage(levels, internalformat, width, height); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7366 | } |
| 7367 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7368 | |
| 7369 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7370 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7371 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7372 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7373 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7374 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7375 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7376 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 7377 | textureCube->storage(levels, internalformat, width); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7378 | } |
| 7379 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7380 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7381 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7382 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7383 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7384 | } |
| 7385 | } |
| 7386 | catch(std::bad_alloc&) |
| 7387 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7388 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7389 | } |
| 7390 | } |
| 7391 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7392 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 7393 | GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7394 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7395 | 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] | 7396 | "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] | 7397 | "const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7398 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 7399 | |
| 7400 | try |
| 7401 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7402 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7403 | |
| 7404 | if (context) |
| 7405 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7406 | if (context->getClientVersion() < 3 && |
| 7407 | !validateES2TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7408 | 0, 0, width, height, 0, format, type, pixels)) |
daniel@transgaming.com | 1d2d3c4 | 2012-05-31 01:14:15 +0000 | [diff] [blame] | 7409 | { |
| 7410 | return; |
| 7411 | } |
| 7412 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7413 | if (context->getClientVersion() >= 3 && |
| 7414 | !validateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7415 | 0, 0, 0, width, height, 1, 0, format, type)) |
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 | return; |
| 7418 | } |
| 7419 | |
| 7420 | switch (target) |
| 7421 | { |
| 7422 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7423 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7424 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7425 | 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] | 7426 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7427 | break; |
| 7428 | |
| 7429 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7430 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7431 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7432 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7433 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7434 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7435 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7436 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7437 | 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] | 7438 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7439 | break; |
| 7440 | |
| 7441 | default: |
| 7442 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7443 | } |
| 7444 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7445 | } |
| 7446 | catch(std::bad_alloc&) |
| 7447 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7448 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7449 | } |
| 7450 | } |
| 7451 | |
| 7452 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 7453 | { |
| 7454 | glUniform1fv(location, 1, &x); |
| 7455 | } |
| 7456 | |
| 7457 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 7458 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7459 | 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] | 7460 | |
| 7461 | try |
| 7462 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7463 | if (count < 0) |
| 7464 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7465 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7466 | } |
| 7467 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7468 | if (location == -1) |
| 7469 | { |
| 7470 | return; |
| 7471 | } |
| 7472 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7473 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7474 | |
| 7475 | if (context) |
| 7476 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7477 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7478 | if (!programBinary) |
| 7479 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7480 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7481 | } |
| 7482 | |
| 7483 | if (!programBinary->setUniform1fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7484 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7485 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7486 | } |
| 7487 | } |
| 7488 | } |
| 7489 | catch(std::bad_alloc&) |
| 7490 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7491 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7492 | } |
| 7493 | } |
| 7494 | |
| 7495 | void __stdcall glUniform1i(GLint location, GLint x) |
| 7496 | { |
| 7497 | glUniform1iv(location, 1, &x); |
| 7498 | } |
| 7499 | |
| 7500 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 7501 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7502 | 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] | 7503 | |
| 7504 | try |
| 7505 | { |
| 7506 | if (count < 0) |
| 7507 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7508 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7509 | } |
| 7510 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7511 | if (location == -1) |
| 7512 | { |
| 7513 | return; |
| 7514 | } |
| 7515 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7516 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7517 | |
| 7518 | if (context) |
| 7519 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7520 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7521 | if (!programBinary) |
| 7522 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7523 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7524 | } |
| 7525 | |
| 7526 | if (!programBinary->setUniform1iv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7527 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7528 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7529 | } |
| 7530 | } |
| 7531 | } |
| 7532 | catch(std::bad_alloc&) |
| 7533 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7534 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7535 | } |
| 7536 | } |
| 7537 | |
| 7538 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 7539 | { |
| 7540 | GLfloat xy[2] = {x, y}; |
| 7541 | |
| 7542 | glUniform2fv(location, 1, (GLfloat*)&xy); |
| 7543 | } |
| 7544 | |
| 7545 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 7546 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7547 | 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] | 7548 | |
| 7549 | try |
| 7550 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7551 | if (count < 0) |
| 7552 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7553 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7554 | } |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7555 | |
| 7556 | if (location == -1) |
| 7557 | { |
| 7558 | return; |
| 7559 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7560 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7561 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7562 | |
| 7563 | if (context) |
| 7564 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7565 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7566 | if (!programBinary) |
| 7567 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7568 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7569 | } |
| 7570 | |
| 7571 | if (!programBinary->setUniform2fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7572 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7573 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7574 | } |
| 7575 | } |
| 7576 | } |
| 7577 | catch(std::bad_alloc&) |
| 7578 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7579 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7580 | } |
| 7581 | } |
| 7582 | |
| 7583 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 7584 | { |
| 7585 | GLint xy[4] = {x, y}; |
| 7586 | |
| 7587 | glUniform2iv(location, 1, (GLint*)&xy); |
| 7588 | } |
| 7589 | |
| 7590 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 7591 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7592 | 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] | 7593 | |
| 7594 | try |
| 7595 | { |
| 7596 | if (count < 0) |
| 7597 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7598 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7599 | } |
| 7600 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7601 | if (location == -1) |
| 7602 | { |
| 7603 | return; |
| 7604 | } |
| 7605 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7606 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7607 | |
| 7608 | if (context) |
| 7609 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7610 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7611 | if (!programBinary) |
| 7612 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7613 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7614 | } |
| 7615 | |
| 7616 | if (!programBinary->setUniform2iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7617 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7618 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7619 | } |
| 7620 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7621 | } |
| 7622 | catch(std::bad_alloc&) |
| 7623 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7624 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7625 | } |
| 7626 | } |
| 7627 | |
| 7628 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 7629 | { |
| 7630 | GLfloat xyz[3] = {x, y, z}; |
| 7631 | |
| 7632 | glUniform3fv(location, 1, (GLfloat*)&xyz); |
| 7633 | } |
| 7634 | |
| 7635 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 7636 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7637 | 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] | 7638 | |
| 7639 | try |
| 7640 | { |
| 7641 | if (count < 0) |
| 7642 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7643 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7644 | } |
| 7645 | |
| 7646 | if (location == -1) |
| 7647 | { |
| 7648 | return; |
| 7649 | } |
| 7650 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7651 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7652 | |
| 7653 | if (context) |
| 7654 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7655 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7656 | if (!programBinary) |
| 7657 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7658 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7659 | } |
| 7660 | |
| 7661 | if (!programBinary->setUniform3fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7662 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7663 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7664 | } |
| 7665 | } |
| 7666 | } |
| 7667 | catch(std::bad_alloc&) |
| 7668 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7669 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7670 | } |
| 7671 | } |
| 7672 | |
| 7673 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 7674 | { |
| 7675 | GLint xyz[3] = {x, y, z}; |
| 7676 | |
| 7677 | glUniform3iv(location, 1, (GLint*)&xyz); |
| 7678 | } |
| 7679 | |
| 7680 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 7681 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7682 | 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] | 7683 | |
| 7684 | try |
| 7685 | { |
| 7686 | if (count < 0) |
| 7687 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7688 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7689 | } |
| 7690 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7691 | if (location == -1) |
| 7692 | { |
| 7693 | return; |
| 7694 | } |
| 7695 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7696 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7697 | |
| 7698 | if (context) |
| 7699 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7700 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7701 | if (!programBinary) |
| 7702 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7703 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7704 | } |
| 7705 | |
| 7706 | if (!programBinary->setUniform3iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7707 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7708 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7709 | } |
| 7710 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7711 | } |
| 7712 | catch(std::bad_alloc&) |
| 7713 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7714 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7715 | } |
| 7716 | } |
| 7717 | |
| 7718 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7719 | { |
| 7720 | GLfloat xyzw[4] = {x, y, z, w}; |
| 7721 | |
| 7722 | glUniform4fv(location, 1, (GLfloat*)&xyzw); |
| 7723 | } |
| 7724 | |
| 7725 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 7726 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7727 | 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] | 7728 | |
| 7729 | try |
| 7730 | { |
| 7731 | if (count < 0) |
| 7732 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7733 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7734 | } |
| 7735 | |
| 7736 | if (location == -1) |
| 7737 | { |
| 7738 | return; |
| 7739 | } |
| 7740 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7741 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7742 | |
| 7743 | if (context) |
| 7744 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7745 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7746 | if (!programBinary) |
| 7747 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7748 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7749 | } |
| 7750 | |
| 7751 | if (!programBinary->setUniform4fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7752 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7753 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7754 | } |
| 7755 | } |
| 7756 | } |
| 7757 | catch(std::bad_alloc&) |
| 7758 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7759 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7760 | } |
| 7761 | } |
| 7762 | |
| 7763 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 7764 | { |
| 7765 | GLint xyzw[4] = {x, y, z, w}; |
| 7766 | |
| 7767 | glUniform4iv(location, 1, (GLint*)&xyzw); |
| 7768 | } |
| 7769 | |
| 7770 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 7771 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7772 | 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] | 7773 | |
| 7774 | try |
| 7775 | { |
| 7776 | if (count < 0) |
| 7777 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7778 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7779 | } |
| 7780 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7781 | if (location == -1) |
| 7782 | { |
| 7783 | return; |
| 7784 | } |
| 7785 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7786 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7787 | |
| 7788 | if (context) |
| 7789 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7790 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7791 | if (!programBinary) |
| 7792 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7793 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7794 | } |
| 7795 | |
| 7796 | if (!programBinary->setUniform4iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7797 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7798 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7799 | } |
| 7800 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7801 | } |
| 7802 | catch(std::bad_alloc&) |
| 7803 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7804 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7805 | } |
| 7806 | } |
| 7807 | |
| 7808 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7809 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7810 | 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] | 7811 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7812 | |
| 7813 | try |
| 7814 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7815 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7816 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7817 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7818 | } |
| 7819 | |
| 7820 | if (location == -1) |
| 7821 | { |
| 7822 | return; |
| 7823 | } |
| 7824 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7825 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7826 | |
| 7827 | if (context) |
| 7828 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7829 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7830 | { |
| 7831 | return gl::error(GL_INVALID_VALUE); |
| 7832 | } |
| 7833 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7834 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7835 | if (!programBinary) |
| 7836 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7837 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7838 | } |
| 7839 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7840 | if (!programBinary->setUniformMatrix2fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7841 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7842 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7843 | } |
| 7844 | } |
| 7845 | } |
| 7846 | catch(std::bad_alloc&) |
| 7847 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7848 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7849 | } |
| 7850 | } |
| 7851 | |
| 7852 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7853 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7854 | 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] | 7855 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7856 | |
| 7857 | try |
| 7858 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7859 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7860 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7861 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7862 | } |
| 7863 | |
| 7864 | if (location == -1) |
| 7865 | { |
| 7866 | return; |
| 7867 | } |
| 7868 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7869 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7870 | |
| 7871 | if (context) |
| 7872 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7873 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7874 | { |
| 7875 | return gl::error(GL_INVALID_VALUE); |
| 7876 | } |
| 7877 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7878 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7879 | if (!programBinary) |
| 7880 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7881 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7882 | } |
| 7883 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7884 | if (!programBinary->setUniformMatrix3fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7885 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7886 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7887 | } |
| 7888 | } |
| 7889 | } |
| 7890 | catch(std::bad_alloc&) |
| 7891 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7892 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7893 | } |
| 7894 | } |
| 7895 | |
| 7896 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7897 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7898 | 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] | 7899 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7900 | |
| 7901 | try |
| 7902 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7903 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7904 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7905 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7906 | } |
| 7907 | |
| 7908 | if (location == -1) |
| 7909 | { |
| 7910 | return; |
| 7911 | } |
| 7912 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7913 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7914 | |
| 7915 | if (context) |
| 7916 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7917 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7918 | { |
| 7919 | return gl::error(GL_INVALID_VALUE); |
| 7920 | } |
| 7921 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7922 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7923 | if (!programBinary) |
| 7924 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7925 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7926 | } |
| 7927 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7928 | if (!programBinary->setUniformMatrix4fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7929 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7930 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7931 | } |
| 7932 | } |
| 7933 | } |
| 7934 | catch(std::bad_alloc&) |
| 7935 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7936 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7937 | } |
| 7938 | } |
| 7939 | |
| 7940 | void __stdcall glUseProgram(GLuint program) |
| 7941 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7942 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7943 | |
| 7944 | try |
| 7945 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7946 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7947 | |
| 7948 | if (context) |
| 7949 | { |
| 7950 | gl::Program *programObject = context->getProgram(program); |
| 7951 | |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7952 | if (!programObject && program != 0) |
| 7953 | { |
| 7954 | if (context->getShader(program)) |
| 7955 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7956 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7957 | } |
| 7958 | else |
| 7959 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7960 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7961 | } |
| 7962 | } |
| 7963 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 7964 | if (program != 0 && !programObject->isLinked()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7965 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7966 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7967 | } |
| 7968 | |
| 7969 | context->useProgram(program); |
| 7970 | } |
| 7971 | } |
| 7972 | catch(std::bad_alloc&) |
| 7973 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7974 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7975 | } |
| 7976 | } |
| 7977 | |
| 7978 | void __stdcall glValidateProgram(GLuint program) |
| 7979 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7980 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7981 | |
| 7982 | try |
| 7983 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7984 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7985 | |
| 7986 | if (context) |
| 7987 | { |
| 7988 | gl::Program *programObject = context->getProgram(program); |
| 7989 | |
| 7990 | if (!programObject) |
| 7991 | { |
| 7992 | if (context->getShader(program)) |
| 7993 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7994 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7995 | } |
| 7996 | else |
| 7997 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7998 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7999 | } |
| 8000 | } |
| 8001 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 8002 | programObject->validate(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 8003 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8004 | } |
| 8005 | catch(std::bad_alloc&) |
| 8006 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8007 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8008 | } |
| 8009 | } |
| 8010 | |
| 8011 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 8012 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8013 | EVENT("(GLuint index = %d, GLfloat x = %f)", index, x); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8014 | |
| 8015 | try |
| 8016 | { |
| 8017 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8018 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8019 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8020 | } |
| 8021 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8022 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8023 | |
| 8024 | if (context) |
| 8025 | { |
| 8026 | GLfloat vals[4] = { x, 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8027 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8028 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8029 | } |
| 8030 | catch(std::bad_alloc&) |
| 8031 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8032 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8033 | } |
| 8034 | } |
| 8035 | |
| 8036 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 8037 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8038 | 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] | 8039 | |
| 8040 | try |
| 8041 | { |
| 8042 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8043 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8044 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8045 | } |
| 8046 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8047 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8048 | |
| 8049 | if (context) |
| 8050 | { |
| 8051 | GLfloat vals[4] = { values[0], 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8052 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8053 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8054 | } |
| 8055 | catch(std::bad_alloc&) |
| 8056 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8057 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8058 | } |
| 8059 | } |
| 8060 | |
| 8061 | void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 8062 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8063 | 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] | 8064 | |
| 8065 | try |
| 8066 | { |
| 8067 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8068 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8069 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8070 | } |
| 8071 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8072 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8073 | |
| 8074 | if (context) |
| 8075 | { |
| 8076 | GLfloat vals[4] = { x, y, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8077 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8078 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8079 | } |
| 8080 | catch(std::bad_alloc&) |
| 8081 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8082 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8083 | } |
| 8084 | } |
| 8085 | |
| 8086 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 8087 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8088 | 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] | 8089 | |
| 8090 | try |
| 8091 | { |
| 8092 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8093 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8094 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8095 | } |
| 8096 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8097 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8098 | |
| 8099 | if (context) |
| 8100 | { |
| 8101 | 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] | 8102 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8103 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8104 | } |
| 8105 | catch(std::bad_alloc&) |
| 8106 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8107 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8108 | } |
| 8109 | } |
| 8110 | |
| 8111 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 8112 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8113 | 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] | 8114 | |
| 8115 | try |
| 8116 | { |
| 8117 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8118 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8119 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8120 | } |
| 8121 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8122 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8123 | |
| 8124 | if (context) |
| 8125 | { |
| 8126 | GLfloat vals[4] = { x, y, z, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8127 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8128 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8129 | } |
| 8130 | catch(std::bad_alloc&) |
| 8131 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8132 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8133 | } |
| 8134 | } |
| 8135 | |
| 8136 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 8137 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8138 | 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] | 8139 | |
| 8140 | try |
| 8141 | { |
| 8142 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8143 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8144 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8145 | } |
| 8146 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8147 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8148 | |
| 8149 | if (context) |
| 8150 | { |
| 8151 | 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] | 8152 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8153 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8154 | } |
| 8155 | catch(std::bad_alloc&) |
| 8156 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8157 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8158 | } |
| 8159 | } |
| 8160 | |
| 8161 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 8162 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8163 | 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] | 8164 | |
| 8165 | try |
| 8166 | { |
| 8167 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8168 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8169 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8170 | } |
| 8171 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8172 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8173 | |
| 8174 | if (context) |
| 8175 | { |
| 8176 | GLfloat vals[4] = { x, y, z, w }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8177 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8178 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8179 | } |
| 8180 | catch(std::bad_alloc&) |
| 8181 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8182 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8183 | } |
| 8184 | } |
| 8185 | |
| 8186 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 8187 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8188 | 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] | 8189 | |
| 8190 | try |
| 8191 | { |
| 8192 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8193 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8194 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8195 | } |
| 8196 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8197 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8198 | |
| 8199 | if (context) |
| 8200 | { |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8201 | context->setVertexAttribf(index, values); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8202 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8203 | } |
| 8204 | catch(std::bad_alloc&) |
| 8205 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8206 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8207 | } |
| 8208 | } |
| 8209 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8210 | void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
| 8211 | { |
| 8212 | EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor); |
| 8213 | |
| 8214 | try |
| 8215 | { |
| 8216 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8217 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8218 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8219 | } |
| 8220 | |
| 8221 | gl::Context *context = gl::getNonLostContext(); |
| 8222 | |
| 8223 | if (context) |
| 8224 | { |
| 8225 | context->setVertexAttribDivisor(index, divisor); |
| 8226 | } |
| 8227 | } |
| 8228 | catch(std::bad_alloc&) |
| 8229 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8230 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8231 | } |
| 8232 | } |
| 8233 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 8234 | 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] | 8235 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8236 | 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] | 8237 | "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] | 8238 | index, size, type, normalized, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8239 | |
| 8240 | try |
| 8241 | { |
| 8242 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8243 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8244 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8245 | } |
| 8246 | |
| 8247 | if (size < 1 || size > 4) |
| 8248 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8249 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8250 | } |
| 8251 | |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 8252 | gl::Context *context = gl::getNonLostContext(); |
| 8253 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8254 | switch (type) |
| 8255 | { |
| 8256 | case GL_BYTE: |
| 8257 | case GL_UNSIGNED_BYTE: |
| 8258 | case GL_SHORT: |
| 8259 | case GL_UNSIGNED_SHORT: |
| 8260 | case GL_FIXED: |
| 8261 | case GL_FLOAT: |
| 8262 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 8263 | case GL_HALF_FLOAT: |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8264 | case GL_INT: |
| 8265 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 8266 | case GL_INT_2_10_10_10_REV: |
| 8267 | 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] | 8268 | if (context && context->getClientVersion() < 3) |
| 8269 | { |
| 8270 | return gl::error(GL_INVALID_ENUM); |
| 8271 | } |
| 8272 | else |
| 8273 | { |
| 8274 | break; |
| 8275 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8276 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8277 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8278 | } |
| 8279 | |
| 8280 | if (stride < 0) |
| 8281 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8282 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8283 | } |
| 8284 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 8285 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 8286 | { |
| 8287 | return gl::error(GL_INVALID_OPERATION); |
| 8288 | } |
| 8289 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8290 | if (context) |
| 8291 | { |
Jamie Madill | d8db866 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 8292 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 8293 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 8294 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 8295 | // and the pointer argument is not NULL. |
| 8296 | if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && ptr != NULL) |
| 8297 | { |
| 8298 | return gl::error(GL_INVALID_OPERATION); |
| 8299 | } |
| 8300 | |
shannon.woods%transgaming.com@gtempaccount.com | 8de4e6a | 2013-04-13 03:37:44 +0000 | [diff] [blame] | 8301 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, |
| 8302 | normalized == GL_TRUE, false, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8303 | } |
| 8304 | } |
| 8305 | catch(std::bad_alloc&) |
| 8306 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8307 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8308 | } |
| 8309 | } |
| 8310 | |
| 8311 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 8312 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8313 | 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] | 8314 | |
| 8315 | try |
| 8316 | { |
| 8317 | if (width < 0 || height < 0) |
| 8318 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8319 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8320 | } |
| 8321 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8322 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8323 | |
| 8324 | if (context) |
| 8325 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 8326 | context->setViewportParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8327 | } |
| 8328 | } |
| 8329 | catch(std::bad_alloc&) |
| 8330 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8331 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8332 | } |
| 8333 | } |
| 8334 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8335 | // OpenGL ES 3.0 functions |
| 8336 | |
| 8337 | void __stdcall glReadBuffer(GLenum mode) |
| 8338 | { |
| 8339 | EVENT("(GLenum mode = 0x%X)", mode); |
| 8340 | |
| 8341 | try |
| 8342 | { |
| 8343 | gl::Context *context = gl::getNonLostContext(); |
| 8344 | |
| 8345 | if (context) |
| 8346 | { |
| 8347 | if (context->getClientVersion() < 3) |
| 8348 | { |
| 8349 | return gl::error(GL_INVALID_OPERATION); |
| 8350 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8351 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8352 | // glReadBuffer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8353 | UNIMPLEMENTED(); |
| 8354 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8355 | } |
| 8356 | catch(std::bad_alloc&) |
| 8357 | { |
| 8358 | return gl::error(GL_OUT_OF_MEMORY); |
| 8359 | } |
| 8360 | } |
| 8361 | |
| 8362 | void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) |
| 8363 | { |
| 8364 | EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, " |
| 8365 | "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices); |
| 8366 | |
| 8367 | try |
| 8368 | { |
| 8369 | gl::Context *context = gl::getNonLostContext(); |
| 8370 | |
| 8371 | if (context) |
| 8372 | { |
| 8373 | if (context->getClientVersion() < 3) |
| 8374 | { |
| 8375 | return gl::error(GL_INVALID_OPERATION); |
| 8376 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8377 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8378 | // glDrawRangeElements |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8379 | UNIMPLEMENTED(); |
| 8380 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8381 | } |
| 8382 | catch(std::bad_alloc&) |
| 8383 | { |
| 8384 | return gl::error(GL_OUT_OF_MEMORY); |
| 8385 | } |
| 8386 | } |
| 8387 | |
| 8388 | void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
| 8389 | { |
| 8390 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8391 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " |
| 8392 | "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8393 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 8394 | |
| 8395 | try |
| 8396 | { |
| 8397 | gl::Context *context = gl::getNonLostContext(); |
| 8398 | |
| 8399 | if (context) |
| 8400 | { |
| 8401 | if (context->getClientVersion() < 3) |
| 8402 | { |
| 8403 | return gl::error(GL_INVALID_OPERATION); |
| 8404 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8405 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8406 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8407 | if (!validateES3TexImageParameters(context, target, level, internalformat, false, false, |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8408 | 0, 0, 0, width, height, depth, border, format, type)) |
| 8409 | { |
| 8410 | return; |
| 8411 | } |
| 8412 | |
| 8413 | switch(target) |
| 8414 | { |
| 8415 | case GL_TEXTURE_3D: |
| 8416 | { |
| 8417 | gl::Texture3D *texture = context->getTexture3D(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8418 | 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] | 8419 | } |
| 8420 | break; |
| 8421 | |
| 8422 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8423 | { |
| 8424 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8425 | 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] | 8426 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8427 | break; |
| 8428 | |
| 8429 | default: |
| 8430 | return gl::error(GL_INVALID_ENUM); |
| 8431 | } |
| 8432 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8433 | } |
| 8434 | catch(std::bad_alloc&) |
| 8435 | { |
| 8436 | return gl::error(GL_OUT_OF_MEMORY); |
| 8437 | } |
| 8438 | } |
| 8439 | |
| 8440 | 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) |
| 8441 | { |
| 8442 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8443 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8444 | "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8445 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); |
| 8446 | |
| 8447 | try |
| 8448 | { |
| 8449 | gl::Context *context = gl::getNonLostContext(); |
| 8450 | |
| 8451 | if (context) |
| 8452 | { |
| 8453 | if (context->getClientVersion() < 3) |
| 8454 | { |
| 8455 | return gl::error(GL_INVALID_OPERATION); |
| 8456 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8457 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8458 | if (!pixels) |
| 8459 | { |
| 8460 | return gl::error(GL_INVALID_VALUE); |
| 8461 | } |
| 8462 | |
| 8463 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8464 | 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] | 8465 | xoffset, yoffset, zoffset, width, height, depth, 0, |
| 8466 | format, type)) |
| 8467 | { |
| 8468 | return; |
| 8469 | } |
| 8470 | |
| 8471 | switch(target) |
| 8472 | { |
| 8473 | case GL_TEXTURE_3D: |
| 8474 | { |
| 8475 | gl::Texture3D *texture = context->getTexture3D(); |
| 8476 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8477 | } |
| 8478 | break; |
| 8479 | |
| 8480 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8481 | { |
| 8482 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8483 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8484 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8485 | break; |
| 8486 | |
| 8487 | default: |
| 8488 | return gl::error(GL_INVALID_ENUM); |
| 8489 | } |
| 8490 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8491 | } |
| 8492 | catch(std::bad_alloc&) |
| 8493 | { |
| 8494 | return gl::error(GL_OUT_OF_MEMORY); |
| 8495 | } |
| 8496 | } |
| 8497 | |
| 8498 | void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 8499 | { |
| 8500 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8501 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 8502 | target, level, xoffset, yoffset, zoffset, x, y, width, height); |
| 8503 | |
| 8504 | try |
| 8505 | { |
| 8506 | gl::Context *context = gl::getNonLostContext(); |
| 8507 | |
| 8508 | if (context) |
| 8509 | { |
| 8510 | if (context->getClientVersion() < 3) |
| 8511 | { |
| 8512 | return gl::error(GL_INVALID_OPERATION); |
| 8513 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8514 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8515 | if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset, |
| 8516 | x, y, width, height, 0)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8517 | { |
| 8518 | return; |
| 8519 | } |
| 8520 | |
| 8521 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 8522 | gl::Texture *texture = NULL; |
| 8523 | switch (target) |
| 8524 | { |
| 8525 | case GL_TEXTURE_3D: |
| 8526 | texture = context->getTexture3D(); |
| 8527 | break; |
| 8528 | |
| 8529 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8530 | texture = context->getTexture2DArray(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8531 | break; |
| 8532 | |
| 8533 | default: |
| 8534 | return gl::error(GL_INVALID_ENUM); |
| 8535 | } |
| 8536 | |
| 8537 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer); |
| 8538 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8539 | } |
| 8540 | catch(std::bad_alloc&) |
| 8541 | { |
| 8542 | return gl::error(GL_OUT_OF_MEMORY); |
| 8543 | } |
| 8544 | } |
| 8545 | |
| 8546 | void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) |
| 8547 | { |
| 8548 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8549 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, " |
| 8550 | "const GLvoid* data = 0x%0.8p)", |
| 8551 | target, level, internalformat, width, height, depth, border, imageSize, data); |
| 8552 | |
| 8553 | try |
| 8554 | { |
| 8555 | gl::Context *context = gl::getNonLostContext(); |
| 8556 | |
| 8557 | if (context) |
| 8558 | { |
| 8559 | if (context->getClientVersion() < 3) |
| 8560 | { |
| 8561 | return gl::error(GL_INVALID_OPERATION); |
| 8562 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8563 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8564 | 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] | 8565 | { |
| 8566 | return gl::error(GL_INVALID_VALUE); |
| 8567 | } |
| 8568 | |
| 8569 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8570 | if (!validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 8571 | 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] | 8572 | { |
| 8573 | return; |
| 8574 | } |
| 8575 | |
| 8576 | switch(target) |
| 8577 | { |
| 8578 | case GL_TEXTURE_3D: |
| 8579 | { |
| 8580 | gl::Texture3D *texture = context->getTexture3D(); |
| 8581 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8582 | } |
| 8583 | break; |
| 8584 | |
| 8585 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8586 | { |
| 8587 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8588 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8589 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8590 | break; |
| 8591 | |
| 8592 | default: |
| 8593 | return gl::error(GL_INVALID_ENUM); |
| 8594 | } |
| 8595 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8596 | } |
| 8597 | catch(std::bad_alloc&) |
| 8598 | { |
| 8599 | return gl::error(GL_OUT_OF_MEMORY); |
| 8600 | } |
| 8601 | } |
| 8602 | |
| 8603 | 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) |
| 8604 | { |
| 8605 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8606 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8607 | "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 8608 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); |
| 8609 | |
| 8610 | try |
| 8611 | { |
| 8612 | gl::Context *context = gl::getNonLostContext(); |
| 8613 | |
| 8614 | if (context) |
| 8615 | { |
| 8616 | if (context->getClientVersion() < 3) |
| 8617 | { |
| 8618 | return gl::error(GL_INVALID_OPERATION); |
| 8619 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8620 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8621 | 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] | 8622 | { |
| 8623 | return gl::error(GL_INVALID_VALUE); |
| 8624 | } |
| 8625 | |
| 8626 | if (!data) |
| 8627 | { |
| 8628 | return gl::error(GL_INVALID_VALUE); |
| 8629 | } |
| 8630 | |
| 8631 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8632 | if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 8633 | 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] | 8634 | { |
| 8635 | return; |
| 8636 | } |
| 8637 | |
| 8638 | switch(target) |
| 8639 | { |
| 8640 | case GL_TEXTURE_3D: |
| 8641 | { |
| 8642 | gl::Texture3D *texture = context->getTexture3D(); |
| 8643 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8644 | format, imageSize, data); |
| 8645 | } |
| 8646 | break; |
| 8647 | |
| 8648 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8649 | { |
| 8650 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8651 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8652 | format, imageSize, data); |
| 8653 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8654 | break; |
| 8655 | |
| 8656 | default: |
| 8657 | return gl::error(GL_INVALID_ENUM); |
| 8658 | } |
| 8659 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8660 | } |
| 8661 | catch(std::bad_alloc&) |
| 8662 | { |
| 8663 | return gl::error(GL_OUT_OF_MEMORY); |
| 8664 | } |
| 8665 | } |
| 8666 | |
| 8667 | void __stdcall glGenQueries(GLsizei n, GLuint* ids) |
| 8668 | { |
| 8669 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8670 | |
| 8671 | try |
| 8672 | { |
| 8673 | gl::Context *context = gl::getNonLostContext(); |
| 8674 | |
| 8675 | if (context) |
| 8676 | { |
| 8677 | if (context->getClientVersion() < 3) |
| 8678 | { |
| 8679 | return gl::error(GL_INVALID_OPERATION); |
| 8680 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8681 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 8682 | glGenQueriesEXT(n, ids); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8683 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8684 | } |
| 8685 | catch(std::bad_alloc&) |
| 8686 | { |
| 8687 | return gl::error(GL_OUT_OF_MEMORY); |
| 8688 | } |
| 8689 | } |
| 8690 | |
| 8691 | void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids) |
| 8692 | { |
| 8693 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8694 | |
| 8695 | try |
| 8696 | { |
| 8697 | gl::Context *context = gl::getNonLostContext(); |
| 8698 | |
| 8699 | if (context) |
| 8700 | { |
| 8701 | if (context->getClientVersion() < 3) |
| 8702 | { |
| 8703 | return gl::error(GL_INVALID_OPERATION); |
| 8704 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8705 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 8706 | glDeleteQueriesEXT(n, ids); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8707 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8708 | } |
| 8709 | catch(std::bad_alloc&) |
| 8710 | { |
| 8711 | return gl::error(GL_OUT_OF_MEMORY); |
| 8712 | } |
| 8713 | } |
| 8714 | |
| 8715 | GLboolean __stdcall glIsQuery(GLuint id) |
| 8716 | { |
| 8717 | EVENT("(GLuint id = %u)", id); |
| 8718 | |
| 8719 | try |
| 8720 | { |
| 8721 | gl::Context *context = gl::getNonLostContext(); |
| 8722 | |
| 8723 | if (context) |
| 8724 | { |
| 8725 | if (context->getClientVersion() < 3) |
| 8726 | { |
| 8727 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8728 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8729 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 8730 | // TODO: XFB queries |
| 8731 | return glIsQueryEXT(id); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8732 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8733 | } |
| 8734 | catch(std::bad_alloc&) |
| 8735 | { |
| 8736 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8737 | } |
| 8738 | |
| 8739 | return GL_FALSE; |
| 8740 | } |
| 8741 | |
| 8742 | void __stdcall glBeginQuery(GLenum target, GLuint id) |
| 8743 | { |
| 8744 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 8745 | |
| 8746 | try |
| 8747 | { |
| 8748 | gl::Context *context = gl::getNonLostContext(); |
| 8749 | |
| 8750 | if (context) |
| 8751 | { |
| 8752 | if (context->getClientVersion() < 3) |
| 8753 | { |
| 8754 | return gl::error(GL_INVALID_OPERATION); |
| 8755 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8756 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 8757 | switch (target) |
| 8758 | { |
| 8759 | case GL_ANY_SAMPLES_PASSED: |
| 8760 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE: |
| 8761 | case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: |
| 8762 | break; |
| 8763 | default: |
| 8764 | return gl::error(GL_INVALID_ENUM); |
| 8765 | } |
| 8766 | |
| 8767 | if (id == 0) |
| 8768 | { |
| 8769 | return gl::error(GL_INVALID_OPERATION); |
| 8770 | } |
| 8771 | |
| 8772 | if (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN) |
| 8773 | { |
| 8774 | // TODO: XFB queries |
| 8775 | UNIMPLEMENTED(); |
| 8776 | } |
| 8777 | else |
| 8778 | { |
| 8779 | context->beginQuery(target, id); |
| 8780 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8781 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8782 | } |
| 8783 | catch(std::bad_alloc&) |
| 8784 | { |
| 8785 | return gl::error(GL_OUT_OF_MEMORY); |
| 8786 | } |
| 8787 | } |
| 8788 | |
| 8789 | void __stdcall glEndQuery(GLenum target) |
| 8790 | { |
| 8791 | EVENT("(GLenum target = 0x%X)", target); |
| 8792 | |
| 8793 | try |
| 8794 | { |
| 8795 | gl::Context *context = gl::getNonLostContext(); |
| 8796 | |
| 8797 | if (context) |
| 8798 | { |
| 8799 | if (context->getClientVersion() < 3) |
| 8800 | { |
| 8801 | return gl::error(GL_INVALID_OPERATION); |
| 8802 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8803 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 8804 | if (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN) |
| 8805 | { |
| 8806 | // TODO: XFB queries |
| 8807 | UNIMPLEMENTED(); |
| 8808 | } |
| 8809 | else |
| 8810 | { |
| 8811 | glEndQueryEXT(target); |
| 8812 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8813 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8814 | } |
| 8815 | catch(std::bad_alloc&) |
| 8816 | { |
| 8817 | return gl::error(GL_OUT_OF_MEMORY); |
| 8818 | } |
| 8819 | } |
| 8820 | |
| 8821 | void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params) |
| 8822 | { |
| 8823 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
| 8824 | |
| 8825 | try |
| 8826 | { |
| 8827 | gl::Context *context = gl::getNonLostContext(); |
| 8828 | |
| 8829 | if (context) |
| 8830 | { |
| 8831 | if (context->getClientVersion() < 3) |
| 8832 | { |
| 8833 | return gl::error(GL_INVALID_OPERATION); |
| 8834 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8835 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 8836 | if (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN) |
| 8837 | { |
| 8838 | // TODO: XFB queries |
| 8839 | UNIMPLEMENTED(); |
| 8840 | } |
| 8841 | else |
| 8842 | { |
| 8843 | glGetQueryivEXT(target, pname, params); |
| 8844 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8845 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8846 | } |
| 8847 | catch(std::bad_alloc&) |
| 8848 | { |
| 8849 | return gl::error(GL_OUT_OF_MEMORY); |
| 8850 | } |
| 8851 | } |
| 8852 | |
| 8853 | void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) |
| 8854 | { |
| 8855 | EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params); |
| 8856 | |
| 8857 | try |
| 8858 | { |
| 8859 | gl::Context *context = gl::getNonLostContext(); |
| 8860 | |
| 8861 | if (context) |
| 8862 | { |
| 8863 | if (context->getClientVersion() < 3) |
| 8864 | { |
| 8865 | return gl::error(GL_INVALID_OPERATION); |
| 8866 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8867 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 8868 | // TODO: XFB queries |
| 8869 | glGetQueryObjectuivEXT(id, pname, params); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8870 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8871 | } |
| 8872 | catch(std::bad_alloc&) |
| 8873 | { |
| 8874 | return gl::error(GL_OUT_OF_MEMORY); |
| 8875 | } |
| 8876 | } |
| 8877 | |
| 8878 | GLboolean __stdcall glUnmapBuffer(GLenum target) |
| 8879 | { |
| 8880 | EVENT("(GLenum target = 0x%X)", target); |
| 8881 | |
| 8882 | try |
| 8883 | { |
| 8884 | gl::Context *context = gl::getNonLostContext(); |
| 8885 | |
| 8886 | if (context) |
| 8887 | { |
| 8888 | if (context->getClientVersion() < 3) |
| 8889 | { |
| 8890 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8891 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8892 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8893 | // glUnmapBuffer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8894 | UNIMPLEMENTED(); |
| 8895 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8896 | } |
| 8897 | catch(std::bad_alloc&) |
| 8898 | { |
| 8899 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8900 | } |
| 8901 | |
| 8902 | return GL_FALSE; |
| 8903 | } |
| 8904 | |
| 8905 | void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) |
| 8906 | { |
| 8907 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 8908 | |
| 8909 | try |
| 8910 | { |
| 8911 | gl::Context *context = gl::getNonLostContext(); |
| 8912 | |
| 8913 | if (context) |
| 8914 | { |
| 8915 | if (context->getClientVersion() < 3) |
| 8916 | { |
| 8917 | return gl::error(GL_INVALID_OPERATION); |
| 8918 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8919 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8920 | // glGetBufferPointerv |
shannonwoods@chromium.org | 2d2190a | 2013-05-30 00:17:35 +0000 | [diff] [blame] | 8921 | UNIMPLEMENTED(); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8922 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8923 | } |
| 8924 | catch(std::bad_alloc&) |
| 8925 | { |
| 8926 | return gl::error(GL_OUT_OF_MEMORY); |
| 8927 | } |
| 8928 | } |
| 8929 | |
| 8930 | void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs) |
| 8931 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8932 | try |
| 8933 | { |
| 8934 | gl::Context *context = gl::getNonLostContext(); |
| 8935 | |
| 8936 | if (context) |
| 8937 | { |
| 8938 | if (context->getClientVersion() < 3) |
| 8939 | { |
| 8940 | return gl::error(GL_INVALID_OPERATION); |
| 8941 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8942 | |
shannon.woods%transgaming.com@gtempaccount.com | 7948c5f | 2013-04-13 03:38:58 +0000 | [diff] [blame] | 8943 | glDrawBuffersEXT(n, bufs); |
| 8944 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8945 | } |
| 8946 | catch(std::bad_alloc&) |
| 8947 | { |
| 8948 | return gl::error(GL_OUT_OF_MEMORY); |
| 8949 | } |
| 8950 | } |
| 8951 | |
| 8952 | void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8953 | { |
| 8954 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8955 | location, count, transpose, value); |
| 8956 | |
| 8957 | try |
| 8958 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8959 | if (count < 0) |
| 8960 | { |
| 8961 | return gl::error(GL_INVALID_VALUE); |
| 8962 | } |
| 8963 | |
| 8964 | if (location == -1) |
| 8965 | { |
| 8966 | return; |
| 8967 | } |
| 8968 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8969 | gl::Context *context = gl::getNonLostContext(); |
| 8970 | |
| 8971 | if (context) |
| 8972 | { |
| 8973 | if (context->getClientVersion() < 3) |
| 8974 | { |
| 8975 | return gl::error(GL_INVALID_OPERATION); |
| 8976 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8977 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8978 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8979 | if (!programBinary) |
| 8980 | { |
| 8981 | return gl::error(GL_INVALID_OPERATION); |
| 8982 | } |
| 8983 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8984 | if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8985 | { |
| 8986 | return gl::error(GL_INVALID_OPERATION); |
| 8987 | } |
| 8988 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8989 | } |
| 8990 | catch(std::bad_alloc&) |
| 8991 | { |
| 8992 | return gl::error(GL_OUT_OF_MEMORY); |
| 8993 | } |
| 8994 | } |
| 8995 | |
| 8996 | void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8997 | { |
| 8998 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8999 | location, count, transpose, value); |
| 9000 | |
| 9001 | try |
| 9002 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9003 | if (count < 0) |
| 9004 | { |
| 9005 | return gl::error(GL_INVALID_VALUE); |
| 9006 | } |
| 9007 | |
| 9008 | if (location == -1) |
| 9009 | { |
| 9010 | return; |
| 9011 | } |
| 9012 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9013 | gl::Context *context = gl::getNonLostContext(); |
| 9014 | |
| 9015 | if (context) |
| 9016 | { |
| 9017 | if (context->getClientVersion() < 3) |
| 9018 | { |
| 9019 | return gl::error(GL_INVALID_OPERATION); |
| 9020 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9021 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9022 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9023 | if (!programBinary) |
| 9024 | { |
| 9025 | return gl::error(GL_INVALID_OPERATION); |
| 9026 | } |
| 9027 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9028 | if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9029 | { |
| 9030 | return gl::error(GL_INVALID_OPERATION); |
| 9031 | } |
| 9032 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9033 | } |
| 9034 | catch(std::bad_alloc&) |
| 9035 | { |
| 9036 | return gl::error(GL_OUT_OF_MEMORY); |
| 9037 | } |
| 9038 | } |
| 9039 | |
| 9040 | void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 9041 | { |
| 9042 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 9043 | location, count, transpose, value); |
| 9044 | |
| 9045 | try |
| 9046 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9047 | if (count < 0) |
| 9048 | { |
| 9049 | return gl::error(GL_INVALID_VALUE); |
| 9050 | } |
| 9051 | |
| 9052 | if (location == -1) |
| 9053 | { |
| 9054 | return; |
| 9055 | } |
| 9056 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9057 | gl::Context *context = gl::getNonLostContext(); |
| 9058 | |
| 9059 | if (context) |
| 9060 | { |
| 9061 | if (context->getClientVersion() < 3) |
| 9062 | { |
| 9063 | return gl::error(GL_INVALID_OPERATION); |
| 9064 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9065 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9066 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9067 | if (!programBinary) |
| 9068 | { |
| 9069 | return gl::error(GL_INVALID_OPERATION); |
| 9070 | } |
| 9071 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9072 | if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9073 | { |
| 9074 | return gl::error(GL_INVALID_OPERATION); |
| 9075 | } |
| 9076 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9077 | } |
| 9078 | catch(std::bad_alloc&) |
| 9079 | { |
| 9080 | return gl::error(GL_OUT_OF_MEMORY); |
| 9081 | } |
| 9082 | } |
| 9083 | |
| 9084 | void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 9085 | { |
| 9086 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 9087 | location, count, transpose, value); |
| 9088 | |
| 9089 | try |
| 9090 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9091 | if (count < 0) |
| 9092 | { |
| 9093 | return gl::error(GL_INVALID_VALUE); |
| 9094 | } |
| 9095 | |
| 9096 | if (location == -1) |
| 9097 | { |
| 9098 | return; |
| 9099 | } |
| 9100 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9101 | gl::Context *context = gl::getNonLostContext(); |
| 9102 | |
| 9103 | if (context) |
| 9104 | { |
| 9105 | if (context->getClientVersion() < 3) |
| 9106 | { |
| 9107 | return gl::error(GL_INVALID_OPERATION); |
| 9108 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9109 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9110 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9111 | if (!programBinary) |
| 9112 | { |
| 9113 | return gl::error(GL_INVALID_OPERATION); |
| 9114 | } |
| 9115 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9116 | if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9117 | { |
| 9118 | return gl::error(GL_INVALID_OPERATION); |
| 9119 | } |
| 9120 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9121 | } |
| 9122 | catch(std::bad_alloc&) |
| 9123 | { |
| 9124 | return gl::error(GL_OUT_OF_MEMORY); |
| 9125 | } |
| 9126 | } |
| 9127 | |
| 9128 | void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 9129 | { |
| 9130 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 9131 | location, count, transpose, value); |
| 9132 | |
| 9133 | try |
| 9134 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9135 | if (count < 0) |
| 9136 | { |
| 9137 | return gl::error(GL_INVALID_VALUE); |
| 9138 | } |
| 9139 | |
| 9140 | if (location == -1) |
| 9141 | { |
| 9142 | return; |
| 9143 | } |
| 9144 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9145 | gl::Context *context = gl::getNonLostContext(); |
| 9146 | |
| 9147 | if (context) |
| 9148 | { |
| 9149 | if (context->getClientVersion() < 3) |
| 9150 | { |
| 9151 | return gl::error(GL_INVALID_OPERATION); |
| 9152 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9153 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9154 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9155 | if (!programBinary) |
| 9156 | { |
| 9157 | return gl::error(GL_INVALID_OPERATION); |
| 9158 | } |
| 9159 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9160 | if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9161 | { |
| 9162 | return gl::error(GL_INVALID_OPERATION); |
| 9163 | } |
| 9164 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9165 | } |
| 9166 | catch(std::bad_alloc&) |
| 9167 | { |
| 9168 | return gl::error(GL_OUT_OF_MEMORY); |
| 9169 | } |
| 9170 | } |
| 9171 | |
| 9172 | void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 9173 | { |
| 9174 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 9175 | location, count, transpose, value); |
| 9176 | |
| 9177 | try |
| 9178 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9179 | if (count < 0) |
| 9180 | { |
| 9181 | return gl::error(GL_INVALID_VALUE); |
| 9182 | } |
| 9183 | |
| 9184 | if (location == -1) |
| 9185 | { |
| 9186 | return; |
| 9187 | } |
| 9188 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9189 | gl::Context *context = gl::getNonLostContext(); |
| 9190 | |
| 9191 | if (context) |
| 9192 | { |
| 9193 | if (context->getClientVersion() < 3) |
| 9194 | { |
| 9195 | return gl::error(GL_INVALID_OPERATION); |
| 9196 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9197 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9198 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9199 | if (!programBinary) |
| 9200 | { |
| 9201 | return gl::error(GL_INVALID_OPERATION); |
| 9202 | } |
| 9203 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9204 | if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9205 | { |
| 9206 | return gl::error(GL_INVALID_OPERATION); |
| 9207 | } |
| 9208 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9209 | } |
| 9210 | catch(std::bad_alloc&) |
| 9211 | { |
| 9212 | return gl::error(GL_OUT_OF_MEMORY); |
| 9213 | } |
| 9214 | } |
| 9215 | |
| 9216 | void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) |
| 9217 | { |
| 9218 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, " |
| 9219 | "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 9220 | srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 9221 | |
| 9222 | try |
| 9223 | { |
| 9224 | gl::Context *context = gl::getNonLostContext(); |
| 9225 | |
| 9226 | if (context) |
| 9227 | { |
| 9228 | if (context->getClientVersion() < 3) |
| 9229 | { |
| 9230 | return gl::error(GL_INVALID_OPERATION); |
| 9231 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9232 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 9233 | if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 9234 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 9235 | false)) |
| 9236 | { |
| 9237 | return; |
| 9238 | } |
| 9239 | |
| 9240 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 9241 | mask, filter); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9242 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9243 | } |
| 9244 | catch(std::bad_alloc&) |
| 9245 | { |
| 9246 | return gl::error(GL_OUT_OF_MEMORY); |
| 9247 | } |
| 9248 | } |
| 9249 | |
| 9250 | void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| 9251 | { |
| 9252 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 9253 | target, samples, internalformat, width, height); |
| 9254 | |
| 9255 | try |
| 9256 | { |
| 9257 | gl::Context *context = gl::getNonLostContext(); |
| 9258 | |
| 9259 | if (context) |
| 9260 | { |
| 9261 | if (context->getClientVersion() < 3) |
| 9262 | { |
| 9263 | return gl::error(GL_INVALID_OPERATION); |
| 9264 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9265 | |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 9266 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 9267 | width, height, false)) |
| 9268 | { |
| 9269 | return; |
| 9270 | } |
| 9271 | |
| 9272 | context->setRenderbufferStorage(width, height, internalformat, samples); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9273 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9274 | } |
| 9275 | catch(std::bad_alloc&) |
| 9276 | { |
| 9277 | return gl::error(GL_OUT_OF_MEMORY); |
| 9278 | } |
| 9279 | } |
| 9280 | |
| 9281 | void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) |
| 9282 | { |
| 9283 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)", |
| 9284 | target, attachment, texture, level, layer); |
| 9285 | |
| 9286 | try |
| 9287 | { |
| 9288 | gl::Context *context = gl::getNonLostContext(); |
| 9289 | |
| 9290 | if (context) |
| 9291 | { |
| 9292 | if (context->getClientVersion() < 3) |
| 9293 | { |
| 9294 | return gl::error(GL_INVALID_OPERATION); |
| 9295 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9296 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9297 | // glFramebufferTextureLayer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9298 | UNIMPLEMENTED(); |
| 9299 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9300 | } |
| 9301 | catch(std::bad_alloc&) |
| 9302 | { |
| 9303 | return gl::error(GL_OUT_OF_MEMORY); |
| 9304 | } |
| 9305 | } |
| 9306 | |
| 9307 | GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 9308 | { |
| 9309 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 9310 | target, offset, length, access); |
| 9311 | |
| 9312 | try |
| 9313 | { |
| 9314 | gl::Context *context = gl::getNonLostContext(); |
| 9315 | |
| 9316 | if (context) |
| 9317 | { |
| 9318 | if (context->getClientVersion() < 3) |
| 9319 | { |
| 9320 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 9321 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9322 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9323 | // glMapBufferRange |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9324 | UNIMPLEMENTED(); |
| 9325 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9326 | } |
| 9327 | catch(std::bad_alloc&) |
| 9328 | { |
| 9329 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL)); |
| 9330 | } |
| 9331 | |
| 9332 | return NULL; |
| 9333 | } |
| 9334 | |
| 9335 | void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) |
| 9336 | { |
| 9337 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 9338 | |
| 9339 | try |
| 9340 | { |
| 9341 | gl::Context *context = gl::getNonLostContext(); |
| 9342 | |
| 9343 | if (context) |
| 9344 | { |
| 9345 | if (context->getClientVersion() < 3) |
| 9346 | { |
| 9347 | return gl::error(GL_INVALID_OPERATION); |
| 9348 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9349 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9350 | // glFlushMappedBufferRange |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9351 | UNIMPLEMENTED(); |
| 9352 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9353 | } |
| 9354 | catch(std::bad_alloc&) |
| 9355 | { |
| 9356 | return gl::error(GL_OUT_OF_MEMORY); |
| 9357 | } |
| 9358 | } |
| 9359 | |
| 9360 | void __stdcall glBindVertexArray(GLuint array) |
| 9361 | { |
| 9362 | EVENT("(GLuint array = %u)", array); |
| 9363 | |
| 9364 | try |
| 9365 | { |
| 9366 | gl::Context *context = gl::getNonLostContext(); |
| 9367 | |
| 9368 | if (context) |
| 9369 | { |
| 9370 | if (context->getClientVersion() < 3) |
| 9371 | { |
| 9372 | return gl::error(GL_INVALID_OPERATION); |
| 9373 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9374 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9375 | gl::VertexArray *vao = context->getVertexArray(array); |
| 9376 | |
| 9377 | if (!vao) |
| 9378 | { |
| 9379 | // The default VAO should always exist |
| 9380 | ASSERT(array != 0); |
| 9381 | return gl::error(GL_INVALID_OPERATION); |
| 9382 | } |
| 9383 | |
| 9384 | context->bindVertexArray(array); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9385 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9386 | } |
| 9387 | catch(std::bad_alloc&) |
| 9388 | { |
| 9389 | return gl::error(GL_OUT_OF_MEMORY); |
| 9390 | } |
| 9391 | } |
| 9392 | |
| 9393 | void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) |
| 9394 | { |
| 9395 | EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays); |
| 9396 | |
| 9397 | try |
| 9398 | { |
| 9399 | gl::Context *context = gl::getNonLostContext(); |
| 9400 | |
| 9401 | if (context) |
| 9402 | { |
| 9403 | if (context->getClientVersion() < 3) |
| 9404 | { |
| 9405 | return gl::error(GL_INVALID_OPERATION); |
| 9406 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9407 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9408 | if (n < 0) |
| 9409 | { |
| 9410 | return gl::error(GL_INVALID_VALUE); |
| 9411 | } |
| 9412 | |
| 9413 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 9414 | { |
| 9415 | if (arrays[arrayIndex] != 0) |
| 9416 | { |
| 9417 | context->deleteVertexArray(arrays[arrayIndex]); |
| 9418 | } |
| 9419 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9420 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9421 | } |
| 9422 | catch(std::bad_alloc&) |
| 9423 | { |
| 9424 | return gl::error(GL_OUT_OF_MEMORY); |
| 9425 | } |
| 9426 | } |
| 9427 | |
| 9428 | void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) |
| 9429 | { |
| 9430 | EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays); |
| 9431 | |
| 9432 | try |
| 9433 | { |
| 9434 | gl::Context *context = gl::getNonLostContext(); |
| 9435 | |
| 9436 | if (context) |
| 9437 | { |
| 9438 | if (context->getClientVersion() < 3) |
| 9439 | { |
| 9440 | return gl::error(GL_INVALID_OPERATION); |
| 9441 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9442 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9443 | if (n < 0) |
| 9444 | { |
| 9445 | return gl::error(GL_INVALID_VALUE); |
| 9446 | } |
| 9447 | |
| 9448 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 9449 | { |
| 9450 | arrays[arrayIndex] = context->createVertexArray(); |
| 9451 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9452 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9453 | } |
| 9454 | catch(std::bad_alloc&) |
| 9455 | { |
| 9456 | return gl::error(GL_OUT_OF_MEMORY); |
| 9457 | } |
| 9458 | } |
| 9459 | |
| 9460 | GLboolean __stdcall glIsVertexArray(GLuint array) |
| 9461 | { |
| 9462 | EVENT("(GLuint array = %u)", array); |
| 9463 | |
| 9464 | try |
| 9465 | { |
| 9466 | gl::Context *context = gl::getNonLostContext(); |
| 9467 | |
| 9468 | if (context) |
| 9469 | { |
| 9470 | if (context->getClientVersion() < 3) |
| 9471 | { |
| 9472 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 9473 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9474 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9475 | if (array == 0) |
| 9476 | { |
| 9477 | return GL_FALSE; |
| 9478 | } |
| 9479 | |
| 9480 | gl::VertexArray *vao = context->getVertexArray(array); |
| 9481 | |
| 9482 | return (vao != NULL ? GL_TRUE : GL_FALSE); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9483 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9484 | } |
| 9485 | catch(std::bad_alloc&) |
| 9486 | { |
| 9487 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 9488 | } |
| 9489 | |
| 9490 | return GL_FALSE; |
| 9491 | } |
| 9492 | |
| 9493 | void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data) |
| 9494 | { |
| 9495 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)", |
| 9496 | target, index, data); |
| 9497 | |
| 9498 | try |
| 9499 | { |
| 9500 | gl::Context *context = gl::getNonLostContext(); |
| 9501 | |
| 9502 | if (context) |
| 9503 | { |
| 9504 | if (context->getClientVersion() < 3) |
| 9505 | { |
| 9506 | return gl::error(GL_INVALID_OPERATION); |
| 9507 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9508 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9509 | // glGetIntegeri_v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9510 | UNIMPLEMENTED(); |
| 9511 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9512 | } |
| 9513 | catch(std::bad_alloc&) |
| 9514 | { |
| 9515 | return gl::error(GL_OUT_OF_MEMORY); |
| 9516 | } |
| 9517 | } |
| 9518 | |
| 9519 | void __stdcall glBeginTransformFeedback(GLenum primitiveMode) |
| 9520 | { |
| 9521 | EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode); |
| 9522 | |
| 9523 | try |
| 9524 | { |
| 9525 | gl::Context *context = gl::getNonLostContext(); |
| 9526 | |
| 9527 | if (context) |
| 9528 | { |
| 9529 | if (context->getClientVersion() < 3) |
| 9530 | { |
| 9531 | return gl::error(GL_INVALID_OPERATION); |
| 9532 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9533 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9534 | // glBeginTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9535 | UNIMPLEMENTED(); |
| 9536 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9537 | } |
| 9538 | catch(std::bad_alloc&) |
| 9539 | { |
| 9540 | return gl::error(GL_OUT_OF_MEMORY); |
| 9541 | } |
| 9542 | } |
| 9543 | |
| 9544 | void __stdcall glEndTransformFeedback(void) |
| 9545 | { |
| 9546 | EVENT("(void)"); |
| 9547 | |
| 9548 | try |
| 9549 | { |
| 9550 | gl::Context *context = gl::getNonLostContext(); |
| 9551 | |
| 9552 | if (context) |
| 9553 | { |
| 9554 | if (context->getClientVersion() < 3) |
| 9555 | { |
| 9556 | return gl::error(GL_INVALID_OPERATION); |
| 9557 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9558 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9559 | // glEndTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9560 | UNIMPLEMENTED(); |
| 9561 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9562 | } |
| 9563 | catch(std::bad_alloc&) |
| 9564 | { |
| 9565 | return gl::error(GL_OUT_OF_MEMORY); |
| 9566 | } |
| 9567 | } |
| 9568 | |
| 9569 | void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
| 9570 | { |
| 9571 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)", |
| 9572 | target, index, buffer, offset, size); |
| 9573 | |
| 9574 | try |
| 9575 | { |
| 9576 | gl::Context *context = gl::getNonLostContext(); |
| 9577 | |
| 9578 | if (context) |
| 9579 | { |
| 9580 | if (context->getClientVersion() < 3) |
| 9581 | { |
| 9582 | return gl::error(GL_INVALID_OPERATION); |
| 9583 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9584 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9585 | switch (target) |
| 9586 | { |
| 9587 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9588 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9589 | { |
| 9590 | return gl::error(GL_INVALID_VALUE); |
| 9591 | } |
| 9592 | break; |
| 9593 | |
| 9594 | case GL_UNIFORM_BUFFER: |
| 9595 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 9596 | { |
| 9597 | return gl::error(GL_INVALID_VALUE); |
| 9598 | } |
| 9599 | break; |
| 9600 | |
| 9601 | default: |
| 9602 | return gl::error(GL_INVALID_ENUM); |
| 9603 | } |
| 9604 | |
shannonwoods@chromium.org | e6e0079 | 2013-05-30 00:06:07 +0000 | [diff] [blame] | 9605 | if (buffer != 0 && size <= 0) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9606 | { |
| 9607 | return gl::error(GL_INVALID_VALUE); |
| 9608 | } |
| 9609 | |
| 9610 | switch (target) |
| 9611 | { |
| 9612 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | a26aeaf | 2013-05-30 00:06:13 +0000 | [diff] [blame] | 9613 | |
| 9614 | // size and offset must be a multiple of 4 |
| 9615 | if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) |
| 9616 | { |
| 9617 | return gl::error(GL_INVALID_VALUE); |
| 9618 | } |
| 9619 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9620 | context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 9621 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9622 | break; |
| 9623 | |
| 9624 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 97c3d50 | 2013-05-30 00:04:34 +0000 | [diff] [blame] | 9625 | |
| 9626 | // it is an error to bind an offset not a multiple of the alignment |
| 9627 | if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0) |
| 9628 | { |
| 9629 | return gl::error(GL_INVALID_VALUE); |
| 9630 | } |
| 9631 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9632 | context->bindIndexedUniformBuffer(buffer, index, offset, size); |
| 9633 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9634 | break; |
| 9635 | |
| 9636 | default: |
| 9637 | UNREACHABLE(); |
| 9638 | } |
| 9639 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9640 | } |
| 9641 | catch(std::bad_alloc&) |
| 9642 | { |
| 9643 | return gl::error(GL_OUT_OF_MEMORY); |
| 9644 | } |
| 9645 | } |
| 9646 | |
| 9647 | void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 9648 | { |
| 9649 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)", |
| 9650 | target, index, buffer); |
| 9651 | |
| 9652 | try |
| 9653 | { |
| 9654 | gl::Context *context = gl::getNonLostContext(); |
| 9655 | |
| 9656 | if (context) |
| 9657 | { |
| 9658 | if (context->getClientVersion() < 3) |
| 9659 | { |
| 9660 | return gl::error(GL_INVALID_OPERATION); |
| 9661 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9662 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9663 | switch (target) |
| 9664 | { |
| 9665 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9666 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9667 | { |
| 9668 | return gl::error(GL_INVALID_VALUE); |
| 9669 | } |
| 9670 | break; |
| 9671 | |
| 9672 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9673 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9674 | { |
| 9675 | return gl::error(GL_INVALID_VALUE); |
| 9676 | } |
| 9677 | break; |
| 9678 | |
| 9679 | default: |
| 9680 | return gl::error(GL_INVALID_ENUM); |
| 9681 | } |
| 9682 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9683 | switch (target) |
| 9684 | { |
| 9685 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9686 | context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9687 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9688 | break; |
| 9689 | |
| 9690 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9691 | context->bindIndexedUniformBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9692 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9693 | break; |
| 9694 | |
| 9695 | default: |
| 9696 | UNREACHABLE(); |
| 9697 | } |
| 9698 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9699 | } |
| 9700 | catch(std::bad_alloc&) |
| 9701 | { |
| 9702 | return gl::error(GL_OUT_OF_MEMORY); |
| 9703 | } |
| 9704 | } |
| 9705 | |
| 9706 | void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
| 9707 | { |
| 9708 | EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)", |
| 9709 | program, count, varyings, bufferMode); |
| 9710 | |
| 9711 | try |
| 9712 | { |
| 9713 | gl::Context *context = gl::getNonLostContext(); |
| 9714 | |
| 9715 | if (context) |
| 9716 | { |
| 9717 | if (context->getClientVersion() < 3) |
| 9718 | { |
| 9719 | return gl::error(GL_INVALID_OPERATION); |
| 9720 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9721 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9722 | // glTransformFeedbackVaryings |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9723 | UNIMPLEMENTED(); |
| 9724 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9725 | } |
| 9726 | catch(std::bad_alloc&) |
| 9727 | { |
| 9728 | return gl::error(GL_OUT_OF_MEMORY); |
| 9729 | } |
| 9730 | } |
| 9731 | |
| 9732 | void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
| 9733 | { |
| 9734 | EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, " |
| 9735 | "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
| 9736 | program, index, bufSize, length, size, type, name); |
| 9737 | |
| 9738 | try |
| 9739 | { |
| 9740 | gl::Context *context = gl::getNonLostContext(); |
| 9741 | |
| 9742 | if (context) |
| 9743 | { |
| 9744 | if (context->getClientVersion() < 3) |
| 9745 | { |
| 9746 | return gl::error(GL_INVALID_OPERATION); |
| 9747 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9748 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9749 | // glGetTransformFeedbackVarying |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9750 | UNIMPLEMENTED(); |
| 9751 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9752 | } |
| 9753 | catch(std::bad_alloc&) |
| 9754 | { |
| 9755 | return gl::error(GL_OUT_OF_MEMORY); |
| 9756 | } |
| 9757 | } |
| 9758 | |
| 9759 | void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) |
| 9760 | { |
| 9761 | EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)", |
| 9762 | index, size, type, stride, pointer); |
| 9763 | |
| 9764 | try |
| 9765 | { |
| 9766 | gl::Context *context = gl::getNonLostContext(); |
| 9767 | |
| 9768 | if (context) |
| 9769 | { |
| 9770 | if (context->getClientVersion() < 3) |
| 9771 | { |
| 9772 | return gl::error(GL_INVALID_OPERATION); |
| 9773 | } |
| 9774 | } |
| 9775 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9776 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9777 | { |
| 9778 | return gl::error(GL_INVALID_VALUE); |
| 9779 | } |
| 9780 | |
| 9781 | if (size < 1 || size > 4) |
| 9782 | { |
| 9783 | return gl::error(GL_INVALID_VALUE); |
| 9784 | } |
| 9785 | |
| 9786 | switch (type) |
| 9787 | { |
| 9788 | case GL_BYTE: |
| 9789 | case GL_UNSIGNED_BYTE: |
| 9790 | case GL_SHORT: |
| 9791 | case GL_UNSIGNED_SHORT: |
| 9792 | case GL_INT: |
| 9793 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9794 | case GL_INT_2_10_10_10_REV: |
| 9795 | 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] | 9796 | break; |
| 9797 | default: |
| 9798 | return gl::error(GL_INVALID_ENUM); |
| 9799 | } |
| 9800 | |
| 9801 | if (stride < 0) |
| 9802 | { |
| 9803 | return gl::error(GL_INVALID_VALUE); |
| 9804 | } |
| 9805 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9806 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 9807 | { |
| 9808 | return gl::error(GL_INVALID_OPERATION); |
| 9809 | } |
| 9810 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9811 | if (context) |
| 9812 | { |
Jamie Madill | d8db866 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9813 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 9814 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 9815 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 9816 | // and the pointer argument is not NULL. |
| 9817 | if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && pointer != NULL) |
| 9818 | { |
| 9819 | return gl::error(GL_INVALID_OPERATION); |
| 9820 | } |
| 9821 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9822 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true, |
| 9823 | stride, pointer); |
| 9824 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9825 | } |
| 9826 | catch(std::bad_alloc&) |
| 9827 | { |
| 9828 | return gl::error(GL_OUT_OF_MEMORY); |
| 9829 | } |
| 9830 | } |
| 9831 | |
| 9832 | void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) |
| 9833 | { |
| 9834 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 9835 | index, pname, params); |
| 9836 | |
| 9837 | try |
| 9838 | { |
| 9839 | gl::Context *context = gl::getNonLostContext(); |
| 9840 | |
| 9841 | if (context) |
| 9842 | { |
| 9843 | if (context->getClientVersion() < 3) |
| 9844 | { |
| 9845 | return gl::error(GL_INVALID_OPERATION); |
| 9846 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9847 | |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 9848 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9849 | { |
| 9850 | return gl::error(GL_INVALID_VALUE); |
| 9851 | } |
| 9852 | |
| 9853 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
| 9854 | |
| 9855 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
| 9856 | { |
| 9857 | return; |
| 9858 | } |
| 9859 | |
| 9860 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 9861 | { |
| 9862 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 9863 | for (int i = 0; i < 4; ++i) |
| 9864 | { |
| 9865 | params[i] = currentValueData.IntValues[i]; |
| 9866 | } |
| 9867 | } |
| 9868 | else |
| 9869 | { |
| 9870 | *params = attribState.querySingleParameter<GLint>(pname); |
| 9871 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9872 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9873 | } |
| 9874 | catch(std::bad_alloc&) |
| 9875 | { |
| 9876 | return gl::error(GL_OUT_OF_MEMORY); |
| 9877 | } |
| 9878 | } |
| 9879 | |
| 9880 | void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) |
| 9881 | { |
| 9882 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)", |
| 9883 | index, pname, params); |
| 9884 | |
| 9885 | try |
| 9886 | { |
| 9887 | gl::Context *context = gl::getNonLostContext(); |
| 9888 | |
| 9889 | if (context) |
| 9890 | { |
| 9891 | if (context->getClientVersion() < 3) |
| 9892 | { |
| 9893 | return gl::error(GL_INVALID_OPERATION); |
| 9894 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9895 | |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 9896 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9897 | { |
| 9898 | return gl::error(GL_INVALID_VALUE); |
| 9899 | } |
| 9900 | |
| 9901 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
| 9902 | |
| 9903 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
| 9904 | { |
| 9905 | return; |
| 9906 | } |
| 9907 | |
| 9908 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 9909 | { |
| 9910 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 9911 | for (int i = 0; i < 4; ++i) |
| 9912 | { |
| 9913 | params[i] = currentValueData.UnsignedIntValues[i]; |
| 9914 | } |
| 9915 | } |
| 9916 | else |
| 9917 | { |
| 9918 | *params = attribState.querySingleParameter<GLuint>(pname); |
| 9919 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9920 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9921 | } |
| 9922 | catch(std::bad_alloc&) |
| 9923 | { |
| 9924 | return gl::error(GL_OUT_OF_MEMORY); |
| 9925 | } |
| 9926 | } |
| 9927 | |
| 9928 | void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 9929 | { |
| 9930 | EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)", |
| 9931 | index, x, y, z, w); |
| 9932 | |
| 9933 | try |
| 9934 | { |
| 9935 | gl::Context *context = gl::getNonLostContext(); |
| 9936 | |
| 9937 | if (context) |
| 9938 | { |
| 9939 | if (context->getClientVersion() < 3) |
| 9940 | { |
| 9941 | return gl::error(GL_INVALID_OPERATION); |
| 9942 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9943 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9944 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9945 | { |
| 9946 | return gl::error(GL_INVALID_VALUE); |
| 9947 | } |
| 9948 | |
| 9949 | GLint vals[4] = { x, y, z, w }; |
| 9950 | context->setVertexAttribi(index, vals); |
| 9951 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9952 | } |
| 9953 | catch(std::bad_alloc&) |
| 9954 | { |
| 9955 | return gl::error(GL_OUT_OF_MEMORY); |
| 9956 | } |
| 9957 | } |
| 9958 | |
| 9959 | void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 9960 | { |
| 9961 | EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)", |
| 9962 | index, x, y, z, w); |
| 9963 | |
| 9964 | try |
| 9965 | { |
| 9966 | gl::Context *context = gl::getNonLostContext(); |
| 9967 | |
| 9968 | if (context) |
| 9969 | { |
| 9970 | if (context->getClientVersion() < 3) |
| 9971 | { |
| 9972 | return gl::error(GL_INVALID_OPERATION); |
| 9973 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9974 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9975 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9976 | { |
| 9977 | return gl::error(GL_INVALID_VALUE); |
| 9978 | } |
| 9979 | |
| 9980 | GLuint vals[4] = { x, y, z, w }; |
| 9981 | context->setVertexAttribu(index, vals); |
| 9982 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9983 | } |
| 9984 | catch(std::bad_alloc&) |
| 9985 | { |
| 9986 | return gl::error(GL_OUT_OF_MEMORY); |
| 9987 | } |
| 9988 | } |
| 9989 | |
| 9990 | void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) |
| 9991 | { |
| 9992 | EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v); |
| 9993 | |
| 9994 | try |
| 9995 | { |
| 9996 | gl::Context *context = gl::getNonLostContext(); |
| 9997 | |
| 9998 | if (context) |
| 9999 | { |
| 10000 | if (context->getClientVersion() < 3) |
| 10001 | { |
| 10002 | return gl::error(GL_INVALID_OPERATION); |
| 10003 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10004 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 10005 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 10006 | { |
| 10007 | return gl::error(GL_INVALID_VALUE); |
| 10008 | } |
| 10009 | |
| 10010 | context->setVertexAttribi(index, v); |
| 10011 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10012 | } |
| 10013 | catch(std::bad_alloc&) |
| 10014 | { |
| 10015 | return gl::error(GL_OUT_OF_MEMORY); |
| 10016 | } |
| 10017 | } |
| 10018 | |
| 10019 | void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v) |
| 10020 | { |
| 10021 | EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v); |
| 10022 | |
| 10023 | try |
| 10024 | { |
| 10025 | gl::Context *context = gl::getNonLostContext(); |
| 10026 | |
| 10027 | if (context) |
| 10028 | { |
| 10029 | if (context->getClientVersion() < 3) |
| 10030 | { |
| 10031 | return gl::error(GL_INVALID_OPERATION); |
| 10032 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10033 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 10034 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 10035 | { |
| 10036 | return gl::error(GL_INVALID_VALUE); |
| 10037 | } |
| 10038 | |
| 10039 | context->setVertexAttribu(index, v); |
| 10040 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10041 | } |
| 10042 | catch(std::bad_alloc&) |
| 10043 | { |
| 10044 | return gl::error(GL_OUT_OF_MEMORY); |
| 10045 | } |
| 10046 | } |
| 10047 | |
| 10048 | void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) |
| 10049 | { |
| 10050 | EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)", |
| 10051 | program, location, params); |
| 10052 | |
| 10053 | try |
| 10054 | { |
| 10055 | gl::Context *context = gl::getNonLostContext(); |
| 10056 | |
| 10057 | if (context) |
| 10058 | { |
| 10059 | if (context->getClientVersion() < 3) |
| 10060 | { |
| 10061 | return gl::error(GL_INVALID_OPERATION); |
| 10062 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10063 | |
shannon.woods%transgaming.com@gtempaccount.com | e229012 | 2013-04-13 03:41:07 +0000 | [diff] [blame] | 10064 | if (program == 0) |
| 10065 | { |
| 10066 | return gl::error(GL_INVALID_VALUE); |
| 10067 | } |
| 10068 | |
| 10069 | gl::Program *programObject = context->getProgram(program); |
| 10070 | |
| 10071 | if (!programObject || !programObject->isLinked()) |
| 10072 | { |
| 10073 | return gl::error(GL_INVALID_OPERATION); |
| 10074 | } |
| 10075 | |
| 10076 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10077 | if (!programBinary) |
| 10078 | { |
| 10079 | return gl::error(GL_INVALID_OPERATION); |
| 10080 | } |
| 10081 | |
| 10082 | if (!programBinary->getUniformuiv(location, NULL, params)) |
| 10083 | { |
| 10084 | return gl::error(GL_INVALID_OPERATION); |
| 10085 | } |
| 10086 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10087 | } |
| 10088 | catch(std::bad_alloc&) |
| 10089 | { |
| 10090 | return gl::error(GL_OUT_OF_MEMORY); |
| 10091 | } |
| 10092 | } |
| 10093 | |
| 10094 | GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) |
| 10095 | { |
| 10096 | EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)", |
| 10097 | program, name); |
| 10098 | |
| 10099 | try |
| 10100 | { |
| 10101 | gl::Context *context = gl::getNonLostContext(); |
| 10102 | |
| 10103 | if (context) |
| 10104 | { |
| 10105 | if (context->getClientVersion() < 3) |
| 10106 | { |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame] | 10107 | return gl::error(GL_INVALID_OPERATION, -1); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10108 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10109 | |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame] | 10110 | if (program == 0) |
| 10111 | { |
| 10112 | return gl::error(GL_INVALID_VALUE, -1); |
| 10113 | } |
| 10114 | |
| 10115 | gl::Program *programObject = context->getProgram(program); |
| 10116 | |
| 10117 | if (!programObject || !programObject->isLinked()) |
| 10118 | { |
| 10119 | return gl::error(GL_INVALID_OPERATION, -1); |
| 10120 | } |
| 10121 | |
| 10122 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10123 | if (!programBinary) |
| 10124 | { |
| 10125 | return gl::error(GL_INVALID_OPERATION, -1); |
| 10126 | } |
| 10127 | |
| 10128 | return programBinary->getFragDataLocation(name); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10129 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10130 | } |
| 10131 | catch(std::bad_alloc&) |
| 10132 | { |
| 10133 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10134 | } |
| 10135 | |
| 10136 | return 0; |
| 10137 | } |
| 10138 | |
| 10139 | void __stdcall glUniform1ui(GLint location, GLuint v0) |
| 10140 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10141 | glUniform1uiv(location, 1, &v0); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10142 | } |
| 10143 | |
| 10144 | void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1) |
| 10145 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10146 | const GLuint xy[] = { v0, v1 }; |
| 10147 | glUniform2uiv(location, 1, xy); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10148 | } |
| 10149 | |
| 10150 | void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 10151 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10152 | const GLuint xyz[] = { v0, v1, v2 }; |
| 10153 | glUniform3uiv(location, 1, xyz); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10154 | } |
| 10155 | |
| 10156 | void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 10157 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10158 | const GLuint xyzw[] = { v0, v1, v2, v3 }; |
| 10159 | glUniform4uiv(location, 1, xyzw); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10160 | } |
| 10161 | |
| 10162 | void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) |
| 10163 | { |
| 10164 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 10165 | location, count, value); |
| 10166 | |
| 10167 | try |
| 10168 | { |
| 10169 | gl::Context *context = gl::getNonLostContext(); |
| 10170 | |
| 10171 | if (context) |
| 10172 | { |
| 10173 | if (context->getClientVersion() < 3) |
| 10174 | { |
| 10175 | return gl::error(GL_INVALID_OPERATION); |
| 10176 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10177 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10178 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10179 | if (!programBinary) |
| 10180 | { |
| 10181 | return gl::error(GL_INVALID_OPERATION); |
| 10182 | } |
| 10183 | |
| 10184 | if (!programBinary->setUniform1uiv(location, count, value)) |
| 10185 | { |
| 10186 | return gl::error(GL_INVALID_OPERATION); |
| 10187 | } |
| 10188 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10189 | } |
| 10190 | catch(std::bad_alloc&) |
| 10191 | { |
| 10192 | return gl::error(GL_OUT_OF_MEMORY); |
| 10193 | } |
| 10194 | } |
| 10195 | |
| 10196 | void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) |
| 10197 | { |
| 10198 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 10199 | location, count, value); |
| 10200 | |
| 10201 | try |
| 10202 | { |
| 10203 | gl::Context *context = gl::getNonLostContext(); |
| 10204 | |
| 10205 | if (context) |
| 10206 | { |
| 10207 | if (context->getClientVersion() < 3) |
| 10208 | { |
| 10209 | return gl::error(GL_INVALID_OPERATION); |
| 10210 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10211 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10212 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10213 | if (!programBinary) |
| 10214 | { |
| 10215 | return gl::error(GL_INVALID_OPERATION); |
| 10216 | } |
| 10217 | |
| 10218 | if (!programBinary->setUniform2uiv(location, count, value)) |
| 10219 | { |
| 10220 | return gl::error(GL_INVALID_OPERATION); |
| 10221 | } |
| 10222 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10223 | } |
| 10224 | catch(std::bad_alloc&) |
| 10225 | { |
| 10226 | return gl::error(GL_OUT_OF_MEMORY); |
| 10227 | } |
| 10228 | } |
| 10229 | |
| 10230 | void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) |
| 10231 | { |
| 10232 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)", |
| 10233 | location, count, value); |
| 10234 | |
| 10235 | try |
| 10236 | { |
| 10237 | gl::Context *context = gl::getNonLostContext(); |
| 10238 | |
| 10239 | if (context) |
| 10240 | { |
| 10241 | if (context->getClientVersion() < 3) |
| 10242 | { |
| 10243 | return gl::error(GL_INVALID_OPERATION); |
| 10244 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10245 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10246 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10247 | if (!programBinary) |
| 10248 | { |
| 10249 | return gl::error(GL_INVALID_OPERATION); |
| 10250 | } |
| 10251 | |
| 10252 | if (!programBinary->setUniform3uiv(location, count, value)) |
| 10253 | { |
| 10254 | return gl::error(GL_INVALID_OPERATION); |
| 10255 | } |
| 10256 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10257 | } |
| 10258 | catch(std::bad_alloc&) |
| 10259 | { |
| 10260 | return gl::error(GL_OUT_OF_MEMORY); |
| 10261 | } |
| 10262 | } |
| 10263 | |
| 10264 | void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) |
| 10265 | { |
| 10266 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 10267 | location, count, value); |
| 10268 | |
| 10269 | try |
| 10270 | { |
| 10271 | gl::Context *context = gl::getNonLostContext(); |
| 10272 | |
| 10273 | if (context) |
| 10274 | { |
| 10275 | if (context->getClientVersion() < 3) |
| 10276 | { |
| 10277 | return gl::error(GL_INVALID_OPERATION); |
| 10278 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10279 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10280 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10281 | if (!programBinary) |
| 10282 | { |
| 10283 | return gl::error(GL_INVALID_OPERATION); |
| 10284 | } |
| 10285 | |
| 10286 | if (!programBinary->setUniform4uiv(location, count, value)) |
| 10287 | { |
| 10288 | return gl::error(GL_INVALID_OPERATION); |
| 10289 | } |
| 10290 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10291 | } |
| 10292 | catch(std::bad_alloc&) |
| 10293 | { |
| 10294 | return gl::error(GL_OUT_OF_MEMORY); |
| 10295 | } |
| 10296 | } |
| 10297 | |
| 10298 | void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) |
| 10299 | { |
| 10300 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)", |
| 10301 | buffer, drawbuffer, value); |
| 10302 | |
| 10303 | try |
| 10304 | { |
| 10305 | gl::Context *context = gl::getNonLostContext(); |
| 10306 | |
| 10307 | if (context) |
| 10308 | { |
| 10309 | if (context->getClientVersion() < 3) |
| 10310 | { |
| 10311 | return gl::error(GL_INVALID_OPERATION); |
| 10312 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10313 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10314 | // glClearBufferiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10315 | UNIMPLEMENTED(); |
| 10316 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10317 | } |
| 10318 | catch(std::bad_alloc&) |
| 10319 | { |
| 10320 | return gl::error(GL_OUT_OF_MEMORY); |
| 10321 | } |
| 10322 | } |
| 10323 | |
| 10324 | void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) |
| 10325 | { |
| 10326 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)", |
| 10327 | buffer, drawbuffer, value); |
| 10328 | |
| 10329 | try |
| 10330 | { |
| 10331 | gl::Context *context = gl::getNonLostContext(); |
| 10332 | |
| 10333 | if (context) |
| 10334 | { |
| 10335 | if (context->getClientVersion() < 3) |
| 10336 | { |
| 10337 | return gl::error(GL_INVALID_OPERATION); |
| 10338 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10339 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10340 | // glClearBufferuiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10341 | UNIMPLEMENTED(); |
| 10342 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10343 | } |
| 10344 | catch(std::bad_alloc&) |
| 10345 | { |
| 10346 | return gl::error(GL_OUT_OF_MEMORY); |
| 10347 | } |
| 10348 | } |
| 10349 | |
| 10350 | void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) |
| 10351 | { |
| 10352 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)", |
| 10353 | buffer, drawbuffer, value); |
| 10354 | |
| 10355 | try |
| 10356 | { |
| 10357 | gl::Context *context = gl::getNonLostContext(); |
| 10358 | |
| 10359 | if (context) |
| 10360 | { |
| 10361 | if (context->getClientVersion() < 3) |
| 10362 | { |
| 10363 | return gl::error(GL_INVALID_OPERATION); |
| 10364 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10365 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10366 | // glClearBufferfv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10367 | UNIMPLEMENTED(); |
| 10368 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10369 | } |
| 10370 | catch(std::bad_alloc&) |
| 10371 | { |
| 10372 | return gl::error(GL_OUT_OF_MEMORY); |
| 10373 | } |
| 10374 | } |
| 10375 | |
| 10376 | void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 10377 | { |
| 10378 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)", |
| 10379 | buffer, drawbuffer, depth, stencil); |
| 10380 | |
| 10381 | try |
| 10382 | { |
| 10383 | gl::Context *context = gl::getNonLostContext(); |
| 10384 | |
| 10385 | if (context) |
| 10386 | { |
| 10387 | if (context->getClientVersion() < 3) |
| 10388 | { |
| 10389 | return gl::error(GL_INVALID_OPERATION); |
| 10390 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10391 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10392 | // glClearBufferfi |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10393 | UNIMPLEMENTED(); |
| 10394 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10395 | } |
| 10396 | catch(std::bad_alloc&) |
| 10397 | { |
| 10398 | return gl::error(GL_OUT_OF_MEMORY); |
| 10399 | } |
| 10400 | } |
| 10401 | |
| 10402 | const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) |
| 10403 | { |
| 10404 | EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index); |
| 10405 | |
| 10406 | try |
| 10407 | { |
| 10408 | gl::Context *context = gl::getNonLostContext(); |
| 10409 | |
| 10410 | if (context) |
| 10411 | { |
| 10412 | if (context->getClientVersion() < 3) |
| 10413 | { |
| 10414 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL)); |
| 10415 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10416 | |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 10417 | if (name != GL_EXTENSIONS) |
| 10418 | { |
| 10419 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL)); |
| 10420 | } |
| 10421 | |
| 10422 | if (index >= context->getNumExtensions()) |
| 10423 | { |
| 10424 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL)); |
| 10425 | } |
| 10426 | |
| 10427 | return reinterpret_cast<const GLubyte*>(context->getExtensionString(index)); |
| 10428 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10429 | } |
| 10430 | catch(std::bad_alloc&) |
| 10431 | { |
| 10432 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL)); |
| 10433 | } |
| 10434 | |
| 10435 | return NULL; |
| 10436 | } |
| 10437 | |
| 10438 | void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 10439 | { |
| 10440 | EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)", |
| 10441 | readTarget, writeTarget, readOffset, writeOffset, size); |
| 10442 | |
| 10443 | try |
| 10444 | { |
| 10445 | gl::Context *context = gl::getNonLostContext(); |
| 10446 | |
| 10447 | if (context) |
| 10448 | { |
| 10449 | if (context->getClientVersion() < 3) |
| 10450 | { |
| 10451 | return gl::error(GL_INVALID_OPERATION); |
| 10452 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10453 | |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 10454 | gl::Buffer *readBuffer = NULL; |
| 10455 | switch (readTarget) |
| 10456 | { |
| 10457 | case GL_ARRAY_BUFFER: |
| 10458 | readBuffer = context->getArrayBuffer(); |
| 10459 | break; |
| 10460 | case GL_COPY_READ_BUFFER: |
| 10461 | readBuffer = context->getCopyReadBuffer(); |
| 10462 | break; |
| 10463 | case GL_COPY_WRITE_BUFFER: |
| 10464 | readBuffer = context->getCopyWriteBuffer(); |
| 10465 | break; |
| 10466 | case GL_ELEMENT_ARRAY_BUFFER: |
| 10467 | readBuffer = context->getElementArrayBuffer(); |
| 10468 | break; |
| 10469 | case GL_PIXEL_PACK_BUFFER: |
| 10470 | readBuffer = context->getPixelPackBuffer(); |
| 10471 | break; |
| 10472 | case GL_PIXEL_UNPACK_BUFFER: |
| 10473 | readBuffer = context->getPixelUnpackBuffer(); |
| 10474 | break; |
| 10475 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 10476 | readBuffer = context->getGenericTransformFeedbackBuffer(); |
| 10477 | break; |
| 10478 | case GL_UNIFORM_BUFFER: |
| 10479 | readBuffer = context->getGenericUniformBuffer(); |
| 10480 | break; |
| 10481 | default: |
| 10482 | return gl::error(GL_INVALID_ENUM); |
| 10483 | } |
| 10484 | |
| 10485 | gl::Buffer *writeBuffer = NULL; |
| 10486 | switch (writeTarget) |
| 10487 | { |
| 10488 | case GL_ARRAY_BUFFER: |
| 10489 | writeBuffer = context->getArrayBuffer(); |
| 10490 | break; |
| 10491 | case GL_COPY_READ_BUFFER: |
| 10492 | writeBuffer = context->getCopyReadBuffer(); |
| 10493 | break; |
| 10494 | case GL_COPY_WRITE_BUFFER: |
| 10495 | writeBuffer = context->getCopyWriteBuffer(); |
| 10496 | break; |
| 10497 | case GL_ELEMENT_ARRAY_BUFFER: |
| 10498 | writeBuffer = context->getElementArrayBuffer(); |
| 10499 | break; |
| 10500 | case GL_PIXEL_PACK_BUFFER: |
| 10501 | writeBuffer = context->getPixelPackBuffer(); |
| 10502 | break; |
| 10503 | case GL_PIXEL_UNPACK_BUFFER: |
| 10504 | writeBuffer = context->getPixelUnpackBuffer(); |
| 10505 | break; |
| 10506 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 10507 | writeBuffer = context->getGenericTransformFeedbackBuffer(); |
| 10508 | break; |
| 10509 | case GL_UNIFORM_BUFFER: |
| 10510 | writeBuffer = context->getGenericUniformBuffer(); |
| 10511 | break; |
| 10512 | default: |
| 10513 | return gl::error(GL_INVALID_ENUM); |
| 10514 | } |
| 10515 | |
| 10516 | if (!readBuffer || !writeBuffer) |
| 10517 | { |
| 10518 | return gl::error(GL_INVALID_OPERATION); |
| 10519 | } |
| 10520 | |
| 10521 | if (readOffset < 0 || writeOffset < 0 || size < 0 || |
| 10522 | static_cast<unsigned int>(readOffset + size) > readBuffer->size() || |
| 10523 | static_cast<unsigned int>(writeOffset + size) > writeBuffer->size()) |
| 10524 | { |
| 10525 | return gl::error(GL_INVALID_VALUE); |
| 10526 | } |
| 10527 | |
| 10528 | if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size) |
| 10529 | { |
| 10530 | return gl::error(GL_INVALID_VALUE); |
| 10531 | } |
| 10532 | |
| 10533 | // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION) |
| 10534 | |
shannon.woods%transgaming.com@gtempaccount.com | c53376a | 2013-04-13 03:41:23 +0000 | [diff] [blame] | 10535 | // if size is zero, the copy is a successful no-op |
| 10536 | if (size > 0) |
| 10537 | { |
| 10538 | writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); |
| 10539 | } |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 10540 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10541 | } |
| 10542 | catch(std::bad_alloc&) |
| 10543 | { |
| 10544 | return gl::error(GL_OUT_OF_MEMORY); |
| 10545 | } |
| 10546 | } |
| 10547 | |
| 10548 | void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) |
| 10549 | { |
| 10550 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)", |
| 10551 | program, uniformCount, uniformNames, uniformIndices); |
| 10552 | |
| 10553 | try |
| 10554 | { |
| 10555 | gl::Context *context = gl::getNonLostContext(); |
| 10556 | |
| 10557 | if (context) |
| 10558 | { |
| 10559 | if (context->getClientVersion() < 3) |
| 10560 | { |
| 10561 | return gl::error(GL_INVALID_OPERATION); |
| 10562 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10563 | |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 10564 | if (uniformCount < 0) |
| 10565 | { |
| 10566 | return gl::error(GL_INVALID_VALUE); |
| 10567 | } |
| 10568 | |
| 10569 | gl::Program *programObject = context->getProgram(program); |
| 10570 | |
| 10571 | if (!programObject) |
| 10572 | { |
| 10573 | if (context->getShader(program)) |
| 10574 | { |
| 10575 | return gl::error(GL_INVALID_OPERATION); |
| 10576 | } |
| 10577 | else |
| 10578 | { |
| 10579 | return gl::error(GL_INVALID_VALUE); |
| 10580 | } |
| 10581 | } |
| 10582 | |
| 10583 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10584 | if (!programObject->isLinked() || !programBinary) |
| 10585 | { |
| 10586 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10587 | { |
| 10588 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 10589 | } |
| 10590 | } |
| 10591 | else |
| 10592 | { |
| 10593 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10594 | { |
| 10595 | uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]); |
| 10596 | } |
| 10597 | } |
| 10598 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10599 | } |
| 10600 | catch(std::bad_alloc&) |
| 10601 | { |
| 10602 | return gl::error(GL_OUT_OF_MEMORY); |
| 10603 | } |
| 10604 | } |
| 10605 | |
| 10606 | void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) |
| 10607 | { |
| 10608 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10609 | program, uniformCount, uniformIndices, pname, params); |
| 10610 | |
| 10611 | try |
| 10612 | { |
| 10613 | gl::Context *context = gl::getNonLostContext(); |
| 10614 | |
| 10615 | if (context) |
| 10616 | { |
| 10617 | if (context->getClientVersion() < 3) |
| 10618 | { |
| 10619 | return gl::error(GL_INVALID_OPERATION); |
| 10620 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10621 | |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 10622 | if (uniformCount < 0) |
| 10623 | { |
| 10624 | return gl::error(GL_INVALID_VALUE); |
| 10625 | } |
| 10626 | |
| 10627 | gl::Program *programObject = context->getProgram(program); |
| 10628 | |
| 10629 | if (!programObject) |
| 10630 | { |
| 10631 | if (context->getShader(program)) |
| 10632 | { |
| 10633 | return gl::error(GL_INVALID_OPERATION); |
| 10634 | } |
| 10635 | else |
| 10636 | { |
| 10637 | return gl::error(GL_INVALID_VALUE); |
| 10638 | } |
| 10639 | } |
| 10640 | |
| 10641 | switch (pname) |
| 10642 | { |
| 10643 | case GL_UNIFORM_TYPE: |
| 10644 | case GL_UNIFORM_SIZE: |
| 10645 | case GL_UNIFORM_NAME_LENGTH: |
| 10646 | case GL_UNIFORM_BLOCK_INDEX: |
| 10647 | case GL_UNIFORM_OFFSET: |
| 10648 | case GL_UNIFORM_ARRAY_STRIDE: |
| 10649 | case GL_UNIFORM_MATRIX_STRIDE: |
| 10650 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 10651 | break; |
| 10652 | default: |
| 10653 | return gl::error(GL_INVALID_ENUM); |
| 10654 | } |
| 10655 | |
| 10656 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10657 | |
| 10658 | if (!programBinary && uniformCount > 0) |
| 10659 | { |
| 10660 | return gl::error(GL_INVALID_VALUE); |
| 10661 | } |
| 10662 | |
| 10663 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10664 | { |
| 10665 | const GLuint index = uniformIndices[uniformId]; |
| 10666 | |
| 10667 | if (index >= (GLuint)programBinary->getActiveUniformCount()) |
| 10668 | { |
| 10669 | return gl::error(GL_INVALID_VALUE); |
| 10670 | } |
| 10671 | } |
| 10672 | |
| 10673 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10674 | { |
| 10675 | const GLuint index = uniformIndices[uniformId]; |
| 10676 | params[uniformId] = programBinary->getActiveUniformi(index, pname); |
| 10677 | } |
| 10678 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10679 | } |
| 10680 | catch(std::bad_alloc&) |
| 10681 | { |
| 10682 | return gl::error(GL_OUT_OF_MEMORY); |
| 10683 | } |
| 10684 | } |
| 10685 | |
| 10686 | GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) |
| 10687 | { |
| 10688 | EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName); |
| 10689 | |
| 10690 | try |
| 10691 | { |
| 10692 | gl::Context *context = gl::getNonLostContext(); |
| 10693 | |
| 10694 | if (context) |
| 10695 | { |
| 10696 | if (context->getClientVersion() < 3) |
| 10697 | { |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10698 | 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] | 10699 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10700 | |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10701 | gl::Program *programObject = context->getProgram(program); |
| 10702 | |
| 10703 | if (!programObject) |
| 10704 | { |
| 10705 | if (context->getShader(program)) |
| 10706 | { |
| 10707 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
| 10708 | } |
| 10709 | else |
| 10710 | { |
| 10711 | return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX); |
| 10712 | } |
| 10713 | } |
| 10714 | |
| 10715 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10716 | if (!programBinary) |
| 10717 | { |
| 10718 | return GL_INVALID_INDEX; |
| 10719 | } |
| 10720 | |
| 10721 | return programBinary->getUniformBlockIndex(uniformBlockName); |
| 10722 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10723 | } |
| 10724 | catch(std::bad_alloc&) |
| 10725 | { |
| 10726 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10727 | } |
| 10728 | |
| 10729 | return 0; |
| 10730 | } |
| 10731 | |
| 10732 | void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) |
| 10733 | { |
| 10734 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10735 | program, uniformBlockIndex, pname, params); |
| 10736 | |
| 10737 | try |
| 10738 | { |
| 10739 | gl::Context *context = gl::getNonLostContext(); |
| 10740 | |
| 10741 | if (context) |
| 10742 | { |
| 10743 | if (context->getClientVersion() < 3) |
| 10744 | { |
| 10745 | return gl::error(GL_INVALID_OPERATION); |
| 10746 | } |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10747 | gl::Program *programObject = context->getProgram(program); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10748 | |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10749 | if (!programObject) |
| 10750 | { |
| 10751 | if (context->getShader(program)) |
| 10752 | { |
| 10753 | return gl::error(GL_INVALID_OPERATION); |
| 10754 | } |
| 10755 | else |
| 10756 | { |
| 10757 | return gl::error(GL_INVALID_VALUE); |
| 10758 | } |
| 10759 | } |
| 10760 | |
| 10761 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10762 | |
| 10763 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10764 | { |
| 10765 | return gl::error(GL_INVALID_VALUE); |
| 10766 | } |
| 10767 | |
| 10768 | switch (pname) |
| 10769 | { |
| 10770 | case GL_UNIFORM_BLOCK_BINDING: |
| 10771 | *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); |
| 10772 | break; |
| 10773 | |
| 10774 | case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 10775 | case GL_UNIFORM_BLOCK_NAME_LENGTH: |
| 10776 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 10777 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| 10778 | case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
| 10779 | case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
| 10780 | programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params); |
| 10781 | break; |
| 10782 | |
| 10783 | default: |
| 10784 | return gl::error(GL_INVALID_ENUM); |
| 10785 | } |
| 10786 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10787 | } |
| 10788 | catch(std::bad_alloc&) |
| 10789 | { |
| 10790 | return gl::error(GL_OUT_OF_MEMORY); |
| 10791 | } |
| 10792 | } |
| 10793 | |
| 10794 | void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) |
| 10795 | { |
| 10796 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)", |
| 10797 | program, uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10798 | |
| 10799 | try |
| 10800 | { |
| 10801 | gl::Context *context = gl::getNonLostContext(); |
| 10802 | |
| 10803 | if (context) |
| 10804 | { |
| 10805 | if (context->getClientVersion() < 3) |
| 10806 | { |
| 10807 | return gl::error(GL_INVALID_OPERATION); |
| 10808 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10809 | |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 10810 | gl::Program *programObject = context->getProgram(program); |
| 10811 | |
| 10812 | if (!programObject) |
| 10813 | { |
| 10814 | if (context->getShader(program)) |
| 10815 | { |
| 10816 | return gl::error(GL_INVALID_OPERATION); |
| 10817 | } |
| 10818 | else |
| 10819 | { |
| 10820 | return gl::error(GL_INVALID_VALUE); |
| 10821 | } |
| 10822 | } |
| 10823 | |
| 10824 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10825 | |
| 10826 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10827 | { |
| 10828 | return gl::error(GL_INVALID_VALUE); |
| 10829 | } |
| 10830 | |
| 10831 | programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10832 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10833 | } |
| 10834 | catch(std::bad_alloc&) |
| 10835 | { |
| 10836 | return gl::error(GL_OUT_OF_MEMORY); |
| 10837 | } |
| 10838 | } |
| 10839 | |
| 10840 | void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) |
| 10841 | { |
| 10842 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)", |
| 10843 | program, uniformBlockIndex, uniformBlockBinding); |
| 10844 | |
| 10845 | try |
| 10846 | { |
| 10847 | gl::Context *context = gl::getNonLostContext(); |
| 10848 | |
| 10849 | if (context) |
| 10850 | { |
| 10851 | if (context->getClientVersion() < 3) |
| 10852 | { |
| 10853 | return gl::error(GL_INVALID_OPERATION); |
| 10854 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10855 | |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 10856 | if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings()) |
| 10857 | { |
| 10858 | return gl::error(GL_INVALID_VALUE); |
| 10859 | } |
| 10860 | |
| 10861 | gl::Program *programObject = context->getProgram(program); |
| 10862 | |
| 10863 | if (!programObject) |
| 10864 | { |
| 10865 | if (context->getShader(program)) |
| 10866 | { |
| 10867 | return gl::error(GL_INVALID_OPERATION); |
| 10868 | } |
| 10869 | else |
| 10870 | { |
| 10871 | return gl::error(GL_INVALID_VALUE); |
| 10872 | } |
| 10873 | } |
| 10874 | |
| 10875 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10876 | |
| 10877 | // if never linked, there won't be any uniform blocks |
| 10878 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10879 | { |
| 10880 | return gl::error(GL_INVALID_VALUE); |
| 10881 | } |
| 10882 | |
| 10883 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
| 10884 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10885 | } |
| 10886 | catch(std::bad_alloc&) |
| 10887 | { |
| 10888 | return gl::error(GL_OUT_OF_MEMORY); |
| 10889 | } |
| 10890 | } |
| 10891 | |
| 10892 | void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 10893 | { |
| 10894 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)", |
| 10895 | mode, first, count, instanceCount); |
| 10896 | |
| 10897 | try |
| 10898 | { |
| 10899 | gl::Context *context = gl::getNonLostContext(); |
| 10900 | |
| 10901 | if (context) |
| 10902 | { |
| 10903 | if (context->getClientVersion() < 3) |
| 10904 | { |
| 10905 | return gl::error(GL_INVALID_OPERATION); |
| 10906 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10907 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10908 | // glDrawArraysInstanced |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10909 | UNIMPLEMENTED(); |
| 10910 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10911 | } |
| 10912 | catch(std::bad_alloc&) |
| 10913 | { |
| 10914 | return gl::error(GL_OUT_OF_MEMORY); |
| 10915 | } |
| 10916 | } |
| 10917 | |
| 10918 | void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) |
| 10919 | { |
| 10920 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)", |
| 10921 | mode, count, type, indices, instanceCount); |
| 10922 | |
| 10923 | try |
| 10924 | { |
| 10925 | gl::Context *context = gl::getNonLostContext(); |
| 10926 | |
| 10927 | if (context) |
| 10928 | { |
| 10929 | if (context->getClientVersion() < 3) |
| 10930 | { |
| 10931 | return gl::error(GL_INVALID_OPERATION); |
| 10932 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10933 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10934 | // glDrawElementsInstanced |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10935 | UNIMPLEMENTED(); |
| 10936 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10937 | } |
| 10938 | catch(std::bad_alloc&) |
| 10939 | { |
| 10940 | return gl::error(GL_OUT_OF_MEMORY); |
| 10941 | } |
| 10942 | } |
| 10943 | |
| 10944 | GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags) |
| 10945 | { |
| 10946 | EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags); |
| 10947 | |
| 10948 | try |
| 10949 | { |
| 10950 | gl::Context *context = gl::getNonLostContext(); |
| 10951 | |
| 10952 | if (context) |
| 10953 | { |
| 10954 | if (context->getClientVersion() < 3) |
| 10955 | { |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 10956 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(0)); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10957 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10958 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 10959 | if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE) |
| 10960 | { |
| 10961 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLsync>(0)); |
| 10962 | } |
| 10963 | |
| 10964 | if (flags != 0) |
| 10965 | { |
| 10966 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLsync>(0)); |
| 10967 | } |
| 10968 | |
| 10969 | return context->createFenceSync(condition); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10970 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10971 | } |
| 10972 | catch(std::bad_alloc&) |
| 10973 | { |
| 10974 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL)); |
| 10975 | } |
| 10976 | |
| 10977 | return NULL; |
| 10978 | } |
| 10979 | |
| 10980 | GLboolean __stdcall glIsSync(GLsync sync) |
| 10981 | { |
| 10982 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10983 | |
| 10984 | try |
| 10985 | { |
| 10986 | gl::Context *context = gl::getNonLostContext(); |
| 10987 | |
| 10988 | if (context) |
| 10989 | { |
| 10990 | if (context->getClientVersion() < 3) |
| 10991 | { |
| 10992 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10993 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10994 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 10995 | return (context->getFenceSync(sync) != NULL); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10996 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10997 | } |
| 10998 | catch(std::bad_alloc&) |
| 10999 | { |
| 11000 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 11001 | } |
| 11002 | |
| 11003 | return GL_FALSE; |
| 11004 | } |
| 11005 | |
| 11006 | void __stdcall glDeleteSync(GLsync sync) |
| 11007 | { |
| 11008 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 11009 | |
| 11010 | try |
| 11011 | { |
| 11012 | gl::Context *context = gl::getNonLostContext(); |
| 11013 | |
| 11014 | if (context) |
| 11015 | { |
| 11016 | if (context->getClientVersion() < 3) |
| 11017 | { |
| 11018 | return gl::error(GL_INVALID_OPERATION); |
| 11019 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11020 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 11021 | if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync)) |
| 11022 | { |
| 11023 | return gl::error(GL_INVALID_VALUE); |
| 11024 | } |
| 11025 | |
| 11026 | context->deleteFenceSync(sync); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11027 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11028 | } |
| 11029 | catch(std::bad_alloc&) |
| 11030 | { |
| 11031 | return gl::error(GL_OUT_OF_MEMORY); |
| 11032 | } |
| 11033 | } |
| 11034 | |
| 11035 | GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 11036 | { |
| 11037 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 11038 | sync, flags, timeout); |
| 11039 | |
| 11040 | try |
| 11041 | { |
| 11042 | gl::Context *context = gl::getNonLostContext(); |
| 11043 | |
| 11044 | if (context) |
| 11045 | { |
| 11046 | if (context->getClientVersion() < 3) |
| 11047 | { |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 11048 | return gl::error(GL_INVALID_OPERATION, GL_WAIT_FAILED); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11049 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11050 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 11051 | if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0) |
| 11052 | { |
| 11053 | return gl::error(GL_INVALID_VALUE, GL_WAIT_FAILED); |
| 11054 | } |
| 11055 | |
| 11056 | gl::FenceSync *fenceSync = context->getFenceSync(sync); |
| 11057 | |
| 11058 | if (!fenceSync) |
| 11059 | { |
| 11060 | return gl::error(GL_INVALID_VALUE, GL_WAIT_FAILED); |
| 11061 | } |
| 11062 | |
| 11063 | return fenceSync->clientWait(flags, timeout); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11064 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11065 | } |
| 11066 | catch(std::bad_alloc&) |
| 11067 | { |
| 11068 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 11069 | } |
| 11070 | |
| 11071 | return GL_FALSE; |
| 11072 | } |
| 11073 | |
| 11074 | void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 11075 | { |
| 11076 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 11077 | sync, flags, timeout); |
| 11078 | |
| 11079 | try |
| 11080 | { |
| 11081 | gl::Context *context = gl::getNonLostContext(); |
| 11082 | |
| 11083 | if (context) |
| 11084 | { |
| 11085 | if (context->getClientVersion() < 3) |
| 11086 | { |
| 11087 | return gl::error(GL_INVALID_OPERATION); |
| 11088 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11089 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 11090 | if (flags != 0) |
| 11091 | { |
| 11092 | return gl::error(GL_INVALID_VALUE); |
| 11093 | } |
| 11094 | |
| 11095 | if (timeout != GL_TIMEOUT_IGNORED) |
| 11096 | { |
| 11097 | return gl::error(GL_INVALID_VALUE); |
| 11098 | } |
| 11099 | |
| 11100 | gl::FenceSync *fenceSync = context->getFenceSync(sync); |
| 11101 | |
| 11102 | if (!fenceSync) |
| 11103 | { |
| 11104 | return gl::error(GL_INVALID_VALUE); |
| 11105 | } |
| 11106 | |
| 11107 | fenceSync->serverWait(); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11108 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11109 | } |
| 11110 | catch(std::bad_alloc&) |
| 11111 | { |
| 11112 | return gl::error(GL_OUT_OF_MEMORY); |
| 11113 | } |
| 11114 | } |
| 11115 | |
| 11116 | void __stdcall glGetInteger64v(GLenum pname, GLint64* params) |
| 11117 | { |
| 11118 | EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 11119 | pname, params); |
| 11120 | |
| 11121 | try |
| 11122 | { |
| 11123 | gl::Context *context = gl::getNonLostContext(); |
| 11124 | |
| 11125 | if (context) |
| 11126 | { |
| 11127 | if (context->getClientVersion() < 3) |
| 11128 | { |
| 11129 | return gl::error(GL_INVALID_OPERATION); |
| 11130 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11131 | |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 11132 | if (!(context->getInteger64v(pname, params))) |
| 11133 | { |
| 11134 | GLenum nativeType; |
| 11135 | unsigned int numParams = 0; |
| 11136 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
| 11137 | return gl::error(GL_INVALID_ENUM); |
| 11138 | |
| 11139 | if (numParams == 0) |
| 11140 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 11141 | |
| 11142 | if (nativeType == GL_BOOL) |
| 11143 | { |
| 11144 | GLboolean *boolParams = NULL; |
| 11145 | boolParams = new GLboolean[numParams]; |
| 11146 | |
| 11147 | context->getBooleanv(pname, boolParams); |
| 11148 | |
| 11149 | for (unsigned int i = 0; i < numParams; ++i) |
| 11150 | { |
| 11151 | if (boolParams[i] == GL_FALSE) |
| 11152 | params[i] = 0; |
| 11153 | else |
| 11154 | params[i] = 1; |
| 11155 | } |
| 11156 | |
| 11157 | delete [] boolParams; |
| 11158 | } |
| 11159 | else if (nativeType == GL_INT) |
| 11160 | { |
| 11161 | GLint *intParams = NULL; |
| 11162 | intParams = new GLint[numParams]; |
| 11163 | |
| 11164 | context->getIntegerv(pname, intParams); |
| 11165 | |
| 11166 | for (unsigned int i = 0; i < numParams; ++i) |
| 11167 | { |
| 11168 | params[i] = static_cast<GLint64>(intParams[i]); |
| 11169 | } |
| 11170 | |
| 11171 | delete [] intParams; |
| 11172 | } |
| 11173 | else if (nativeType == GL_FLOAT) |
| 11174 | { |
| 11175 | GLfloat *floatParams = NULL; |
| 11176 | floatParams = new GLfloat[numParams]; |
| 11177 | |
| 11178 | context->getFloatv(pname, floatParams); |
| 11179 | |
| 11180 | for (unsigned int i = 0; i < numParams; ++i) |
| 11181 | { |
| 11182 | // RGBA color values and DepthRangeF values are converted to integer using Equation 2.4 from Table 4.5 |
| 11183 | if (pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE || pname == GL_BLEND_COLOR) |
| 11184 | { |
| 11185 | params[i] = static_cast<GLint64>((static_cast<GLfloat>(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f); |
| 11186 | } |
| 11187 | else |
| 11188 | { |
| 11189 | params[i] = gl::iround<GLint64>(floatParams[i]); |
| 11190 | } |
| 11191 | } |
| 11192 | |
| 11193 | delete [] floatParams; |
| 11194 | } |
| 11195 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11196 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11197 | } |
| 11198 | catch(std::bad_alloc&) |
| 11199 | { |
| 11200 | return gl::error(GL_OUT_OF_MEMORY); |
| 11201 | } |
| 11202 | } |
| 11203 | |
| 11204 | void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) |
| 11205 | { |
| 11206 | EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)", |
| 11207 | sync, pname, bufSize, length, values); |
| 11208 | |
| 11209 | try |
| 11210 | { |
| 11211 | gl::Context *context = gl::getNonLostContext(); |
| 11212 | |
| 11213 | if (context) |
| 11214 | { |
| 11215 | if (context->getClientVersion() < 3) |
| 11216 | { |
| 11217 | return gl::error(GL_INVALID_OPERATION); |
| 11218 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11219 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 11220 | if (bufSize < 0) |
| 11221 | { |
| 11222 | return gl::error(GL_INVALID_VALUE); |
| 11223 | } |
| 11224 | |
| 11225 | gl::FenceSync *fenceSync = context->getFenceSync(sync); |
| 11226 | |
| 11227 | if (!fenceSync) |
| 11228 | { |
| 11229 | return gl::error(GL_INVALID_VALUE); |
| 11230 | } |
| 11231 | |
| 11232 | switch (pname) |
| 11233 | { |
| 11234 | case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break; |
| 11235 | case GL_SYNC_STATUS: values[0] = static_cast<GLint>(fenceSync->getStatus()); break; |
| 11236 | case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break; |
| 11237 | case GL_SYNC_FLAGS: values[0] = 0; break; |
| 11238 | |
| 11239 | default: |
| 11240 | return gl::error(GL_INVALID_ENUM); |
| 11241 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11242 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11243 | } |
| 11244 | catch(std::bad_alloc&) |
| 11245 | { |
| 11246 | return gl::error(GL_OUT_OF_MEMORY); |
| 11247 | } |
| 11248 | } |
| 11249 | |
| 11250 | void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) |
| 11251 | { |
| 11252 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)", |
| 11253 | target, index, data); |
| 11254 | |
| 11255 | try |
| 11256 | { |
| 11257 | gl::Context *context = gl::getNonLostContext(); |
| 11258 | |
| 11259 | if (context) |
| 11260 | { |
| 11261 | if (context->getClientVersion() < 3) |
| 11262 | { |
| 11263 | return gl::error(GL_INVALID_OPERATION); |
| 11264 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11265 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11266 | // glGetInteger64i_v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11267 | UNIMPLEMENTED(); |
| 11268 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11269 | } |
| 11270 | catch(std::bad_alloc&) |
| 11271 | { |
| 11272 | return gl::error(GL_OUT_OF_MEMORY); |
| 11273 | } |
| 11274 | } |
| 11275 | |
| 11276 | void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) |
| 11277 | { |
| 11278 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 11279 | target, pname, params); |
| 11280 | |
| 11281 | try |
| 11282 | { |
| 11283 | gl::Context *context = gl::getNonLostContext(); |
| 11284 | |
| 11285 | if (context) |
| 11286 | { |
| 11287 | if (context->getClientVersion() < 3) |
| 11288 | { |
| 11289 | return gl::error(GL_INVALID_OPERATION); |
| 11290 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11291 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11292 | // glGetBufferParameteri64v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11293 | UNIMPLEMENTED(); |
| 11294 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11295 | } |
| 11296 | catch(std::bad_alloc&) |
| 11297 | { |
| 11298 | return gl::error(GL_OUT_OF_MEMORY); |
| 11299 | } |
| 11300 | } |
| 11301 | |
| 11302 | void __stdcall glGenSamplers(GLsizei count, GLuint* samplers) |
| 11303 | { |
| 11304 | EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers); |
| 11305 | |
| 11306 | try |
| 11307 | { |
| 11308 | gl::Context *context = gl::getNonLostContext(); |
| 11309 | |
| 11310 | if (context) |
| 11311 | { |
| 11312 | if (context->getClientVersion() < 3) |
| 11313 | { |
| 11314 | return gl::error(GL_INVALID_OPERATION); |
| 11315 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11316 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11317 | if (count < 0) |
| 11318 | { |
| 11319 | return gl::error(GL_INVALID_VALUE); |
| 11320 | } |
| 11321 | |
| 11322 | for (int i = 0; i < count; i++) |
| 11323 | { |
| 11324 | samplers[i] = context->createSampler(); |
| 11325 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11326 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11327 | } |
| 11328 | catch(std::bad_alloc&) |
| 11329 | { |
| 11330 | return gl::error(GL_OUT_OF_MEMORY); |
| 11331 | } |
| 11332 | } |
| 11333 | |
| 11334 | void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers) |
| 11335 | { |
| 11336 | EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers); |
| 11337 | |
| 11338 | try |
| 11339 | { |
| 11340 | gl::Context *context = gl::getNonLostContext(); |
| 11341 | |
| 11342 | if (context) |
| 11343 | { |
| 11344 | if (context->getClientVersion() < 3) |
| 11345 | { |
| 11346 | return gl::error(GL_INVALID_OPERATION); |
| 11347 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11348 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11349 | if (count < 0) |
| 11350 | { |
| 11351 | return gl::error(GL_INVALID_VALUE); |
| 11352 | } |
| 11353 | |
| 11354 | for (int i = 0; i < count; i++) |
| 11355 | { |
| 11356 | context->deleteSampler(samplers[i]); |
| 11357 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11358 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11359 | } |
| 11360 | catch(std::bad_alloc&) |
| 11361 | { |
| 11362 | return gl::error(GL_OUT_OF_MEMORY); |
| 11363 | } |
| 11364 | } |
| 11365 | |
| 11366 | GLboolean __stdcall glIsSampler(GLuint sampler) |
| 11367 | { |
| 11368 | EVENT("(GLuint sampler = %u)", sampler); |
| 11369 | |
| 11370 | try |
| 11371 | { |
| 11372 | gl::Context *context = gl::getNonLostContext(); |
| 11373 | |
| 11374 | if (context) |
| 11375 | { |
| 11376 | if (context->getClientVersion() < 3) |
| 11377 | { |
| 11378 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 11379 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11380 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11381 | return context->isSampler(sampler); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 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, GL_FALSE); |
| 11387 | } |
| 11388 | |
| 11389 | return GL_FALSE; |
| 11390 | } |
| 11391 | |
| 11392 | void __stdcall glBindSampler(GLuint unit, GLuint sampler) |
| 11393 | { |
| 11394 | EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler); |
| 11395 | |
| 11396 | try |
| 11397 | { |
| 11398 | gl::Context *context = gl::getNonLostContext(); |
| 11399 | |
| 11400 | if (context) |
| 11401 | { |
| 11402 | if (context->getClientVersion() < 3) |
| 11403 | { |
| 11404 | return gl::error(GL_INVALID_OPERATION); |
| 11405 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11406 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11407 | if (sampler != 0 && !context->isSampler(sampler)) |
| 11408 | { |
| 11409 | return gl::error(GL_INVALID_OPERATION); |
| 11410 | } |
| 11411 | |
| 11412 | if (unit >= context->getMaximumCombinedTextureImageUnits()) |
| 11413 | { |
| 11414 | return gl::error(GL_INVALID_VALUE); |
| 11415 | } |
| 11416 | |
| 11417 | context->bindSampler(unit, sampler); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11418 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11419 | } |
| 11420 | catch(std::bad_alloc&) |
| 11421 | { |
| 11422 | return gl::error(GL_OUT_OF_MEMORY); |
| 11423 | } |
| 11424 | } |
| 11425 | |
| 11426 | void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 11427 | { |
| 11428 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param); |
| 11429 | |
| 11430 | try |
| 11431 | { |
| 11432 | gl::Context *context = gl::getNonLostContext(); |
| 11433 | |
| 11434 | if (context) |
| 11435 | { |
| 11436 | if (context->getClientVersion() < 3) |
| 11437 | { |
| 11438 | return gl::error(GL_INVALID_OPERATION); |
| 11439 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11440 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11441 | if (!validateSamplerObjectParameter(pname)) |
| 11442 | { |
| 11443 | return; |
| 11444 | } |
| 11445 | |
| 11446 | if (!validateTexParamParameters(context, pname, param)) |
| 11447 | { |
| 11448 | return; |
| 11449 | } |
| 11450 | |
| 11451 | if (!context->isSampler(sampler)) |
| 11452 | { |
| 11453 | return gl::error(GL_INVALID_OPERATION); |
| 11454 | } |
| 11455 | |
| 11456 | context->samplerParameteri(sampler, pname, param); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11457 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11458 | } |
| 11459 | catch(std::bad_alloc&) |
| 11460 | { |
| 11461 | return gl::error(GL_OUT_OF_MEMORY); |
| 11462 | } |
| 11463 | } |
| 11464 | |
| 11465 | void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) |
| 11466 | { |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11467 | glSamplerParameteri(sampler, pname, *param); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11468 | } |
| 11469 | |
| 11470 | void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 11471 | { |
| 11472 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param); |
| 11473 | |
| 11474 | try |
| 11475 | { |
| 11476 | gl::Context *context = gl::getNonLostContext(); |
| 11477 | |
| 11478 | if (context) |
| 11479 | { |
| 11480 | if (context->getClientVersion() < 3) |
| 11481 | { |
| 11482 | return gl::error(GL_INVALID_OPERATION); |
| 11483 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11484 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11485 | if (!validateSamplerObjectParameter(pname)) |
| 11486 | { |
| 11487 | return; |
| 11488 | } |
| 11489 | |
| 11490 | if (!validateTexParamParameters(context, pname, static_cast<GLint>(param))) |
| 11491 | { |
| 11492 | return; |
| 11493 | } |
| 11494 | |
| 11495 | if (!context->isSampler(sampler)) |
| 11496 | { |
| 11497 | return gl::error(GL_INVALID_OPERATION); |
| 11498 | } |
| 11499 | |
| 11500 | context->samplerParameterf(sampler, pname, param); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11501 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11502 | } |
| 11503 | catch(std::bad_alloc&) |
| 11504 | { |
| 11505 | return gl::error(GL_OUT_OF_MEMORY); |
| 11506 | } |
| 11507 | } |
| 11508 | |
| 11509 | void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) |
| 11510 | { |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11511 | glSamplerParameterf(sampler, pname, *param); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11512 | } |
| 11513 | |
| 11514 | void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) |
| 11515 | { |
| 11516 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); |
| 11517 | |
| 11518 | try |
| 11519 | { |
| 11520 | gl::Context *context = gl::getNonLostContext(); |
| 11521 | |
| 11522 | if (context) |
| 11523 | { |
| 11524 | if (context->getClientVersion() < 3) |
| 11525 | { |
| 11526 | return gl::error(GL_INVALID_OPERATION); |
| 11527 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11528 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11529 | if (!validateSamplerObjectParameter(pname)) |
| 11530 | { |
| 11531 | return; |
| 11532 | } |
| 11533 | |
| 11534 | if (!context->isSampler(sampler)) |
| 11535 | { |
| 11536 | return gl::error(GL_INVALID_OPERATION); |
| 11537 | } |
| 11538 | |
| 11539 | *params = context->getSamplerParameteri(sampler, pname); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11540 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11541 | } |
| 11542 | catch(std::bad_alloc&) |
| 11543 | { |
| 11544 | return gl::error(GL_OUT_OF_MEMORY); |
| 11545 | } |
| 11546 | } |
| 11547 | |
| 11548 | void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) |
| 11549 | { |
| 11550 | EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params); |
| 11551 | |
| 11552 | try |
| 11553 | { |
| 11554 | gl::Context *context = gl::getNonLostContext(); |
| 11555 | |
| 11556 | if (context) |
| 11557 | { |
| 11558 | if (context->getClientVersion() < 3) |
| 11559 | { |
| 11560 | return gl::error(GL_INVALID_OPERATION); |
| 11561 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11562 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11563 | if (!validateSamplerObjectParameter(pname)) |
| 11564 | { |
| 11565 | return; |
| 11566 | } |
| 11567 | |
| 11568 | if (!context->isSampler(sampler)) |
| 11569 | { |
| 11570 | return gl::error(GL_INVALID_OPERATION); |
| 11571 | } |
| 11572 | |
| 11573 | *params = context->getSamplerParameterf(sampler, pname); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11574 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11575 | } |
| 11576 | catch(std::bad_alloc&) |
| 11577 | { |
| 11578 | return gl::error(GL_OUT_OF_MEMORY); |
| 11579 | } |
| 11580 | } |
| 11581 | |
| 11582 | void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor) |
| 11583 | { |
| 11584 | EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor); |
| 11585 | |
| 11586 | try |
| 11587 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 11588 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 11589 | { |
| 11590 | return gl::error(GL_INVALID_VALUE); |
| 11591 | } |
| 11592 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11593 | gl::Context *context = gl::getNonLostContext(); |
| 11594 | |
| 11595 | if (context) |
| 11596 | { |
| 11597 | if (context->getClientVersion() < 3) |
| 11598 | { |
| 11599 | return gl::error(GL_INVALID_OPERATION); |
| 11600 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11601 | |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 11602 | context->setVertexAttribDivisor(index, divisor); |
| 11603 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11604 | } |
| 11605 | catch(std::bad_alloc&) |
| 11606 | { |
| 11607 | return gl::error(GL_OUT_OF_MEMORY); |
| 11608 | } |
| 11609 | } |
| 11610 | |
| 11611 | void __stdcall glBindTransformFeedback(GLenum target, GLuint id) |
| 11612 | { |
| 11613 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 11614 | |
| 11615 | try |
| 11616 | { |
| 11617 | gl::Context *context = gl::getNonLostContext(); |
| 11618 | |
| 11619 | if (context) |
| 11620 | { |
| 11621 | if (context->getClientVersion() < 3) |
| 11622 | { |
| 11623 | return gl::error(GL_INVALID_OPERATION); |
| 11624 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11625 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11626 | // glBindTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11627 | UNIMPLEMENTED(); |
| 11628 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11629 | } |
| 11630 | catch(std::bad_alloc&) |
| 11631 | { |
| 11632 | return gl::error(GL_OUT_OF_MEMORY); |
| 11633 | } |
| 11634 | } |
| 11635 | |
| 11636 | void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) |
| 11637 | { |
| 11638 | EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids); |
| 11639 | |
| 11640 | try |
| 11641 | { |
| 11642 | gl::Context *context = gl::getNonLostContext(); |
| 11643 | |
| 11644 | if (context) |
| 11645 | { |
| 11646 | if (context->getClientVersion() < 3) |
| 11647 | { |
| 11648 | return gl::error(GL_INVALID_OPERATION); |
| 11649 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11650 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11651 | // glDeleteTransformFeedbacks |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11652 | UNIMPLEMENTED(); |
| 11653 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11654 | } |
| 11655 | catch(std::bad_alloc&) |
| 11656 | { |
| 11657 | return gl::error(GL_OUT_OF_MEMORY); |
| 11658 | } |
| 11659 | } |
| 11660 | |
| 11661 | void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids) |
| 11662 | { |
| 11663 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 11664 | |
| 11665 | try |
| 11666 | { |
| 11667 | gl::Context *context = gl::getNonLostContext(); |
| 11668 | |
| 11669 | if (context) |
| 11670 | { |
| 11671 | if (context->getClientVersion() < 3) |
| 11672 | { |
| 11673 | return gl::error(GL_INVALID_OPERATION); |
| 11674 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11675 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11676 | // glGenTransformFeedbacks |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11677 | UNIMPLEMENTED(); |
| 11678 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11679 | } |
| 11680 | catch(std::bad_alloc&) |
| 11681 | { |
| 11682 | return gl::error(GL_OUT_OF_MEMORY); |
| 11683 | } |
| 11684 | } |
| 11685 | |
| 11686 | GLboolean __stdcall glIsTransformFeedback(GLuint id) |
| 11687 | { |
| 11688 | EVENT("(GLuint id = %u)", id); |
| 11689 | |
| 11690 | try |
| 11691 | { |
| 11692 | gl::Context *context = gl::getNonLostContext(); |
| 11693 | |
| 11694 | if (context) |
| 11695 | { |
| 11696 | if (context->getClientVersion() < 3) |
| 11697 | { |
| 11698 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 11699 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11700 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11701 | // glIsTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11702 | UNIMPLEMENTED(); |
| 11703 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11704 | } |
| 11705 | catch(std::bad_alloc&) |
| 11706 | { |
| 11707 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 11708 | } |
| 11709 | |
| 11710 | return GL_FALSE; |
| 11711 | } |
| 11712 | |
| 11713 | void __stdcall glPauseTransformFeedback(void) |
| 11714 | { |
| 11715 | EVENT("(void)"); |
| 11716 | |
| 11717 | try |
| 11718 | { |
| 11719 | gl::Context *context = gl::getNonLostContext(); |
| 11720 | |
| 11721 | if (context) |
| 11722 | { |
| 11723 | if (context->getClientVersion() < 3) |
| 11724 | { |
| 11725 | return gl::error(GL_INVALID_OPERATION); |
| 11726 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11727 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11728 | // glPauseTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11729 | UNIMPLEMENTED(); |
| 11730 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11731 | } |
| 11732 | catch(std::bad_alloc&) |
| 11733 | { |
| 11734 | return gl::error(GL_OUT_OF_MEMORY); |
| 11735 | } |
| 11736 | } |
| 11737 | |
| 11738 | void __stdcall glResumeTransformFeedback(void) |
| 11739 | { |
| 11740 | EVENT("(void)"); |
| 11741 | |
| 11742 | try |
| 11743 | { |
| 11744 | gl::Context *context = gl::getNonLostContext(); |
| 11745 | |
| 11746 | if (context) |
| 11747 | { |
| 11748 | if (context->getClientVersion() < 3) |
| 11749 | { |
| 11750 | return gl::error(GL_INVALID_OPERATION); |
| 11751 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11752 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11753 | // glResumeTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11754 | UNIMPLEMENTED(); |
| 11755 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11756 | } |
| 11757 | catch(std::bad_alloc&) |
| 11758 | { |
| 11759 | return gl::error(GL_OUT_OF_MEMORY); |
| 11760 | } |
| 11761 | } |
| 11762 | |
| 11763 | void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) |
| 11764 | { |
| 11765 | EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)", |
| 11766 | program, bufSize, length, binaryFormat, binary); |
| 11767 | |
| 11768 | try |
| 11769 | { |
| 11770 | gl::Context *context = gl::getNonLostContext(); |
| 11771 | |
| 11772 | if (context) |
| 11773 | { |
| 11774 | if (context->getClientVersion() < 3) |
| 11775 | { |
| 11776 | return gl::error(GL_INVALID_OPERATION); |
| 11777 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11778 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11779 | // glGetProgramBinary |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11780 | UNIMPLEMENTED(); |
| 11781 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11782 | } |
| 11783 | catch(std::bad_alloc&) |
| 11784 | { |
| 11785 | return gl::error(GL_OUT_OF_MEMORY); |
| 11786 | } |
| 11787 | } |
| 11788 | |
| 11789 | void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) |
| 11790 | { |
| 11791 | EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
| 11792 | program, binaryFormat, binary, length); |
| 11793 | |
| 11794 | try |
| 11795 | { |
| 11796 | gl::Context *context = gl::getNonLostContext(); |
| 11797 | |
| 11798 | if (context) |
| 11799 | { |
| 11800 | if (context->getClientVersion() < 3) |
| 11801 | { |
| 11802 | return gl::error(GL_INVALID_OPERATION); |
| 11803 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11804 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11805 | // glProgramBinary |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11806 | UNIMPLEMENTED(); |
| 11807 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11808 | } |
| 11809 | catch(std::bad_alloc&) |
| 11810 | { |
| 11811 | return gl::error(GL_OUT_OF_MEMORY); |
| 11812 | } |
| 11813 | } |
| 11814 | |
| 11815 | void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value) |
| 11816 | { |
| 11817 | EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)", |
| 11818 | program, pname, value); |
| 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 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11830 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11831 | // glProgramParameteri |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11832 | UNIMPLEMENTED(); |
| 11833 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11834 | } |
| 11835 | catch(std::bad_alloc&) |
| 11836 | { |
| 11837 | return gl::error(GL_OUT_OF_MEMORY); |
| 11838 | } |
| 11839 | } |
| 11840 | |
| 11841 | void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) |
| 11842 | { |
| 11843 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)", |
| 11844 | target, numAttachments, attachments); |
| 11845 | |
| 11846 | try |
| 11847 | { |
| 11848 | gl::Context *context = gl::getNonLostContext(); |
| 11849 | |
| 11850 | if (context) |
| 11851 | { |
| 11852 | if (context->getClientVersion() < 3) |
| 11853 | { |
| 11854 | return gl::error(GL_INVALID_OPERATION); |
| 11855 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11856 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11857 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11858 | { |
| 11859 | return; |
| 11860 | } |
| 11861 | |
| 11862 | int maxDimension = context->getMaximumRenderbufferDimension(); |
| 11863 | context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension); |
| 11864 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11865 | } |
| 11866 | catch(std::bad_alloc&) |
| 11867 | { |
| 11868 | return gl::error(GL_OUT_OF_MEMORY); |
| 11869 | } |
| 11870 | } |
| 11871 | |
| 11872 | void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) |
| 11873 | { |
| 11874 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, " |
| 11875 | "GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 11876 | target, numAttachments, attachments, x, y, width, height); |
| 11877 | |
| 11878 | try |
| 11879 | { |
| 11880 | gl::Context *context = gl::getNonLostContext(); |
| 11881 | |
| 11882 | if (context) |
| 11883 | { |
| 11884 | if (context->getClientVersion() < 3) |
| 11885 | { |
| 11886 | return gl::error(GL_INVALID_OPERATION); |
| 11887 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11888 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11889 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11890 | { |
| 11891 | return; |
| 11892 | } |
| 11893 | |
| 11894 | context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height); |
| 11895 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11896 | } |
| 11897 | catch(std::bad_alloc&) |
| 11898 | { |
| 11899 | return gl::error(GL_OUT_OF_MEMORY); |
| 11900 | } |
| 11901 | } |
| 11902 | |
| 11903 | void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 11904 | { |
| 11905 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 11906 | target, levels, internalformat, width, height); |
| 11907 | |
| 11908 | try |
| 11909 | { |
| 11910 | gl::Context *context = gl::getNonLostContext(); |
| 11911 | |
| 11912 | if (context) |
| 11913 | { |
| 11914 | if (context->getClientVersion() < 3) |
| 11915 | { |
| 11916 | return gl::error(GL_INVALID_OPERATION); |
| 11917 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11918 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11919 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 11920 | { |
| 11921 | return; |
| 11922 | } |
| 11923 | |
| 11924 | switch (target) |
| 11925 | { |
| 11926 | case GL_TEXTURE_2D: |
| 11927 | { |
| 11928 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 11929 | texture2d->storage(levels, internalformat, width, height); |
| 11930 | } |
| 11931 | break; |
| 11932 | |
| 11933 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 11934 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 11935 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 11936 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 11937 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 11938 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 11939 | { |
| 11940 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 11941 | textureCube->storage(levels, internalformat, width); |
| 11942 | } |
| 11943 | break; |
| 11944 | |
| 11945 | default: |
| 11946 | return gl::error(GL_INVALID_ENUM); |
| 11947 | } |
| 11948 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11949 | } |
| 11950 | catch(std::bad_alloc&) |
| 11951 | { |
| 11952 | return gl::error(GL_OUT_OF_MEMORY); |
| 11953 | } |
| 11954 | } |
| 11955 | |
| 11956 | void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
| 11957 | { |
| 11958 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 11959 | "GLsizei height = %d, GLsizei depth = %d)", |
| 11960 | target, levels, internalformat, width, height, depth); |
| 11961 | |
| 11962 | try |
| 11963 | { |
| 11964 | gl::Context *context = gl::getNonLostContext(); |
| 11965 | |
| 11966 | if (context) |
| 11967 | { |
| 11968 | if (context->getClientVersion() < 3) |
| 11969 | { |
| 11970 | return gl::error(GL_INVALID_OPERATION); |
| 11971 | } |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11972 | |
| 11973 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) |
| 11974 | { |
| 11975 | return; |
| 11976 | } |
| 11977 | |
| 11978 | switch (target) |
| 11979 | { |
| 11980 | case GL_TEXTURE_3D: |
| 11981 | { |
| 11982 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 11983 | texture3d->storage(levels, internalformat, width, height, depth); |
| 11984 | } |
| 11985 | break; |
| 11986 | |
| 11987 | case GL_TEXTURE_2D_ARRAY: |
| 11988 | { |
| 11989 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 11990 | texture2darray->storage(levels, internalformat, width, height, depth); |
| 11991 | } |
| 11992 | break; |
| 11993 | |
| 11994 | default: |
| 11995 | return gl::error(GL_INVALID_ENUM); |
| 11996 | } |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 11997 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11998 | } |
| 11999 | catch(std::bad_alloc&) |
| 12000 | { |
| 12001 | return gl::error(GL_OUT_OF_MEMORY); |
| 12002 | } |
| 12003 | } |
| 12004 | |
| 12005 | void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) |
| 12006 | { |
| 12007 | EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, " |
| 12008 | "GLint* params = 0x%0.8p)", |
| 12009 | target, internalformat, pname, bufSize, params); |
| 12010 | |
| 12011 | try |
| 12012 | { |
| 12013 | gl::Context *context = gl::getNonLostContext(); |
| 12014 | |
| 12015 | if (context) |
| 12016 | { |
| 12017 | if (context->getClientVersion() < 3) |
| 12018 | { |
| 12019 | return gl::error(GL_INVALID_OPERATION); |
| 12020 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 12021 | |
Shannon Woods | 809d250 | 2013-07-08 10:32:18 -0400 | [diff] [blame] | 12022 | if (!gl::IsColorRenderingSupported(internalformat, context) && |
| 12023 | !gl::IsDepthRenderingSupported(internalformat, context) && |
| 12024 | !gl::IsStencilRenderingSupported(internalformat, context)) |
| 12025 | { |
| 12026 | return gl::error(GL_INVALID_ENUM); |
| 12027 | } |
| 12028 | |
| 12029 | if (target != GL_RENDERBUFFER) |
| 12030 | { |
| 12031 | return gl::error(GL_INVALID_ENUM); |
| 12032 | } |
| 12033 | |
| 12034 | if (bufSize < 0) |
| 12035 | { |
| 12036 | return gl::error(GL_INVALID_VALUE); |
| 12037 | } |
| 12038 | |
| 12039 | switch (pname) |
| 12040 | { |
| 12041 | case GL_NUM_SAMPLE_COUNTS: |
| 12042 | if (bufSize != 0) |
| 12043 | *params = context->getNumSampleCounts(internalformat); |
| 12044 | break; |
| 12045 | case GL_SAMPLES: |
| 12046 | context->getSampleCounts(internalformat, bufSize, params); |
| 12047 | break; |
| 12048 | default: |
| 12049 | return gl::error(GL_INVALID_ENUM); |
| 12050 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 12051 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 12052 | } |
| 12053 | catch(std::bad_alloc&) |
| 12054 | { |
| 12055 | return gl::error(GL_OUT_OF_MEMORY); |
| 12056 | } |
| 12057 | } |
| 12058 | |
| 12059 | // Extension functions |
| 12060 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 12061 | void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 12062 | GLbitfield mask, GLenum filter) |
| 12063 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 12064 | 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] | 12065 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, " |
| 12066 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 12067 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 12068 | |
| 12069 | try |
| 12070 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 12071 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 12072 | |
| 12073 | if (context) |
| 12074 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 12075 | if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 12076 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 12077 | true)) |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 12078 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 12079 | return; |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 12080 | } |
| 12081 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 12082 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 12083 | mask, filter); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 12084 | } |
| 12085 | } |
| 12086 | catch(std::bad_alloc&) |
| 12087 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12088 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 12089 | } |
| 12090 | } |
| 12091 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 12092 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, |
| 12093 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 12094 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 12095 | 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] | 12096 | "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] | 12097 | "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] | 12098 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 12099 | |
| 12100 | try |
| 12101 | { |
| 12102 | UNIMPLEMENTED(); // FIXME |
| 12103 | } |
| 12104 | catch(std::bad_alloc&) |
| 12105 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12106 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 12107 | } |
| 12108 | } |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12109 | |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12110 | void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, |
| 12111 | GLenum *binaryFormat, void *binary) |
| 12112 | { |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 12113 | 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] | 12114 | program, bufSize, length, binaryFormat, binary); |
| 12115 | |
| 12116 | try |
| 12117 | { |
| 12118 | gl::Context *context = gl::getNonLostContext(); |
| 12119 | |
| 12120 | if (context) |
| 12121 | { |
| 12122 | gl::Program *programObject = context->getProgram(program); |
| 12123 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 12124 | if (!programObject || !programObject->isLinked()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12125 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12126 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12127 | } |
| 12128 | |
| 12129 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 12130 | |
| 12131 | if (!programBinary) |
| 12132 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12133 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12134 | } |
| 12135 | |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 12136 | if (!programBinary->save(binary, bufSize, length)) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12137 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12138 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12139 | } |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 12140 | |
| 12141 | *binaryFormat = GL_PROGRAM_BINARY_ANGLE; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12142 | } |
| 12143 | } |
| 12144 | catch(std::bad_alloc&) |
| 12145 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12146 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12147 | } |
| 12148 | } |
| 12149 | |
| 12150 | void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat, |
| 12151 | const void *binary, GLint length) |
| 12152 | { |
| 12153 | EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)", |
| 12154 | program, binaryFormat, binary, length); |
| 12155 | |
| 12156 | try |
| 12157 | { |
| 12158 | gl::Context *context = gl::getNonLostContext(); |
| 12159 | |
| 12160 | if (context) |
| 12161 | { |
| 12162 | if (binaryFormat != GL_PROGRAM_BINARY_ANGLE) |
| 12163 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12164 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12165 | } |
| 12166 | |
| 12167 | gl::Program *programObject = context->getProgram(program); |
| 12168 | |
| 12169 | if (!programObject) |
| 12170 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12171 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12172 | } |
| 12173 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 12174 | context->setProgramBinary(program, binary, length); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12175 | } |
| 12176 | } |
| 12177 | catch(std::bad_alloc&) |
| 12178 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12179 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12180 | } |
| 12181 | } |
| 12182 | |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12183 | void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) |
| 12184 | { |
| 12185 | EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs); |
| 12186 | |
| 12187 | try |
| 12188 | { |
| 12189 | gl::Context *context = gl::getNonLostContext(); |
| 12190 | |
| 12191 | if (context) |
| 12192 | { |
| 12193 | if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets()) |
| 12194 | { |
| 12195 | return gl::error(GL_INVALID_VALUE); |
| 12196 | } |
| 12197 | |
| 12198 | if (context->getDrawFramebufferHandle() == 0) |
| 12199 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12200 | if (n != 1) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12201 | { |
| 12202 | return gl::error(GL_INVALID_OPERATION); |
| 12203 | } |
| 12204 | |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12205 | 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] | 12206 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12207 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12208 | } |
| 12209 | } |
| 12210 | else |
| 12211 | { |
| 12212 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 12213 | { |
| 12214 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 12215 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment) |
| 12216 | { |
| 12217 | return gl::error(GL_INVALID_OPERATION); |
| 12218 | } |
| 12219 | } |
| 12220 | } |
| 12221 | |
| 12222 | gl::Framebuffer *framebuffer = context->getDrawFramebuffer(); |
| 12223 | |
| 12224 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 12225 | { |
| 12226 | framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]); |
| 12227 | } |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12228 | |
| 12229 | for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++) |
| 12230 | { |
| 12231 | framebuffer->setDrawBufferState(colorAttachment, GL_NONE); |
| 12232 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12233 | } |
| 12234 | } |
| 12235 | catch (std::bad_alloc&) |
| 12236 | { |
| 12237 | return gl::error(GL_OUT_OF_MEMORY); |
| 12238 | } |
| 12239 | } |
| 12240 | |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12241 | __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) |
| 12242 | { |
| 12243 | struct Extension |
| 12244 | { |
| 12245 | const char *name; |
| 12246 | __eglMustCastToProperFunctionPointerType address; |
| 12247 | }; |
| 12248 | |
| 12249 | static const Extension glExtensions[] = |
| 12250 | { |
| 12251 | {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 12252 | {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, |
daniel@transgaming.com | 1fe96c9 | 2011-01-14 15:08:44 +0000 | [diff] [blame] | 12253 | {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 12254 | {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, |
| 12255 | {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, |
| 12256 | {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, |
| 12257 | {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, |
| 12258 | {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, |
| 12259 | {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, |
| 12260 | {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 12261 | {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE}, |
daniel@transgaming.com | 0bd1f2f | 2011-11-11 04:19:03 +0000 | [diff] [blame] | 12262 | {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT}, |
daniel@transgaming.com | 709ed11 | 2011-11-12 03:18:10 +0000 | [diff] [blame] | 12263 | {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT}, |
| 12264 | {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT}, |
| 12265 | {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT}, |
| 12266 | {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT}, |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 12267 | {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT}, |
| 12268 | {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT}, |
| 12269 | {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT}, |
| 12270 | {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT}, |
| 12271 | {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT}, |
| 12272 | {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT}, |
| 12273 | {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT}, |
shannon.woods%transgaming.com@gtempaccount.com | 77d9472 | 2013-04-13 03:34:22 +0000 | [diff] [blame] | 12274 | {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT}, |
daniel@transgaming.com | dce02fd | 2012-01-27 15:39:51 +0000 | [diff] [blame] | 12275 | {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE}, |
| 12276 | {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, |
| 12277 | {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12278 | {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, |
| 12279 | {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, }; |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12280 | |
shannon.woods@transgaming.com | d438fd4 | 2013-02-28 23:17:45 +0000 | [diff] [blame] | 12281 | for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12282 | { |
| 12283 | if (strcmp(procname, glExtensions[ext].name) == 0) |
| 12284 | { |
| 12285 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address; |
| 12286 | } |
| 12287 | } |
| 12288 | |
| 12289 | return NULL; |
| 12290 | } |
| 12291 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 12292 | // Non-public functions used by EGL |
| 12293 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 12294 | bool __stdcall glBindTexImage(egl::Surface *surface) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12295 | { |
| 12296 | EVENT("(egl::Surface* surface = 0x%0.8p)", |
| 12297 | surface); |
| 12298 | |
| 12299 | try |
| 12300 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 12301 | gl::Context *context = gl::getNonLostContext(); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12302 | |
| 12303 | if (context) |
| 12304 | { |
| 12305 | gl::Texture2D *textureObject = context->getTexture2D(); |
| 12306 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 12307 | if (textureObject->isImmutable()) |
| 12308 | { |
| 12309 | return false; |
| 12310 | } |
| 12311 | |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12312 | if (textureObject) |
| 12313 | { |
| 12314 | textureObject->bindTexImage(surface); |
| 12315 | } |
| 12316 | } |
| 12317 | } |
| 12318 | catch(std::bad_alloc&) |
| 12319 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12320 | return gl::error(GL_OUT_OF_MEMORY, false); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12321 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 12322 | |
| 12323 | return true; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12324 | } |
| 12325 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 12326 | } |